Merge branch 'update_warehouse_product' into dev

This commit is contained in:
lewis 2025-03-17 14:36:13 +08:00
commit 60ae388d9f
5 changed files with 29 additions and 19 deletions

View File

@ -431,6 +431,7 @@ class BeforehandOrderLogic extends BaseLogic
// } else { // } else {
// $price = StoreProductGroupPrice::where('product_id', $arr['product_id'])->where('group_id', $user_ship)->value('price') ?? 0; // $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 = [ $data = [
'warehouse_id' => $warehouse_id, 'warehouse_id' => $warehouse_id,
'product_id' => $arr['product_id'], 'product_id' => $arr['product_id'],
@ -443,6 +444,7 @@ class BeforehandOrderLogic extends BaseLogic
'admin_id' => $admin_id, 'admin_id' => $admin_id,
'total_price' => $arr['total_price'], 'total_price' => $arr['total_price'],
'price' => $arr['price'], 'price' => $arr['price'],
'cost' => $cost,
'vip_price' => StoreProduct::where('id',$arr['product_id'])->withTrashed()->value('vip_price') ?? 0, 'vip_price' => StoreProduct::where('id',$arr['product_id'])->withTrashed()->value('vip_price') ?? 0,
'purchase' => $arr['purchase'], 'purchase' => $arr['purchase'],
'oid' => $res['id'], 'oid' => $res['id'],
@ -958,18 +960,23 @@ class BeforehandOrderLogic extends BaseLogic
$v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name'); $v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
$v['store_name'] = $find['store_name']; $v['store_name'] = $find['store_name'];
$v['mark'] = $find['after_sales']; $v['mark'] = $find['after_sales'];
if ($v['vip_price'] > 0) { if (isset($params['type']) && $params['type'] == 2) {
$v['pay_price'] = bcmul($v['vip_price'], $v['nums'], 2); $price = $v['cost'];
$price =$v['vip_price']; $v['pay_price'] = bcmul($price, $v['nums'], 2);
} else { } else {
$price = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', $user_ship)->value('price'); if ($v['vip_price'] > 0) {
if ($price > 0) { $v['pay_price'] = bcmul($v['vip_price'], $v['nums'], 2);
$v['pay_price'] = bcmul($price, $v['nums'], 2); $price = $v['vip_price'];
} else { } else {
$price = $find['cost']; $price = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', $user_ship)->value('price');
$v['pay_price'] = bcmul($price, $v['nums'], 2); 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; $v['purchase'] = $price;

View File

@ -472,7 +472,7 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
$product = StoreProduct::where('id', $purchaseProductOffer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find(); $product = StoreProduct::where('id', $purchaseProductOffer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find();
if (!in_array($beforehandOrder['order_type'], [6, 9])) { if (!in_array($beforehandOrder['order_type'], [6, 9])) {
PurchaseProductOfferLogic::setProductGroupPrice($purchaseProductOffer, $product, $params['warehouse_id']); PurchaseProductOfferLogic::setProductPrice($purchaseProductOffer, $product, $params['warehouse_id']);
} }
Db::commit(); Db::commit();
return true; return true;

View File

@ -324,7 +324,7 @@ class PurchaseProductOfferLogic extends BaseLogic
BeforehandOrder::where('id', $offer['bhoid'])->update(['pay_price' => $pay_price]); BeforehandOrder::where('id', $offer['bhoid'])->update(['pay_price' => $pay_price]);
$product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find(); $product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find();
$offer['purchase']=$price; $offer['purchase']=$price;
self::setProductGroupPrice($offer, $product); self::setProductPrice($offer, $product);
Db::commit(); Db::commit();
return true; return true;
} catch (\Throwable $e) { } catch (\Throwable $e) {
@ -380,7 +380,7 @@ class PurchaseProductOfferLogic extends BaseLogic
} }
/** /**
* 设置商品分组价格 * 设置商品价格
* @param $params * @param $params
* @param $product * @param $product
* @return void * @return void
@ -388,7 +388,7 @@ class PurchaseProductOfferLogic extends BaseLogic
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
public static function setProductGroupPrice($params, $product, $warehouseId = 0) public static function setProductPrice($params, $product, $warehouseId = 0)
{ {
$priceConfig = []; $priceConfig = [];
$data = [ $data = [

View File

@ -99,15 +99,16 @@ class StoreProductPriceLogic extends BaseLogic
'purchase' => $find['purchase'], 'purchase' => $find['purchase'],
'cost' => $find['cost'], 'cost' => $find['cost'],
'vip_price' => $find['vip_price'], 'vip_price' => $find['vip_price'],
'price' => $find['price'] 'price' => $find['vip_price'],
'ot_price' => $find['price']
]); ]);
StoreBranchProduct::where('product_id', $find['product_id'])->update([ StoreBranchProduct::where('product_id', $find['product_id'])->update([
'purchase' => $find['purchase'], 'purchase' => $find['purchase'],
'cost' => $find['cost'], 'cost' => $find['cost'],
'vip_price' => $find['vip_price'], 'vip_price' => $find['vip_price'],
'price' => $find['price'] 'price' => $find['vip_price'],
'ot_price' => $find['price']
]); ]);
// self::setProductGroupPrice($find);
} }
Db::commit(); Db::commit();
return true; return true;
@ -172,15 +173,16 @@ class StoreProductPriceLogic extends BaseLogic
'purchase' => $find['purchase'] ?? 0, 'purchase' => $find['purchase'] ?? 0,
'cost' => $find['cost'] ?? 0, 'cost' => $find['cost'] ?? 0,
'vip_price' => $find['vip_price'] ?? 0, 'vip_price' => $find['vip_price'] ?? 0,
'price' => $find['price'] ?? 0 'price' => $find['vip_price'] ?? 0,
'ot_price' => $find['price'] ?? 0,
]); ]);
StoreBranchProduct::where('product_id', $find['product_id'])->update([ StoreBranchProduct::where('product_id', $find['product_id'])->update([
'purchase' => $find['purchase'] ?? 0, 'purchase' => $find['purchase'] ?? 0,
'cost' => $find['cost'] ?? 0, 'cost' => $find['cost'] ?? 0,
'vip_price' => $find['vip_price'] ?? 0, 'vip_price' => $find['vip_price'] ?? 0,
'price' => $find['price'] ?? 0 'price' => $find['vip_price'] ?? 0,
'ot_price' => $find['price'] ?? 0,
]); ]);
// self::setProductGroupPrice($find);
} }
Db::commit(); Db::commit();
return true; return true;

View File

@ -189,6 +189,7 @@ class WarehouseProductLogic extends BaseLogic
'price' => $params['price'] ?? 0, 'price' => $params['price'] ?? 0,
'purchase' => $params['purchase'] ?? 0, 'purchase' => $params['purchase'] ?? 0,
'vip_price' => $params['vip_price'] ?? 0, 'vip_price' => $params['vip_price'] ?? 0,
'cost' => $params['cost'] ?? 0,
'total_price' => $params['total_price'] ?? 0, 'total_price' => $params['total_price'] ?? 0,
'admin_id' => $params['admin_id'], 'admin_id' => $params['admin_id'],
'code' => $params['code'] ?? '', 'code' => $params['code'] ?? '',