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 {
// $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;

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();
if (!in_array($beforehandOrder['order_type'], [6, 9])) {
PurchaseProductOfferLogic::setProductGroupPrice($purchaseProductOffer, $product, $params['warehouse_id']);
PurchaseProductOfferLogic::setProductPrice($purchaseProductOffer, $product, $params['warehouse_id']);
}
Db::commit();
return true;

View File

@ -324,7 +324,7 @@ class PurchaseProductOfferLogic extends BaseLogic
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();
$offer['purchase']=$price;
self::setProductGroupPrice($offer, $product);
self::setProductPrice($offer, $product);
Db::commit();
return true;
} catch (\Throwable $e) {
@ -380,7 +380,7 @@ class PurchaseProductOfferLogic extends BaseLogic
}
/**
* 设置商品分组价格
* 设置商品价格
* @param $params
* @param $product
* @return void
@ -388,7 +388,7 @@ class PurchaseProductOfferLogic extends BaseLogic
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function setProductGroupPrice($params, $product, $warehouseId = 0)
public static function setProductPrice($params, $product, $warehouseId = 0)
{
$priceConfig = [];
$data = [

View File

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

View File

@ -189,6 +189,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'] ?? '',