Browse Source

商品发布信息增加首付款、月供、尾款、库存有效期

lionared 7 năm trước cách đây
mục cha
commit
e2f431b0fc

+ 6 - 0
helper/car/finder.php

@@ -51,6 +51,12 @@ class finder
         }
     }
 
+    public function getMarketPrice($car_id)
+    {
+        $mod_car = Model();
+        return $mod_car->table('car_base')->field('market_price')->find($car_id);
+    }
+
     private function init()
     {
         $ret = rcache('cars', 'mb_');

+ 40 - 7
shop/control/store_goods_add.php

@@ -249,8 +249,8 @@ class store_goods_addControl extends BaseSellerControl
             } else {
                 $common_array['goods_stcids'] = ','.implode(',',$goods_stcids_arr).',';// 首尾需要加,
             }
-            $common_array['plateid_top']        = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : '';
-            $common_array['plateid_bottom']     = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : '';
+            $common_array['plateid_top']        = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : 0;
+            $common_array['plateid_bottom']     = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : 0;
             $common_array['is_virtual']         = intval($_POST['is_gv']);
             $common_array['virtual_indate']     = $_POST['g_vindate'] != '' ? (strtotime($_POST['g_vindate']) + 24*60*60 -1) : 0;  // 当天的最后一秒结束
             $common_array['virtual_limit']      = intval($_POST['g_vlimit']) > 10 || intval($_POST['g_vlimit']) < 0 ? 10 : intval($_POST['g_vlimit']);
@@ -284,12 +284,26 @@ class store_goods_addControl extends BaseSellerControl
                         $goods['gc_id_2']           = $common_array['gc_id_2'];
                         $goods['gc_id_3']           = $common_array['gc_id_3'];
                         $goods['brand_id']          = $common_array['brand_id'];
-                        $goods['goods_price']       = $value['price'];
                         $goods['goods_promotion_price']=$value['price'];
-                        $goods['goods_marketprice'] = $value['marketprice'] == 0 ? $common_array['goods_marketprice'] : $value['marketprice'];
-                        $goods['goods_serial']      = $value['sku'];
+                        //$goods['goods_price']       = $value['price'];
+                        //$goods['goods_marketprice'] = $value['marketprice'] == 0 ? $common_array['goods_marketprice'] : $value['marketprice'];
+                        //$goods['goods_storage_alarm']= intval($value['alarm']);
+
+                        $goods['first_pay']         = floatval($value['first_pay']);     //首付
+                        $goods['month_pay']         = floatval($value['month_pay']);     //月供
+                        $goods['final_pay']         = floatval($value['final_pay']);     //尾款
+                        $goods['storage_exp_date']  = strtotime($value['expdate']);      //库存有效期
+
+                        $specs = array_values($value['sp_value']);
+                        $split_num = 0;
+                        preg_match_all('/\d+(\.\d+)?/',$specs[1], $matches);
+                        if(isset($matches[0][0])) {
+                            $split_num = intval($matches[0][0]);
+                        }
+                        $goods['goods_price']       = round(($goods['first_pay'] + $goods['month_pay'] * $split_num + $goods['final_pay']), 2);
+
+                        $goods['goods_serial']      = $_POST['g_serial'];
                         $goods['oms_id']            = intval($value['oms_id']);
-                        $goods['goods_storage_alarm']= intval($value['alarm']);
                         $goods['goods_spec']        = serialize($value['sp_value']);
                         $goods['goods_storage']     = $value['stock'];
                         $goods['goods_image']       = $common_array['goods_image'];
@@ -760,7 +774,7 @@ class store_goods_addControl extends BaseSellerControl
             echo json_encode(array('done' => false));die();
         }
         $insert = array(
-            'sp_value_name' => $name,
+            'sp_value_name' => $this->format_spec_value($name),
             'sp_id' => $sp_id,
             'gc_id' => $gc_id,
             'store_id' => $_SESSION['store_id'],
@@ -838,4 +852,23 @@ class store_goods_addControl extends BaseSellerControl
             echo "";die();
         }
     }
+
+    public function ajax_get_car_priceOp()
+    {
+        $car_id = intval($_GET['car_id']);
+        if($car_id && $car_id > 0) {
+            $market_price = car\finder::instance()->getMarketPrice($car_id);
+            echo json_encode($market_price);die();
+        } else {
+            echo "";die();
+        }
+    }
+
+    private function format_spec_value($spec_value)
+    {
+        preg_match_all("/\d+(\.\d+)?/", $spec_value, $matches);
+        if(isset($matches[0][0])) {
+            return $matches[0][0]. "%";
+        }
+    }
 }

+ 39 - 11
shop/control/store_goods_online.php

@@ -373,8 +373,8 @@ class store_goods_onlineControl extends BaseSellerControl {
         } else {
             $update_common['goods_stcids'] = ','.implode(',',$goods_stcids_arr).',';
         }
-        $update_common['plateid_top']        = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : '';
-        $update_common['plateid_bottom']     = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : '';
+        $update_common['plateid_top']        = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : 0;
+        $update_common['plateid_bottom']     = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : 0;
         $update_common['is_virtual']         = intval($_POST['is_gv']);
         $update_common['virtual_indate']     = $_POST['g_vindate'] != '' ? (strtotime($_POST['g_vindate']) + 24*60*60 -1) : 0;  // 当天的最后一秒结束
         $update_common['virtual_limit']      = intval($_POST['g_vlimit']) > 10 || intval($_POST['g_vlimit']) < 0 ? 10 : intval($_POST['g_vlimit']);
@@ -420,11 +420,25 @@ class store_goods_onlineControl extends BaseSellerControl {
                     $update['gc_id_2']           = $update_common['gc_id_2'];
                     $update['gc_id_3']           = $update_common['gc_id_3'];
                     $update['brand_id']          = $update_common['brand_id'];
-                    $update['goods_price']       = $value['price'];
-                    $update['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice'];
-                    $update['goods_serial']      = $value['sku'];
+                    //$update['goods_price']       = $value['price'];
+                    //$update['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice'];
+                    //$update['goods_storage_alarm']= intval($value['alarm']);
+                    $update['first_pay']         = floatval($value['first_pay']);   //首付
+                    $update['month_pay']         = floatval($value['month_pay']);   //月供
+                    $update['final_pay']         = floatval($value['final_pay']);   //尾款
+                    $update['storage_exp_date']  = strtotime($value['expdate']);    //库存有效期
+
+                    $specs = array_values($value['sp_value']);
+                    $split_num = 0;
+                    preg_match_all('/\d+(\.\d+)?/',$specs[1], $matches);
+                    if(isset($matches[0][0])) {
+                        $split_num = intval($matches[0][0]);
+                    }
+
+                    $update['goods_price'] = round(($update['first_pay'] + $update['month_pay'] * $split_num + $update['final_pay']), 2);
+
+                    $update['goods_serial']      = $_POST['g_serial'];
                     $update['oms_id']            = intval($value['oms_id']);
-                    $update['goods_storage_alarm']= intval($value['alarm']);
                     $update['goods_spec']        = serialize($value['sp_value']);
                     $update['goods_storage']     = $value['stock'];
                     $update['goods_state']       = $update_common['goods_state'];
@@ -471,12 +485,26 @@ class store_goods_onlineControl extends BaseSellerControl {
                     $insert['gc_id_2']           = $update_common['gc_id_2'];
                     $insert['gc_id_3']           = $update_common['gc_id_3'];
                     $insert['brand_id']          = $update_common['brand_id'];
-                    $insert['goods_price']       = $value['price'];
                     $insert['goods_promotion_price']=$value['price'];
-                    $insert['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice'];
-                    $insert['goods_serial']      = $value['sku'];
+                    //$insert['goods_price']       = $value['price'];
+                    //$insert['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice'];
+                    //$insert['goods_storage_alarm']= intval($value['alarm']);
+                    $insert['first_pay']         = floatval($value['first_pay']);   //首付
+                    $insert['month_pay']         = floatval($value['month_pay']);   //月供
+                    $insert['final_pay']         = floatval($value['final_pay']);   //尾款
+                    $insert['storage_exp_date']  = strtotime($value['expdate']);    //库存有效期
+
+                    $specs = array_values($value['sp_value']);
+                    $split_num = 0;
+                    preg_match_all('/\d+(\.\d+)?/',$specs[1], $matches);
+                    if(isset($matches[0][0])) {
+                        $split_num = intval($matches[0][0]);
+                    }
+
+                    $insert['goods_price'] = round(($insert['first_pay'] + $insert['month_pay'] * $split_num + $insert['final_pay']), 2);
+
+                    $insert['goods_serial']      = $_POST['g_serial'];
                     $insert['oms_id']            = intval($value['oms_id']);
-                    $insert['goods_storage_alarm']= intval($value['alarm']);
                     $insert['goods_spec']        = serialize($value['sp_value']);
                     $insert['goods_storage']     = $value['stock'];
                     $insert['goods_image']       = $update_common['goods_image'];
@@ -531,8 +559,8 @@ class store_goods_onlineControl extends BaseSellerControl {
                 $update['brand_id']          = $update_common['brand_id'];
                 $update['goods_price']       = $update_common['goods_price'];
                 $update['goods_marketprice'] = $update_common['goods_marketprice'];
-                $update['goods_serial']      = $update_common['goods_serial'];
                 $update['goods_storage_alarm']= $update_common['goods_storage_alarm'];
+                $update['goods_serial']      = $update_common['goods_serial'];
                 $update['goods_spec']        = serialize(null);
                 $update['goods_storage']     = intval($_POST['g_storage']);
                 $update['goods_state']       = $update_common['goods_state'];

+ 11 - 3
shop/control/store_spec.php

@@ -65,12 +65,12 @@ class store_specControl extends BaseSellerControl {
         // 更新原规格值
         if (is_array($_POST['sv']['old'])) {
             foreach ($_POST['sv']['old'] as $key=> $value) {
-                if (empty($value['name'])) {
+                if (trim($value['name']) == '') {
                     continue;
                 }
                 $where = array('sp_value_id' => $key);
                 $update = array(
-                        'sp_value_name' => $value['name'],
+                        'sp_value_name' => $this->format_spec_value($value['name']),
                         'sp_id' => $sp_id,
                         'gc_id' => $gc_id,
                         'store_id' => $_SESSION['store_id'],
@@ -89,7 +89,7 @@ class store_specControl extends BaseSellerControl {
                     continue;
                 }
                 $tmp_insert = array(
-                        'sp_value_name' => $value['name'],
+                        'sp_value_name' => $this->format_spec_value($value['name']),
                         'sp_id' => $sp_id,
                         'gc_id' => $gc_id,
                         'store_id' => $_SESSION['store_id'],
@@ -180,4 +180,12 @@ class store_specControl extends BaseSellerControl {
         Tpl::output('member_menu',$menu_array);
         Tpl::output('menu_key',$menu_key);
     }
+
+    private function format_spec_value($spec_value)
+    {
+        preg_match_all("/\d+(\.\d+)?/", $spec_value, $matches);
+        if(isset($matches[0][0])) {
+            return $matches[0][0]. "%";
+        }
+    }
 }

+ 21 - 7
shop/resource/js/store_goods_add.step2.js

@@ -106,7 +106,7 @@ $(function(){
     $('dl[nctype="spec_group_dl"]').on('click', 'input[type="checkbox"]', function(){
         pv = $(this).parents('li').find('span[nctype="pv_name"]');
         if(typeof(pv.find('input').val()) == 'undefined'){
-            pv.html('<input type="text" maxlength="20" class="text" value="'+pv.html()+'" />');
+            pv.html('<input disabled type="text" maxlength="20" class="text" value="'+pv.html()+'" />');
         }else{
             pv.html(pv.find('input').val());
         }
@@ -207,7 +207,7 @@ $(function(){
         }
         $('th[nctype="spec_name_' + data_str.id + '"]').html($(this).val());
     });
-    // 批量设置价格、库存、预警值
+    // 批量设置价格、库存、预警值、库存有效期
     $('.batch > .icon-edit').click(function(){
         $('.batch > .batch-input').hide();
         $(this).next().show();
@@ -218,22 +218,24 @@ $(function(){
     $('.batch-input > .ncsc-btn-mini').click(function(){
         var _value = $(this).prev().val();
         var _type = $(this).attr('data-type');
-        if (_type == 'price') {
+        if (_type == 'first_pay' || _type == 'month_pay' || _type == 'final_pay') {
             _value = number_format(_value, 2);
+        } else if(_type == 'expdate') {
+            //批量设置库存有效期不作处理
         } else {
             _value = parseInt(_value);
         }
-        if (_type == 'alarm' && _value > 255) {
+        /*if (_type == 'alarm' && _value > 255) {
             _value = 255;
-        }
-        if (isNaN(_value)) {
+        }*/
+        if (isNaN(_value) && _type != 'expdate') {
             _value = 0;
         }
         $('input[data_type="' + _type + '" ]').val(_value);
         $(this).parent().hide();
         $(this).prev().val('');
         if (_type == 'price') {
-            computePrice();
+            //computePrice();
         }
         if (_type == 'stock') {
             computeStock();
@@ -350,6 +352,18 @@ $(function(){
             $('input[name="g_name"]').val(car_name);
             $('input[name="g_mobile_name"]').val(car_name);
             $('#car_id').val($(this).val());
+            //获取市场指导价
+            var url = SITEURL + '/index.php?act=store_goods_add&op=ajax_get_car_price&car_id=' + $(this).val();
+            $.ajax({
+                url: url,
+                type: 'get',
+                success: function (data) {
+                    var result = JSON.parse(data);
+                    if(result) {
+                        $('input[name="g_marketprice"]').val(result.market_price);
+                    }
+                }
+            });
         }
     });
 

+ 2 - 1
shop/templates/default/css/seller_center.css

@@ -742,8 +742,9 @@ td.trigger i:hover { color: #27A9E3;}
 .spec_table { background-color: #FFF; width: 98%; margin: 10px auto; border: solid 1px #BCE8F1; box-shadow: 3px 3px 0 rgba(153,153,153,0.15);}
 .spec_table thead th { font-weight: 600; line-height: 24px; color: #3A87AD; background: #D9EDF7; height: 24px; padding: 5px 10px;}
 .spec_table tbody td { height: 30px; padding: 5px 10px; border-top: solid 1px #BCE8F1;}
-.spec_table .text.price,
+.spec_table .text.price { width: 70px;}
 .spec_table .text.stock { width: 40px;}
+.spec_table .text.expdate { width: 120px;}
 .spec_table .text.sku { width: 80px;}
 /* 电脑端手机端商品详情切换Tab */
 #ncProductDetails .ui-tabs { padding: 0;}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 47 - 35
shop/templates/default/seller/store_goods_add.step2.php