123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- <?php
- namespace app\api\controller;
- use think\Db;
- /**
- * @title 其他接口
- * @controller General
- * @group base
- */
- class General extends Base
- {
- public function initialize()
- {
- parent::check_login();
- }
- /**
- * @title 获取物流详情
- * @desc 获取物流详情
- * @author qc
- * @url /api/General/deliveryDetails
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:send_no type:string require:1 default:-- desc:物流单号(订单express_send_no字段)
- * @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])
- ->count();
- $this->success('ok',['is_sign'=>$ck_sign]);
- }
- /**
- * @title 获取会员连续签到天数
- * @desc 获取会员连续签到天数
- * @author qc
- * @url /api/General/getContinuousSign
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:is_sign type:int default:-- desc:当天是否签到(0签到,1已签到)
- * @return name:sign_num type:int default:-- desc:连续签到天数
- */
- public function getContinuousSign()
- {
- $today_sign = Db::table('user_sign')
- ->where(['uid'=>$this->uid,'day_time'=>date('Y-m-d')])
- ->find();
- $is_sign = !empty($today_sign) ? 1:0;
- $sign_num = 0;
- $week_sign = Db::table('user_sign')
- ->where('uid','=',$this->uid)
- ->where('create_at','>= time',date('Y-m-d 00:00:00',strtotime('-6 days')))
- ->where('status','=',0)
- ->order('id desc')
- ->select();
- $sign_date = array_column($week_sign,'day_time');
- for($i=0;$i<=6;$i++) {
- if(in_array(date('Y-m-d',strtotime("-$i days")),$sign_date)){
- $sign_num++;
- }else if($i>0){
- break;
- }
- }
- $this->success('ok',['sign_num'=>$sign_num,'is_sign'=>$is_sign]);
- }
- /**
- * @title 会员签到
- * @desc 会员签到
- * @author qc
- * @url /api/General/userSign
- * @method POST
- * @header name:Authorization require:1 desc:Token
- * @return name:sign_crystal type:int default:-- desc:明信片
- * @return name:coupon_id type:int default:-- desc:券id(没有券是0)
- */
- public function userSign()
- {
- $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])
- ->count();
- if($ck_sign) $this->error('已签到');
- $sign_crystal = rand(1,5);
- $sign_data=[
- 'uid' =>$this->uid,
- 'year' =>$year,
- 'month' =>$month,
- 'day' =>$day,
- 'day_time'=>date('Y-m-d'),
- 'create_at' => date('Y-m-d H:i:s'),
- 'desc' => '每日签到',
- 'crystal'=>$sign_crystal
- ];
- Db::table('user_sign')->insert($sign_data);// 签到日志
- //
- Db::table('store_member')->where('id',$this->uid)->setInc('crystal',$sign_crystal);
- crystal_log($this->uid,$sign_crystal,'每日签到奖励',10);
- // 连续签到7天送券
- $week_sign = Db::table('user_sign')
- ->where('uid','=',$this->uid)
- ->where('create_at','>= time',date('Y-m-d 00:00:00',strtotime('-6 days')))
- ->where('status','=',0)
- ->order('id desc')
- ->count();
- $coupon_id = 0;
- if($week_sign == 7) {
- Db::table('user_sign')
- ->where('uid','=',$this->uid)
- ->where('create_at','>= time',date('Y-m-d 00:00:00',strtotime('-6 days')))
- ->where('status','=',0)
- ->update(['status'=>1]);
- // 送券
- $ticket_day = intval(sysconf('ticket_days'));// 获取设置天数
- if($ticket_day > 0) {
- $coupon_data=[
- 'user_id' => $this->uid,
- 'low_day' => $ticket_day ,
- 'create_at'=> date('Y-m-d H:i:s'),
- 'past_at' => date('Y-m-d H:i:s',strtotime("+$ticket_day days"))
- ];
- Db::table('user_coupon_list')->insert($coupon_data);
- $coupon_id = Db::getLastInsID();
- }
- }
- $this->success('签到成功',['sign_crystal'=>$sign_crystal,'coupon_id'=>$coupon_id]);
- }
- /**
- * @title 会员签到列表
- * @desc 会员签到列表
- * @author qc
- * @url /api/General/getSignList
- * @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:每页数
- * @return name:create_at type:string default:-- desc:时间
- * @return name:desc type:string default:-- desc:描述
- */
- public function getSignList()
- {
- $list = Db::table('user_sign')
- ->field('id,create_at,desc')
- ->where('uid','=',$this->uid)
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取运费
- * @desc 获取运费
- * @author qc
- * @url /api/General/getFreight
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:num type:int require:1 default:1 desc:商品数量
- * @return name:all_freight type:int default:-- desc:总运费
- * @return name:first_freight type:int default:-- desc:首件运费
- * @return name:later_freight type:int default:-- desc:续件运费
- */
- public function getFreight()
- {
- $freight_data = get_freight(input('num',1));
- $this->success('ok',$freight_data);
- }
- /**
- * @title 获取消息
- * @desc 获取消息
- * @author qc
- *
- * @url /api/General/getUserMessage
- * @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:每页数
- * @return name:create_at type:string default:-- desc:时间
- * @return name:content type:string default:-- desc:内容
- * @return name:type_id type:int default:-- desc:类型(1中奖消息2平台消息)
- */
- public function getUserMessage()
- {
- Db::table('user_message')->where('user_id',$this->uid)->where('is_read',0)->update(['is_read'=>1]);
- $list = Db::table('user_message')
- ->where('user_id',$this->uid)
- ->limit($this->off_set,$this->page_num)
- ->order('id desc')
- ->select();
- $this->success('ok',['list'=>$list]);
- }
- }
|