增加:开通会员卡赠送封坛酒额度
This commit is contained in:
parent
7a507574db
commit
6d7325217f
|
|
@ -389,8 +389,9 @@ class GroupDataRepository extends BaseRepository
|
|||
Elm::number('cost_price','原价')->required()->col(12)->min(0),
|
||||
Elm::number('price','优惠价')->required()->col(12)->min(0),
|
||||
Elm::number('sort','排序')->col(12)->min(0),
|
||||
Elm::number('quota','赠送酒卡额度')->required()->col(12)->min(0),
|
||||
Elm::number('vegetable_quota','赠送菜卡额度')->required()->col(12)->min(0),
|
||||
Elm::number('quota','赠送酒卡额度')->required()->col(12)->min(0),
|
||||
Elm::number('wine_quota','赠送封坛酒额度')->required()->col(12)->min(0),
|
||||
Elm::switches('status','是否显示')
|
||||
->activeValue(1)
|
||||
->inactiveValue(0)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class OrderVipPayEvent{
|
|||
// 'order_info' => $order->order_info ?? ''
|
||||
// ],1));
|
||||
$insertData = [];
|
||||
// 酒卡赠送处理
|
||||
// 酒卡额度赠送处理
|
||||
$giveNum = (float)$vipInfo['quota'] ?? 0;
|
||||
if((float)$giveNum > 0){
|
||||
// 获取用户当前持有
|
||||
|
|
@ -63,7 +63,7 @@ class OrderVipPayEvent{
|
|||
'quota_type' => 1,
|
||||
];
|
||||
}
|
||||
// 菜卡赠送处理
|
||||
// 菜卡额度赠送处理
|
||||
$giveNum = (float)$vipInfo['vegetable_quota'] ?? 0;
|
||||
if((float)$giveNum > 0){
|
||||
// 获取用户当前持有
|
||||
|
|
@ -92,6 +92,39 @@ class OrderVipPayEvent{
|
|||
'quota_type' => 2,
|
||||
];
|
||||
}
|
||||
// 封坛酒额度赠送处理
|
||||
$giveNum = (float)$vipInfo['wine_quota'] ?? 0;
|
||||
if((float)$giveNum > 0){
|
||||
// 获取用户当前持有
|
||||
$userHoldInfo = app()->make(ExchangeQuotaRepository::class)
|
||||
->searchModel(['uid' => $order->uid,'quota_type' => 3])
|
||||
->findOrEmpty();
|
||||
if((int)$userHoldInfo->uid <= 0) $userHoldInfo->uid = $order->uid;
|
||||
// 赠送
|
||||
$changeFront = (float)$userHoldInfo->surplus_quota;
|
||||
$userHoldInfo->total_quota += (float)$giveNum;// 总额度
|
||||
$userHoldInfo->surplus_quota += (float)$giveNum;// 剩余额度
|
||||
$userHoldInfo->quota_type = 3;// 额度类型
|
||||
$userHoldInfo->save();
|
||||
// 记录
|
||||
$insertData[] = [
|
||||
'uid' => $order->uid,
|
||||
'product_id' => 0,
|
||||
'order_id' => $order->order_id,
|
||||
'order_product_id' => 0,
|
||||
'change_type' => 1,
|
||||
'change_quantity' => (float)$giveNum,
|
||||
'change_front' => $changeFront,
|
||||
'change_after' => (float)$userHoldInfo->surplus_quota,
|
||||
'remark' => "购买会员卡赠送",
|
||||
'source' => 3,
|
||||
'quota_type' => 3,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(count($insertData) > 0) ExchangeQuotaRecord::insertAll($insertData);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue