Procházet zdrojové kódy

产品规格可以修改、修改今天收货的

dong025 před 4 dny
rodič
revize
48b444c140

+ 132 - 45
app/admin/controller/goods/ImportList.php

@@ -44,11 +44,11 @@ class ImportList extends Backend
         $sql_restul = $shopList->alias('s')
             ->join("yun_customer c", "s.customer_id = c.id", "INNER")
             ->where(['s.status' => 1, 'c.status' => 1])
-            ->field(['s.id','s.shop_id', 's.name', 'c.name' => 'nickname'])
+            ->field(['s.id', 's.shop_id', 's.name', 'c.name' => 'nickname'])
             ->select();
         $arr = [];
         foreach ($sql_restul as $item) {
-            $arr[$item['id']] = $item['name'] .'('.'店铺id:'.$item['shop_id'].',客户:' . $item['nickname'] . ')';
+            $arr[$item['id']] = $item['name'] . '(' . '店铺id:' . $item['shop_id'] . ',客户:' . $item['nickname'] . ')';
         }
 
         return $this->jsonSuccess('', $arr);
@@ -113,11 +113,11 @@ class ImportList extends Backend
             $sql_restul = $shopList->alias('s')
                 ->join("yun_customer c", "s.customer_id = c.id", "INNER")
                 ->where(['s.status' => 1, 'c.status' => 1])
-                ->field(['s.id','s.shop_id', 's.name', 'c.name' => 'nickname'])
+                ->field(['s.id', 's.shop_id', 's.name', 'c.name' => 'nickname'])
                 ->select();
             $arr = [];
             foreach ($sql_restul as $item) {
-                $arr[$item['id']] = $item['name'] .'('.'店铺id:'.$item['shop_id'].',客户:' . $item['nickname'] . ')';
+                $arr[$item['id']] = $item['name'] . '(' . '店铺id:' . $item['shop_id'] . ',客户:' . $item['nickname'] . ')';
             }
 
             $this->assign('shopList', $arr);
@@ -169,6 +169,7 @@ class ImportList extends Backend
     public function specs(mixed $row = null)
     {
         $ids = $this->request->param('ids');
+        $importSku = new ImportSku();
         if (!$row || is_array($row)) {
             $row = $this->model->find($ids);
         }
@@ -187,8 +188,12 @@ class ImportList extends Backend
             $shopListModel = new ShopListModel();
 
             $rows = $shopListModel::where('shop_id', $shop_id)->where('status', 1)->find();
+            $sql_data = $importSku->where(['shop_id' => $row['shop_id'], 'sku_id' => $row['sku_id']])->find();
+            
             $this->assign('rows', $rows->type_spec ?? '');
             $this->assign('row', $row);
+            $this->assign('now_spec_id', $sql_data['spec_id']);
+            
             return $this->fetch();
         }
         $params = $this->request->post("");
@@ -197,53 +202,135 @@ class ImportList extends Backend
         Db::startTrans();
         try {
 
-            //插入规格
-            ImportSku::insertSpecs($row['shop_id'], $row['sku_id'], (int)$params['all_data'][0]['type_id'], (int)$params['all_data'][0]['id']);
+            $status = $row['status'];
+            $time = time();
 
-            //查看有多少规格
-            $list = $this->model::where('shop_id', $row['shop_id'])->where('sku_id', $row['sku_id'])->where('status', 2)->select();
             $shopList = new ShopList();
             $productConfig = new ProductConfig();
             $shopDelivery = new ShopDelivery();
             $customerSpec = new CustomerSpec();
-            $importSku = new ImportSku();
-            $shopDelivery_list=[];
-            $import_list=[];
-            foreach ($list as $item) {
-                //插入发货数据
-                $res=JuShuiTanService::setAdditionalPrice(
-                    $importSku,
-                    $shopList,
-                    $productConfig,
-                    $shopDelivery,
-                    $customerSpec,
-                    $item['shop_id'],
-                    $item['sku_id'],
-                    $params['all_data'][0]['type_id'],
-                    $params['all_data'][0]['id'],
-                    $params['all_data'][0]['name'],
-                    $item
-                );
-                $getPackSpecsFee=$res['getPackSpecsFee'];
-                $shopDelivery_list[]=$res['shopDelivery'];
-                $import_list_item=[
-                    'id'=>$item['id'],
-                    'pack_specs_id'=>$getPackSpecsFee['data']['id'],
-                    'labor_cost_money'=>$getPackSpecsFee['data']['labor_cost_money'],
-                    'one_surcharge_money'=>$getPackSpecsFee['one_surcharge_money'],
-                    'two_surcharge_money'=>$getPackSpecsFee['two_surcharge_money'],
-                    'status' => 3
-                ];
-                $import_list[]=$import_list_item;
-                $count++;
-                // $count += $item->save(['pack_specs_id'=>$getPackSpecsFee['data']['id'],'labor_cost_money'=>$getPackSpecsFee['data']['labor_cost_money'],'one_surcharge_money'=>$getPackSpecsFee['one_surcharge_money'],'two_surcharge_money'=>$getPackSpecsFee['two_surcharge_money'],'status' => 3]);
-            }
-            $this->model->saveAll($import_list);
-            $shopDelivery->saveAll($shopDelivery_list);
-            if ($this->callback) {
-                $callback = $this->callback;
-                $callback($ids);
+            
+            $shopDelivery_list = [];
+            $import_list = [];
+
+            $shopDelivery_updata_list=[];
+            $todayStart = date('Y-m-d', $time);
+            $todayStart=$todayStart.' 00:00:00';
+            switch ($status) {
+                case 2:
+                    //插入规格
+                    ImportSku::insertSpecs($row['shop_id'], $row['sku_id'], (int)$params['all_data'][0]['type_id'], (int)$params['all_data'][0]['id']);
+
+                    //查看有多少规格
+                    $list = $this->model::where('shop_id', $row['shop_id'])->where('sku_id', $row['sku_id'])->where('status', 2)->select();
+
+                    foreach ($list as $item) {
+                        //插入发货数据
+                        $res = JuShuiTanService::setAdditionalPrice(
+                            $importSku,
+                            $shopList,
+                            $productConfig,
+                            $shopDelivery,
+                            $customerSpec,
+                            $item['shop_id'],
+                            $item['sku_id'],
+                            $params['all_data'][0]['type_id'],
+                            $params['all_data'][0]['id'],
+                            $params['all_data'][0]['name'],
+                            $item
+                        );
+                        $getPackSpecsFee = $res['getPackSpecsFee'];
+                        $shopDelivery_list[] = $res['shopDelivery'];
+                        $import_list_item = [
+                            'id' => $item['id'],
+                            'pack_specs_id' => $getPackSpecsFee['data']['id'],
+                            'labor_cost_money' => $getPackSpecsFee['data']['labor_cost_money'],
+                            'one_surcharge_money' => $getPackSpecsFee['one_surcharge_money'],
+                            'two_surcharge_money' => $getPackSpecsFee['two_surcharge_money'],
+                            'status' => 3
+                        ];
+                        $import_list[] = $import_list_item;
+                        $count++;
+                    }
+                    $this->model->saveAll($import_list);
+                    $shopDelivery->saveAll($shopDelivery_list);
+                    break;
+                case 3:
+                    //修改规格
+                    $importSku = new ImportSku();
+                    $sql_data = $importSku->where(['shop_id' => $row['shop_id'], 'sku_id' => $row['sku_id']])->find();
+
+                    $result = $sql_data->save([
+                        'variety_id'    => (int)$params['all_data'][0]['type_id'],
+                        'spec_id'    => (int)$params['all_data'][0]['id']
+                    ]);
+                    if (!$result) $this->error(__('没有数据被更新'));
+                    //查看有多少规格
+                    $where=[];
+                    $where[] = ['shop_id', '=', $row['shop_id']];
+                    $where[] = ['sku_id', '=', $row['sku_id']];
+                    $where[] = ['consign_time','>=',$todayStart];
+
+                    $whereOr=[];
+                    $whereOr[] = ['shop_id', '=', $row['shop_id']];
+                    $whereOr[] = ['sku_id', '=', $row['sku_id']];
+                    $whereOr[] = ['status','=',2];
+
+                    $list = $this->model::where($where)->whereOr($whereOr)->select();
+                    
+                    foreach ($list as $item) {
+                        //插入发货数据
+                        $res = JuShuiTanService::setAdditionalPrice(
+                            $importSku,
+                            $shopList,
+                            $productConfig,
+                            $shopDelivery,
+                            $customerSpec,
+                            $item['shop_id'],
+                            $item['sku_id'],
+                            $params['all_data'][0]['type_id'],
+                            $params['all_data'][0]['id'],
+                            $params['all_data'][0]['name'],
+                            $item
+                        );
+                        $getPackSpecsFee = $res['getPackSpecsFee'];
+                        
+
+                        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'];
+                            }
+                            
+                        }
+
+                        $import_list_item = [
+                            'id' => $item['id'],
+                            'pack_specs_id' => $getPackSpecsFee['data']['id'],
+                            'labor_cost_money' => $getPackSpecsFee['data']['labor_cost_money'],
+                            'one_surcharge_money' => $getPackSpecsFee['one_surcharge_money'],
+                            '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...
+                    break;
             }
+
             Db::commit();
         } catch (\Exception $e) {
             Db::rollback();

+ 1 - 1
app/admin/controller/goods/PackSpecs.php

@@ -64,7 +64,7 @@ class PackSpecs extends Backend
         
     }
 
-    //添加
+    //修改
     #[Route("GET,POST","edit")]
     public function edit(mixed $row=null)
     {

+ 16 - 2
app/admin/service/JuShuiTanService.php

@@ -11,7 +11,7 @@ declare(strict_types=1);
 namespace app\admin\service;
 
 use app\common\model\ImportList;
-
+use app\common\model\ShopDelivery;
 class JuShuiTanService {
 
     /** 加收价格 
@@ -20,6 +20,8 @@ class JuShuiTanService {
      * @param array $item
      * @return int
      */
+  
+
     public static function getAdditionalPrice(object $shopList, object $sku, object $productConfig, object $shopDelivery, object $customerSpec, array $item)
     {
         $status = 1;
@@ -174,7 +176,7 @@ class JuShuiTanService {
             'waybill_no'    => $item['waybill_no'],
             'region'        => $item['province'].' '.$item['city'],
             'other_price'   => $other_price,
-            'ship_date'     => $item['deliveryDate'],
+            'ship_date'     => $item['consign_time'],
             'incubator'   => $getPackSpecsFee['pack_specs_type'],
             'insulation_money'   => $getPackSpecsFee['surcharge_money'],
             'labor_cost_money'   => $getPackSpecsFee['data']['labor_cost_money']
@@ -278,4 +280,16 @@ class JuShuiTanService {
         
         return $res;
     }
+    // 根据快递订单号获取发货记录中的订单id
+    
+    public static function get_shopDelivery_id($waybill_no){
+        $shopDeliveryModel=new ShopDelivery();
+        $order_data=$shopDeliveryModel->where('waybill_no',$waybill_no)->find();
+        if(empty($order_data)){
+            return 0;
+        }else{
+            return $order_data['id'];
+        }
+        
+    }
 }

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

@@ -61,11 +61,26 @@
                 { field: "two_surcharge_money", title: "双层保温金额", operate: false },
                 // {field:"weight",title:"重量(斤)",operate: false},
                 { field: "consign_time", title: "发货时间", operate: "daterange", formatter: Yunqi.formatter.datetime },
-                
+
                 // {field:"user_id",title:"录入人",operate: false},
                 { field: "createtime", title: "创建时间", operate: false, formatter: Yunqi.formatter.datetime },
                 { field: "updatetime", title: "修改时间", operate: false, formatter: Yunqi.formatter.datetime },
-                { field: "status",fixed: 'right', title: "状态", operate: "select", searchList: { 1: "无店铺", 2: "无Sku", 3: "正常" }, formatter: Yunqi.formatter.tags },
+                {
+                    field: "status", fixed: 'right', title: "状态", operate: "select", searchList: { 1: "无店铺", 2: "无Sku", 3: "正常" }, formatter: function (data, row) {
+                        let tag = Yunqi.formatter.tag;
+                        if (row.status == 1) {
+                            tag.value = '无店铺';
+                            tag.type = 'danger';
+                        } else if (row.status == 2) {
+                            tag.value = '无Sku';
+                            tag.type = 'warning';
+                        } else if (row.status == 3) {
+                            tag.value = '正常';
+                            tag.type = 'success';
+                        }
+                        return tag;
+                    }
+                },
                 {
                     field: 'operate',
                     fixed: 'right',
@@ -92,6 +107,16 @@
                                 return row.status == 2;
                             }
                         },
+                        edit: {
+                            tooltip: true,
+                            icon: 'fa fa-pencil',
+                            type: 'primary',
+                            text: __('修改关联规格'),
+                            method: 'specs',
+                            visible: function (row, index) {
+                                return row.status == 3;
+                            }
+                        },
                         // del: true
                     }
                 }
@@ -130,5 +155,5 @@
     }
 </script>
 <style>
-    
+
 </style>

+ 25 - 70
app/admin/view/goods/import_list/specs.html

@@ -6,16 +6,17 @@
             <el-table :data="tableData" style="width: 100%" border :ref="'multipleTable_' + tabValue" stripe
                 highlight-current-row @select="handleSelectionChange" @select-all="handleAllSelect"
                 @current-change="handleCurrentChange">
-                <!-- <el-table-column type="index" width="55">
-                </el-table-column> -->
-                <el-table-column prop="selected_d" label="店铺关联规格" width="90" height="40">
+                <el-table-column type="index" width="55">
+                </el-table-column>
+                <!-- <el-table-column prop="selected_d" label="店铺关联规格" width="90" height="40">
                    
                    <template #default="{row}">
                         <el-checkbox v-model="row.selected_d" size="large" disabled/>
                     </template>
-                </el-table-column>
+                </el-table-column> -->
                 <el-table-column prop="name" label="规格" align="center">
                 </el-table-column>
+                
                 <!-- <el-table-column prop="packet" label="包装箱" align="center">
                     <template #default="{row}">
                         <span>{{options[row.box_id]}}</span>
@@ -53,7 +54,8 @@
             chooseSpec: [], // 当前分类选中的规格  
             allData: {},
             type: 0, // 1编辑 0新增,
-            shop_allData: []
+            shop_allData: [],
+            now_spec_id: 0
         },
         methods: {
             onSubmit() {
@@ -75,12 +77,13 @@
             },
             handleAllSelect(e) {
                 this.allData[this.tabValue] = e || []
+
             },
             handleCurrentChange(e) {
                 this.allData[this.tabValue] = e || []
             },
             handleSelectionChange(e) {
-                console.log(this.allData, "=====this.allData")
+
             },
             handleClick(data, row) {
                 // 品种切换事件 可以在这里请求规格接口
@@ -96,81 +99,39 @@
 
                 //获取规格 ;
                 Yunqi.ajax.get('shop/customer_spec/get_box', { type_id: this.tabValue }, false, false, true).then(res => {
+
                     //编辑数据
                     if (res.length > 0) {
                         for (var key in Object(res)) {
                             let index = this.tableData.findIndex(item => item.id == res[key]['id']);
                             const isExist = this.shop_allData.includes(res[key]['id'])
+                            let now_spec_state = this.now_spec_id == res[key]['id'] ? true : false;
                             if (index != -1) {
                                 this.tableData.splice(index, 1)
                             } else {
+                                let item = {
+                                    id: res[key]['id'],
+                                    name: res[key]['title'],
+                                    type_id: this.tabValue,
+                                    selected_d: isExist,
+                                    now_spec_state: now_spec_state
+                                }
+                                this.tableData.push(item);
+                                // if(now_spec_state){
+                                //     this.allData[this.tabValue] = item
+                                // }
 
-                                this.tableData.push({ name: res[key]['title'], id: res[key]['id'], type_id: this.tabValue, selected_d: isExist });
                             }
 
                         }
-                        // this.$nextTick(() => {
-                        //     const tableRef = this.$refs['multipleTable_' + this.tabValue];
-                        //     if (this.type == 0 && this.allData[this.tabValue]?.length > 0 && tableRef) {
-                        //         this.tableData.forEach((item, index) => {
-                        //             const matched = this.allData[this.tabValue].find(row => {
-                        //                 return row.id == item.id
-                        //             });
-                        //             if (matched) {
-                        //                 this.tableData[index] = matched
-                        //             }
-                        //         })
-                        //         this.allData[this.tabValue].forEach(selected => {
-                        //             const matched = this.tableData.find(row => row.id === selected.id);
-                        //             if (matched) {
-                        //                 this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
-                        //             }
-                        //         });
-                        //     }
-                        //     else if (this.type == 1 && this.allData[Number(this.tabValue)]) {
-                        //         this.tableData.forEach((item, index) => {
-                        //             const matched = this.allData[Number(this.tabValue)].find(row => {
-                        //                 if (row.product_id) {
-                        //                     return row.product_id == item.value
-                        //                 } else {
-                        //                     return row.value == item.value
-                        //                 }
-                        //             });
-                        //             if (matched) {
-                        //                 // this.tableData[index] = { name: 'kam', value: 3, price: '111', type_id: '4', packet: '3' }
-                        //                 if (matched.product_id) {
-                        //                     this.tableData[index].name = matched.name
-                        //                     this.tableData[index].box_name = matched.box_name
-                        //                     this.tableData[index].type_name = matched.type_name
-                        //                     this.tableData[index].price = matched.price
-                        //                     this.tableData[index].packet = matched.box_id != 0 ? matched?.box_id.toString() : ""
-                        //                 } else {
-                        //                     this.tableData[index] = matched
-                        //                 }
-                        //             }
-                        //         })
-                        //         this.allData[Number(this.tabValue)].forEach(selected => {
-                        //             const matched = this.tableData.find(row => {
-                        //                 if (selected.product_id) {
-                        //                     return selected.product_id == row.value
-                        //                 } else {
-                        //                     return row.value === selected.value
-                        //                 }
-                        //             });
-                        //             if (matched) {
-                        //                 this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
-                        //             }
-                        //         });
-                        //         console.log(this.allData)
-                        //     }
-                        // });
+                        
                     }
                 });
             }
 
         },
         onLoad: function (query) {
-
+            this.now_spec_id = Yunqi.data.now_spec_id;
             let rows = Yunqi.data.rows;
             if (rows) {
                 const grouped = JSON.parse(rows).reduce((acc, item) => {
@@ -196,11 +157,5 @@
     }
 </script>
 <style>
-    .el-table_1_column_1{
-        padding: 0px !important;
-    }
-    .el-checkbox__input.is-checked .el-checkbox__inner {
-        background-color: var(--el-checkbox-checked-bg-color) !important;
-        border-color: var(--el-checkbox-checked-input-border-color) !important;
-    }
+    
 </style>