reportTips.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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;use think\facade\Db;
  10. class reportTips extends Command
  11. {
  12. protected function configure()
  13. {
  14. // 指令配置
  15. $this->setName('reporttips')
  16. ->setDescription('the reporttips command');
  17. }
  18. protected function execute(Input $input, Output $output)
  19. {
  20. // 指令输出
  21. $sttime = Cache::get("repotTips");
  22. if($sttime==1) return '';
  23. Cache::set("repotTips",1,1800);
  24. $this->GetData();
  25. $date=date('Y-m-d H:i:s');
  26. $output->writeln("[{$date}] 更新数据成功");
  27. }
  28. private function GetData(){
  29. $daprtid = [52,53,56];
  30. $companyNo='GS2203161855277894';
  31. $temp=[];
  32. $depart= Db::connect("mysql_sys")->name("company_item")->where(["id"=>$daprtid])->column("name","id");
  33. foreach ($depart as $item=>$name){
  34. $uidArr =getUidByDepartId($item);
  35. $where=["ownerid"=>$uidArr,"companyNo"=>$companyNo,"platform_type"=>1];
  36. $tem=[
  37. "depart"=>$name,
  38. "wpay_fee"=>Db::name("qrd_info")->where($where)->sum('wpay_fee'),
  39. "wpay_ainv_fee"=>Db::name("qrd_info")->where($where)->where(["inv_status"=>[2,3]])->sum('wpay_fee'),
  40. "ainv_fee"=>Db::name("qrd_info")->where($where)->where(function ($query){
  41. $query->whereOr([['inv_status','<>',3],['pay_status','<>',3]]);
  42. })->sum('ainv_fee'),
  43. "apay_fee"=>Db::name("qrd_info")->where($where)->where(function ($query){
  44. $query->whereOr([['inv_status','<>',3],['pay_status','<>',3]]);
  45. })->sum('apay_fee'),
  46. "ainv_apay_fee"=>Db::name("qrd_info")->where($where)->where(function ($query){
  47. $query->whereOr([['inv_status','<>',3],['pay_status','<>',3]]);
  48. })->sum(Db::raw("ainv_fee - apay_fee")),
  49. "wpay_send_fee"=>Db::name("qrd_info")->where($where)->where(["sendStatus"=>1])->sum('wpay_fee'),
  50. "winv_fee"=>Db::name("qrd_info")->where($where)->sum('winv_fee'),
  51. "inv_fee"=>Db::name("qrd_info")->where($where)->sum('inv_fee'),
  52. "winv_asend_fee"=>Db::name("qrd_info")->where($where)->where(["sendStatus"=>[2,3]])->sum('winv_fee'),
  53. "winv_two_month"=>Db::name("qrd_info")->where($where)->where(["sendStatus"=>[2,3]])->where("createdTime","<=",date("Y-m-d H:i:s",time()-60*24*3600))->sum("winv_fee"),
  54. "wpay_six_month"=>Db::name("qrd_info")->where($where)->where("createdTime","<=",date("Y-m-d H:i:s",time()-180*24*3600))->sum("wpay_fee")
  55. ];
  56. $temp[]=$tem;
  57. }
  58. Cache::set("pay_inv_stat",$temp);
  59. }
  60. }