diff --git a/application/api/controller/Goods.php b/application/api/controller/Goods.php index 2f9495b996d3aca6a82c61d636e25c22ec20a598..a0f6ffd342c4f25acbfcf3309825f050e7e8c81a 100755 --- a/application/api/controller/Goods.php +++ b/application/api/controller/Goods.php @@ -218,8 +218,7 @@ class Goods extends Common { // 开始处理 $params = $this->data_post; - $data = GoodsService::GoodsCategory($params); - return DataReturn('success', 0, $data); + return DataReturn('success', 0, GoodsService::GoodsCategoryAll($params)); } /** diff --git a/application/service/AppHomeNavService.php b/application/service/AppHomeNavService.php index 04196a84193abb3f1c492e9287078975089a150c..844f6d6d6cdf88da412647241ba70a74b9a7f33b 100755 --- a/application/service/AppHomeNavService.php +++ b/application/service/AppHomeNavService.php @@ -342,16 +342,35 @@ class AppHomeNavService */ public static function AppHomeNav($params = []) { - $client_type = (APPLICATION_CLIENT_TYPE == 'pc') ? (IsMobile() ? 'h5' : 'pc') : APPLICATION_CLIENT_TYPE; - $data = Db::name('AppHomeNav')->field('id,name,images_url,event_value,event_type,bg_color,is_need_login')->where(['platform'=>$client_type, 'is_enable'=>1])->order('sort asc')->select(); - if(!empty($data)) + // 平台 + $platform = APPLICATION_CLIENT_TYPE; + + // web端手机访问 + if($platform == 'pc' && IsMobile()) { - foreach($data as &$v) + $platform = 'h5'; + } + + // 缓存 + $key = config('shopxo.cache_navigation_key').$platform; + $data = cache($key); + + if(empty($data)) + { + // 获取导航数据 + $data = Db::name('AppHomeNav')->field('id,name,images_url,event_value,event_type,bg_color,is_need_login')->where(['platform'=>$platform, 'is_enable'=>1])->order('sort asc')->select(); + if(!empty($data)) { - $v['images_url_old'] = $v['images_url']; - $v['images_url'] = ResourcesService::AttachmentPathViewHandle($v['images_url']); - $v['event_value'] = empty($v['event_value']) ? null : $v['event_value']; + foreach($data as &$v) + { + $v['images_url_old'] = $v['images_url']; + $v['images_url'] = ResourcesService::AttachmentPathViewHandle($v['images_url']); + $v['event_value'] = empty($v['event_value']) ? null : $v['event_value']; + } } + + // 存储缓存 + cache($key, $data, 3600*24); } return $data; } diff --git a/application/service/BannerService.php b/application/service/BannerService.php index 36801ffbc062d26cde9a599739688afa353bdf2f..6e71125ed6eb17867b831c0fbbad29171ad5ae2c 100755 --- a/application/service/BannerService.php +++ b/application/service/BannerService.php @@ -42,18 +42,28 @@ class BannerService $platform = 'h5'; } - // 获取banner数据 - $banner = Db::name('Slide')->field('name,images_url,event_value,event_type,bg_color')->where(['platform'=>$platform, 'is_enable'=>1])->order('sort asc,id asc')->select(); - if(!empty($banner)) + // 缓存 + $key = config('shopxo.cache_banner_list_key').$platform; + $data = cache($key); + + if(empty($data)) { - foreach($banner as &$v) + // 获取banner数据 + $data = Db::name('Slide')->field('name,images_url,event_value,event_type,bg_color')->where(['platform'=>$platform, 'is_enable'=>1])->order('sort asc,id asc')->select(); + if(!empty($data)) { - $v['images_url_old'] = $v['images_url']; - $v['images_url'] = ResourcesService::AttachmentPathViewHandle($v['images_url']); - $v['event_value'] = empty($v['event_value']) ? null : $v['event_value']; + foreach($data as &$v) + { + $v['images_url_old'] = $v['images_url']; + $v['images_url'] = ResourcesService::AttachmentPathViewHandle($v['images_url']); + $v['event_value'] = empty($v['event_value']) ? null : $v['event_value']; + } } + + // 存储缓存 + cache($key, $data, 3600*24); } - return $banner; + return $data; } } ?> \ No newline at end of file diff --git a/application/service/GoodsService.php b/application/service/GoodsService.php index 8e49aa8a84281e7d2b1bdf47b901142b5892f2be..eb06bb2463fdb924d84ee4c5848002546a8d6d5f 100755 --- a/application/service/GoodsService.php +++ b/application/service/GoodsService.php @@ -59,18 +59,16 @@ class GoodsService // 从缓存获取 $key = config('shopxo.cache_goods_category_key'); $data = cache($key); - if(!empty($data)) - { - return $data; - } - - // 获取分类 - $params['where'] = ['pid'=>0, 'is_enable'=>1]; - $data = self::GoodsCategory($params); - // 存储缓存 - cache($key, $data); + if(empty($data)) + { + // 获取分类 + $params['where'] = ['pid'=>0, 'is_enable'=>1]; + $data = self::GoodsCategory($params); + // 存储缓存 + cache($key, $data, 3600*24); + } return $data; } @@ -178,19 +176,30 @@ class GoodsService */ public static function HomeFloorList($params = []) { - // 商品大分类 - $params['where'] = ['pid'=>0, 'is_home_recommended'=>1, 'is_enable'=>1]; - $goods_category = self::GoodsCategory($params); - if(!empty($goods_category)) + // 缓存 + $key = config('shopxo.cache_goods_floor_list_key'); + $data = cache($key); + + if(empty($data)) { - foreach($goods_category as &$v) + // 商品大分类 + $params['where'] = ['pid'=>0, 'is_home_recommended'=>1, 'is_enable'=>1]; + $data = self::GoodsCategory($params); + if(!empty($data)) { - $category_ids = self::GoodsCategoryItemsIds([$v['id']], 1); - $goods = self::CategoryGoodsList(['where'=>['gci.category_id'=>$category_ids, 'g.is_home_recommended'=>1, 'g.is_shelves'=>1], 'm'=>0, 'n'=>8, 'field'=>'g.*']); - $v['goods'] = $goods['data']; + // 根据分类获取楼层商品 + foreach($data as &$v) + { + $category_ids = self::GoodsCategoryItemsIds([$v['id']], 1); + $goods = self::CategoryGoodsList(['where'=>['gci.category_id'=>$category_ids, 'g.is_home_recommended'=>1, 'g.is_shelves'=>1], 'm'=>0, 'n'=>8, 'field'=>'g.*']); + $v['goods'] = $goods['data']; + } } + + // 存储缓存 + cache($key, $data, 3600*24); } - return $goods_category; + return $data; } /** diff --git a/application/tags.php b/application/tags.php index cb18788a5f5d6271c71efdc778db40cf391a341f..04425bbdd6d9476b3bf3b41271de0dd7bd63a99b 100755 --- a/application/tags.php +++ b/application/tags.php @@ -62,6 +62,26 @@ return array ( 0 => 'app\\plugins\\orderexportprint\\Hook', 1 => 'app\\plugins\\orderpricerevision\\Hook', ), + 'plugins_view_user_login_info_top' => + array ( + 0 => 'app\\plugins\\weixinwebauthorization\\Hook', + ), + 'plugins_view_user_reg_info' => + array ( + 0 => 'app\\plugins\\weixinwebauthorization\\Hook', + ), + 'plugins_view_header_navigation_top_left' => + array ( + 0 => 'app\\plugins\\weixinwebauthorization\\Hook', + ), + 'plugins_service_users_personal_show_field_list_handle' => + array ( + 0 => 'app\\plugins\\weixinwebauthorization\\Hook', + ), + 'plugins_service_system_begin' => + array ( + 0 => 'app\\plugins\\weixinwebauthorization\\Hook', + ), 'plugins_service_users_center_left_menu_handle' => array ( 0 => 'app\\plugins\\excellentbuyreturntocash\\Hook', @@ -97,6 +117,7 @@ return array ( 0 => 'app\\plugins\\excellentbuyreturntocash\\Hook', 1 => 'app\\plugins\\coupon\\Hook', 2 => 'app\\plugins\\distribution\\Hook', + 3 => 'app\\plugins\\neworderemail\\Hook', ), 'plugins_view_goods_detail_panel_bottom' => array ( @@ -127,7 +148,7 @@ return array ( array ( 0 => 'app\\plugins\\coupon\\Hook', 1 => 'app\\plugins\\membershiplevelvip\\Hook', - 2 => 'app\\plugins\\touristbuy\\Hook', + 2 => 'app\\plugins\\speedplaceorder\\Hook', ), 'plugins_view_buy_goods_bottom' => array ( @@ -184,13 +205,11 @@ return array ( ), 'plugins_service_goods_handle_end' => array ( - 0 => 'app\\plugins\\usernotloginhidegoodsprice\\Hook', - 1 => 'app\\plugins\\membershiplevelvip\\Hook', + 0 => 'app\\plugins\\membershiplevelvip\\Hook', ), 'plugins_service_goods_spec_base' => array ( - 0 => 'app\\plugins\\usernotloginhidegoodsprice\\Hook', - 1 => 'app\\plugins\\membershiplevelvip\\Hook', + 0 => 'app\\plugins\\membershiplevelvip\\Hook', ), 'plugins_service_user_login_success_record' => array ( @@ -220,25 +239,5 @@ return array ( array ( 0 => 'app\\plugins\\share\\Hook', ), - 'plugins_service_system_begin' => - array ( - 0 => 'app\\plugins\\touristbuy\\Hook', - ), - 'plugins_common_header' => - array ( - 0 => 'app\\plugins\\touristbuy\\Hook', - ), - 'plugins_view_header_navigation_top_left' => - array ( - 0 => 'app\\plugins\\touristbuy\\Hook', - ), - 'plugins_view_user_login_info_top' => - array ( - 0 => 'app\\plugins\\touristbuy\\Hook', - ), - 'plugins_view_user_reg_info' => - array ( - 0 => 'app\\plugins\\touristbuy\\Hook', - ), ); ?> \ No newline at end of file diff --git a/config/shopxo.php b/config/shopxo.php index 0bbfb68dea590adfa3be04704dfdccaf7ba7eef0..2bd9a410931af2534796bc7d09535266d7ee3fdf 100755 --- a/config/shopxo.php +++ b/config/shopxo.php @@ -48,6 +48,15 @@ return [ // 用户缓存信息 'cache_user_info' => 'cache_user_info_', + // 首页楼层缓存信息 + 'cache_goods_floor_list_key' => 'cache_goods_floor_list_data', + + // 轮播缓存信息 + 'cache_banner_list_key' => 'cache_banner_list_data_', + + // 导航缓存信息 + 'cache_navigation_key' => 'cache_navigation_data_', + // 附件host, 数据库图片地址以/static/...开头 'attachment_host' => defined('__MY_PUBLIC_URL__') ? substr(__MY_PUBLIC_URL__, 0, -1) : '', diff --git a/extend/base/Sms.php b/extend/base/Sms.php index 7e16c93a2ce9fa7a38c34ea5995635cb4a0f3c5c..fc02710d0a2d46224e2075afa70e8cf5ce63084e 100755 --- a/extend/base/Sms.php +++ b/extend/base/Sms.php @@ -82,21 +82,41 @@ class Sms $signature = base64_encode ( hash_hmac ( 'sha1', $stringToSign, $accessKeySecret . '&', true ) ); return $signature; } + /** - * @param unknown $mobile - * @param unknown $verify_code - * + * 短信发送 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-04-02 + * @desc description + * @param [string] $mobile [手机号码,多个以 英文逗号 , 分割] + * @param [string|array] $code [变量code(单个直接传入 code 即可,多个传入数组)] + * @param [string] $template_code [模板 id] + * @param [boolean] $sign_name [自定义签名,默认使用基础配置的签名] */ - public function SendCode($mobile, $code, $template_code) { - // 是否频繁操作 - if(!$this->IntervalTimeCheck()) - { - $this->error = '防止造成骚扰,请勿频繁发送'; - return false; - } + public function SendCode($mobile, $code, $template_code, $sign_name = '') + { + // 单个验证码需要校验是否频繁 + if(is_string($code)) + { + // 是否频繁操作 + if(!$this->IntervalTimeCheck()) + { + $this->error = '防止造成骚扰,请勿频繁发送'; + return false; + } + $codes = ['code'=>$code]; + } else { + $codes = $code; + } + + // 签名 + $SignName = empty($sign_name) ? $this->signName : $sign_name; + // 请求参数 $params = array ( //此处作了修改 - 'SignName' => $this->signName, + 'SignName' => $SignName, 'Format' => 'JSON', 'Version' => '2017-05-25', 'AccessKeyId' => $this->accessKeyId, @@ -107,7 +127,7 @@ class Sms 'Action' => 'SendSms', 'TemplateCode' => $template_code, 'PhoneNumbers' => $mobile, - 'TemplateParam' => '{"code":"' . $code . '"}' + 'TemplateParam' => json_encode($codes, JSON_UNESCAPED_UNICODE), ); //print_r($params);die; // 计算签名并把签名结果加入请求参数 @@ -132,7 +152,10 @@ class Sms } // 种session - $this->KindofSession($code); + if(is_string($code)) + { + $this->KindofSession($code); + } return true; }