Kaynağa Gözat

无店铺、无Sku数量提示,修改关联规格优化

dong025 1 hafta önce
ebeveyn
işleme
bbba6dbf13

+ 41 - 35
app/admin/controller/goods/ImportList.php

@@ -26,17 +26,16 @@ class ImportList extends Backend
     use Actions {
         index as private _index;
         del as private _del;
-    
     }
-    private $typeList=null;
-    private $tabValue=null;
-    
+    private $typeList = null;
+    private $tabValue = null;
+
     protected function _initialize()
     {
         parent::_initialize();
         $this->model = new ImportListModel();
-        $this->typeList=StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title', 'id');
-        $this->tabValue=array_keys($this->typeList)[0]?? null;
+        $this->typeList = StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title', 'id');
+        $this->tabValue = array_keys($this->typeList)[0] ?? null;
         // $this->assign('shopList', ShopList::where('status', 1)->column('name', 'id'));
         $this->assign('typeList',  $this->typeList);
         $this->assign('packingList', StockConfig::where('type_id', 'packing_box')->column('title', 'id'));
@@ -102,7 +101,15 @@ class ImportList extends Backend
 
                 return $item;
             });
-        $result = ['total' => $list->total(), 'rows' => $list->items()];
+
+        $shops_num = $this->model
+            ->where('status', 1)
+            ->sum('status');
+        $specs_num = $this->model
+            ->where('status', 2)
+            ->sum('status');
+
+        $result = ['total' => $list->total(), 'rows' => $list->items(), 'shops_num' => $shops_num, 'specs_num' => $specs_num];
         return json($result);
     }
 
@@ -193,20 +200,20 @@ class ImportList extends Backend
             $shopListModel = new ShopListModel();
 
             $rows = $shopListModel::where('shop_id', $shop_id)->where('status', 1)->find();
-            
+
             //修改规格
             $importSku = new ImportSku();
             $sql_data = $importSku->where(['shop_id' => $row['shop_id'], 'sku_id' => $row['sku_id']])->find();
-            $spec_id=0;
-            if(!empty($sql_data)){
-                $this->tabValue=$sql_data['variety_id'];
-                $spec_id=$sql_data['spec_id'];
+            $spec_id = 0;
+            if (!empty($sql_data)) {
+                $this->tabValue = $sql_data['variety_id'];
+                $spec_id = $sql_data['spec_id'];
             }
-            $this->assign('tabValue',$this->tabValue.'');
-            $this->assign('spec_id',$spec_id);
+            $this->assign('tabValue', $this->tabValue . '');
+            $this->assign('spec_id', $spec_id);
             $this->assign('rows', $rows->type_spec ?? '');
             $this->assign('row', $row);
-            
+
             return $this->fetch();
         }
         $params = $this->request->post("");
@@ -222,13 +229,13 @@ class ImportList extends Backend
             $productConfig = new ProductConfig();
             $shopDelivery = new ShopDelivery();
             $customerSpec = new CustomerSpec();
-            
+
             $shopDelivery_list = [];
             $import_list = [];
 
-            $shopDelivery_updata_list=[];
+            $shopDelivery_updata_list = [];
             $todayStart = date('Y-m-d', $time);
-            $todayStart=$todayStart.' 00:00:00';
+            $todayStart = $todayStart . ' 00:00:00';
             switch ($status) {
                 case 2:
                     //插入规格
@@ -279,18 +286,18 @@ class ImportList extends Backend
                     ]);
                     if (!$result) $this->error(__('没有数据被更新'));
                     //查看有多少规格
-                    $where=[];
+                    $where = [];
                     $where[] = ['shop_id', '=', $row['shop_id']];
                     $where[] = ['sku_id', '=', $row['sku_id']];
-                    $where[] = ['consign_time','>=',$todayStart];
+                    $where[] = ['consign_time', '>=', $todayStart];
 
-                    $whereOr=[];
+                    $whereOr = [];
                     $whereOr[] = ['shop_id', '=', $row['shop_id']];
                     $whereOr[] = ['sku_id', '=', $row['sku_id']];
-                    $whereOr[] = ['status','=',2];
+                    $whereOr[] = ['status', '=', 2];
 
                     $list = $this->model::where($where)->whereOr($whereOr)->select();
-                    
+
                     foreach ($list as $item) {
                         //插入发货数据
                         $res = JuShuiTanService::setAdditionalPrice(
@@ -307,19 +314,18 @@ class ImportList extends Backend
                             $item
                         );
                         $getPackSpecsFee = $res['getPackSpecsFee'];
-                        
 
-                        if($item['status']==2){
+
+                        if ($item['status'] == 2) {
                             $shopDelivery_list[] = $res['shopDelivery'];
-                        }else if($item['status']==3){
-                            $waybill_no=$res['shopDelivery']['waybill_no'];
-                            $shopDelivery_id=JuShuiTanService::get_shopDelivery_id($waybill_no);
-                            if($shopDelivery_id>0){
-                                $res['shopDelivery']['id']=$shopDelivery_id;
-                                $res['shopDelivery']['updatetime']=$time;
-                                $shopDelivery_updata_list[]=$res['shopDelivery'];
+                        } else if ($item['status'] == 3) {
+                            $waybill_no = $res['shopDelivery']['waybill_no'];
+                            $shopDelivery_id = JuShuiTanService::get_shopDelivery_id($waybill_no);
+                            if ($shopDelivery_id > 0) {
+                                $res['shopDelivery']['id'] = $shopDelivery_id;
+                                $res['shopDelivery']['updatetime'] = $time;
+                                $shopDelivery_updata_list[] = $res['shopDelivery'];
                             }
-                            
                         }
 
                         $import_list_item = [
@@ -330,14 +336,14 @@ class ImportList extends Backend
                             'two_surcharge_money' => $getPackSpecsFee['two_surcharge_money'],
                             'status' => 3
                         ];
-                       
+
                         $import_list[] = $import_list_item;
                         $count++;
                     }
                     $this->model->saveAll($import_list);
                     $shopDelivery->saveAll($shopDelivery_list);
                     $shopDelivery->saveAll($shopDelivery_updata_list);
-                    
+
                     break;
                 default:
                     # code...

+ 23 - 3
app/admin/view/goods/import_list/index.html

@@ -4,7 +4,8 @@
                
                     del:{:$auth->check('app\\admin\\controller\\goods\\ImportList','del')},
          
-                }" :extend="extend">
+                }" :extend="extend" :total-arr="totalArr" :is-showtotal="true"
+            @data-loaded="handleData">
         </yun-table>
     </el-card>
 </template>
@@ -111,7 +112,7 @@
                             tooltip: true,
                             icon: 'fa fa-pencil',
                             type: 'primary',
-                            text: __('修改关联规格'),
+                            text: __('修改关联规格,且只能修改当天发货订单'),
                             method: 'specs',
                             visible: function (row, index) {
                                 return row.status == 3;
@@ -120,9 +121,24 @@
                         // del: true
                     }
                 }
-            ]
+            ],
+            totalArr: [
+
+            ],
         },
         methods: {
+            handleData(data) {
+                console.log(data)
+                this.totalArr = [
+                    {
+                        name: "无店铺",
+                        value: data.shops_num
+                    }, {
+                        name: "无Sku",
+                        value: data.specs_num
+                    }
+                ]
+            },
             shops: function (row) {
                 let that = this;
                 Yunqi.api.open({
@@ -151,6 +167,10 @@
 
             },
 
+        },
+        onLoad: function (query) {
+
+
         }
     }
 </script>

+ 9 - 2
app/admin/view/goods/import_list/specs.html

@@ -69,13 +69,20 @@
                         //倒计时刷新窗口
                         setTimeout(() => {
                             Yunqi.api.closelayer(Yunqi.app.window.id, true);
-                            loading.close()
+                            
                         }, 1000);
 
                     } else {
                         Yunqi.alert(__('请选择规格'), __('温馨提示'), { type: 'error' });
-                        loading.close()
+                        
                     }
+                    setTimeout(() => {
+                            loading.close()
+                        }, 1000);
+                }).catch(err=>{
+                        setTimeout(() => {
+                            loading.close()
+                        }, 1000);
                 });
             },