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\Cache;
- use think\facade\Db;
- use think\facade\Log;
- class updateqrd extends Command
- {
- protected $db="";
- protected function configure()
- {
- // 指令配置
- $this->setName('CopyData')
- ->setDescription('the CopyData command');
- }
- protected function execute(Input $input, Output $output)
- {
- $redis = Cache::store('redis');
- $iscgd = $redis->get("fhstatus");
- if ($iscgd == 0) {
- $redis->set("fhstatus", 1,1200);
- } else {
- return;
- }
- $data= $this->GetData();
- if(empty($data)){
- return;
- }
- foreach ($data as $key=>$value){
- if($value['cgdNo']!=''){
- $cgd = Db::name("cgd_info")->where([['ShortText1618315935182','=',$value['cgdNo']]])->find();
- if(empty($cgd)){
- continue;
- }
- $thnum = Db::table('fh_source')->where([['cgdNo',"=",$value['cgdNo']],['status','=',1]])
- ->sum('send');
- $cgd['ShortText1618859321070'] = isset($thnum) && $thnum>0 ?
- ($cgd['Number1618240600907']>$thnum ? 2 : 3) :1;
- Db::name("cgd_info")->save($cgd);
- }
- }
- $redis->set("fhstatus",0);
- $output->writeln('CopyData');
- }
- protected function GetData(){
- $date = date("Y-m-d H:i:s",strtotime("-3 day"));
- $list = Db::table('fh_source')->where([['updatetime',">=",$date],['status','=',1]])->select();
- return $list;
- }
- }
|