123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <?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();
- parent::set_uid();
- }
- /**
- * @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:cover type:srting default:-- desc:图片路径
- * @return name:link' type:srting default:-- desc:链接
- */
- public function getBanner()
- {
- $num = input('get.num',20);
- $place = input('get.place',1);
- $list = Db::table('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/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:type type:int require:0 default:1 desc:商品类型(0全部,1售卖,3邀请)
- * @param name:sell_type type:int require:0 default:0 desc:售卖类型(0全部,1在售,2未售,3已售)
- * @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:detail type:int default:-- desc:商品详情
- * @return name:stock type:float default:-- desc:剩余库存
- * @return name:base_stock type:float default:-- desc:初始库存
- * @return name:sell_time type:string default:-- desc:开始售卖时间
- * @return name:adv_type type:int default:-- desc:广告类型(1图片,2mp3,3视频)
- * @return name:adv_cover type:string default:-- desc:广告图片
- * @return name:mp3_url type:string default:-- desc:广告mp3
- * @return name:audio_url type:string default:-- desc:广告视频
- * @return name:buy_notice type:string default:-- desc:购买须知
- * @return name:type type:int default:-- desc:商品类型(1售卖,2兑换,3邀请)
- * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
- * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
- * @return name:crystal type:float default:0 desc:赠送所需元石
- * @return name:gift_day type:int default:0 desc:赠送时间限制(天)
- * @return name:auth_img type:string default:0 desc:作者头像
- * @return name:goods_auth type:string default:0 desc:作者名
- * @return name:invite_num type:int default:0 desc:邀请人数
- * @return name:sell_day type:int default:0 desc:售卖天
- * @return name:sell_point type:int default:0 desc:售卖时间点
- */
- public function getGoodsList(){
- $type = input('type',0);
- $sell_type = input('sell_type',0);
- $sel_where = [];
- $sel_where[] = ['status','=',1];
- $sel_where[] = ['is_deleted','=',0];
- if(input('goods_name')) $sel_where[] = ['name','like',"%".input('goods_name')."%"];
- if($type){
- $sel_where[] = ['type','=',$type];
- }else{
- $sel_where[] = ['type','in','1,3'];
- }
- if($sell_type){
- switch ($sell_type){
- case 1:
- $sel_where[] = ['sell_time','<= time',date('Y-m-d 23:59:59')];
- $sel_where[] = ['stock','>',0];
- break;
- case 2:
- $sel_where[] = ['sell_time','> time',date('Y-m-d H:i:s')];
- $sel_where[] = ['stock','>',0];
- break;
- case 3:
- $sel_where[] = ['stock','=',0];
- break;
- }
- }
- $list = Db::table('store_goods')
- ->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/getPreSellGoods
- * @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:type type:int require:0 default:1 desc:商品类型(0全部,1售卖,3邀请)
- * @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:detail type:int default:-- desc:商品详情
- * @return name:stock type:float default:-- desc:剩余库存
- * @return name:base_stock type:float default:-- desc:初始库存
- * @return name:sell_time type:string default:-- desc:开始售卖时间
- * @return name:adv_type type:int default:-- desc:广告类型(1图片,2mp3,3视频)
- * @return name:adv_cover type:string default:-- desc:广告图片
- * @return name:mp3_url type:string default:-- desc:广告mp3
- * @return name:audio_url type:string default:-- desc:广告视频
- * @return name:buy_notice type:string default:-- desc:购买须知
- * @return name:type type:int default:-- desc:商品类型(1售卖,2兑换,3邀请)
- * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
- * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
- * @return name:crystal type:float default:0 desc:赠送所需元石
- * @return name:gift_day type:int default:0 desc:赠送时间限制(天)
- * @return name:auth_img type:string default:0 desc:作者头像
- * @return name:goods_auth type:string default:0 desc:作者名
- * @return name:invite_num type:int default:0 desc:邀请人数
- * @return name:sell_day type:int default:0 desc:售卖天
- * @return name:sell_point type:int default:0 desc:售卖时间点
- */
- public function getPreSellGoods()
- {
- $all_day = Db::table('store_goods')
- ->field('sell_day')
- ->where(['status'=>1,'is_deleted'=>0])
- ->where('stock','>',0)
- ->where('type','in','1,3')
- ->where('sell_day','>',date('Y-m-d'))
- ->where('sell_time','> time',date('Y-m-d 23:59:59'))
- ->group('sell_day')
- ->order('sell_day asc')
- ->select();
- $date = [];
- foreach ($all_day as $dv) {
- $date[$dv['sell_day']] = Db::table('store_goods')
- ->where(['status'=>1,'is_deleted'=>0])
- ->where('stock','>',0)
- ->where('sell_day',$dv['sell_day'])
- ->order('sell_time asc,id desc')
- ->select();
- }
- $this->success('ok',['list'=>$date]);
- }
- /**
- * @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:goods_price type:float default:-- desc:价格
- * @return name:detail type:int default:-- desc:商品详情
- * @return name:stock type:float default:-- desc:剩余库存
- * @return name:base_stock type:float default:-- desc:初始库存
- * @return name:sell_time type:string default:-- desc:开始售卖时间
- * @return name:adv_type type:int default:-- desc:广告类型(1图片,2mp3,3视频)
- * @return name:adv_cover type:string default:-- desc:广告图片
- * @return name:mp3_url type:string default:-- desc:广告mp3
- * @return name:audio_url type:string default:-- desc:广告视频
- * @return name:buy_notice type:string default:-- desc:购买须知
- * @return name:type type:int default:-- desc:商品类型(1售卖,2兑换)
- * @return name:is_gift type:int default:0 desc:是否允许赠送(0否1是)
- * @return name:crystal type:float default:0 desc:赠送所需元石
- * @return name:gift_day type:int default:0 desc:赠送时间限制(天)
- * @return name:invite_num type:int default:0 desc:邀请人数
- * @return name:share_img type:string default:0 desc:分享
- * @return name:goods_auth type:string default:0 desc:作者
- * @return name:auth_img type:string default:0 desc:作者头像
- * @return name:audio_line type:int default:0 desc:是否展示视频进度条(0否1是)
- * @return name:pay_pic type:string default:0 desc:支付完成弹窗图片
- * @return name:pay_content type:string default:0 desc:支付完成弹窗内容
- * @return name:vir_num type:string default:0 desc:收藏量
- * @return name:less_num type:int default:0 desc:还需邀请多少人
- * @return name:has_invite type:int default:0 desc:已邀请多少(已经领取的不算)
- * @return name:has_get type:int default:0 desc:已领取多少次
- * @return name:part_cal type:string default:0 desc:算法
- * @return name:part_link type:string default:0 desc:链接
- */
- public function getGoodsDetail()
- {
- $goods_id = input('goods_id');
- $detail = Db::table('store_goods')
- ->where(['id'=>$goods_id,'status'=>1,'is_deleted'=>0])
- ->find($goods_id);
- if(empty($detail)) $this->error('商品已下架');
- $detail['less_num'] = 0;
- $detail['has_invite'] = 0;
- $detail['part_cal'] = 'ED25519';
- $detail['part_link'] = 'JD China';
- $detail['is_login'] = 0;
- if(strtotime($detail['sell_time']) <= time()) $detail['sell_time'] = date("Y-m-d H:i:s", time() - 3600);
- if($detail['type'] == 3 && $this->uid){
- $detail['is_login'] = 1;
- $invite_num = Db::table('invite_info')->where(['pid'=>$this->uid,'status'=>1])->count();
- $detail['has_invite'] = $invite_num;
- $detail['has_get'] = Db::table('goods_collect')->where(['user_id'=>$this->uid,'goods_id'=>$goods_id,'source'=>3])->count();
- $detail['less_num'] = $detail['invite_num'] - $invite_num > 0 ? $detail['invite_num']-$invite_num :0;
- }
- $detail['goods_detail_switch'] = intval(sysconf('goods_detail_switch'));
- $detail['about_deliver'] = sysconf('about_deliver')?:'';
- $this->success('oK',['goods_info'=>$detail]);
- }
- /**
- * @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:about_us type:string default:-- desc:关于我们
- * @return name:service type:string default:-- desc:客服
- * @return name:intro_crystal type:string default:-- desc:什么是元石
- * @return name:platform_agreement type:string default:-- desc:平台协议
- * @return name:privacy type:string default:-- desc:隐私政策
- * @return name:self type:string default:-- desc:自定义文字
- * @return name:plat_name type:string default:-- desc:自定义标题名称
- * @return name:sell_switch type:int default:-- desc:销售历史开关(1开启,0关闭)
- * @return name:goods_detail_switch type:int default:-- desc:商品详情的开关(1开启,0关闭)
- */
- public function getSysConfig(){
- $con_name =['agreement','purchase_notice','about_us','service','intro_crystal','sell_switch','platform_agreement','privacy','self','plat_name','goods_detail_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);
- }
- /**
- * @title 什么是元石
- * @desc 什么是元石
- * @author qc
- * @method GET
- * @tag 编辑信息
- * @url /api/Expedite/introduceCrystal
- * @header name:Authorization require:0 desc:Token
- * @return name:str type:string default:-- desc:解释文案
- */
- public function introduceCrystal()
- {
- $intro_str = '作品的转赠请求需要消耗对应的元石数量。元石价格:1元/枚';
- $this->success('ok',['str'=>$intro_str]);
- }
- }
|