添加红包使用记录和获取记录
This commit is contained in:
parent
68eaa416bf
commit
7c743c780f
@ -306,11 +306,11 @@ class StoreCouponUserDao extends BaseDao
|
|||||||
$totalAmount = reset_index($totalAmount, 'coupon_type');
|
$totalAmount = reset_index($totalAmount, 'coupon_type');
|
||||||
$result = [
|
$result = [
|
||||||
[
|
[
|
||||||
'coupon_type' => 1,
|
'coupon_type' => StoreCouponRepository::TYPE_STORE_COUPON,
|
||||||
'total_amount' => 0.00
|
'total_amount' => 0.00
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'coupon_type' => 2,
|
'coupon_type' => StoreCouponRepository::TYPE_PLATFORM_CARD,
|
||||||
'total_amount' => 0.00
|
'total_amount' => 0.00
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@ -325,12 +325,36 @@ class StoreCouponUserDao extends BaseDao
|
|||||||
|
|
||||||
public function record($userId, $type, $page, $limit)
|
public function record($userId, $type, $page, $limit)
|
||||||
{
|
{
|
||||||
|
$totalAmount = StoreCouponUser::where('uid', $userId)
|
||||||
|
->where('type', $type)
|
||||||
|
->where('status', StoreCouponUserRepository::STATUS_UNUSED)
|
||||||
|
->sum('coupon_price');
|
||||||
|
$query = StoreCouponDetail::field('order_id,create_time,amount coupon_price,pay_price')
|
||||||
|
->where('uid', $userId)
|
||||||
|
->where('type', StoreCouponDetail::TYPE_INCOME);
|
||||||
|
$count = $query->count();
|
||||||
|
$record = $query->page($page)->limit($limit)->select()->toArray();
|
||||||
|
foreach ($record as &$item) {
|
||||||
|
$item['order_amount'] = bcadd($item['coupon_price'], $item['pay_price'], 2);
|
||||||
|
}
|
||||||
|
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function useRecord($userId, $type, $page, $limit)
|
public function useRecord($userId, $type, $page, $limit)
|
||||||
{
|
{
|
||||||
|
$totalAmount = StoreCouponUser::where('uid', $userId)
|
||||||
|
->where('type', $type)
|
||||||
|
->where('status', StoreCouponUserRepository::STATUS_UNUSED)
|
||||||
|
->sum('coupon_price');
|
||||||
|
$query = StoreCouponDetail::field('order_id,create_time,amount coupon_price,pay_price')
|
||||||
|
->where('uid', $userId)
|
||||||
|
->where('type', StoreCouponDetail::TYPE_EXPEND);
|
||||||
|
$count = $query->count();
|
||||||
|
$record = $query->page($page)->limit($limit)->select()->toArray();
|
||||||
|
foreach ($record as &$item) {
|
||||||
|
$item['order_amount'] = bcadd($item['coupon_price'], $item['pay_price'], 2);
|
||||||
|
}
|
||||||
|
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user