修改采购单价格的错误

This commit is contained in:
lewis 2024-12-27 17:56:18 +08:00
parent ccc774593a
commit 715f84d2f2

View File

@ -183,7 +183,7 @@ class PurchaseProductOfferLogic extends BaseLogic
'expiration_date' => $params['expiration_date'],
]);
// $find = StoreProductPrice::where(['offer_id' => $params['id']])->find();
$product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id')->find();
$product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find();
$unit_name=StoreProductUnit::where('id', $offer['unit'])->value('name');
$order = BeforehandOrder::where('id', $params['bhoid'])->find();
$order->pay_price = PurchaseProductOffer::where('order_id', $order['id'])->sum('total_price');
@ -364,7 +364,7 @@ class PurchaseProductOfferLogic extends BaseLogic
'update_time' => time(),
'status' => 0,
];
$productCatePriceRate = StoreCategory::where('id', $product['top_cate_id'])->value('price_rate');
$productCatePriceRate = self::getProductCatePriceRate($product);
if (!empty($productCatePriceRate)) {
$storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $product['id'])->select()->toArray();
$storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id');
@ -400,7 +400,7 @@ class PurchaseProductOfferLogic extends BaseLogic
}
continue;
}
$baseRate = 100 + $v['rate'];
$baseRate = ($v['id'] == 100001 || $v['id'] == 21) ? 100 : 100 + $v['rate'];
if($purchase>0){
$item = [
'product_id' => $product['id'],
@ -427,4 +427,18 @@ class PurchaseProductOfferLogic extends BaseLogic
StoreProductPrice::create($data);
}
}
public static function getProductCatePriceRate($product)
{
$productCatePriceRate = StoreCategory::where('id', $product['cate_id'])->value('price_rate');
if (!empty($productCatePriceRate)) {
return $productCatePriceRate;
}
$productCatePriceRate = StoreCategory::where('id', $product['two_cate_id'])->value('price_rate');
if (!empty($productCatePriceRate)) {
return $productCatePriceRate;
}
return StoreCategory::where('id', $product['top_cate_id'])->value('price_rate');
}
}