123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746 |
- <?php
- namespace app\api\controller;
- use AlibabaCloud\SDK\Vod\V20170321\Models\GetAIMediaAuditJobResponseBody\mediaAuditJob\data;
- use app\common\model\ActivityApply;
- use app\common\model\ActivityApplyItem;
- use app\common\model\ActivityPrice;
- use app\common\model\ActivitySchedule;
- use app\common\model\ActivitySponsor;
- use app\common\model\ActivityTemplate;
- use app\common\model\ActivityTemplateItem;
- use app\common\model\ArticleItem;
- use app\common\model\BillApply;
- use app\common\model\BillHeader;
- use app\common\model\DatumUrl;
- use app\common\model\DeliveryAddress;
- use app\common\model\GoodsOrderRefund;
- use app\common\model\PlatformLike;
- use app\common\model\StoreOrderRefund;
- use app\common\model\TopSearch;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserMessage;
- use app\common\model\UserSearch;
- use app\common\model\UserTrack;
- use app\common\model\VideoUrl;
- use app\common\service\CheckPower;
- use app\common\service\OrderCallback;
- use app\common\service\UserSynth;
- use think\Db;
- /**
- * @title 活动
- * @controller Activity
- * @group base
- */
- class Activity extends Base
- {
- // 需要登录的
- protected $need_login = [
- 'activityTags',
- 'activityCollect',
- //'activityApply',
- //'payApplyOrder',
- 'getApplyInfo',
- 'cancelApplyOrder',
- 'getMyActivityList',
- 'getCollectActivity',
- 'getActivityTrack',
- 'getTagsActivity',
- 'getApplyList',
- 'getTicketInfo',
- 'hxOrder',
- 'applyRefund',
- 'deliveryDetails',
- 'getBillInfo',
- 'getApplyOrderList',
- 'delApplyOrder',
- 'delTicket',
- 'unreadChange',
- 'getMessageList',
- 'batchesDel',
- 'applyBill',
- ];
- 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:每页数
- * @param name:rand_user type:string default:-- desc:随机id(非登录状态必传,page=1时生成(a123),其他页数(a123),一直查询到没有数据)
- * @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:status type:int default:-- desc:活动状态1正常2取消
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:is_apply type:int default:-- desc:是否报名(0否1是)
- * @return name:release_time type:string default:-- desc:上架时间
- */
- public function getRecommendList()
- {
- $user_id = $this->user_id ? $this->user_id : input('rand_user');
- if(!$user_id) $this->error('参数错误');
- $list = UserSynth::getRecommendList($user_id,'activity',$this->page,$this->page_num);
- if($list['code'] != 200) $this->error($list['msg']);
- $this->success('ok',$list);
- $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,a.province,a.city,a.county,a.address,title,a.status,address,a.read_num,label,start_time,end_time,IFNULL(is_recommend,0) is_recommend ';
- $table = 'dd_activity';
- $order_by_two = 'a.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}";
- $sql2 = "SELECT count(a.id) num 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 ";
- $list = Db::query($sql);
- $list = dispose_recommend($list);
- array_walk($list,function (&$v,$k){
- $v['read_num'] = numTransform( $v['read_num']);
- $v['cover_arr'] = $v['cover'] ? explode('|',$v['cover']) : null;
- $v['cover'] = $v['cover_arr'] ? $v['cover_arr'][0]:null;
- $v['is_apply'] = ActivityApply::checkApply($this->user_id,$v['id']);
- $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')): null;
- });
- $total = Db::query($sql2);
- $this->success('ok',['list'=>$list,'total_count'=>$total[0]['num'],'page_num'=>$this->page_num]);
- }
- /**
- * @title 活动列表
- * @desc 活动列表
- * @author qc
- * @method GET
- * @url /api/Activity/getActivityList
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:sel_type type:int default:0 desc:活动状态【0全部,1已结束2待开始3进行中】
- * @return name:title type:string default:-- desc:标题
- * @return name:cover type:string default:-- desc:海报
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- */
- public function getActivityList(){
- $sort_type = input('get.sort_type',1);
- $sel_type = input('get.sel_type',0);
- switch ($sort_type) {
- case 1:
- $order = ['read_num'=>'desc','id'=>'asc'];
- break;
- case 2:
- $order = ['id'=>'asc','sort'=>'desc'];
- break;
- case 3:
- $order = ['id'=>'desc','sort'=>'desc'];
- break;
- }
- $where = [];
- $where[] = ['is_deleted','=',0];
- $where[] = ['status','=',1];
- $where[] = ['release_time','< time',date('Y-m-d H:i:s')];
- switch ($sel_type) {
- case 1:
- $where[] = ['end_time','< time',date('Y-m-d H:i:s')];
- break;
- case 2:
- $where[] = ['start_time','> time',date('Y-m-d H:i:s')];
- break;
- case 3:
- $where[] = ['start_time','< time',date('Y-m-d H:i:s')];
- $where[] = ['end_time','> time',date('Y-m-d H:i:s')];
- break;
- }
- $list = \app\common\model\Activity::field('id,title,cover,start_time,end_time,province,city,county,address,read_num,release_time')
- ->where($where)->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
- foreach ($list as $k => $v){
- $user = User::where('id',$v['id'])->field('id,name,headimg')->find();
- if($user){
- $list[$k]['name'] = $user['name'];
- $list[$k]['headimg'] = $user['headimg'];
- }else{
- $list[$k]['name'] = null;
- $list[$k]['headimg'] = null;
- }
- }
- $total_num = \app\common\model\Activity::where($where)->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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: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:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:longitude type:string default:-- desc:经度
- * @return name:latitude type:string 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:pay_offline type:int default:-- desc:是否支持下线支付【0否1是】
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:read_num type:string default:-- desc:阅读量
- * @return name:release_time type:string default:-- desc:发布时间
- * @return name:offline_user type:string default:-- desc:线下支付户名
- * @return name:offline_bank type:string default:-- desc:线下支付开户行
- * @return name:offline_card type:string default:-- desc:线下支付账号
- * @return name:video_id type:int default:-- desc:视频系列id
- * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
- * @return name:video_jump type:int default:-- desc:关联视频是否能跳转【0不能跳转,1能跳转,验证是否vip】
- *
- * @return name:article_id type:int default:-- desc:图文系列id
- * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
- * @return name:article_jump type:int default:-- desc:关联图文是否能跳转【0不能跳转,1能跳转,验证是否vip】
- * @return name:datum_id type:int default:-- desc:资料id--ppt【系列id】
- * @return name:datum_item type:int default:-- desc:资料id--ppt【系列下的其中一个】
- * @return name:datum_jump type:int default:-- desc:关联资料是否能跳转【0不能跳转,1能跳转,验证是否vip】
- * @return name:datum_url type:int default:-- desc:关联资料链接
- *
- * @return name:price_list type:array default:-- desc:价格设置
- * @return name:price_list.id type:int default:-- desc:价格阶梯记录id
- * @return name:price_list.ladder_title type:string default:-- desc:标题
- * @return name:price_list.ladder_remark type:string default:-- desc:备注
- * @return name:price_list.ladder_price type:float default:-- desc:价格
- * @return name:price_list.ladder_status type:float default:-- desc:当前门票是否下架【0下架,1正常】
- * @return name:price_list.ladder_num type:float default:-- desc:活动票发行量
- * @return name:price_list.stock type:int default:-- desc:剩余票量
- * @return name:price_list.fill_num type:int default:-- desc:满减张数
- * @return name:price_list.sub_money type:float default:-- desc:每张优惠
- * @return name:price_list.is_sh type:int default:-- desc:是否需要审核【1是,0否】
- * @return name:sponsor type:array default:-- desc:主办方信息
- * @return name:sponsor.id type:int default:-- desc:主办方记录id
- * @return name:sponsor.qr_code type:string default:-- desc:二维码
- * @return name:sponsor.cover type:string default:-- desc:主办方logo
- * @return name:sponsor.official_web type:string default:-- desc:主办方官网
- * @return name:sponsor.title type:string default:-- desc:主办方名称
- * @return name:sponsor.address type:string default:-- desc:地址
- * @return name:sponsor.email type:string default:-- desc:email
- * @return name:sponsor.phone type:string default:-- desc:phone
- * @return name:template_list type:array default:-- desc:报名模板信息
- * @return name:template_list.id type:int default:-- desc:报名模板详情id
- * @return name:template_list.title type:string default:-- desc:标题
- * @return name:template_list.type type:string default:-- desc:类型【1input,2文本,3多选】
- * @return name:template_list.value type:string default:-- desc:报名提交填写的内容【1input,2文本】
- * @return name:template_list.required type:int default:-- desc:是否必填【1是,0否】
- * @return name:template_list.extend type:array default:-- desc:多选选项【type=3】
- * @return name:template_list.extend.item_title type:string default:-- desc:选项【type=3】
- *
- * @return name:schedule type:array default:-- desc:活动日程
- * @return name:schedule.title type:string default:-- desc:标题
- * @return name:schedule.date_time type:string default:-- desc:时间
- * @return name:schedule.schedule_list type:array default:-- desc:日程详情
- * @return name:schedule.schedule_list.theme type:string default:-- desc:主题
- * @return name:schedule.schedule_list.theme_time type:string default:-- desc:主题时间
- * @return name:schedule.children type:array default:-- desc:二级日程【数据同上】
- *
- */
- public function getActivityDetail()
- {
- $sel_where[] = ['id','=',input('get.id')];
- $detail = \app\common\model\Activity::where($sel_where)
- ->with(['sponsor','priceList'])
- ->find()->toArray();
- if($detail['is_deleted'] != 0 || $detail['status'] !=1) $this->error('该活动已取消');
- $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['transmit_num'] = numTransform($detail['transmit_num']);
- $detail['read_num'] = numTransform($detail['read_num']);
- $detail['article_jump'] = ArticleItem::checkVip($detail['article_item'],$this->user_id);
- $detail['video_jump'] = VideoUrl::checkVip($detail['video_item'],$this->user_id);
- $detail['datum_jump'] = DatumUrl::checkVip($detail['datum_item'],$this->user_id);
- $auth_info = \app\common\model\Activity::getAuth($detail['user_id'],APPNAME,APPLOGO);
- $detail['app_name'] = $auth_info['app_name'];
- $detail['app_logo'] = $auth_info['app_logo'];
- $template_list = ActivityTemplateItem::getList($detail['template_id']);
- array_walk($template_list,function (&$v){
- if($v['type'] == 3 && $v['extend'] )$v['extend'] = json_decode($v['extend']);
- });
- $detail['template_list'] =$template_list;
- $detail['schedule'] = ActivitySchedule::getActivitySchedule($detail['id']);
- \app\common\model\Activity::where('id',$detail['id'])->setInc('read_num');
- UserTrack::crateTrack($this->user_id,7,input('get.id'),0);
- // TopSearch::seIncHotNum($detail['id'],$this->request->controller());
- if($this->user_id){
- TopSearch::seIncHotNum($detail['id'],$this->request->controller());
- }
- if($this->user_id){
- $General = new General();
- $General->label($detail['label']);
- }
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 活动详情--返回字段少[活动报名]
- * @desc 活动详情
- * @author qc
- * @method GET
- * @url /api/Activity/getActivityDetailSimplify
- * @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:create_at type:string default:-- desc:时间
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:pay_offline type:int default:-- desc:是否支持下线支付【0否1是】
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:release_time type:string default:-- desc:发布时间
- * @return name:offline_user type:string default:-- desc:线下支付户名
- * @return name:offline_bank type:string default:-- desc:线下支付开户行
- * @return name:offline_card type:string default:-- desc:线下支付账号
- * @return name:price_list type:array default:-- desc:价格设置
- * @return name:price_list.id type:int default:-- desc:价格阶梯记录id
- * @return name:price_list.ladder_title type:string default:-- desc:标题
- * @return name:price_list.ladder_remark type:string default:-- desc:备注
- * @return name:price_list.ladder_price type:float default:-- desc:价格
- * @return name:price_list.ladder_num type:float default:-- desc:活动票发行量
- * @return name:price_list.stock type:float default:-- desc:剩余票量
- * @return name:price_list.is_sh type:float default:-- desc:是否需要审核【1是,0否】
- * @return name:price_list.fill_num type:int default:-- desc:满减张数
- * @return name:price_list.sub_money type:float default:-- desc:每张优惠
- * @return name:sponsor type:array default:-- desc:主办方信息
- * @return name:sponsor.id type:int default:-- desc:主办方记录id
- * @return name:sponsor.qr_code type:string default:-- desc:二维码
- * @return name:sponsor.cover type:string default:-- desc:主办方logo
- * @return name:sponsor.official_web type:string default:-- desc:主办方官网
- * @return name:sponsor.title type:string default:-- desc:主办方名称
- * @return name:sponsor.address type:string default:-- desc:地址
- * @return name:sponsor.email type:string default:-- desc:email
- * @return name:sponsor.phone type:string default:-- desc:phone
- * @return name:template_list type:array default:-- desc:报名模板信息
- * @return name:template_list.id type:int default:-- desc:报名模板详情id
- * @return name:template_list.title type:string default:-- desc:标题
- * @return name:template_list.type type:string default:-- desc:类型【1input,2文本,3多选】
- * @return name:template_list.value type:string default:-- desc:报名提交填写的内容【1input,2文本】
- * @return name:template_list.required type:int default:-- desc:是否必填【1是,0否】
- * @return name:template_list.extend type:array default:-- desc:多选选项【type=3】
- * @return name:template_list.extend.item_title type:string default:-- desc:选项【type=3】
- */
- public function getActivityDetailSimplify()
- {
- $sel_where[] = ['id','=',input('get.id')];
- $detail = \app\common\model\Activity::where($sel_where)
- ->field('id,sponsor_id,title,cover,create_at,start_time,end_time,province,city,county,address,template_id,pay_offline,offline_user,offline_bank,offline_card')
- ->with(['sponsor','priceList'])
- ->find()->toArray();
- $template_list = ActivityTemplateItem::getList($detail['template_id']);
- array_walk($template_list,function (&$v){
- if($v['type'] == 3 && $v['extend'] )$v['extend'] = json_decode($v['extend']);
- });
- $detail['template_list'] =$template_list;
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @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 GET
- * @url /api/Activity/getApplyData
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:活动id
- */
- public function getApplyData()
- {
- $sel_where[] = ['id','=',input('get.id')];
- $detail = \app\common\model\Activity::where($sel_where)
- ->field('id,sponsor_id,title,cover,create_at,start_time,end_time,province,city,county,address,template_id')
- ->with(['sponsor','priceList'])
- ->find()->toArray();
- $template_list = ActivityTemplateItem::getList($detail['template_id']);
- $user_info = $this->userInfo();
- $apply_data = [];
- array_walk($template_list,function (&$v)use ($user_info){
- if(in_array($v['type'],[1,2])) $v['value'] = '填写'.$v['title'];
- if($v['type'] == 3 && $v['extend'] ) {
- $extend = json_decode($v['extend'],true);
- foreach ($extend as &$ev) {
- $ev['value'] = 1;
- }
- $v['extend'] =$extend;
- }
- });
- $apply_data[] = [
- 'price_id' => $detail['price_list'][0]['id'],
- 'name' => $user_info['name'],
- 'phone_pre' => $user_info['phone_pre'],
- 'phone' => $user_info['phone'],
- 'email' => '123456@qq.com',
- 'num' => 1,
- 'code' => 1,
- 'phone_code' => 123456,
- 'template_list' => $template_list,
- ];
- $apply_data[] = [
- 'price_id' => $detail['price_list'][0]['id'],
- 'name' => $user_info['name'],
- 'phone_pre' => $user_info['phone_pre'],
- 'phone' => $user_info['phone'],
- 'email' => '123456@qq.com',
- 'num' => 1,
- 'code' => 1,
- 'phone_code' => 123456,
- 'template_list' => $template_list,
- ];
- $bill_info = BillHeader::where('id',1)->field('type,header,identify_number,bank,card_no,phone,email,address,remark')->find()->toArray();
- $this->success('ok',[
- 'apply_json'=>json_encode($apply_data,JSON_UNESCAPED_UNICODE),
- 'apply_array'=>$apply_data,
- 'template_json'=>json_encode($template_list,JSON_UNESCAPED_UNICODE),
- 'bill_info'=>json_encode($bill_info,JSON_UNESCAPED_UNICODE),
- ]);
- }
- /**
- * @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:tg type:string default:-- desc:推广参数
- * @param name:phone type:int default:-- desc:下单人手机号【未登录必填】
- * @param name:phone_pre type:string default:-- desc:下单人手机号前缀【未登录必填】
- * @param name:phone_code type:string default:-- desc:下单人手机号验证码【未登录必填】
- * @param name:pay_type type:int require:1 default:0 desc:支付方式(1.h5微信,2.h5支付宝,3.app微信,4.app支付宝,5.h5微信内支付,6微信pc,7pc支付宝,9线下支付)
- * @param name:apply_data type:string default:-- desc:报名信息
- * @param name:apply_data.price_id type:int default:-- desc:价格id
- * @param name:apply_data.name type:string default:-- desc:联系人
- * @param name:apply_data.phone_pre type:string default:-- desc:手机号前缀
- * @param name:apply_data.phone type:string default:-- desc:联系人电话
- * @param name:apply_data.email type:string default:-- desc:email
- * @param name:apply_data.num type:int default:-- desc:数量
- * @param name:apply_data.code type:int default:-- desc:第几张票
- * @param name:apply_data.phone_code type:int default:-- desc:短信验证码
- * @param name:apply_data.template_list type:string default:-- desc:报名模板信息【活动模板填完值之后的json】
- * @param name:bill_info type:string default:-- desc:发票信息--json【不开票可以不传】
- * @param name:bill_info.type type:int default:-- desc:类型id
- * @param name:bill_info.header type:string default:-- desc:抬头名称[公司名称||个人名称]
- * @param name:bill_info.identify_number type:string default:-- desc:纳税人识别号
- * @param name:bill_info.email type:string default:-- desc:邮箱
- * @param name:bill_info.remark type:string default:-- desc:备注
- *
- * @param name:address_info type:string default:-- desc:收货信息--json【非物流不传】
- * @param name:address_info.type type:int require:1 default:-- desc:领取方式【1现场2快递】
- * @param name:address_info.send_type type:int require:1 default:-- desc:申请类型【1点子发票2纸质发票】
- * @param name:address_info.pro_name type:string require:1 default:-- desc:省名【快递必传】
- * @param name:address_info.city_name type:string require:1 default:-- desc:市名【快递必传】
- * @param name:address_info.county_name type:string require:1 default:-- desc:县区名【快递必传】
- * @param name:address_info.detail type:string require:0 default:-- desc:详细地址【快递必传】
- * @param name:address_info.phone type:string require:1 default:-- desc:联系电话【快递必传】
- * @param name:address_info.name type:string require:1 default:-- desc:联系人【快递必传】
- *
- * @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.appId type:string default:-- desc:appID【h5】
- * @return name:config.paySign type:string default:-- desc:签名【h5】
- * @return name:config.nonceStr type:string default:-- desc:随机字符串【h5】
- * @return name:config.timeStamp type:string default:-- desc:时间戳【h5】
- * @return name:config.appid type:string default:-- desc:appid【微信APP】
- * @return name:config.sign type:string default:-- desc:签名【微信APP】
- * @return name:config.noncestr type:string default:-- desc:随机字符串【微信APP】
- * @return name:config.timestamp type:string default:-- desc:时间戳【微信APP】
- *
- * @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');
- $tg = input('post.tg','');
- $pay_type = input('post.pay_type',1);
- $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('活动已经取消');
- if($act_info->status == 0) $this->error('活动已经下架');
- if($act_info->pay_offline == 0 && $pay_type == 9) $this->error('活动不支持线下支付');
- if(!$this->user_id) {
- $phone = input('post.phone');
- $phone_pre = input('post.phone_pre','86');
- $phone_code = input('post.phone_code');
- if(empty($phone)) $this->error('请填写支付人手机号'.$phone);
- if(empty($phone_code)) $this->error('请填写支付人手机号验证码:'.$phone_code);
- $check_code = $this->checkPhoneCode($phone,$phone_code,$phone_pre);
- if(!$check_code) $this->error('验证码错误');
- $this->updatePhoneCode($check_code);
- $user_info = User::getUserInfo($phone,$phone_pre);
- $this->user_id = $user_info['id'];
- if(empty($user_info)) $this->error('该手机号被禁用');
- }else{
- $user_info = $this->userInfo();
- }
- // 订单详情
- $apply_info = [
- 'user_id' => $this->user_id,
- 'order_no' => get_order_sn(),
- 'pay_no' => get_order_sn(),
- 'name' => $user_info['name'],
- 'phone' => $user_info['phone'],
- 'phone_pre' => $user_info['phone_pre'],
- 'pay_type' => $pay_type,
- 'act_id' => $act_id,
- 'tg_id' => $tg ? Db::name('activity_qrcode')->where('tg_param',$tg)->max('id'): 0,
- ];
- $apply_item = [];
- $post_apply = input('post.apply_data');
- $post_bill = input('post.bill_info');
- $post_address = input('post.address_info');
- $apply_data = json_decode(stripslashes($post_apply),true);
- $bill_info = json_decode(stripslashes($post_bill),true);
- $address_info = json_decode(stripslashes($post_address),true);
- if(empty($apply_data)) $this->error('请填写报名信息');
- $ret_data = ['pay_status'=>0,'config'=>null,'code_url'=>'','openid'=>$user_info['openid'],'order_id'=>0];
- Db::startTrans();
- try {
- $cl_apply = [];
- array_walk($apply_data,function (&$cv)use (&$cl_apply){
- if(isset($cl_apply[$cv['price_id']])){
- $cl_apply[$cv['price_id']]++;
- } else{
- $cl_apply[$cv['price_id']] = 1;
- }
- });
- array_walk($apply_data,function (&$v)use (&$apply_item,$act_id,$cl_apply){
- $v['buy_total'] = $cl_apply[$v['price_id']];
- // 验证码验证
- //$check_code = $this->checkPhoneCode($v['phone'],$v['phone_code'],$v['phone_pre']);
- // if(!$check_code) $this->exception($v['phone'].'验证码错误');
- //$this->updatePhoneCode($check_code);
- // 会员验证
- $user_item = User::getUserInfo($v['phone'],$v['phone_pre'] ? $v['phone_pre'] : 86);
- if(empty($user_item)) $this->exception($v['phone'].'被禁用');
- // 售票验证
- // var_dump($v['price_id']);
- $price_info = ActivityPrice::where('id',$v['price_id'])->find()->toArray();
- if($price_info['ladder_status'] != 1) $this->exception($price_info['ladder_title'].'已下架');
- if($price_info['stock'] <= 0) $this->exception($price_info['ladder_title'].'已售罄');
- // 扣减库存
- ActivityPrice::where('id',$price_info['id'])->setDec('stock',$v['num']);
- // var_dump($v['template_list']);
- // 报名模板验证
- foreach ($v['template_list'] as &$tv) {
- if($tv['required'] && in_array($tv['type'],[1,2]) && !$tv['value'] ) $this->exception($tv['title'].'必填');
- if($tv['required'] && in_array($tv['type'],[3])) {
- $extend = is_array($tv['extend']) ? $tv['extend'] : json_decode($tv['extend']);
- $sel_extend = array_sum(array_column($extend,'value'));
- if(!$sel_extend) $this->exception($tv['title'].'必选');
- }
- }
- // 票详情
- $apply_item[] = [
- 'user_id' => $user_item['id'],
- 'act_id' => $act_id,
- 'price_id' => $v['price_id'],
- 'num' => $v['num'],
- 'name' => $v['name'],
- 'phone' => $v['phone'],
- 'code' => isset($v['code']) ? $v['code'] : 1,
- 'email' => $v['email'],
- 'sh_status' => $price_info['is_sh'] ? 0 : 1 ,
- 'price_sh' => $price_info['is_sh'] ,
- 'money' => $price_info['fill_num'] > 0 && $v['buy_total'] >= $price_info['fill_num'] ? bcmul($price_info['ladder_price']- $price_info['sub_money'],$v['num'],2) : bcmul($price_info['ladder_price'],$v['num'],2),
- 'total_money' => bcmul($price_info['ladder_price'],$v['num'],2),
- 'extend' => json_encode($v['template_list'],JSON_UNESCAPED_UNICODE),
- ];
- });
- $apply_info['money'] = array_sum(array_column($apply_item,'money'));
- $apply_info['total_money'] = array_sum(array_column($apply_item,'total_money'));
- $apply_info['num'] = array_sum(array_column($apply_item,'num'));
- if($apply_info['money'] < 0) $this->exception('金额错误');
- // 主订单写入
- $order_info = ActivityApply::create($apply_info)->toArray();
- array_walk($apply_item,function (&$v)use ($order_info){
- $v['apply_id'] = $order_info['id'];
- });
- (new ActivityApplyItem())->saveAll($apply_item);
- if($order_info['money'] == 0) {
- $back_res = OrderCallback::activityOrderCallBack($order_info);// 支付完成后回调
- if(!$back_res['ret_val']) $this->exception($back_res['msg']);
- $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_h5('订单支付',$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/applyOrderNotify';
- $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;
- case 6:
- $notify_url = $this->request->root(true) . '/api/we_chat_pay/applyOrderNotify';
- $pay_config = WeChatPay::wxPay('订单支付',$order_info['pay_no'],$order_info['money'] ,$notify_url,'NATIVE');
- $ret_data['config'] = $pay_config['config'];
- $ret_data['code_url'] = $pay_config['pc_pay_url'];
- break;
- case 7:
- $notify_url = $this->request->root(true) . '/api/Alipay/applyOrderNotify';
- $return_url ='https://'.$_SERVER['HTTP_HOST']."/pc/?#/activity/my-order#";
- $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;
- }
- }
- //订单需要开票
- if($order_info['money'] > 0 && !empty($bill_info)) {
- // 是否是选择的已有的抬头
- /* if(isset($bill_info['header_id']) && $bill_info['header_id']) {
- $bill_info = BillHeader::where('id',$bill_info['header_id'])->find()->toArray();
- }else{
- $bill_info = BillHeader::saveHeader(array_merge($bill_info,['user_id'=>$user_info['id'],'is_deleted'=>1]));
- }*/
- // 是否有物流地址
- $address_id = 0;
- if(!empty($address_info) && isset($address_info['send_type']) && $address_info['send_type'] == 2 && isset($address_info['type']) && $address_info['type']){
- $address_info = DeliveryAddress::saveAddress(array_merge($address_info,['user_id'=>$user_info['id'],'is_deleted'=>1]));
- $address_id = $address_info['id'];
- }
- $ret_val = UserSynth::buildBillApply($user_info['id'], $order_info['id'], 3,$bill_info,$address_id,1,$bill_info['remark'],0);
- if($ret_val['code'] != 200) $this->exception($ret_val['msg']);
- }
- 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】
- * @param name:pay_type type:int default:-- desc:支付方式(1.h5微信,2.h5支付宝,3.app微信,4.app支付宝,5.h5微信内支付,9线下支付)
- *
- * @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 = input('post.pay_type',0) ;//$order_info['pay_type'];
- $user_info = User::where('id',$order_info['user_id'])->find();
- $ret_data = ['pay_status'=>0,'config'=>[],'code_url'=>'','openid'=>$user_info['openid'],'order_id'=>0];
- if($pay_type == 9) $this->error('订单为线下支付,请联系管理员');
- Db::startTrans();
- try {
- ActivityApply::where('id',$order_id)->update(['pay_type'=>$pay_type]);
- 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_h5('订单支付',$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;
- case 6 :
- $notify_url = $this->request->root(true) . '/api/we_chat_pay/applyOrderNotify';
- $pay_config = WeChatPay::wxPay('订单支付',$order_info['pay_no'],$order_info['money'] ,$notify_url,'NATIVE');
- $ret_data['config'] = $pay_config['config'];
- $ret_data['code_url'] = $pay_config['pc_pay_url'];
- break;
- case 7 :
- $notify_url = $this->request->root(true) . '/api/Alipay/applyOrderNotify';
- $return_url ='https://'.$_SERVER['HTTP_HOST']."/pc/?#/activity/my-order#";
- $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;
- }
- 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/getApplyInfo
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:订单id
- * @param name:order_no type:string default:-- desc:订单号
- * @param name:pay_no type:string default:-- desc:订单支付号
- * @param name:create_at type:string default:-- desc:创建时间
- * @param name:pay_at type:string default:-- desc:支付时间
- * @param name:status type:int default:-- desc:订单状态【0未支付1已支付2已取消】
- * @param name:money type:float default:-- desc:订单金额
- * @param name:pay_type type:int default:-- desc:支付方式(1.h5微信,2.h5支付宝,3.app微信,4.app支付宝,5.h5微信内支付,9线下支付)
- * @param name:pay_state type:int default:-- desc:是否支付【0未支付1已支付】
- * @param name:cancel_state type:int default:-- desc:是否取消【0未取消1已取消】
- * @param name:refund_state type:int default:-- desc:退款状态(0未申请1审核中2同意3拒绝4退款成功5退款异常)
- * @param name:phone_pre type:string default:-- desc:phone前缀
- * @param name:phone type:string default:-- desc:phone
- * @param name:cancel_timestamp type:string default:-- desc:支付倒计时(单位秒)【已支付忽略】
- * @return name:sh_num type:int default:-- desc:已核销票数量
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:cover type:string default:-- desc:图片
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:pay_offline type:int default:-- desc:线下支付是否开启【0关闭1开启】
- * @return name:offline_user type:string default:-- desc:线下支付户名
- * @return name:offline_bank type:string default:-- desc:线下支付开户行
- * @return name:offline_card type:string default:-- desc:线下支付账号
- *
- * @return name:item_list type:array default:-- desc:票详情
- * @return name:item_list.id type:array default:-- desc:票详情id
- * @return name:item_list.ladder_title type:string default:-- desc:票标题
- * @return name:item_list.name type:string default:-- desc:名称
- * @return name:item_list.phone type:string default:-- desc:phone
- * @return name:item_list.phone_pre type:string default:-- desc:phone前缀
- * @return name:item_list.email type:string default:-- desc:email
- * @return name:item_list.sh_status type:int default:-- desc:是否需要审核【0待审核,1审核通过,2审核拒绝】
- * @return name:item_list.extend type:array default:-- desc:报名模板信息
- * @return name:sponsor type:array default:-- desc:主办方信息
- * @return name:sponsor.id type:int default:-- desc:主办方记录id
- * @return name:sponsor.qr_code type:string default:-- desc:二维码
- * @return name:sponsor.cover type:string default:-- desc:主办方logo
- * @return name:sponsor.official_web type:string default:-- desc:主办方官网
- * @return name:sponsor.title type:string default:-- desc:主办方名称
- * @return name:sponsor.address type:string default:-- desc:地址
- * @return name:sponsor.email type:string default:-- desc:email
- * @return name:sponsor.phone type:string default:-- desc:phone
- *
- * @return name:bill_info type:array default:-- desc:发票申请信息
- * @return name:bill_info.header type:string default:0 desc:抬头
- * @return name:bill_info.type type:int default:0 desc:发票类型
- * @return name:bill_info.email type:string default:0 desc:邮箱
- * @return name:bill_info.phone type:string default:0 desc:电话
- * @return name:bill_info.bank type:string default:0 desc:开户行
- * @return name:bill_info.card_no type:string default:0 desc:银行账号
- * @return name:bill_info.identify_number type:string default:0 desc:纳税人识别号
- * @return name:bill_info.bill_img type:string default:0 desc:点子发票url
- * @return name:bill_info.send_type type:string default:1 desc:1点子发票2纸质发票
- * @return name:bill_info.remark type:string default:0 desc:备注
- * @return name:express_state type:int default:0 desc:物流状态0未发货1已发货【send_type=1时忽略】
- * @return name:express_company_title type:int default:0 desc:物流公司【send_type=1时忽略】
- * @return name:express_send_no type:int default:0 desc:物流编号【send_type=1时忽略】
- * @return name:express_send_at type:int default:0 desc:发货时间【send_type=1时忽略】
- * @return name:address_info type:array default:0 desc:售货地址详情【send_type=1时忽略】
- * @return name:address_info.pro_name type:string default:-- desc:省名
- * @return name:address_info.city_name type:string default:-- desc:市名
- * @return name:address_info.county_name type:string default:-- desc:县区名
- * @return name:address_info.detail type:string default:-- desc:详细地址
- * @return name:address_info.phone type:string default:-- desc:联系电话
- * @return name:address_info.name type:string default:-- desc:联系人
- */
- public function getApplyInfo()
- {
- $detail = ActivityApply::where(['y.user_id'=>$this->user_id,'y.id'=>input('get.id')])
- ->alias('y')
- ->field('y.*,a.title,a.cover,a.start_time,a.end_time,a.province,y.pay_at,a.city,a.county,a.address,a.sponsor_id,a.pay_offline,a.offline_user,a.offline_bank,a.offline_card')
- ->leftJoin('Activity a','y.act_id = a.id')
- ->with(['itemList'])
- ->find()->toArray();
- $detail['cancel_timestamp'] = $detail['pay_state'] == 0 && $detail['cancel_state'] == 0 && strtotime($detail['create_at']) + 300 - time() > 0 ? strtotime($detail['create_at']) + 300 - time() : 0;
- array_walk($detail['item_list'],function (&$v){
- $v['extend'] = $v['extend'] ? json_decode($v['extend'],true) : null;
- });
- $detail['sh_num'] = ActivityApplyItem::where('apply_id',$detail['id'])->where('is_hx',1)->count();
- $detail['sponsor'] = $detail['sponsor_id'] ? ActivitySponsor::where('id',$detail['sponsor_id'])->find()->toArray() : null;
- $bill_info = BillApply::where(['order_type'=>3,'order_id'=>$detail['id']])->find();
- if($bill_info) {
- $bill_info = $bill_info->toArray();
- if($bill_info['address_info']) $bill_info['address_info'] = json_decode($bill_info['address_info'],true);
- }
- $detail['bill_info'] = !empty($bill_info) ? $bill_info : null;
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 取消订单
- * @desc 取消订单
- * @author qc
- * @method POST
- * @url /api/Activity/cancelApplyOrder
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:活动订单id
- */
- public function cancelApplyOrder()
- {
- $detail = ActivityApply::with(['itemList'])
- ->where([['user_id','=',$this->user_id],['pay_state','=',0],['cancel_state','=',0],['id','=',input('post.id')]])
- ->find();
- if(empty($detail)) $this->error('订单异常');
- $detail= $detail->toArray();
- // if($detail['pay_state'] == 1 && $detail['money'] > 0) $this->error('订单已支付');
- Db::startTrans();
- try {
- ActivityApply::where('id',$detail['id'])->update(['cancel_state'=>1,'status'=>2]);
- foreach ($detail['item_list'] as $it) {
- ActivityPrice::where('id',$it['price_id'])->setInc('stock',$it['num']);
- }
- Db::commit();
- }catch (\Exception $e) {
- Db::rollback();
- $this->error($e->getMessage());
- }
- $this->success('取消成功');
- }
- /**
- * @title 获取角标数量【未读数量统计】
- * @desc 未读数量统计
- * @author qc
- * @method GET
- * @url /api/Activity/getMarkNum
- * @header name:Authorization require:1 desc:Token
- * @return name:order_num type:int default:-- desc:订单数量
- * @return name:apply_num type:int default:-- desc:报名数量
- * @return name:message_num type:int default:-- desc:消息数量
- */
- public function getMarkNum()
- {
- $order_num = 0;
- $apply_num = 0;
- $message_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'is_read'=>0])->where('m.module','in','activity,apply,activityapply')->alias('m')->count();
- $total_num = $message_num;
- $this->success('ok',compact(['order_num','apply_num','message_num','total_num']));
- }
- /**
- * @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:release_time type:string default:-- desc:发布时间
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:status type:int default:-- desc:活动状态【0已下架,1正常】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getMyActivityList(){
- $title = input('get.title');
- $list = \app\common\model\Activity::where(['is_deleted'=>0,'user_id'=>$this->user_id])
- ->field('id,title,cover,start_time,end_time,province,city,county,address,status,release_time')
- ->when($title,function ($query)use($title){
- if($title) $query->where('title|label','like','%'.$title.'%');
- })->order( ['id'=>'desc'])->limit($this->off_set,$this->page_num)->select()->toArray();
- foreach ($list as &$v) {
- $v['is_normal'] = CheckPower::checkModulesPower($v['id'],0,$this->request->controller());
- }
- $total_num = \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.'%');
- })->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:activity_id type:string default:-- desc:活动id
- * @return name:title type:string default:-- desc:标题
- * @return name:cover type:string default:-- desc:海报
- * @return name:release_time type:string default:-- desc:发布时间
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:status type:int default:-- desc:活动状态【0已下架,1正常】
- */
- 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.start_time,i.end_time,i.address,i.province,i.city,i.county,i.status,i.release_time')
- ->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['is_normal'] = CheckPower::checkModulesPower($v['activity_id'],0,$this->request->controller());
- }
- $total_num = UserCollect::where($sel_where)->alias('t')->leftJoin('Activity i','t.coll_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:title type:string default:-- desc:标题
- * @return name:cover type:string default:-- desc:海报
- * @return name:release_time type:string default:-- desc:发布时间
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:time type:string default:-- desc:浏览时间
- * @return name:status type:int default:-- desc:活动状态【0已下架,1正常】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getActivityTrack()
- {
- $sel_where = [];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',7];
- $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.start_time,i.end_time,i.address,i.province,i.city,i.county,i.status,i.release_time')
- ->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['is_normal'] = CheckPower::checkModulesPower($v['activity_id'],0,$this->request->controller());
- }
- $total_num = UserTrack::where($sel_where)->alias('t') ->leftJoin('Activity i','t.first_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:标签[数组]
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- 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;
- $v['is_normal'] = CheckPower::checkModulesPower($v['activity_id'],0,$this->request->controller());
- }
- $total_num = PlatformLike::where($sel_where)->alias('t')->leftJoin('Activity i','t.like_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 我的报名【门票列表】
- * @desc 我的报名
- * @author qc
- * @method GET
- * @url /api/Activity/getApplyList
- * @header name:Authorization require:1 desc:Token
- * @param name:sel_type type:int default:-- desc:查询类型(1报名成功2审核中,3报名失败)
- * @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:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:sh_status type:int default:-- desc:审核【0待审核,1审核通过,2审核拒绝】
- * @return name:is_hx type:int default:-- desc:是否核销(签到)【0未核销,1已核销】
- * @return name:qr_code type:string default:-- desc:核销二维码
- * @return name:qr_content type:string default:-- desc:核销码
- * @return name:activity_title type:string default:-- desc:活动标题
- * @return name:sponsor_title type:string default:-- desc:举办方
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:video_id type:int default:-- desc:视频系列id
- * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
- * @return name:video_jump type:int default:-- desc:关联视频是否能跳转【0不能跳转,1能跳转,验证是否vip】
- *
- * @return name:article_id type:int default:-- desc:图文系列id
- * @return name:article_item type:int default:-- desc:关联图文详情id【item_list.id】
- * @return name:article_jump type:int default:-- desc:关联图文是否能跳转【0不能跳转,1能跳转,验证是否vip】
- * @return name:datum_id type:int default:-- desc:资料id--ppt【系列id】
- * @return name:datum_item type:int default:-- desc:资料id--ppt【系列下的其中一个】
- * @return name:datum_jump type:int default:-- desc:关联资料是否能跳转【0不能跳转,1能跳转,验证是否vip】
- * @return name:datum_url type:int default:-- desc:关联资料链接
- * @return name:label type:string default:-- desc:标签[多个','隔开]
- * @return name:label_name type:array default:-- desc:标签[数组]
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getApplyList()
- {
- $sel_where = [];
- $title = input('get.title');
- $sel_type = input('get.sel_type',1);
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['a.cancel_state','=',0];
- $sel_where[] = ['a.pay_state','=',1];
- $sel_where[] = ['t.is_deleted','=',0];
- switch ($sel_type) {
- case 1:
- $sel_where[] = ['t.sh_status','=',1];
- break;
- case 2:
- $sel_where[] = ['t.sh_status','=',0];
- break;
- case 3:
- $sel_where[] = ['t.sh_status','=',2];
- break;
- }
- $list = ActivityApplyItem::where($sel_where)
- ->field('t.id,a.order_no,t.act_id activity_id,t.sh_status,a.cancel_state,t.status,t.is_hx,i.title,i.status,i.cover,i.label,i.start_time,i.end_time,i.address,i.price,i.video_id,i.video_item,i.article_id,i.article_item,i.datum_id,i.datum_item,i.province,i.city,i.county,i.address')
- ->alias('t')
- ->leftJoin('Activity i','t.act_id = i.id')
- ->leftJoin('ActivityApply a','a.id = t.apply_id')
- ->order(['t.id'=>'desc'])
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['article_jump'] = ArticleItem::checkVip($v['article_item'],$this->user_id);
- $v['video_jump'] = VideoUrl::checkVip($v['video_item'],$this->user_id);
- $v['datum_jump'] = DatumUrl::checkVip($v['datum_item'],$this->user_id);
- $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')): null;
- $v['is_normal'] = CheckPower::checkModulesPower($v['activity_id'],0,$this->request->controller());
- }
- $total_num = ActivityApplyItem::where($sel_where)
- ->alias('t')
- ->leftJoin('Activity i','t.act_id = i.id')
- ->leftJoin('ActivityApply a','a.id = t.apply_id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 获取门票详情
- * @desc 获取门票详情
- * @author qc
- * @url /api/Activity/getTicketInfo
- * @method GET
- * @param name:id type:int require default:-- desc:门票id
- * @return name:id type:array default:-- desc:票详情id
- * @return name:ladder_title type:string default:-- desc:票标题
- * @return name:status type:string default:-- desc:票状态【0未支付1已支付2已取消3退款处理中4已退款】
- * @return name:phone type:string default:-- desc:phone
- * @return name:phone_pre type:string default:-- desc:phone前缀
- * @return name:email type:string default:-- desc:email
- * @return name:sh_status type:int default:-- desc:审核【0待审核,1审核通过,2审核拒绝】
- * @return name:is_hx type:int default:-- desc:是否核销(签到)【0未核销,1已核销】
- * @return name:hx_time type:string default:-- desc:核销时间
- * @return name:qr_code type:string default:-- desc:核销二维码
- * @return name:qr_content type:string default:-- desc:核销码
- * @return name:activity_title type:string default:-- desc:活动标题
- * @return name:sponsor_title type:string default:-- desc:举办方
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:refund_info type:array default:-- desc:退款信息【无退款信息是null】
- * @return name:refund_info.status type:int default:-- desc:0待审核1同意退款2审核拒绝3通过且退款4退款异常5取消申请
- */
- public function getTicketInfo()
- {
- $item_id = input('get.id');
- $info = ActivityApplyItem::where('i.id',$item_id) ->where('i.user_id',$this->user_id)
- ->field('i.id,i.status,i.is_deleted,i.name,i.act_id,i.phone,sh_status,i.email,i.qr_code,i.code,i.is_hx,i.hx_time,qr_content,i.phone_pre,a.pay_state,c.title activity_title,c.start_time,c.end_time,s.title sponsor_title,c.province,c.city,c.county,c.address')
- ->alias('i')
- ->leftJoin('ActivityApply a','a.id = i.apply_id')
- ->leftJoin('Activity c','c.id = i.act_id')
- ->leftJoin('ActivitySponsor s','s.id = c.sponsor_id')
- ->find()->toArray();
- if($info['is_deleted'] == 1) $this->error('门票详情有误');
- $info['refund_info'] = GoodsOrderRefund::getActivityRefund($item_id);
- // if(!$info['pay_state']) $this->error('订单未支付');
- $this->success('ok',['detail'=>$info]);
- }
- /**
- * @title 门票核销
- * @desc 门票核销
- * @author qc
- * @url /api/Activity/hxOrder
- * @method POST
- * @param name:qr_content type:int require default:-- desc:核销码内容
- */
- public function hxOrder(){
- $qr_content = input('post.qr_content');
- if(!$qr_content) $this->error('没有核销内容');
- if(!$this->user_info['is_hx'])$this->error('没有核销权限');
- $item_info = ActivityApplyItem::where(['i.qr_content'=>$qr_content,'is_hx'=>0])
- ->alias('i')->field('i.id,i.is_hx,i.status,i.apply_id,i.is_deleted,a.status,a.cancel_state,a.pay_state,a.refund_state')
- ->leftJoin("ActivityApply a",'a.id = i.apply_id')->find();
- if(!$item_info) $this->error('没有找到核销记录');
- if($item_info->cancel_state)$this->error('订单已取消');
- $refund_info = StoreOrderRefund::getRefundInfo($item_info['apply_id'],$item_info['id'],1);
- if(!empty($refund_info && in_array($refund_info['status'],[0,1,3,5])))$this->error('已申请退款');
- if(!in_array($item_info->refund_state,[0,3]))$this->error('订单已申请退款');
- if(!in_array($item_info->status,[1]))$this->error('票状态异常');
- ActivityApplyItem::where('id',$item_info['id'])->update(['is_hx'=>1,'ticket_status'=>1,'hx_user'=>$this->user_id,'hx_time'=>date("Y-m-d H:i:s")]);
- $this->success('核销成功');
- }
- /**
- * @title 申请退款
- * @desc 申请退款
- * @author qc
- * @url /api/Activity/applyRefund
- * @method POST
- * @param name:order_id type:int require default:-- desc:订单id
- */
- public function applyRefund()
- {
- $order_id = input('order_id');
- $res = \app\common\service\Activity::orderRefundApply($order_id);
- $res['code'] == 200 ? $this->success($res['msg']) : $this->error($res['msg']);
- }
- /**
- * @title 取消申请退款
- * @desc 取消申请退款
- * @author qc
- * @url /api/Activity/applyRefund
- * @method POST
- * @param name:order_id type:int require default:-- desc:订单id
- */
- public function cancelRefund()
- {
- $order_id = input('order_id');
- $order_info = ActivityApply::where('id',$order_id)->where('user_id',$this->user_id)->find();
- if(empty($order_info)) $this->error('订单不存在');
- if(in_array($order_info['refund_state'],[5]))$this->error('订单已退款');
- StoreOrderRefund::where(['order_id'=>$order_id,'source'=>1,'type'=>1])->update(['status'=>5]);
- ActivityApply::where('id',$order_id)->update(['status'=>6]);
- $this->success('取消成功');
- }
- /**
- * @title 获取发票详情
- * @desc 获取发票详情
- * @author qc
- * @url /api/Activity/getBillInfo
- * @method GET
- * @param name:id type:int require default:-- desc:订单id
- * @return name:id type:array default:-- desc:票详情id
- * @return name:header type:string default:0 desc:抬头
- * @return name:type_title type_title:int default:0 desc:发票类型
- * @return name:email type:string default:0 desc:邮箱
- * @return name:create_at type:string default:0 desc:申请时间
- * @return name:phone type:string default:0 desc:电话
- * @return name:bank type:string default:0 desc:开户行
- * @return name:status type:int default:0 desc:状态(0申请中1已开票2已完成【现场领取或是确认收货】)
- * @return name:card_no type:string default:0 desc:银行账号
- * @return name:identify_number type:string default:0 desc:纳税人识别号
- * @return name:send_type type:string default:1 desc:1点子发票2纸质发票
- * @return name:remark type:string default:0 desc:备注
- * @return name:bill_img type:string default:0 desc:点子发票【图片】
- * @return name:bill_time type:string default:0 desc:开票时间
- * @return name:address type:string default:0 desc:公司地址
- * @return name:order_pay type:string default:0 desc:订单是否已支付【0未支付1已支付】
- * @return name:express_state type:int default:0 desc:物流状态0未发货1已发货【send_type=1时忽略】
- * @return name:express_company_title type:int default:0 desc:物流公司【send_type=1时忽略】
- * @return name:express_send_no type:int default:0 desc:物流编号【send_type=1时忽略】
- * @return name:express_send_at type:int default:0 desc:发货时间【send_type=1时忽略】
- * @return name:address_info type:array default:0 desc:售货地址详情【send_type=1时忽略】
- * @return name:address_info.pro_name type:string default:-- desc:省名
- * @return name:address_info.city_name type:string default:-- desc:市名
- * @return name:address_info.county_name type:string default:-- desc:县区名
- * @return name:address_info.detail type:string default:-- desc:详细地址
- * @return name:address_info.phone type:string default:-- desc:联系电话
- * @return name:address_info.name type:string default:-- desc:联系人
- *
- */
- public function getBillInfo()
- {
- //'order_type'=>3,
- $info = BillApply::where(['b.id'=>input('get.id')])
- ->alias('b')->field('b.*,t.title type_title,a.money')
- ->leftJoin('BillType t','t.id = b.type')
- ->leftJoin('ActivityApply a','a.id = b.order_id')
- ->find();
- if(empty($info)) $this->error('该订单未申请发票');
- $info = $info->toArray();
- if($info['address_info']) $info['address_info'] = json_decode($info['address_info'],true);
- $this->success('ok',['detail'=>$info]);
- }
- /**
- * @title 获取纸质发票物流详情
- * @desc 获取纸质发票物流详情
- * @author qc
- * @url /api/Activity/deliveryDetails
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string require:1 default:-- desc:发票申请详情记录
- * @return name:number type:string default:-- desc:单号
- * @return name:type type:string default:-- desc:快递类型
- * @return name:list type:array default:-- desc:数据列表
- * @return name:list.time type:string default:-- desc:时间
- * @return name:list.status type:string default:-- desc:内容
- * @return name:deliverystatus type:int default:-- desc:0:快递收件(揽件)1.在途中2.正在派件3.已签收4.派送失败5.疑难件6.退件签收
- * @return name:issign type:int default:-- desc:是否签收(1.是否签收)
- * @return name:expName type:string default:-- desc:快递公司名称
- * @return name:expSite type:string default:-- desc:快递公司官网
- * @return name:expPhone type:string default:-- desc:快递公司电话
- * @return name:courier type:string default:-- desc:快递员 或 快递站(没有则为空)
- * @return name:courierPhone type:string default:-- desc:快递员电话 (没有则为空)
- * @return name:updateTime type:string default:-- desc:快递轨迹信息最新时间
- * @return name:takeTime type:string default:-- desc:发货到收货消耗时长 (截止最新轨迹)
- * @return name:logo type:string default:-- desc:快递公司LOGO
- */
- public function deliveryDetails(){
- $this->success('ok', get_delivery());
- $send_no = BillApply::where('id',input('get.id'))->value('express_send_no');
- if(!$send_no) $this->error('订单没有发货');
- $data = get_delivery($send_no);
- $this->success('ok',$data);
- }
- /**
- * @title 订单列表【报名订单列表】
- * @desc 订单列表
- * @author qc
- * @url /api/Activity/getApplyOrderList
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:sel_type type:int require:1 default:0 desc:0全部1线上订单2转账订单3免费订单
- * @param name:sel_status type:int require:1 default:-1 desc:查询状态-1全部0待支付1已支付3退款中4已取消
- * @return name:id type:string default:-- desc:订单id
- * @return name:title type:string default:-- desc:活动标题
- * @return name:cover type:string default:-- desc:活动海报
- * @return name:start_time type:string default:-- desc:开始时间
- * @return name:end_time type:string default:-- desc:结束时间
- * @return name:province type:string default:-- desc:省
- * @return name:city type:string default:-- desc:市
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:money type:float default:-- desc:订单金额
- * @return name:pay_type type:int default:-- desc:支付方式(1.h5微信,2.h5支付宝,3.app微信,4.app支付宝,5.h5微信内支付,9线下支付)
- * @return name:pay_offline type:int default:-- desc:线下支付是否开启【0关闭1开启】
- * @return name:offline_user type:string default:-- desc:线下支付户名
- * @return name:offline_bank type:string default:-- desc:线下支付开户行
- * @return name:offline_card type:string default:-- desc:线下支付账号
- * @return name:pay_state type:int default:-- desc:是否支付【0否1是】
- * @return name:sh_num type:int default:-- desc:已核销票数量
- * @return name:refund_state type:int default:-- desc:退款状态【0未申请1审核中2同意3拒绝4退款异常5退款成功6取消申请】
- * @return name:bill_info type:array default:-- desc:发票申请详情
- * @return name:bill_info.id type:int default:-- desc:发票申请详情id
- */
- public function getApplyOrderList()
- {
- $sel_type = input('get.sel_type',0);
- $sel_status = input('get.sel_status',-1);
- $where = [];
- $where[] = ['o.user_id','=',$this->user_id];
- $where[] = ['o.is_deleted','=',0];
- switch ($sel_type) {
- case 1:
- $where[] = ['o.money','>',0];
- $where[] = ['o.pay_type','in','1,2,3,4,5,6,7'];
- break;
- case 2:
- $where[] = ['o.money','>',0];
- $where[] = ['o.pay_type','=',9];
- break;
- case 3:
- $where[] = ['o.money','=',0];
- break;
- }
- switch ($sel_status) {
- case 0:
- $where[] = ['o.pay_state','=',0];
- $where[] = ['o.cancel_state','=',0];
- break;
- case 1:
- $where[] = ['o.pay_state','=',1];
- $where[] = ['o.refund_state','=',0];
- break;
- case 3:
- $where[] = ['o.refund_state','in',[1,2,3,4,5]];
- break;
- case 4:
- $where[] = ['o.cancel_state','=',1];
- break;
- }
- //var_dump($where);
- //testaaaa
- //testbbbb
- $list = ActivityApply::where($where)
- ->field('o.id,o.money,o.order_no,o.sh_state,o.total_money,pay_type,o.pay_state,o.cancel_state,o.refund_state,o.create_at,o.act_id,a.title,a.start_time,a.end_time,a.cover,a.pay_offline,offline_user,offline_bank,offline_card,province,city,county,address')
- ->alias('o')
- ->order('o.id desc')
- ->leftJoin('Activity a','o.act_id = a.id')
- ->select()->toArray();
- array_walk($list,function (&$v){
- $bill_info = BillApply::where(['order_type'=>3,'order_id'=>$v['id']])->find();
- if($bill_info) {
- $bill_info = $bill_info->toArray();
- if($bill_info['address_info']) $bill_info['address_info'] = json_decode($bill_info['address_info'],true);
- }
- $v['bill_info'] = $bill_info;
- $v['sh_num'] = ActivityApplyItem::where('apply_id',$v['id'])->where('is_hx',1)->count();
- });
- $total_num = ActivityApply::where($where) ->alias('o') ->leftJoin('Activity a','o.act_id = a.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 删除订单
- * @desc 删除订单
- * @author qc
- * @url /api/Activity/delApplyOrder
- * @method POST
- * @param name:order_id type:int require default:-- desc:订单id
- */
- public function delApplyOrder()
- {
- $order_id = input('order_id');
- ActivityApply::where('id',$order_id)->where('user_id',$this->user_id)->update(['is_deleted'=>1]);
- $this->success('删除成功');
- }
- /**
- * @title 删除门票
- * @desc 删除门票
- * @author qc
- * @url /api/Activity/delTicket
- * @method POST
- * @param name:id type:int require default:-- desc:门票id
- */
- public function delTicket()
- {
- ActivityApplyItem::where('id',input('post.id'))->where('user_id',$this->user_id)->update(['is_deleted'=>1]);
- $this->success('删除成功');
- }
- /**
- * @title 活动消息
- * @desc 活动消息
- * @author qc
- * @url /api/Activity/getMessageList
- * @method GET
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:id type:int default:-- desc:消息记录id
- * @return name:content type:string default:-- desc:内容
- * @return name:create_at type:string default:-- desc:时间
- * @return name:relation_id type:int default:-- desc:活动id
- * @return name:type_id type:int default:-- desc:类型标识:1活动报名,2活动变更,3活动提醒,4活动订单
- * @return name:children_id type:int default:-- desc:相关详情id【type_id等于1或3是票的id,type_id等于2是活动id,type_id=4是订单id,type_id=5是申请发票记录id】
- * @return name:is_read type:int default:-- desc:是否已读【0否1是】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getMessageList()
- {
- $list = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0])->where('m.module','in','activity,apply,activityapply')->alias('m')
- ->limit($this->off_set,$this->page_num)->order(['m.id'=>'desc'])
- ->select()->toArray();
- array_walk($list,function (&$v){
- $massage = UserMessage::where(['user_id'=>$this->user_id,'is_deleted'=>0])
- ->where('id',$v['id'])
- ->where('title','like','%发票%')->find();
- if($massage){
- $v['is_normal'] = CheckPower::checkModulesPower($v['relation_id'],0,'activityapply');
- }else{
- $v['is_normal'] = CheckPower::checkModulesPower($v['relation_id'],0,$v['module']);
- }
- });
- $total_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0])->where('m.module','in','activity,apply,activityapply')->alias('m')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 消息已读&&未读变更
- * @desc 支持批量选择
- * @author qc
- * @method POST
- * @url /api/Activity/unreadChange
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:-- desc:记录id(多个逗号隔开,不传修改全部])
- * @param name:is_read type:int default:1 desc:变更类型【0消息变更为未读,1变更为已读】
- */
- public function unreadChange()
- {
- $id = input('post.id');
- $where[] = ['user_id','=',$this->user_id];
- $where[] = ['module','in','activity,apply,activityapply'];
- if($id) $where[] = ['id','in',$id];
- $message = UserMessage::where($where)->select();
- UserMessage::where($where)->update(['is_read'=>input('post.is_read')]);
- $this->success('消息变更成功');
- }
- /**
- * @title 批量删除||批量取消
- * @desc 删除||取消
- * @author qc
- * @method POST
- * @url /api/Activity/batchesDel
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:1 desc:记录id【多个用逗号隔开=>'1,2'】
- * @param name:type type:string default:1 desc:消息类型【1消息记录删除】
- */
- public function batchesDel()
- {
- $type = input('post.type',1);
- $del_where = [];
- $del_where[] = ['id','in',input('post.id')];
- if(in_array($type,[1])) UserMessage::where($del_where)->update(['is_deleted'=>1,'is_read'=>1]);
- $this->success('操作成功');
- }
- /**
- * @title 申请开票
- * @desc 申请开票
- * @author qc
- * @method POST
- * @url /api/Activity/applyBill
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:1 desc:订单id
- * @param name:bill_info type:string default:-- desc:发票信息
- * @param name:bill_info.type type:int default:-- desc:类型id
- * @param name:bill_info.header type:string default:-- desc:抬头名称[公司名称||个人名称]
- * @param name:bill_info.identify_number type:string default:-- desc:纳税人识别号
- * @param name:bill_info.email type:string default:-- desc:邮箱
- * @param name:bill_info.remark type:string default:-- desc:备注
- *
- * @param name:address_info type:string default:-- desc:收货信息--json【非物流不传】
- * @param name:address_info.type type:int require:1 default:-- desc:领取方式【1现场2快递】
- * @param name:address_info.send_type type:int require:1 default:-- desc:申请类型【1点子发票2纸质发票】
- * @param name:address_info.pro_name type:string require:1 default:-- desc:省名【快递必传】
- * @param name:address_info.city_name type:string require:1 default:-- desc:市名【快递必传】
- * @param name:address_info.county_name type:string require:1 default:-- desc:县区名【快递必传】
- * @param name:address_info.detail type:string require:0 default:-- desc:详细地址【快递必传】
- * @param name:address_info.phone type:string require:1 default:-- desc:联系电话【快递必传】
- * @param name:address_info.name type:string require:1 default:-- desc:联系人【快递必传】
- */
- public function applyBill()
- {
- $order_id = input('post.id');
- $post_bill = input('post.bill_info');
- $post_address = input('post.address_info');
- $bill_info = json_decode(stripslashes($post_bill),true);
- $address_info = json_decode(stripslashes($post_address),true);
- $order_info = ActivityApply::where('id',$order_id)->where('user_id',$this->user_id)->find()->toArray();
- if($order_info['money'] <= 0 ) $this->error('免费订单无法申请开票');
- if(!$order_info['pay_state'])$this->error('订单未支付');
- if(in_array($order_info['refund_state'],[1,2,4,5]))$this->error('订单已申请退款');
- $refund_money = StoreOrderRefund::getRefundMoney($order_id);
- if($refund_money >= $order_info['money'])$this->error('订单已全额退款');
- if(BillApply::checkBillApply($order_id,3)) $this->error('已申请开票');
- $user_info = $this->userInfo();
- // 是否是选择的已有的抬头
- /* if(isset($bill_info['header_id']) && $bill_info['header_id']) {
- $bill_info = BillHeader::where('id',$bill_info['header_id'])->find()->toArray();
- }else{
- $bill_info = BillHeader::saveHeader(array_merge($bill_info,['user_id'=>$user_info['id'],'is_deleted'=>1]));
- }*/
- // 是否有物流地址
- if(!empty($address_info) && isset($address_info['type']) && $address_info['type'] == 2)$address_info = DeliveryAddress::saveAddress(array_merge($address_info,['user_id'=>$user_info['id'],'is_deleted'=>1]));
- $ret_val = UserSynth::buildBillApply($user_info['id'], $order_info['id'], 3,$bill_info,!empty($address_info)&& isset($address_info['type']) && $address_info['type'] == 2 ? $address_info['id']:0,1,$bill_info['remark'],0);
- if($ret_val['code'] != 200) $this->error($ret_val['msg']);
- $this->success('申请成功');
- }
- }
|