IndexController.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace addons\Happiness\console\controllers;
  3. use addons\Happiness\common\logic\weight\PoolLogLogic;
  4. use addons\Happiness\common\service\CommissionService;
  5. use addons\Happiness\common\service\PensionService;
  6. use common\models\mall\Mall;
  7. use yii\console\Controller;
  8. use yii\console\ExitCode;
  9. use yii;
  10. class IndexController extends Controller
  11. {
  12. public function actionSendCommission()
  13. {
  14. try {
  15. $malls = Mall::getEnableMallList();
  16. $service=new CommissionService();
  17. if(!empty($malls))
  18. {
  19. foreach ($malls as $mall)
  20. {
  21. $mall_id = $mall['id'];
  22. $service->jobSend($mall_id);
  23. }
  24. }
  25. return ExitCode::OK;
  26. }
  27. catch (\Exception $e) {
  28. echo $e->getMessage();
  29. $this->stderr('Error: ' . ExitCode::getReason(ExitCode::UNSPECIFIED_ERROR));
  30. return ExitCode::UNSPECIFIED_ERROR;
  31. }
  32. }
  33. public function actionSendPension()
  34. {
  35. try {
  36. $malls = Mall::getEnableMallList();
  37. $service=new PensionService();
  38. if(!empty($malls))
  39. {
  40. foreach ($malls as $mall)
  41. {
  42. $mall_id = $mall['id'];
  43. $service->jobSend($mall_id);
  44. }
  45. }
  46. return ExitCode::OK;
  47. }
  48. catch (\Exception $e) {
  49. echo $e->getMessage();
  50. $this->stderr('Error: ' . ExitCode::getReason(ExitCode::UNSPECIFIED_ERROR));
  51. return ExitCode::UNSPECIFIED_ERROR;
  52. }
  53. }
  54. /**
  55. * 自动发放加权分红佣金定时任务
  56. * 0 20 0 * * * *
  57. * @return int
  58. */
  59. public function actionPoolRun(){
  60. try {
  61. $logic = new PoolLogLogic();
  62. $res = $logic->execute();
  63. if($res == true) {
  64. echo '操作成功';
  65. return ExitCode::OK;
  66. }
  67. } catch (\Exception $e) {
  68. echo $e->getMessage();
  69. $this->stderr('Error: ' . ExitCode::getReason(ExitCode::UNSPECIFIED_ERROR));
  70. return ExitCode::UNSPECIFIED_ERROR;
  71. }
  72. }
  73. }