|
|
@@ -26,14 +26,14 @@ class PaymentOrder extends Controller
|
|
|
//人工充值订单
|
|
|
$data['rgRecharge'] = (int)PaymentOrderModel::whereIn('status', [0,1,5])->where('type', 3)->count();
|
|
|
//人民币充值订单
|
|
|
- $data['rgRecharge'] = (int)PaymentOrderModel::whereIn('status', [0,1])->where('type', 1)->count();
|
|
|
+ $data['rmbRecharge'] = (int)PaymentOrderModel::whereIn('status', [0,1])->where('type', 1)->count();
|
|
|
|
|
|
//USDT提现订单
|
|
|
$data['usdtWithdraw'] = (int)Withdraw::where('status', 0)->count();
|
|
|
//人工提现订单
|
|
|
$data['rgWithdraw'] = (int)PaymentOrderModel::where('status', 0)->where('type', 4)->count();
|
|
|
//人民币提现订单
|
|
|
- $data['rgWithdraw'] = (int)PaymentOrderModel::where('status', 0)->where('type', 2)->count();
|
|
|
+ $data['rmbWithdraw'] = (int)PaymentOrderModel::where('status', 0)->where('type', 2)->count();
|
|
|
return $this->success($data);
|
|
|
}
|
|
|
|
|
|
@@ -74,40 +74,44 @@ class PaymentOrder extends Controller
|
|
|
DB::beginTransaction();
|
|
|
try {
|
|
|
$params = request()->validate([
|
|
|
- 'id' => ['required', 'integer'],
|
|
|
+ 'id' => ['required'],
|
|
|
'status' => ['required', 'integer', 'in:2,3'],
|
|
|
'remark' => ['nullable', 'string'],
|
|
|
]);
|
|
|
$remark = $params['remark'] ?? '';
|
|
|
- $info = PaymentOrderModel::find($params['id']);
|
|
|
- if (!$info) throw new Exception('数据不存在', HttpStatus::CUSTOM_ERROR);
|
|
|
- if ($info->status != 5) throw new Exception('用户未提交充值凭证', HttpStatus::CUSTOM_ERROR);
|
|
|
- if ($info->payment_type == 0) throw new Exception('当前订单非人工充值,无法操作', HttpStatus::CUSTOM_ERROR);
|
|
|
- if ($params['status'] == 3) {
|
|
|
- if (empty($remark)) {
|
|
|
- throw new Exception('请填写原因', HttpStatus::CUSTOM_ERROR);
|
|
|
+ $ids = is_array($params['id']) ? $params['id'] : [$params['id']];
|
|
|
+ foreach($ids as $id) {
|
|
|
+ $info = PaymentOrderModel::find($id);
|
|
|
+ if (!$info) throw new Exception('数据不存在', HttpStatus::CUSTOM_ERROR);
|
|
|
+ if ($params['status'] == 2 && $info->status != 5) throw new Exception('用户未提交充值凭证', HttpStatus::CUSTOM_ERROR);
|
|
|
+ if ($params['status'] == 3 && !in_array($info->status, [0,1,4,5])) throw new Exception('订单已完成,不可驳回', HttpStatus::CUSTOM_ERROR);
|
|
|
+ if ($params['status'] == 3) {
|
|
|
+ //驳回
|
|
|
+ if (empty($remark)) {
|
|
|
+ throw new Exception('请填写原因', HttpStatus::CUSTOM_ERROR);
|
|
|
+ }
|
|
|
+ $info->status = $params['status'];
|
|
|
+ $info->remark = $remark;
|
|
|
+ $info->save();
|
|
|
+ } else {
|
|
|
+ //充值成功
|
|
|
+ $info->status = $params['status'];
|
|
|
+ $info->remark = $remark;
|
|
|
+ $info->state = 1;
|
|
|
+ $info->save();
|
|
|
+
|
|
|
+ $memberId = $info->member_id;
|
|
|
+ $amount = $info->amount;
|
|
|
+ $changeType = '人工充值';
|
|
|
+ $wallet = Wallet::where('member_id', $memberId)->first();
|
|
|
+ if (!$wallet) throw new Exception('用户不存在', HttpStatus::CUSTOM_ERROR);
|
|
|
+ $availableBalance = bcadd($wallet->available_balance, $amount, 10);
|
|
|
+ BalanceLogService::addLog($memberId, $amount, $wallet->available_balance, $availableBalance, $changeType, null, $remark);
|
|
|
+ $wallet->available_balance = $availableBalance;
|
|
|
+ $wallet->save();
|
|
|
}
|
|
|
- $info->status = $params['status'];
|
|
|
- $info->remark = $remark;
|
|
|
- $info->save();
|
|
|
- } else {
|
|
|
- //充值成功
|
|
|
- $info->status = $params['status'];
|
|
|
- $info->remark = $remark;
|
|
|
- $info->state = 1;
|
|
|
- $info->save();
|
|
|
-
|
|
|
- $memberId = $info->member_id;
|
|
|
- $amount = $info->amount;
|
|
|
- $changeType = '人工充值';
|
|
|
- $wallet = Wallet::where('member_id', $memberId)->first();
|
|
|
- if (!$wallet) throw new Exception('用户不存在', HttpStatus::CUSTOM_ERROR);
|
|
|
- $availableBalance = bcadd($wallet->available_balance, $amount, 10);
|
|
|
- BalanceLogService::addLog($memberId, $amount, $wallet->available_balance, $availableBalance, $changeType, null, $remark);
|
|
|
- $wallet->available_balance = $availableBalance;
|
|
|
- $wallet->save();
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
DB::commit();
|
|
|
} catch (ValidationException $e) {
|
|
|
DB::rollBack();
|
|
|
@@ -124,6 +128,7 @@ class PaymentOrder extends Controller
|
|
|
{
|
|
|
DB::beginTransaction();
|
|
|
try {
|
|
|
+
|
|
|
$validate = [
|
|
|
'ids' => ['required', 'array', 'min:1', 'max:20'],
|
|
|
'ids.*' => ['required', 'integer', 'min:1'],
|