1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace api\modules\v1\controllers;
- use common\models\ActivityReceive;
- use yii\rest\ActiveController;
- use common\library\Apireturn;
- use yii\helpers\ArrayHelper;
- use yii\filters\auth\QueryParamAuth;
- use yii;
- class RedController extends ActiveController
- {
- public $modelClass = 'common\models';
- const DISPLAY = 10;//显示条数
- public function behaviors()
- {
- return ArrayHelper::merge(parent::behaviors(), [
- 'authenticator' => [
- 'class' => QueryParamAuth::className(),
- 'tokenParam' => "token",//access-token修改为token
- 'optional' => [//不需要认证方法名 array
- ],
- ]
- ]);
- }
- /**
- * 红包记录
- * @return array
- */
- public function actionLog()
- {
- $page = Yii::$app->request->POST('page', 1);//分页页数
- $display = Yii::$app->request->POST('display', self::DISPLAY);//分页页数
- $mod = ActivityReceive::findBySql("SELECT a.amount,a.receive_at,b.title FROM {{%activity_receive}} AS a LEFT JOIN {{%building}} AS b ON a.source_id = b.id WHERE a.uid = :uid AND a.status = :status ORDER BY a.id desc LIMIT ". ($page - 1) * $display . "," . $display,[':uid'=>Yii::$app->user->id,':status'=>ActivityReceive::STATUS_YES]);
- $list = $mod->asArray()->all();
- $count = ActivityReceive::find()->where(['uid'=>Yii::$app->user->id,'status'=>ActivityReceive::STATUS_YES])->count();
- return Apireturn::sent(1,'success',200,array('count'=>$count,'list'=>$list));
- }
- }
|