| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace addons\Certificate\backend\controllers;
- use addons\Certificate\common\models\CertificateClaim;
- use common\enums\StatusEnum;
- use common\models\user\User;
- use Yii;
- use yii\db\Exception;
- /**
- * 默认控制器
- *
- * Class DefaultController
- * @package addons\Car\backend\controllers
- */
- class ClaimController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isAjax) {
- if ($retuest->isGet) {
- $params = Yii::$app->request->get();
- // 检查提交的参数
- $res = Yii::$app->services->validate->validate($params,[
- [['id','user_id','user_keyword','create_time'], 'safe'],
- [['limit'],'default','value' => '15'],
- ]);
- if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where = [];
- if (!empty($params['user_keyword'])) {
- $user_ids = User::find()->select("id")->where(['mall_id' => $this->mall_id])->andWhere(['like', 'mobile', $params['user_keyword'] . '%', false])->asArray()->column();
- $user_name = User::find()->select("id")->where(['mall_id' => $this->mall_id])->andWhere(['like', 'nickname', $params['user_keyword'] . '%', false])->asArray()->column();
- $user_ids = $user_ids + $user_name;
- if (empty($user_ids)) $this->success('查无此用户');
- $where[] = ['in', 'user_id', $user_ids];
- }
- if($params['create_time']) $where[] = ['between', 'created_at', strtotime($params['create_time'][0]),strtotime($params['create_time'][1])];
- if(!empty($params['user_id'])) $where[] = ['=', 'user_id', $params['user_id']];
- $with = ['user','certificate'];
- $where[] = ['=', 'mall_id', $this->mall_id];
- $where[] = ['>=', 'status', StatusEnum::DISABLED];
- $order = 'id desc';
- $params = array('where' => $where, 'order'=>$order, 'with'=>$with, 'limit' => $params['limit']);
- $list = CertificateClaim::listPage($params, false, true);
- $this->success('获取成功', $list);
- }
- } else {
- return $this->render($this->action->id);
- }
- }
- }
|