1.优化后台页面样式
2.优化统一订单中红利的状态和失败原因 3.移除项目中冗余代码和字段
This commit is contained in:
@@ -26,7 +26,7 @@ class Order extends Backend
|
||||
|
||||
protected array $withJoinTable = ['mallItem'];
|
||||
|
||||
protected string|array $quickSearchField = ['user_id', 'external_transaction_id', 'playx_transaction_id'];
|
||||
protected string|array $quickSearchField = ['user_id', 'external_transaction_id'];
|
||||
|
||||
protected string|array $indexField = [
|
||||
'id',
|
||||
@@ -38,7 +38,6 @@ class Order extends Backend
|
||||
'amount',
|
||||
'multiplier',
|
||||
'external_transaction_id',
|
||||
'playx_transaction_id',
|
||||
'grant_status',
|
||||
'fail_reason',
|
||||
'reject_reason',
|
||||
@@ -301,7 +300,7 @@ class Order extends Backend
|
||||
$result = MallBonusGrantPush::push($order);
|
||||
if ($result['ok']) {
|
||||
$order->grant_status = MallOrder::GRANT_ACCEPTED;
|
||||
$order->playx_transaction_id = $result['playx_transaction_id'];
|
||||
$order->status = MallOrder::STATUS_COMPLETED;
|
||||
$order->fail_reason = null;
|
||||
$order->update_time = time();
|
||||
$order->save();
|
||||
|
||||
@@ -100,4 +100,11 @@ return [
|
||||
'PlayX API not configured' => 'PlayX API not configured',
|
||||
'Current grant status cannot be manually pushed' => 'Current grant status cannot be manually pushed',
|
||||
'Order status must be PENDING' => 'Order status must be PENDING',
|
||||
'Missing required fields' => 'Missing required fields',
|
||||
'Order type not PHYSICAL' => 'Order type is not physical goods',
|
||||
'Order type not supported' => 'Order type not supported',
|
||||
'Only BONUS can retry' => 'Only bonus orders can retry push',
|
||||
'Shipped successfully' => 'Shipped successfully',
|
||||
'Approved successfully' => 'Approved successfully',
|
||||
'Rejected successfully' => 'Rejected successfully',
|
||||
];
|
||||
@@ -119,4 +119,11 @@ return [
|
||||
'PlayX API not configured' => 'PlayX 接口未配置',
|
||||
'Current grant status cannot be manually pushed' => '当前发放状态不可手动推送',
|
||||
'Order status must be PENDING' => '订单状态须为处理中',
|
||||
'Missing required fields' => '缺少必填项',
|
||||
'Order type not PHYSICAL' => '订单类型不是实物',
|
||||
'Order type not supported' => '订单类型不支持',
|
||||
'Only BONUS can retry' => '仅红利订单可重试推送',
|
||||
'Shipped successfully' => '发货成功',
|
||||
'Approved successfully' => '审核通过',
|
||||
'Rejected successfully' => '驳回成功',
|
||||
];
|
||||
@@ -1330,7 +1330,6 @@ SQL;
|
||||
]);
|
||||
$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 {
|
||||
|
||||
@@ -15,7 +15,7 @@ use GuzzleHttp\Client;
|
||||
final class MallBonusGrantPush
|
||||
{
|
||||
/**
|
||||
* @return array{ok: bool, message: string, playx_transaction_id: string}
|
||||
* @return array{ok: bool, message: string}
|
||||
*/
|
||||
public static function push(MallOrder $order): array
|
||||
{
|
||||
@@ -24,7 +24,6 @@ final class MallBonusGrantPush
|
||||
return [
|
||||
'ok' => false,
|
||||
'message' => 'PlayX angpow_import not configured',
|
||||
'playx_transaction_id' => '',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -36,7 +35,6 @@ final class MallBonusGrantPush
|
||||
return [
|
||||
'ok' => false,
|
||||
'message' => 'PlayX Angpow Import API not configured',
|
||||
'playx_transaction_id' => '',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -47,7 +45,6 @@ final class MallBonusGrantPush
|
||||
return [
|
||||
'ok' => false,
|
||||
'message' => 'User asset not found',
|
||||
'playx_transaction_id' => '',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -56,7 +53,6 @@ final class MallBonusGrantPush
|
||||
return [
|
||||
'ok' => false,
|
||||
'message' => 'Item not found',
|
||||
'playx_transaction_id' => '',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -67,7 +63,6 @@ final class MallBonusGrantPush
|
||||
return [
|
||||
'ok' => false,
|
||||
'message' => 'Build signature failed',
|
||||
'playx_transaction_id' => '',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -123,20 +118,17 @@ final class MallBonusGrantPush
|
||||
return [
|
||||
'ok' => true,
|
||||
'message' => '',
|
||||
'playx_transaction_id' => '',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'ok' => false,
|
||||
'message' => strval($data['message'] ?? 'PlayX angpow import not accepted'),
|
||||
'playx_transaction_id' => '',
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'message' => $e->getMessage(),
|
||||
'playx_transaction_id' => '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ use support\think\Model;
|
||||
* @property float $amount
|
||||
* @property int $multiplier
|
||||
* @property string $external_transaction_id
|
||||
* @property string $playx_transaction_id
|
||||
* @property string $grant_status
|
||||
* @property string|null $fail_reason
|
||||
* @property int $retry_count
|
||||
|
||||
@@ -198,6 +198,7 @@ class AngpowImportJobs
|
||||
if ($code === '0' || $code === 0) {
|
||||
MallOrder::whereIn('id', $orderIds)->update([
|
||||
'grant_status' => MallOrder::GRANT_ACCEPTED,
|
||||
'status' => MallOrder::STATUS_COMPLETED,
|
||||
'fail_reason' => null,
|
||||
'update_time' => time(),
|
||||
]);
|
||||
@@ -265,6 +266,21 @@ class AngpowImportJobs
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条失败原因压成一行,避免异常信息自带换行导致与 attempt 分段混在一起。
|
||||
*/
|
||||
private function normalizeReasonLine(string $reason): string
|
||||
{
|
||||
$s = trim($reason);
|
||||
if ($s === '') {
|
||||
return '';
|
||||
}
|
||||
$s = str_replace(["\r\n", "\r", "\n"], ' ', $s);
|
||||
$replaced = preg_replace('/\s+/', ' ', $s);
|
||||
|
||||
return is_string($replaced) && $replaced !== '' ? $replaced : $s;
|
||||
}
|
||||
|
||||
private function markFailedAttempt(MallOrder $order, string $reason): void
|
||||
{
|
||||
// retry_count 在“准备发送”阶段已 +1;此处用当前 retry_count 作为 attempt 编号
|
||||
@@ -277,7 +293,7 @@ class AngpowImportJobs
|
||||
|
||||
$prev = $order->fail_reason;
|
||||
$prefix = 'attempt ' . $attempt . ': ';
|
||||
$line = $prefix . $reason;
|
||||
$line = $prefix . $this->normalizeReasonLine($reason);
|
||||
$newReason = $line;
|
||||
if (is_string($prev) && $prev !== '') {
|
||||
$newReason = $prev . "\n" . $line;
|
||||
|
||||
@@ -171,7 +171,8 @@ class PlayxJobs
|
||||
$result = MallBonusGrantPush::push($order);
|
||||
if ($result['ok']) {
|
||||
$order->grant_status = MallOrder::GRANT_ACCEPTED;
|
||||
$order->playx_transaction_id = $result['playx_transaction_id'];
|
||||
$order->status = MallOrder::STATUS_COMPLETED;
|
||||
$order->update_time = time();
|
||||
$order->save();
|
||||
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user