123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608 |
- <?php
- namespace app\api\controller;
- use AlibabaCloud\Client\AlibabaCloud;
- use AlibabaCloud\Client\Exception\ClientException;
- use AlibabaCloud\Client\Exception\ServerException;
- use app\common\model\CouponConfig;
- use app\common\model\ExchangeGoods;
- use app\common\model\GoodsCate;
- use app\common\model\GoodsSeason;
- use app\common\model\GoodsSellInfo;
- use app\common\model\GoodsServe;
- use app\common\model\GoodsTerritory;
- use app\common\model\MallMenu;
- use app\common\model\OrderComment;
- use app\common\model\ReductionActivity;
- use app\common\model\RemarkLabel;
- use app\common\model\StoreGoods;
- use app\common\model\StoreGoodsItem;
- use app\common\model\TopSearch;
- use app\common\model\UserCollect;
- use app\common\model\UserTrack;
- use app\common\service\Activity;
- use think\Db;
- /**
- * @title 不需要验证token接口(商品列表等)
- * @controller Expedite
- * @package app\api\controller
- */
- class Expedite extends Base
- {
- public function initialize(){
- parent::initialize();
- parent::setUid();
- }
- /**
- * @title 获取首页轮播图(广告位)
- * @desc 获取首页轮播图(广告位)
- * @author qc
- * @url /api/Expedite/getBanner
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:place type:int default:1 desc:展示位置1商城首页2营养百科3视频专栏4商城商品5商城活动6商城分类7商城广告8预售
- * @param name:num type:int default:5 desc:查询数量
- * @return name:cover type:srting default:-- desc:图片路径
- * @return name:link type:srting default:-- desc:链接
- */
- public function getBanner()
- {
- $num = input('get.num',5);
- $place = input('get.place',1);
- $list = Db::name('store_banner')
- ->field('id,cover,link')
- ->where(['is_deleted'=>0,'place'=>$place])
- ->limit(0,$num)
- ->order('sort desc ,id desc')
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取首页小菜单
- * @desc 获取首页小菜单
- * @author qc
- * @url /api/Expedite/getIndexMenu
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:num type:int default:5 desc:查询数量
- * @return name:logo type:srting default:-- desc:图片路径
- * @return name:link type:srting default:-- desc:跳转链接
- */
- public function getIndexMenu()
- {
- $list = MallMenu::where('is_deleted',0)->where('pid',0)->select()->toArray();
- $this->success('ok',$list);
- }
- /**
- * @title 获取商品分类(四级)
- * @desc 获取商品分类(四级)
- * @author qc
- * @url /api/Expedite/getGoodsCate
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:int default:-- desc:分类id
- * @return name:title type:srting default:-- desc:标题
- * @return name:logo type:srting default:-- desc:图片路径
- * @return name:lev type:srting default:-- desc:分类等级(1,2,3,4)
- * @return name:children type:array default:-- desc:下级分类(数据同上)
- */
- public function getGoodsCate()
- {
- $list = GoodsCate::getCateTree();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取商品第一级分类
- * @desc 获取商品第一级分类
- * @author qc
- * @url /api/Expedite/getFirstClassify
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:int default:-- desc:分类id
- * @return name:title type:srting default:-- desc:标题
- * @return name:logo type:srting default:-- desc:图片路径
- * @return name:lev type:srting default:-- desc:分类等级
- */
- public function getFirstClassify()
- {
- $list = GoodsCate::field('id,title,logo,lev')->where('lev',1)->select()->toArray();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取商品时令设置(二级)
- * @desc 获取商品时令设置(二级)
- * @author qc
- * @url /api/Expedite/getGoodsSeason
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:int default:-- desc:分类id
- * @return name:title type:srting default:-- desc:标题
- * @return name:lev type:srting default:-- desc:分类等级(1,2)
- * @return name:children type:array default:-- desc:下级分类(数据同上)
- */
- public function getGoodsSeason()
- {
- $list = GoodsSeason::getSeasonTree();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取商品地域设置(二级)
- * @desc 获取商品地域设置(二级)
- * @author qc
- * @url /api/Expedite/getGoodsTerritory
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:int default:-- desc:分类id
- * @return name:title type:srting default:-- desc:标题
- * @return name:lev type:srting default:-- desc:分类等级(1,2)
- * @return name:children type:array default:-- desc:下级分类(数据同上)
- */
- public function getGoodsTerritory()
- {
- $list = GoodsTerritory::getTerritoryTree();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取商品列表
- * @desc 获取商品列表
- * @author qc
- * @url /api/Expedite/getGoodsList
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:1 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:goods_name type:string require:0 default:-- desc:商品名称
- * @param name:first_classify type:int require:0 default:-- desc:一级分类id
- * @param name:second_classify type:int require:0 default:-- desc:二级分类id
- * @param name:third_classify type:int require:0 default:-- desc:三级分类id
- * @param name:fourth_classify type:int require:0 default:-- desc:四级分类id
- * @param name:is_presell type:int require:0 default:0 desc:是否是预售(0否1是)
- * @param name:first_season type:int require:0 default:-- desc:第一级时令id
- * @param name:second_season type:int require:0 default:-- desc:第二级时令id
- * @param name:first_territory type:int require:0 default:-- desc:第一级地域id
- * @param name:second_territory type:int require:0 default:-- desc:第二级地域id
- * @param name:column_id type:int require:0 default:-- desc:推荐专栏id
- * @param name:is_zx type:int require:0 default:-1 desc:是否是产地直销(-1全部,0否,1是)
- * @return name:name type:string default:-- desc:商品名称
- * @return name:cover type:string default:-- desc:商品封面图
- * @return name:desc type:string default:-- desc:商品简述(副标题)
- * @return name:low_price type:float default:-- desc:最低售价
- * @return name:low_original type:float default:-- desc:最低原价格
- * @return name:total_num type:int default:-- desc:商品总数量
- * @return name:detail type:int default:-- desc:商品详情
- * @return name:first_classify type:int require:0 default:-- desc:一级分类id
- * @return name:second_classify type:int require:0 default:-- desc:二级分类id
- * @return name:third_classify type:int require:0 default:-- desc:三级分类id
- * @return name:fourth_classify type:int require:0 default:-- desc:四级分类id
- * @return name:freight_type type:int default:-- desc:运费类型0固定金额,1运费模板
- * @return name:freight_id type:int default:-- desc:模板id(freight_type=1)
- * @return name:postage type:float default:-- desc:运费(freight_type=0)
- * @return name:share_money type:float default:-- desc:分享返利金额
- * @return name:source_pic type:string default:-- desc:商品溯源图(多张)
- * @return name:goods_match type:string default:-- desc:商品搭配推荐(多个用|隔开)
- * @return name:item_list type:array default:-- desc:商品多规格列表
- * @return name:item_list.spec_info type:array default:-- desc:规格型号设置['规格组id'=>'规格id','规格组id'=>'规格id'];
- * @return name:item_list.goods_no type:string default:-- desc:规格货号
- * @return name:item_list.goods_title:string default:-- desc:规格标题
- * @return name:item_list.cover type:string default:-- desc:规格封面
- * @return name:item_list.stock type:int default:-- desc:剩余库存
- * @return name:item_list.original_price type:float default:-- desc:原价
- * @return name:item_list.sell_price type:float default:-- desc:售价
- * @return name:item_list.sell_price type:float default:-- desc:售价
- * @return name:first_classify_name type:int require:0 default:-- desc:一级分类名
- * @return name:second_classify_name type:int require:0 default:-- desc:二级分类名
- * @return name:third_classify_name type:int require:0 default:-- desc:三级分类名
- * @return name:fourth_classify_name type:int require:0 default:-- desc:四级分类名
- * @return name:is_presell type:int require:0 default:-- desc:是否是预售商品(0否1是)
- * @return name:sell_time type:string require:0 default:-- desc:预售时间
- * @return name:first_season type:int require:0 default:0 desc:第一级时令id
- * @return name:second_season type:int require:0 default:0 desc:第二级时令id
- * @return name:first_territory type:int require:0 default:0 desc:第一级地域id
- * @return name:second_territory type:int require:0 default:0 desc:第二级地域id
- * @return name:first_season_name type:string require:0 default:0 desc:第一级时令名称
- * @return name:second_season_name type:string require:0 default:0 desc:第二级时令名称
- * @return name:first_territory_name type:string require:0 default:0 desc:第一级地域名称
- * @return name:second_territory_name type:string require:0 default:0 desc:第二级地域名称
- */
- public function getGoodsList(){
- $all_cate = GoodsCate::field('id,title')->select()->toArray();
- $all_cate = array_column($all_cate,null,'id');
- $all_season = GoodsSeason::field('id,title')->select()->toArray();
- $all_season = array_column($all_season,null,'id');
- $all_territory= GoodsTerritory::field('id,title')->select()->toArray();
- $all_territory = array_column($all_territory,null,'id');
- $input = input('get.');
- $sel_where = [];
- $sel_where[] = ['status','=',1];
- $sel_where[] = ['is_deleted','=',0];
- if(isset_full($input,'goods_name'))$sel_where[] = ['name','like',"%".$input['goods_name']."%"];
- if(isset_full($input,'first_classify'))$sel_where[] = ['first_classify','=',$input['first_classify']];
- if(isset_full($input,'second_classify'))$sel_where[] = ['second_classify','=',$input['second_classify']];
- if(isset_full($input,'third_classify'))$sel_where[] = ['third_classify','=',$input['third_classify']];
- if(isset_full($input,'fourth_classify'))$sel_where[] = ['fourth_classify','=',$input['fourth_classify']];
- if(isset_full($input,'first_season'))$sel_where[] = ['first_season','=',$input['first_season']];
- if(isset_full($input,'second_season'))$sel_where[] = ['second_season','=',$input['second_season']];
- if(isset_full($input,'first_territory'))$sel_where[] = ['first_territory','=',$input['first_territory']];
- if(isset_full($input,'second_territory'))$sel_where[] = ['second_territory','=',$input['second_territory']];
- if(isset_full($input,'column_id'))$sel_where[] = ['column_id','=',$input['column_id']];
- if(isset($input['is_zx']) && $input['is_zx'] >=0 ) $sel_where[] = ['is_zx','=',$input['is_zx']];
- if(isset_full($input,'is_presell')){
- $sel_where[] = ['is_presell','=',$input['is_presell']];
- }else{
- $sel_where[] = ['is_presell','=',0];
- }
- $list = StoreGoods::with(['itemList'])->where($sel_where)->limit($this->off_set,$this->page_num)->select()->toArray();
- foreach ($list as &$v){
- $v['first_classify_name'] = isset($all_cate[$v['first_classify']]['title']) ? $all_cate[$v['first_classify']]['title']:'';
- $v['second_classify_name'] = isset($all_cate[$v['second_classify']]['title']) ? $all_cate[$v['second_classify']]['title']:'';
- $v['third_classify_name'] = isset($all_cate[$v['third_classify']]['title']) ? $all_cate[$v['third_classify']]['title']:'';
- $v['fourth_classify_name'] = isset($all_cate[$v['fourth_classify']]['title']) ?$all_cate[$v['fourth_classify']]['title']:'';
- $v['low_original'] = min(array_column($v['item_list'],'original_price'));
- $v['low_price'] = min(array_column($v['item_list'],'sell_price'));
- $v['first_season_name'] = isset($all_season[$v['first_season']]['title']) ? $all_season[$v['first_season']]['title']:'';
- $v['second_season_name'] = isset($all_season[$v['second_season']]['title']) ? $all_season[$v['second_season']]['title']:'';
- $v['first_territory_name'] = isset($all_territory[$v['first_territory']]['title']) ? $all_territory[$v['first_territory']]['title']:'';
- $v['second_territory_name'] = isset($all_territory[$v['second_territory']]['title']) ? $all_territory[$v['second_territory']]['title']:'';
- $v['total_num'] = array_sum(array_column($v['item_list'],'base_stock'));
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取商品详情
- * @desc 获取商品详情
- * @author qc
- * @url /api/Expedite/getGoodsDetail
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:goods_id type:int require:1 default:0 desc:商品id
- * @return name:name type:string default:-- desc:商品名称
- * @return name:cover type:string default:-- desc:商品封面图
- * @return name:desc type:string default:-- desc:商品简述(副标题)
- * @return name:low_price type:float default:-- desc:最低价格
- * @return name:max_price type:float default:-- desc:最高价格(下划线公用)
- * @return name:low_seckill type:float default:-- desc:最低秒杀价格(有秒杀活动)
- * @return name:low_group type:float default:-- desc:最低拼团价格(有拼团活动)
- * @return name:low_discount type:float default:-- desc:最低折扣价格(有折扣活动)
- * @return name:discount type:float default:-- desc:商品折扣(没有折扣为10,有折扣活动,例如75折,值为7.5)
- * @return name:freight_type type:int default:-- desc:运费类型0固定金额,1运费模板
- * @return name:freight_id type:int default:-- desc:模板id(freight_type=1)
- * @return name:postage type:float default:-- desc:运费(freight_type=0)
- * @return name:is_collect type:int default:-- desc:是否收藏(1是0否)
- * @return name:effect type:string default:-- desc:商品功效(多个用|隔开)
- * @return name:explain type:string default:-- desc:商品说明(使用说明)
- * @return name:share_money type:float default:-- desc:分享返利金额
- * @return name:source_pic type:string default:-- desc:商品溯源图(多张)
- * @return name:goods_match type:string default:-- desc:商品搭配推荐(多个用|隔开)
- * @return name:remark_title type:array default:-- desc:评论标签(数组)
- * @return name:serve_title type:array default:-- desc:服务标签(数组)
- * @return name:is_presell type:int require:0 default:-- desc:是否是预售商品(0否1是,预售商品不加购物)
- * @return name:sell_time type:string require:0 default:-- desc:预售时间
- * @return name:first_season type:int require:0 default:0 desc:第一级时令id
- * @return name:second_season type:int require:0 default:0 desc:第二级时令id
- * @return name:first_territory type:int require:0 default:0 desc:第一级地域id
- * @return name:second_territory type:int require:0 default:0 desc:第二级地域id
- * @return name:first_season_name type:string require:0 default:0 desc:第一级时令名称
- * @return name:second_season_name type:string require:0 default:0 desc:第二级时令名称
- * @return name:first_territory_name type:string require:0 default:0 desc:第一级地域名称
- * @return name:second_territory_name type:string require:0 default:0 desc:第二级地域名称
- * @return name:item_list type:array default:-- desc:商品多规格列表
- * @return name:item_list.spec_info type:array default:-- desc:规格型号设置;
- * @return name:item_list.goods_no type:string default:-- desc:规格货号
- * @return name:item_list.goods_title:string default:-- desc:规格标题
- * @return name:item_list.cover type:string default:-- desc:规格封面
- * @return name:item_list.stock type:int default:-- desc:剩余库存
- * @return name:item_list.original_price type:float default:-- desc:原价
- * @return name:item_list.sell_price type:float default:-- desc:售价
- * @return name:item_list.seckill_price type:float default:-- desc:秒杀价(没有秒杀活动则=售价)
- * @return name:goods_param type:array default:-- desc:商品相关参数
- * @return name:goods_param.title type:string default:-- desc:参数名
- * @return name:goods_param.value type:string default:-- desc:参数值
- * @return name:seckill type:array default:-- desc:秒杀活动详情(为空:商品没有正在进行的秒杀活动)
- * @return name:seckill.start_time type:string default:-- desc:开始时间
- * @return name:seckill.end_time type:string default:-- desc:结束时间
- * @return name:group type:array default:-- desc:拼团活动
- * @return name:group.start_time type:string default:-- desc:开始时间
- * @return name:group.end_time type:string default:-- desc:结束时间
- * @return name:group.full_num type:int default:-- desc:成团人数
- * @return name:discount_act type:array default:-- desc:折扣活动
- * @return name:discount_act.id type:int default:-- desc:折扣活动id
- * @return name:reduction type:array default:-- desc:满减活动
- * @return name:reduction.id type:int default:-- desc:满减活动id
- * @return name:reduction.title type:string default:-- desc:满减标题
- * @return name:reduction.start_time type:string default:-- desc:满减开始时间
- * @return name:reduction.end_time type:string default:-- desc:满减结束时间
- * @return name:reduction.act_set type:array default:-- desc:满减设置
- * @return name:reduction.act_set.full type:float default:-- desc:满多少
- * @return name:reduction.act_set.reduction type:float default:-- desc:减多少
- *
- */
- public function getGoodsDetail()
- {
- $goods_id = input('goods_id');
- if($this->user_id)UserTrack::createTrack($this->user_id,1,$goods_id);
- $detail = StoreGoods::with(['itemList'])->field('g.*,p.goods_param')->alias('g')->leftJoin('GoodsParam p','g.base_id = p.goods_id')->where('g.id',$goods_id)->find()->toArray();
- if(isset($detail['goods_param']) && !empty($detail['goods_param'])) $detail['goods_param'] = json_decode($detail['goods_param'],true);
- $detail['max_price'] = max(array_column($detail['item_list'],'original_price'));
- $detail['remark_title'] = RemarkLabel::getRemarkLabelTitle($detail['remark_label']);
- $detail['serve_title'] = GoodsServe::getServeLabelTitle($detail['serve_label']);
- $detail['first_season_name'] ='';
- $detail['first_season_name'] ='';
- $detail['first_territory_name'] ='';
- $detail['first_season_name'] ='';
- if($detail['first_season']) $detail['first_season_name'] = GoodsSeason::where('id',$detail['first_season'])->value('title');
- if($detail['second_season']) $detail['second_season_name'] = GoodsSeason::where('id',$detail['second_season'])->value('title');
- if($detail['first_territory']) $detail['first_territory_name'] = GoodsTerritory::where('id',$detail['first_territory'])->value('title');
- if($detail['second_territory']) $detail['second_territory_name'] = GoodsTerritory::where('id',$detail['second_territory'])->value('title');
- $goods_act = Activity::goodsActivityList($goods_id);
- $detail['discount'] = 10;
- foreach ($detail['item_list'] as $ik=>&$iv)
- {
- // $iv['stock'] = $iv['depot_item_info']['stock'];// 仓库库存
- $iv['seckill_price'] = $iv['sell_price'];
- $iv['group_price'] = $iv['sell_price'];
- $iv['discount_price'] = $iv['sell_price'];
- // 秒杀
- if(!empty($goods_act['seckill']['goods'])){
- foreach ($goods_act['seckill']['goods']['item'] as $sv){
- if($sv['spec_id'] == $iv['id']){
- $iv['seckill_price'] = $sv['seckill_price'];
- break;
- }
- }
- }
- // 拼团
- if(!empty($goods_act['group']['goods'])){
- foreach ($goods_act['group']['goods']['item'] as $gv){
- if($gv['spec_id'] == $iv['id']){
- $iv['group_price'] = $gv['group_price'];
- break;
- }
- }
- }
- // 折扣活动
- if(!empty($goods_act['discount']['act'])){
- $detail['discount'] = bcdiv($goods_act['discount']['act']['discount'],10,1);
- $iv['discount_price'] = bcmul($iv['sell_price'],$goods_act['discount']['act']['discount']/100,2);
- }
- }
- $detail['low_seckill'] = min(array_column($detail['item_list'],'seckill_price'));
- $detail['low_group'] = min(array_column($detail['item_list'],'group_price'));
- $detail['low_discount'] = min(array_column($detail['item_list'],'discount_price'));
- $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$goods_id);
- $this->success('oK',[
- 'goods_info'=>$detail,
- 'seckill'=>$goods_act['seckill']['act'],
- 'group'=>$goods_act['group']['act'],
- 'discount_act'=>$goods_act['discount']['act'],
- 'reduction'=>ReductionActivity::getAct(),
- ]);
- }
- /**
- * @title 获取商品评论
- * @desc 获取商品评论
- * @author qc
- * @url /api/Expedite/getGoodsComment
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:1 desc:页数
- * @param name:page_num type:int : default:20 desc:每页数
- * @param name:goods_id type:string require:0 default:-- desc:商品名称
- * @param name:create_at type:string require:0 default:-- desc:时间
- * @param name:spec_id type:string require:0 default:-- desc:规格id
- * @param name:sort_type type:int require:0 default:-- desc:排序(1,时间,2商品评分,3物流评分,4服务评分)
- * @param name:order_by type:int require:0 default:2 desc:排序规则(1升序,2降序)
- * @param name:type type:int require:0 default:0 desc:查询类型(0全部,1有图片)
- * @return name:spec_id type:string require:0 default:-- desc:规格id
- * @return name:content type:string default:-- desc:内容
- * @return name:images type:string default:-- desc:图片
- * @return name:video type:string default:-- desc:视频
- * @return name:goods_core type:int default:-- desc:商品评分
- * @return name:wl_core type:int default:-- desc:物流评分
- * @return name:serve_core type:int default:-- desc:服务评分
- * @return name:user type:array default:-- desc:会员信息
- * @return name:user.name type:string default:-- desc:会员名
- * @return name:user.headimg type:string default:-- desc:会员头像
- * @return name:total type:int default:-- desc:总评论数量
- */
- public function getGoodsComment()
- {
- $goods_id = input('get.goods_id');
- $spec_id = input('get.spec_id');
- $sort_type = input('get.sort_type',0);
- $order_by = input('get.order_by',2);
- $type = input('get.type',0);
- $oby = $order_by == 1 ?'asc' : 'desc';
- $where = [];
- $where[] = ['goods_id','=',$goods_id];
- if($spec_id) $where[] = ['spec_id','=',$spec_id];
- if($type) $where[] = ['images','<>',''];
- $sort_arr = ['id','id','goods_core','wl_core','serve_core'];
- $total = OrderComment::where($where)->count();
- $list = OrderComment::with('user')->where($where)
- ->order($sort_arr[$sort_type].' '.$oby)
- ->limit($this->off_set,$this->page_num)
- ->select();
- $this->success('ok',['list'=>$list ? $list->toArray():[],'total'=>$total]);
- }
- /**
- * @title 获取平台文案设置
- * @desc 获取平台文案设置
- * @author qc
- * @url /api/Expedite/getSysConfig
- * @method GET
- * @param name:search_name type:string default:-- desc:根据下面名称查(不传查全部的)
- * @return name:agreement type:string default:-- desc:用户协议
- * @return name:about_us type:string default:-- desc:关于我们
- * @return name:privacy type:string default:-- desc:隐私政策
- * @return name:agent_notice type:string default:-- desc:代理商须知
- * @return name:partner_item type:string default:-- desc:分销条款
- * @return name:refund_desc type:string default:-- desc:退款退货说明
- * @return name:user_equity type:string default:-- desc:会员权益
- * @return name:integral_channel type:string default:-- desc:积分渠道
- * @return name:sign_rule type:string default:-- desc:签到规则
- * @return name:write_off type:string default:-- desc:注销须知
- * @return name:customer_service type:string default:-- desc:客服设置
- */
- public function getSysConfig(){
- $search_name = input('get.search_name');
- $con_name = $search_name? [$search_name] : ['agreement','about_us','privacy','agent_notice','partner_item','refund_desc','user_equity','integral_channel','sign_rule','write_off','customer_service'];
- $set = Db::name('system_config')->where('name','in',$con_name)->select();
- $ret = [];
- foreach ($set as $value) {
- $ret[$value['name']]=$value['value'];
- }
- $this->success('获取成功',$ret);
- }
- /**
- * @title 获取所有的优惠券设置
- * @desc 获取所有的优惠券设置
- * @author qc
- * @method GET
- * @url /api/Expedite/getCouponConfig
- * @param name:goods_id type:int require:0 default:限制商品id
- * @return name:id type:int default:-- desc:会员优惠券记录id
- * @return name:coupon_type type:int default:-- desc:优惠券类型0全场券1商品券
- * @return name:goods_id type:int default:-- desc:商品id
- * @return name:title type:int default:-- desc:标题
- * @return name:low_amount type:float default:-- desc:最低消费限制
- * @return name:amount type:float default:-- desc:券额
- * @return name:time_type type:int default:-- desc:使用时间限制0数限制(low_day)1时间限制(start_tm--end_tm)
- * @return name:low_day type:int default:-- desc:限制天数
- * @return name:start_tm type:string default:-- desc:开始使用时间
- * @return name:end_tm type:string default:-- desc:结束使用时间
- * @return name:status type:int default:-- desc:状态 (状态 0:失效 1:正常)
- * @return name:create_at type:string default:-- desc:时间
- * @return name:num type:int default:-- desc:优惠券总数量
- * @return name:user_num type:int default:-- desc:每人限制领取张数0不限制
- */
- public function getCouponConfig()
- {
- $goods_id = input('get.goods_id',0);
- $where = [];
- $where[] = ['is_deleted','=',0];
- $where[] = ['status','=',1];
- if($goods_id)$where[] = ['goods_id','in',[0,$goods_id]];
- $list = CouponConfig::where($where)->order('id desc')->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 发送短信验证码
- * @desc 发送短信验证码
- * @author qc
- * @url /api/Expedite/sendSms
- * @method POST
- * @param name:phone type:int require:1 default:-- desc:要获取验证码的手机号
- * @return name:code type:string default:-- desc:验证码
- */
- public function sendSms(){
- $phone = input('post.phone');
- if(empty($phone)) $this ->error('参数错误');
- $code = rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
- AlibabaCloud::accessKeyClient('LTAI5tEEfowhMkLu8auo6n6G', 'ch94CL3TEwNAxXNREweZl3gfk8jQ84')
- ->regionId('cn-hangzhou')->asDefaultClient();
- try {
- $result = AlibabaCloud::rpc()
- ->product('Dysmsapi')
- ->version('2017-05-25')
- ->action('SendSms')
- ->method('POST')
- ->host('dysmsapi.aliyuncs.com')
- ->options([
- 'query' => [
- 'RegionId' => "cn-hangzhou",
- 'PhoneNumbers' => $phone,
- 'SignName' => "康养食品",
- 'TemplateCode' => "SMS_241155218",
- 'TemplateParam' => json_encode(array("code"=>$code)),
- ],
- ])->request();
- $result = $result->toArray();
- if($result['Code'] == "OK") {
- $sms_data = array(
- 'phone'=>$phone,
- 'code'=>$code,
- 'result'=>$result['Message']
- );
- Db::name('store_member_sms')->insert($sms_data);
- $this->success('发送成功',$code);
- }else{
- $this->error('发送失败');
- }
- } catch (ClientException $e) {
- $this->error($e->getErrorMessage() . PHP_EOL);
- } catch (ServerException $e) {
- $this->error($e->getErrorMessage() . PHP_EOL);
- }
- }
- /**
- * @title 获取商品热搜设置
- * @desc 获取商品热搜设置
- * @author qc
- * @url /api/Expedite/goodsTopSearch
- * @method GET
- * @return name:title type:string default:-- desc:标题
- */
- public function goodsTopSearch()
- {
- $list = TopSearch::field('id,title')->where(['status'=>1,'is_deleted'=>0])->order('sort desc,id desc')->select()->toArray();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取热销商品
- * @desc 获取热销商品
- * @author qc
- * @url /api/Expedite/getHotSell
- * @method GET
- * @return name:goods_id type:int default:-- desc:商品id
- * @return name:name type:string default:-- desc:商品名
- * @return name:cover type:string default:-- desc:商品图片
- * @return name:low_price type:float default:-- desc:最低价
- * @return name:line_money type:float default:-- desc:下划线价格
- */
- public function getHotSell()
- {
- $sel_time = date('Y-m-d H:i:s',strtotime('-70 days'));
- $list = GoodsSellInfo::field('i.goods_id,sum(i.num) total_num,g.name,g.cover,g.low_price')->where('i.create_at','> time',$sel_time)
- ->alias('i')
- ->leftJoin('StoreGoods g','g.id = i.goods_id')
- ->group('i.goods_id')
- ->order('total_num desc')
- ->limit(0,20)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['line_money'] = StoreGoodsItem::where(['goods_id'=>$v['goods_id']])->max('original_price');
- });
- $this->success('ok',['list'=>$list]);
- }
- }
|