SmsController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace backend\modules\mall\controllers;
  3. use backend\controllers\MallController;
  4. use common\models\common\SmsLog;
  5. use Yii;
  6. /**
  7. * 短信控制器
  8. *
  9. * Class SmsController
  10. * @package backend\modules\mall\BackendLogController
  11. */
  12. class SmsController extends MallController
  13. {
  14. /**
  15. * 短信日志记录
  16. * @return mixed|string|void
  17. */
  18. public function actionIndex()
  19. {
  20. $request = Yii::$app->request;
  21. if ($request->isAjax && $request->isGet) {
  22. $get = $request->get();
  23. // 检查提交的参数
  24. $res = Yii::$app->services->validate->validate($get,[
  25. [['page','mobile','ip','type'], 'safe'],
  26. ]);
  27. if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  28. // 查询参数
  29. $where[] = ['=', 'mall_id', $this->mall_id];
  30. !empty($get['ip']) && $where[] = ['=', 'ip', $get['ip']];
  31. !empty($get['mobile']) && $where[] = ['=', 'mobile', $get['mobile']];
  32. !empty($get['type']) && $where[] = ['=', 'type', $get['type']];
  33. $params = array('where' => $where, 'order' => 'id desc', 'limit' => $request->get('limit', 20));
  34. $list = SmsLog::listPage($params);
  35. $type_arr = SmsLog::getType();// 获取模块
  36. $statistic = [];
  37. if ($get['page'] == 1) $statistic = SmsLog::statistic($this->mall_id);// 获取模块
  38. return $this->success('获取成功', compact('list', 'type_arr','statistic'));
  39. }
  40. return $this->render($this->action->id);
  41. }
  42. }