优化推送统一订单信息-playxId修改为用户名
This commit is contained in:
@@ -74,10 +74,18 @@ class Order extends Backend
|
|||||||
|
|
||||||
[$where, $alias, $limit, $order] = $this->queryBuilder();
|
[$where, $alias, $limit, $order] = $this->queryBuilder();
|
||||||
$res = $this->model
|
$res = $this->model
|
||||||
->with(['mallItem' => function ($query) {
|
->with([
|
||||||
|
'mallItem' => function ($query) {
|
||||||
$query->field('id,title');
|
$query->field('id,title');
|
||||||
}])
|
},
|
||||||
->visible(['mallItem' => ['title']])
|
'mallUserAsset' => function ($query) {
|
||||||
|
$query->field('playx_user_id,username');
|
||||||
|
},
|
||||||
|
])
|
||||||
|
->visible([
|
||||||
|
'mallItem' => ['title'],
|
||||||
|
'mallUserAsset' => ['username'],
|
||||||
|
])
|
||||||
->alias($alias)
|
->alias($alias)
|
||||||
->where($where)
|
->where($where)
|
||||||
->order($order)
|
->order($order)
|
||||||
|
|||||||
@@ -49,6 +49,14 @@ final class MallBonusGrantPush
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$memberLogin = trim(strval($asset->username ?? ''));
|
||||||
|
if ($memberLogin === '') {
|
||||||
|
return [
|
||||||
|
'ok' => false,
|
||||||
|
'message' => 'User username empty',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$item = MallItem::where('id', $order->mall_item_id)->find();
|
$item = MallItem::where('id', $order->mall_item_id)->find();
|
||||||
if (!$item) {
|
if (!$item) {
|
||||||
return [
|
return [
|
||||||
@@ -79,7 +87,7 @@ final class MallBonusGrantPush
|
|||||||
'report_date' => $reportDate,
|
'report_date' => $reportDate,
|
||||||
'angpow' => [
|
'angpow' => [
|
||||||
[
|
[
|
||||||
'member_login' => strval($asset->playx_user_id),
|
'member_login' => $memberLogin,
|
||||||
'start_time' => $start,
|
'start_time' => $start,
|
||||||
'end_time' => $end,
|
'end_time' => $end,
|
||||||
'amount' => $order->amount,
|
'amount' => $order->amount,
|
||||||
|
|||||||
@@ -72,5 +72,13 @@ class MallOrder extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(MallAddress::class, 'mall_address_id', 'id');
|
return $this->belongsTo(MallAddress::class, 'mall_address_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单 user_id 存 playX 侧用户标识字符串,与 mall_user_asset.playx_user_id 对齐。
|
||||||
|
*/
|
||||||
|
public function mallUserAsset(): \think\model\relation\BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(MallUserAsset::class, 'user_id', 'playx_user_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,13 +125,17 @@ class AngpowImportJobs
|
|||||||
if (!$order instanceof MallOrder) {
|
if (!$order instanceof MallOrder) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$row = $this->buildAngpowRow($order);
|
$rowResult = $this->buildAngpowRow($order);
|
||||||
if ($row === null) {
|
if ($rowResult === null) {
|
||||||
// 构造失败:直接标为可重试失败
|
// 构造失败:直接标为可重试失败
|
||||||
$this->markFailedAttempt($order, 'Build payload failed');
|
$this->markFailedAttempt($order, 'Build payload failed');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$payload['angpow'][] = $row;
|
if (is_string($rowResult)) {
|
||||||
|
$this->markFailedAttempt($order, $rowResult);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$payload['angpow'][] = $rowResult;
|
||||||
$orderIds[] = $order->id;
|
$orderIds[] = $order->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +222,10 @@ class AngpowImportJobs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildAngpowRow(MallOrder $order): ?array
|
/**
|
||||||
|
* @return array<string, mixed>|string|null 成功返回行数组;用户名缺失返回错误文案字符串;其它构造失败返回 null
|
||||||
|
*/
|
||||||
|
private function buildAngpowRow(MallOrder $order): array|string|null
|
||||||
{
|
{
|
||||||
$asset = MallUserAsset::where('playx_user_id', $order->user_id)->find();
|
$asset = MallUserAsset::where('playx_user_id', $order->user_id)->find();
|
||||||
if (!$asset) {
|
if (!$asset) {
|
||||||
@@ -233,6 +240,11 @@ class AngpowImportJobs
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$memberLogin = trim(strval($asset->username ?? ''));
|
||||||
|
if ($memberLogin === '') {
|
||||||
|
return 'User username empty';
|
||||||
|
}
|
||||||
|
|
||||||
$item = null;
|
$item = null;
|
||||||
if ($order->mallItem) {
|
if ($order->mallItem) {
|
||||||
$item = $order->mallItem;
|
$item = $order->mallItem;
|
||||||
@@ -256,7 +268,7 @@ class AngpowImportJobs
|
|||||||
$end = gmdate('Y-m-d\TH:i:s\Z', strtotime($order->end_time));
|
$end = gmdate('Y-m-d\TH:i:s\Z', strtotime($order->end_time));
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'member_login' => strval($asset->playx_user_id),
|
'member_login' => $memberLogin,
|
||||||
'start_time' => $start,
|
'start_time' => $start,
|
||||||
'end_time' => $end,
|
'end_time' => $end,
|
||||||
'amount' => $order->amount,
|
'amount' => $order->amount,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ export default {
|
|||||||
manual_retry: 'Retry grant',
|
manual_retry: 'Retry grant',
|
||||||
retry_confirm: 'Queue this order for grant retry?',
|
retry_confirm: 'Queue this order for grant retry?',
|
||||||
id: 'Order ID',
|
id: 'Order ID',
|
||||||
user_id: 'User ID',
|
user_id: 'Username',
|
||||||
type: 'Type',
|
type: 'Type',
|
||||||
'type BONUS': 'Bonus',
|
'type BONUS': 'Bonus',
|
||||||
'type PHYSICAL': 'Physical',
|
'type PHYSICAL': 'Physical',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ export default {
|
|||||||
manual_retry: '手动重试',
|
manual_retry: '手动重试',
|
||||||
retry_confirm: '确认将该订单加入重试队列?',
|
retry_confirm: '确认将该订单加入重试队列?',
|
||||||
id: 'ID',
|
id: 'ID',
|
||||||
user_id: 'playX-ID',
|
user_id: '用户名',
|
||||||
type: '类型',
|
type: '类型',
|
||||||
'type BONUS': '红利(BONUS)',
|
'type BONUS': '红利(BONUS)',
|
||||||
'type PHYSICAL': '实物(PHYSICAL)',
|
'type PHYSICAL': '实物(PHYSICAL)',
|
||||||
|
|||||||
@@ -60,6 +60,17 @@ const baTable = new baTableClass(
|
|||||||
operatorPlaceholder: t('Fuzzy query'),
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
sortable: false,
|
sortable: false,
|
||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
|
formatter: (row: TableRow, _column: TableColumn, cellValue: string) => {
|
||||||
|
const r = row as Record<string, unknown>
|
||||||
|
const rel = r.mallUserAsset ?? r.mall_user_asset
|
||||||
|
if (rel && typeof rel === 'object' && 'username' in rel) {
|
||||||
|
const u = (rel as { username?: unknown }).username
|
||||||
|
if (typeof u === 'string' && u.trim() !== '') {
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (cellValue ?? row.user_id ?? '').toString()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('mall.order.type'),
|
label: t('mall.order.type'),
|
||||||
|
|||||||
Reference in New Issue
Block a user