Prechádzať zdrojové kódy

首页改版专区商品列表

zhijiezhao 3 mesiacov pred
rodič
commit
ae882d83da

+ 23 - 0
src/main/java/com/caimei/modules/newhome/dao/NewPageZoneDao.java

@@ -0,0 +1,23 @@
+package com.caimei.modules.newhome.dao;
+
+import com.caimei.modules.newhome.entity.NewPageZone;
+import com.caimei.modules.product.entity.Product;
+import com.thinkgem.jeesite.common.persistence.CrudDao;
+import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@MyBatisDao
+public interface NewPageZoneDao extends CrudDao<NewPageZone> {
+
+    void saveSort(@Param("sort") String sort, @Param("id") String id, @Param("zoneId") Integer zoneId);
+
+    List<Product> findZoneProductList(Product product);
+
+    List<Product> findProducts(Product product);
+
+    void addProducts(@Param("split") String[] split, @Param("zoneId") Integer zoneId);
+
+    void delProduct(@Param("productId") Integer productId, @Param("zoneId") Integer zoneId);
+}

+ 16 - 0
src/main/java/com/caimei/modules/newhome/entity/NewPageZone.java

@@ -0,0 +1,16 @@
+package com.caimei.modules.newhome.entity;
+
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+import lombok.Data;
+
+@Data
+public class NewPageZone extends DataEntity<NewPageZone> {
+    private static final long serialVersionUID = 1L;
+    private String floorTitle;
+    private String floorDetail;
+    private String sort;
+    // Pc端状态 0停用 1启用
+    private String wwwEnabledStatus;
+    // CRM端状态 0停用 1启用
+    private String crmEnabledStatus;
+}

+ 45 - 0
src/main/java/com/caimei/modules/newhome/service/NewPageZoneService.java

@@ -0,0 +1,45 @@
+package com.caimei.modules.newhome.service;
+
+import com.caimei.modules.newhome.dao.NewPageZoneDao;
+import com.caimei.modules.newhome.entity.NewPageZone;
+import com.caimei.modules.product.entity.Product;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.service.CrudService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class NewPageZoneService extends CrudService<NewPageZoneDao, NewPageZone> {
+
+    @Resource
+    private NewPageZoneDao pageZoneDao;
+
+    @Transactional(readOnly = false)
+    public void saveSort(String sort, String id, Integer zoneId) {
+        pageZoneDao.saveSort(sort, id, zoneId);
+    }
+
+    public List<Product> findZoneProductList(Integer zoneId, Page<Product> page) {
+        Product product = new Product();
+        product.setZoneId(zoneId);
+        product.setPage(page);
+        return pageZoneDao.findZoneProductList(product);
+    }
+
+    public List<Product> findProductList(Product product) {
+        return pageZoneDao.findProducts(product);
+    }
+
+    @Transactional(readOnly = false)
+    public void addProducts(String[] split, Integer zoneId) {
+        pageZoneDao.addProducts(split, zoneId);
+    }
+
+    @Transactional(readOnly = false)
+    public void productDel(Integer productId, Integer zoneId) {
+        pageZoneDao.delProduct(productId, zoneId);
+    }
+}

+ 268 - 0
src/main/java/com/caimei/modules/newhome/web/NewPageZoneController.java

@@ -0,0 +1,268 @@
+package com.caimei.modules.newhome.web;
+
+import com.caimei.modules.newhome.entity.NewPageZone;
+import com.caimei.modules.newhome.service.NewPageZoneService;
+import com.caimei.modules.opensearch.GenerateUtils;
+import com.caimei.modules.product.entity.Product;
+import com.caimei.modules.product.service.ProductService;
+import com.caimei.redis.RedisService;
+import com.caimei.utils.AppUtils;
+import com.google.common.collect.Maps;
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.thinkgem.jeesite.common.web.BaseController;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
+
+import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;
+
+
+@Controller
+@RequestMapping(value = "${adminPath}/newhome/newPageZone")
+public class NewPageZoneController extends BaseController {
+
+    @Resource
+    private NewPageZoneService newPageZoneService;
+    @Resource
+    private ProductService productService;
+    @Resource
+    private RedisService redisService;
+    @Resource
+    private GenerateUtils generateUtils;
+
+
+    @ModelAttribute
+    public NewPageZone get(@RequestParam(required = false) String id) {
+        NewPageZone entity = null;
+        if (StringUtils.isNotBlank(id)) {
+            entity = newPageZoneService.get(id);
+        }
+        if (entity == null) {
+            entity = new NewPageZone();
+        }
+        return entity;
+    }
+
+    @RequiresPermissions("newhome:newPageZone:view")
+    @RequestMapping(value = {"list", ""})
+    public String list(NewPageZone newPageZone, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<NewPageZone> page = newPageZoneService.findPage(new Page<NewPageZone>(request, response), newPageZone);
+        model.addAttribute("page", page);
+        return "modules/newhome/newPageZoneList";
+    }
+
+    @RequestMapping(value = "productList")
+    public String productList(Integer zoneId, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<Product> page = new Page<Product>(request, response);
+        if (0 == page.getPageSize() || -1 == page.getPageSize()) page.setPageSize(20);
+        if (0 == page.getPageNo()) page.setPageNo(1);
+        //获取组合列表
+        List<Product> list = newPageZoneService.findZoneProductList(zoneId, page);
+        page.setList(list);
+        model.addAttribute("zoneId", zoneId);
+        model.addAttribute("page", page);
+        return "modules/newhome/zoneProductList";
+    }
+
+    @RequestMapping(value = "toAddProduct")
+    public String toAddProduct(Product product, Page page, Model model) {
+        //获取采美所有商品
+        if (0 == page.getPageSize() || -1 == page.getPageSize()) page.setPageSize(30);
+        if (0 == page.getPageNo()) page.setPageNo(1);
+        product.setPage(page);
+        List<Product> productList = newPageZoneService.findProductList(product);
+        if (CollectionUtils.isNotEmpty(productList)) {
+            for (Product p : productList) {
+                p.setMainImage(AppUtils.getProductImageURL(p.getMainImage(), 0, Global.getConfig("wwwServer")));
+            }
+        }
+        page.setList(productList);
+        model.addAttribute("page", page);
+        model.addAttribute("Product", product);
+        return "modules/newhome/toSelectProduct";
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "saveAddProduct")
+    public Map<String, Object> saveAddProduct(Product product) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            String[] split = product.getProductIds().split(",");
+            //保存商品添加的组合
+            newPageZoneService.addProducts(split, product.getZoneId());
+            map.put("success", true);
+            map.put("msg", "添加成功");
+        } catch (Exception e) {
+            map.put("success", false);
+            map.put("msg", "添加失败");
+        }
+        return map;
+    }
+
+
+    @RequiresPermissions("newhome:newPageZone:view")
+    @RequestMapping(value = "form")
+    public String form(NewPageZone newPageZone, Model model) {
+        model.addAttribute("newPageZone", newPageZone);
+        return "modules/newhome/newPageZoneForm";
+    }
+
+    @RequestMapping(value = "save")
+    public String save(Integer floor, NewPageZone newPageZone, Model model, RedirectAttributes redirectAttributes) {
+        if (!beanValidator(model, newPageZone)) {
+            return form(newPageZone, model);
+        }
+        newPageZoneService.save(newPageZone);
+        cleanRedisCache();
+        addMessage(redirectAttributes, "保存楼层管理成功");
+        if (floor != null) {
+            return "redirect:" + Global.getAdminPath() + "/newhome/newPageZone/lists";
+        } else {
+            return "redirect:" + Global.getAdminPath() + "/newhome/newPageZone";
+        }
+
+    }
+
+    @RequestMapping(value = "delete")
+    public String delete(Integer floor, NewPageZone newPageZone, RedirectAttributes redirectAttributes) {
+        newPageZoneService.delete(newPageZone);
+        cleanRedisCache();
+        addMessage(redirectAttributes, "删除楼层管理成功");
+        if (floor != null) {
+            return "redirect:" + Global.getAdminPath() + "/newhome/newPageZone/lists";
+        } else {
+            return "redirect:" + Global.getAdminPath() + "/newhome/newPageZone/?repage";
+        }
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "updateEnabledStatus")
+    public Map<String, Object> updateEnabledStatus(String enabledStatus, String[] ids, String[] supplierIDs, HttpServletRequest request, HttpServletResponse response) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            newPageZoneService.updateEnabledStatusByIds(enabledStatus, ids);
+            cleanRedisCache();
+            map.put("success", true);
+            map.put("msg", "修改成功");
+        } catch (Exception e) {
+            logger.debug(e.toString(), e);
+            map.put("success", false);
+            map.put("msg", "修改失败");
+        }
+        return map;
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "updateCrmEnabledStatusByIds")
+    public Map<String, Object> updateCrmEnabledStatusByIds(String crmEnabledStatus, String[] ids, String[] supplierIDs, HttpServletRequest request, HttpServletResponse response) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            newPageZoneService.updateCrmEnabledStatusByIds(crmEnabledStatus, ids);
+            cleanRedisCache();
+            map.put("success", true);
+            map.put("msg", "修改成功");
+        } catch (Exception e) {
+            logger.debug(e.toString(), e);
+            map.put("success", false);
+            map.put("msg", "修改失败");
+        }
+        return map;
+    }
+
+    /**
+     * 批量更新专区排序值
+     */
+    @RequestMapping(value = "batchSaveSort")
+    @ResponseBody
+    public Map<String, Object> batchSaveSort(String sortList, Integer zoneId) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            String[] newPageLists = sortList.split(",");
+            for (String list : newPageLists) {
+                String[] split = list.split("-");
+                if (split.length == 1 || split.length < 1) {
+                    String id = split[0];
+                    String sort = null;
+                    newPageZoneService.saveSort(sort, id, zoneId);
+                } else {
+                    String id = split[0];
+                    String sort = split[1];
+                    if (isInteger(sort)) {
+                        if (StringUtils.equals("0", sort)) {
+                            map.put("success", false);
+                            map.put("msg", "排序值只能填写大于等于1的整数");
+                            return map;
+                        }
+                        newPageZoneService.saveSort(sort, id, zoneId);
+                    } else {
+                        map.put("success", false);
+                        map.put("msg", "排序值只能为数字");
+                        return map;
+                    }
+                }
+            }
+            cleanRedisCache();
+            map.put("success", true);
+            map.put("msg", "更新排序成功");
+            return map;
+        } catch (Exception e) {
+            map.put("success", false);
+            map.put("msg", "更新排序失败");
+            return map;
+        }
+    }
+
+    /**
+     * 添加商品
+     */
+    @RequestMapping("/addProductImage")
+    public String addProductImage(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
+        product.setValidFlag("2");
+        Page<Product> page = productService.findProductImage(new Page<Product>(request, response), product);
+        model.addAttribute("page", page);
+        model.addAttribute("productCategory", product.getProductCategory());
+        model.addAttribute("productIds", product.getProductIds());
+        return "modules/newhome/addProductImage";
+    }
+
+    @RequestMapping(value = "deleteProduct")
+    public String productDel(Integer productId, Integer zoneId, RedirectAttributes redirectAttributes) {
+        newPageZoneService.productDel(productId,zoneId);
+        addMessage(redirectAttributes, "删除成功");
+        return "redirect:" + Global.getAdminPath() + "/newhome/newPageZone/productList?zoneId=" + zoneId;
+    }
+
+    /**
+     * 有数据变动时需要清除缓存
+     */
+    public void cleanRedisCache() {
+        //清除活动专题缓存
+        redisService.removePattern("getPageFloorData*");
+        //清除活动专题缓存
+        redisService.removePattern("activityData*");
+        //清除产品仪器缓存
+        redisService.removePattern("instrumentData*");
+        redisService.removePattern("insCommodityData*");
+        //首页缓存
+        String homeData = "getHomeData*";
+        redisService.removePattern(homeData);
+        redisService.removePattern("getHomeCommodityData*");
+        // 重新生成静态首页
+        generateUtils.generateHome();
+
+    }
+}

+ 1 - 0
src/main/java/com/caimei/modules/product/entity/Product.java

@@ -15,6 +15,7 @@ import java.util.List;
 @Data
 public class Product extends DataEntity<Product> {
 
+    private Integer zoneId;
     private Integer supId;
     private String name;
     private String shopName;//供应商名称

+ 173 - 0
src/main/resources/mappings/modules/newhome/NewPageZoneMapper.xml

@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei.modules.newhome.dao.NewPageZoneDao">
+
+    <sql id="NewPageZoneColumns">
+        a.id AS "id",
+		a.floorTitle AS "floorTitle",
+		a.floorDetail AS "floorDetail",
+		a.sort AS "sort",
+		a.wwwEnabledStatus AS "wwwEnabledStatus",
+		a.crmEnabledStatus AS "crmEnabledStatus",
+		a.createBy AS "createBy.id",
+		a.createDate AS "createDate",
+		a.updateBy AS "updateBy.id",
+		a.updateDate AS "updateDate",
+		a.delFlag AS "delFlag"
+    </sql>
+
+    <select id="get" resultType="NewPageZone">
+        SELECT
+        <include refid="NewPageZoneColumns"/>
+        FROM new_page_zone a
+        WHERE a.id = #{id}
+    </select>
+
+    <select id="findList" resultType="NewPageZone">
+        SELECT
+        <include refid="NewPageZoneColumns"/>
+        FROM new_page_zone a
+        <where>
+            delFlag = 0
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findZoneProductList" resultType="com.caimei.modules.product.entity.Product">
+        SELECT npz.sort AS sortIndex, p.mainImage, p.name, p.productID, s.name AS shopName
+        FROM new_page_zone_product npz
+                 LEFT JOIN product p ON npz.productId = p.productID
+                 LEFT JOIN shop s ON p.shopId = s.shopId
+        WHERE p.productCategory = 1
+          AND npz.zoneId = #{zoneId}
+        GROUP BY p.productID
+        ORDER BY npz.sort ASC
+    </select>
+
+    <select id="findProducts" resultType="com.caimei.modules.product.entity.Product">
+        SELECT a.mainImage, a.name, a.productID,s.name as "shopName"
+        FROM product a
+        left join cm_organize_product_info copi on copi.productId = a.productID
+        left join shop s on a.shopId = s.shopID
+        left join new_page_zone_product npz ON a.productId = npz.productId
+        <where>
+            npz.productId is null
+            and
+            copi.validFlag in (2,3,9)
+            <if test="productID !=null and productID !=''">
+                AND a.productID=#{productID}
+            </if>
+            <if test="name != null and name != ''">
+                AND a.name LIKE concat('%',#{name},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name LIKE concat('%',#{shopName},'%')
+            </if>
+            and a.productCategory = 1
+        </where>
+        group by a.productID
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                order by a.productID desc
+            </otherwise>
+        </choose>
+    </select>
+
+    <insert id="insert" parameterType="NewPageZone" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO new_page_zone(
+        floorTitle,
+        floorDetail,
+        <if test="sort != null and sort != ''">
+            sort,
+        </if>
+        wwwEnabledStatus,
+        crmEnabledStatus,
+        createBy,
+        createDate,
+        updateBy,
+        updateDate,
+        delFlag
+        ) VALUES (
+        #{floorTitle},
+        #{floorDetail},
+        <if test="sort != null and sort != ''">
+            #{sort},
+        </if>
+        #{wwwEnabledStatus},
+        #{crmEnabledStatus},
+        #{createBy.id},
+        #{createDate},
+        #{updateBy.id},
+        #{updateDate},
+        #{delFlag}
+        )
+    </insert>
+
+    <insert id="addProducts">
+        insert into new_page_zone_product (zoneId,productId)
+        values
+        <foreach collection="split" item="item" index="index" separator=",">
+            (#{zoneId},#{item})
+        </foreach>
+    </insert>
+
+    <update id="update">
+        UPDATE new_page_zone
+        SET floorTitle       = #{floorTitle},
+            floorDetail      = #{floorDetail},
+            sort             = #{sort},
+            wwwEnabledStatus = #{wwwEnabledStatus},
+            crmEnabledStatus = #{crmEnabledStatus},
+            createBy         = #{createBy.id},
+            createDate       = #{createDate},
+            updateBy         = #{updateBy.id},
+            updateDate       = #{updateDate},
+            delFlag          = #{delFlag}
+        WHERE id = #{id}
+    </update>
+
+    <delete id="delete">
+        UPDATE new_page_zone
+        SET delFlag = 1
+        WHERE id = #{id}
+    </delete>
+
+    <delete id="delProduct">
+        delete from new_page_zone_product
+        where productId = #{productId}
+        and zoneId = #{zoneId}
+    </delete>
+
+    <update id="updateEnabledStatusByIds">
+        UPDATE new_page_zone a SET a.wwwEnabledStatus = #{param1}
+        WHERE a.id IN
+        <foreach collection="param2" item="id" index="index" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
+    <update id="updateCrmEnabledStatusByIds">
+        UPDATE new_page_zone a SET a.crmEnabledStatus = #{param1}
+        WHERE a.id IN
+        <foreach collection="param2" item="id" index="index" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
+    <update id="saveSort">
+        UPDATE new_page_zone_product
+        SET sort = #{sort}
+        WHERE zoneId = #{zoneId}
+        and productId = #{id}
+    </update>
+
+</mapper>

+ 76 - 0
src/main/webapp/WEB-INF/views/modules/newhome/newPageZoneForm.jsp

@@ -0,0 +1,76 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+	<title>专区管理管理</title>
+	<meta name="decorator" content="default"/>
+	<script type="text/javascript">
+		$(document).ready(function() {
+			//$("#name").focus();
+			$("#inputForm").validate({
+				submitHandler: function(form){
+					loading('正在提交,请稍等...');
+					form.submit();
+				},
+				errorContainer: "#messageBox",
+				errorPlacement: function(error, element) {
+					$("#messageBox").text("输入有误,请先更正。");
+					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+						error.appendTo(element.parent().parent());
+					} else {
+						error.insertAfter(element);
+					}
+				}
+			});
+		});
+	</script>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li><a href="${ctx}/newhome/newPageZone/">专区管理列表</a></li>
+		<li class="active"><a href="${ctx}/newhome/newPageZone/form?id=${newPageZone.id}">专区管理${not empty newPageZone.id?'编辑':'添加'}</a></li>
+	</ul><br/>
+	<form:form id="inputForm" modelAttribute="newPageZone" action="${ctx}/newhome/newPageZone/save" method="post" class="form-horizontal">
+		<form:hidden path="id"/>
+		<sys:message content="${message}"/>
+		<div class="control-group">
+			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>专区标题:</label>
+			<div class="controls">
+				<form:input path="floorTitle" htmlEscape="false" maxlength="10" class="input-xlarge required"/>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>专区描述:</label>
+			<div class="controls">
+				<form:input path="floorDetail" htmlEscape="false" maxlength="30" class="input-xlarge required"/>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>排序:</label>
+			<div class="controls">
+				<form:input path="sort" htmlEscape="false" maxlength="11" class="input-xlarge required"/>
+			</div>
+		</div>
+		<div class="control-group crmstatus" style="" >
+			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>网站状态:</label>
+			<div class="controls">
+				<form:select path="wwwEnabledStatus" class="input-xlarge required">
+					<form:options items="${fns:getDictList('enabled_status')}" itemLabel="label" itemValue="value" htmlEscape="false"  />
+				</form:select>
+			</div>
+		</div>
+		<div class="control-group crmstatus" style="" >
+			<label class="control-label"><span class="help-inline"><font color="red">*</font> </span>小程序状态:</label>
+			<div class="controls">
+				<form:select path="crmEnabledStatus" class="input-xlarge required">
+					<form:options items="${fns:getDictList('enabled_status')}" itemLabel="label" itemValue="value" htmlEscape="false"  />
+				</form:select>
+			</div>
+		</div>
+		<div class="form-actions">
+			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
+			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+		</div>
+	</form:form>
+</body>
+</html>

+ 191 - 0
src/main/webapp/WEB-INF/views/modules/newhome/newPageZoneList.jsp

@@ -0,0 +1,191 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>专区管理管理</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th {
+            text-align: center;
+        }
+
+        .table td {
+            text-align: center;
+        }
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+
+        });
+
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+
+        //PC端状态修改
+        function updateEnabledStatus(status, ids) {
+            var msg = '确定启用该专区吗?';
+            if ('0' == status) {
+                msg = '确定停用该专区吗?';
+            }
+            top.$.jBox.confirm(msg, '系统提示', function (v, h, f) {
+                if (v == 'ok') {
+                    $.post("${ctx}/newhome/newPageZone/updateEnabledStatus", {
+                        'enabledStatus': status,
+                        'ids': ids
+                    }, function (data) {
+                        if (true == data.success) {
+                            $.jBox.tip(data.msg, 'info');
+                        } else {
+                            $.jBox.tip(data.msg, 'error');
+                        }
+                        window.location = "${ctx}/newhome/newPageZone/";
+                    }, "JSON");//这里返回的类型有:json,html,xml,text
+                }
+                return;
+            }, {buttonsFocus: 1, persistent: true});
+        }
+
+
+        //CRM端状态修改
+        function updateCrmEnabledStatusByIds(status, ids) {
+            var msg = '确定启用该专区吗?';
+            if ('0' == status) {
+                msg = '确定停用该专区吗?';
+            }
+            top.$.jBox.confirm(msg, '系统提示', function (v, h, f) {
+                if (v == 'ok') {
+                    $.post("${ctx}/newhome/newPageZone/updateCrmEnabledStatusByIds", {
+                        'crmEnabledStatus': status,
+                        'ids': ids
+                    }, function (data) {
+                        if (true == data.success) {
+                            $.jBox.tip(data.msg, 'info');
+                        } else {
+                            $.jBox.tip(data.msg, 'error');
+                        }
+                        window.location = "${ctx}/newhome/newPageZone/";
+                    }, "JSON");//这里返回的类型有:json,html,xml,text
+                }
+                return;
+            }, {buttonsFocus: 1, persistent: true});
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+
+        //批量保存排序
+        function batchSaveSort() {
+            var items = new Array();
+            var $items = $('.check-item');
+            $items.each(function () {
+                items.push($(this).val());
+            });
+            //保存批量排序
+            $.post("${ctx}/newhome/newPageZone/batchSaveSort?sortList=" + items, function (data) {
+                if (true == data.success) {
+                    $.jBox.tip(data.msg, 'info');
+                    window.location.href = "${ctx}/newhome/newPageZone";
+                } else {
+                    $.jBox.tip(data.msg, 'error');
+                }
+            }, "JSON");//这里返回的类型有:json,html,xml,text
+        }
+
+        //修改排序值
+        function changeSort(id, sortThis) {
+            var value = sortThis.value;
+            $("#preferredProductSort" + id).val(id + "-" + value);
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li class="active"><a href="${ctx}/newhome/newPageZone/">专区管理列表</a></li>
+</ul>
+<form:form action="" class="breadcrumb form-search">
+    <input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort()" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;
+    <input class="btn btn-primary" style="width: 70px" onclick="window.location='${ctx}/newhome/newPageZone/form'"
+           value="添加专区"/>
+    <div style="margin-top: 10px">
+        <label><font color="#a9a9a9">注:排序值越小越靠前</font></label>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>ID</th>
+        <th>专区名称</th>
+        <th>描述</th>
+        <th>网站状态</th>
+        <th>小程序状态</th>
+        <th>排序</th>
+        <th>创建时间</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="newPageZone">
+        <tr>
+            <input class="check-item" type="hidden" id="preferredProductSort${newPageZone.id}"
+                   value='${newPageZone.id}-${newPageZone.sort}'/>
+            <td>${newPageZone.id}</td>
+            <td>${newPageZone.floorTitle}</td>
+            <td>${newPageZone.floorDetail}</td>
+            <td>
+                <c:if test="${newPageZone.wwwEnabledStatus eq 1 }">
+                    <font color="green">已启用</font>
+                    <a href="javascript:void(0);" onclick="updateEnabledStatus('0','${newPageZone.id}');">
+                        停用
+                    </a>
+                </c:if>
+                <c:if test="${newPageZone.wwwEnabledStatus ne 1 }">
+                    <font color="red">已停用</font>
+                    <a href="javascript:void(0)" onclick="updateEnabledStatus('1','${newPageZone.id}');">
+                        启用
+                    </a>
+                </c:if>
+            </td>
+            <td>
+                <c:if test="${newPageZone.crmEnabledStatus eq 1 }">
+                    <font color="green">已启用</font>
+                    <a href="javascript:void(0);" onclick="updateCrmEnabledStatusByIds('0','${newPageZone.id}');">
+                        停用
+                    </a>
+                </c:if>
+                <c:if test="${newPageZone.crmEnabledStatus ne 1 }">
+                    <font color="red">已停用</font>
+                    <a href="javascript:void(0)" onclick="updateCrmEnabledStatusByIds('1','${newPageZone.id}');">
+                        启用
+                    </a>
+                </c:if>
+            </td>
+            <td>
+                <input type="text" id="sort" name="sort" style="width:50px;" value="${newPageZone.sort}"
+                       onkeyup="onlynum(this)" onchange="changeSort(${newPageZone.id},this)">
+            </td>
+            <td><fmt:formatDate value="${newPageZone.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
+            <td>
+                <a href="${ctx}/newhome/newPageZone/form?id=${newPageZone.id}">编辑</a>
+                <a href="${ctx}/newhome/newPageZone/productList?zoneId=${newPageZone.id}">专区商品</a>
+                <a href="${ctx}/newhome/newPageZone/goContentPage?floorId=${newPageZone.id}">专区轮播图</a>
+
+                <a href="${ctx}/newhome/newPageZone/delete?id=${newPageZone.id}"
+                   onclick="return confirmx('确定删除该专区吗?', this.href)">删除</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+</body>
+</html>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/newhome/recommendProductList.jsp

@@ -2,7 +2,7 @@
 <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
 <html>
 <head>
-	<title>组合商品列表</title>
+	<title>推荐商品列表</title>
 	<meta name="decorator" content="default"/>
 	<style type="text/css">
 		.table th{text-align: center;}

+ 123 - 0
src/main/webapp/WEB-INF/views/modules/newhome/toSelectZoneProduct.jsp

@@ -0,0 +1,123 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>选择商品</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table td i {
+            margin: 0 2px;
+        }
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //弹出框去滚动条
+            top.$('#jbox-content').css("overflow-y", "hidden");
+            $('body').on('click', 'input[name="info"]', function () {
+                var allInputLength = $('input[name="info"]').length - $('input[name="info"]:disabled').length,
+                    allInputCheckedLength = $('input[name="info"]:checked').length,
+                    checkAllEle = $('.check-all');
+                if (allInputLength === allInputCheckedLength) {
+                    checkAllEle.attr('checked', true);
+                } else {
+                    checkAllEle.attr('checked', false);
+                }
+            })
+        });
+
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+
+        function getCheckedItems() {
+            var items = "";
+            var $items = $('.check-item:checked');
+            $items.each(function () {
+                //通过拿到的商品ID串(逗号隔开)
+                var productID = $(this).val();
+                items = items + productID + ","
+            });
+            items = items.substring(0, items.length - 1);
+            return items;
+        }
+
+        function allCkbfun(ckb) {
+            var isChecked = ckb.checked;
+            $(".check-item").attr('checked', isChecked);
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字和两位小数(金额)
+         */
+        function num(obj) {
+            obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+            obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
+            obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
+            obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+        }
+
+    </script>
+</head>
+<body>
+<form:form id="searchForm" modelAttribute="product"
+           action="${ctx}/newhome/newPageQualitySupplier/toAddProduct?zoneId=${product.zoneId}" method="post"
+           class="breadcrumb form-search">
+    <input id="zoneId" name="zoneId" type="hidden" value="${product.zoneId}"/>
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>商品ID:</label>
+        <form:input path="productID" htmlEscape="false" maxlength="10" class="input-mini" onchange="onlynum(this)"/>
+        <label>商品名称:</label>
+        <form:input path="productName" htmlEscape="false" class="input-medium" maxlength="20"/>
+        <label>供应商:</label>
+        <form:input path="shopName" htmlEscape="false" class="input-medium" maxlength="20"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table class="table table-striped table-bordered table-condensed table-hover">
+    <tr>
+        <th style="width:20px;"><input class="check-all" type="checkbox" onclick="allCkbfun(this);"/></th>
+        <th>商品ID</th>
+        <th>商品图片</th>
+        <th>商品名称</th>
+        <th>供应商</th>
+    </tr>
+    <tbody>
+    <c:if test="${not empty page.list}">
+        <c:forEach items="${page.list}" var="item">
+            <tr id="${item.productID}" class="itemtr">
+                    <%--已过滤添加过的商品和未上架的商品--%>
+                <th>
+                    <input class="check-item" type="checkbox" name="info" value='${item.productID}'/>
+                </th>
+                <td>${item.productID}</td>
+                <td><img src="${item.mainImage}" width="50px" height="50px"></td>
+                <td>${item.name}</td>
+                <td>${item.shopName}</td>
+            </tr>
+        </c:forEach>
+    </c:if>
+    </tbody>
+</table>
+<c:if test="${empty page.list}">
+    <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+</body>
+</html>

+ 171 - 0
src/main/webapp/WEB-INF/views/modules/newhome/zoneProductList.jsp

@@ -0,0 +1,171 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>专区商品列表</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th {
+            text-align: center;
+        }
+
+        .table td {
+            text-align: center;
+        }
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+
+        });
+
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+
+
+        //选择添加商品
+        function showSelect(zoneId) {
+            top.$.jBox("iframe:${ctx}/newhome/newPageZone/toAddProduct?zoneId=" + zoneId, {
+                iframeScrolling: 'yes',
+                width: $(top.document).width() - 400,
+                height: $(top.document).height() - 160,
+                persistent: true,
+                title: "选择商品",
+                buttons: {"确定": '1', "关闭": '-1'},
+                submit: function (v, h, f) {
+                    //确定
+                    var $jboxFrame = top.$('#jbox-iframe');
+                    var $mainFrame = top.$('#mainFrame');
+                    if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                        var items = $jboxFrame[0].contentWindow.getCheckedItems();//获取到的数据格式:(含有参数序号拼接,使用数组传入)1o,2e,3t,4y,5u,6p
+                        if (items.length > 0) {
+                            //添加数据
+                            $.post("${ctx}/newhome/newPageZone/saveAddProduct", {
+                                "productIds": items, "zoneId": zoneId
+                            }, function (data) {
+                                if (true == data.success) {
+                                    window.location.href = "${ctx}/newhome/newPageZone/productList?zoneId=" + zoneId;
+                                    $.jBox.tip(data.msg, 'info');
+                                } else {
+                                    $.jBox.tip(data.msg, 'error');
+                                }
+                            }, "JSON");//这里返回的类型有:json,html,xml,text
+                            return true;
+                        } else {
+                            top.$.jBox.tip("请先勾选商品...");
+                            return false;
+                        }
+                    }
+                    return true;
+                }
+            });
+        }
+
+        //批量保存排序
+        function batchSaveSort() {
+            var items = new Array();
+            var $items = $('.check-item');
+            $items.each(function () {
+                items.push($(this).val());
+            });
+            var zoneId = $('#zoneId').val();
+            //保存批量排序
+            $.post("${ctx}/newhome/newPageZone/batchSaveSort?sortList=" + items + "&zoneId=" + zoneId, function (data) {
+                if (true == data.success) {
+                    $.jBox.tip(data.msg, 'info');
+                    setInterval(g, 1000);
+                } else {
+                    $.jBox.tip(data.msg, 'error');
+                }
+            }, "JSON");//这里返回的类型有:json,html,xml,text
+        }
+
+        function g() {
+            window.location.href = "${ctx}/newhome/newPageZone/productList";//刷新页面
+        }
+
+        //修改排序值
+        function changeSort(id, sortThis) {
+            var value = sortThis.value;
+            $("#sort" + id).val(id + "-" + value);
+        }
+
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/newhome/newPageZone/">专区管理列表</a></li>
+    <li class="active"><a href="${ctx}/newhome/newPageZone/productList">专区商品列表</a></li>
+</ul>
+<form:form id="searchForm" action="${ctx}/newhome/newPageZone/productList" method="post" class="breadcrumb form-search">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <input id="zoneId" name="zoneId" type="hidden" value="${zoneId}"/>
+    <div class="ul-form">
+        <input type="button" class="btn btn-primary" value="添加商品" onclick="showSelect(${zoneId})"/>&nbsp&nbsp&nbsp
+        <c:if test="${not empty page.list}">
+            <input type="button" class="btn btn-primary" value="保存排序" onclick="batchSaveSort()"/>
+        </c:if>
+        <br><font color="#a9a9a9">&nbsp;&nbsp;&nbsp;排序规则:按照排序数值升序排列,数值越小排序越靠前,排序值允许重复。</font>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>商品ID</th>
+        <th>商品图片</th>
+        <th>商品名称</th>
+        <th>供应商</th>
+        <th>排序值</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <c:if test="${not empty page.list}">
+        <c:forEach items="${page.list}" var="product">
+            <tbody>
+            <tr>
+                <input class="check-item" type="hidden" id="sort${product.productID}"
+                       value='${product.productID}-${product.sortIndex}'/>
+                <td>
+                        ${product.productID}
+                </td>
+                <td><img src="${product.mainImage}" width="50px" height="50px"></td>
+                <td>
+                    <a href="https://www.caimei365.com/product-${product.productID}.html"
+                       target="_blank">${product.name}</a>
+                </td>
+                <td>
+                        ${product.shopName}
+                </td>
+                <td>
+                    <input id="sort" name="sort" style="width:50px;" value="${product.sortIndex}"
+                           onkeyup="onlynum(this)" onchange="changeSort(${product.productID},this)">
+                </td>
+                <td>
+                    <a href="${ctx}/newhome/newPageZone/deleteProduct?productId=${product.productID}&zoneId=${zoneId}"
+                       onclick="return confirmx('确认删除吗?', this.href)">删除</a>
+                </td>
+            </tr>
+            </tbody>
+        </c:forEach>
+    </c:if>
+</table>
+<c:if test="${empty page.list}">
+    <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+</body>
+</html>