|
@@ -1,41 +0,0 @@
|
|
|
-<?php
|
|
|
-declare (strict_types = 1);
|
|
|
-
|
|
|
-namespace app\youzan\command;
|
|
|
-
|
|
|
-use app\common\facade\Youzan;
|
|
|
-use app\youzan\model\Promocode;use think\console\Command;
|
|
|
-use think\console\Input;
|
|
|
-use think\console\input\Argument;
|
|
|
-use think\console\input\Option;
|
|
|
-use think\console\Output;use think\facade\Cache;
|
|
|
-
|
|
|
-class UpdatePromod extends Command
|
|
|
-{
|
|
|
- protected function configure()
|
|
|
- {
|
|
|
- // 指令配置
|
|
|
- $this->setName('updatepromod')
|
|
|
- ->setDescription('the updatepromod command');
|
|
|
- }
|
|
|
-
|
|
|
- protected function execute(Input $input, Output $output)
|
|
|
- {
|
|
|
- // 指令输出
|
|
|
- $param = Cache::get("voucher_list_params");
|
|
|
- if(!empty($param)){
|
|
|
- Cache::delete('voucher_list_params');
|
|
|
- $data = Youzan::getData('promocode_query',$param,'3.0.1');
|
|
|
- if ($data['code'] != '200') {
|
|
|
- $output->writeln(json_encode($data, JSON_UNESCAPED_UNICODE));
|
|
|
- }
|
|
|
- if (!empty($data['data'])) (new Promocode)->saveAll(array_map(function ($item){
|
|
|
- $item['activity']['start_time'] = date('Y-m-d H:i:s', $item['activity']['start_time'] / 1000);
|
|
|
- $item['activity']['end_time'] = date('Y-m-d H:i:s', $item['activity']['end_time'] / 1000);
|
|
|
- $item['activity']['created_at'] = date('Y-m-d H:i:s', $item['activity']['created_at'] / 1000);
|
|
|
- return $item['activity'];
|
|
|
- }, $data['data']));
|
|
|
- }
|
|
|
- $output->writeln('updatepromod');
|
|
|
- }
|
|
|
-}
|