|
@@ -218,6 +218,18 @@ class CmsContentTemplateSetRepository {
|
|
|
//同一个城市同一个模板(团购/菜市场) 只能有一种状态(草稿/发布),已发布的一旦被编辑把之前的直接删掉
|
|
|
$templateSet = $this->cmsContentTemplateSet->where('tpl_id',$request['tpl_id'])->select('id','status')->get();
|
|
|
$tem_array = $templateSet->toArray();
|
|
|
+ $template = $this->cmsContentTemplate->select('id','city_name','city_id','title','apply_type','is_open')->where('id',$request['tpl_id'])->first();
|
|
|
+ $where = [
|
|
|
+ 'city_id'=>$template->city_id,
|
|
|
+ 'title'=>$template->title,
|
|
|
+ 'apply_type'=>$template->apply_type,
|
|
|
+ ];
|
|
|
+ $templates = $this->cmsContentTemplate->where($where)->get();
|
|
|
+ foreach ($templates->toArray() as $k=>$v){
|
|
|
+ if ($v['is_open'] == 1){
|
|
|
+ $this->cmsContentTemplate->update(['is_open'=>0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
foreach ($tem_array as $k=>$v) {
|
|
|
if ($v['status'] == 1) {
|
|
|
$result = $this->cmsContentTemplateSet->where('id', $v['id'])->delete();
|
|
@@ -230,6 +242,13 @@ class CmsContentTemplateSetRepository {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ $update_tpl = $this->cmsContentTemplate->where('id',$request['tpl_id'])->update(['is_open'=>1]);
|
|
|
+ if (!$update_tpl){
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '修改失败,请重试',
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }
|
|
|
$res = $this->cmsContentTemplateSet->where('tpl_id',$request['tpl_id'])->update(['status'=>1]);
|
|
|
if (!$res){
|
|
|
return Response::create([
|
|
@@ -255,10 +274,12 @@ class CmsContentTemplateSetRepository {
|
|
|
$group_array = [];
|
|
|
if ($request['type'] == 0){
|
|
|
$group_array['apply_type'] = 0;
|
|
|
+ $group_array['tpl_id'] = $request['tpl_id'];
|
|
|
$group_array['title'] = $temalates->title;
|
|
|
$group_array['content'] =[];
|
|
|
}else{//菜市场首页
|
|
|
$group_array['apply_type'] = 1;
|
|
|
+ $group_array['tpl_id'] = $request['tpl_id'];
|
|
|
$group_array['title'] = $temalates->title;
|
|
|
$group_array['content'] =[];
|
|
|
}
|