SendTeamRewards.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. namespace app\api\command;
  3. use think\console\Command;
  4. use think\console\Input;
  5. use think\console\Output;
  6. use app\common\logic\TeamRewards;
  7. use app\common\model\TimedTaskLogModel;
  8. use think\Model;
  9. class SendTeamRewards extends Command
  10. {
  11. protected function configure()
  12. {
  13. $this->setName('SendTeamRewards')->setDescription('Here is the remark ');
  14. }
  15. protected function execute(Input $input, Output $output)
  16. {
  17. /* 永不超时 */
  18. // ini_set('max_execution_time', 0);
  19. // 记录开始运行的时间
  20. $GLOBALS['_beginTime'] = microtime(TRUE);
  21. $output->writeln('定时任务开始执行:' . date('Y-m-d H:i:s', time()));
  22. /*** 发放团队算力奖励 ***/
  23. $output->writeln("开始发放团队算力奖励:");
  24. $log_id = (new TeamRewards())->powerRewards();
  25. $time_total = round(microtime(true) - $GLOBALS['_beginTime'], 4);//计算耗时
  26. $output->writeln('团队算力奖励发放结束:' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
  27. //更新发放日志
  28. if($log_id > 0){
  29. (new TimedTaskLogModel())->update([
  30. 'id' => $log_id,
  31. 'status' => 1,
  32. 'end_time' => date('Y-m-d H:i:s'),
  33. 'elapsed_time' => $time_total
  34. ]);
  35. }
  36. /*** 发放分红收益 ***/
  37. $begin_usdt = microtime(TRUE);
  38. $output->writeln("开始发放加权分红:");
  39. $log_id_1 = (new TeamRewards())->usdtRewards();
  40. $time_total = round(microtime(true) - $begin_usdt, 4);//计算耗时
  41. $output->writeln('加权分红发放结束:' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
  42. //更新发放日志
  43. if($log_id_1 > 0){
  44. (new TimedTaskLogModel())
  45. ->where('id', $log_id_1)
  46. ->update([
  47. 'id' => $log_id_1,
  48. 'status' => 1,
  49. 'end_time' => date('Y-m-d H:i:s'),
  50. 'elapsed_time' => $time_total
  51. ]);
  52. }
  53. /*** 发放社区长、系统领导人加权分红 ***/
  54. $begin_usdt = microtime(TRUE);
  55. $output->writeln("开始发放社区长、系统领导人加权分红:");
  56. $log_id_1 = (new TeamRewards())->marketRewards();
  57. $time_total = round(microtime(true) - $begin_usdt, 4);//计算耗时
  58. $output->writeln('社区长、系统领导人加权分红发放结束:' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
  59. //更新发放日志
  60. if($log_id_1 > 0){
  61. (new TimedTaskLogModel())
  62. ->where('id', $log_id_1)
  63. ->update([
  64. 'id' => $log_id_1,
  65. 'status' => 1,
  66. 'end_time' => date('Y-m-d H:i:s'),
  67. 'elapsed_time' => $time_total
  68. ]);
  69. }
  70. /*** 团队业绩分红 ***/
  71. $begin_usdt = microtime(TRUE);
  72. $output->writeln("团队业绩分红:");
  73. $log_id_1 = (new TeamRewards())->teamRewards();
  74. $time_total = round(microtime(true) - $begin_usdt, 4);//计算耗时
  75. $output->writeln('团队业绩分红发放结束:' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
  76. //更新发放日志
  77. if($log_id_1 > 0){
  78. (new TimedTaskLogModel())
  79. ->where('id', $log_id_1)
  80. ->update([
  81. 'id' => $log_id_1,
  82. 'status' => 1,
  83. 'end_time' => date('Y-m-d H:i:s'),
  84. 'elapsed_time' => $time_total
  85. ]);
  86. }
  87. /*** 今日产出 ***/
  88. // $begin_usdt = microtime(TRUE);
  89. // $output->writeln("今日产出:");
  90. //
  91. // $log_id_1 = (new TeamRewards())->AllocateEtc();
  92. //
  93. // $time_total = round(microtime(true) - $begin_usdt, 4);//计算耗时
  94. // $output->writeln('今日产出放结束:' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
  95. // //更新发放日志
  96. // if($log_id_1 > 0){
  97. // (new TimedTaskLogModel())
  98. // ->where('id', $log_id_1)
  99. // ->update([
  100. // 'id' => $log_id_1,
  101. // 'status' => 1,
  102. // 'end_time' => date('Y-m-d H:i:s'),
  103. // 'elapsed_time' => $time_total
  104. // ]);
  105. // }
  106. $time_total = round(microtime(true) - $GLOBALS['_beginTime'], 4);//计算耗时
  107. $output->writeln('定时任务执行结束,总耗时' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
  108. }
  109. }