feat(OrderLogic): 修改订单逻辑以计算商品成本与利润
This commit is contained in:
parent
dac95c1e0c
commit
876d2d8dd9
@ -64,19 +64,19 @@ class OrderLogic extends BaseLogic
|
||||
/** 计算价格 */
|
||||
$check = DictType::where('type', 'activities')->find();
|
||||
foreach ($cart_select as $k => $v) {
|
||||
$find = StoreBranchProduct::where(['id' => $v['goods']])->field('store_name,image,unit,price,product_id')->find();
|
||||
$find = StoreBranchProduct::where(['id' => $v['goods']])->field('store_name,image,unit,price,cost,product_id')->find();
|
||||
if (!$find) {
|
||||
continue;
|
||||
}
|
||||
$productBase = StoreProduct::where('id', $find['product_id'])->withTrashed()->field('price,ot_price,cost')->find();
|
||||
// $productBase = StoreProduct::where('id', $find['product_id'])->withTrashed()->field('price,ot_price,cost')->find();
|
||||
if (isset($check) && $check['status'] == 1) {
|
||||
$find['price'] = $productBase['ot_price'];
|
||||
$find['price'] = $find['cost'];
|
||||
}
|
||||
unset($cart_select[$k]['id']);
|
||||
//利润
|
||||
$onePrice = bcsub($productBase['price'], $productBase['ot_price'], 2);
|
||||
$onePrice = bcsub($find['price'], $find['ot_price'], 2);
|
||||
$cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2);//利润
|
||||
$cart_select[$k]['cost'] = bcmul($v['cart_num'], $productBase['cost'], 2) ?? 0;
|
||||
$cart_select[$k]['cost'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0;
|
||||
$cart_select[$k]['total'] = bcmul($v['cart_num'], $find['price'], 2);//钱
|
||||
$cart_select[$k]['price'] = $find['price'];
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2);//钱
|
||||
|
Loading…
x
Reference in New Issue
Block a user