qrd.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. class qrd extends Command
  12. {
  13. protected $db="";
  14. protected function configure()
  15. {
  16. // 指令配置
  17. $this->setName('qrd')
  18. ->setDescription('the qrd command');
  19. }
  20. protected function execute(Input $input, Output $output)
  21. {
  22. $redis = Cache::store('redis');
  23. $iscgd = $redis->get("qrd");
  24. if($iscgd==0){
  25. $redis->set("qrd",1,1200);
  26. }else{
  27. return;
  28. }
  29. $this->db =Db::connect("mysql2");
  30. $data = $this->GetData();
  31. foreach ($data as $value){
  32. $qrd = Db::name("qrd")->where("sequenceNo","=",$value['sequenceNo'])->find();
  33. $info = Db::name("qrd_info")->where("ShortText1617650701648","=",$value['sequenceNo'])
  34. ->field(' ifnull(round(sum(Number1618249146997),2),0) as apay_fee ,ifnull(round(sum(number1618249149738),2),0) as
  35. wpay_fee,ifnull(round(sum(Number1618249202608),2),0) as ainv_fee,ifnull(round(sum(Number1618249205231),2),0) as winv_fee,sum(inving_fee) as inv_fee,sum(paying_fee) as pay_fee,
  36. ShortText1617650701648')->group('ShortText1617650701648')->find();
  37. if(empty($info)){
  38. continue;
  39. }
  40. $value['wpay_fee']=$info['wpay_fee'];
  41. $value['apay_fee']=$info['apay_fee'];
  42. $value['winv_fee']=$info['winv_fee'];
  43. $value['ainv_fee']=$info['ainv_fee'];
  44. $value['inv_fee']=$info['inv_fee'];
  45. $value['pay_fee']=$info['pay_fee'];
  46. $value['total_fee'] = round($value['total_fee'],2);
  47. $value['pay_status'] = $info['wpay_fee']+$info['pay_fee']==0 ? 3:($info['wpay_fee']+$info['pay_fee']<$value['total_fee']?2:1);
  48. $value['inv_status'] = $info['winv_fee']+$info['inv_fee']==0 ? 3:($info['winv_fee']+$info['inv_fee']<$value['total_fee']?2:1);
  49. var_dump($value['name']);
  50. if(!$qrd){
  51. Db::name("qrd")->insert($value);
  52. }else{
  53. Db::name("qrd")->where("sequenceNo","=",$value['sequenceNo'])->save($value);
  54. }
  55. }
  56. $redis->set("qrd",0);
  57. }
  58. private function GetData(){
  59. $date = date("Y-m-d H:i:s",strtotime("-3 day"));
  60. $sql = "SELECT
  61. NAME name,
  62. sequenceNo,
  63. createdTime,
  64. (SELECT
  65. `b_`.`name`
  66. FROM
  67. `h_org_user` `b_`
  68. WHERE
  69. (
  70. CONVERT ( `b_`.`id` USING utf8mb4 ) = json_extract( `StaffSelector1617031034341`, '$[0].id' ))) as sales_name,
  71. (SELECT
  72. `b_`.`name`
  73. FROM
  74. `h_org_department` `b_`
  75. WHERE
  76. (
  77. CONVERT ( `b_`.`id` USING utf8mb4 ) = json_extract( `StaffSelector1617031050718`, '$[0].id' ))) as sales_depart,
  78. Number1617648665166 as total_fee,
  79. ShortText1617648743587 mobile,
  80. ShortText1617648745795 contactor,
  81. Date1617672422547 as qrddate,
  82. ShortText1617774189420 as customer,
  83. text1617774207439 as companyNo,
  84. ShortText1618266846625 supplerName,
  85. ShortText1619406464190 addr,
  86. ifnull(ShortText1619541934512,'') depart,
  87. 1 as type,
  88. 1 inv_status,
  89. 0 ainv_fee,
  90. Number1617648665166 winv_fee,
  91. Number1617648665166 wpay_fee,
  92. 0 apay_fee,
  93. 1 pay_status,
  94. 1 status,
  95. createdTime addtime,
  96. modifiedTime updatetime
  97. FROM
  98. il150_querendan
  99. where sequenceStatus = 'COMPLETED' and modifiedTime>='{$date}'";
  100. $data=$this->db->query($sql);
  101. return $data;
  102. }
  103. }