updateqrd.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\command;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. use think\facade\Cache;
  10. use think\facade\Db;
  11. use think\facade\Log;
  12. class updateqrd extends Command
  13. {
  14. protected $db="";
  15. protected function configure()
  16. {
  17. // 指令配置
  18. $this->setName('CopyData')
  19. ->setDescription('the CopyData command');
  20. }
  21. protected function execute(Input $input, Output $output)
  22. {
  23. $redis = Cache::store('redis');
  24. $iscgd = $redis->get("fhstatus");
  25. if ($iscgd == 0) {
  26. $redis->set("fhstatus", 1,1200);
  27. } else {
  28. return;
  29. }
  30. $data= $this->GetData();
  31. if(empty($data)){
  32. return;
  33. }
  34. foreach ($data as $key=>$value){
  35. if($value['cgdNo']!=''){
  36. $cgd = Db::name("cgd_info")->where([['ShortText1618315935182','=',$value['cgdNo']]])->find();
  37. if(empty($cgd)){
  38. continue;
  39. }
  40. $thnum = Db::table('fh_source')->where([['cgdNo',"=",$value['cgdNo']],['status','=',1]])
  41. ->sum('send');
  42. $cgd['ShortText1618859321070'] = isset($thnum) && $thnum>0 ?
  43. ($cgd['Number1618240600907']>$thnum ? 2 : 3) :1;
  44. Db::name("cgd_info")->save($cgd);
  45. }
  46. }
  47. $redis->set("fhstatus",0);
  48. $output->writeln('CopyData');
  49. }
  50. protected function GetData(){
  51. $date = date("Y-m-d H:i:s",strtotime("-3 day"));
  52. $list = Db::table('fh_source')->where([['updatetime',">=",$date],['status','=',1]])->select();
  53. return $list;
  54. }
  55. }