diff --git a/app/common/model/store/parameter/Parameter.php b/app/common/model/store/parameter/Parameter.php new file mode 100644 index 00000000..33c68062 --- /dev/null +++ b/app/common/model/store/parameter/Parameter.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- + +namespace app\common\model\store\parameter; + +use app\common\model\BaseModel; + +class Parameter extends BaseModel +{ + + + public static function tablePk(): string + { + return 'parameter_id'; + } + + public static function tableName(): string + { + return 'parameter'; + } + + public function searchTemplateIdAttr($query, $value) + { + $query->where('template_id',$value); + } + +} diff --git a/app/common/model/store/parameter/ParameterTemplate.php b/app/common/model/store/parameter/ParameterTemplate.php new file mode 100644 index 00000000..02a7fdb0 --- /dev/null +++ b/app/common/model/store/parameter/ParameterTemplate.php @@ -0,0 +1,85 @@ + +// +---------------------------------------------------------------------- + +namespace app\common\model\store\parameter; + +use app\common\model\BaseModel; +use app\common\model\system\merchant\Merchant; +use app\common\model\system\Relevance; +use app\common\repositories\system\RelevanceRepository; + +class ParameterTemplate extends BaseModel +{ + + + public static function tablePk(): string + { + return 'template_id'; + } + + public static function tableName(): string + { + return 'parameter_template'; + } + + public function merchant() + { + return $this->hasOne(Merchant::class,'mer_id','mer_id'); + } + + public function parameter() + { + return $this->hasMany(Parameter::class,'template_id','template_id'); + } + + public function cateId() + { + return $this->hasMany(Relevance::class,'left_id','template_id')->where('type', RelevanceRepository::PRODUCT_PARAMES_CATE); + } + + public function searchCateIdAttr($query, $value) + { + $id = Relevance::where('right_id',$value)->where('type', RelevanceRepository::PRODUCT_PARAMES_CATE)->column('left_id'); + $query->where('template_id','in',$id); + } + + public function searchTemplateNameAttr($query, $value) + { + $query->whereLike('template_name',"%{$value}%"); + } + + public function searchTemplateIdsAttr($query, $value) + { + $query->whereIn('template_id',$value); + } + + public function searchMerIdAttr($query, $value) + { + $query->where('mer_id',$value); + } + + public function searchMerNameAttr($query, $value) + { + $value = Merchant::whereLike('mer_name',"%{$value}%")->coupon('mer_id'); + $query->whereIn('mer_id',$value); + } + + public function searchIsMerAttr($query, $value) + { + if ($value == 1) { + $query->where('mer_id','>',0); + } else { + $query->where('mer_id',0); + } + } + +} diff --git a/app/common/model/store/parameter/ParameterValue.php b/app/common/model/store/parameter/ParameterValue.php new file mode 100644 index 00000000..7ee90338 --- /dev/null +++ b/app/common/model/store/parameter/ParameterValue.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- + +namespace app\common\model\store\parameter; + +use app\common\model\BaseModel; + +class ParameterValue extends BaseModel +{ + + + public static function tablePk(): string + { + return 'parameter_attr_id'; + } + + public static function tableName(): string + { + return 'parameter_value'; + } + + public function parameter() + { + return $this->hasOne(Parameter::class,'parameter_id','parameter_id'); + } +} diff --git a/app/controller/api/community/Community.php b/app/controller/api/community/Community.php index 85701158..31dd4d76 100644 --- a/app/controller/api/community/Community.php +++ b/app/controller/api/community/Community.php @@ -53,25 +53,25 @@ class Community extends BaseController */ public function lst() { - $where = $this->request->params(['keyword','topic_id','is_hot','category_id','spu_id']); - $a=true; + $where = $this->request->params(['keyword', 'topic_id', 'is_hot', 'category_id', 'spu_id']); + $a = true; if (!$where['category_id']) { unset($where['category_id']); //查询非社区数据 - $where['no_category_id']=69; - $a=false; - } else if ($where['category_id'] == -1) { + $where['no_category_id'] = 69; + $a = false; + } else if ($where['category_id'] == -1) { $where['is_type'] = $this->repository::COMMUNIT_TYPE_VIDEO; unset($where['category_id']); - if ($a &&$where['category_id']==69){ + } + if ($a && $where['category_id'] == 69) { [$page, $limit] = $this->getPage(); return app('json')->success($this->repository->getApiListTwo($where, $page, $limit, $this->user)); } - $where = array_merge($where,$this->repository::IS_SHOW_WHERE); + $where = array_merge($where, $this->repository::IS_SHOW_WHERE); [$page, $limit] = $this->getPage(); return app('json')->success($this->repository->getApiList($where, $page, $limit, $this->user)); } - /** * TODO 视频列表 * @return \think\response\Json