123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?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 supplier extends Command
- {
- protected $db="";
- protected function configure()
- {
- // 指令配置
- $this->setName('supplier')
- ->setDescription('the CopyData command');
- }
- protected function execute(Input $input, Output $output)
- {
- // 指令输php出
- $this->db =Db::connect("mysql2");
- $data = $this->GetData();
- $list=[];
- foreach ($data as $key=>$value){
- $relas = Db::name('supplier_info')->where("code","=",$value['code'])->find();
- if($relas){
- Db::name('supplier_info')->where("code","=",$value['code'])->save($value);
- }else{
- Db::name('supplier_info')->insert($value);
- }
- }
- $output->writeln('CopyData');
- }
- private function GetData(){
- $date = date("Y-m-d H:i:s",strtotime("-1 day"));
- $data = $this->db->table("iw48m_Supplier_info")->alias('a')->where("a.modifiedTime",">=",$date)
- ->field("name,
- ifnull(sequenceNo,'') as code,
- ifnull(ShortText1614742711656,'') 'source',
- ifnull(text1614751047046,'') 'contector',
- ifnull(text1614751060372,'') 'post',
- ifnull(dropdown1614742750833,'') 'type',
- ifnull(dropdown1614750342128,'') 'nature',
- ifnull(text1614742995718,'') 'corporation',
- ifnull(dropdown1614750626613,'') 'pay_method',
- ifnull(ShortText1617870922867,0) 'paydays',
- ifnull(number1614751108814,'') 'mobile',
- ifnull(ShortText1617870495099,'') 'address',
- ifnull(dropdown1614750757071,'') 'return_ticket',
- ifnull(dropdown1614751201116,'') 'delivery',
- 1 'status',
- createdTime 'addtime',
- modifiedTime 'updatetime'")->select()->toArray();
- return $data;
- }
- }
|