123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703 |
- <?php
- namespace app\api\controller;
- use app\common\model\ActivityApply;
- use app\common\model\PlatformLike;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserSearch;
- use app\common\model\UserTrack;
- use app\common\service\OrderCallback;
- use think\Db;
- /**
- * @title 活动
- * @controller Activity
- * @group base
- */
- class Activity extends Base
- {
- // 需要登录的
- protected $need_login = ['activityTags','activityCollect','activityTransmit','activityApply','payApplyOrder'];
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- }
- /**
- * @title 活动推荐
- * @desc 活动推荐
- * @author qc
- * @method GET
- * @url /api/Activity/getRecommendList
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:id type:string default:-- desc:资料item_id
- * @return name:id type:int default:-- desc:id
- * @return name:address type:string default:-- desc:地址
- * @return name:cover type:string default:-- desc:封面
- * @return name:label_name type:array default:-- desc:标签
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时候
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:price type:string default:-- desc:价格
- * @return name:status type:int default:-- desc:活动状态1正常2取消
- * @return name:is_apply type:int default:-- desc:是否报名(0否1是)
- */
- public function getRecommendList()
- {
- $search_log = UserSearch::getSearchTitle($this->user_id,11);
- $search_arr = [];
- $where_str = 'b.id > 0';
- foreach ($search_log as $t){
- $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
- $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
- }
- if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
- $field = 'a.id,cover,a.user_id,title,a.status,address,label,start_time,end_time,ladder,price,IFNULL(is_recommend,0) is_recommend ';
- $table = 'dd_activity';
- $order_by_two = 'read_num';
- $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.is_deleted = 0 AND a.status = 1 ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}";
- $list = Db::query($sql);
- array_walk($list,function (&$v,$k){
- $v['is_apply'] = ActivityApply::checkApply($this->user_id,$v['id']);
- $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')): null;
- });
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取活动列表
- * @desc 获取活动列表
- * @author qc
- * @method GET
- * @url /api/Activity/getActivityList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
- * @return name:title type:string default:-- desc:标题
- * @return name:cover type:string default:-- desc:图片多张|隔开
- * @return name:status type:int default:-- desc:活动状态1正常2取消
- * @return name:cover_arr type:array default:-- desc:图片多张[数组]
- * @return name:content type:string default:-- desc:详情
- * @return name:create_at type:string default:-- desc:时间
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:address type:string default:-- desc:地址
- * @return name:price type:float default:-- desc:价格
- * @return name:label type:string default:-- desc:标签[多个','隔开]
- * @return name:label_name type:array default:-- desc:标签[数组]
- * @return name:is_apply type:int default:0 desc:是否报名【0否1是】
- */
- public function getActivityList(){
- $title = input('get.title');
- $sort_type = input('get.sort_type',1);
- switch ($sort_type) {
- case 1:
- $order = ['sort'=>'desc','id'=>'desc'];
- break;
- case 2:
- $order = ['id'=>'asc','sort'=>'desc'];
- break;
- case 3:
- $order = ['id'=>'desc','sort'=>'desc'];
- break;
- }
- if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,11);
- $list = \app\common\model\Activity::where(['is_deleted'=>0,'status'=>1])
- ->when($title,function ($query)use($title){
- if($title) $query->where('title|label','like','%'.$title.'%');
- })->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
- foreach ($list as &$v) {
- $v['cover_arr'] = $v['cover'] ? explode('|',$v['cover']) : null;
- $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')): null;
- $v['is_apply'] = ActivityApply::checkApply($this->user_id,$v['id']);
- $v['ladder_arr'] = json_decode($v['ladder'],true);
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取活动详情
- * @desc 获取活动详情
- * @author qc
- * @method GET
- * @url /api/Activity/getActivityDetail
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:活动id
- * @return name:title type:string default:-- desc:标题
- * @return name:cover type:string default:-- desc:图片多张|隔开
- * @return name:cover_arr type:array default:-- desc:图片多张[数组]
- * @return name:status type:int default:-- desc:活动状态1正常2取消
- * @return name:content type:string default:-- desc:详情
- * @return name:create_at type:string default:-- desc:时间
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:address type:string default:-- desc:地址
- * @return name:price type:float default:-- desc:价格
- * @return name:label type:string default:-- desc:标签[多个','隔开]
- * @return name:label_name type:array default:-- desc:标签[数组]
- * @return name:is_apply type:int default:0 desc:是否报名【0否1是】
- * @return name:praise_num type:int default:-- desc:点赞量
- * @return name:is_praise type:int default:-- desc:是否点赞【0否1是】
- * @return name:is_collect type:int default:-- desc:是否收藏【0否1是】
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:transmit_num type:int default:-- desc:转发量
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:ladder_arr type:array default:-- desc:价格阶梯设置
- * @return name:ladder_arr.ladder_num type:int default:-- desc:人数
- * @return name:ladder_arr.ladder_num type:float default:-- desc:价格
- */
- public function getActivityDetail()
- {
- $sel_where[] = ['id','=',input('get.id')];
- $detail = \app\common\model\Activity::where($sel_where)->find()->toArray();
- $detail['cover_arr'] = $detail['cover'] ? explode('|',$detail['cover']) : null;
- $detail['label_name'] = $detail['label'] ? explode(',',trim($detail['label'],',')): null;
- $detail['is_apply'] = ActivityApply::checkApply($this->user_id,$detail['id']);
- $detail['is_praise'] = PlatformLike::checkTags($this->user_id,$detail['id'],4);
- $detail['praise_num'] = PlatformLike::getPraiseNum($detail['id'],4);
- $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,7,$detail['id']);
- $detail['collect_num'] = UserCollect::getCollectNum(7,$detail['id']);
- $detail['ladder_arr'] = $detail['ladder'] ? json_decode($detail['ladder']): null;
- if(!$detail['user_id']){
- $detail['app_name'] = sysconf('app_name');
- $detail['app_logo'] = sysconf('app_logo');
- }else{
- $user_info = User::where('id',$detail['user_id'])->field('name,headimg')->find();
- $detail['app_name'] = $user_info ? $user_info->name : '';
- $detail['app_logo'] = $user_info ? $user_info->headimg : '';
- }
- UserTrack::crateTrack($this->user_id,7,input('get.id'),0);
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 以下接口调用验证登录【需要header传Authorization】
- * @desc 以下接口调用验证登录
- * @author qc
- * @method
- * @url /api/Activity/needLogin()
- */
- public function needLogin(){}
- /**
- * @title 点赞||取消点赞
- * @desc 点赞||取消点赞
- * @author qc
- * @method POST
- * @url /api/Activity/activityTags
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:活动id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function activityTags()
- {
- $ret_val = PlatformLike::userTags($this->user_id,input('post.id'),4);
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
- /**
- * @title 收藏||取消收藏
- * @desc 用户收藏
- * @author qc
- * @method POST
- * @url /api/Activity/activityCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int require:1 default:-- desc:活动id
- * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
- */
- public function activityCollect(){
- $coll_status = UserCollect::plateCollect($this->user_id,7,input('post.id',0));
- $coll_status ? $this->success('收藏成功',['status'=>1]) : $this->success('取消收藏成功',['status'=>0]);
- }
- /**
- * @title 活动转发(转发数量统计)
- * @desc 转发成功后调用
- * @author qc
- * @method POST
- * @url /api/Activity/activityTransmit
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:活动id
- */
- public function activityTransmit()
- {
- $activity_id = input('post.id',0);
- \app\common\model\Activity::where('id',$activity_id)->setInc('transmit_num');
- $this->success('ok');
- }
- /**
- * @title 活动报名
- * @desc 活动报名[生成订单(报名记录),返回支付信息]
- * @author qc
- * @method POST
- * @url /api/Activity/activityApply
- * @header name:Authorization require:1 desc:Token
- * @param name:act_id type:int default:-- desc:活动id
- * @param name:name type:string default:-- desc:联系人
- * @param name:phone type:string default:-- desc:联系人电话
- * @param name:email type:string default:-- desc:email
- * @param name:num type:int default:-- desc:报名人数
- * @param name:phone_code type:int default:-- desc:短信验证码
- * @param name:pay_type type:int require:1 default:0 desc:支付方式(1.h5微信,2.h5支付宝,3.app微信,4.app支付宝,5.h5微信内支付)
- * @param name:port type:int default:1 desc:来源【1:h5,2:安卓,3:ios】
- *
- * @return name:pay_status type:int default:0 desc:该值为1:订单金额是0不需要支付!!!
- * @return name:config type:array default:0 desc:支付配置
- * @return name:config.appId type:string default:-- desc:公众账号ID
- * @return name:config.signType type:string default:-- desc:签名类型
- * @return name:config.paySign type:string default:-- desc:签名
- * @return name:config.nonceStr type:string default:-- desc:随机字符串
- * @return name:config.timestamp type:string default:-- desc:时间戳
- * @return name:config.partnerid type:string default:-- desc:商户号
- * @return name:config.prepayid type:string default:-- desc:唯一支付号
- * @return name:config.package type:string default:-- desc:package
- * @return name:config.mch_id type:string default:-- desc:商户号(H5)
- * @return name:config.pay_no type:string default:-- desc:订单支付号(H5)
- * @return name:config.notify_url type:string default:-- desc:回调地址(H5)
- * @return name:config.total_fee type:int default:-- desc:支付金额(分!!!)
- * @return name:code_url type:string default:-- desc:付款码url
- * @return name:openid type:string default:-- desc:openid
- */
- public function activityApply()
- {
- $act_id = input('post.act_id');
- $name = input('post.name');
- $phone = input('post.phone');
- $email = input('post.email');
- $num = input('post.num',1);
- $port = input('post.port',1);
- $phone_code = input('post.phone_code');
- $pay_type = input('post.pay_type',1);
- if(!$name || !$phone || !$email) $this->error('请完善报名信息');
- if(!in_array($pay_type,[1,2,3,4,5])) $this->error('支付方式错误');
- if($num <= 0) $this->error('请输入报名人数');
- $check_apply = ActivityApply::checkApply($this->user_id,$act_id);
- //if($check_apply) $this->error('已报名!');
- $act_info = \app\common\model\Activity::where('id',$act_id)->where('is_deleted',0)->find();
- if(!$act_info) $this->error('活动不存在');
- if(strtotime($act_info->end_time) < time() ) $this->error('活动已经结束');
- if(strtotime($act_info->start_time) < time() ) $this->error('活动已经开始');
- if($act_info->status == 2) $this->error('活动已经取消');
- $check_code = $this->checkPhoneCode($phone,$phone_code);
- // if(!$check_code) $this->error('验证码错误');
- $this->updatePhoneCode($check_code);
- $ladder = $act_info->ladder ? json_decode($act_info->ladder,true) : [];
- $order_money = bcmul($act_info->price,$num,2);
- if(!empty($ladder)) {
- $ladder_set = array_column($ladder,null,'ladder_num');
- krsort($ladder_set);
- $max_num = array_column($ladder_set,'ladder_num');
- $min_num = array_column($ladder_set,'ladder_num');
- if($max_num < $num) {
- $order_money = bcmul($ladder_set[$max_num]['ladder_price'],$num,2);
- }else if ($min_num > $num){
- foreach ($ladder_set as $lk=>$lv) {
- if($lk <= $num){
- $order_money = bcmul($lv['ladder_price'],$num,2);
- break;
- }
- }
- }
- }
- if($order_money < 0 )$this->error('报名费不能小于0');
- $apply_info = [
- 'user_id' => $this->user_id,
- 'order_no' => get_order_sn(),
- 'pay_no' => get_order_sn(),
- 'num' => $num,
- 'name' => $name,
- 'phone' => $phone,
- 'email' => $email,
- 'pay_type' => $pay_type,
- 'money' => $order_money,
- 'port' => $port,
- 'act_id' => $act_id,
- ];
- $user_info = User::where('id',$this->user_id)->find();
- $ret_data = ['pay_status'=>0,'config'=>[],'code_url'=>'','openid'=>$user_info['openid'],'order_id'=>0];
- Db::startTrans();
- try {
- $order_info = ActivityApply::create($apply_info)->toArray();
- if($order_money == 0) {
- $back_res = OrderCallback::activityOrderCallBack($order_info);// 支付完成后回调
- if(!$back_res['ret_val']) $this->exception('报名失败');
- $ret_data['pay_status'] = 1;
- }else{
- $ret_data['order_id'] = $order_info['id'];
- switch ($pay_type){
- case 1:
- $notify_url = $this->request->root(true) . '/api/we_chat_pay/applyOrderNotify';
- $pay_config = WeChatPay::wxPay('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url,'MWEB');
- if($pay_config['code'] != 200) $this->exception($pay_config['msg']);
- $pay_config['config']['mch_id'] = config('app.wx_pay')['mch_id'];
- $pay_config['config']['pay_no'] = $order_info['pay_no'];
- $pay_config['config']['notify_url'] = $notify_url;
- $pay_config['config']['mweb_url'] = $pay_config['mweb_url'];
- $pay_config['config']['total_fee'] = $order_info['money'] * 100;
- $ret_data['config'] = $pay_config['config'];
- break;
- case 2:
- $notify_url = $this->request->root(true) . '/api/Alipay/applyOrderNotify';
- $return_url ='https://'.$_SERVER['HTTP_HOST']."/dist/#/my";
- $config = Alipay::ali_pay_pc('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url,$return_url);
- $ret_data['config']['ali_url'] = $config;
- $ret_data['ali_url'] = $config;
- break;
- case 3:
- $notify_url = $this->request->root(true) . '/api/we_chat_pay/applyOrderNotify';
- $pay_config = WeChatPay::wxPay('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url,'APP');
- if($pay_config['code'] != 200) $this->exception($pay_config['msg']);
- $ret_data['config'] = $pay_config['config'];
- break;
- case 4:
- $notify_url = $this->request->root(true) . '/api/Alipay/LevelOrderNotify';
- $config = Alipay::ali_pay('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url);
- $ret_data['config']['ali_url'] = $config;
- $ret_data['ali_url'] = $config;
- $ret_data['money'] = $order_info['money'];
- break;
- case 5 :
- if(!$user_info['openid']) $this->exception('请绑定openid');
- $notify_url = $this->request->root(true) . '/api/we_chat_pay/applyOrderNotify';
- $pay_config = WeChatPay::wxPay('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url,'JSAPI',$user_info['openid']);
- if($pay_config['code'] != 200) $this->exception($pay_config['msg']);
- $ret_data['config'] = $pay_config['config'];
- break;
- }
- }
- Db::commit();
- }catch (\Exception $e){
- Db::rollback();
- $this->error($e->getMessage());
- }
- $this->success('报名成功',$ret_data);
- }
- /**
- * @title 活动报名订单支付
- * @desc 活动报名订单支付
- * @author qc
- * @method POST
- * @url /api/Activity/payApplyOrder
- * @header name:Authorization require:1 desc:Token
- * @param name:order_id type:int default:-- desc:订单id【报名记录id】
- *
- * @return name:pay_status type:array default:0 desc:该值为1:订单金额是0不需要支付!!!
- * @return name:config type:array default:0 desc:支付配置
- * @return name:config.appId type:string default:-- desc:公众账号ID
- * @return name:config.signType type:string default:-- desc:签名类型
- * @return name:config.paySign type:string default:-- desc:签名
- * @return name:config.nonceStr type:string default:-- desc:随机字符串
- * @return name:config.timestamp type:string default:-- desc:时间戳
- * @return name:config.partnerid type:string default:-- desc:商户号
- * @return name:config.prepayid type:string default:-- desc:唯一支付号
- * @return name:config.package type:string default:-- desc:package
- * @return name:config.mch_id type:string default:-- desc:商户号(H5)
- * @return name:config.pay_no type:string default:-- desc:订单支付号(H5)
- * @return name:config.notify_url type:string default:-- desc:回调地址(H5)
- * @return name:config.total_fee type:int default:-- desc:支付金额(分!!!)
- * @return name:code_url type:string default:-- desc:付款码url
- * @return name:openid type:string default:-- desc:openid
- */
- public function payApplyOrder()
- {
- $order_id = input('post.order_id');
- $order_info = ActivityApply::where('id',$order_id)->find()->toArray();
- if($order_info['status'] != 0) $this->error('订单状态错误');
- if($order_info['cancel_state'] != 0 || $order_info['is_deleted'] != 0) $this->error('订单异常');
- if($order_info['money'] <= 0) $this->error('订单金额错误');
- $pay_type = $order_info['pay_type'];
- $user_info = User::where('id',$this->user_id)->find();
- $ret_data = ['pay_status'=>0,'config'=>[],'code_url'=>'','openid'=>$user_info['openid'],'order_id'=>0];
- Db::startTrans();
- try {
- switch ($pay_type){
- case 1:
- $notify_url = $this->request->root(true) . '/api/we_chat_pay/applyOrderNotify';
- $pay_config = WeChatPay::wxPay('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url,'MWEB');
- if($pay_config['code'] != 200) $this->exception($pay_config['msg']);
- $pay_config['config']['mch_id'] = config('app.wx_pay')['mch_id'];
- $pay_config['config']['pay_no'] = $order_info['pay_no'];
- $pay_config['config']['notify_url'] = $notify_url;
- $pay_config['config']['mweb_url'] = $pay_config['mweb_url'];
- $pay_config['config']['total_fee'] = $order_info['money'] * 100;
- $ret_data['config'] = $pay_config['config'];
- break;
- case 2:
- $notify_url = $this->request->root(true) . '/api/Alipay/applyOrderNotify';
- $return_url ='https://'.$_SERVER['HTTP_HOST']."/dist/#/my";
- $config = Alipay::ali_pay_pc('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url,$return_url);
- $ret_data['config']['ali_url'] = $config;
- $ret_data['ali_url'] = $config;
- break;
- case 3:
- $notify_url = $this->request->root(true) . '/api/we_chat_pay/applyOrderNotify';
- $pay_config = WeChatPay::wxPay('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url,'APP');
- if($pay_config['code'] != 200) $this->exception($pay_config['msg']);
- $ret_data['config'] = $pay_config['config'];
- break;
- case 4:
- $notify_url = $this->request->root(true) . '/api/Alipay/LevelOrderNotify';
- $config = Alipay::ali_pay('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url);
- $ret_data['config']['ali_url'] = $config;
- $ret_data['ali_url'] = $config;
- $ret_data['money'] = $order_info['money'];
- break;
- case 5 :
- if(!$user_info['openid']) $this->exception('请绑定openid');
- $notify_url = $this->request->root(true) . '/api/we_chat_pay/applyOrderNotify';
- $pay_config = WeChatPay::wxPay('订单支付',$order_info['pay_no'],$order_info['money'],$notify_url,'JSAPI',$user_info['openid']);
- if($pay_config['code'] != 200) $this->exception($pay_config['msg']);
- $ret_data['config'] = $pay_config['config'];
- break;
- }
- Db::commit();
- }catch (\Exception $e){
- Db::rollback();
- $this->error($e->getMessage());
- }
- $this->success('ok',$ret_data);
- }
- /**
- * @title 我的发布列表
- * @desc 我的发布列表
- * @author qc
- * @method GET
- * @url /api/Activity/getMyActivityList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:cover type:string default:-- desc:图片多张|隔开
- * @return name:cover_arr type:array default:-- desc:图片多张[数组]
- * @return name:content type:string default:-- desc:详情
- * @return name:create_at type:string default:-- desc:时间
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:address type:string default:-- desc:地址
- * @return name:price type:float default:-- desc:价格
- * @return name:label type:string default:-- desc:标签[多个','隔开]
- * @return name:label_name type:array default:-- desc:标签[数组]
- */
- public function getMyActivityList(){
- $title = input('get.title');
- $list = \app\common\model\Activity::where(['is_deleted'=>0,'user_id'=>$this->user_id])
- ->when($title,function ($query)use($title){
- if($title) $query->where('title|label','like','%'.$title.'%');
- })->order( ['sort'=>'desc','id'=>'desc'])->limit($this->off_set,$this->page_num)->select()->toArray();
- foreach ($list as &$v) {
- $v['cover_arr'] = $v['cover'] ? explode('|',$v['cover']) : null;
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的收藏【活动】
- * @desc 我的收藏
- * @author qc
- * @method GET
- * @url /api/Activity/getCollectActivity
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:activity_id type:string default:-- desc:活动id
- * @return name:cover type:string default:-- desc:图片多张|隔开
- * @return name:cover_arr type:array default:-- desc:图片多张[数组]
- * @return name:content type:string default:-- desc:详情
- * @return name:create_at type:string default:-- desc:时间
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:address type:string default:-- desc:地址
- * @return name:price type:float default:-- desc:价格
- * @return name:label type:string default:-- desc:标签[多个','隔开]
- * @return name:label_name type:array default:-- desc:标签[数组]
- */
- public function getCollectActivity()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.coll_type','=',7];
- $list = UserCollect::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.coll_id activity_id,i.title,i.cover,i.label,i.content,i.start_time,i.end_time,i.address,i.price')
- ->leftJoin('Activity i','t.coll_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['cover_arr'] = $v['cover'] ? explode('|',$v['cover']) : null;
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 浏览记录【活动】
- * @desc 浏览记录
- * @author qc
- * @method GET
- * @url /api/Activity/getActivityTrack
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:activity_id type:string default:-- desc:活动id
- * @return name:cover type:string default:-- desc:图片多张|隔开
- * @return name:cover_arr type:array default:-- desc:图片多张[数组]
- * @return name:content type:string default:-- desc:详情
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:address type:string default:-- desc:地址
- * @return name:price type:float default:-- desc:价格
- * @return name:label type:string default:-- desc:标签[多个','隔开]
- * @return name:label_name type:array default:-- desc:标签[数组]
- * @return name:time type:string default:-- desc:时间
- */
- public function getActivityTrack()
- {
- $sel_where = [];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',4];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $list = UserTrack::where($sel_where)
- ->alias('t')
- ->field('t.id,t.update_int,t.first_id activity_id,i.title,i.cover,i.label,i.content,i.start_time,i.end_time,i.address,i.price')
- ->leftJoin('Activity i','t.first_id = i.id')
- ->order('update_int desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
- $v['cover_arr'] = $v['cover'] ? explode('|',$v['cover']) : null;
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的点赞【活动】
- * @desc 我的点赞
- * @author qc
- * @method GET
- * @url /api/Activity/getTagsActivity
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:activity_id type:string default:-- desc:活动id
- * @return name:cover type:string default:-- desc:图片多张|隔开
- * @return name:cover_arr type:array default:-- desc:图片多张[数组]
- * @return name:content type:string default:-- desc:详情
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:address type:string default:-- desc:地址
- * @return name:price type:float default:-- desc:价格
- * @return name:label type:string default:-- desc:标签[多个','隔开]
- * @return name:label_name type:array default:-- desc:标签[数组]
- */
- public function getTagsActivity()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',4];
- $list = PlatformLike::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.like_id activity_id,i.title,i.cover,i.label,i.content,i.start_time,i.end_time,i.address,i.price')
- ->leftJoin('Activity i','t.like_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['cover_arr'] = $v['cover'] ? explode('|',$v['cover']) : null;
- $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')): null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的报名【活动】
- * @desc 我的报名
- * @author qc
- * @method GET
- * @url /api/Activity/getApplyList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:activity_id type:string default:-- desc:活动id
- * @return name:status type:int default:-- desc:活动状态1正常2取消
- * @return name:cover type:string default:-- desc:图片多张|隔开
- * @return name:cover_arr type:array default:-- desc:图片多张[数组]
- * @return name:content type:string default:-- desc:详情
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:address type:string default:-- desc:地址
- * @return name:price type:float default:-- desc:价格
- * @return name:label type:string default:-- desc:标签[多个','隔开]
- * @return name:label_name type:array default:-- desc:标签[数组]
- */
- public function getApplyList()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.status','=',1];
- $list = ActivityApply::where($sel_where)
- ->field('t.id,t.order_no,t.act_id activity_id,i.title,i.status,i.cover,i.label,i.content,i.start_time,i.end_time,i.address,i.price')
- ->alias('t')
- ->leftJoin('Activity i','t.act_id = i.id')
- ->order(['t.id'=>'desc'])
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['cover_arr'] = $v['cover'] ? explode('|',$v['cover']) : null;
- $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')): null;
- }
- $this->success('ok',['list'=>$list]);
- }
- }
|