Просмотр исходного кода

平台后台-财务操作-用户提现,当用户提现时减少用户的可提现额度

sunxbiao месяцев назад: 5
Родитель
Сommit
1cef81f474
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      app/controller/admin/user/UserExtract.php

+ 12 - 0
app/controller/admin/user/UserExtract.php

@@ -9,6 +9,7 @@
9 9
  */
10 10
 namespace app\controller\admin\user;
11 11
 
12
+use app\common\repositories\user\UserRepository;
12 13
 use crmeb\basic\BaseController;
13 14
 use crmeb\services\SpreadsheetExcelService;
14 15
 use think\App;
@@ -158,6 +159,17 @@ class UserExtract extends BaseController
158 159
         $data['status_time'] = date('Y-m-d H:i:s',time());
159 160
         $extract_data=Db::name('user_extract')->where('extract_id',$id)->find();
160 161
         if($data['status']!='-1'){
162
+
163
+            /** @var UserRepository $userRepository */
164
+            $userRepository = app()->make(UserRepository::class);
165
+            $userEntity = $userRepository->getUserEntityByUid($extract_data['uid']);
166
+            if ($userEntity->getWithdrawalLimit() < $extract_data['extract_price']) {
167
+                return app('json')->fail('提现额度不足');
168
+            } else {
169
+                $withdrawalLimit = bcsub($userEntity->getWithdrawalLimit(), $extract_data['extract_price'], 2);
170
+                $userRepository->update($userEntity->getUid(), ['withdrawal_limit' => $withdrawalLimit]);
171
+            }
172
+
161 173
             if($extract_data['extract_type']==1){
162 174
                 $res=$this->repository->WechatTransfers($id);
163 175
                 if($res['code']==201){