优化推送统一订单信息-playxId修改为用户名
This commit is contained in:
@@ -74,10 +74,18 @@ class Order extends Backend
|
||||
|
||||
[$where, $alias, $limit, $order] = $this->queryBuilder();
|
||||
$res = $this->model
|
||||
->with(['mallItem' => function ($query) {
|
||||
$query->field('id,title');
|
||||
}])
|
||||
->visible(['mallItem' => ['title']])
|
||||
->with([
|
||||
'mallItem' => function ($query) {
|
||||
$query->field('id,title');
|
||||
},
|
||||
'mallUserAsset' => function ($query) {
|
||||
$query->field('playx_user_id,username');
|
||||
},
|
||||
])
|
||||
->visible([
|
||||
'mallItem' => ['title'],
|
||||
'mallUserAsset' => ['username'],
|
||||
])
|
||||
->alias($alias)
|
||||
->where($where)
|
||||
->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();
|
||||
if (!$item) {
|
||||
return [
|
||||
@@ -79,7 +87,7 @@ final class MallBonusGrantPush
|
||||
'report_date' => $reportDate,
|
||||
'angpow' => [
|
||||
[
|
||||
'member_login' => strval($asset->playx_user_id),
|
||||
'member_login' => $memberLogin,
|
||||
'start_time' => $start,
|
||||
'end_time' => $end,
|
||||
'amount' => $order->amount,
|
||||
|
||||
@@ -72,5 +72,13 @@ class MallOrder extends Model
|
||||
{
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
$row = $this->buildAngpowRow($order);
|
||||
if ($row === null) {
|
||||
$rowResult = $this->buildAngpowRow($order);
|
||||
if ($rowResult === null) {
|
||||
// 构造失败:直接标为可重试失败
|
||||
$this->markFailedAttempt($order, 'Build payload failed');
|
||||
continue;
|
||||
}
|
||||
$payload['angpow'][] = $row;
|
||||
if (is_string($rowResult)) {
|
||||
$this->markFailedAttempt($order, $rowResult);
|
||||
continue;
|
||||
}
|
||||
$payload['angpow'][] = $rowResult;
|
||||
$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();
|
||||
if (!$asset) {
|
||||
@@ -233,6 +240,11 @@ class AngpowImportJobs
|
||||
return null;
|
||||
}
|
||||
|
||||
$memberLogin = trim(strval($asset->username ?? ''));
|
||||
if ($memberLogin === '') {
|
||||
return 'User username empty';
|
||||
}
|
||||
|
||||
$item = null;
|
||||
if ($order->mallItem) {
|
||||
$item = $order->mallItem;
|
||||
@@ -256,7 +268,7 @@ class AngpowImportJobs
|
||||
$end = gmdate('Y-m-d\TH:i:s\Z', strtotime($order->end_time));
|
||||
|
||||
return [
|
||||
'member_login' => strval($asset->playx_user_id),
|
||||
'member_login' => $memberLogin,
|
||||
'start_time' => $start,
|
||||
'end_time' => $end,
|
||||
'amount' => $order->amount,
|
||||
|
||||
Reference in New Issue
Block a user