Update.php 7.7 KB
<?php


namespace app\api\controller;


use app\common\controller\Api;
use think\Db;

/**
 * 改版接口
 */
class Update extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = '*';


    /**
     * 改版接口
     * @ApiTitle    (token换UserId)
     * @ApiSummary  (token换UserId)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Update/TokenToUser)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": 29   用户UserID
    })
     */
    public function TokenToUser()
    {
        $UserId = $this->is_token($this->request->header());
        $this->success('成功', $UserId);
    }


    /**
     * 改版接口
     * @ApiTitle    (被邀请页)
     * @ApiSummary  (被邀请页)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Update/InviteHtml)
     * @ApiParams   (name="user_id", type="int", required=true, description="用户UserID")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": {
    "Nickname": "允安",
    "Avatar": "https://thirdwx.qlogo.cn/mmopen/vi_32/PiajxSqBRaEKRz8aJsbiaEwSkCamJBVEx05Y9IHhic7qpd5AK7uQJv8fia6QPXnCBaTFpXxF0Epml7u8K1TybnSwVA/132"
    }
    })
     */
    public function InviteHtml()
    {
        $UserId = input('user_id');
        $Info = Db::name('user')->where('id', $UserId)->find();
        if (empty($Info)) {
            $this->error('网络异常', 0);
        }
        $this->success('成功', ['Nickname' => $Info['nickname'], 'Avatar' => $Info['avatar']]);
    }


    /**
     * 改版接口
     * @ApiTitle    (支付后分享内容)
     * @ApiSummary  (支付后分享内容)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Update/AfterPayWindow)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": {
    "title": "点击领取榴莲味儿的鸡蛋仔送你的免费能量测试及健康礼券",
    "image": "http://xm-public.xyslife.com/life2c/20210106/FmpUPCk0MZAmKJ-LHaKzNwvCdhJk.jpg"
    }
    }
    })
     */
    public function AfterPayWindow()
    {
        $UserId = $this->is_token($this->request->header());
        $UserInfo = Db::name('user')->where('id', $UserId)->find();
        $Info = Db::name('pay_miniappfriends')->find();
        $this->success('成功', ['title' => '点击领取' . $UserInfo['nickname'] . '送你的' . $Info['title'], 'image' => cdnurl($Info['image'])]);
    }


    /**
     * 改版接口
     * @ApiTitle    (氧气泡泡使用规则)
     * @ApiSummary  (氧气泡泡使用规则)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Update/WaterOOGroup)
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": {
    "id": 1,
    "content": "<p><span style=\"color: rgb(255, 192, 0);\"><strong>使用条件:</strong></span></p><ol class=\" list-paddingleft-2\" style=\"list-style-type: decimal;\"><li><p>订单金额≥199元</p></li><li><p>氧气泡泡≥100元</p></li></ol><p>&nbsp;&nbsp;&nbsp;&nbsp;氧气泡泡支付不得超过每笔订单应付金额的20%<br/></p><p><br/></p><p><span style=\"color: rgb(255, 192, 0);\"><strong>使用数量</strong></span></p><p>&nbsp;&nbsp;&nbsp;&nbsp;1.100氧气泡泡=1元<br/></p><p>&nbsp;&nbsp;&nbsp;&nbsp;2.可兑换到分位,例如102氧气泡泡=1.02元<br/></p>"
    }
    }
    })
     */
    public function WaterOOGroup()
    {
        $Info = Db::name('warter_content')->find();
        $this->success('成功', $Info);
    }


    /**
     * 改版接口
     * @ApiTitle    (用户获取一张优惠券)
     * @ApiSummary  (用户获取一张优惠券)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Update/InserUserTick)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    }
    })
     */
    public function InserUserTick()
    {
        $UserId = $this->is_token($this->request->header());
        $TickInfo = Db::name('tick')->find();
        $data = [
            'user_id' => $UserId,
            'exp_time' => time() + $TickInfo['you_time'] * 86400,
            'createtime' => time(),
            'updatetime' => time(),
            'status' => 0
        ];
        $Res = Db::name('user_tick')->insert($data);
        $this->Res($Res);
    }


    /**
     * 改版接口
     * @ApiTitle    (下单选择优惠券页面)
     * @ApiSummary  (下单选择优惠券页面)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Update/ThinkUserTick)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     * @ApiParams   (name="status", type="int", required=true, description="0=可用优惠券,2=不可用优惠券")
     * @ApiParams   (name="total", type="int", required=true, description="总价")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": [
    {
    "id": 1, //优惠券ID
    "title": "好友邀请优惠券",
    "door": 100,  //门槛金额
    "del_price": "30.00",  //优惠金额
    "exp_time": "2021-02-22 13:35:22—2021-03-24 13:35:22"//有效期
    }
    ]
    }
    })
     */
    public function ThinkUserTick()
    {
        $UserId = $this->is_token($this->request->header());
        $Status = input('status');
        $Total = input('total');
        $TickInfo = Db::name('tick')->find();
        if (($Status == 0 && $Total < $TickInfo['door']) || ($Status == 2 && $Total > $TickInfo['door'] - 0.01)) {
            $this->success('成功', []);
        } else {
            $TickArray = Db::name('user_tick')->where('user_id', $UserId)->where('status', 0)->select();
        }
        $List = [];
        if (!empty($TickArray)) {
            foreach ($TickArray as $k => $v) {
                $List[$k]['id'] = $v['id'];
                $List[$k]['title'] = $TickInfo['title'];
                $List[$k]['door'] = $TickInfo['door'];
                $List[$k]['del_price'] = $TickInfo['del_price'];
                $List[$k]['exp_time'] = date('Y-m-d H:i:s', $v['createtime']) . '—' . date('Y-m-d H:i:s', $v['exp_time']);
            }
        }
        $this->success('成功', $List);
    }


    /**
     * 改版接口
     * @ApiTitle    (订单页计算)
     * @ApiSummary  (订单页计算)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Update/OrderPages)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    }
    })
     */

}