diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index fc89ae7a6..75579b135 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -431,6 +431,7 @@ class BeforehandOrderLogic extends BaseLogic // } else { // $price = StoreProductGroupPrice::where('product_id', $arr['product_id'])->where('group_id', $user_ship)->value('price') ?? 0; // } + $cost = StoreProduct::where('id', $arr['product_id'])->withTrashed()->value('cost') ?? 0; $data = [ 'warehouse_id' => $warehouse_id, 'product_id' => $arr['product_id'], @@ -443,6 +444,7 @@ class BeforehandOrderLogic extends BaseLogic 'admin_id' => $admin_id, 'total_price' => $arr['total_price'], 'price' => $arr['price'], + 'cost' => $cost, 'vip_price' => StoreProduct::where('id',$arr['product_id'])->withTrashed()->value('vip_price') ?? 0, 'purchase' => $arr['purchase'], 'oid' => $res['id'], @@ -958,18 +960,23 @@ class BeforehandOrderLogic extends BaseLogic $v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name'); $v['store_name'] = $find['store_name']; $v['mark'] = $find['after_sales']; - if ($v['vip_price'] > 0) { - $v['pay_price'] = bcmul($v['vip_price'], $v['nums'], 2); - $price =$v['vip_price']; + if (isset($params['type']) && $params['type'] == 2) { + $price = $v['cost']; + $v['pay_price'] = bcmul($price, $v['nums'], 2); } else { - $price = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', $user_ship)->value('price'); - if ($price > 0) { - $v['pay_price'] = bcmul($price, $v['nums'], 2); + if ($v['vip_price'] > 0) { + $v['pay_price'] = bcmul($v['vip_price'], $v['nums'], 2); + $price = $v['vip_price']; } else { - $price = $find['cost']; - $v['pay_price'] = bcmul($price, $v['nums'], 2); + $price = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', $user_ship)->value('price'); + if ($price > 0) { + $v['pay_price'] = bcmul($price, $v['nums'], 2); + } else { + $price = $find['cost']; + $v['pay_price'] = bcmul($price, $v['nums'], 2); + } + WarehouseProduct::where('id', $v['id'])->update(['vip_price' => $price]); } - WarehouseProduct::where('id', $v['id'])->update(['vip_price' => $price]); } $v['purchase'] = $price; diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 01d4f5918..735ffe7a6 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -176,6 +176,7 @@ class WarehouseProductLogic extends BaseLogic 'price' => $params['price'] ?? 0, 'purchase' => $params['purchase'] ?? 0, 'vip_price' => $params['vip_price'] ?? 0, + 'cost' => $params['cost'] ?? 0, 'total_price' => $params['total_price'] ?? 0, 'admin_id' => $params['admin_id'], 'code' => $params['code'] ?? '',