dongxiaoqin 11 kuukautta sitten
vanhempi
commit
e672a49742

+ 6 - 0
app/adminapi/controller/fault_type/FaultTypeController.php

@@ -121,4 +121,10 @@ class FaultTypeController extends BaseAdminController
         $result = FaultTypeLogic::getAllData();
         return $this->data($result);
     }
+
+    public function goodsCategory()
+    {
+        $result = FaultTypeLogic::getGoodsCategoryData();
+        return $this->data($result);
+    }
 }

+ 2 - 7
app/adminapi/lists/fault_code/FaultCodeLists.php

@@ -39,7 +39,7 @@ class FaultCodeLists extends BaseAdminDataLists implements ListsSearchInterface
     public function setSearch(): array
     {
         return [
-            '=' => ['status'],
+            '=' => ['status','type'],
             '%like%' => ['codes', 'name', 'detail'],
         ];
     }
@@ -48,12 +48,7 @@ class FaultCodeLists extends BaseAdminDataLists implements ListsSearchInterface
     {
         $where = [];
         if (isset($this->params['type_id']) && $this->params['type_id'] !== '') {
-            $pid = FaultType::where('id', $this->params['type_id'])->value('pid');
-            if ($pid == 0) {
-                $where[] = ['type_id', 'in', FaultType::where('pid', $this->params['type_id'])->column('id')];
-            } else {
-                $where[] = ['type_id', '=', $this->params['type_id']];
-            }
+            $where[] = ['type_id', '=', $this->params['type_id']];
         }
         return $where;
     }

+ 16 - 2
app/adminapi/logic/fault_type/FaultTypeLogic.php

@@ -15,9 +15,10 @@
 namespace app\adminapi\logic\fault_type;
 
 
-use app\common\model\fault_type\FaultType;
-use app\common\logic\BaseLogic;
 use think\facade\Db;
+use app\common\logic\BaseLogic;
+use app\common\model\fault_type\FaultType;
+use app\common\model\goods_category\GoodsCategory;
 
 
 /**
@@ -72,6 +73,7 @@ class FaultTypeLogic extends BaseLogic
                 'name' => $params['name'],
                 'pid' => $params['pid'],
                 'sort' => $params['sort']?:0,
+                'goods_category_id' => $params['goods_category_id'],
                 //'level' => $params['level'],
                 'status' => $params['status'],
             ]);
@@ -106,6 +108,7 @@ class FaultTypeLogic extends BaseLogic
                 'pid' => $pid,
                 'name' => $params['name'],
                 'sort' => $params['sort'],
+                'goods_category_id' => $params['goods_category_id'],
                 //'level' => $params['level'],
                 'status' => $params['status'],
             ]);
@@ -167,4 +170,15 @@ class FaultTypeLogic extends BaseLogic
         }
         return [];
     }
+
+    public static function getGoodsCategoryData()
+    {
+        $data = GoodsCategory::where('status',1)
+            ->whereRaw('pid in (select id from la_goods_category where pid in (6,62))')
+            ->field('id,pid,name,category_type')
+            ->order(['weigh'=> 'desc'])
+            ->select()
+            ->toArray();
+        return $data;
+    }
 }

+ 1 - 0
app/adminapi/service/WeCallService.php

@@ -158,6 +158,7 @@ class WeCallService
 
     private function taskStatusChange($data)
     {
+        return true;
         $taskId = $data['taskId'];
         $status = $data['status'];
         if ($taskId == $this->taskId && $status == 'COMPLETE') {

+ 4 - 4
app/adminapi/validate/fault_type/FaultTypeValidate.php

@@ -33,7 +33,7 @@ class FaultTypeValidate extends BaseValidate
     protected $rule = [
         'id' => 'require',
         'name' => 'require',
-        'pid' => 'require',
+        //'pid' => 'require',
         'sort' => 'require',
         'status' => 'require',
 
@@ -47,7 +47,7 @@ class FaultTypeValidate extends BaseValidate
     protected $field = [
         'id' => 'id',
         'name' => '分类名称',
-        'pid' => '上级id',
+        //'pid' => '上级id',
         'sort' => '排序',
         'status' => '部门状态(0停用 1正常)',
 
@@ -62,7 +62,7 @@ class FaultTypeValidate extends BaseValidate
      */
     public function sceneAdd()
     {
-        return $this->only(['name','pid','sort','status']);
+        return $this->only(['name','sort','status']);
     }
 
 
@@ -74,7 +74,7 @@ class FaultTypeValidate extends BaseValidate
      */
     public function sceneEdit()
     {
-        return $this->only(['id','name','pid','sort','status']);
+        return $this->only(['id','name','sort','status']);
     }
 
 

+ 4 - 4
app/common/command/AutomaticDispatch.php

@@ -156,9 +156,9 @@ class AutomaticDispatch extends Command
         if ($this->customerList) {
             $weCallService = new WeCallService();
             $res = $weCallService->importUser($this->customerList);
-            if (isset($res['code']) && $res['code'] == 200) {
-                $res = $weCallService->startTask();
-            }
+            // if (isset($res['code']) && $res['code'] == 200) {
+            //     $res = $weCallService->startTask();
+            // }
         }
         $this->customerList = [];
     }
@@ -275,8 +275,8 @@ class AutomaticDispatch extends Command
                             // '客户手机号'=>$item['mobile']
                         ]
                     ];
-                    return true;
                 }
+                return $res;
             }
         } 
         return false;

+ 143 - 0
app/common/command/FaultInit.php

@@ -0,0 +1,143 @@
+<?php
+namespace app\common\command;
+
+use think\facade\Db;
+use think\facade\Log;
+use think\console\Input;
+use think\console\Output;
+use think\console\Command;
+use app\common\model\fault_code\FaultCode;
+use app\common\model\fault_type\FaultType;
+
+/*
+** 家电维修故障限价数据抓取
+*/
+class FaultInit extends Command
+{
+    protected function configure()
+    {
+        $this->setName('fault_init')
+            ->setDescription('家电维修故障限价数据抓取');
+    }
+
+    protected function execute(Input $input, Output $output)
+    {
+        //挂机空调维修
+        $this->getData('10763',1,17);
+
+        //柜机空调维修
+        $this->getData('10764',1,17);
+
+        //家用中央空调维修
+        $this->getData('10765',1,17);
+
+        //空调加氟(变频挂机 1-1.5P加氟)
+        $this->getData('23153',1,52);
+
+        //空调加氟(变频挂机 1-1.5P加氟)
+        $this->getData('23153',1,52);
+
+        //空调加氟(变频挂机 2-3P加氟)
+        $this->getData('23154',1,52);
+
+        //空调加氟(定频挂机 1-1.5P加氟)
+        $this->getData('23156',1,52);
+
+        //空调加氟(定频挂机 2-3P加氟)
+        $this->getData('23157',1,52);
+
+        //空调加氟(变频柜机 2-3P加氟)
+        $this->getData('23155',1,52);
+
+        //空调加氟(定频柜机 2-3P加氟)
+        $this->getData('23158',1,52);
+        
+        //冰箱维修
+        $this->getData('10766',1,50);
+        
+        //洗衣机维修
+        $this->getData('10767',1,42);
+
+        //干洗机维修
+        $this->getData('10797',1,37);
+
+        //甩干机维修
+        $this->getData('10799',1,41);
+    
+        //燃气热水器维修
+        $this->getData('10769',1,40);
+
+        //电热水器维修
+        $this->getData('10770',1,39);
+        
+        //燃气灶维修
+        $this->getData('10772',1,38);
+
+        //油烟机维修
+        $this->getData('10773',1,43);
+
+        //制冷设备(冰柜)维修
+        $this->getData('10813',1,44);
+
+        //制冷设备(冷藏展示柜)维修
+        $this->getData('10815',1,44);
+        
+        //制冷设备(自动售卖机)维修
+        $this->getData('10816',1,44);
+    }
+
+    /**
+     * 请求数据
+     */
+    protected function getData($productId, $category_type, $goods_category_id)
+    {
+        $type_list = [
+            '维修项目' => '1',
+            '特殊项目' => '2', 
+            '仅检测' => '3',
+            '仅维修' => '4',
+            '检测+维修' => '5',
+            '服务收费' => '6',
+            '特殊故障' => '7',
+            '产品销售' => '8',
+        ];
+        $params = [
+            'cityId' => '500100',
+            'productId' => $productId,
+            'cooperationId' => '41100',
+        ];
+        $url = 'https://cx-api.zmn.cn/Miniprograms/Product/GetPrciceDesV2';
+        $response = http_request($url, $params, []);
+        try {
+
+            if (!empty($response['data']['chargingStandardList'])) {
+                $data = $response['data']['chargingStandardList'];
+                foreach($data as $item) {
+                    $res = FaultType::create([
+                        'name' => $item['productName'], //分类名称
+                        'category_type' => $category_type,
+                        'goods_category_id' => $goods_category_id,
+                        'pid' => 0
+                    ]);
+                    $type_id = $res->id;
+
+                    $list = $item['itemTypeList'];//故障限价列表
+                    foreach($list as $v) {
+                        $type = isset($type_list[$v['itemTypeName']]) ? $type_list[$v['itemTypeName']] : 0;
+                        foreach($v['itemList'] as $vv) {
+                            FaultCode::create([
+                                'type_id' => $type_id,
+                                'name' => $vv['itemName'],
+                                'price' => $vv['price'],
+                                'type' => $type,
+                            ]);
+                        }
+                    }
+                }
+            }
+        } catch (\Exception $e) {
+            Log::error('家电维修故障限价数据抓取失败:'.$e->getMessage());
+        }
+    }
+
+}

+ 2 - 0
config/console.php

@@ -25,5 +25,7 @@ return [
         'group_order' => 'app\common\command\GroupOrder',
         // 导出表格
         'excel_export' => 'app\common\command\ExcelExport',
+        //维修故障限价数据初始化抓取
+        'fault_init' => 'app\common\command\FaultInit',
     ],
 ];