Explorar o código

debug 底价/oms查询进货价

lionared %!s(int64=6) %!d(string=hai) anos
pai
achega
289faa4da6

+ 41 - 1
shop/control/store_goods_online.php

@@ -120,6 +120,7 @@ class store_goods_onlineControl extends BaseSellerControl {
             Tpl::output ( 'attr_checked', $attr_checked );
 
             $spec_checked = array();
+            $mod = Model();
             foreach ( $goods_array as $k => $v ) {
                 $a = unserialize($v['goods_spec']);
                 if (!empty($a)) {
@@ -129,10 +130,22 @@ class store_goods_onlineControl extends BaseSellerControl {
                     }
                     $matchs = array_keys($a);
                     sort($matchs);
+
+                    $oms_id = intval($v['oms_id']);
+                    $purchase_price = 0.00;
+                    if ($oms_id > 0) {
+                        $oms_info = $mod->table('goods_orgprice')->where([ 'omsid' => $oms_id ])->find();
+                        if (!empty($oms_info)) {
+                            $purchase_price = floatval($oms_info['purchase_price']);
+                        } else {
+                            $purchase_price = floatval($v['goods_lowest_price']);
+                        }
+                    }
                     $id = str_replace ( ',', '', implode ( ',', $matchs ) );
+                    $sp_value ['i_' . $id . '|purchase_price'] = $purchase_price;
                     $sp_value ['i_' . $id . '|marketprice'] = $v['goods_marketprice'];
                     $sp_value ['i_' . $id . '|price'] = $v['goods_price'];
-                    $sp_value ['i_' . $id . '|lowest_price'] = $v['goods_lowest_price'];
+                    $sp_value ['i_' . $id . '|lowest_price'] = floatval($v['goods_lowest_price']);
                     $sp_value ['i_' . $id . '|id'] = $v['goods_id'];
                     $sp_value ['i_' . $id . '|stock'] = $v['goods_storage'];
                     $sp_value ['i_' . $id . '|alarm'] = $v['goods_storage_alarm'];
@@ -1316,4 +1329,31 @@ class store_goods_onlineControl extends BaseSellerControl {
 		echo '<br/><b>全部生成完成</b>';
 	}
 
+	public function ajax_get_omsinfoOp()
+    {
+        $ret = [
+            'code'  => 1,
+            'message'   => "",
+            'data'  => []
+        ];
+        $oms_ids = $_REQUEST['oms_id'];
+        if (empty($oms_ids)) {
+            $ret['message'] = "缺少OMSID";
+            echo json_encode($ret);
+            return;
+        }
+        $omsids = implode($oms_ids, ",");
+
+        $mod = Model();
+        $oms_info = $mod->table('goods_orgprice')->where([ 'omsid' => ['in',$omsids] ])->select();
+
+        if (empty($oms_info)) {
+            $ret['message'] = "未查到相应的OMS信息";
+            echo json_encode($ret);
+            return;
+        }
+        $ret['code'] = 0;
+        $ret['data'] = $oms_info;
+        echo json_encode($ret);return;
+    }
 }

+ 17 - 5
shop/resource/js/store_goods_add.step2.js

@@ -218,7 +218,7 @@ $(function(){
     $('.batch-input > .ncsc-btn-mini').click(function(){
         var _value = $(this).prev().val();
         var _type = $(this).attr('data-type');
-        if (_type == 'price') {
+        if (_type == 'price' || _type == 'lowest_price') {
             _value = number_format(_value, 2);
         } else {
             _value = parseInt(_value);
@@ -235,6 +235,11 @@ $(function(){
         if (_type == 'price') {
             computePrice();
         }
+        if (_type == 'lowest_price') {
+            $('tbody[nc_type="spec_table"]').find('input[data_type="' + _type + '" ]').each(function () {
+                computeLowestPrice($(this));
+            });
+        }
         if (_type == 'stock') {
             computeStock();
         }
@@ -659,12 +664,19 @@ function computePrice(){
     discountCalculator();       // 计算折扣
 }
 
+//计算底价
 function computeLowestPrice($target) {
-    var _lowest = $($target).val();
-    var _price = $($target).parent().children('input[data_type="price"]').val();
-    if (parseFloat(_lowest) > parseFloat(_price)) {
+    var _lowest = parseFloat($($target).val());
+    var _price = parseFloat($($target).parents("tr").find('input[data_type="price"]').eq(0).val());
+    //var _costPrice = parseFloat($('input[name="g_costprice"]').val());
+    var _purchase_price = parseFloat($($target).parents("tr").find('input:hidden[data_type="purchase_price"]').val());
+    if (isNaN(_lowest) || isNaN(_price) || isNaN(_purchase_price)) return;
+    if (_lowest > _price) {
         console.log("lowest > price");
-        $($target).val(_price);
+        $($target).val(number_format(_price, 2));
+    } else if(_lowest < _purchase_price) {
+        console.log("lowest < _purchase_price");
+        $($target).val(number_format(_purchase_price, 2));
     }
 }
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 43 - 4
shop/templates/default/seller/store_goods_add.step2.php