Prechádzať zdrojové kódy

Merge branch 'develop'

durong 5 rokov pred
rodič
commit
a5401b4903

+ 1 - 1
app/Http/Controllers/CmsContentTemplateSetController.php

@@ -161,7 +161,7 @@ class CmsContentTemplateSetController extends BaseController
 
     }
 
-    //v0.3兑换商城内容预览
+    //v0.3兑换专区内容预览
     public function exchangeMall(Request $request)
     {
         $validator = Validator::make($request->all(), [

+ 3 - 3
app/Repositories/CmsContentTemplateRepository.php

@@ -51,7 +51,7 @@ class CmsContentTemplateRepository {
         }
         if ($request['apply_type'] == 2) {
             if ($this->cmsContentTemplate->where('apply_type', '=', 2)->exists()) {
-                throw new HttpException(500, '兑换商城只能有一个');
+                throw new HttpException(500, '兑换专区只能有一个');
             }
         }
 
@@ -97,7 +97,7 @@ class CmsContentTemplateRepository {
             throw new HttpException(500, '配置内容为空无法开启');
         }
         if ($template_id->apply_type == 2){
-            throw new HttpException(500, '兑换商城不允许手动关闭');
+            throw new HttpException(500, '兑换专区不允许手动关闭');
         }
 
         $template_id->is_open = $request['is_open'];
@@ -132,7 +132,7 @@ class CmsContentTemplateRepository {
     {
         $template = $this->cmsContentTemplate->select('city_id','apply_type')->where('id',$data['id'])->first();
         if ($template->apply_type == 2){
-            throw new HttpException(500, '兑换商城不允许修改名称');
+            throw new HttpException(500, '兑换专区不允许修改名称');
         }
 
         $template_array = $this->cmsContentTemplate->where(['city_id' => $template->city_id, 'apply_type' => $template->apply_type])->get();

+ 25 - 7
app/Repositories/CmsContentTemplateSetRepository.php

@@ -121,6 +121,9 @@ class CmsContentTemplateSetRepository
             if (isset($v['link_type'])) {
                 $rules[$k]['link_type'] = intval($v['link_type']);
             }
+            if (isset($v['link_url'])) {
+                $rules[$k]['link_url'] = trim($v['link_url']);
+            }
         }
 
         $templateSet = [
@@ -144,7 +147,7 @@ class CmsContentTemplateSetRepository
 
                         if ($template_id->apply_type == 2) {
                             if (!$subject || $subject->is_open != 1 || $subject->used_mall != 0) {
-                                throw new HttpException(500, '所填专题已关闭或不是兑换商城专题');
+                                throw new HttpException(500, '所填专题已关闭或不是兑换专区专题');
                             }
                         }
 
@@ -177,7 +180,7 @@ class CmsContentTemplateSetRepository
                         $subject = $this->cmsSubject->where('id', intval($v['link_url']))->first();
                         if ($template_id->apply_type == 2) {
                             if (!$subject || $subject->is_open != 1 || $subject->used_mall != 0) {
-                                throw new HttpException(500, '所填专题已关闭或不是兑换商城专题');
+                                throw new HttpException(500, '所填专题已关闭或不是兑换专区专题');
                             }
                         }
                         $subject->used_count += 1;
@@ -210,7 +213,7 @@ class CmsContentTemplateSetRepository
                 $subject = $this->cmsSubject->where('id', intval($request['rule']['link_url']))->first();
                 if ($request['apply_type'] == 2) {
                     if (!$subject || $subject->is_open != 1 || $subject->used_mall != 0) {
-                        throw new HttpException(500, '所填专题已关闭或不是兑换商城专题');
+                        throw new HttpException(500, '所填专题已关闭或不是兑换专区专题');
                     }
                 }
                 $subject->used_count += 1;
@@ -228,7 +231,7 @@ class CmsContentTemplateSetRepository
             $subject = $this->cmsSubject->where('id', intval($request['rule']['link_url']))->first();
             if ($request['apply_type'] == 2) {
                 if (!$subject || $subject->is_open != 1 || $subject->used_mall != 0) {
-                    throw new HttpException(500, '所填专题已关闭或不是兑换商城专题');
+                    throw new HttpException(500, '所填专题已关闭或不是兑换专区专题');
                 }
             }
             $subject->used_count += 1;
@@ -262,6 +265,12 @@ class CmsContentTemplateSetRepository
     public function advertisementSet($request)
     {
         $advertisement_id = $request['id'] ?? '';
+        if (isset($request['rule']['link_type'])) {
+            $request['rule']['link_type'] = intval($request['rule']['link_type']);
+        }
+        if (isset($request['rule']['link_url'])) {
+            $request['rule']['link_url'] = trim($request['rule']['link_url']);
+        }
         $subject = [
             'tpl_id' => $request['tpl_id'],
             'rule' => json_encode($request['rule']),
@@ -299,6 +308,9 @@ class CmsContentTemplateSetRepository
         if (isset($request['rule']['link_type'])) {
             $request['rule']['link_type'] = intval($request['rule']['link_type']);
         }
+        if (isset($request['rule']['link_url'])) {
+            $request['rule']['link_url'] = trim($request['rule']['link_url']);
+        }
         if (isset($request['rule']['show_num'])) {
             $request['rule']['show_num'] = intval($request['rule']['show_num']);
         }
@@ -318,7 +330,7 @@ class CmsContentTemplateSetRepository
                 $subject = $this->cmsSubject->where('id', intval($request['rule']['link_url']))->first();
                 if ($template_id->apply_type == 2) {
                     if (!$subject || $subject->is_open != 1 || $subject->used_mall != 0) {
-                        throw new HttpException(500, '所填专题已关闭或不是兑换商城专题');
+                        throw new HttpException(500, '所填专题已关闭或不是兑换专区专题');
                     }
                 }
 
@@ -347,6 +359,12 @@ class CmsContentTemplateSetRepository
     public function categorySet($request)
     {
         $category_id = $request['id'] ?? '';
+        if (isset($request['rule']['link_type'])) {
+            $request['rule']['link_type'] = intval($request['rule']['link_type']);
+        }
+        if (isset($request['rule']['link_url'])) {
+            $request['rule']['link_url'] = trim($request['rule']['link_url']);
+        }
         $subject = [
             'tpl_id' => $request['tpl_id'],
             'rule' => json_encode($request['rule']),
@@ -409,7 +427,7 @@ class CmsContentTemplateSetRepository
         //同一个城市同一个模板(团购/菜市场) 只能有一种状态(草稿/发布),已发布的一旦被编辑把之前的直接删掉
         $template = $this->cmsContentTemplate->select('id', 'city_name', 'city_id', 'title', 'apply_type', 'is_open', 'status')->where('id', $request['tpl_id'])->first();
 
-        //兑换商城检测banner是否设置
+        //兑换专区检测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();
@@ -611,7 +629,7 @@ class CmsContentTemplateSetRepository
     }
 
     /**
-     * v0.3兑换商城内容预览
+     * v0.3兑换专区内容预览
      */
     public function exchangeMall($request)
     {

+ 1 - 1
app/Transformers/CmsSubjectTransformer.php

@@ -19,7 +19,7 @@ class CmsSubjectTransformer extends TransformerAbstract
             'product_count'    => $cmsSubject['product_count'],
             'is_open'    => $cmsSubject['is_open'],
             'used_mall'    => $cmsSubject['used_mall'],
-            'used_mall_name'    => $cmsSubject['used_mall'] == 0 ? '兑换商城' : '电商商城',
+            'used_mall_name'    => $cmsSubject['used_mall'] == 0 ? '兑换专区' : '电商商城',
             'subject_img'    => $cmsSubject['subject_img'],
         ];
     }

+ 1 - 1
app/Transformers/CmsSubjectViewTransformer.php

@@ -20,7 +20,7 @@ class CmsSubjectViewTransformer extends TransformerAbstract
             'product_id'    => $cmsSubject['product_id'],
             'sort'    => $cmsSubject['sort'],
             'used_mall'    => $cmsSubject['used_mall'],
-            'used_mall_name'    => $cmsSubject['used_mall'] == 0 ? '兑换商城' : '电商商城',
+            'used_mall_name'    => $cmsSubject['used_mall'] == 0 ? '兑换专区' : '电商商城',
             'subject_img'    => $cmsSubject['subject_img']
         ];
     }

+ 1 - 1
database/migrations/2019_07_08_085907_add_used_mall_to_cms_subject_table.php

@@ -14,7 +14,7 @@ class AddUsedMallToCmsSubjectTable extends Migration
     public function up()
     {
         Schema::table('cms_subject', function (Blueprint $table) {
-            $table->tinyInteger('used_mall')->default(1)->comment('对应商城:0.兑换商城;1.电商商城');
+            $table->tinyInteger('used_mall')->default(1)->comment('对应商城:0.兑换专区;1.电商商城');
             $table->string('subject_img')->default('')->comment('专题顶图');
             \Illuminate\Support\Facades\DB::statement("ALTER TABLE cms_subject MODIFY COLUMN show_type TINYINT (4) NOT NULL DEFAULT 0 COMMENT '商品展示方式:0:左图右字;1:通栏大图;2:左右滑动;3.左右两列'");
         });

+ 1 - 1
database/migrations/2019_07_09_061003_update_apply_type_to_cms_content_template_table.php

@@ -14,7 +14,7 @@ class UpdateApplyTypeToCmsContentTemplateTable extends Migration
     public function up()
     {
         Schema::table('cms_content_template', function (Blueprint $table) {
-            \Illuminate\Support\Facades\DB::statement("ALTER TABLE cms_content_template MODIFY COLUMN apply_type TINYINT (4) NOT NULL DEFAULT 1 COMMENT '对应模板:0:团购首页;1:菜市场首页;2.兑换商城首页'");
+            \Illuminate\Support\Facades\DB::statement("ALTER TABLE cms_content_template MODIFY COLUMN apply_type TINYINT (4) NOT NULL DEFAULT 1 COMMENT '对应模板:0:团购首页;1:菜市场首页;2.兑换专区首页'");
         });
     }
 

+ 1 - 1
database/seeds/CmsContentTemplateTableSeeder.php

@@ -18,7 +18,7 @@ class CmsContentTemplateTableSeeder extends Seeder
             [
                 'city_id'   => 0,
                 'city_name'    => '',
-                'title'    => '兑换商城',
+                'title'    => '兑换专区',
                 'apply_type'    => 2,
                 'is_open'    => 1,
                 'status'    => 1,

+ 1 - 1
routes/api.php

@@ -95,7 +95,7 @@ $api->version('v1', [
         //获取对应城市模板名称
         $api->get('templateName', 'CmsContentTemplateSetController@templateName');
 
-        //v0.3兑换商城内容预览
+        //v0.3兑换专区内容预览
         $api->post('/templateSet/exchangeMall', 'CmsContentTemplateSetController@exchangeMall');
     });
 });