增加:商品编辑支持设置购赠送封坛酒额度和酒类型
This commit is contained in:
parent
6d7325217f
commit
a6d33770ac
|
|
@ -84,6 +84,9 @@ class ProductRepository extends BaseRepository
|
|||
['give_quota_num',0],
|
||||
['is_give_dish',0],
|
||||
['give_dish_num',0],
|
||||
['is_give_wine',0],
|
||||
['give_wine_num',0],
|
||||
['wine_type',0],
|
||||
// 按照批量购买设置
|
||||
['is_batch',0],
|
||||
['batch_num',0],
|
||||
|
|
@ -528,6 +531,9 @@ class ProductRepository extends BaseRepository
|
|||
'give_quota_num' => $data['give_quota_num'] ?? 0,
|
||||
'is_give_dish' => $data['is_give_dish'] ?? 0,
|
||||
'give_dish_num' => $data['give_dish_num'] ?? 0,
|
||||
'is_give_wine' => $data['is_give_wine'] ?? 0,
|
||||
'give_wine_num' => $data['give_wine_num'] ?? 0,
|
||||
'wine_type' => $data['wine_type'] ?? 0,
|
||||
// 按照批量购买设置
|
||||
'is_batch' => $data['is_batch'] ?? 0,
|
||||
'batch_num' => $data['batch_num'] ?? 0,
|
||||
|
|
@ -2514,17 +2520,12 @@ class ProductRepository extends BaseRepository
|
|||
return app()->make(ProductAttrValueRepository::class)->getSearch(['product_id' => $id])->select()->append(['is_svip_price']);
|
||||
}
|
||||
|
||||
public function checkParams($data,$merId,$id = null)
|
||||
{
|
||||
public function checkParams($data,$merId,$id = null){
|
||||
if (!$data['pay_limit']) $data['once_max_count'] = 0;
|
||||
if ($data['brand_id'] > 0 && !$this->merBrandExists($data['brand_id']))
|
||||
throw new ValidateException('品牌不存在');
|
||||
if (!$this->CatExists($data['cate_id']))
|
||||
throw new ValidateException('平台分类不存在');
|
||||
if (isset($data['mer_cate_id']) && !$this->merCatExists($data['mer_cate_id'], $merId))
|
||||
throw new ValidateException('不存在的商户分类');
|
||||
if ($data['delivery_way'] == 2 && !$this->merShippingExists($merId, $data['temp_id']))
|
||||
throw new ValidateException('运费模板不存在');
|
||||
if ($data['brand_id'] > 0 && !$this->merBrandExists($data['brand_id'])) throw new ValidateException('品牌不存在');
|
||||
if (!$this->CatExists($data['cate_id'])) throw new ValidateException('平台分类不存在');
|
||||
if (isset($data['mer_cate_id']) && !$this->merCatExists($data['mer_cate_id'], $merId)) $data['mer_cate_id'] = [];
|
||||
if ($data['delivery_way'] == 2 && !$this->merShippingExists($merId, $data['temp_id'])) throw new ValidateException('运费模板不存在');
|
||||
if (isset($data['type']) && $data['type'] == 1 && $data['extend']) {
|
||||
$key = ['email','text','number','date','time','idCard','mobile','image'];
|
||||
if (count($data['extend']) > 10) throw new ValidateException('附加表单不能超过10条');
|
||||
|
|
@ -2605,7 +2606,8 @@ class ProductRepository extends BaseRepository
|
|||
*/
|
||||
public function getWineList($search, $page, $limit){
|
||||
// 获取信息
|
||||
$query = (new Product())->alias('Product')
|
||||
$query = (new Product())
|
||||
->alias('Product')
|
||||
->join('Merchant', 'Product.mer_id = Merchant.mer_id and Merchant.is_del = 0', 'LEFT')
|
||||
->where('Product.delete', 0)
|
||||
->where('Product.product_type', 0)
|
||||
|
|
@ -2615,6 +2617,7 @@ class ProductRepository extends BaseRepository
|
|||
->where('Merchant.status', 1)
|
||||
->where('Merchant.mer_state', 1)
|
||||
->where('Merchant.merchant_type', 1)
|
||||
->whereIn('Product.wine_type', [1,2])
|
||||
->when(isset($search['store_name']) && $search['store_name'] !== '', function ($query) use ($search) {
|
||||
$query->whereLike('Product.store_name', "%{$search['store_name']}%");
|
||||
})
|
||||
|
|
|
|||
|
|
@ -106,6 +106,12 @@ class OrderPaySuccessEvent{
|
|||
$userHoldInfoDish->uid = $groupOrder->uid;
|
||||
$userHoldInfoDish->quota_type = 2;
|
||||
}
|
||||
// 用户当前持有 封坛酒额度
|
||||
$userHoldInfoWine = app()->make(ExchangeQuotaRepository::class)->searchModel(['uid'=>$groupOrder->uid,'quota_type'=>3])->findOrEmpty();
|
||||
if((int)$userHoldInfoWine->uid <= 0) {
|
||||
$userHoldInfoWine->uid = $groupOrder->uid;
|
||||
$userHoldInfoWine->quota_type = 3;
|
||||
}
|
||||
// 总平台统一设置 赠送酒卡额度倍数
|
||||
$exchangeQuotaMultiple = (int)systemConfig('exchange_quota_multiple');
|
||||
// 循环处理单个商品
|
||||
|
|
@ -170,11 +176,40 @@ class OrderPaySuccessEvent{
|
|||
'quota_type' => 2
|
||||
];
|
||||
}
|
||||
// 判断:商品是否开启赠送封坛酒额度
|
||||
if($orderProductInfo->product->is_give_wine == 1){
|
||||
// 计算默认额度
|
||||
$giveNum = (float)$orderProductInfo->product_price;// 默认为支付金额
|
||||
$merExchangeQuotaMultiple = (int)app()->make(MerchantRepository::class)->getSearch(['mer_id' => $orderInfo->mer_id])->value('mer_exchange_quota_multiple');
|
||||
if($merExchangeQuotaMultiple > 0) $giveNum = (float)sprintf("%2.f",$giveNum * $merExchangeQuotaMultiple);
|
||||
else if($exchangeQuotaMultiple > 0) $giveNum = (float)sprintf("%2.f",$giveNum * $exchangeQuotaMultiple);
|
||||
// 判断:独立设置 还是使用统一设置
|
||||
if((float)$orderProductInfo->product->give_wine_num > 0) $giveNum = (float)$orderProductInfo->product->give_wine_num;
|
||||
// 赠送
|
||||
$changeFront = (float)$userHoldInfoWine->surplus_quota;
|
||||
$userHoldInfoWine->total_quota += (float)$giveNum;// 总额度
|
||||
$userHoldInfoWine->surplus_quota += (float)$giveNum;// 剩余额度
|
||||
$userHoldInfoWine->freeze_quota += (float)$giveNum;// 冻结额度
|
||||
// 记录
|
||||
$insertData[] = [
|
||||
'uid' => $orderProductInfo->uid,
|
||||
'product_id' => $orderProductInfo->product_id,
|
||||
'order_id' => $orderProductInfo->order_id,
|
||||
'order_product_id' => $orderProductInfo->order_product_id,
|
||||
'change_type' => 1,
|
||||
'change_quantity' => (float)$giveNum,
|
||||
'change_front' => $changeFront,
|
||||
'change_after' => (float)$userHoldInfoWine->surplus_quota,
|
||||
'remark' => "购买商品赠送",
|
||||
'quota_type' => 3
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 修改用户持有
|
||||
$userHoldInfo->save();
|
||||
$userHoldInfoDish->save();
|
||||
$userHoldInfoWine->save();
|
||||
// 记录酒卡额度信息
|
||||
if(count($insertData) > 0) ExchangeQuotaRecord::insertAll($insertData);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue