123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- <?php
- namespace app\api\controller;
- use think\Db;
- /**
- * @title 其他接口(订单转换,许愿单等)
- * @controller General
- * @group base
- */
- class General extends Base
- {
- public function initialize()
- {
- parent::initialize();
- parent::check_login();
- }
- /**
- * @title 提交订单转换
- * @desc 提交订单转换
- * @author qc
- * @url /api/General/orderShift
- * @method POST
- * @tag 订单转换
- * @header name:Authorization require:1 desc:Token
- * @param name:order_sn type:string require:1 default:-- desc:第三方订单号
- */
- public function orderShift()
- {
- $order_no = input('post.order_sn');
- if(!$order_no) $this->error('请填写订单号');
- $ck = Db::table('order_shift')->where('order_no',$order_no)->value('id');
- if($ck) $this->error('您已提交过相同的订单ID,请核实后重新提交,有疑问咨询专属客服哦~');
- Db::table('order_shift')->insert(['uid'=>$this->uid,'create_at'=>date('Y-m-d H:i:s'),'order_no'=>$order_no]);
- $this->success('订单提交成功,等待审核!');
- }
- /**
- * @title 获取提交的转换记录
- * @desc 获取提交的转换记录
- * @author qc
- * @url /api/General/getOrderShiftList
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int : default:1 desc:页数
- * @param name:page_num type:int : default:20 desc:每页数
- * @param name:ck_status type:int : default:-1 desc:审核状态(默认全部)0待审核,1审核通过,2审核不通过,
- * @return name:id type:int default:-- desc:记录id
- * @return name:uid type:string default:-- desc:会员id
- * @return name:order_no type:string default:-- desc:提交的订单号
- * @return name:sh_status type:int default:-- desc:审核状态(0待审核,1审核通过,2审核不通过)
- * @return name:remark type:string default:-- desc:审核备注
- * @return name:ck_time type:string default:-- desc:审核时间
- * @return name:integral type:int default:-- desc:转化多少积分
- * @return name:growth type:int default:-- desc:转化多少成长值
- */
- public function getOrderShiftList()
- {
- $where['o.uid'] = $this->uid;
- $ck_status = input('ck_status',-1);
- if(in_array($ck_status,[0,1,2]))$where['o.sh_status'] =$ck_status;
- $list = Db::table('order_shift')
- ->field('o.id,o.order_no,o.sh_status,ck_time,integral,growth,d.title as remark')
- ->alias('o')
- ->join('audit_desc d','d.id = o.audit_id',"LEFT")
- ->where($where)
- ->limit($this->off_set,$this->page_num)
- ->order('o.id desc')
- ->select();
- $this->success('ok',$list);
- }
- /**
- * @title 获取许愿分类
- * @desc 获取许愿分类
- * @author qc
- * @url /api/General/getWishCate
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:int default:-- desc:分类id
- * @return name:title type:string default:-- desc:分类名称
- */
- public function getWishCate()
- {
- $list = Db::table('wish_cate')
- ->field('id,title')
- ->where('is_deleted',0)->where('status',1)
- ->order('sort desc,id desc')->select();
- $this->success('提交成功',['list'=>$list]);
- }
- /**
- * @title 提交许愿单
- * @desc 提交许愿单
- * @author qc
- * @url /api/General/proWish
- * @method POST
- * @header name:Authorization require:1 desc:Token
- * @param name:phone type:string require:1 default:-- desc:手机号
- * @param name:first_classify type:int require:1 default:-- desc:分类id
- * @param name:detail type:string require:1 default:-- desc:详情
- */
- public function proWish()
- {
- $phone = input('post.phone');
- $first_classify = input('post.first_classify');
- $detail = input('post.detail');
- if(!$detail ) $this->error('请填写愿望号');
- $ck = Db::table('user_wish')
- ->where(['uid'=>$this->uid,'first_classify'=>$first_classify,'detail'=>$detail])
- ->value('id');
- if($ck) $this->error('愿望不能重复提交');
- Db::table('user_wish')->insert(['uid'=>$this->uid,'phone'=>$phone,'first_classify'=>$first_classify,'detail'=>$detail,'create_at'=>date('Y-m-d H:i:s')]);
- $this->success('提交成功');
- }
- /**
- * @title 获取物流详情
- * @desc 获取物流详情
- * @author qc
- * @url /api/General/deliveryDetails
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:company_id type:int require:1 default:-- desc:快递id(订单express_company_id字段)
- * @param name:send_no 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(){
- $send_no = input('get.send_no');
- $data = get_delivery($send_no);
- $this->success('ok',$data);
- }
- /**
- * @title 验证会员当天是否签到
- * @desc 验证会员当天是否签到
- * @author qc
- * @url /api/General/checkSign
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:is_sign type:int default:0 desc:是否签到0未签到,1已签到
- */
- public function checkSign()
- {
- $year = date('Y');
- $month = date('m');
- $day = date('d');
- $ck_sign = Db::table('user_sign')
- ->where(['uid'=>$this->uid,'year'=>$year,'month'=>$month,'day'=>$day,'type'=>1])
- ->count();
- $this->success('ok',['is_sign'=>$ck_sign]);
- }
- /**
- * @title 会员当月签到详情
- * @desc 会员当月签到详情
- * @author qc
- * @url /api/General/getUserMonthSign
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:month_data type:array default:-- desc:日历
- * @return name:month_data.date_str type:array default:-- desc:时间
- * @return name:month_data.date type:array default:-- desc:日期
- * @return name:month_data.prefix_date type:array default:-- desc:日期
- * @return name:month_data.week type:string default:-- desc:星期几
- * @return name:month_data.live_num type:int default:-- desc:当天直播场数(没有直播是0)
- * @return name:month_data.is_sign type:int default:-- desc:是否签到(未签到是0,签到是1)
- * @return name:month_data.live_sign type:string default:-- desc:标签
- * @return name:today_sign type:int default:0 desc:当天是否签到(未签到是0,签到是1)
- * @return name:count type:int default:0 desc:月签到次数
- * @return name:acc_data type:array default:-- desc:月累计签到签到
- * @return name:acc_data.seven type:int default:0 desc:累计7天奖励是否领取(0未领取,1已领取)
- * @return name:acc_data.seventeen type:int default:0 desc:累计17天奖励是否领取(0未领取,1已领取)
- * @return name:acc_data.twenty_seven type:int default:0 desc:累计27天奖励是否领取(0未领取,1已领取)
- * @return name:sign_set type:array default:0 desc:签到设置
- * @return name:sign_set.type type:int default:0 desc:签到类型(1每日签到,2累积签到)
- * @return name:sign_set.day type:int default:0 desc:天数
- * @return name:sign_set.integral type:int default:0 desc:积分
- * @return name:sign_set.growth type:int default:0 desc:成长值
- */
- public function getUserMonthSign()
- {
- $year = date('Y');
- $month = date('m');
- $month_data = get_month_days();
- $today_sign = 0;
- foreach ($month_data as &$v) {
- $is_live = Db::table('store_live')
- ->where('start_at','>= time',$v['date_str'].' 00:00:00')
- ->where('start_at','<= time',$v['date_str'].' 23:59:59')
- ->find();
- $v['live_num'] = !empty($is_live) ? 1:0;
- $v['live_sign'] = !empty($is_live) ? $is_live['title_sign']:'';
- $v['is_sign'] = Db::table('user_sign')
- ->where(['uid'=>$this->uid,'year'=>$year,'month'=>$month,'set_id'=>1,'day'=>$v['prefix_date']])
- ->count();
- if($v['date_str'] == date('Y-m-d') )$today_sign = $v['is_sign'] ;
- }
- $acc = Db::table('user_sign')
- ->where(['uid'=>$this->uid,'year'=>$year,'month'=>$month,'set_id'=>[2,3,4]])
- ->select();
- $acc_data =['seven'=>0,'seventeen'=>0,'twenty_seven'=>0];
- array_map(function ($val)use (&$acc_data){
- switch ($val['set_id']){
- case 2:
- $acc_data['seven']=1;
- break;
- case 3:
- $acc_data['seventeen']=1;
- break;
- case 4:
- $acc_data['twenty_seven']=1;
- break;
- }
- },$acc);
- $sign_set = Db::table('store_sign')->select();
- $this->success('ok',['month_data'=>$month_data,'today_sign'=>$today_sign,'count'=>array_sum(array_column($month_data,'is_sign')),'acc_data'=>$acc_data,'sign_set'=>$sign_set]);
- }
- /**
- * @title 会员签到
- * @desc 会员签到
- * @author qc
- * @url /api/General/userSign
- * @method POST
- * @header name:Authorization require:1 desc:Token
- * @param name:type type:int require:1 default:1 desc:签到类型1普通签到,2累计7天,3,累计17天,4累计27天
- * @return name:send_integral type:int default:0 desc:发放积分数
- */
- public function userSign()
- {
- $type = input('post.type',1);
- $year = date('Y');
- $month = date('m');
- $day = date('d');
- $send_integral = 0;
- $daily_set = Db::table('store_sign')->where(['type'=>1])->find();//每日签到
- $cumulant_set = Db::table('store_sign')->where(['type'=>2])->select();// 累积签到
- $ck_sign = Db::table('user_sign')
- ->where(['uid'=>$this->uid,'year'=>$year,'month'=>$month,'day'=>$day,'type'=>$type])
- ->count();
- if($ck_sign) $this->error('已签到');
- $sign_data=[
- 'uid' =>$this->uid,
- 'year' =>$year,
- 'month' =>$month,
- 'day' =>$day,
- 'type' =>$type,
- 'create_at' => date('Y-m-d H:i:s'),
- 'desc' => '每日签到',
- 'integral' => $daily_set['integral'],
- 'set_id' => $daily_set['id'],
- 'growth' => $daily_set['growth'],
- ];
- Db::table('user_sign')->insert($sign_data);// 签到日志
- $int_id = Db::getLastInsID();
- $send_integral = bcadd($send_integral,$daily_set['integral']);
- update_user_integral($this->uid,$daily_set['integral'],3,'恭喜亲通过每日签到获得'.$daily_set['integral'].'积分',$int_id);// 更新积分
- if($daily_set['growth'] > 0) update_user_growth($this->uid,$daily_set['growth'],3,'恭喜亲通过每日签到获得'.$daily_set['growth'].'成长值');// 更新成长值
- /**
- * 累积签到
- */
- // 当月每日签到
- $month_sign = Db::table('user_sign')
- ->where(['uid'=>$this->uid,'year'=>$year,'month'=>$month,'type'=>1])
- ->count();
- foreach ($cumulant_set as $val)
- {
- if($val['day'] <= $month_sign){
- // 当月的累积签到是否发放
- $ck_sign = Db::table('user_sign')
- ->where(['uid'=>$this->uid,'year'=>$year,'month'=>$month,'set_id'=>$val['id']])
- ->count();
- if($ck_sign) continue;
- $sign_data=[
- 'uid' =>$this->uid,
- 'year' =>$year,
- 'month' =>$month,
- 'day' =>$day,
- 'type' =>$val['id'],
- 'create_at' => date('Y-m-d H:i:s'),
- 'desc' => '恭喜亲通过累积签到'.$val['day'].'天获得'.$val['integral'].'积分',
- 'integral' => $val['integral'],
- 'growth' => $val['growth'],
- 'set_id' => $val['id'],
- ];
- Db::table('user_sign')->insert($sign_data);
- $int_id = Db::getLastInsID();
- // 更新积分余额
- $send_integral = bcadd($send_integral,$val['integral']);
- update_user_integral($this->uid, $val['integral'],3,$sign_data['desc'],$int_id);
- if($val['growth'] > 0) update_user_growth($this->uid,$val['growth'],3,'恭喜亲通过累积签到'.$val['day'].'天获得'.$val['growth'].'成长值');// 更新成长值
- }
- }
- $this->success('签到成功',['send_integral'=>intval($send_integral)]);
- }
- /**
- * @title 积分兑换
- * @desc 积分兑换
- * @author qc
- * @url /api/General/integralConvert
- * @method POST
- * @tag 积分兑换
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string require:1 default:-- desc:标题
- * @param name:desc type:string require:1 default:-- desc:描述
- * @param name:image type:string require:1 default:-- desc:图片(1张)
- */
- public function integralConvert()
- {
- $title = input('post.title');
- $desc = input('post.desc');
- $image = input('post.image');
- $info = [
- 'user_id' => $this->uid,
- 'title' =>$title,
- 'desc' =>$desc,
- 'image' =>$image,
- ];
- Db::name('integral_convert')->insert($info);
- $this->success('ok',['已提交等待审核']);
- }
- /**
- * @title 积分兑换详情
- * @desc 积分兑换详情
- * @author qc
- * @url /api/General/getIntegralConvertDetail
- * @method GET
- * @tag
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int : default:1 desc:记录id
- * @return name:title type:string require:1 default:-- desc:标题
- * @return name:desc type:string require:1 default:-- desc:描述
- * @return name:image type:string require:1 default:-- desc:图片(1张)
- * @return name:sh_status type:int require:1 default:-- desc:审核状态(0 待审核1审核通过2审核不通过)
- * @return name:ck_time type:string require:1 default:-- desc:审核时间
- * @return name:remark type:string require:1 default:-- desc:审核备注
- * @return name:integral type:int require:1 default:-- desc:积分数
- */
- public function getIntegralConvertDetail()
- {
- $id = input('post.id');
- $detail = Db::name('integral_convert')->where(['user_id'=>$this->uid,'id'=>$id])->find();
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 积分兑换记录
- * @desc 积分兑换记录
- * @author qc
- * @url /api/General/getIntegralConvertList
- * @method GET
- * @tag 积分兑换
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int : default:1 desc:页数
- * @param name:page_num type:int : default:20 desc:每页数
- * @return name:title type:string require:1 default:-- desc:标题
- * @return name:desc type:string require:1 default:-- desc:描述
- * @return name:image type:string require:1 default:-- desc:图片(1张)
- * @return name:sh_status type:int require:1 default:-- desc:审核状态(0 待审核1审核通过2审核不通过)
- * @return name:ck_time type:string require:1 default:-- desc:审核时间
- * @return name:remark type:string require:1 default:-- desc:审核备注
- * @return name:integral type:int require:1 default:-- desc:积分数
- */
- public function getIntegralConvertList()
- {
- $list = Db::name('integral_convert')->where(['user_id'=>$this->uid,'is_deleted'=>0])
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 删除积分兑换记录
- * @desc 删除积分兑换记录
- * @author qc
- * @url /api/General/delIntegralConvert
- * @method POST
- * @tag 积分兑换
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int require:1 default:-- desc:积分兑换记录id
- */
- public function delIntegralConvert()
- {
- $id = input('post.id');
- Db::name('integral_convert')->where(['user_id'=>$this->uid,'id'=>$id])->update(['is_deleted'=>1]);
- $this->success('删除成功');
- }
- }
|