|
|
@@ -19,6 +19,7 @@ use think\Env;
|
|
|
use think\exception\DbException;
|
|
|
use think\Model;
|
|
|
use app\api\controller\Offline as OfflineApi;
|
|
|
+use think\Lang;
|
|
|
use think\response\Json;
|
|
|
|
|
|
/**
|
|
|
@@ -129,37 +130,22 @@ class OfflineWithdraw extends Backend
|
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
$row->validateFailException()->validate($validate);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$approved = in_array($params['status'], [WithdrawStatus::StatusApprove, WithdrawStatus::StatusManual]); // true:通过 false:拒绝 $params['status'] ==
|
|
|
+
|
|
|
$update = [
|
|
|
'status' => $params['status'],
|
|
|
'tx_hash' => $approved ? $params['tx_hash'] : $row['tx_hash'],
|
|
|
'update_time' => time(),
|
|
|
];
|
|
|
|
|
|
- //自动动打款调用接口
|
|
|
- if ($params['status'] == WithdrawStatus::StatusApprove) {
|
|
|
- if($row['symbol'] != 'usdt'){
|
|
|
- throw new Exception("自动打款只支持USDT提现订单");
|
|
|
- }
|
|
|
- //(new OfflineWithdrawRecordModel())->where('id', $row->id)->update(['status' => 1]);
|
|
|
- $req = (new MyBscApi())->createWithdraw($row->id);
|
|
|
- //$req = (new KangApi())->createWithdraw($row->id);
|
|
|
- if ($req['code'] == 0){
|
|
|
- throw new Exception("打款失败:" . $req['msg']);
|
|
|
- }
|
|
|
- $update['status'] = OfflineWithdrawRecordModel::StatusConfirm;
|
|
|
- }
|
|
|
-
|
|
|
// 仅处理"待处理"状态的订单,"已抢单"的暂不处理
|
|
|
$result = (new OfflineWithdrawRecordModel())->where('id', $row['id'])->where('status', OfflineWithdrawRecordModel::StatusDefault)->update($update);
|
|
|
- if (empty($result)) {
|
|
|
- throw new Exception("修改订单状态失败");
|
|
|
- }
|
|
|
-
|
|
|
+ if (empty($result)) throw new Exception("修改订单状态失败");
|
|
|
+
|
|
|
// 拒绝时,将提交的金额退回到用户余额里
|
|
|
if ($params['status'] == OfflineWithdrawRecordModel::StatusReturn) {
|
|
|
- (new LedgerWalletModel())->changeWalletAccount($row['user_id'], Asset::USDT, $row['amount'], Action::UsdtWithdrawReturn);
|
|
|
+ (new LedgerWalletModel())->changeWalletAccount($row['user_id'], Asset::TOKEN, $row['amount'], LedgerWalletModel::Return);
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|