优化同意订单页面和推送订单到playx的功能
This commit is contained in:
@@ -1016,6 +1016,7 @@ class Playx extends Api
|
||||
'receiver_name' => $snapshot['receiver_name'],
|
||||
'receiver_phone' => $snapshot['receiver_phone'],
|
||||
'receiver_address' => $snapshot['receiver_address'],
|
||||
'grant_status' => MallOrder::GRANT_NOT_APPLICABLE,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
@@ -1082,7 +1083,7 @@ class Playx extends Api
|
||||
'amount' => $amount,
|
||||
'multiplier' => $multiplier,
|
||||
'external_transaction_id' => $orderNo,
|
||||
'grant_status' => MallOrder::GRANT_NOT_SENT,
|
||||
'grant_status' => MallOrder::GRANT_NOT_APPLICABLE,
|
||||
'create_time' => time(),
|
||||
'update_time' => time(),
|
||||
]);
|
||||
@@ -1093,11 +1094,6 @@ class Playx extends Api
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
|
||||
$baseUrl = config('playx.api.base_url', '');
|
||||
if ($baseUrl !== '') {
|
||||
$this->callPlayxBalanceCredit($order, $playxUserId);
|
||||
}
|
||||
|
||||
return $this->success(__('Withdraw submitted, please wait about 10 minutes'), [
|
||||
'order_id' => $order->id,
|
||||
'status' => 'PENDING',
|
||||
@@ -1143,39 +1139,4 @@ class Playx extends Api
|
||||
}
|
||||
}
|
||||
|
||||
private function callPlayxBalanceCredit(MallOrder $order, string $userId): void
|
||||
{
|
||||
$baseUrl = rtrim(config('playx.api.base_url', ''), '/');
|
||||
$url = config('playx.api.balance_credit_url', '/api/v1/balance/credit');
|
||||
if ($baseUrl === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['timeout' => 15]);
|
||||
$res = $client->post($baseUrl . $url, [
|
||||
'json' => [
|
||||
'request_id' => 'mall_withdraw_' . uniqid(),
|
||||
'externalTransactionId' => $order->external_transaction_id,
|
||||
'user_id' => $userId,
|
||||
'amount' => $order->amount,
|
||||
'multiplier' => $order->multiplier,
|
||||
],
|
||||
]);
|
||||
$data = json_decode(strval($res->getBody()), true);
|
||||
if ($res->getStatusCode() === 200 && ($data['status'] ?? '') === 'accepted') {
|
||||
$order->playx_transaction_id = $data['playx_transaction_id'] ?? '';
|
||||
$order->grant_status = MallOrder::GRANT_ACCEPTED;
|
||||
$order->save();
|
||||
} else {
|
||||
$order->grant_status = MallOrder::GRANT_FAILED_RETRYABLE;
|
||||
$order->fail_reason = $data['message'] ?? 'unknown';
|
||||
$order->save();
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$order->grant_status = MallOrder::GRANT_FAILED_RETRYABLE;
|
||||
$order->fail_reason = $e->getMessage();
|
||||
$order->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user