|
@@ -48,7 +48,8 @@ class CmsContentTemplateSetRepository
|
|
|
$request['city_id'] = $v['city_id'];
|
|
|
if ($v['apply_type'] == 2) {
|
|
|
return $this->exchangeMall($request);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ if ($v['apply_type'] == 0 || $v['apply_type'] == 1){
|
|
|
return $this->preview($request);
|
|
|
}
|
|
|
}
|
|
@@ -79,6 +80,7 @@ class CmsContentTemplateSetRepository
|
|
|
'status' => $val['status'],
|
|
|
'sort' => $val['sort'],
|
|
|
'name' => $val['name'],
|
|
|
+ 'floor_img' => $val['floor_img'],
|
|
|
];
|
|
|
$result = $this->cmsContentTemplateSet->create($copy_template);
|
|
|
if (!$result) {
|
|
@@ -94,7 +96,8 @@ class CmsContentTemplateSetRepository
|
|
|
|
|
|
if ($res->apply_type == 2) {
|
|
|
return $this->exchangeMall($request);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ if ($res->apply_type == 0 || $res->apply_type == 1){
|
|
|
return $this->preview($request);
|
|
|
}
|
|
|
//return Response::create();
|
|
@@ -354,9 +357,21 @@ class CmsContentTemplateSetRepository
|
|
|
{
|
|
|
$group_key = config('constants.CMS_GROUP');
|
|
|
$market_key = config('constants.CMS_MARKET');
|
|
|
+ $exchange_key = config('constants.CMS_EXCHANGE');
|
|
|
|
|
|
//同一个城市同一个模板(团购/菜市场) 只能有一种状态(草稿/发布),已发布的一旦被编辑把之前的直接删掉
|
|
|
$template = $this->cmsContentTemplate->select('id', 'city_name', 'city_id', 'title', 'apply_type', 'is_open', 'status')->where('id', $request['tpl_id'])->first();
|
|
|
+
|
|
|
+ //兑换商城检测banner是否设置
|
|
|
+ if ($template->apply_type == 2) {
|
|
|
+ $testing_banner = $this->cmsContentTemplateSet->select('rule')->where(['tpl_id' => $request['tpl_id'], 'area_type' => 0])->first();
|
|
|
+ $testing_banner = $testing_banner->toArray();
|
|
|
+ $rule = json_decode($testing_banner['rule'], true);
|
|
|
+ if (empty($testing_banner) || count($rule) == 0) {
|
|
|
+ throw new HttpException(500, '请先上传banner后再发布');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$where = [
|
|
|
'city_id' => $template->city_id,
|
|
|
'title' => $template->title,
|
|
@@ -418,6 +433,10 @@ class CmsContentTemplateSetRepository
|
|
|
if (Cache::has($market_key)) {
|
|
|
Cache::forget($market_key);
|
|
|
}
|
|
|
+ } elseif ($template->apply_type == 2) {
|
|
|
+ if (Cache::has($exchange_key)) {
|
|
|
+ Cache::forget($exchange_key);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -561,10 +580,10 @@ class CmsContentTemplateSetRepository
|
|
|
$banner_rule = $this->cmsContentTemplateSet->select('id', 'rule')->where(['tpl_id' => $request['tpl_id'], 'area_type' => 0])->orderBy('id', 'desc')->limit(1)->get();
|
|
|
$new_rule = [];
|
|
|
foreach ($banner_rule->toArray() as $k => $v) {
|
|
|
- if (count(json_decode($v['rule'])) > 0) {
|
|
|
- $new_rule[$k]['id'] = $v['id'];
|
|
|
- $new_rule[$k]['rule'] = json_decode($v['rule'], true);
|
|
|
- }
|
|
|
+// if (count(json_decode($v['rule'])) > 0) {
|
|
|
+ $new_rule[$k]['id'] = $v['id'];
|
|
|
+ $new_rule[$k]['rule'] = json_decode($v['rule'], true);
|
|
|
+// }
|
|
|
}
|
|
|
$group_array['content'][0]['rule'] = $new_rule;
|
|
|
|
|
@@ -573,22 +592,21 @@ class CmsContentTemplateSetRepository
|
|
|
$count = count($all_subject);
|
|
|
$new_rule = [];
|
|
|
foreach ($all_subject as $k => $v) {
|
|
|
- $new_rule[$k]['rule'] = [];
|
|
|
- if (count(json_decode($v['rule'])) > 0) {
|
|
|
- $new_rule[$k]['area_type'] = $v['area_type'];
|
|
|
- $new_rule[$k]['rule']['id'] = $v['id'];
|
|
|
- $new_rule[$k]['rule']['name'] = $v['name'];
|
|
|
- $new_rule[$k]['rule']['floor_img'] = $v['floor_img'];
|
|
|
- $new_rule[$k]['rule']['rule'] = json_decode($v['rule'], true);
|
|
|
- }
|
|
|
- }
|
|
|
- foreach ($new_rule as $k => $v) {
|
|
|
- $group_array['content'][$k + 1]['area_type'] = $new_rule[$k]['area_type'];
|
|
|
- $group_array['content'][$k + 1]['rule'] = array($new_rule[$k]['rule']);
|
|
|
+// if (count(json_decode($v['rule'])) > 0) {
|
|
|
+ $new_rule[$k]['area_type'] = $v['area_type'];
|
|
|
+ $new_rule[$k]['rule']['id'] = $v['id'];
|
|
|
+// $new_rule[$k]['rule']['name'] = $v['name'];
|
|
|
+ $new_rule[$k]['rule']['sort'] = $v['sort'];
|
|
|
+ $new_rule[$k]['rule']['floor_img'] = $v['floor_img'];
|
|
|
+ $new_rule[$k]['rule']['rule'] = json_decode($v['rule'], true);
|
|
|
+// }
|
|
|
}
|
|
|
+ foreach ($new_rule as $k => $v) {
|
|
|
+ $group_array['content'][$k + 1]['area_type'] = $new_rule[$k]['area_type'];
|
|
|
+ $group_array['content'][$k + 1]['rule'] = array($new_rule[$k]['rule']);
|
|
|
+ }
|
|
|
|
|
|
- $group_array['content'][$count + 1]['area_type'] = 2;
|
|
|
- $floor_rule = $this->cmsContentTemplateSet->select('id', 'rule', 'floor_img')->where(['tpl_id' => $request['tpl_id'], 'area_type' => 2])->get();
|
|
|
+ $floor_rule = $this->cmsContentTemplateSet->select('id', 'rule', 'floor_img')->where(['tpl_id' => $request['tpl_id'], 'area_type' => 2])->orderBy('id', 'asc')->get();
|
|
|
$new_rule = [];
|
|
|
foreach ($floor_rule->toArray() as $k => $v) {
|
|
|
$new_rule[$k]['id'] = $v['id'];
|
|
@@ -610,7 +628,8 @@ class CmsContentTemplateSetRepository
|
|
|
unset($v['link_type']);
|
|
|
}
|
|
|
}
|
|
|
- $group_array['content'][$count + 1]['rule'] = $new_rule;
|
|
|
+ $group_array['content'][$count + 1]['area_type'] = 2;
|
|
|
+ $group_array['content'][$count + 1]['rule'] = $new_rule;
|
|
|
|
|
|
return $group_array;
|
|
|
}
|