lan = $this->request->getLan(); } //获取领取福利信息 public function getNewbieWeal(UserWelfare $userWelfare, ProductOrder $productOrder) { $info = $productOrder::getUserWelfare($this->auth->id, $productOrder::Newbie); $endTime = isset($info->create_time)? bcadd($info->create_time, config('super_weal_end_time')): 0; $rows = $userWelfare::getIsWelfare(); $this->success('', ['is_super'=>$this->auth->is_super, 'end_time'=>$endTime, 'chabao'=>$rows->frozen]); } //新人福利 public function setNewbieWeal(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->new_product_id, $row->new_num, time(), $this->lan, $productOrder::Newbie); //修改标识 $userModel::where('id', $this->auth->id)->update(['is_super'=> $userModel::NewPeo]); Db::commit(); } catch (\Exception $e) { Db::rollback(); $this->error($e->getMessage()); } $this->success('', $result); } //超级福利 public function setSuperWeal(UserWelfare $userWelfare, UserModel $userModel, ProductOrder $productOrder, LedgerWalletModel $ledgerWalletModel) { $row = $userWelfare::getIsWelfare(); if(empty($row->is_super)) $this->error(__('暂未开启')); if($this->auth->is_super != $userModel::NewPeo) $this->error(__('您已领取')); //判断距离领取新人福利是否超过一天 $info = $productOrder::getUserWelfare($this->auth->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, LedgerTokenChangeModel::Super, '+'); //添加Rwa茶记录 WelfareLoginc::setUserWelfareLos($this->auth->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); //插入待空投记录 $result = UserAirdrop::insert([ 'user_id' => $this->auth->id, 'type_id' => UserAirdrop::TypeSuperWeal, 'product_id' => $row->super_product_id, 'num' => $row->super_num, 'address' => $this->auth->address, 'remark' => '超级福利空投', 'create_time' =>time(), 'status' =>UserAirdrop::Normal,//为0 待发放层级奖励 ]); Db::commit(); } catch (\Exception $e) { Db::rollback(); $this->error($e->getMessage()); } $this->success('', $result); } }