调整用户红包记录
This commit is contained in:
parent
32ebe6ce1c
commit
6026efc4df
@ -183,13 +183,19 @@ class StoreActivityUserDao extends BaseDao
|
|||||||
->whereIn('type', $type)
|
->whereIn('type', $type)
|
||||||
->where('status', StoreConsumptionUser::STATUS_UNUSED)
|
->where('status', StoreConsumptionUser::STATUS_UNUSED)
|
||||||
->sum('balance');
|
->sum('balance');
|
||||||
$query = UserBill::with('storeConsumptionUser')
|
$query = UserBill::field('link_id,create_time,number coupon_price,mark')
|
||||||
->field('link_id,create_time')
|
|
||||||
->where('uid', $userId)
|
->where('uid', $userId)
|
||||||
->where('category', 'red_pack')
|
->where('category', 'red_pack')
|
||||||
->where('type', "red_pack_{$type}");
|
->where('type', "red_pack_{$type}");
|
||||||
$count = $query->count();
|
$count = $query->count();
|
||||||
$record = $query->page($page)->limit($limit)->select()->toArray();
|
$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];
|
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,10 +212,24 @@ class StoreActivityUserDao extends BaseDao
|
|||||||
->field('SUM(balance) as total_amount,type')
|
->field('SUM(balance) as total_amount,type')
|
||||||
->group('type')
|
->group('type')
|
||||||
->select()->toArray();
|
->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']];
|
$item['type_cn'] = StoreConsumptionUser::TYPE_MAP[$item['type']];
|
||||||
}
|
}
|
||||||
return $totalAmount;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ class StoreConsumptionUserDao extends BaseDao
|
|||||||
'status' => 1,
|
'status' => 1,
|
||||||
'title' => '获得' . $title,
|
'title' => '获得' . $title,
|
||||||
'number' => $couponPrice,
|
'number' => $couponPrice,
|
||||||
'mark' => '获得' . $title . $couponPrice,
|
'mark' => '获得' . $title . $couponPrice . ",订单金额:{$amount}",
|
||||||
'balance' => 0
|
'balance' => 0
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user