Browse Source

salegetprice优化贵金属售价计算

wufeng 2 years ago
parent
commit
29c5150429
1 changed files with 23 additions and 2 deletions
  1. 23 2
      app/admin/controller/Sale.php

+ 23 - 2
app/admin/controller/Sale.php

@@ -3257,9 +3257,9 @@ class Sale extends Base
                 return error_show(1003, "未找到相关阶梯价格");
             }
 
-            if(!isset($origin['min_num'])) $origin['min_num']=0;
+            if (!isset($origin['min_num'])) $origin['min_num'] = 0;
 
-            $lastnum = max($origin['min_num']??0, $good['min_num']);
+            $lastnum = max($origin['min_num'] ?? 0, $good['min_num']);
             if ($sale_num < $lastnum) {
                 return error_show(1003, "商品不满足起订量{$lastnum}");
             }
@@ -3269,6 +3269,27 @@ class Sale extends Base
                 return error_show(1003, "未找到相关阶梯价格");
             }
 
+            $cat_top_list = made($ct['cat_id']);
+            $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
+
+            if ($ct['is_stock'] == 0 && $ct['is_gold_price'] == 1 && $cat_top_id == 6) {
+                $gold = Db::name("gold_price1")
+                    ->field('id,price')
+                    ->where(["type" => $ct['noble_metal'], "is_del" => 0, "status" => 1])
+                    ->order("addtime desc")
+                    ->find();
+
+                //$saleprice(最终售价) = (打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价+物流费)/(1-成本售价/100);
+                $total_fee = $ct['demo_fee'] / $sale_num + $ct['open_fee'] / $sale_num + $ct['weight'] * $gold["price"] + $good_temp['cost_fee'] * $ct['weight'] + $ct['packing_fee'] + $ct['mark_fee'] + $ct['cert_fee'] + $origin['nake_fee'] + $origin['delivery_fee'];
+
+                $order_rate = Db::name("cat")->where(["id" => $ct['cat_id']])->value('order_rate');
+                $budget = isset($order_rate) ? $order_rate / 100 : 0;
+
+                $saleprice = $total_fee / (1 - $budget);
+
+                return app_show(0, "获取成功", ['sale_price' => $saleprice, "stock" => $stock]);
+            }
+
             return app_show(0, "获取成功", ['sale_price' => $good_temp['sale_price'], "stock" => $stock]);
 
         }