| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace addons\Seed\api\modules\v1\controllers;
- use addons\Seed\common\enums\SeedEnum;
- use addons\Seed\common\models\SeedCapitalStatistics;
- use addons\Seed\common\models\SeedOrder;
- use common\enums\StatusEnum;
- use Yii;
- use api\controllers\OnAuthController;
- /**
- * 默认控制器
- *
- * Class PoolController
- * @package addons\Seed\api\modules\v1\controllers
- */
- class PoolController extends OnAuthController
- {
- public $modelClass = '';
- /**
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = ['index'];
- /**
- * 用户种子金
- * @return string
- */
- public function actionIndex()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isGet) {
- // 能量池释放周期
- $release_cycle = Yii::$app->services->setting->addons->get($this->mall_id, SeedEnum::ADDONS_NAME, 'basic.release_cycle');
- // 种子金、能量池数据
- $statistics = SeedCapitalStatistics::find()->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])->asArray()->one();
- $data['total_energy_pool'] = $statistics['total_energy_pool'];// 当前能量池能量
- $data['release_energy_pool'] = $statistics['release_energy_pool'];// 能量池累计释放总额
- $data['next_release_at'] = $statistics['last_release_at'] + 3600 * $release_cycle;// 下次释放时间
- $where = [];
- $where[] = ['=', 'mall_id', $this->mall_id];
- $where[] = ['=', 'status', StatusEnum::ENABLED];
- $with = ['user'];
- $params = array('where' => $where, 'select' => 'user_id,goods_name,created_at', 'with' => $with, 'order' => 'created_at desc', 'limit' => 100);
- $data['list'] = SeedOrder::lists($params, true);
- $this->success('获取成功', $data);
- }
- }
- }
|