|
@@ -44,24 +44,32 @@ class CmsContentTemplateRepository {
|
|
*/
|
|
*/
|
|
public function create($request)
|
|
public function create($request)
|
|
{
|
|
{
|
|
- $where = ['city_id'=>$request['city_id'],'apply_type'=>$request['apply_type']];
|
|
|
|
- $template = $this->cmsContentTemplate->where($where)->get();
|
|
|
|
- if (count($template) >= 1){
|
|
|
|
- throw new HttpException(500, '当前城市该模版类型已存在');
|
|
|
|
|
|
+ if (isset($request['city_id'])) {
|
|
|
|
+ if ($this->cmsContentTemplate->where(['city_id' => $request['city_id'], 'apply_type' => $request['apply_type']])->exists()) {
|
|
|
|
+ throw new HttpException(500, '当前城市该模版类型已存在');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ($request['apply_type'] == 2) {
|
|
|
|
+ if ($this->cmsContentTemplate->where(['title' => $request['title'], 'apply_type' => 2])->exists()) {
|
|
|
|
+ throw new HttpException(500, '当前模版类型下该名称已存在');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
$subject = [
|
|
$subject = [
|
|
'title' => $request['title'],
|
|
'title' => $request['title'],
|
|
- 'city_id' => $request['city_id'],
|
|
|
|
- 'city_name' => $request['city_name'],
|
|
|
|
|
|
+ 'city_id' => isset($request['city_id']) ? $request['city_id'] : 0,
|
|
|
|
+ 'city_name' => isset($request['city_name']) ? $request['city_name'] : '',
|
|
'apply_type' => $request['apply_type'],
|
|
'apply_type' => $request['apply_type'],
|
|
'status' => 1,
|
|
'status' => 1,
|
|
'is_open' => 0,
|
|
'is_open' => 0,
|
|
];
|
|
];
|
|
|
|
|
|
- if ($request['city_id'] == 610100){
|
|
|
|
|
|
+ //默认开启,且不可手动关闭
|
|
|
|
+ if (isset($request['city_id']) && $request['city_id'] == 610100){
|
|
|
|
+ $subject['is_open'] = 1;
|
|
|
|
+ }
|
|
|
|
+ if ($request['apply_type'] == 2){
|
|
$subject['is_open'] = 1;
|
|
$subject['is_open'] = 1;
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if (!$this->cmsContentTemplate->create($subject)) {
|
|
if (!$this->cmsContentTemplate->create($subject)) {
|
|
@@ -88,6 +96,9 @@ class CmsContentTemplateRepository {
|
|
if (count($template) == 0){
|
|
if (count($template) == 0){
|
|
throw new HttpException(500, '配置内容为空无法开启');
|
|
throw new HttpException(500, '配置内容为空无法开启');
|
|
}
|
|
}
|
|
|
|
+ if ($template_id->apply_type == 2){
|
|
|
|
+ throw new HttpException(500, '兑换商城不允许手动关闭');
|
|
|
|
+ }
|
|
|
|
|
|
$template_id->is_open = $request['is_open'];
|
|
$template_id->is_open = $request['is_open'];
|
|
$template_id->updated_at = date('Y-m-d H:i:s');
|
|
$template_id->updated_at = date('Y-m-d H:i:s');
|
|
@@ -117,7 +128,7 @@ class CmsContentTemplateRepository {
|
|
public function updateTemplateName($data)
|
|
public function updateTemplateName($data)
|
|
{
|
|
{
|
|
$template = $this->cmsContentTemplate->select('city_id','apply_type')->where('id',$data['id'])->first();
|
|
$template = $this->cmsContentTemplate->select('city_id','apply_type')->where('id',$data['id'])->first();
|
|
- $template_array = $this->cmsContentTemplate->where(['city_id'=>$template->city_id,'apply_type'=>$template->apply_type])->get();
|
|
|
|
|
|
+ $template_array = $this->cmsContentTemplate->where(['city_id' => $template->city_id, 'apply_type' => $template->apply_type])->get();
|
|
|
|
|
|
if (count($template_array)>1){
|
|
if (count($template_array)>1){
|
|
foreach ($template_array->toArray() as $value){
|
|
foreach ($template_array->toArray() as $value){
|