DefaultController.php 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace addons\Seed\backend\controllers;
  3. use addons\Seed\common\enums\SeedEnum;
  4. use addons\Seed\common\logic\SeedLogic;
  5. use addons\Seed\common\models\SeedCapitalStatistics;
  6. use addons\Seed\common\models\SeedEnergyPool;
  7. use addons\Seed\common\models\SeedOrder;
  8. use addons\Seed\common\models\SeedUser;
  9. use common\enums\StatusEnum;
  10. /**
  11. * 默认控制器
  12. *
  13. * Class DefaultController
  14. * @package addons\Seed\backend\controllers
  15. */
  16. class DefaultController extends BaseController
  17. {
  18. public $enableCsrfValidation = false;
  19. /**
  20. * 首页
  21. *
  22. * @return string
  23. */
  24. public function actionIndex()
  25. {
  26. return $this->render('index',[
  27. ]);
  28. }
  29. /**
  30. * 手动释放
  31. * @Author: lun
  32. * @DateTime: 2022/8/29 0029 16:31
  33. * @Copyright: copyright (c) 2021 广东七件事集团
  34. */
  35. public function actionRelease()
  36. {
  37. SeedLogic::release($this->mall_id);
  38. }
  39. /**
  40. * 查询数据是否正确
  41. * @Author: lun
  42. * @DateTime: 2022/8/24 0024 19:15
  43. * @Copyright: copyright (c) 2021 广东七件事集团
  44. */
  45. public function actionTest()
  46. {
  47. $time = time();
  48. // 用户统计查询
  49. $select = 'sum(total_seed_num) seed_num,sum(collect_seed_num) collect,sum(refund_seed_num) refund';
  50. $user_seed = SeedUser::find()->select($select)->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])->asArray()->one();
  51. $user_seed_num = $user_seed['seed_num'] ?? 0;// 统计用户种子金总数
  52. $user_collect = $user_seed['collect'] ?? 0;// 统计用户已收取种子金总数
  53. $user_refund = $user_seed['refund'] ?? 0;// 统计用户退款种子金总数
  54. // 统计用户未到释放时间种子金总数
  55. $no_release = SeedOrder::find()->where(['mall_id' => $this->mall_id, 'seed_status' => StatusEnum::ENABLED, 'status' => StatusEnum::ENABLED])->andWhere(['>','can_send_at',$time])->andWhere(['=','last_send_at',0])->sum('seed_num') ?? 0;
  56. // 用户冻结种子金
  57. $frozen_seed = SeedOrder::find()->where(['mall_id' => $this->mall_id, 'seed_status' => StatusEnum::DISABLED, 'status' => StatusEnum::ENABLED])->sum('seed_num') ?? 0;
  58. // 进入能量池总额
  59. $user_pool = SeedOrder::find()->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])->sum('join_pool_money') ?? 0;
  60. // 商城种子金统计信息
  61. $statistics = SeedCapitalStatistics::find()->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])->asArray()->one();
  62. // 实际释放能量池总额
  63. $actual_release = SeedEnergyPool::find()->where(['mall_id' => $this->mall_id, 'release_status' => 1, 'status' => StatusEnum::ENABLED])->sum("release_energy_pool") ?? 0;
  64. // 停止增长种子金
  65. $stop_seed_num = SeedOrder::find()->where(['mall_id' => $this->mall_id, 'seed_status' => SeedEnum::SEED_STOP, 'status' => StatusEnum::ENABLED])->sum("seed_num") ?? 0;
  66. echo "用户种子金总数:{$user_seed_num}<br>";
  67. echo "用户收取种子金总数:{$user_collect}<br>";
  68. echo "用户退款种子金总数:{$user_refund}<br>";
  69. echo "用户未到释放时间种子金总数:{$no_release}<br>";
  70. echo "用户冻结种子金总数:{$frozen_seed}<br>";
  71. echo "订单进入能量池总额:{$user_pool}<br>";
  72. echo '<br>';
  73. echo "种子金总数:{$statistics['total_seed_num']}<br>";
  74. echo "收取种子金总数:{$statistics['collect_seed_num']}<br>";
  75. echo "退款种子金总数:{$statistics['refund_seed_num']}<br>";
  76. echo "坏账(冻结)种子金总数:{$statistics['bad_seed_num']}<br>";
  77. echo "停止增长种子金总数:{$stop_seed_num}<br>";
  78. echo "可释放种子金总数:".($statistics['total_seed_num'] - $statistics['collect_seed_num'] - $statistics['refund_seed_num'] - $statistics['bad_seed_num'] - $stop_seed_num)."<br>";
  79. echo '<br>';
  80. echo "当前能量池总额:".floatval($statistics['total_energy_pool']).",理论上当前能量池:".floatval($statistics['cumulative_energy_pool'] - $actual_release)."<br>";
  81. echo "已释放能量池总额:".floatval($statistics['release_energy_pool']).",实际释放能量池总额:{$actual_release}<br>";
  82. echo "计算累计能量池总额:".floatval($statistics['total_energy_pool'] + $statistics['release_energy_pool'])."<br>";
  83. echo "累计能量池总额:".floatval($statistics['cumulative_energy_pool'])."<br>";
  84. exit;
  85. }
  86. }