Просмотр исходного кода

Merge branch 'master' into group_0313

dongxiaoqin 1 год назад
Родитель
Сommit
99c3d8ca39

+ 2 - 1
app/adminapi/controller/export/ExportController.php

@@ -113,6 +113,7 @@ class ExportController extends BaseAdminController
     {
         $params = $this->request->get();
         if(empty($params['download_type'])) return $this->fail('参数错误');
+        $params['admin_id'] = $this->adminId??0;
         $result = ExportLogic::add([
             'download_type' => $params['download_type']??0,
             'params' => $params,
@@ -123,7 +124,7 @@ class ExportController extends BaseAdminController
             return $this->fail(ExportLogic::getError());
         }
         // 暂时 - 立即生成导出文件
-        (new ExcelExportService)->download($result);
+        if(!isset($params['cmd'])) (new ExcelExportService)->download($result);
         return $this->success('添加成功-'.$result, [], 1, 1);
     }
 

+ 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;
     }

+ 57 - 1
app/adminapi/lists/master_worker_register/MasterWorkerRegisterLists.php

@@ -16,6 +16,8 @@ namespace app\adminapi\lists\master_worker_register;
 
 
 use app\adminapi\lists\BaseAdminDataLists;
+use app\adminapi\logic\auth\AdminLogic;
+use app\adminapi\logic\ConfigLogic;
 use app\common\model\master_worker_register\MasterWorkerRegister;
 use app\common\lists\ListsSearchInterface;
 
@@ -50,7 +52,11 @@ class MasterWorkerRegisterLists extends BaseAdminDataLists implements ListsSearc
      */
     public function queryDataWhere(){
         $where = [];
-        $data_rules = $this->adminInfo['data_rules'];
+        if(isset($this->params['admin_id']) && $this->params['admin_id']){
+            $data_rules = AdminLogic::getDataPermissions($this->params['admin_id']);
+        }else{
+            $data_rules = $this->adminInfo['data_rules'];
+        }
         if (isset($data_rules['province']) && !empty($data_rules['province'])) {
             $where[] = ['province','in' ,$data_rules['province']];
         }
@@ -99,4 +105,54 @@ class MasterWorkerRegisterLists extends BaseAdminDataLists implements ListsSearc
         return MasterWorkerRegister::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
     }
 
+    public function setExcelComplexFields(): array
+    {
+        $zh_cn_fields = [
+            '工程师名称','手机号','入驻时间','工作经验','是否有证件', '特种证名称','证件照片','地区',
+            '销售名称','销售手机号'
+        ];
+        $data_fields = ['name','mobile','create_time',
+            function($row){
+                $dictType = array_column(\app\adminapi\logic\ConfigLogic::getDictByType('worker_exp_type')['worker_exp_type'],'name','value');
+                return $dictType[$row['maintain_exp_type']]??'';
+            },function($row){ return $row['is_credential']? '有特种证' : '无特种证'; },function($row){ return $row['credential_name']? implode('、',$row['credential_name']) : ''; }
+            ,function($row){
+                if(empty($row['credential_images'])) return '';
+                $images = '';
+                if(is_array($row['credential_images'])){
+                    $images = implode("\r\n",$row['credential_images']);
+                }
+                return $images;
+            },'area_name',
+            function($row){ return empty($row['sale'])? '' :$row['sale']['sale_name']??''; },
+            function($row){ return empty($row['sale'])? '' :$row['sale']['mobile']??''; }
+        ];
+        /*$data_fields = [
+            function($row){
+                $dictType = array_column(\app\adminapi\logic\ConfigLogic::getDictByType('worker_exp_type')['worker_exp_type'],'name','value');
+                return $dictType[$row['maintain_exp_type']]??'';
+            },function($row){ return $row['is_credential']? '有特种证' : '无特种证'; },'credential_name'
+            ,function($row){
+                    if(empty($row['credential_images'])) return '';
+                    $images = '';
+                    if(is_array($row['credential_images'])){
+                        $images = implode(',',$row['credential_images']);
+                    }
+                    return $images;
+            },'area_name',function($row){
+                $dictType = array_column(\app\adminapi\logic\ConfigLogic::getDictByType('worker_vehicle_type')['worker_vehicle_type'],'name','value');
+                return $dictType[$row['vehicle_type']]??'';
+            },
+            function($row){ return $row['sale']['sale_name']??''; },
+            function($row){ return $row['sale']['mobile']??''; },
+            'name','age','mobile','address','create_time',function($row){
+                $dictType = array_column(\app\adminapi\logic\ConfigLogic::getDictByType('audit_state')['audit_state'],'name','value');
+                return $dictType[$row['status']]??'';
+            },'update_time'
+        ];*/
+        return [
+            'zh_cn_fields' => $zh_cn_fields,
+            'data_fields' => $data_fields
+        ];
+    }
 }

+ 3 - 3
app/adminapi/lists/sale/SaleCommissionLists.php

@@ -128,7 +128,7 @@ class SaleCommissionLists extends BaseAdminDataLists implements ListsSearchInter
             $item['group_counts'] = $group_counts[$item['id']]??0;
             $item['group_merits'] = $this->groupMerits($group_counts[$item['id']]??0);
 
-            $item['all_merits'] = $item['passes_merits'] + $item['property_merits'] + $item['group_merits'];
+            $item['all_merits'] = (float)$item['passes_merits'] + (float)$item['property_merits'] + (float)$item['group_merits'];
         }
         return $list;
     }
@@ -153,7 +153,7 @@ class SaleCommissionLists extends BaseAdminDataLists implements ListsSearchInter
         ];
         $data_fields = [function($row){ return $row['saleGroupInfo']['sale_name']??''; },'sale_name','mobile',
             'passes_counts','passes_merits','property_counts','property_merits','group_counts','group_merits','all_merits'
-            ,'start_date','end_date'
+            ,function($row){ return $row['start_date']?date('Y-m-d',$row['start_date']):''; },function($row){ return $row['end_date']?date('Y-m-d',$row['end_date']):''; }
         ];
         return [
             'zh_cn_fields' => $zh_cn_fields,
@@ -252,7 +252,7 @@ class SaleCommissionLists extends BaseAdminDataLists implements ListsSearchInter
 
     public function groupMerits($value)
     {
-        return $value;
+        return bcmul($value, 0.05,2);
     }
 
 

+ 1 - 1
app/adminapi/lists/sale/SaleMasterWorkerLists.php

@@ -156,7 +156,7 @@ class SaleMasterWorkerLists extends BaseAdminDataLists implements ListsSearchInt
         $data_fields = [
             function($row){ return $row['sale']['sale_name']??''; },
             function($row){ return $row['sale']['saleGroupInfo']['sale_name']??''; },
-            'register_count','settled_count','start_date','end_date'
+            'register_count','settled_count',function($row){ return $row['start_date']?date('Y-m-d',$row['start_date']):''; },function($row){ return $row['end_date']?date('Y-m-d',$row['end_date']):''; }
         ];
         return [
             'zh_cn_fields' => $zh_cn_fields,

+ 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;

+ 42 - 0
app/common/command/ExcelExport.php

@@ -0,0 +1,42 @@
+<?php
+namespace app\common\command;
+
+use app\common\model\bank_account\BankAccount;
+use app\common\model\export\Export;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerInfo;
+use app\common\service\ExcelExportService;
+use think\console\Command;
+use think\console\Input;
+use think\console\Output;
+use think\facade\Log;
+
+/**
+ *  表格导出
+ * Class OpenObtainOrder
+ * @package app\command
+ */
+class ExcelExport extends Command
+{
+    protected function configure()
+    {
+        $this->setName('excel_export')->setDescription('表格导出');
+    }
+
+    protected function execute(Input $input, Output $output)
+    {
+        set_time_limit(180);
+        ini_set('memory_limit', '1024M');
+        try {
+            Export::where('generate_status',0)->where('createtime','<',(time()-86400*2))->delete();
+            $result = Export::where('generate_status',0)->findOrEmpty();
+            if(!$result->isEmpty()){
+                (new ExcelExportService)->download($result->id,true);
+            }
+            return true;
+        } catch (\Exception $e) {
+            Log::write('ExcelExport:'.$e->getMessage());
+            return $e->getMessage();
+        }
+    }
+}

+ 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());
+        }
+    }
+
+}

+ 6 - 2
app/common/service/ExcelExportService.php

@@ -46,7 +46,7 @@ class ExcelExportService
         $this->download_type = config('export.download_type');
         $this->sheet = new ExcelWriter();
     }
-    public function download($id)
+    public function download($id,$isCmd = false)
     {
         try{
             $infoExport = Export::findOrEmpty($id);
@@ -64,12 +64,16 @@ class ExcelExportService
                         break;
                     default:
                         $use_file = explode('.',$download_fun);
-                        $this->getDownloadFileUrl(invoke(str_replace('.', '\\', App::getNamespace() . '\\lists\\' . $use_file[0] . '\\'. ucwords($use_file[1]))));
+                        $this->sheet->savePath = ($isCmd?'./public/exports/':'');
+                        $this->getDownloadFileUrl(invoke(str_replace('.', '\\', App::getNamespace() . ($isCmd?'\\adminapi':'') . '\\lists\\' . $use_file[0] . '\\'. ucwords($use_file[1]))));
                        break;
                 }
             }
         }catch (\Exception $e){
             Log::info("download-error:{$id}:".$e->getMessage());
+            $this->infoExport->generate_status = 2;
+            $this->infoExport->updatetime = time();
+            $this->infoExport->save();
             throw new Exception($e->getMessage());
         }
     }

+ 4 - 0
config/console.php

@@ -23,5 +23,9 @@ return [
         'update_worker_score' => 'app\common\command\UpdateWorkerScore',
         //拼团订单结束
         'group_order' => 'app\common\command\GroupOrder',
+        // 导出表格
+        'excel_export' => 'app\common\command\ExcelExport',
+        //维修故障限价数据初始化抓取
+        'fault_init' => 'app\common\command\FaultInit',
     ],
 ];

+ 1 - 0
config/export.php

@@ -21,5 +21,6 @@ return [
         '11' =>  'group_activity.GroupUserOrderLists',
         '12' =>  'sale.SaleMasterWorkerLists',
         '13' =>  'sale.SaleCommissionLists',
+        '14' =>  'master_worker_register.MasterWorkerRegisterLists',
     ],
 ];

+ 1 - 1
extend/excel/ExcelWriter.php

@@ -42,7 +42,7 @@ class ExcelWriter
         $filePath = $savePath . $filename;
         $writer = new Xlsx($this->spreadsheet);
         $writer->save($filePath);
-        $this->fileUrl = ($this->savePath?:"/exports/"). $filename;
+        $this->fileUrl = "/exports/". $filename;
     }
     public function fileUrl()
     {