qrdmx.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 qrdmx extends Command
  12. {
  13. protected $db="";
  14. protected function configure()
  15. {
  16. // 指令配置
  17. $this->setName('qrdmx')
  18. ->setDescription('the qrdmx command');
  19. }
  20. protected function execute(Input $input, Output $output)
  21. {
  22. // 指令输出
  23. $this->db =Db::connect("mysql2");
  24. // 指令输出
  25. $redis = Cache::store('redis');
  26. $iscgd = $redis->get("qrdmx");
  27. if($iscgd==0){
  28. $redis->set("qrdmx",1,1200);
  29. }else{
  30. return;
  31. }
  32. $data = $this->GetData();
  33. foreach ($data as $value){
  34. $ist = Db::table("source_all")->where('productNo',"=",$value['productNo'])->find();
  35. array_walk($value,function (&$v,$k){
  36. is_null($v) ? $v="" :"";
  37. if($v==''&& in_array($k,['paytime','zxfktime','zxtime','cgdtime','qrd_invtime','paytime','ordertime'])){
  38. $v=null;
  39. }
  40. // if(in_array($k,['qrd_ainv_fee','qrd_winv_fee','qrd_pay_status','qrd_inv_status','qrd_invNo','qrd_apay_fee','qrd_wpay_fee'])){
  41. // $v=0;
  42. // }
  43. });
  44. // $value['qrd_winv_fee'] = $value['sale_total'];
  45. // $value['qrd_wpay_fee'] =$value['sale_total'];
  46. if($ist){
  47. Db::table("source_all")->where('productNo',"=",$value['productNo'])->save($value);
  48. }else{
  49. Db::table("source_all")->save($value);
  50. }
  51. }
  52. $redis->set("qrdmx",0);
  53. $output->writeln('qrdmx');
  54. }
  55. private function GetData(){
  56. $date =date("Y-m-d",strtotime("-3 day"));
  57. $sql="SELECT
  58. `a`.`ShortText1618447165317` AS `supperinfo`,
  59. `a`.`ShortText1619523892833` AS `companyName`,
  60. `a`.`ShortText1619542951283` AS `companyNo`,
  61. a.ShortText1619543001392 as middle_branch,
  62. a.ShortText1619523693355 as area_branch,
  63. `b`.`ShortText1620753234895` AS `return_ticket`,
  64. `b`.`ShortText1620753237335` AS `return_trade`,
  65. `a`.`ShortText1619413394855` AS `khzzxz`,
  66. `a`.`ShortText1619413401534` AS `khcomp`,
  67. `a`.`ShortText1619523689586` AS `suppitem`,
  68. `a`.`ShortText1617366186330` AS `itemcode`,
  69. `a`.`ShortText1617023369580` AS `workNo`,
  70. `a`.`text1617365646297` AS `poNo`,
  71. `a`.`ShortText1617650701648` AS `qrdNo`,
  72. `a`.`ShortText1617650669915` AS `qrd_type`,
  73. `a`.`Date1617081795606` AS `zxfktime`,
  74. `a`.`createdTime` AS `ordertime`,
  75. a.`ShortText1618887148862` as `qrd_delivery`,
  76. a.`ShortText1617499210157` as `qrd_stock`,
  77. IF(a.sequenceStatus='COMPLETED',1,0) as status,
  78. (
  79. SELECT
  80. `b_`.`name`
  81. FROM
  82. `h_org_user` `b_`
  83. WHERE
  84. (
  85. CONVERT ( `b_`.`id` USING utf8mb4 ) = json_extract( `a`.`StaffSelector1618445844046`, '$[0].id' ))) AS `sale_name`,
  86. (
  87. SELECT
  88. `b_`.`name`
  89. FROM
  90. `h_org_department` `b_`
  91. WHERE
  92. (
  93. CONVERT ( `b_`.`id` USING utf8mb4 ) = json_extract( `a`.`StaffSelector1618445850209`, '$[0].id' ))) as 'depart',
  94. `a`.`sequenceNo` AS `productNo`,
  95. `a`.`ShortText1617365292699` AS `product_name`,
  96. `a`.`text1617499162303` AS `product_code`,
  97. `a`.`ShortText1617499192065` AS `cat_f`,
  98. `c`.`text1615776646788` AS `cat_t`,
  99. `c`.`ShortText1618558317611` AS `cat_d`,
  100. `a`.`ShortText1621217495905` AS `fund_code`,
  101. `a`.`text1617365597522` AS `unit`,
  102. `a`.`ShortText1617367958909` AS `tax`,
  103. `a`.`ShortText1619146965777` AS `qrdkey`,
  104. round( `a`.`Number1619403905454`, 2 ) AS `diff_weight`,
  105. round( `a`.`Number1619403908740`, 2 ) AS `diff_price`,
  106. `a`.`Date1619542686640` AS `paytime`,
  107. round( `a`.`Number1618248810624`, 2 ) AS `sale_price`,
  108. cast( `a`.`Number1617365688048` AS signed ) AS `order_num`,
  109. round( `a`.`Number1618248813613`, 2 ) AS `sale_total`,
  110. round((
  111. `a`.`Number1618248813613` -
  112. IF
  113. ((
  114. length( `a`.`ShortText1617367958909` ) > 1
  115. ),(
  116. `a`.`Number1618248813613` * ( cast( LEFT ( `a`.`ShortText1617367958909`,( length( `a`.`ShortText1617367958909` ) - 1 )) AS DECIMAL ( 10, 0 )) / 100 )),
  117. 0
  118. )),
  119. 2
  120. ) AS `income`,
  121. '0' AS `gross`,
  122. `a`.`ShortText1617111725596` AS `zxcode`,
  123. `a`.`Date1619626098213` AS `zxtime`,
  124. `a`.`ShortText1617670912205` AS `zxtype`,
  125. `b`.`ShortText1618315935182` AS `cgdNo`,
  126. `b`.`Date1618315953443` AS `cgdtime`,
  127. `b`.`ShortText1618270412964` AS `cgdtype`,(
  128. SELECT
  129. `b_`.`name`
  130. FROM
  131. `h_org_user` `b_`
  132. WHERE
  133. ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`creater` )) AS `cgd_saler`,
  134. `b`.`ShortText1620399144946` AS `suplier_name`,
  135. `b`.`ShortText1617861287265` AS `suppierNo`,
  136. round( `a`.`Number1618249202608`, 2 ) AS `qrd_ainv_fee`,
  137. round( `a`.`Number1618249205231`, 2 ) AS `qrd_winv_fee`,
  138. `a`.`ShortText1618559274859` AS `qrd_inv_status`,
  139. '' AS `qrd_invNo`,
  140. null AS `qrd_invtime`,
  141. round( `a`.`Number1618249146997`, 2 ) AS `qrd_apay_fee`,
  142. round( `a`.`number1618249149738`, 2 ) AS `qrd_wpay_fee`,
  143. `a`.`ShortText1618559043560` AS `qrd_pay_status`,
  144. '' AS `qrd_pay_code`,
  145. a.ShortText1618559007040 As 'delivery_status'
  146. FROM
  147. (((
  148. `il150_querendanchanpin` `a`
  149. LEFT JOIN `iw48m_CGDJL` `b` ON (((
  150. `a`.`ShortText1617650701648` = `b`.`ShortText1617866360004`
  151. )
  152. AND ( `a`.`ShortText1619146965777` = `b`.`ShortText1619147112929` ))))
  153. LEFT JOIN `ibt0b_commodity` `c` ON ((
  154. `c`.`sequenceNo` = `a`.`text1617499162303`
  155. )))
  156. )
  157. WHERE
  158. ((
  159. `a`.`sequenceStatus` ='COMPLETED' )
  160. AND ( date_format( `a`.`modifiedTime`, '%Y-%m-%d' ) >= '{$date}' )
  161. )
  162. ORDER BY
  163. `a`.`createdTime`,
  164. `a`.`sequenceNo`";
  165. $data=$this->db->query($sql);
  166. return $data;
  167. }
  168. }