短信优化,新增缓存
parent
cdec48a014
commit
18cf35818b
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -59,18 +59,16 @@ class GoodsService
|
|||
// 从缓存获取
|
||||
$key = config('shopxo.cache_goods_category_key');
|
||||
$data = cache($key);
|
||||
if(!empty($data))
|
||||
|
||||
if(empty($data))
|
||||
{
|
||||
return $data;
|
||||
// 获取分类
|
||||
$params['where'] = ['pid'=>0, 'is_enable'=>1];
|
||||
$data = self::GoodsCategory($params);
|
||||
|
||||
// 存储缓存
|
||||
cache($key, $data, 3600*24);
|
||||
}
|
||||
|
||||
// 获取分类
|
||||
$params['where'] = ['pid'=>0, 'is_enable'=>1];
|
||||
$data = self::GoodsCategory($params);
|
||||
|
||||
// 存储缓存
|
||||
cache($key, $data);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
),
|
||||
);
|
||||
?>
|
||||
|
|
@ -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) : '',
|
||||
|
||||
|
|
|
|||
|
|
@ -82,21 +82,41 @@ class Sms
|
|||
$signature = base64_encode ( hash_hmac ( 'sha1', $stringToSign, $accessKeySecret . '&', true ) );
|
||||
return $signature;
|
||||
}
|
||||
/**
|
||||
* @param unknown $mobile
|
||||
* @param unknown $verify_code
|
||||
*
|
||||
*/
|
||||
public function SendCode($mobile, $code, $template_code) {
|
||||
// 是否频繁操作
|
||||
if(!$this->IntervalTimeCheck())
|
||||
{
|
||||
$this->error = '防止造成骚扰,请勿频繁发送';
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信发送
|
||||
* @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, $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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue