修改补贴列表
This commit is contained in:
parent
2c07c80bcc
commit
d5a81d6ba4
@ -186,17 +186,41 @@ class Store extends BaseController
|
|||||||
} else {
|
} else {
|
||||||
$couponType = StoreCouponRepository::TYPE_SALE_SUBSIDY;
|
$couponType = StoreCouponRepository::TYPE_SALE_SUBSIDY;
|
||||||
}
|
}
|
||||||
$couponId = StoreCoupon::where('type', $couponType)->value('coupon_id');
|
$coupon = StoreCoupon::where('type', $couponType)->field('coupon_id,config')->find();
|
||||||
$totalAmount = StoreCouponUser::where('uid', $userId)
|
$totalAmount = StoreCouponUser::where('uid', $userId)
|
||||||
->where('coupon_type', StoreCouponRepository::TYPE_STORE_COUPON)
|
->where('coupon_type', StoreCouponRepository::TYPE_STORE_COUPON)
|
||||||
->whereIn('status', [StoreCouponUser::STATUS_UNUSED, StoreCouponUser::STATUS_REPEAL])
|
->whereIn('status', [StoreCouponUser::STATUS_UNUSED, StoreCouponUser::STATUS_REPEAL])
|
||||||
->value('origin_price');
|
->value('origin_price');
|
||||||
|
$totalAmount = empty($totalAmount) ? '0.00' : $totalAmount;
|
||||||
$query = StoreCouponDetail::field('amount coupon_price,create_time,status,send_status,extra')
|
$query = StoreCouponDetail::field('amount coupon_price,create_time,status,send_status,extra')
|
||||||
->where('uid', $userId)
|
->where('uid', $userId)
|
||||||
->where('coupon_id', $couponId)
|
->where('coupon_id', $coupon['coupon_id'])
|
||||||
->where('type', StoreCouponDetail::TYPE_INCOME);
|
->where('type', StoreCouponDetail::TYPE_INCOME);
|
||||||
$count = $query->count();
|
$count = $query->count();
|
||||||
$record = $query->page($page)->limit($limit)->order('id', 'desc')->select()->toArray();
|
$record = $query->page($page)->limit($limit)->order('id', 'desc')->select()->toArray();
|
||||||
|
if (empty($record) && $type == 2) {
|
||||||
|
$merchantTypeId = Merchant::where('mer_id', $this->merId)->value('type_id');
|
||||||
|
$couponPrice = 0;
|
||||||
|
$saleTarget = 0;
|
||||||
|
foreach ($coupon['config'] as $item) {
|
||||||
|
if (!in_array($merchantTypeId, $item['type_id'])) {
|
||||||
|
$couponPrice = $item['subsidy'];
|
||||||
|
$saleTarget = $item['amount'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$record[] = [
|
||||||
|
'coupon_price' => $couponPrice ?? '0.00',
|
||||||
|
'create_time' => time(),
|
||||||
|
'status' => StoreCouponDetail::STATUS_INVALID,
|
||||||
|
'send_status' => StoreCouponDetail::SEND_REPEAL,
|
||||||
|
'extra' => [
|
||||||
|
'sale_target' => $saleTarget,
|
||||||
|
'purchase_target' => bcmul($saleTarget, 0.2, 2),
|
||||||
|
'official_purchase_target' => bcmul($saleTarget, 0.3, 2),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
foreach ($record as &$item) {
|
foreach ($record as &$item) {
|
||||||
$item['status_cn'] = StoreCouponDetail::STATUS_MAP[$item['status']];
|
$item['status_cn'] = StoreCouponDetail::STATUS_MAP[$item['status']];
|
||||||
$item['send_status_cn'] = StoreCouponDetail::SEND_STATUS_MAP[$item['send_status']];
|
$item['send_status_cn'] = StoreCouponDetail::SEND_STATUS_MAP[$item['send_status']];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user