123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- declare (strict_types = 1);
- namespace app\command;
- 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\Db;
- class UpdateGod extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('updategod')
- ->setDescription('the updategod command');
- }
- protected function execute(Input $input, Output $output)
- {
- // 指令输出
- $this->GetData();
- $this->GetData2();
- $output->writeln('updategod');
- }
- public function GetData(){
- $date = date("Y-m-d H:i:s",strtotime("-1 day"));
- $data = Db::table("good")->where("updatetime>='{$date}'")->field("CONCAT('GD-',good_code) as good_code,
- item,
- good_name,
- technology 'good_desc',
- brand,
- unit_price 'original_price',
- cg_saler,
- good_type,
- good_addr,
- supply_area,
- market_fee,
- unit,
- gys_code,
- is_step ,
- tax,
- is_online,
- fund,
- sort_f,
- sort_s,
- sort_t,
- 1 status,
- 0 is_del,
- createtime 'addtime',
- updatetime")->select();
- foreach ($data as $value){
- $isT = Db::name("good")->where("good_code","=",$value['good_code'])->find();
- if($isT){
- Db::name("good")->where($isT)->save($value);
- }else{
- Db::name("good")->save($value);
- }
- }
- }
- public function GetData2(){
- $date = date("Y-m-d H:i:s",strtotime("-1 day"));
- $data = Db::table("good")->where("updatetime>='{$date}'")->field("CONCAT('GD-',good_code) as good_code,
- good_code 'type_code',
- model 'attribute',
- color,
- material,
- specs,
- is_main,
- is_diff,
- good_weight,
- box_weight,
- box_size,
- box_specs,
- pack_size,
- bar_code,
- min_num,
- order_minnum,
- duration,
- sampling_period,
- sample_fee,
- cost_fee,
- logistics,
- logistics_fee,
- cert_fee,
- packing_fee,
- mark_fee,
- tech_fee,
- unit_price,
- noble_metal,
- tax,
- 1 status,
- 0 is_del,
- createtime 'addtime',
- updatetime")->select();
- foreach ($data as $value){
- $isT = Db::name("good_type")->where("good_code","=",$value['good_code'])->find();
- if($isT){
- Db::name("good_type")->where($isT)->save($value);
- }else{
- Db::name("good_type")->save($value);
- }
- }
- }
- }
|