| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace backend\modules\common\logic;
- use common\enums\DiyEnum;
- use common\enums\StatusEnum;
- use common\models\diy\DiyMallTemplate;
- use common\models\diy\DiyTemplate;
- use common\traits\ErrorTrait;
- class DiyTemplateLogic {
- use ErrorTrait;
- /**
- *
- * 模板市场列表
- * @Author: lun
- * @DateTime: 2022/8/4 0004 10:47
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $params
- * @return array
- */
- public static function TemplateMarket($params)
- {
- // 条件组合
- $where = [];
- !empty($params['cate_id']) && $where[] = ['=', 'cate_id', $params['cate_id']];
- !empty($params['template']) && $where[] = ['=', 'template', $params['template']];
- !empty($params['title']) && $where[] = ['like', 'title', $params['title']];
- if ($params['route_type'] == 'market') {
- $where[] = ['=', 'is_on_sale', StatusEnum::ENABLED];
- $where[] = ['=', 'status', StatusEnum::ENABLED];
- // 判断查询商城已有的模板
- if (!empty($params['mid'])) {
- $data['mall_template'] = DiyMallTemplate::getMallTemplate($params['mid'],"template_id,expire_time");
- }
- } else {
- $where[] = ['<>', 'status', StatusEnum::DELETE];
- }
- $order = 'created_at desc';
- $select = ['id','title','cate_id','template','created_at','cover','setting','is_on_sale','status'];
- $list_params = array('select' => $select,'where' => $where, 'order' => $order, 'limit' => $params['limit'] ?? 20);
- $list = DiyTemplate::listPage($list_params, false, true);
- if (empty($list)) return [];
- $data['list'] = $list;
- // 获取模板
- $data['cate_arr'] = DiyEnum::getTemplateCate();
- return $data;
- }
- }
|