IntelligentMatchForm.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\client\models\v1;
  8. use app\models\Cat;
  9. use app\models\Goods;
  10. use app\models\IntelligentMatchCat;
  11. use app\models\IntelligentScene;
  12. use yii\base\Model;
  13. class IntelligentMatchForm extends Model
  14. {
  15. public $store_id;
  16. public $cat_id;
  17. public $goods_id;
  18. public function getIntelligentMatch(){
  19. //1.获取商品分类
  20. $goodsCat = Cat::getCatList(get_store_id(), Cat::IS_SHOW_TRUE);
  21. //2.获取场景分类
  22. $intelligentMatchCat = IntelligentMatchCat::getCatList(get_store_id(), IntelligentMatchCat::IS_SHOW_TRUE);
  23. // 获取商品的智配图片
  24. if($this->goods_id){
  25. $accessories_image = Goods::findOne($this->goods_id)->accessories_image;
  26. }else{
  27. $accessories_image = '';
  28. }
  29. // 获取默认场景
  30. $defaultScene = IntelligentScene::findOne(['is_delete'=>0,'status'=>1,'is_default'=>1])->pic_url;
  31. return [
  32. 'code' => 0,
  33. 'data' => [
  34. 'goods_cat' => $goodsCat,
  35. 'intelligent_match_cat' => $intelligentMatchCat,
  36. 'accessories_image' => $accessories_image,
  37. 'defaultScene' => $defaultScene
  38. ]
  39. ];
  40. }
  41. /**
  42. * 根据分类获取场景
  43. * @return array
  44. * User: hankaige
  45. * DATE TIME: 2023/1/28 15:23
  46. */
  47. public function getScene(){
  48. $query = IntelligentScene::find()->where(['store_id'=>$this->store_id,'cat_id'=>$this->cat_id,'is_delete'=>0,'status'=>1]);
  49. $data = pagination_make($query);
  50. return [
  51. 'code' => 0,
  52. 'data' => $data
  53. ];
  54. }
  55. }