request->path()); if(in_array(end($path),['CollectionDetail']) )parent::set_uid(); if(!in_array(end($path),['CollectionDetail']) )parent::check_login(); } /** * @title 获取轮播图列表 * @desc 获取轮播图列表 * @author Gavin * @url /api/Index/getBanner * @method POST * @header name:Authorization require:1 desc:Token * @return name:id type:int require:0 default:0 desc:轮播图id * @return name:name type:string require:0 default:0 desc:标题 * @return name:cover type:string require:0 default:0 desc:图片 * @return name:content type:string require:0 default:0 desc:内容【富文本】 */ public function getBanner() { $list = Db::table('store_banner') ->field('id,name,cover,content') ->where(['is_deleted'=>0]) ->order('sort desc ,id desc') ->cache(300) ->select(); $this->success('ok',$list); } /** * @title 获取轮播图详情 * @desc 获取轮播图详情 * @author Gavin * @url /api/Index/getBannerInfo * @method GET * @header name:Authorization require:1 desc:Token * @param name:id type:int require:0 default:0 desc:轮播图id * @return name:name type:string require:0 default:0 desc:标题 * @return name:cover type:string require:0 default:0 desc:图片 * @return name:content type:string require:0 default:0 desc:内容【富文本】 */ public function getBannerInfo() { $detail = Db::table('store_banner')->field('id,name,cover,content')->where(['id'=>input('id')])->find(); $this->success('ok',['detail'=>$detail]); } /** * @title 首页藏品列表 * @desc 首页藏品列表 * @author Gavin * @url /api/Index/indexCollectionList * @method POST * @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:type type:int require:-- default:0 desc:0全部1普通藏品3盲盒 * @param name:issue_mode type:int require:-- default:0 desc:发行方式(0全部1普通发行2抽签发行) * * @return name:name type:string default:-- desc:藏品名称 * @return name:cover type:string default:-- desc:藏品图 * @return name:label type:string default:-- desc:标签 * @return name:price type:DECIMAL default:-- desc:价格 * @return name:inventory type:int default:-- desc:库存 * @return name:type type:int default:-- desc:1普通藏品3盲盒 * @return name:now_inventory type:int default:-- desc:剩余库存 * @return name:state type:float default:-- desc:藏品状态(1:进行中2:即将开售3:已售罄) * @return name:sell_time type:string default:-- desc:发行时间[抽签时间,报名结束时间] * @return name:issue_mode type:string default:-- desc:发行方式(1普通发行2抽签发行) * @return name:is_remind type:string default:-- desc:是否设置提醒true:已设置false:未设置 * @return name:auth_name type:string default:-- desc:作者名称 * @return name:auth_img type:string default:-- desc:作者头像 * @return name:issue_mode type:string default:-- desc:发行方式(1普通发行2抽签发行) * @return name:apply_st type:string default:-- desc:抽签报名开始时间【普通发行忽略】 */ public function indexCollectionList(){ checkCollectionState(); $type = input('type',0); if(!in_array($type,[0,1,3])) $this->error('参数错误'); $in_type = $type == 0 ? '1,3' : $type; $issue_mode = input('issue_mode',0); /* $list = Db::name('store_collection') ->where('is_deleted',0) ->where('status',1) ->whereIn('type',$in_type) ->where('sell_time','< time',date("Y-m-d 23:59:59")) ->when($issue_mode,function ($query)use($issue_mode){ if($issue_mode) $query->where('issue_mode',$issue_mode);}) ->field('id,cover,name,type,label,price,inventory,now_inventory,state,sell_time,advance_info,auth_name,auth_img,issue_mode,apply_st,before_time') ->order('state asc,sell_time asc') ->limit($this->off_set,$this->page_num) ->select();*/ $list = Db::name('store_collection')->where(function ($query)use($in_type,$issue_mode){ if($issue_mode){ return $query->where('status',1)->where('is_deleted',0)->whereIn('type',$in_type)->where('sell_time','< time',date("Y-m-d 23:59:59"))->where('issue_mode',$issue_mode); }else{ return $query->where('status',1)->where('is_deleted',0)->whereIn('type',$in_type)->where('sell_time','< time',date("Y-m-d 23:59:59")); } })->whereOr(function ($query)use($in_type,$issue_mode){ if($issue_mode){ return $query->where('status',1)->where('is_deleted',0)->whereIn('type',$in_type)->where('id',2)->where('issue_mode',$issue_mode); }else{ return $query->where('status',1)->where('is_deleted',0)->whereIn('type',$in_type)->where('id',2); } })->field('id,cover,name,type,label,price,inventory,now_inventory,state,sell_time,advance_info,auth_name,auth_img,issue_mode,apply_st,before_time') ->order('state asc,sell_time asc') ->limit($this->off_set,$this->page_num) ->select(); foreach ($list as &$v){ $advance_minutes = $v['before_time']; // 验证产品赋能优先购 if($v['issue_mode'] == 1){ $priority = checkMemberPriority($this->uid,$v['id']); if($priority){ $sell_time = strtotime($v['sell_time'])-($advance_minutes * 60); if ($sell_time <= time()) $info['state'] = 1; $info['sell_time'] = date('Y-m-d H:i:s',$sell_time); } } $now_inventory = getCollectionInventory($v['id']); $v['now_inventory'] = $now_inventory<=0 ? 0 : $now_inventory; $v['is_remind'] = getRemind($this->uid,$v['id']) ? true : false; } $this->success('成功',$list); } /** * @title 发售日历 * @desc 发售日历 * @author Gavin * @url /api/Index/CollectionCalendar * @method POST * @header name:Authorization require:1 desc:Token * @param name:type type:int require:-- default:0 desc:0普通藏品&&盲盒1普通藏品3盲盒 * @return name:name type:string default:-- desc:藏品名称 * @return name:cover type:string default:-- desc:藏品图 * @return name:label type:string default:-- desc:标签 * @return name:price type:DECIMAL default:-- desc:价格 * @return name:inventory type:int default:-- desc:库存 * @return name:type type:int default:-- desc:1普通藏品3盲盒 * @return name:now_inventory type:int default:-- desc:剩余库存 * @return name:state type:float default:-- desc:藏品状态(1:进行中2:即将开售3:已售罄) * @return name:sell_time type:string default:-- desc:发行时间[抽签时间,报名结束时间] * @return name:date type:string default:-- desc:日期 * @return name:time type:string default:-- desc:时间 * @return name:is_remind type:string default:-- desc:是否设置提醒true:已设置false:未设置 */ public function CollectionCalendar(){ checkCollectionState(); $type = input('type',0); $in_type= $type ? $type :'1,3'; $datelist = Db::name('store_collection') ->where('is_deleted',0) ->where('status',1) ->where('state',2) ->whereIn('type',$in_type) ->where('date','>=',date('Y-m-d',time()+86400)) ->group('date') ->order('date asc') ->column('date'); if ($datelist){ foreach ($datelist as $k=>&$v){ $array[$k]['date'] = $v; $list = Db::name('store_collection') ->where('is_deleted',0) ->where('status',1) ->where('state',2) ->where('date',$v) ->whereIn('type',$in_type) ->field('id,cover,name,label,price,inventory,now_inventory,state,sell_time,date,issue_mode,apply_st') ->order('state asc,sell_time asc') ->select(); foreach ($list as &$a){ $a['time'] = date('H:i',strtotime($a['sell_time'])); $a['is_remind'] = getRemind($this->uid,$a['id']) ? true : false; $now_inventory = getCollectionInventory($a['id']); $a['now_inventory'] = $now_inventory<=0 ? 0 : $now_inventory; } $array[$k]['list'] = $list; } }else $array=[]; $this->success('成功',$array); } /** * @title 藏品详情 * @desc 藏品详情 * @author Gavin * @url /api/Index/CollectionDetail * @method POST * @header name:Authorization require:1 desc:Token * * @param name:id type:string require:1 default:-- desc:藏品ID * * @return name:name type:string default:-- desc:藏品名称 * @return name:cover type:string default:-- desc:藏品图 * @return name:label type:string default:-- desc:标签 * @return name:price type:DECIMAL default:-- desc:价格 * @return name:inventory type:int default:-- desc:库存 * @return name:type type:int default:-- desc:1普通藏品3盲盒 * @return name:now_inventory type:int default:-- desc:剩余库存 * @return name:state type:float default:-- desc:藏品状态(1:进行中2:即将开售3:已售罄) * @return name:sell_time type:string default:-- desc:发行时间[抽签时间,报名结束时间] * @return name:describe type:string default:-- desc:商品描述 * @return name:buy_count type:int default:1 desc:限购数量 * @return name:before_count type:int default:1 desc:提前购限购数量 * @return name:instructions type:int default:1 desc:权益说明 * @return name:buy_notice type:int default:1 desc:购买须知 * @return name:warm_prompt type:int default:1 desc:温馨提示 * @return name:auth_img type:int default:1 desc:作者头像 * @return name:auth_name type:int default:1 desc:作者姓名 * @return name:is_remind type:string default:-- desc:是否设置提醒true:已设置false:未设置 * @return name:share_img type:string default:-- desc:分享二维码 * @return name:issue_mode type:string default:-- desc:发行方式(1普通发行2抽签发行) * @return name:circulate_num type:int default:-- desc:流通量 * @return name:is_task type:int default:-- desc:是否有抽签结果(0未出结果,1已出结果)【普通发行忽略】 * @return name:all_apply type:int default:-- desc:参与抽签人数【普通发行忽略】 * @return name:apply_st type:string default:-- desc:抽签报名开始时间【普通发行忽略】 * @return name:apply_end type:string default:-- desc:抽签报名结束时间||抽奖发布时间【普通发行忽略】 * @return name:has_apply type:int default:-- desc:是否报名(0否,1是)【普通发行忽略】 * @return name:apply_code type:int default:-- desc:抽签码【普通发行忽略】 * @return name:ballot_status type:int default:-- desc:是否中签(0待抽签1抽中2未中)【普通发行忽略】 */ public function CollectionDetail(){ $collect_id = input('id'); if (!$collect_id) $this->error('参数错误'); checkCollectionState($collect_id); (new Timedtask())->collectionDraw($collect_id); $info = Db::name('store_collection') ->where('is_deleted',0) ->where('status',1) ->whereIn('type','1,3') ->where('id',$collect_id) ->field('id,cover,name,label,type,price,inventory,now_inventory,state,sell_time,describe,buy_count,instructions,buy_notice,warm_prompt,auth_img,auth_name,share_img,intro,detail_img,format,advance_info,issue_mode,apply_st,apply_end,is_task,before_time') ->find(); if(!$info) $this->error('商品已下架'); // 抽签发行 $draw = Db::name('store_collection_draw')->where(['coll_id'=>$info['id'],'sell_time'=>$info['sell_time'],'user_id'=>$this->uid])->find(); $info['has_apply'] = empty($draw) ? 0 : 1; $info['apply_code'] = empty($draw) ? '' : $draw['code']; $info['ballot_status'] = empty($draw) ? 0 : $draw['is_ballot']; $info['all_apply'] = Db::name('store_collection_draw')->where(['coll_id'=>$info['id'],'sell_time'=>$info['sell_time']])->count(); if (!$info) $this->error('藏品不存在'); $info['describe'] = explode('|',$info['describe']); $info['before_count'] = 0; // 验证产品赋能优先购 $set_time = $info['sell_time']; if( $info['issue_mode'] == 1){ $priority = checkMemberPriority($this->uid,$info['id']); if($priority){ $sell_time = strtotime($info['sell_time'])-($info['before_time'] * 60); if ($sell_time <= time()) $info['state'] = 1; $info['sell_time'] = date('Y-m-d H:i:s',$sell_time); } } $info['is_remind'] = getRemind($this->uid,$info['id']) ? true : false; $now_inventory = getCollectionInventory($info['id']); $info['now_inventory'] = $now_inventory<=0 ? 0 : $now_inventory; // 用户持有量 $info['circulate_num']= Db::name('store_order_info') ->where('c_id',$info['id']) ->where('is_destruction',1) ->whereIn('resale_status','1,2') ->count(); if( $info['circulate_num'] > $info['inventory'])$info['circulate_num'] = $info['inventory']; $this->success('成功',$info); } /** * @title 设置提醒 * @desc 设置提醒 * @author Gavin * @url /api/Index/setRemind * @method POST * @header name:Authorization require:1 desc:Token * * @param name:id type:string require:1 default:-- desc:藏品ID */ public function setRemind(){ $id = input('id'); if (!$id) $this->error('参数错误'); $remind = Db::name('store_collection_remind') ->where('mid',$this->uid) ->where('c_id',$id) ->count(); if ($remind) $this->error('已设置过'); $data = [ 'c_id'=>$id, 'mid'=>$this->uid ]; if (Db::name('store_collection_remind')->insert($data)) $this->success('设置成功'); $this->error('设置失败'); } /** * @title 认证信息 * @desc 认证信息 * @author QC * @url /api/Index/certificate * @method POST * @header name:Authorization require:1 desc:Token * @param name:name type:string default:-- desc:名称 * @param name:link type:string default:-- desc:合约地址 */ public function certificate() { $this->success('ok',['name' => '蚂蚁链HASH', 'link' => '0c214bcd4f1766fdd6d36f127234fc7e7ba883711e19938777f01523c28e74dc',]); } }