|
|
@@ -15,11 +15,8 @@ use App\Models\RoomUser;
|
|
|
use App\Models\User;
|
|
|
use App\Models\Wallet;
|
|
|
use App\Models\Withdraw;
|
|
|
-use App\Services\Payment\ZimuPayService;
|
|
|
use Exception;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
-use Illuminate\Support\Facades\DB;
|
|
|
-use Illuminate\Support\Facades\Log;
|
|
|
use LaravelLang\Publisher\Console\Add;
|
|
|
use Telegram\Bot\Api;
|
|
|
use Telegram\Bot\Exceptions\TelegramSDKException;
|
|
|
@@ -645,27 +642,7 @@ class WithdrawService
|
|
|
if (!$w) return 0;
|
|
|
// 汇率
|
|
|
$rate = $w->exchange_rate ?? 1;
|
|
|
- if ($status == 1 && ($w->channel ?? '') === ZimuPayService::CHANNEL_WITHDRAW) {
|
|
|
- $orderNo = $w->order_no ?: PaymentOrderService::createOrderNo('zw_', $w->member_id);
|
|
|
- $ret = ZimuPayService::withdraw($w->to_account, $orderNo, (string)$w->member_id, (string)$w->address);
|
|
|
- Log::channel('payment')->info('ZIMU钱包地址提现接口调用', [
|
|
|
- 'withdraw_id' => $w->id,
|
|
|
- 'order_no' => $orderNo,
|
|
|
- 'member_id' => $w->member_id,
|
|
|
- 'amount' => $w->to_account,
|
|
|
- 'address' => $w->address,
|
|
|
- 'response' => $ret,
|
|
|
- ]);
|
|
|
- if (($ret['code'] ?? -1) != 0) {
|
|
|
- throw new Exception($ret['msg'] ?? 'ZIMU钱包地址提现失败', HttpStatus::CUSTOM_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
- $w->order_no = $orderNo;
|
|
|
- $w->pay_no = $ret['data']['orderNo'] ?? '';
|
|
|
- $w->pay_data = json_encode($ret, JSON_UNESCAPED_UNICODE);
|
|
|
- $w->status = 1;
|
|
|
- $w->save();
|
|
|
- } else if ($status == 1) {
|
|
|
+ if ($status == 1) {
|
|
|
$w->status = 1;
|
|
|
$w->save();
|
|
|
} else if ($status == 2) {
|
|
|
@@ -700,62 +677,6 @@ class WithdrawService
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- public static function receiveZimuWithdraw(array $params): bool
|
|
|
- {
|
|
|
- $withdraw = Withdraw::where('order_no', $params['mchOrderNo'] ?? '')->first();
|
|
|
- if (!$withdraw || ($withdraw->channel ?? '') !== ZimuPayService::CHANNEL_WITHDRAW) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!ZimuPayService::verifyNotify($params)) {
|
|
|
- Log::error('ZIMU钱包地址提现回调验签失败', [
|
|
|
- 'mch_order_no' => $params['mchOrderNo'] ?? '',
|
|
|
- 'signature' => ZimuPayService::notifySignatureDiagnostics($params),
|
|
|
- ]);
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (bccomp(ZimuPayService::amount($withdraw->to_account), ZimuPayService::amount($params['amount'] ?? 0), 2) !== 0) {
|
|
|
- Log::error('ZIMU钱包地址提现回调金额不一致', [
|
|
|
- 'mch_order_no' => $params['mchOrderNo'] ?? '',
|
|
|
- 'order_amount' => $withdraw->to_account,
|
|
|
- 'callback_amount' => $params['amount'] ?? null,
|
|
|
- ]);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- DB::transaction(function () use ($params, $withdraw) {
|
|
|
- $order = Withdraw::where('id', $withdraw->id)->lockForUpdate()->first();
|
|
|
- if (!$order || $order->status == 2) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $order->callback_data = json_encode($params, JSON_UNESCAPED_UNICODE);
|
|
|
- if ((string)$params['status'] === ZimuPayService::WITHDRAW_STATUS_SUCCESS) {
|
|
|
- $order->status = 1;
|
|
|
- $order->save();
|
|
|
- } elseif ((string)$params['status'] === ZimuPayService::WITHDRAW_STATUS_FAIL) {
|
|
|
- if ($order->status != 2) {
|
|
|
- $order->status = 2;
|
|
|
- $order->remark = $params['msg'] ?? 'ZIMU钱包地址提现失败';
|
|
|
- $order->save();
|
|
|
-
|
|
|
- $wallet = Wallet::where('member_id', $order->member_id)->lockForUpdate()->first();
|
|
|
- if ($wallet) {
|
|
|
- $refundAmount = bcmul($order->amount, $order->exchange_rate ?: 1, 2);
|
|
|
- $beforeBalance = $wallet->available_balance;
|
|
|
- $afterBalance = bcadd($beforeBalance, $refundAmount, 10);
|
|
|
- $wallet->available_balance = $afterBalance;
|
|
|
- $wallet->save();
|
|
|
- BalanceLogService::addLog($order->member_id, $refundAmount, $beforeBalance, $afterBalance, '提现', $order->id, 'ZIMU钱包地址提现失败退款');
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- $order->save();
|
|
|
- }
|
|
|
- }, 3);
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
public static function batchReject()
|
|
|
{
|