添加:商品单独设置积分赠送方式,商户可以设置统一赠送积分比例
This commit is contained in:
parent
e43d510bfc
commit
b6fc8f6078
|
|
@ -76,7 +76,7 @@ class StoreCartDao extends BaseDao
|
|||
{
|
||||
return StoreCart::getDb()->where('uid', $uid)->with([
|
||||
'product' => function (Relation $query) use ($address) {
|
||||
$query->field('product_id,cate_id,image,store_name,is_show,status,is_del,unit_name,price,mer_status,temp_id,give_coupon_ids,is_gift_bag,is_used,product_type,old_product_id,integral_rate,delivery_way,delivery_free,type,extend,pay_limit,once_max_count,once_min_count,mer_svip_status,svip_price_type,refund_switch');
|
||||
$query->field('product_id,cate_id,image,store_name,is_show,status,is_del,unit_name,price,mer_status,temp_id,give_coupon_ids,is_gift_bag,is_used,product_type,old_product_id,integral_rate,delivery_way,delivery_free,type,extend,pay_limit,once_max_count,once_min_count,mer_svip_status,svip_price_type,refund_switch,integral_give_switch,integral_give_set,integral_give_type,integral_give_rate,integral_give_money');
|
||||
if ($address) {
|
||||
$cityIds = array_filter([$address->province_id, $address->city_id, $address->district_id, $address->street_id]);
|
||||
$query->with([
|
||||
|
|
@ -117,6 +117,7 @@ class StoreCartDao extends BaseDao
|
|||
'mer_integral_status',
|
||||
'mer_integral_rate',
|
||||
'mer_integral_money',
|
||||
'mer_integral_order_rate',
|
||||
'mer_store_stock',
|
||||
'mer_take_status',
|
||||
'mer_take_name',
|
||||
|
|
|
|||
|
|
@ -767,6 +767,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||
'mer_integral_rate' => 0,
|
||||
'mer_integral_status' => 0,
|
||||
'mer_integral_money' => 0,
|
||||
'mer_integral_order_rate' => 0,
|
||||
];
|
||||
$allow_no_address = $allow_no_address && $merchantCart['order']['isTake'];
|
||||
foreach ($merchantCart['config'] as $config) {
|
||||
|
|
@ -891,11 +892,31 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||
$pay_price = $org_price;
|
||||
}
|
||||
|
||||
$giveIntegralFlag = $sysIntegralConfig['integral_status'] && $sysIntegralConfig['integral_order_rate'] > 0;
|
||||
$giveIntegralFlag = $sysIntegralConfig['integral_status'] && $sysIntegralConfig['integral_order_rate'] > 0;// 总平台是否开启赠送积分
|
||||
$total_give_integral = 0;
|
||||
//计算赠送积分, 只有普通商品赠送积分
|
||||
// 计算赠送积分, 只有普通商品赠送积分
|
||||
if ($giveIntegralFlag && !$order_type && $pay_price > 0) {
|
||||
$total_give_integral = floor(bcmul($pay_price, $sysIntegralConfig['integral_order_rate'], 0));
|
||||
// 统一比例 商户大于0则使用商户比例,否则使用平台比例
|
||||
$uniformRate = (float)$merIntegralConfig['mer_integral_order_rate'] > 0 ? (float)$merIntegralConfig['mer_integral_order_rate'] : (float)$sysIntegralConfig['integral_order_rate'];
|
||||
foreach ($merchantCart['list'] as &$cart) {
|
||||
// 判断:商品是否开启赠送积分
|
||||
if((int)$cart->product->integral_give_switch != 1) continue;
|
||||
// 判断:赠送设置为统一设置 or 独立设置
|
||||
if((int)$cart->product->integral_give_set != 1){
|
||||
// 使用统一设置
|
||||
$total_give_integral = floor(bcmul($cart['true_price'], $uniformRate, 0));
|
||||
}else{
|
||||
// 使用独立设置
|
||||
if((int)$cart->product->integral_give_type != 1) {
|
||||
// 百分比
|
||||
$total_give_integral = floor(bcmul($cart['true_price'], ((float)$cart->product->integral_give_rate), 0));
|
||||
}else{
|
||||
// 固定金额
|
||||
$total_give_integral = (int)$cart->product->integral_give_money;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理付费会员
|
||||
if ($total_give_integral > 0 && $svip_status && $svip_integral_rate > 0) {
|
||||
$total_give_integral = bcmul($svip_integral_rate, $total_give_integral, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@ class ProductRepository extends BaseRepository
|
|||
['svip_price_type',0],
|
||||
['params',[]],
|
||||
['product_type',0],
|
||||
// 赠送积分
|
||||
['integral_give_switch',0],
|
||||
['integral_give_set',0],
|
||||
['integral_give_type',0],
|
||||
'integral_give_rate',
|
||||
'integral_give_money',
|
||||
];
|
||||
protected $admin_filed = 'Product.product_id,Product.mer_id,brand_id,spec_type,unit_name,mer_status,rate,reply_count,store_info,cate_id,Product.image,slider_image,Product.store_name,Product.keyword,Product.sort,U.rank,Product.is_show,Product.sales,Product.price,extension_type,refusal,cost,Product.ot_price,stock,is_gift_bag,Product.care_count,Product.status,is_used,Product.create_time,Product.product_type,old_product_id,star,ficti,integral_total,integral_price_total,sys_labels,param_temp_id,mer_svip_status,svip_price,svip_price_type';
|
||||
protected $filed = 'Product.product_id,Product.mer_id,brand_id,unit_name,spec_type,mer_status,rate,reply_count,store_info,cate_id,Product.image,slider_image,Product.store_name,Product.keyword,Product.sort,Product.is_show,Product.sales,Product.price,extension_type,refusal,cost,Product.ot_price,stock,is_gift_bag,Product.care_count,Product.status,is_used,Product.create_time,Product.product_type,old_product_id,integral_total,integral_price_total,mer_labels,Product.is_good,Product.is_del,type,param_temp_id,mer_svip_status,svip_price,svip_price_type';
|
||||
|
|
@ -437,39 +443,43 @@ class ProductRepository extends BaseRepository
|
|||
$integral_rate = $data['integral_rate'];
|
||||
if($data['integral_rate'] < 0) $integral_rate = -1;
|
||||
if($data['integral_rate'] > 100) $integral_rate = 100;
|
||||
|
||||
}
|
||||
|
||||
$result = [
|
||||
'store_name' => $data['store_name'],
|
||||
'image' => $data['image'],
|
||||
'slider_image' => is_array($data['slider_image']) ? implode(',', $data['slider_image']) : '',
|
||||
'store_info' => $data['store_info'] ?? '',
|
||||
'keyword' => $data['keyword']??'',
|
||||
'brand_id' => $data['brand_id'] ?? 0,
|
||||
'cate_id' => $data['cate_id'] ?? 0,
|
||||
'unit_name' => $data['unit_name']??'件',
|
||||
'sort' => $data['sort'] ?? 0,
|
||||
'is_show' => $data['is_show'] ?? 0,
|
||||
'is_used' => (isset($data['status']) && $data['status'] == 1) ? 1 : 0,
|
||||
'is_good' => $data['is_good'] ?? 0,
|
||||
'video_link' => $data['video_link']??'',
|
||||
'temp_id' => $data['delivery_free'] ? 0 : ($data['temp_id'] ?? 0),
|
||||
'extension_type' => $data['extension_type']??0,
|
||||
'spec_type' => $data['spec_type'] ?? 0,
|
||||
'status' => $data['status']??0,
|
||||
'give_coupon_ids' => $give_coupon_ids,
|
||||
'mer_status' => $data['mer_status'],
|
||||
'guarantee_template_id' => $data['guarantee_template_id']??0,
|
||||
'is_gift_bag' => $data['is_gift_bag'] ?? 0,
|
||||
'integral_rate' => $integral_rate ?? 0,
|
||||
'delivery_way' => implode(',',$data['delivery_way']),
|
||||
'delivery_free' => $data['delivery_free'] ?? 0,
|
||||
'once_min_count' => $data['once_min_count'] ?? 0,
|
||||
'once_max_count' => $data['once_max_count'] ?? 0,
|
||||
'pay_limit' => $data['pay_limit'] ?? 0,
|
||||
'svip_price_type' => $data['svip_price_type'] ?? 0,
|
||||
'refund_switch' => $data['refund_switch'] ?? 0,
|
||||
'store_name' => $data['store_name'],
|
||||
'image' => $data['image'],
|
||||
'slider_image' => is_array($data['slider_image']) ? implode(',',$data['slider_image']) : '',
|
||||
'store_info' => $data['store_info'] ?? '',
|
||||
'keyword' => $data['keyword'] ?? '',
|
||||
'brand_id' => $data['brand_id'] ?? 0,
|
||||
'cate_id' => $data['cate_id'] ?? 0,
|
||||
'unit_name' => $data['unit_name'] ?? '件',
|
||||
'sort' => $data['sort'] ?? 0,
|
||||
'is_show' => $data['is_show'] ?? 0,
|
||||
'is_used' => (isset($data['status']) && $data['status'] == 1) ? 1 : 0,
|
||||
'is_good' => $data['is_good'] ?? 0,
|
||||
'video_link' => $data['video_link'] ?? '',
|
||||
'temp_id' => $data['delivery_free'] ? 0 : ($data['temp_id'] ?? 0),
|
||||
'extension_type' => $data['extension_type'] ?? 0,
|
||||
'spec_type' => $data['spec_type'] ?? 0,
|
||||
'status' => $data['status'] ?? 0,
|
||||
'give_coupon_ids' => $give_coupon_ids,
|
||||
'mer_status' => $data['mer_status'],
|
||||
'guarantee_template_id' => $data['guarantee_template_id'] ?? 0,
|
||||
'is_gift_bag' => $data['is_gift_bag'] ?? 0,
|
||||
'integral_rate' => $integral_rate ?? 0,
|
||||
'delivery_way' => implode(',',$data['delivery_way']),
|
||||
'delivery_free' => $data['delivery_free'] ?? 0,
|
||||
'once_min_count' => $data['once_min_count'] ?? 0,
|
||||
'once_max_count' => $data['once_max_count'] ?? 0,
|
||||
'pay_limit' => $data['pay_limit'] ?? 0,
|
||||
'svip_price_type' => $data['svip_price_type'] ?? 0,
|
||||
'refund_switch' => $data['refund_switch'] ?? 0,
|
||||
// 赠送积分
|
||||
'integral_give_switch' => $data['integral_give_switch'] ?? 0,
|
||||
'integral_give_set' => $data['integral_give_set'] ?? 0,
|
||||
'integral_give_type' => $data['integral_give_type'] ?? 0,
|
||||
'integral_give_rate' => $data['integral_give_rate'] ?? 0,
|
||||
'integral_give_money' => $data['integral_give_money'] ?? 0,
|
||||
];
|
||||
if (isset($data['extend']))
|
||||
$result['extend'] = $data['extend'] ? json_encode($data['extend'], JSON_UNESCAPED_UNICODE) : '';
|
||||
|
|
@ -782,7 +792,7 @@ class ProductRepository extends BaseRepository
|
|||
$data['content'] = $content;
|
||||
|
||||
// 查找该商品积分抵扣比例
|
||||
if(!empty($data['merchant'])) $data['merchant'] = merchantConfig($data['merchant']['mer_id'],['mer_integral_status','mer_integral_rate','mer_integral_money']);
|
||||
if(!empty($data['merchant'])) $data['merchant'] = merchantConfig($data['merchant']['mer_id'],['mer_integral_status','mer_integral_rate','mer_integral_money','mer_integral_order_rate']);
|
||||
|
||||
|
||||
// 拼接商品分类
|
||||
|
|
|
|||
Loading…
Reference in New Issue