преди 6 месеца
родител
ревизия
828b3484a2

+ 10 - 1
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/business/newProd/controller/NewProdController.java

@@ -8,6 +8,7 @@ import com.xingxi.common.core.domain.AjaxResult;
 import com.xingxi.common.core.page.TableDataInfo;
 import com.xingxi.common.enums.BusinessType;
 import com.xingxi.common.utils.poi.ExcelUtil;
+import com.xingxi.system.service.ISysConfigService;
 import com.xingxi.web.controller.business.newProd.domain.NewProdVo;
 import com.xingxi.web.controller.business.newProd.service.INewProdVoService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -29,6 +30,8 @@ public class NewProdController extends BaseController {
     private String prefix = "business/newProd";
 
     @Resource
+    private ISysConfigService configService;
+    @Resource
     private INewProdService newProdService;
     @Resource
     private INewProdVoService newProdVoService;
@@ -72,7 +75,13 @@ public class NewProdController extends BaseController {
     @PostMapping("/add")
     @ResponseBody
     public AjaxResult addSave(NewProd newProd) {
-        return toAjax(newProdService.insertNewProd(newProd));
+        int dispLimit = Integer.parseInt(configService.selectConfigByKey("miniprogram.prod.dispLimit"));
+        List<NewProd> list = newProdService.selectNewProdList(newProd);
+        if (list.size() >= dispLimit) {
+            return new AjaxResult(AjaxResult.Type.ERROR, "可添加商品已达上限!");
+        } else {
+            return toAjax(newProdService.insertNewProd(newProd));
+        }
     }
 
     /**

+ 10 - 1
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/business/popular/controller/PopularProdController.java

@@ -8,6 +8,7 @@ import com.xingxi.common.core.domain.AjaxResult;
 import com.xingxi.common.core.page.TableDataInfo;
 import com.xingxi.common.enums.BusinessType;
 import com.xingxi.common.utils.poi.ExcelUtil;
+import com.xingxi.system.service.ISysConfigService;
 import com.xingxi.web.controller.business.popular.domain.PopularProdVo;
 import com.xingxi.web.controller.business.popular.service.IPopularProdVoService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -29,6 +30,8 @@ public class PopularProdController extends BaseController {
     private String prefix = "business/popularProd";
 
     @Resource
+    private ISysConfigService configService;
+    @Resource
     private IPopularProdService popularProdService;
     @Resource
     private IPopularProdVoService popularProdVoService;
@@ -72,7 +75,13 @@ public class PopularProdController extends BaseController {
     @PostMapping("/add")
     @ResponseBody
     public AjaxResult addSave(PopularProd popularProd) {
-        return toAjax(popularProdService.insertPopularProd(popularProd));
+        int dispLimit = Integer.parseInt(configService.selectConfigByKey("miniprogram.prod.dispLimit"));
+        List<PopularProd> list = popularProdService.selectPopularProdList(popularProd);
+        if (list.size() >= dispLimit) {
+            return new AjaxResult(AjaxResult.Type.ERROR, "可添加商品已达上限!");
+        } else {
+            return toAjax(popularProdService.insertPopularProd(popularProd));
+        }
     }
 
     /**

+ 10 - 1
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/business/suggest/controller/SuggestProdController.java

@@ -8,6 +8,7 @@ import com.xingxi.common.core.domain.AjaxResult;
 import com.xingxi.common.core.page.TableDataInfo;
 import com.xingxi.common.enums.BusinessType;
 import com.xingxi.common.utils.poi.ExcelUtil;
+import com.xingxi.system.service.ISysConfigService;
 import com.xingxi.web.controller.business.suggest.domain.SuggestProdVo;
 import com.xingxi.web.controller.business.suggest.service.ISuggestProdVoService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -29,6 +30,8 @@ public class SuggestProdController extends BaseController {
     private String prefix = "business/suggestProd";
 
     @Resource
+    private ISysConfigService configService;
+    @Resource
     private ISuggestProdService suggestProdService;
     @Resource
     private ISuggestProdVoService suggestProdVoService;
@@ -72,7 +75,13 @@ public class SuggestProdController extends BaseController {
     @PostMapping("/add")
     @ResponseBody
     public AjaxResult addSave(SuggestProd suggestProd) {
-        return toAjax(suggestProdService.insertSuggestProd(suggestProd));
+        int dispLimit = Integer.parseInt(configService.selectConfigByKey("miniprogram.prod.dispLimit"));
+        List<SuggestProd> list = suggestProdService.selectSuggestProdList(suggestProd);
+        if (list.size() >= dispLimit) {
+            return new AjaxResult(AjaxResult.Type.ERROR, "可添加商品已达上限!");
+        } else {
+            return toAjax(suggestProdService.insertSuggestProd(suggestProd));
+        }
     }
 
     /**

+ 24 - 5
08.src/Xingxi/xingxi-admin/src/main/resources/templates/business/newProd/newProd.html

@@ -160,7 +160,6 @@
         });
 
         function selectMerchantProd() {
-            console.log($("#sort").val());
             var rows = $.map($("#mercProd-table").bootstrapTable('getData'), function (row) {
                 return $.common.getItemField(row, "mercProdId");
             });
@@ -171,7 +170,7 @@
                 maxmin: false,
                 shade: 0.3,
                 area: ['800px', '690px'],
-                title: '选择商户商品',
+                title: '选择最新上架商品',
                 // 弹层外区域关闭
                 shadeClose: true,
                 success: function (layero, index) {
@@ -179,7 +178,7 @@
                         id: "merchant-prod-table",
                         formId: "formSelectMerchant",
                         url: ctx + "master/merchant/prod/list",
-                        modalName: "选择商户商品",
+                        modalName: "选择最新上架商品",
                         showSearch: false,
                         showColumns: false,
                         showRefresh: false,
@@ -239,8 +238,28 @@
                         "mercProdId": $("#mercProdId").val(),
                         "sort": $("#sort").val() * 1 + 1,
                     };
-                    $.operate.post(prefix + "/add", data, refreshTab);
-                    layer.closeAll();
+                    $.ajax({
+                        url: prefix + "/add",
+                        data: data,
+                        type: "post",
+                        processData: false,
+                        success: function(result) {
+                            if (result.code === web_status.SUCCESS) {
+                                $.modal.closeAll();
+                                $.modal.enable();
+                                $.modal.alertSuccess("添加成功。");
+                                refreshTab();
+                            } else if (result.code === web_status.WARNING) {
+                                $.modal.closeAll();
+                                $.modal.enable();
+                                $.modal.alertWarning(result.msg)
+                            } else {
+                                $.modal.closeAll();
+                                $.modal.enable();
+                                $.modal.alertError(result.msg);
+                            }
+                        }
+                    });
                 }
             });
         }

+ 16 - 5
08.src/Xingxi/xingxi-admin/src/main/resources/templates/business/popularProd/popularProd.html

@@ -160,7 +160,6 @@
         });
 
         function selectMerchantProd() {
-            console.log($("#sort").val());
             var rows = $.map($("#mercProd-table").bootstrapTable('getData'), function (row) {
                 return $.common.getItemField(row, "mercProdId");
             });
@@ -171,7 +170,7 @@
                 maxmin: false,
                 shade: 0.3,
                 area: ['800px', '690px'],
-                title: '选择商户商品',
+                title: '选择热门商品',
                 // 弹层外区域关闭
                 shadeClose: true,
                 success: function (layero, index) {
@@ -179,7 +178,7 @@
                         id: "merchant-prod-table",
                         formId: "formSelectMerchant",
                         url: ctx + "master/merchant/prod/list",
-                        modalName: "选择商户商品",
+                        modalName: "选择热门商品",
                         showSearch: false,
                         showColumns: false,
                         showRefresh: false,
@@ -239,8 +238,20 @@
                         "mercProdId": $("#mercProdId").val(),
                         "sort": $("#sort").val() * 1 + 1,
                     };
-                    $.operate.post(prefix + "/add", data, refreshTab);
-                    layer.closeAll();
+                    if (result.code === web_status.SUCCESS) {
+                        $.modal.closeAll();
+                        $.modal.enable();
+                        $.modal.alertSuccess("添加成功。");
+                        refreshTab();
+                    } else if (result.code === web_status.WARNING) {
+                        $.modal.closeAll();
+                        $.modal.enable();
+                        $.modal.alertWarning(result.msg)
+                    } else {
+                        $.modal.closeAll();
+                        $.modal.enable();
+                        $.modal.alertError(result.msg);
+                    }
                 }
             });
         }

+ 16 - 4
08.src/Xingxi/xingxi-admin/src/main/resources/templates/business/suggestProd/suggestProd.html

@@ -160,7 +160,6 @@
         });
 
         function selectMerchantProd() {
-            console.log($("#sort").val());
             var rows = $.map($("#mercProd-table").bootstrapTable('getData'), function (row) {
                 return $.common.getItemField(row, "mercProdId");
             });
@@ -171,7 +170,7 @@
                 maxmin: false,
                 shade: 0.3,
                 area: ['800px', '690px'],
-                title: '选择商户商品',
+                title: '选择推荐商品',
                 // 弹层外区域关闭
                 shadeClose: true,
                 success: function (layero, index) {
@@ -179,7 +178,7 @@
                         id: "merchant-prod-table",
                         formId: "formSelectMerchant",
                         url: ctx + "master/merchant/prod/list",
-                        modalName: "选择商户商品",
+                        modalName: "选择推荐商品",
                         showSearch: false,
                         showColumns: false,
                         showRefresh: false,
@@ -239,7 +238,20 @@
                         "mercProdId": $("#mercProdId").val(),
                         "sort": $("#sort").val() * 1 + 1,
                     };
-                    $.operate.post(prefix + "/add", data, refreshTab);
+                    if (result.code === web_status.SUCCESS) {
+                        $.modal.closeAll();
+                        $.modal.enable();
+                        $.modal.alertSuccess("添加成功。");
+                        refreshTab();
+                    } else if (result.code === web_status.WARNING) {
+                        $.modal.closeAll();
+                        $.modal.enable();
+                        $.modal.alertWarning(result.msg)
+                    } else {
+                        $.modal.closeAll();
+                        $.modal.enable();
+                        $.modal.alertError(result.msg);
+                    }
                     layer.closeAll();
                 }
             });