调整用户红包记录

This commit is contained in:
lewis 2024-01-21 21:16:33 +08:00
parent 32ebe6ce1c
commit 6026efc4df
4 changed files with 25 additions and 5 deletions

View File

@ -183,13 +183,19 @@ class StoreActivityUserDao extends BaseDao
->whereIn('type', $type)
->where('status', StoreConsumptionUser::STATUS_UNUSED)
->sum('balance');
$query = UserBill::with('storeConsumptionUser')
->field('link_id,create_time')
$query = UserBill::field('link_id,create_time,number coupon_price,mark')
->where('uid', $userId)
->where('category', 'red_pack')
->where('type', "red_pack_{$type}");
$count = $query->count();
$record = $query->page($page)->limit($limit)->select()->toArray();
foreach ($record as &$item) {
$item['order_amount'] = 0;
if (mb_strpos($item['mark'], '订单金额:') !== false) {
$item['order_amount'] = mb_substr($item['mark'], mb_strpos($item['mark'], '订单金额:') + 5);
}
unset($item['mark']);
}
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
}
@ -206,10 +212,24 @@ class StoreActivityUserDao extends BaseDao
->field('SUM(balance) as total_amount,type')
->group('type')
->select()->toArray();
foreach ($totalAmount as &$item) {
$totalAmount = reset_index($totalAmount, 'type');
$result = [
[
'type' => 1,
'total_amount' => 0.00
],
[
'type' => 2,
'total_amount' => 0.00
]
];
foreach ($result as &$item) {
if (isset($totalAmount[$item['type']])) {
$item['total_amount'] = $totalAmount[$item['type']]['total_amount'];
}
$item['type_cn'] = StoreConsumptionUser::TYPE_MAP[$item['type']];
}
return $totalAmount;
return $result;
}
}

View File

@ -230,7 +230,7 @@ class StoreConsumptionUserDao extends BaseDao
'status' => 1,
'title' => '获得' . $title,
'number' => $couponPrice,
'mark' => '获得' . $title . $couponPrice,
'mark' => '获得' . $title . $couponPrice . ",订单金额:{$amount}",
'balance' => 0
]);
}