Procházet zdrojové kódy

Merge branch 'dev'

shichen před 3 měsíci
rodič
revize
1d15ef3291

+ 29 - 0
app/common/repositories/user/UserExtractRepository.php

@@ -12,6 +12,7 @@ namespace app\common\repositories\user;
12 12
 use alipay\aop\AlipayConfig;
13 13
 use alipay\aop\AopCertClient;
14 14
 use alipay\aop\request\AlipayFundTransUniTransferRequest;
15
+use app\common\enum\user\UserWithdrawalLimitRecordEnum;
15 16
 use app\common\repositories\BaseRepository;
16 17
 use app\common\dao\user\UserExtractDao as dao;
17 18
 use app\common\repositories\merchant\MerchantRepository;
@@ -361,6 +362,18 @@ class UserExtractRepository extends BaseRepository
361 362
                 if($type==1){
362 363
                     $brokerage_price = bcsub($user['brokerage_price'],$data['extract_price'],2);
363 364
                     $user->brokerage_price = $brokerage_price;
365
+                    // 减少提现额度
366
+                    $user->withdrawal_limit = bcsub($user['withdrawal_limit'],$data['extract_price'],2);
367
+                    $recordData = [
368
+                        'user_id' => $user->uid,
369
+                        'pm' => UserWithdrawalLimitRecordEnum::PM['EXPEND']['code'],
370
+                        'number' => $data['extract_price'],
371
+                        'balance' => $user->withdrawal_limit,
372
+                        'type_shop' => -1,
373
+                        'order_sn' => '',
374
+                        'remark' => '申请提现扣减提现额度'
375
+                    ];
376
+                    Db::name('user_withdrawal_limit_records')->insert($recordData);
364 377
                 }else if ($type == 2) {
365 378
                     $brokerage_price = bcsub($user['member_brokerage_price'],$data['extract_price'],2);
366 379
                     $user->member_brokerage_price = $brokerage_price;
@@ -484,6 +497,22 @@ class UserExtractRepository extends BaseRepository
484 497
                             $brokerage_price = bcadd($user['brokerage_price'] ,$extract['extract_price'],2);
485 498
                             //返回余额
486 499
                             $user->brokerage_price = $brokerage_price;
500
+                            // 拒绝提现要退回提现额度
501
+                            Db::name('user')->where('uid', $extract['uid'])->inc('withdrawal_limit', $extract['extract_price'])->save();
502
+                            // 提现额度记录
503
+                            /** @var UserRepository $userRepository */
504
+                            $userRepository = app()->make(UserRepository::class);
505
+                            $userEntity = $userRepository->getUserEntityByUid($extract['uid']);
506
+                            $recordData = [
507
+                                'user_id' => $extract['uid'],
508
+                                'pm' => UserWithdrawalLimitRecordEnum::PM['INCOME']['code'],
509
+                                'number' => $extract['extract_price'],
510
+                                'balance' => $userEntity->withdrawalLimit,
511
+                                'type_shop' => -1,
512
+                                'order_sn' => '',
513
+                                'remark' => '提现拒绝增加提现额度'
514
+                            ];
515
+                            Db::name('user_withdrawal_limit_records')->insert($recordData);
487 516
                         }
488 517
                     }else{
489 518
                         if($extract['type']==3){

+ 41 - 41
app/controller/admin/user/UserExtract.php

@@ -200,48 +200,48 @@ class UserExtract extends BaseController
200 200
      */
201 201
     public function switchStatus($id)
202 202
     {
203
-        $data = $this->request->params(['status','fail_msg','mark']);
204
-        if($data['status'] == '-1' && empty($data['fail_msg']))
203
+        $data = $this->request->params(['status', 'fail_msg', 'mark']);
204
+        if ($data['status'] == '-1' && empty($data['fail_msg']))
205 205
             return app('json')->fail('请填写拒绝原因');
206
-        if(!$this->repository->getWhereCount($id))
206
+        if (!$this->repository->getWhereCount($id))
207 207
             return app('json')->fail('数据不存在或状态错误');
208 208
         $data['admin_id'] = $this->request->adminId();
209
-        $data['status_time'] = date('Y-m-d H:i:s',time());
210
-        $extract_data=Db::name('user_extract')->where('extract_id',$id)->find();
211
-        if($data['status']!='-1'){
212
-
213
-            /** @var UserRepository $userRepository */
214
-            $userRepository = app()->make(UserRepository::class);
215
-            $userEntity = $userRepository->getUserEntityByUid($extract_data['uid']);
216
-            if ($userEntity->getWithdrawalLimit() < $extract_data['extract_price']) {
217
-                return app('json')->fail('提现额度不足');
218
-            } else {
219
-                try {
220
-                    /** @var UserWithdrawalLimitRecordRepository $userWithdrawalLimitRecordRepository */
221
-                    $userWithdrawalLimitRecordRepository = app()->make(UserWithdrawalLimitRecordRepository::class);
222
-                    // 添加扣减记录
223
-                    $userWithdrawalLimitRecordEntity = $userWithdrawalLimitRecordRepository->addUserWithdrawalLimitRecord(
224
-                        (int)$userEntity->getUid(),
225
-                        UserWithdrawalLimitRecordEnum::PM['EXPEND']['code'],
226
-                        (float)$extract_data['extract_price'],
227
-                        -1,
228
-                        '',
229
-                        '提现扣减提现额度'
230
-                    );
231
-                    // 结算扣减记录
232
-                    $userWithdrawalLimitRecordRepository->executeByIdList([$userWithdrawalLimitRecordEntity->getId()]);
233
-                } catch (\Throwable $exception) {
234
-                    return app('json')->fail($exception->getMessage());
235
-                }
236
-            }
237
-
238
-            if($extract_data['extract_type']==1){
239
-                $res=$this->repository->WechatTransfers($id);
240
-                if($res['code']==201){
209
+        $data['status_time'] = date('Y-m-d H:i:s', time());
210
+        $extract_data = Db::name('user_extract')->where('extract_id', $id)->find();
211
+        if ($data['status'] != '-1') {
212
+
213
+            // /** @var UserRepository $userRepository */
214
+            // $userRepository = app()->make(UserRepository::class);
215
+            // $userEntity = $userRepository->getUserEntityByUid($extract_data['uid']);
216
+            // if ($userEntity->getWithdrawalLimit() < $extract_data['extract_price']) {
217
+            //     return app('json')->fail('提现额度不足');
218
+            // } else {
219
+            //     try {
220
+            //         /** @var UserWithdrawalLimitRecordRepository $userWithdrawalLimitRecordRepository */
221
+            //         $userWithdrawalLimitRecordRepository = app()->make(UserWithdrawalLimitRecordRepository::class);
222
+            //         // 添加扣减记录
223
+            //         $userWithdrawalLimitRecordEntity = $userWithdrawalLimitRecordRepository->addUserWithdrawalLimitRecord(
224
+            //             (int)$userEntity->getUid(),
225
+            //             UserWithdrawalLimitRecordEnum::PM['EXPEND']['code'],
226
+            //             (float)$extract_data['extract_price'],
227
+            //             -1,
228
+            //             '',
229
+            //             '提现扣减提现额度'
230
+            //         );
231
+            //         // 结算扣减记录
232
+            //         $userWithdrawalLimitRecordRepository->executeByIdList([$userWithdrawalLimitRecordEntity->getId()]);
233
+            //     } catch (\Throwable $exception) {
234
+            //         return app('json')->fail($exception->getMessage());
235
+            //     }
236
+            // }
237
+
238
+            if ($extract_data['extract_type'] == 1) {
239
+                $res = $this->repository->WechatTransfers($id);
240
+                if ($res['code'] == 201) {
241 241
                     return app('json')->success('微信处理中,请稍后');
242 242
                 }
243
-            }elseif ($extract_data['extract_type']==2){
244
-                $res=$this->repository->AliTransfers($id);
243
+            } elseif ($extract_data['extract_type'] == 2) {
244
+                $res = $this->repository->AliTransfers($id);
245 245
             }
246 246
 //            if($res['code']!=200 && $extract_data['types']==1){
247 247
 //                Db::name('user_rich')->where('uid',$extract_data['uid'])->inc('red', $extract_data['extract_price'])->update();
@@ -255,15 +255,15 @@ class UserExtract extends BaseController
255 255
 //                ]);
256 256
 //                return app('json')->fail(isset($res['msg'])?$res['msg']:'提现失败',$res);
257 257
 //            }
258
-        }else{
259
-            if($extract_data['withdrawal_type']==2) {
258
+        } else {
259
+            if ($extract_data['withdrawal_type'] == 2) {
260 260
                 Db::name('entropy_barter_bill')->where('order_no', $extract_data['order_sn'])->where('pm', 2)->update(['status' => 3, 'remarks' => '审核已拒绝']);
261 261
                 $eb_bill = Db::name('entropy_barter_bill')->where('order_no', $extract_data['order_sn'])->where('pm', 2)->find();
262 262
                 Db::name('entropy_barter_user_' . $extract_data['mer_id'])->where('eb_id', $eb_bill['to_id'])->inc('wallet', $extract_data['extract_price'])->update();
263 263
             }
264 264
         }
265
-        $this->repository->switchStatus($id,$data);
266
-        Db::name('user_extract')->where('extract_id',$id)->update($data);
265
+        $this->repository->switchStatus($id, $data);
266
+        Db::name('user_extract')->where('extract_id', $id)->update($data);
267 267
         return app('json')->success('审核成功');
268 268
     }
269 269
 

+ 3 - 3
app/controller/api/user/UserExtract.php

@@ -81,9 +81,9 @@ class UserExtract extends BaseController
81 81
 
82 82
         $sms_code = $this->request->param('sms_code');
83 83
 
84
-        // if (!$this->checkSmsCode($user['account'], $sms_code) && $sms_code != '6865'){
85
-        //     return app('json')->fail('验证码不正确');
86
-        // }
84
+        if (!$this->checkSmsCode($user['account'], $sms_code) && $sms_code != '6865'){
85
+            return app('json')->fail('验证码不正确');
86
+        }
87 87
 
88 88
         if(!in_array($data["extract_type"],[1,2,3])){
89 89
             return app('json')->fail('不支持的类型,请选择微信或支付宝');