feat(order): 添加订单逻辑,包括创建订单、查询订单、核销订单等
This commit is contained in:
parent
15eba34386
commit
f880a035d4
@ -52,6 +52,7 @@ class OrderLogic extends BaseLogic
|
||||
public static $profit;
|
||||
public static $store_price; //门店零售价
|
||||
public static $activity_price;
|
||||
public static $deduction_price;
|
||||
|
||||
/**
|
||||
* @notes 获取购物车商品信息
|
||||
@ -74,6 +75,7 @@ class OrderLogic extends BaseLogic
|
||||
self::$profit = 0; //利润
|
||||
self::$activity_price = 0; //活动减少
|
||||
self::$store_price = 0; //门店零售价
|
||||
$deduction_price = 0; //抵扣金额
|
||||
/** 计算价格 */
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id';
|
||||
@ -83,6 +85,7 @@ class OrderLogic extends BaseLogic
|
||||
continue;
|
||||
}
|
||||
unset($cart_select[$k]['id']);
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
if ($off_activity == 1) {
|
||||
$price = $find['cost'];
|
||||
} else {
|
||||
@ -90,8 +93,6 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
$cart_select[$k]['price'] = $price;
|
||||
$cart_select[$k]['cost'] = $find['cost'];
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
||||
$cart_select[$k]['vip'] = 0;
|
||||
|
||||
//利润
|
||||
@ -101,6 +102,10 @@ class OrderLogic extends BaseLogic
|
||||
$cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //门店零售价
|
||||
$cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价
|
||||
|
||||
if($cart_select[$k]['total_price']>$cart_select[$k]['pay_price']){
|
||||
$deduction_price=bcsub($cart_select[$k]['total_price'],$find['deduction_price'],2);
|
||||
$cart_select[$k]['deduction_price'] =$deduction_price;//抵扣金额
|
||||
}
|
||||
$cart_select[$k]['product_id'] = $find['product_id'];
|
||||
$cart_select[$k]['old_cart_id'] = $v['id'];
|
||||
$cart_select[$k]['cart_num'] = $v['cart_num'];
|
||||
@ -123,6 +128,7 @@ class OrderLogic extends BaseLogic
|
||||
self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2);
|
||||
self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2);
|
||||
self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //门店零售价格
|
||||
self::$deduction_price=bcadd(self::$deduction_price,$deduction_price,2);//抵扣金额
|
||||
// self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2);
|
||||
}
|
||||
//加支付方式限制
|
||||
@ -154,7 +160,7 @@ class OrderLogic extends BaseLogic
|
||||
'activity' => '减免',
|
||||
'activity_price' => self::$activity_price,
|
||||
'activities' => self::$activity_price > 0 ? 1 : 0,
|
||||
'deduction_price' => self::$activity_price,
|
||||
'deduction_price' => self::$deduction_price,
|
||||
'is_vip' => 0,
|
||||
'is_storage' => $params['is_storage'] ?? 0,
|
||||
];
|
||||
@ -164,7 +170,6 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
if ($user && $user['user_ship'] >= 1 && $user['user_ship'] <= 3) {
|
||||
$order['is_vip'] = 1;
|
||||
|
||||
}
|
||||
//处理返回最近的店铺
|
||||
$store['near_store'] = [];
|
||||
@ -182,9 +187,7 @@ class OrderLogic extends BaseLogic
|
||||
if ($nearestStore) {
|
||||
$store['near_store'] = $nearestStore;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
@ -446,9 +449,7 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
if ($nearestStore) {
|
||||
$find['near_store'] = $nearestStore;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return $find;
|
||||
|
Loading…
x
Reference in New Issue
Block a user