SearchController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace addons\TinyShop\merchant\modules\statistics\controllers;
  3. use Yii;
  4. use common\helpers\ResultHelper;
  5. use common\enums\StatusEnum;
  6. use common\models\base\SearchModel;
  7. use addons\TinyShop\merchant\controllers\BaseController;
  8. use addons\TinyShop\common\models\common\SearchHistory;
  9. /**
  10. * Class SearchController
  11. * @package addons\TinyShop\merchant\modules\statistics\controllers
  12. * @author jianyan74 <751393839@qq.com>
  13. */
  14. class SearchController extends BaseController
  15. {
  16. public function actionIndex()
  17. {
  18. return $this->render($this->action->id, [
  19. ]);
  20. }
  21. public function actionRecord()
  22. {
  23. $searchModel = new SearchModel([
  24. 'model' => SearchHistory::class,
  25. 'scenario' => 'default',
  26. 'partialMatchAttributes' => ['keyword', 'search_date'], // 模糊查询
  27. 'defaultOrder' => [
  28. 'id' => SORT_DESC,
  29. ],
  30. 'pageSize' => $this->pageSize,
  31. ]);
  32. $dataProvider = $searchModel
  33. ->search(Yii::$app->request->queryParams);
  34. $dataProvider->query
  35. ->andWhere(['>=', 'status', StatusEnum::DISABLED])
  36. ->andFilterWhere(['merchant_id' => $this->getMerchantId()]);
  37. return $this->render($this->action->id, [
  38. 'dataProvider' => $dataProvider,
  39. 'searchModel' => $searchModel,
  40. ]);
  41. }
  42. /**
  43. * @param $type
  44. * @return array|mixed
  45. */
  46. public function actionData($type)
  47. {
  48. $data = Yii::$app->tinyShopService->searchHistory->getBetweenCountStat($type);
  49. return ResultHelper::json(200, '获取成功', $data);
  50. }
  51. }
粤ICP备19079148号