ConfigController.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 阿源
  5. * Date: 2020/8/31
  6. * Time: 11:21
  7. */
  8. namespace addons\ShortVideo\backend\controllers;
  9. use addons\ShortVideo\common\models\ShortVideoConfig;
  10. use common\enums\StatusEnum;
  11. use common\models\goods\Goods;
  12. class ConfigController extends BaseController
  13. {
  14. /**
  15. * 指定商品可用时搜索商品
  16. * @return mixed|void
  17. */
  18. public function actionGoodsList()
  19. {
  20. if (!\Yii::$app->request->isGet) {
  21. return $this->error('请求方式错误');
  22. }
  23. $page = \Yii::$app->request->get('page', 1);
  24. $limit = \Yii::$app->request->get('limit', $this->pageSize);
  25. $keyword = \Yii::$app->request->get('keyword');
  26. $where[] = [
  27. 'mall_id' => $this->mall_id,
  28. 'mch_id' => $this->admin->mch_id,
  29. 'status' => StatusEnum::ENABLED,
  30. 'is_on_sale' => 1,
  31. ];
  32. if (!empty($keyword)) {
  33. $where[] = ['like', 'goods_name', $keyword];
  34. }
  35. $params = [
  36. 'select' => 'id as goods_id,goods_name,cover_pic,sort',
  37. 'where' => $where,
  38. 'order' => 'sort asc,id desc',
  39. 'page' => $page,
  40. 'limit' => $limit,
  41. ];
  42. $list = Goods::listPage($params);
  43. return $this->success('success', $list);
  44. }
  45. }