| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?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);
- //空调加氟(变频挂机 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
- ]);
- $pid = $res->id;
- $list = $item['itemTypeList'];//故障限价列表
- foreach($list as $v) {
- //二级分类
- $res = FaultType::create([
- 'name' => $v['itemTypeName'], //分类名称
- 'category_type' => $category_type,
- 'goods_category_id' => $goods_category_id,
- 'pid' => $pid
- ]);
- $type_id = $res->id;
- foreach($v['itemList'] as $vv) {
- FaultCode::create([
- 'type_id' => $type_id,
- 'name' => $vv['itemName'],
- 'price' => $vv['price'],
- ]);
- }
- }
- }
- }
- } catch (\Exception $e) {
- Log::error('家电维修故障限价数据抓取失败:'.$e->getMessage());
- }
- }
- }
|