Explorar el Código

测试领取超级福利

afa hace 6 meses
padre
commit
8e8bc54464
Se han modificado 1 ficheros con 14 adiciones y 11 borrados
  1. 14 11
      application/api/controller/Airdrop.php

+ 14 - 11
application/api/controller/Airdrop.php

@@ -43,16 +43,18 @@ class Airdrop extends Api
     {
         $row = $userWelfare::getIsWelfare();
         if(empty($row->is_newbie)) $this->error(__('暂未开启'));
-      
-        $info = $productOrder::getUserWelfare($this->auth->id, $productOrder::Newbie);
+        $user = $userModel->getById($this->request->post('uid')); //测试用户
+        $info = $productOrder::getUserWelfare($user->id, $productOrder::Newbie);
         if(!empty($info)) $this->error(__('您已领取'));
         Db::startTrans();
         try {
+            
+
             //添加Rwa茶记录
-            $result = WelfareLoginc::setUserWelfareLos($this->auth->id, $row->new_product_id, $row->new_num, time(), $this->lan, $productOrder::Newbie);
+            $result = WelfareLoginc::setUserWelfareLos($user->id, $row->new_product_id, $row->new_num, time(), $this->lan, $productOrder::Newbie);
 
             //修改标识
-            $userModel::where('id', $this->auth->id)->update(['is_super'=> $userModel::NewPeo]);
+            $userModel::where('id', $user->id)->update(['is_super'=> $userModel::NewPeo]);
             Db::commit();
         } catch (\Exception $e) {
             Db::rollback();
@@ -67,31 +69,32 @@ class Airdrop extends Api
     public function setSuperWeal(UserWelfare $userWelfare, UserModel $userModel, ProductOrder $productOrder, LedgerWalletModel $ledgerWalletModel)
     {
         $row = $userWelfare::getIsWelfare();
+        $user = $userModel->getById($this->request->post('uid')); //测试用户
         if(empty($row->is_super)) $this->error(__('暂未开启'));
-        if($this->auth->is_super != $userModel::NewPeo) $this->error(__('您已领取'));
+        if($user->is_super != $userModel::NewPeo) $this->error(__('您已领取'));
 
         //判断距离领取新人福利是否超过一天
-        $info = $productOrder::getUserWelfare($this->auth->id, $productOrder::Newbie);
+        $info = $productOrder::getUserWelfare($user->id, $productOrder::Newbie);
         if((time()-$info->create_time) >= config('super_weal_end_time')) $this->error(__('您已过期'));
         Db::startTrans();
         try {
             
             //把9.9茶宝转入冻结账号
-            if($row->frozen > 0) $ledgerWalletModel->setChangeFrozen($this->auth->id, $row->frozen, LedgerFrozenChangeModel::Super, '+');
+            if($row->frozen > 0) $ledgerWalletModel->setChangeFrozen($user->id, $row->frozen, LedgerFrozenChangeModel::Super, '+');
             
             //添加Rwa茶记录
-            $result = WelfareLoginc::setUserWelfareLos($this->auth->id, $row->super_product_id, $row->super_num, time(), $this->lan, $productOrder::Super);
+            $result = WelfareLoginc::setUserWelfareLos($user->id, $row->super_product_id, $row->super_num, time(), $this->lan, $productOrder::Super);
 
             //添加超级福利标识/上级
-            $userModel::updateUserLevel($this->auth->id, $this->auth->parent_id, $this->auth->address_level);
+            $userModel::updateUserLevel($user->id, $user->parent_id, $user->address_level);
 
             //插入待空投记录
             $rs = UserAirdrop::insert([
-                'user_id'       =>  $this->auth->id,
+                'user_id'       =>  $user->id,
                 'type_id'       =>  UserAirdrop::TypeSuperWeal,
                 'product_id'    =>  $row->super_product_id,
                 'num'           =>  $row->super_num,
-                'address'       =>  $this->auth->address,
+                'address'       =>  $user->address,
                 'remark'        =>  '超级福利空投',
                 'create_time'   =>time(),
                 'status'        =>UserAirdrop::Normal,//为0 待发放层级奖励