| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\api\controller;
- use think\Exception;
- use app\api\logic\WelfareLoginc;
- use app\common\model\UserModel;
- use app\common\controller\Api;
- use app\common\model\UserWelfare;
- use think\Db;
- use think\exception\DbException;
- use app\common\model\ProductOrder;
- //空投
- class Airdrop extends Api
- {
- protected array $noNeedLogin = [''];
- protected string $lan = '';
- public function _initialize()
- {
- parent::_initialize();
- $this->lan = $this->request->getLan();
- }
- //新人福利
- public function newbie(UserWelfare $userWelfare, ProductOrder $productOrder, UserModel $userModel)
- {
- $row = $userWelfare::getIsWelfare();
- if(empty($row->is_newbie)) $this->error(__('暂未开启'));
-
- $info = $productOrder::getUserWelfare($this->auth->id, $productOrder::Newbie);
- if(!empty($info)) $this->error(__('您已领取'));
- Db::startTrans();
- try {
- //添加Rwa茶记录
- $result = WelfareLoginc::setUserWelfareLos($this->auth->id, $row->product_id, $row->num, $this->lan);
- //添加茶数量
- $userModel::updateForRwaNum($this->auth->id, $this->auth->parent_id, $row->num, '+');
- Db::commit();
- } catch (\Exception $e) {
- Db::rollback();
- $this->error($e->getMessage());
- }
- $this->success('', $result);
- }
- //超级福利
- public function super()
- {
- $info = (new AnnouncementModel)
- ->where('id', $id)
- ->where('status', 1)
- ->field('id,img_url,body,createtime,' . $this->lan.'_title as title')
- ->find();
- if(empty($info)){
- $this->error('公告信息不存');
- }
- $this->success('', $info);
- }
- }
|