From 87f691d2e899e74e074275d8abe914d93de9ce7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=96=E5=8F=AB?= <392494244@qq.com> Date: Wed, 29 Nov 2023 15:06:42 +0800 Subject: [PATCH] 1 --- models/common/CommonGoodsListForm.php | 14 +++- .../mall/integral/GoodsController.php | 82 +++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) diff --git a/models/common/CommonGoodsListForm.php b/models/common/CommonGoodsListForm.php index 0985907..5abd5fe 100644 --- a/models/common/CommonGoodsListForm.php +++ b/models/common/CommonGoodsListForm.php @@ -48,12 +48,20 @@ class CommonGoodsListForm extends Model private $fields; + public $cat1_id; + public $cat2_id; + public $cat3_id; + public $cat4_id; + public $cat5_id; + + public function rules() { return [ [['keywords', 'plugin_sign',], 'trim'], [['keywords', 'plugin_sign',], 'string'], [['limit', 'page', 'cx_mch_id', 'status', 'goods_id', 'cat_id'], 'integer'], + [['cat_id', 'cat1_id', 'cat2_id', 'cat3_id', 'cat4_id'], 'integer'], [['page'], 'default', 'value' => 1], [['limit'], 'default', 'value' => 20], [['status'], 'in', 'range' => [0, 1, 2]], @@ -87,7 +95,11 @@ class CommonGoodsListForm extends Model ]) ->andFilterWhere([ 'g.id' => $this->goods_id, - 'gc.cat_id' => $this->cat_id + 'gc.cat_id' => $this->cat_id, + 'gc.cat1_id' => $this->cat1_id, + 'gc.cat2_id' => $this->cat2_id, + 'gc.cat3_id' => $this->cat3_id, + 'gc.cat4_id' => $this->cat4_id, ]); if ($this->status == 2) { $query = $query->andWhere(['g.goods_stock' => 0]);//售罄 diff --git a/modules/api/controllers/mall/integral/GoodsController.php b/modules/api/controllers/mall/integral/GoodsController.php index c41cc59..acd023c 100644 --- a/modules/api/controllers/mall/integral/GoodsController.php +++ b/modules/api/controllers/mall/integral/GoodsController.php @@ -13,6 +13,11 @@ namespace app\modules\api\controllers\mall\integral; use app\components\SiteHelper; +use app\models\Cat; +use app\models\Cat1; +use app\models\Cat2; +use app\models\Cat3; +use app\models\Cat4; use app\modules\api\behaviors\LoginBehavior; use app\models\common\integral\mall\CommonIntegralMallActionForm; use app\models\common\integral\mall\CommonIntegralMallGoodsListForm; @@ -29,6 +34,7 @@ class GoodsController extends Controller 'class' => LoginBehavior::className(), 'ignore' => [ 'api/mall/integral/goods/index', + 'api/mall/integral/goods/index-cat', 'api/mall/integral/goods/tree', 'api/mall/integral/goods/detail', ] @@ -90,6 +96,82 @@ class GoodsController extends Controller return $this->responseHandler($data); } + /** + * hidedoc + * @catalog 冠军列表分类 + * @title 冠军列表分类 + * @description 本接口提供冠军列表分类 + * @method get + * @url /api/mall/integral/goods/index-cat + * @return {"code":0,"msg":"ok","data":[{"id":"2","price":"111.00","date":"2023-11-27","sort":"100","subtitle":"111","created_at":"1701077489","name":"李四","cover_pic":"http://cxgj.com/upload/0/1/upload/image/2023/1127/1701077471438838.jpg","video_url":"","pic_urls":"[\"/upload/0/1/upload/image/2023/1127/1701077483860358.jpg\",\"/upload/0/1/upload/image/2023/1127/1701077486913290.jpg\",\"/upload/0/1/upload/image/2023/1127/1701077502452397.jpg\"]","created_at_cn":"2023-11-27 17:31:29","pic_arr":["http://cxgj.com/upload/0/1/upload/image/2023/1127/1701077483860358.jpg","http://cxgj.com/upload/0/1/upload/image/2023/1127/1701077486913290.jpg","http://cxgj.com/upload/0/1/upload/image/2023/1127/1701077502452397.jpg"]}],"count":"1","page_size":20,"page_count":1,"page_no":1,"end_flag":false} + * @return_param id int 分类ID + * @return_param name string 分类名称 + * @remark + */ + public function actionIndexCat() + { + + $cat_list = Cat::find() + ->where([ + 'cx_mch_id' => $this->cx_mch_id, + 'is_delete' => 0, + 'type' => Cat::TYPE_GOODS, + ]) + ->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC]) + ->select('id,name')->asArray()->all(); + + $cat_list1 = Cat1::find() + ->where([ + 'cx_mch_id' => $this->cx_mch_id, + 'is_delete' => 0, + 'type' => Cat::TYPE_GOODS, + ]) + ->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC]) + ->select('id,name')->asArray()->all(); + + $cat_list2 = Cat2::find() + ->where([ + 'cx_mch_id' => $this->cx_mch_id, + 'is_delete' => 0, + 'type' => Cat::TYPE_GOODS, + ]) + ->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC]) + ->select('id,name')->asArray()->all(); + + $cat_list3 = Cat3::find() + ->where([ + 'cx_mch_id' => $this->cx_mch_id, + 'is_delete' => 0, + 'type' => Cat::TYPE_GOODS, + ]) + ->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC]) + ->select('id,name')->asArray()->all(); + + $cat_list4 = Cat4::find() + ->where([ + 'cx_mch_id' => $this->cx_mch_id, + 'is_delete' => 0, + 'type' => Cat::TYPE_GOODS, + ]) + ->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC]) + ->select('id,name')->asArray()->all(); + + $list = [ + 'cat' => $cat_list, + 'cat1' => $cat_list1, + 'cat2' => $cat_list2, + 'cat3' => $cat_list3, + 'cat4' => $cat_list4, + ]; + + $data['code'] = 0; + $data['msg'] = 'ok'; + $data['data'] = $list; + + return $this->responseHandler($data); + } + + /** * hidedoc * @catalog 积分商城/商品