diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index e9cef4c8f..7caa7a63f 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -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'); + } + }