Jelajahi Sumber

完善后台提现

Jason 1 tahun lalu
induk
melakukan
06efd6a014

+ 6 - 10
application/admin/controller/trade/MoneyOut.php

@@ -9,7 +9,7 @@ use think\exception\DbException;
 use think\exception\PDOException;
 use app\common\controller\Backend;
 use think\exception\ValidateException;
-
+use app\common\model\MoneyOut as MoneyOutModel;
 /**
  * 提现记录管理
  *
@@ -86,16 +86,14 @@ class MoneyOut extends Backend
         $result = false;
         Db::startTrans();
         try {
-
             //余额变动
+            if(!in_array($status, [MoneyOutModel::Success, MoneyOutModel::Reject])){
+                $this->error(__('参数有误'));
+            }
             $amount = $row->amount;
-            $action = MoneyLog::Reject;
-            if($status == $this->model::Success){
-                $amount = $row->real_amount;
-                $action = MoneyLog::Withdraw;
+            if($status == $this->model::Reject){
+                (new MoneyLog())->change($row->user_id, $amount, MoneyLog::Reject, '', '驳回');
             }
-            $action = $status == $this->model::Success? MoneyLog::Withdraw :MoneyLog::Reject;
-            (new MoneyLog())->change($row->user_id, $amount, $action, $row->user_id, '提现');
             $result = $row->allowField(true)->save(['status'=>$status]);
             Db::commit();
         } catch (ValidateException|PDOException|Exception $e) {
@@ -107,6 +105,4 @@ class MoneyOut extends Backend
         }
         $this->success();
     }
-
-
 }

+ 0 - 2
application/admin/lang/zh-cn/trade/money_out.php

@@ -27,6 +27,4 @@ return [
     '假人'          => '假人',
     '通过'          => '通过',
     '驳回'          => '驳回',
-
-    
 ];

+ 13 - 0
application/api/controller/Money.php

@@ -3,7 +3,9 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
+use app\common\model\Config;
 use app\common\model\MoneyIn;
+use app\common\model\MoneyLog;
 use app\common\model\MoneyOut;
 use app\common\model\Users AS UserModel;
 use think\Db;
@@ -226,10 +228,19 @@ class Money extends Api
             $this->error(__('无提现信息'));
         }
 
+        $withdraw_fee = (new Config())->getValue('withdraw_fee');
+        if(empty($withdraw_fee)){
+            $withdraw_fee = 0;
+        }elseif($withdraw_fee > 1){
+            $this->error(__('提现手续费有误'));
+        }
+
         $insert_data = [
             'order_type' => $type,
             'user_id'   => $user['id'],
             'amount'    => $amount,
+            'fee'       => $amount * $withdraw_fee,
+            'real_amount'   => $amount * (1 - $withdraw_fee),
             'status'    => MoneyOut::Pending,
             'agent_id'  => $withdraw_info['agent_id'],
             'user_type' => $user['user_type'],
@@ -272,6 +283,8 @@ class Money extends Api
         Db::startTrans();
         try {
             (new MoneyOut())->save($insert_data);
+            //扣款
+            (new MoneyLog())->change($user['id'], -$amount, MoneyLog::Withdraw, '', '');
             Db::commit();
         } catch (Exception $e) {
             $this->error($e->getMessage());

+ 1 - 1
application/api/controller/User.php

@@ -301,7 +301,7 @@ class User extends Api
             Db::rollback();
             $this->error($e->getMessage());
         }
-       
+
         $this->success('');
     }
     /**

+ 1 - 0
application/api/lang/zh-cn/money.php

@@ -6,4 +6,5 @@ return [
     '完成'                    => '完成',
     '冻结'                    => '冻结',
     '取消'                    => '取消',
+    '提现手续费有误'            => '提现手续费配置有误',
 ];

+ 3 - 2
application/common/model/MoneyLog.php

@@ -84,8 +84,9 @@ class MoneyLog extends Model
         }
 
         //余额
-        $balance = in_array($action, [self::Reject]) ? bcsub($user->balance, $amount, 2) : bcadd($user->balance, $amount, 2);
-        if($balance < 0){
+        $balance = bcadd($user->balance, $amount, 2);
+        //只有支付订单或系统调整的时候,可以余额为负数
+        if(($action != self::Pay || $action != self::SystemChange) && $balance < 0){
             throw new Exception(__('余额不足'));
         }
 

+ 2 - 0
application/common/model/MoneyOut.php

@@ -29,6 +29,7 @@ class MoneyOut extends Model
     const Pending   = 100;
     const Success   = 200;
     const Fail      = 400;
+    const Reject    = 401;
     const Cancel    = 500;
 
     /*
@@ -41,6 +42,7 @@ class MoneyOut extends Model
             self::Pending           => __('待处理'),
             self::Success           => __('完成'),
             self::Fail              => __('失败'),
+            self::Reject            => __('驳回'),
             self::Cancel            => __('取消'),
         ];
         if($type == -1){

+ 9 - 6
application/extra/site.php

@@ -2,10 +2,10 @@
 
 return array (
   'name' => '投标系统',
-  'logo' => '111',
-  'Maintain_switch' => '1',
+  'logo' => 'https://www.estyzl38.com/static/img/gemini.90d29b68.png',
+  'maintain_switch' => '1',
   'day_tasks_num' => '1',
-  'Task_income' => '0.1',
+  'task_income' => '0.1',
   'categorytype' => 
   array (
     'default' => 'Default',
@@ -36,9 +36,12 @@ return array (
   'recharge_usdt_switch' => '1',
   'recharge_usdt_address' => '12',
   'recharge_bank_switch' => '1',
-  'recharge_bank_address' => '322',
+  'recharge_bank_name' => '花旗银行',
   'withdraw_usdt_switch' => '1',
   'withdraw_bank_switch' => '1',
-  'Withdrawal_time' => '15:04:41',
-  'Withdrawal_fee' => '0.2',
+  'withdrawal_time' => '15:04:41',
+  'withdrawal_fee' => '0.2',
+  'recharge_bank_card' => '银行卡号号码',
+  'recharge_real_name' => '开户人姓名',
+  'withdraw_fee' => '0.05',
 );

+ 3 - 2
public/assets/js/backend/trade/money_out.js

@@ -28,6 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                             formatter: Table.api.formatter.status
                         },
                         {field: 'users.mobile', title: __('User_id')},
+                        {field: 'users.balance', title: __('当前余额')},
                         {field: 'usdt_address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                         {field: 'bank_name', title: __('Bank_name'), operate: 'LIKE'},
                         {field: 'bank_card', title: __('Bank_card'), operate: 'LIKE'},
@@ -36,7 +37,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'fee', title: __('Fee'), operate:'BETWEEN'},
                         {field: 'real_amount', title: __('Real_amount'), operate:'BETWEEN'},
                         {field: 'status', title: __("Status"), 
-                            searchList: {100:__('Pending'), 200:__('Success'), 400:__('Fail'), 500:__('Cancel')}, 
+                            searchList: {100:__('Pending'), 200:__('Success'), 400:__('Fail'), 401:__('驳回'), 500:__('Cancel')},
                             formatter: Table.api.formatter.status
                         },
                         {field: 'user_type', title: __("用户类型"), 
@@ -65,7 +66,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 text:  __('驳回'),
                                 classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
                                 confirm: __('Confirm review'),
-                                url: 'trade/money_out/review/status/400',
+                                url: 'trade/money_out/review/status/401',
                                 visible: function (row) {
                                     if(row.status == 100) return true;
                                     return false;