| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\client\models\v1;
- use app\models\Cat;
- use app\models\Goods;
- use app\models\IntelligentMatchCat;
- use app\models\IntelligentScene;
- use yii\base\Model;
- class IntelligentMatchForm extends Model
- {
- public $store_id;
- public $cat_id;
- public $goods_id;
- public function getIntelligentMatch(){
- //1.获取商品分类
- $goodsCat = Cat::getCatList(get_store_id(), Cat::IS_SHOW_TRUE);
- //2.获取场景分类
- $intelligentMatchCat = IntelligentMatchCat::getCatList(get_store_id(), IntelligentMatchCat::IS_SHOW_TRUE);
- // 获取商品的智配图片
- if($this->goods_id){
- $accessories_image = Goods::findOne($this->goods_id)->accessories_image;
- }else{
- $accessories_image = '';
- }
- // 获取默认场景
- $defaultScene = IntelligentScene::findOne(['is_delete'=>0,'status'=>1,'is_default'=>1])->pic_url;
- return [
- 'code' => 0,
- 'data' => [
- 'goods_cat' => $goodsCat,
- 'intelligent_match_cat' => $intelligentMatchCat,
- 'accessories_image' => $accessories_image,
- 'defaultScene' => $defaultScene
- ]
- ];
- }
- /**
- * 根据分类获取场景
- * @return array
- * User: hankaige
- * DATE TIME: 2023/1/28 15:23
- */
- public function getScene(){
- $query = IntelligentScene::find()->where(['store_id'=>$this->store_id,'cat_id'=>$this->cat_id,'is_delete'=>0,'status'=>1]);
- $data = pagination_make($query);
- return [
- 'code' => 0,
- 'data' => $data
- ];
- }
- }
|