diff --git a/service/Application/Admin/Controller/ArticleController.class.php b/service/Application/Admin/Controller/ArticleController.class.php
index 77edacb83..fc0ff6f4d 100755
--- a/service/Application/Admin/Controller/ArticleController.class.php
+++ b/service/Application/Admin/Controller/ArticleController.class.php
@@ -2,6 +2,8 @@
namespace Admin\Controller;
+use Service\ResourcesService;
+
/**
* 文章管理
* @author Devil
@@ -182,7 +184,7 @@ class ArticleController extends CommonController
if(!empty($data['content']))
{
// 静态资源地址处理
- $data['content'] = ContentStaticReplace($data['content'], 'get');
+ $data['content'] = ResourcesService::ContentStaticReplace($data['content'], 'get');
}
}
$this->assign('data', $data);
@@ -246,7 +248,7 @@ class ArticleController extends CommonController
$m->title = I('title');
// 静态资源地址处理
- $m->content = ContentStaticReplace($m->content, 'add');
+ $m->content = ResourcesService::ContentStaticReplace($m->content, 'add');
// 正则匹配文章图片
$temp_image = $this->MatchContentImage($m->content);
@@ -286,7 +288,7 @@ class ArticleController extends CommonController
$m->title = I('title');
// 静态资源地址处理
- $m->content = ContentStaticReplace($m->content, 'add');
+ $m->content = ResourcesService::ContentStaticReplace($m->content, 'add');
// 正则匹配文章图片
$temp_image = $this->MatchContentImage($m->content);
diff --git a/service/Application/Admin/Controller/CustomViewController.class.php b/service/Application/Admin/Controller/CustomViewController.class.php
index e44ef1940..671283ab7 100755
--- a/service/Application/Admin/Controller/CustomViewController.class.php
+++ b/service/Application/Admin/Controller/CustomViewController.class.php
@@ -2,6 +2,8 @@
namespace Admin\Controller;
+use Service\ResourcesService;
+
/**
* 自定义页面管理
* @author Devil
@@ -178,7 +180,7 @@ class CustomViewController extends CommonController
if(!empty($data['content']))
{
// 静态资源地址处理
- $data['content'] = ContentStaticReplace($data['content'], 'get');
+ $data['content'] = ResourcesService::ContentStaticReplace($data['content'], 'get');
}
}
$this->assign('data', $data);
@@ -245,7 +247,7 @@ class CustomViewController extends CommonController
$m->title = I('title');
// 静态资源地址处理
- $m->content = ContentStaticReplace($m->content, 'add');
+ $m->content = ResourcesService::ContentStaticReplace($m->content, 'add');
// 正则匹配文章图片
$temp_image = $this->MatchContentImage($m->content);
@@ -280,7 +282,7 @@ class CustomViewController extends CommonController
if($m->create($_POST, 2))
{
// 静态资源地址处理
- $m->content = ContentStaticReplace($m->content, 'add');
+ $m->content = ResourcesService::ContentStaticReplace($m->content, 'add');
// 正则匹配文章图片
$temp_image = $this->MatchContentImage($m->content);
diff --git a/service/Application/Admin/Controller/GoodsController.class.php b/service/Application/Admin/Controller/GoodsController.class.php
index 1d6da28df..500b03fe4 100755
--- a/service/Application/Admin/Controller/GoodsController.class.php
+++ b/service/Application/Admin/Controller/GoodsController.class.php
@@ -2,6 +2,8 @@
namespace Admin\Controller;
+use Service\ResourcesService;
+
/**
* 商品管理
* @author Devil
@@ -230,7 +232,7 @@ class GoodsController extends CommonController
$data['category_ids'] = M('GoodsCategoryJoin')->where(['goods_id'=>$data['id']])->getField('category_id', true);
// pc详情
- $data['content_web'] = ContentStaticReplace($data['content_web'], 'get');
+ $data['content_web'] = ResourcesService::ContentStaticReplace($data['content_web'], 'get');
}
$this->assign('data', $data);
@@ -330,7 +332,7 @@ class GoodsController extends CommonController
'buy_max_number' => intval(I('buy_max_number', 0)),
'is_deduction_inventory' => intval(I('is_deduction_inventory')),
'is_shelves' => intval(I('is_shelves')),
- 'content_web' => ContentStaticReplace($_POST['content_web'], 'add'),
+ 'content_web' => ResourcesService::ContentStaticReplace($_POST['content_web'], 'add'),
'images' => isset($photo['data'][0]) ? $photo['data'][0] : '',
'photo_count' => count($photo['data']),
'is_home_recommended' => intval(I('is_home_recommended')),
diff --git a/service/Application/Admin/Controller/NavigationController.class.php b/service/Application/Admin/Controller/NavigationController.class.php
index b7f5bf83e..52dedf603 100755
--- a/service/Application/Admin/Controller/NavigationController.class.php
+++ b/service/Application/Admin/Controller/NavigationController.class.php
@@ -3,6 +3,7 @@
namespace Admin\Controller;
use Service\ArticleService;
+use Service\NavigationService;
/**
* 导航管理
@@ -101,12 +102,12 @@ class NavigationController extends CommonController
{
$m = M('Navigation');
$field = array('id', 'pid', 'name', 'url', 'value', 'data_type', 'sort', 'is_show', 'is_new_window_open');
- $data = NavDataDealWith($m->field($field)->where(array('nav_type'=>$this->nav_type, 'pid'=>0))->order('sort')->select());
+ $data = NavigationService::NavDataDealWith($m->field($field)->where(array('nav_type'=>$this->nav_type, 'pid'=>0))->order('sort')->select());
if(!empty($data))
{
foreach($data as $k=>$v)
{
- $data[$k]['item'] = NavDataDealWith($m->field($field)->where(array('nav_type'=>$this->nav_type, 'pid'=>$v['id']))->order('sort')->select());
+ $data[$k]['item'] = NavigationService::NavDataDealWith($m->field($field)->where(array('nav_type'=>$this->nav_type, 'pid'=>$v['id']))->order('sort')->select());
}
}
return $data;
diff --git a/service/Application/Admin/Controller/OrderController.class.php b/service/Application/Admin/Controller/OrderController.class.php
index a1409e2ac..26e1226fe 100755
--- a/service/Application/Admin/Controller/OrderController.class.php
+++ b/service/Application/Admin/Controller/OrderController.class.php
@@ -137,12 +137,12 @@ class OrderController extends CommonController
$v['pay_status_text'] = $common_order_pay_status[$v['pay_status']]['name'];
// 快递公司
- $v['express_name'] = GetExpressName($v['express_id']);
+ $v['express_name'] = ResourcesService::ExpressName($v['express_id']);
// 收件人地址
- $v['receive_province_name'] = GetRegionName($v['receive_province']);
- $v['receive_city_name'] = GetRegionName($v['receive_city']);
- $v['receive_county_name'] = GetRegionName($v['receive_county']);
+ $v['receive_province_name'] = ResourcesService::RegionName($v['receive_province']);
+ $v['receive_city_name'] = ResourcesService::RegionName($v['receive_city']);
+ $v['receive_county_name'] = ResourcesService::RegionName($v['receive_county']);
// 商品列表
$goods = M('OrderDetail')->where(['order_id'=>$v['id']])->select();
diff --git a/service/Application/Admin/Controller/UserController.class.php b/service/Application/Admin/Controller/UserController.class.php
index bc780bfbc..25ed789d8 100755
--- a/service/Application/Admin/Controller/UserController.class.php
+++ b/service/Application/Admin/Controller/UserController.class.php
@@ -2,6 +2,8 @@
namespace Admin\Controller;
+use Service\UserService;
+
/**
* 用户管理
* @author Devil
@@ -123,6 +125,17 @@ class UserController extends CommonController
$v['birthday_text'] = '';
}
+ // 头像
+ if(!empty($v['avatar']))
+ {
+ if(substr($v['avatar'], 0, 4) != 'http')
+ {
+ $v['avatar'] = C('IMAGE_HOST').$v['avatar'];
+ }
+ } else {
+ $v['avatar'] = C('IMAGE_HOST').'/Public/Home/'.C('DEFAULT_THEME').'/Images/default-user-avatar.jpg';
+ }
+
// 注册时间
$v['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
@@ -311,7 +324,7 @@ class UserController extends CommonController
if($user['integral'] != $data['integral'])
{
$integral_type = ($user['integral'] > $data['integral']) ? 0 : 1;
- UserIntegralLogAdd($user_id, $user['integral'], $data['integral'], '管理员操作', $integral_type, $this->admin['id']);
+ UserService::UserIntegralLogAdd($user_id, $user['integral'], $data['integral'], '管理员操作', $integral_type, $this->admin['id']);
}
$this->ajaxReturn(L('common_operation_edit_success'));
diff --git a/service/Application/Admin/View/Default/UserIntegralLog/Index.html b/service/Application/Admin/View/Default/UserIntegralLog/Index.html
index c42448878..7cdc67397 100755
--- a/service/Application/Admin/View/Default/UserIntegralLog/Index.html
+++ b/service/Application/Admin/View/Default/UserIntegralLog/Index.html
@@ -69,12 +69,8 @@
{{:L('common_on_fill_in_the_text')}}{{$v.type_text}}
|
-
- {{:L('common_on_fill_in_the_text')}}{{$v.original_integral}}
- |
-
- {{:L('common_on_fill_in_the_text')}}{{$v.new_integral}}
- |
+ {{$v.original_integral}} |
+ {{$v.new_integral}} |
{{:L('common_on_fill_in_the_text')}}{{$v.msg}}
|
diff --git a/service/Application/Api/Controller/BuyController.class.php b/service/Application/Api/Controller/BuyController.class.php
index a773173f7..f293c2e56 100755
--- a/service/Application/Api/Controller/BuyController.class.php
+++ b/service/Application/Api/Controller/BuyController.class.php
@@ -2,6 +2,8 @@
namespace Api\Controller;
+use Service\ResourcesService;
+
/**
* 购买确认
* @author Devil
@@ -77,9 +79,9 @@ class BuyController extends CommonController
$data = M('UserAddress')->where($where)->find();
if(!empty($data))
{
- $data['province_name'] = GetRegionName($data['province']);
- $data['city_name'] = GetRegionName($data['city']);
- $data['county_name'] = GetRegionName($data['county']);
+ $data['province_name'] = ResourcesService::RegionName($data['province']);
+ $data['city_name'] = ResourcesService::RegionName($data['city']);
+ $data['county_name'] = ResourcesService::RegionName($data['county']);
}
return $data;
}
diff --git a/service/Application/Api/Controller/GoodsController.class.php b/service/Application/Api/Controller/GoodsController.class.php
index 681ae3733..c3c65185e 100755
--- a/service/Application/Api/Controller/GoodsController.class.php
+++ b/service/Application/Api/Controller/GoodsController.class.php
@@ -2,6 +2,8 @@
namespace Api\Controller;
+use Service\ResourcesService;
+
/**
* 商品
* @author Devil
@@ -50,7 +52,7 @@ class GoodsController extends CommonController
unset($goods['content_web']);
// 产地
- $goods['place_origin_name'] = GetRegionName($goods['place_origin']);
+ $goods['place_origin_name'] = ResourcesService::RegionName($goods['place_origin']);
// 是否已收藏
$goods['is_favor'] = $this->IsGoodsUserFavor($goods_id);
diff --git a/service/Application/Api/Controller/OrderController.class.php b/service/Application/Api/Controller/OrderController.class.php
index 6a88c30d2..769c9a5ac 100755
--- a/service/Application/Api/Controller/OrderController.class.php
+++ b/service/Application/Api/Controller/OrderController.class.php
@@ -2,6 +2,8 @@
namespace Api\Controller;
+use Service\ResourcesService;
+
/**
* 我的订单
* @author Devil
@@ -143,13 +145,13 @@ class OrderController extends CommonController
$v['pay_status_text'] = $common_order_pay_status[$v['pay_status']]['name'];
// 快递公司
- $v['express_name'] = GetExpressName($v['express_id']);
+ $v['express_name'] = ResourcesService::ExpressName($v['express_id']);
unset($v['express_id']);
// 收件人地址
- $v['receive_province_name'] = GetRegionName($v['receive_province']);
- $v['receive_city_name'] = GetRegionName($v['receive_city']);
- $v['receive_county_name'] = GetRegionName($v['receive_county']);
+ $v['receive_province_name'] = ResourcesService::RegionName($v['receive_province']);
+ $v['receive_city_name'] = ResourcesService::RegionName($v['receive_city']);
+ $v['receive_county_name'] = ResourcesService::RegionName($v['receive_county']);
// 商品列表
$goods = M('OrderDetail')->where(['order_id'=>$v['id']])->select();
diff --git a/service/Application/Api/Controller/UserAddressController.class.php b/service/Application/Api/Controller/UserAddressController.class.php
index 3936a294a..61a2e5a7b 100755
--- a/service/Application/Api/Controller/UserAddressController.class.php
+++ b/service/Application/Api/Controller/UserAddressController.class.php
@@ -2,6 +2,8 @@
namespace Api\Controller;
+use Service\ResourcesService;
+
/**
* 用户地址
* @author Devil
@@ -63,9 +65,9 @@ class UserAddressController extends CommonController
$data = M('UserAddress')->where($where)->field($field)->find();
if(!empty($address))
{
- $data['province_name'] = GetRegionName($data['province']);
- $data['city_name'] = GetRegionName($data['city']);
- $data['county_name'] = GetRegionName($data['county']);
+ $data['province_name'] = ResourcesService::RegionName($data['province']);
+ $data['city_name'] = ResourcesService::RegionName($data['city']);
+ $data['county_name'] = ResourcesService::RegionName($data['county']);
}
$this->ajaxReturn(L('common_operation_success'), 0, $data);
@@ -88,9 +90,9 @@ class UserAddressController extends CommonController
{
foreach($data as &$v)
{
- $v['province_name'] = GetRegionName($v['province']);
- $v['city_name'] = GetRegionName($v['city']);
- $v['county_name'] = GetRegionName($v['county']);
+ $v['province_name'] = ResourcesService::RegionName($v['province']);
+ $v['city_name'] = ResourcesService::RegionName($v['city']);
+ $v['county_name'] = ResourcesService::RegionName($v['county']);
}
}
$this->ajaxReturn(L('common_operation_success'), 0, $data);
diff --git a/service/Application/Common/Common/function.php b/service/Application/Common/Common/function.php
index ea375360e..bfd2e9e10 100755
--- a/service/Application/Common/Common/function.php
+++ b/service/Application/Common/Common/function.php
@@ -126,66 +126,6 @@ function HomeUrl($c='Index', $a='Index', $params=[])
return $url;
}
-/**
- * [UserIntegralLogAdd 用户积分日志添加]
- * @author Devil
- * @blog http://gong.gg/
- * @version 1.0.0
- * @datetime 2018-05-18T16:51:12+0800
- * @param [int] $user_id [用户id]
- * @param [int] $original_integral [原始积分]
- * @param [int] $new_integral [最新积分]
- * @param [string] $msg [操作原因]
- * @param [int] $type [操作类型(0减少, 1增加)]
- * @param [int] $operation_id [操作人员id]
- * @return [boolean] [成功true, 失败false]
- */
-function UserIntegralLogAdd($user_id, $original_integral, $new_integral, $msg = '', $type = 0, $operation_id = 0)
-{
- $data = array(
- 'user_id' => intval($user_id),
- 'original_integral' => intval($original_integral),
- 'new_integral' => intval($new_integral),
- 'msg' => $msg,
- 'type' => intval($type),
- 'operation_id' => intval($operation_id),
- 'add_time' => time(),
- );
- if(M('UserIntegralLog')->add($data) > 0)
- {
- $type_msg = L('common_integral_log_type_list')[$type]['name'];
- $integral = ($data['type'] == 0) ? $data['original_integral']-$data['new_integral'] : $data['new_integral']-$data['original_integral'];
- $detail = $msg.'积分'.$type_msg.$integral;
- CommonMessageAdd('积分变动', $detail, $user_id);
- return true;
- }
- return false;
-}
-
-/**
- * [CommonMessageAdd 消息添加]
- * @author Devil
- * @blog http://gong.gg/
- * @version 1.0.0
- * @datetime 2018-04-14T13:03:35+0800
- * @param [string] $title [标题]
- * @param [string] $detail [内容]
- * @param [int] $user_id[用户id]
- * @param [int] $type [类型(默认0 普通消息)]
- * @return [boolean] [成功true, 失败false]
- */
-function CommonMessageAdd($title = '', $detail = '', $user_id = 0, $type = 0)
-{
- $data = array(
- 'user_id' => intval($user_id),
- 'title' => $title,
- 'detail' => $detail,
- 'type' => intval($type),
- 'add_time' => time(),
- );
- return (M('Message')->add($data) > 0);
-}
-
/**
* [PriceBeautify 金额美化]
* @author Devil
@@ -323,25 +263,6 @@ function ScienceNumToString($num)
return $result;
}
-/**
- * [GenerateStudentNumber 学生编号生成-年份+自增id(不足以0前置补齐)]
- * @author Devil
- * @blog http://gong.gg/
- * @version 0.0.1
- * @datetime 2017-03-02T12:13:06+0800
- * @param [int] $student_id [学生自增id]
- * @return [string] [学生编号]
- */
-function GenerateStudentNumber($student_id)
-{
- $number = date('Y');
- for($i=0; $i<8-strlen($student_id); $i++)
- {
- $number .= '0';
- }
- return $number.$student_id;
-}
-
/**
* [MyConfigInit 系统配置信息初始化]
* @author Devil
@@ -414,71 +335,6 @@ function GetClientIP($long = false)
return $onlineip;
}
-/**
- * [NavDataDealWith 导航数据处理]
- * @author Devil
- * @blog http://gong.gg/
- * @version 0.0.1
- * @datetime 2017-02-05T21:36:46+0800
- * @param [array] $data [需要处理的数据]
- * @return [array] [处理好的数据]
- */
-function NavDataDealWith($data)
-{
- if(!empty($data) && is_array($data))
- {
- foreach($data as $k=>$v)
- {
- // url处理
- switch($v['data_type'])
- {
- // 文章分类
- case 'article':
- $v['url'] = HomeUrl('Article', 'Index', ['id'=>$v['value']]);
- break;
-
- // 自定义页面
- case 'customview':
- $v['url'] = HomeUrl('CustomView', 'Index', ['id'=>$v['value']]);
- break;
-
- // 商品分类
- case 'goods_category':
- $v['url'] = HomeUrl('Search', 'Index', ['category_id'=>$v['value']]);
- break;
- }
- $data[$k] = $v;
- }
- }
- return $data;
-}
-
-/**
- * [ContentStaticReplace 编辑器中内容的静态资源替换]
- * @author Devil
- * @blog http://gong.gg/
- * @version 0.0.1
- * @datetime 2017-01-22T16:07:58+0800
- * @param [string] $content [在这个字符串中查找进行替换]
- * @param [string] $type [操作类型[get读取额你让, add写入内容](编辑/展示传入get,数据写入数据库传入add)]
- * @return [string] [正确返回替换后的内容, 则返回原内容]
- */
-function ContentStaticReplace($content, $type = 'get')
-{
- switch($type)
- {
- // 读取内容
- case 'get':
- return str_replace('/Public/', __MY_URL__.'Public/', $content);
- break;
-
- // 内容写入
- case 'add':
- return str_replace(array(__MY_URL__.'Public/', __MY_ROOT__.'Public/'), '/Public/', $content);
- }
- return $content;
-}
-
/**
* [DelDirFile 删除指定目录下的所有文件]
* @author Devil
@@ -918,56 +774,10 @@ function CheckColor($value)
function CheckLoginPwd($string)
{
return (preg_match('/'.L('common_regex_pwd').'/', $string) == 1) ? true : false;
- // $len = strlen($string);
- // return ($len >= 6 && $len <= 18);
}
/**
- * [Sms_Code_Send 验证码通道]
- * @author Devil
- * @blog http://gong.gg/
- * @version 0.0.1
- * @datetime 2016-12-03T21:58:54+0800
- * @param [staing] $content [内容]
- * @param [string] $mobile_phone [手机号码]
- * @return [boolean] [成功true, 失败false]
- */
-function Sms_Code_Send($content, $mobile_phone)
-{
- $post = array(
- 'apikey' => '17171d4ff3510ae8f532a70401e41067',
- 'text' => '【美啦网】'.$content,
- 'mobile' => $mobile_phone,
- );
- $result = json_decode(Fsockopen_Post('http://yunpian.com/v1/sms/send.json', $post), true);
- if(empty($result)) return false;
- return ($result['msg'] == 'OK');
-}
-
-/**
- * [Sms_Notice_Send 通知短信通道]
- * @param [staing] $content [内容]
- * @param [string] $mobile_phone [手机号码]
- * @return [boolean] [成功true, 失败false]
- */
-function Sms_Notice_Send($content, $mobile_phone)
-{
- $post = array(
- 'action' => 'sendOnce',
- 'ac' => '1001@501186640001',
- 'authkey' => 'C511BEF448D2D063972EEC015C3E95C6',
- 'cgid' => '4534',
- 'csid' => '4717',
- 'c' => $content,
- 'm' => $mobile_phone,
- );
- $return = Xml_Array(Fsockopen_Post('http://smsapi.c123.cn/OpenPlatform/OpenApi', $post));
- if(!isset($return['@attributes']['result']) || $return['@attributes']['result'] != 1) return false;
- return true;
-}
-
-/**
- * [IsExistWebImg 检测一张网络图片是否存在]
+ * [IsExistRemoteImage 检测一张网络图片是否存在]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
@@ -975,7 +785,7 @@ function Sms_Notice_Send($content, $mobile_phone)
* @param [string] $url [图片地址]
* @return [boolean] [存在true, 则false]
*/
-function IsExistWebImg($url)
+function IsExistRemoteImage($url)
{
if(!empty($url))
{
@@ -1345,85 +1155,4 @@ function params_checked($data, $params)
return true;
}
-/**
- * [UserServiceExpire 用户服务有效]
- * @author Devil
- * @blog http://gong.gg/
- * @version 1.0.0
- * @datetime 2018-05-17T17:18:29+0800
- * @param [int] $service_expire_time [description]
- * @return [boolean|int] [有效则返回时间, 无效则false]
- */
-function UserServiceExpire($service_expire_time)
-{
- if(empty($service_expire_time))
- {
- return false;
- }
-
- $service_time = strtotime(date('Y-m-d', $service_expire_time));
- $day_time = strtotime(date('Y-m-d'));
- if($service_time >= $day_time)
- {
- return date('Y-m-d', $service_time);
- }
- return false;
-}
-
-/**
- * [GetRegionName 获取地区名称]
- * @author Devil
- * @blog http://gong.gg/
- * @version 1.0.0
- * @datetime 2018-05-17T18:03:39+0800
- * @param [int] $region_id [地区id]
- * @return [string] [地区名称]
- */
-function GetRegionName($region_id)
-{
- return M('Region')->where(['id'=>$region_id])->getField('name');
-}
-
-/**
- * [GetExpressName 获取快递名称]
- * @author Devil
- * @blog http://gong.gg/
- * @version 1.0.0
- * @datetime 2018-05-17T18:03:39+0800
- * @param [int] $express_id [快递id]
- * @return [string] [快递名称]
- */
-function GetExpressName($express_id)
-{
- return M('Express')->where(['id'=>$express_id])->getField('name');
-}
-
-/**
- * [GetGoodsName 获取物品类型名称]
- * @author Devil
- * @blog http://gong.gg/
- * @version 1.0.0
- * @datetime 2018-05-17T18:03:39+0800
- * @param [int] $goods_id [快递id]
- * @return [string] [快递名称]
- */
-function GetGoodsName($goods_id)
-{
- return M('Goods')->where(['id'=>$goods_id])->getField('name');
-}
-
-/**
- * [GetMerchantName 获取站点名称]
- * @author Devil
- * @blog http://gong.gg/
- * @version 1.0.0
- * @datetime 2018-05-17T18:03:39+0800
- * @param [int] $merchant_id [站点id]
- * @return [string] [站点名称]
- */
-function GetMerchantName($merchant_id)
-{
- return M('Merchant')->where(['id'=>$merchant_id])->getField('name');
-}
-
?>
\ No newline at end of file
diff --git a/service/Application/Home/Controller/CustomViewController.class.php b/service/Application/Home/Controller/CustomViewController.class.php
index f94c465f9..f77cc8f0a 100755
--- a/service/Application/Home/Controller/CustomViewController.class.php
+++ b/service/Application/Home/Controller/CustomViewController.class.php
@@ -2,6 +2,8 @@
namespace Home\Controller;
+use Service\ResourcesService;
+
/**
* 自定义页面
* @author Devil
@@ -42,7 +44,7 @@ class CustomViewController extends CommonController
$m->where(array('id'=>I('id')))->setInc('access_count');
// 静态资源地址处理
- $data['content'] = ContentStaticReplace($data['content'], 'get');
+ $data['content'] = ResourcesService::ContentStaticReplace($data['content'], 'get');
$this->assign('is_header', $data['is_header']);
$this->assign('is_footer', $data['is_footer']);
diff --git a/service/Application/Home/Controller/MessageController.class.php b/service/Application/Home/Controller/MessageController.class.php
index f6a0072a0..bf1b3c697 100755
--- a/service/Application/Home/Controller/MessageController.class.php
+++ b/service/Application/Home/Controller/MessageController.class.php
@@ -39,13 +39,13 @@ class MessageController extends CommonController
*/
public function Index()
{
- // 消息更新未已读
- MessageService::MessageRead($params);
-
// 参数
$params = array_merge($_POST, $_GET);
$params['user'] = $this->user;
+ // 消息更新未已读
+ MessageService::MessageRead($params);
+
// 分页
$number = 10;
diff --git a/service/Application/Service/ArticleService.class.php b/service/Application/Service/ArticleService.class.php
index 5ce1155cd..733651166 100755
--- a/service/Application/Service/ArticleService.class.php
+++ b/service/Application/Service/ArticleService.class.php
@@ -2,6 +2,8 @@
namespace Service;
+use Service\ResourcesService;
+
/**
* 文章服务层
* @author Devil
@@ -34,7 +36,7 @@ class ArticleService
{
if(isset($v['content']))
{
- $v['content'] = ContentStaticReplace($v['content'], 'get');
+ $v['content'] = ResourcesService::ContentStaticReplace($v['content'], 'get');
}
if(isset($v['add_time']))
{
diff --git a/service/Application/Service/GoodsService.class.php b/service/Application/Service/GoodsService.class.php
index 3cd1e0917..c491ec96b 100755
--- a/service/Application/Service/GoodsService.class.php
+++ b/service/Application/Service/GoodsService.class.php
@@ -2,6 +2,8 @@
namespace Service;
+use Service\ResourcesService;
+
/**
* 商品服务层
* @author Devil
@@ -232,7 +234,7 @@ class GoodsService
// PC内容处理
if(isset($v['content_web']))
{
- $v['content_web'] = ContentStaticReplace($v['content_web'], 'get');
+ $v['content_web'] = ResourcesService::ContentStaticReplace($v['content_web'], 'get');
}
// 产地
diff --git a/service/Application/Service/NavigationService.class.php b/service/Application/Service/NavigationService.class.php
index d3373b2c6..d0ed44351 100755
--- a/service/Application/Service/NavigationService.class.php
+++ b/service/Application/Service/NavigationService.class.php
@@ -33,12 +33,12 @@ class NavigationService
// 缓存没数据则从数据库重新读取,顶部菜单
if(empty($header))
{
- $header = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>0))->order('sort')->select());
+ $header = self::NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>0))->order('sort')->select());
if(!empty($header))
{
foreach($header as $k=>$v)
{
- $header[$k]['item'] = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>$v['id']))->order('sort')->select());
+ $header[$k]['item'] = self::NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>$v['id']))->order('sort')->select());
}
}
S(C('cache_common_home_nav_header_key'), $header);
@@ -47,7 +47,7 @@ class NavigationService
// 底部导航
if(empty($footer))
{
- $footer = NavDataDealWith($m->field($field)->where(array('nav_type'=>'footer', 'is_show'=>1))->order('sort')->select());
+ $footer = self::NavDataDealWith($m->field($field)->where(array('nav_type'=>'footer', 'is_show'=>1))->order('sort')->select());
S(C('cache_common_home_nav_footer_key'), $footer);
}
@@ -56,5 +56,44 @@ class NavigationService
'footer' => $footer,
];
}
+
+ /**
+ * [NavDataDealWith 导航数据处理]
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 0.0.1
+ * @datetime 2017-02-05T21:36:46+0800
+ * @param [array] $data [需要处理的数据]
+ * @return [array] [处理好的数据]
+ */
+ public static function NavDataDealWith($data)
+ {
+ if(!empty($data) && is_array($data))
+ {
+ foreach($data as $k=>$v)
+ {
+ // url处理
+ switch($v['data_type'])
+ {
+ // 文章分类
+ case 'article':
+ $v['url'] = HomeUrl('Article', 'Index', ['id'=>$v['value']]);
+ break;
+
+ // 自定义页面
+ case 'customview':
+ $v['url'] = HomeUrl('CustomView', 'Index', ['id'=>$v['value']]);
+ break;
+
+ // 商品分类
+ case 'goods_category':
+ $v['url'] = HomeUrl('Search', 'Index', ['category_id'=>$v['value']]);
+ break;
+ }
+ $data[$k] = $v;
+ }
+ }
+ return $data;
+ }
}
?>
\ No newline at end of file
diff --git a/service/Application/Service/OrderService.class.php b/service/Application/Service/OrderService.class.php
index 283b219c3..cd73a9a09 100755
--- a/service/Application/Service/OrderService.class.php
+++ b/service/Application/Service/OrderService.class.php
@@ -549,12 +549,12 @@ class OrderService
$v['pay_status_name'] = $order_pay_status[$v['pay_status']]['name'];
// 快递公司
- $v['express_name'] = ResourcesService::ExpressName(['express_id'=>$v['express_id']]);
+ $v['express_name'] = ResourcesService::ExpressName($v['express_id']);
// 收件人地址
- $v['receive_province_name'] = ResourcesService::RegionName(['region_id'=>$v['receive_province']]);
- $v['receive_city_name'] = ResourcesService::RegionName(['region_id'=>$v['receive_city']]);
- $v['receive_county_name'] = ResourcesService::RegionName(['region_id'=>$v['receive_county']]);
+ $v['receive_province_name'] = ResourcesService::RegionName($v['receive_province']);
+ $v['receive_city_name'] = ResourcesService::RegionName($v['receive_city']);
+ $v['receive_county_name'] = ResourcesService::RegionName($v['receive_county']);
// 时间
$v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']);
diff --git a/service/Application/Service/ResourcesService.class.php b/service/Application/Service/ResourcesService.class.php
index a8d25d7e8..e2647099e 100755
--- a/service/Application/Service/ResourcesService.class.php
+++ b/service/Application/Service/ResourcesService.class.php
@@ -18,11 +18,11 @@ class ResourcesService
* @version 1.0.0
* @date 2018-09-19
* @desc description
- * @param [array] $params [输入参数]
+ * @param [int] $region_id [地区id]
*/
- public static function RegionName($params = [])
+ public static function RegionName($region_id = 0)
{
- return M('Region')->where(['id'=>intval($params['region_id'])])->getField('name');
+ return empty($region_id) ? null : M('Region')->where(['id'=>intval($region_id)])->getField('name');
}
/**
@@ -32,11 +32,11 @@ class ResourcesService
* @version 1.0.0
* @date 2018-09-19
* @desc description
- * @param [array] $params [输入参数]
+ * @param [int] $express_id [快递id]
*/
- public static function ExpressName($params = [])
+ public static function ExpressName($express_id = 0)
{
- return M('Express')->where(['id'=>intval($params['express_id'])])->getField('name');
+ return empty($express_id) ? null : M('Express')->where(['id'=>intval($express_id)])->getField('name');
}
/**
@@ -172,5 +172,31 @@ class ResourcesService
return M('Region')->where($where)->field($field)->order('id asc, sort asc')->select();
}
+
+ /**
+ * [ContentStaticReplace 编辑器中内容的静态资源替换]
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 0.0.1
+ * @datetime 2017-01-22T16:07:58+0800
+ * @param [string] $content [在这个字符串中查找进行替换]
+ * @param [string] $type [操作类型[get读取额你让, add写入内容](编辑/展示传入get,数据写入数据库传入add)]
+ * @return [string] [正确返回替换后的内容, 则返回原内容]
+ */
+ public static function ContentStaticReplace($content, $type = 'get')
+ {
+ switch($type)
+ {
+ // 读取内容
+ case 'get':
+ return str_replace('/Public/', __MY_URL__.'Public/', $content);
+ break;
+
+ // 内容写入
+ case 'add':
+ return str_replace(array(__MY_URL__.'Public/', __MY_ROOT__.'Public/'), '/Public/', $content);
+ }
+ return $content;
+ }
}
?>
\ No newline at end of file
diff --git a/service/Application/Service/UserService.class.php b/service/Application/Service/UserService.class.php
index e6b5194d1..0bcebb38c 100755
--- a/service/Application/Service/UserService.class.php
+++ b/service/Application/Service/UserService.class.php
@@ -3,6 +3,7 @@
namespace Service;
use Service\ResourcesService;
+use Service\MessageService;
/**
* 用户服务层
@@ -49,9 +50,9 @@ class UserService
{
foreach($data as &$v)
{
- $v['province_name'] = ResourcesService::RegionName(['region_id'=>$v['province']]);
- $v['city_name'] = ResourcesService::RegionName(['region_id'=>$v['city']]);
- $v['county_name'] = ResourcesService::RegionName(['region_id'=>$v['county']]);
+ $v['province_name'] = ResourcesService::RegionName($v['province']);
+ $v['city_name'] = ResourcesService::RegionName($v['city']);
+ $v['county_name'] = ResourcesService::RegionName($v['county']);
}
}
return DataReturn(L('common_operation_success'), 0, $data);
@@ -482,5 +483,41 @@ class UserService
return DataReturn('上传失败', -100);
}
+ /**
+ * [UserIntegralLogAdd 用户积分日志添加]
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @datetime 2018-05-18T16:51:12+0800
+ * @param [int] $user_id [用户id]
+ * @param [int] $original_integral [原始积分]
+ * @param [int] $new_integral [最新积分]
+ * @param [string] $msg [操作原因]
+ * @param [int] $type [操作类型(0减少, 1增加)]
+ * @param [int] $operation_id [操作人员id]
+ * @return [boolean] [成功true, 失败false]
+ */
+ public static function UserIntegralLogAdd($user_id, $original_integral, $new_integral, $msg = '', $type = 0, $operation_id = 0)
+ {
+ $data = array(
+ 'user_id' => intval($user_id),
+ 'original_integral' => intval($original_integral),
+ 'new_integral' => intval($new_integral),
+ 'msg' => $msg,
+ 'type' => intval($type),
+ 'operation_id' => intval($operation_id),
+ 'add_time' => time(),
+ );
+ if(M('UserIntegralLog')->add($data) > 0)
+ {
+ $type_msg = L('common_integral_log_type_list')[$type]['name'];
+ $integral = ($data['type'] == 0) ? $data['original_integral']-$data['new_integral'] : $data['new_integral']-$data['original_integral'];
+ $detail = $msg.'积分'.$type_msg.$integral;
+ MessageService::MessageAdd($user_id, '积分变动', $detail);
+ return true;
+ }
+ return false;
+ }
+
}
?>
\ No newline at end of file