SmsLogController.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace backend\modules\extend\controllers;
  3. use Yii;
  4. use common\models\base\SearchModel;
  5. use common\models\extend\SmsLog;
  6. use common\enums\StatusEnum;
  7. use common\helpers\ResultHelper;
  8. use backend\controllers\BaseController;
  9. /**
  10. * Class SmsLogController
  11. * @package backend\modules\common\controllers
  12. * @author jianyan74 <751393839@qq.com>
  13. */
  14. class SmsLogController extends BaseController
  15. {
  16. /**
  17. * @return string
  18. * @throws \yii\web\NotFoundHttpException
  19. */
  20. public function actionIndex()
  21. {
  22. $searchModel = new SearchModel([
  23. 'model' => SmsLog::class,
  24. 'scenario' => 'default',
  25. 'partialMatchAttributes' => ['mobile'], // 模糊查询
  26. 'defaultOrder' => [
  27. 'id' => SORT_DESC,
  28. ],
  29. 'pageSize' => $this->pageSize,
  30. ]);
  31. $dataProvider = $searchModel
  32. ->search(Yii::$app->request->queryParams);
  33. $dataProvider->query
  34. ->andWhere(['>=', 'status', StatusEnum::DISABLED]);
  35. return $this->render($this->action->id, [
  36. 'dataProvider' => $dataProvider,
  37. 'searchModel' => $searchModel,
  38. ]);
  39. }
  40. /**
  41. * 行为日志详情
  42. *
  43. * @param $id
  44. * @return string
  45. */
  46. public function actionView($id)
  47. {
  48. return $this->renderAjax($this->action->id, [
  49. 'model' => SmsLog::findOne($id),
  50. ]);
  51. }
  52. /**
  53. * @param string $data
  54. * @return array|string
  55. */
  56. public function actionStat($type = '')
  57. {
  58. if (!empty($type)) {
  59. $data = Yii::$app->services->extendSms->stat($type);
  60. return ResultHelper::json(200, '获取成功', $data);
  61. }
  62. return $this->renderAjax($this->action->id, []);
  63. }
  64. }
粤ICP备19079148号