123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <?php
- namespace app\api\controller;
- use think\Db;
- /**
- * @title 不需要验证token接口(商品详情,商品列表等)
- * @controller Expedite
- * @package app\api\controller
- */
- class Expedite extends Base
- {
- public function initialize(){
- parent::initialize();
- }
- /**
- * @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:goods_info type:array default:-- desc:商品详情
- * @return name:goods_info.name type:string default:-- desc:商品名称
- * @return name:goods_info.cover type:string default:-- desc:商品封面图
- * @return name:goods_info.desc type:string default:-- desc:商品简述
- * @return name:goods_info.goods_price type:float default:-- desc:价格
- * @return name:goods_info.end_time type:float default:-- desc:结束时间
- * @return name:goods_info.spec type:string default:-- desc:魔盒设置
- * @return name:spec.award_name type:string default:-- desc:名称
- * @return name:spec.spec_img type:string default:-- desc:封面
- * @return name:spec.store_num type:string default:-- desc:剩余库存
- * @return name:spec.base_num type:string default:-- desc:初始库存
- * @return name:spec.crystal type:string default:-- desc:水晶价值
- * @return name:spec.rate type:string default:-- desc:抽中概率
- * @return name:goods_info.first_classify type:int default:-- desc:分类id
- * @return name:goods_info.detail type:int default:-- desc:商品详情
- * @return name:goods_info.stock type:float default:-- desc:剩余库存
- * @return name:goods_info.base_stock type:float default:-- desc:初始库存
- * @return name:goods_info.special_award type:array default:-- desc:特殊奖励设置(前后场两个奖励)
- * @return name:goods_info.special_award.title type:string default:-- desc:标题
- * @return name:goods_info.special_award.goods type:string default:-- desc:商品名
- * @return name:goods_info.special_award.cover type:string default:-- desc:图片
- * @return name:goods_info.special_award.crystal type:string default:-- desc:水晶
- * @return name:goods_info.special_award.is_over type:string default:-- desc:奖励是否完成
- * @return name:goods_info.special_point type:int default:-- desc:前后场分割数
- * @return name:goods_info.before_num type:int default:-- desc:前场数
- * @return name:goods_info.after_num type:int default:-- desc:后场数
- *
- */
- public function getGoodsDetail()
- {
- $goods_id = input('goods_id');
- $field = 'id,name,cover,desc,goods_price,spec,first_classify,detail,stock,base_stock,end_time,special_award,special_point';
- $detail = Db::table('store_goods')
- ->field($field)
- ->where(['id'=>$goods_id,'status'=>1,'is_deleted'=>0])
- ->find($goods_id);
- if(empty($detail)) $this->error('商品已下架');
- $detail['before_num'] = $detail['special_point'];
- $detail['after_num'] =$detail['base_stock'] - $detail['special_point'];
- $this->success('oK',['goods_info'=>$detail,]);
- }
- /**
- * @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:cate_id type:int require:0 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:goods_price type:float default:-- desc:价格
- * @return name:spec type:string default:-- desc:规格详情
- * @return name:spec.award_name type:string default:-- desc:名称
- * @return name:spec.spec_img type:string default:-- desc:封面
- * @return name:spec.store_num type:string default:-- desc:剩余库存
- * @return name:spec.base_num type:string default:-- desc:初始库存
- * @return name:spec.crystal type:string default:-- desc:水晶价值
- * @return name:first_classify type:int default:-- desc:一级分类id
- * @return name:detail type:int default:-- desc:商品详情
- * @return name:stock type:float default:-- desc:剩余库存
- * @return name:base_stock type:float default:-- desc:初始库存
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:goods_info.special_award type:array default:-- desc:特殊奖励设置(前后场两个奖励)
- * @return name:goods_info.special_award.title type:string default:-- desc:标题
- * @return name:goods_info.special_award.goods type:string default:-- desc:商品名
- * @return name:goods_info.special_award.cover type:string default:-- desc:图片
- * @return name:goods_info.special_award.crystal type:string default:-- desc:水晶
- * @return name:goods_info.special_award.is_over type:string default:-- desc:奖励是否完成
- */
- public function getGoodsList()
- {
- $sel_where = [];
- $sel_where[] = ['status','=',1];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['end_time','> time',date("Y-m-d H:i:s")];
- if(input('goods_name')) $sel_where[] = ['name','like',"%".input('goods_name')."%"];
- if(input('cate_id',0)) $sel_where[] = ['first_classify','=',input('cate_id')];
- $field = 'id,name,cover,desc,goods_price,spec,first_classify,detail,stock,base_stock,end_time,special_award';
- $list = Db::table('store_goods')
- ->field($field)
- ->where($sel_where)
- ->order('sort desc , id desc ')
- ->limit($this->off_set,$this->page_num)
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取商品分类(商城商品)
- * @desc 获取商品分类(商城商品)
- * @author qc
- * @url /api/Expedite/getGoodCate
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:array default:-- desc:商品详情
- * @return name:title type:string default:-- desc:分类名称
- */
- public function getGoodCate()
- {
- $list = Db::table('store_goods_cate')
- ->where('pid',0)
- ->where('status',1)
- ->where('is_deleted',0)
- ->field('id,title')
- ->order('sort desc , id desc')
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取首页轮播图
- * @desc 获取首页轮播图
- * @author qc
- * @url /api/Expedite/getBanner
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:num type:int default:5 desc:查询数量
- * @return name:name type:srting default:-- desc:标题
- * @return name:cover type:srting default:-- desc:图片路径
- * @return name:link type:srting default:-- desc:跳转地址
- */
- public function getBanner()
- {
- $num = input('get.num',20);
- $list = Db::table('store_banner')
- ->field('id,name,cover,link')
- ->where(['is_deleted'=>0])
- ->limit(0,$num)
- ->order('sort desc ,id desc')
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取订单列表(商城商品)
- * @desc 获取订单列表(商城商品)
- * @author qc
- * @url /api/Expedite/getOrderListByGoodsId
- * @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:1 default:-- desc:商品id
- * @return name:create_at type:string default:-- desc:时间
- * @return name:goods_name type:string default:-- desc:商品
- * @return name:name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- */
- public function getOrderListByGoodsId()
- {
- $goods_id = input('goods_id',0);
- $list = Db::table('goods_order')
- ->alias('o')
- ->field('o.create_at,o.goods_name,m.name,m.headimg')
- ->join('store_member m','o.uid = m.id')
- ->where('o.goods_id',$goods_id)
- ->where('o.pay_state',1)
- ->order('o.id desc ')
- ->limit($this->off_set,$this->page_num)
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取商品中奖详情
- * @desc 获取商品中奖详情
- * @author qc
- * @url /api/Expedite/getAwardDetailByGoodsId
- * @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:1 default:-- desc:商品id
- * @return name:create_at type:string default:-- desc:时间
- * @return name:award_name type:string default:-- desc:奖品标题
- * @return name:award_cover type:string default:-- desc:奖品图片
- * @return name:name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- */
- public function getAwardDetailByGoodsId()
- {
- $goods_id = input('goods_id',0);
- $list = Db::table('magic_draw')
- ->alias('d')
- ->field('d.award_name,d.award_cover,d.create_at,m.name,m.headimg')
- ->join('store_member m','d.user_id = m.id')
- ->where('d.goods_id',$goods_id)
- ->order('d.is_special desc,d.id desc ')
- ->limit($this->off_set,$this->page_num)
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取商品详情(兑换商品)
- * @desc 获取商品详情(兑换商品)
- * @author qc
- * @url /api/Expedite/getExchangeGoodsDetail
- * @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:crystal type:int default:-- desc:水晶
- * @return name:first_classify type:int default:-- desc:一级分类id
- * @return name:detail type:int default:-- desc:商品详情
- * @return name:stock type:float default:-- desc:剩余库存
- */
- public function getExchangeGoodsDetail()
- {
- $goods_id = input('goods_id');
- $field = 'id,name,cover,desc,first_classify,detail,stock,crystal';
- $detail = Db::table('exchange_goods')
- ->field($field)
- ->where(['id'=>$goods_id,'status'=>1,'is_deleted'=>0])
- ->find($goods_id);
- if(empty($detail)) $this->error('商品已下架');
- $this->success('oK',$detail);
- }
- /**
- * @title 获取商品列表(兑换商品)
- * @desc 获取商品列表(兑换商品)
- * @author qc
- * @url /api/Expedite/getExchangeGoodsList
- * @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:cate_id type:int require:0 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:crystal type:int default:-- desc:水晶
- * @return name:first_classify type:int default:-- desc:一级分类id
- * @return name:detail type:int default:-- desc:商品详情
- * @return name:stock type:float default:-- desc:剩余库存
- */
- public function getExchangeGoodsList()
- {
- $sel_where = [];
- $sel_where[] = ['status','=',1];
- $sel_where[] = ['is_deleted','=',0];
- if(input('goods_name')) $sel_where[] = ['name','like',"%".input('goods_name')."%"];
- if(input('cate_id',0)) $sel_where[] = ['first_classify','=',input('cate_id')];
- $field = 'id,name,cover,desc,first_classify,detail,stock,crystal';
- $list = Db::table('exchange_goods')
- ->field($field)
- ->where($sel_where)
- ->order('sort desc , id desc ')
- ->limit($this->off_set,$this->page_num)
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取平台设置
- * @desc 获取平台设置
- * @author qc
- * @url /api/Expedite/getSysConfig
- * @method GET
- * @return name:agreement type:string default:-- desc:用户协议
- * @return name:purchase_notice type:string default:-- desc:购买须知
- * @return name:platform_notice type:string default:-- desc:平台消息
- * @return name:crystal_switch type:string default:-- desc:提现开关(1开启0关闭)
- */
- public function getSysConfig(){
- $con_name =['agreement','purchase_notice','platform_notice','crystal_switch'];
- $set = Db::table('system_config')->where('name','in',$con_name)->select();
- $ret = [];
- foreach ($set as $value) {
- $ret[$value['name']]=$value['value'];
- }
- $this->success('获取成功',$ret);
- }
- }
|