Browse Source

呵呵商城改版part2

Aslee 3 years ago
parent
commit
74b5a3c185

+ 18 - 0
src/main/java/com/caimei/modules/hehe/dao/HeheHomeTypeProductDao.java

@@ -0,0 +1,18 @@
+package com.caimei.modules.hehe.dao;
+
+import com.thinkgem.jeesite.common.persistence.CrudDao;
+import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
+import com.caimei.modules.hehe.entity.HeheHomeTypeProduct;
+
+import java.util.List;
+
+/**
+ * 呵呵首页分类商品DAO接口
+ * @author Aslee
+ * @version 2022-03-23
+ */
+@MyBatisDao
+public interface HeheHomeTypeProductDao extends CrudDao<HeheHomeTypeProduct> {
+
+    List<Integer> findHomeTypeProductIds();
+}

+ 88 - 0
src/main/java/com/caimei/modules/hehe/entity/HeheHomeTypeProduct.java

@@ -0,0 +1,88 @@
+package com.caimei.modules.hehe.entity;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+
+/**
+ * 呵呵首页分类商品Entity
+ * @author Aslee
+ * @version 2022-03-23
+ */
+public class HeheHomeTypeProduct extends DataEntity<HeheHomeTypeProduct> {
+	
+	private static final long serialVersionUID = 1L;
+	private Integer homeTypeId;		// 首页分类菜单id
+	private Integer productId;		// 对应采美商品id
+	private Integer status;		// 状态:0已下架,1已上架
+	private Date addTime;		// 添加时间
+	private String name;         //商品名称
+	private String mainImage;       //商品图片
+	private String shopName;        //供应商名称
+	
+	public HeheHomeTypeProduct() {
+		super();
+	}
+
+	public HeheHomeTypeProduct(String id){
+		super(id);
+	}
+
+	public Integer getHomeTypeId() {
+		return homeTypeId;
+	}
+
+	public void setHomeTypeId(Integer homeTypeId) {
+		this.homeTypeId = homeTypeId;
+	}
+	
+	public Integer getProductId() {
+		return productId;
+	}
+
+	public void setProductId(Integer productId) {
+		this.productId = productId;
+	}
+	
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	public Date getAddTime() {
+		return addTime;
+	}
+
+	public void setAddTime(Date addTime) {
+		this.addTime = addTime;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getMainImage() {
+		return mainImage;
+	}
+
+	public void setMainImage(String mainImage) {
+		this.mainImage = mainImage;
+	}
+
+	public String getShopName() {
+		return shopName;
+	}
+
+	public void setShopName(String shopName) {
+		this.shopName = shopName;
+	}
+}

+ 89 - 0
src/main/java/com/caimei/modules/hehe/service/HeheHomeTypeProductService.java

@@ -0,0 +1,89 @@
+package com.caimei.modules.hehe.service;
+
+import java.util.List;
+
+import com.caimei.modules.hehe.dao.CmHeheActivityProductDao;
+import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
+import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.caimei.utils.AppUtils;
+import com.caimei.utils.StringUtil;
+import com.thinkgem.jeesite.common.config.Global;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.service.CrudService;
+import com.caimei.modules.hehe.entity.HeheHomeTypeProduct;
+import com.caimei.modules.hehe.dao.HeheHomeTypeProductDao;
+
+/**
+ * 呵呵首页分类商品Service
+ * @author Aslee
+ * @version 2022-03-23
+ */
+@Service
+@Transactional(readOnly = true)
+public class HeheHomeTypeProductService extends CrudService<HeheHomeTypeProductDao, HeheHomeTypeProduct> {
+	@Autowired
+	private HeheHomeTypeProductDao heheHomeTypeProductDao;
+	@Autowired
+	private CmHeheActivityProductDao activityProductDao;
+
+	public HeheHomeTypeProduct get(String id) {
+		return super.get(id);
+	}
+	
+	public List<HeheHomeTypeProduct> findList(HeheHomeTypeProduct heheHomeTypeProduct) {
+		return super.findList(heheHomeTypeProduct);
+	}
+	
+	public Page<HeheHomeTypeProduct> findPage(Page<HeheHomeTypeProduct> page, HeheHomeTypeProduct heheHomeTypeProduct) {
+		return super.findPage(page, heheHomeTypeProduct);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(HeheHomeTypeProduct heheHomeTypeProduct) {
+		super.save(heheHomeTypeProduct);
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(HeheHomeTypeProduct heheHomeTypeProduct) {
+		super.delete(heheHomeTypeProduct);
+	}
+
+	@Transactional(readOnly = false)
+	public void update(HeheHomeTypeProduct homeTypeProduct) {
+		heheHomeTypeProductDao.update(homeTypeProduct);
+	}
+
+	public Page<CmHeheProduct> findProductPage(Page<CmHeheProduct> productPage, CmHeheProduct product) {
+		List<Integer> productIds = heheHomeTypeProductDao.findHomeTypeProductIds();
+		product.setIds(productIds);
+		product.setPage(productPage);
+		List<CmHeheProduct> productList = activityProductDao.findAllHeHeProduct(product);
+		String wwwServer = Global.getConfig("wwwServer");
+		productList.forEach(item -> {
+			if (StringUtil.isNotBlank(item.getMainImage())) {
+				item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
+			}
+		});
+		productPage.setList(productList);
+		return productPage;
+	}
+
+	@Transactional(readOnly = false)
+	public void addProducts(Integer homeTypeId, String productIds) {
+		HeheHomeTypeProduct homeTypeProduct = new HeheHomeTypeProduct();
+		homeTypeProduct.setHomeTypeId(homeTypeId);
+		if (StringUtil.isNotBlank(productIds)) {
+			String[] ids = productIds.split(",");
+			for (String id : ids) {
+				if (StringUtil.isNotBlank(id)) {
+					homeTypeProduct.setProductId(Integer.valueOf(id));
+					heheHomeTypeProductDao.insert(homeTypeProduct);
+				}
+			}
+		}
+	}
+}

+ 5 - 5
src/main/java/com/caimei/modules/hehe/web/HeheHomeTypeController.java

@@ -68,10 +68,10 @@ public class HeheHomeTypeController extends BaseController {
 
 	@RequestMapping(value = "save")
 	public String save(HeheHomeType heheHomeType, Model model, RedirectAttributes redirectAttributes) {
-		/*if (StringUtils.isEmpty(heheHomeType.getIcon())) {
+		if (StringUtils.isEmpty(heheHomeType.getIcon())) {
 			model.addAttribute("errorMsg", "请上传图标");
 			return form(heheHomeType, model);
-		}*/
+		}
 		if (!beanValidator(model, heheHomeType)){
 			return form(heheHomeType, model);
 		}
@@ -93,14 +93,14 @@ public class HeheHomeTypeController extends BaseController {
 
 	/**
 	 * 批量更新排序
-	 * @param bigTypeIdSortIndexs
+	 * @param typeIdSortIndexs
 	 * @return
 	 */
 	@RequestMapping(value = "updateSortIndex")
 	@ResponseBody
-	public JsonModel updateSortIndex(String bigTypeIdSortIndexs){
+	public JsonModel updateSortIndex(String typeIdSortIndexs){
 		JsonModel jsonModel = JsonModel.newInstance();
-		heheHomeTypeService.updateSortIndex(bigTypeIdSortIndexs);
+		heheHomeTypeService.updateSortIndex(typeIdSortIndexs);
 		return jsonModel.success("批量更新排序成功");
 	}
 

+ 125 - 0
src/main/java/com/caimei/modules/hehe/web/HeheHomeTypeProductController.java

@@ -0,0 +1,125 @@
+package com.caimei.modules.hehe.web;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.caimei.modules.product.entity.CmBigtype;
+import com.google.common.collect.Maps;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+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 com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.web.BaseController;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.caimei.modules.hehe.entity.HeheHomeTypeProduct;
+import com.caimei.modules.hehe.service.HeheHomeTypeProductService;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 呵呵首页分类商品Controller
+ * @author Aslee
+ * @version 2022-03-23
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/hehe/heheHomeTypeProduct")
+public class HeheHomeTypeProductController extends BaseController {
+
+	@Autowired
+	private HeheHomeTypeProductService heheHomeTypeProductService;
+	
+	@ModelAttribute
+	public HeheHomeTypeProduct get(@RequestParam(required=false) String id) {
+		HeheHomeTypeProduct entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = heheHomeTypeProductService.get(id);
+		}
+		if (entity == null){
+			entity = new HeheHomeTypeProduct();
+		}
+		return entity;
+	}
+	
+	@RequestMapping(value = {"list", ""})
+	public String list(HeheHomeTypeProduct heheHomeTypeProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<HeheHomeTypeProduct> page = heheHomeTypeProductService.findPage(new Page<HeheHomeTypeProduct>(request, response), heheHomeTypeProduct); 
+		model.addAttribute("page", page);
+		return "modules/hehe/heheHomeTypeProductList";
+	}
+
+	@RequestMapping(value = "form")
+	public String form(HeheHomeTypeProduct heheHomeTypeProduct, Model model) {
+		model.addAttribute("heheHomeTypeProduct", heheHomeTypeProduct);
+		return "modules/hehe/heheHomeTypeProductForm";
+	}
+
+	@RequestMapping(value = "save")
+	public String save(HeheHomeTypeProduct heheHomeTypeProduct, Model model, RedirectAttributes redirectAttributes) {
+		if (!beanValidator(model, heheHomeTypeProduct)){
+			return form(heheHomeTypeProduct, model);
+		}
+		heheHomeTypeProductService.save(heheHomeTypeProduct);
+		addMessage(redirectAttributes, "保存商品成功");
+		return "redirect:"+Global.getAdminPath()+"/hehe/heheHomeTypeProduct/?repage";
+	}
+	
+	@RequestMapping(value = "delete")
+	public String delete(HeheHomeTypeProduct heheHomeTypeProduct, RedirectAttributes redirectAttributes) {
+		heheHomeTypeProductService.delete(heheHomeTypeProduct);
+		addMessage(redirectAttributes, "删除商品成功");
+		return "redirect:"+Global.getAdminPath()+"/hehe/heheHomeTypeProduct/?repage";
+	}
+
+	@ResponseBody
+	@RequestMapping(value="updateStatus")
+	public Map<String, Object> updateStatus(Integer status, String id, HttpServletRequest request, HttpServletResponse response){
+		Map<String, Object> map = Maps.newLinkedHashMap();
+		try {
+			HeheHomeTypeProduct homeTypeProduct = heheHomeTypeProductService.get(id);
+			homeTypeProduct.setStatus(status);
+			heheHomeTypeProductService.update(homeTypeProduct);
+			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 = "findProductPage")
+	public String findProductPage(CmHeheProduct product, Model model, HttpServletRequest request, HttpServletResponse response) {
+		Page<CmHeheProduct> page = heheHomeTypeProductService.findProductPage(new Page<CmHeheProduct>(request, response), product);
+		model.addAttribute("page", page);
+		return "modules/hehe/addHomeTypeProduct";
+	}
+
+	/**
+	 * 添加商品
+	 *
+	 * @return
+	 */
+	@RequestMapping(value = "addProducts")
+	@ResponseBody
+	public Map<String, Object> addProducts(Integer homeTypeId, String productIds) {
+		heheHomeTypeProductService.addProducts(homeTypeId, productIds);
+		HashMap<String, Object> map = new HashMap<>(2);
+		map.put("success", true);
+		map.put("info", "上线商品成功");
+		return map;
+	}
+}

+ 10 - 3
src/main/java/com/caimei/modules/product/web/CmBigtypeController.java

@@ -102,6 +102,9 @@ public class CmBigtypeController extends BaseController {
 		if (null!=cmBigtype && cmBigtype.getAddTime() == null){
 			cmBigtype.setAddTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
 		}
+		if ("0".equals(cmBigtype.getTypeSort())) {
+			cmBigtype.setTypeSort(null);
+		}
 		cmBigtypeService.save(cmBigtype);
 		if (1 == cmBigtype.getMallType()) {
 			cleanRedisCache();
@@ -180,7 +183,9 @@ public class CmBigtypeController extends BaseController {
 				cmBigtype.setSortIndex(Integer.parseInt(status));
 			}
 			cmBigtypeService.update(cmBigtype);
-			cleanRedisCache();
+			if (1 == cmBigtype.getMallType()) {
+				cleanRedisCache();
+			}
 			map.put("success",true);
 			map.put("msg", "修改成功");
 		} catch (Exception e) {
@@ -226,10 +231,12 @@ public class CmBigtypeController extends BaseController {
 	@RequiresPermissions("product:cmBigtype:edit")
 	@RequestMapping(value = "updateSortIndex")
 	@ResponseBody
-	public JsonModel updateSortIndex(String bigTypeIdSortIndexs){
+	public JsonModel updateSortIndex(String bigTypeIdSortIndexs,Integer mallType){
 		JsonModel jsonModel = JsonModel.newInstance();
 		cmBigtypeService.updateSortIndex(bigTypeIdSortIndexs);
-		cleanRedisCache();
+		if (null == mallType) {
+			cleanRedisCache();
+		}
 		return jsonModel.success("批量更新排序成功");
 	}
 	/**

+ 6 - 4
src/main/java/com/caimei/modules/product/web/CmSmalltypeController.java

@@ -139,10 +139,10 @@ public class CmSmalltypeController extends BaseController {
 				return true;
 			}
 		}
-        /*if (StringUtils.isEmpty(cmSmalltype.getCrmIcon())) {
+        if (StringUtils.isEmpty(cmSmalltype.getCrmIcon())) {
             model.addAttribute("errorMsg", "请上传小程序图标!");
             return true;
-        }*/
+        }
 		if (null ==cmSmalltype.getSortIndex()) {
 			model.addAttribute("errorMsg", "请输入排序值!");
 			return true;
@@ -239,10 +239,12 @@ public class CmSmalltypeController extends BaseController {
 	@RequiresPermissions("product:cmBigtype:edit")
 	@RequestMapping(value = "updateSortIndex")
 	@ResponseBody
-	public JsonModel updateSortIndex(String smallTypeIdSortIndexs){
+	public JsonModel updateSortIndex(String smallTypeIdSortIndexs,Integer mallType){
 		JsonModel jsonModel = JsonModel.newInstance();
 		cmSmalltypeService.updateSortIndex(smallTypeIdSortIndexs);
-		cleanRedisCache();
+		if (null == mallType) {
+			cleanRedisCache();
+		}
 		return jsonModel.success("批量更新排序成功");
 	}
 }

+ 3 - 10
src/main/resources/config/dev/caimei.properties

@@ -12,16 +12,9 @@
 #mysql database setting
 jdbc.type=mysql
 jdbc.driver=com.mysql.cj.jdbc.Driver
-jdbc.url=jdbc:mysql://localhost:3306/caimei?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
-jdbc.username=root
-jdbc.password=wndiqwe
-
-#mysql database setting
-#jdbc.type=mysql
-#jdbc.driver=com.mysql.cj.jdbc.Driver
-#jdbc.url=jdbc:mysql://120.79.25.27:3306/caimei?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
-#jdbc.username=developer
-#jdbc.password=J5p3tgOVazNl4ydf
+jdbc.url=jdbc:mysql://192.168.2.100:3306/caimei?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+jdbc.username=developer
+jdbc.password=05bZ/OxTB:X+yd%1
 
 #jdbc.url=jdbc:mysql://120.79.25.27:3306/caimei?characterEncoding=UTF8&serverTimezone=Asia/Shanghai
 #jdbc.username=developer

+ 4 - 0
src/main/resources/mappings/modules/hehe/HeheHomeTypeMapper.xml

@@ -35,6 +35,7 @@
 				ORDER BY ${page.orderBy}
 			</when>
 			<otherwise>
+				ORDER BY ifnull(sort,10000) ASC,addTime DESC
 			</otherwise>
 		</choose>
 	</select>
@@ -84,6 +85,9 @@
 			<if test="sort != null">
 				sort = #{sort},
 			</if>
+		    <if test="status != null">
+                status = #{status},
+            </if>
 		</set>
 		WHERE id = #{id}
 	</update>

+ 107 - 0
src/main/resources/mappings/modules/hehe/HeheHomeTypeProductMapper.xml

@@ -0,0 +1,107 @@
+<?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.hehe.dao.HeheHomeTypeProductDao">
+    
+	<sql id="heheHomeTypeProductColumns">
+		a.id AS "id",
+		a.homeTypeId AS "homeTypeId",
+		a.productId AS "productId",
+		a.status AS "status",
+		a.addTime AS "addTime",
+		p.mainImage AS "mainImage",
+		p.name AS "name",
+		s.name AS "shopName"
+	</sql>
+	
+	<sql id="heheHomeTypeProductJoins">
+		LEFT JOIN product p ON a.productId = p.productID
+		LEFT JOIN shop s ON s.shopID = p.shopID
+	</sql>
+    
+	<select id="get" resultType="HeheHomeTypeProduct">
+		SELECT 
+			<include refid="heheHomeTypeProductColumns"/>
+		FROM hehe_home_type_product a
+		<include refid="heheHomeTypeProductJoins"/>
+		WHERE a.id = #{id}
+	</select>
+	
+	<select id="findList" resultType="HeheHomeTypeProduct">
+		SELECT 
+			<include refid="heheHomeTypeProductColumns"/>
+		FROM hehe_home_type_product a
+		<include refid="heheHomeTypeProductJoins"/>
+		<where>
+			
+			<if test="homeTypeId != null">
+				AND a.homeTypeId = #{homeTypeId}
+			</if>
+			<if test="productId != null">
+				AND a.productId = #{productId}
+			</if>
+			<if test="status != null">
+				AND a.status = #{status}
+			</if>
+			<if test="name != null and name != ''">
+				AND p.name LIKE CONCAT('%',#{name},'%')
+			</if>
+			<if test="shopName != null and shopName != ''">
+				AND s.name LIKE CONCAT('%',#{shopName},'%')
+			</if>
+		</where>
+		<choose>
+			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
+				ORDER BY ${page.orderBy}
+			</when>
+			<otherwise>
+				ORDER BY a.addTime DESC
+			</otherwise>
+		</choose>
+	</select>
+	
+	<select id="findAllList" resultType="HeheHomeTypeProduct">
+		SELECT 
+			<include refid="heheHomeTypeProductColumns"/>
+		FROM hehe_home_type_product a
+		<include refid="heheHomeTypeProductJoins"/>
+		<where>
+			
+		</where>		
+		<choose>
+			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
+				ORDER BY ${page.orderBy}
+			</when>
+			<otherwise>
+			</otherwise>
+		</choose>
+	</select>
+	<select id="findHomeTypeProductIds" resultType="java.lang.Integer">
+		select productId from hehe_home_type_product;
+	</select>
+
+	<insert id="insert" parameterType="HeheHomeTypeProduct"  keyProperty="id" useGeneratedKeys="true">
+		INSERT INTO hehe_home_type_product(
+			homeTypeId,
+			productId,
+			status,
+			addTime
+		) VALUES (
+			#{homeTypeId},
+			#{productId},
+			1,
+			NOW()
+		)
+	</insert>
+	
+	<update id="update">
+		UPDATE hehe_home_type_product SET 	
+			status = #{status}
+		WHERE id = #{id}
+	</update>
+	
+	<delete id="delete">
+		DELETE FROM hehe_home_type_product
+		WHERE id = #{id}
+	</delete>
+	
+</mapper>

+ 2 - 1
src/main/resources/mappings/modules/product/CmBigtypeMapper.xml

@@ -12,7 +12,8 @@
 		a.wwwIcon AS "wwwIcon",
 		a.crmIcon AS "crmIcon",
 		a.addTime AS "addTime",
-		ifnull(a.typeSort,'0')  AS "typeSort"
+		ifnull(a.typeSort,'0')  AS "typeSort",
+		a.mallType
 	</sql>
 
 	<!--事务过程 修改分类 批量更新商品编码 存储过程名称 caimei4developer.update_productcode_big-->

+ 122 - 0
src/main/webapp/WEB-INF/views/modules/hehe/addHomeTypeProduct.jsp

@@ -0,0 +1,122 @@
+<%@ 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");
+            show_title(30);
+
+            //			反选
+            $('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 = new Array();
+            var $items = $('.check-item:checked');
+            $items.each(function () {
+                //通过拿到的商品ID组合键获取其它值
+                var productId = $(this).val();
+                items.push(productId);
+            });
+            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="cmHeheProduct" action="${ctx}/hehe/heheHomeTypeProduct/findProductPage" 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}"/>
+    <div class="ul-form">
+        <label>商品ID:</label>
+        <form:input path="productId" htmlEscape="false" onkeyup="onlynum(this)" maxlength="9" class="input-mini"/>
+        <label>商品名称:</label>
+        <form:input path="name" 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.id}" 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>

+ 2 - 4
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheBigtypeList.jsp

@@ -85,7 +85,7 @@
 
         //批量保存排序
         function updateSortIndex() {
-            $.post("${ctx}/product/cmBigtype/updateSortIndex",{'bigTypeIdSortIndexs':bigTypeId_sortIndex},function(result){
+            $.post("${ctx}/product/cmBigtype/updateSortIndex",{'bigTypeIdSortIndexs':bigTypeId_sortIndex,'mallType':2},function(result){
                 $.jBox.tip(result.data, 'info');
                 setTimeout(function () {
                     $("#searchForm").submit();
@@ -144,11 +144,9 @@
             <td>
                 <c:if test="${cmBigtype.crmValidFlag eq 1 }">
                     <font color="green" style="margin-right: 10px">已上架</font>
-<%--                    <a style="margin-left: 10px;text-decoration: underline" href="javascript:void(0);" onclick="updateStatus('0','${cmBigtype.bigTypeID}','crmValidFlag');">停用</a>--%>
                 </c:if>
                 <c:if test="${cmBigtype.crmValidFlag ne 1 }">
                     <font color="red" style="margin-right: 10px">已下架</font>
-<%--                    <a style="margin-left: 10px;text-decoration: underline" href="javascript:void(0)" onclick="updateStatus('1','${cmBigtype.bigTypeID}','crmValidFlag');">启用</a>--%>
                 </c:if>
             </td>
             <td>
@@ -161,7 +159,7 @@
                 ${cmBigtype.addTime}
             </td>
             <td>
-                <a href="${ctx}/product/cmBigtype/form?id=${cmBigtype.bigTypeID}">编辑</a>
+                <a href="${ctx}/product/cmBigtype/form?id=${cmBigtype.bigTypeID}&mallType=2">编辑</a>
                 <c:if test="${cmBigtype.crmValidFlag eq 1 }">
                     <a href="javascript:;" onclick="updateStatus('0','${cmBigtype.bigTypeID}','crmValidFlag')">下架</a>
                 </c:if>

+ 1 - 11
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheSmalltypeForm.jsp

@@ -120,7 +120,7 @@
 </head>
 <body>
 	<ul class="nav nav-tabs">
-		<li><a href="${ctx}/product/cmSmalltype/list?bigTypeID=${bigTypeID}&typeSort=${cmSmalltype.typeSort}">二级分类列表</a></li>
+		<li><a href="${ctx}/product/cmSmalltype/list?bigTypeID=${bigTypeID}&mallType=2">二级分类列表</a></li>
 		<li class="active"><a href="${ctx}/product/cmSmalltype/form?id=${cmSmalltype.smallTypeID}&typeSort=${cmSmalltype.typeSort}&mallType=2">二级分类<shiro:hasPermission name="product:cmSmalltype:edit">${not empty cmSmalltype.smallTypeID?'编辑':'添加'}</shiro:hasPermission><shiro:lacksPermission name="product:cmSmalltype:edit">查看</shiro:lacksPermission></a></li>
 	</ul><br/>
 	<form:form id="inputForm" modelAttribute="cmSmalltype" action="${ctx}/product/cmSmalltype/save" method="post" class="form-horizontal">
@@ -160,14 +160,6 @@
 				</form:select>
 			</div>
 		</div>
-<%--		<div class="control-group">
-			<label class="control-label">首页显示:</label>
-			<div class="controls">
-				<form:select path="displayOnHomePageFlag" class="input-xlarge ">
-					<form:options items="${fns:getDictList('enabled_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
-				</form:select>
-			</div>
-		</div>--%>
 		<div class="form-actions">
 			<shiro:hasPermission name="product:cmSmalltype:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
 			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
@@ -179,7 +171,6 @@
 			$('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
 			$('.upload-content .conList').find('.cancel-upload').hide();
 			var observeEle = document.getElementsByClassName('upload-content')[0];
-			var observeEle1 = document.getElementsByClassName('upload-content')[1];
 			var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
 			var MutationObserverConfig = {
 				childList: true,
@@ -202,7 +193,6 @@
 				})
 			});
 			observer.observe(observeEle, MutationObserverConfig);
-			observer.observe(observeEle1, MutationObserverConfig);
 
 			$('body').on('click', '.upload-content li', function () {
 				var index = $(this).closest('.conList').index() + 1,

+ 4 - 4
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheSmalltypeList.jsp

@@ -102,9 +102,9 @@
 			<form:input path="name" htmlEscape="false" maxlength="100" class="input-medium"/>
 			<label>状态:</label>
 			<form:select path="crmValidFlag" class="input-medium">
-				<form:option value="" label="全部"/>
-				<form:option value="1" label="启用"/>
-				<form:option value="0" label="停用"/>
+				<form:option value="" label="请选择"/>
+				<form:option value="1" label="已上架"/>
+				<form:option value="0" label="已下架"/>
 			</form:select>
 			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
 			<input class="btn btn-primary" type="button" value="一键排序" onclick="updateSortIndex()" style="margin-left: 15px"/>
@@ -153,7 +153,7 @@
 						${cmSmalltype.addTime}
 				</td>
 				<td>
-					<a href="${ctx}/product/cmSmalltype/form?id=${cmSmalltype.smallTypeID}&typeSort=${typeSort}">编辑</a>
+					<a href="${ctx}/product/cmSmalltype/form?id=${cmSmalltype.smallTypeID}&typeSort=${typeSort}&mallType=2">编辑</a>
 					<c:if test="${cmSmalltype.crmValidFlag eq 1 }">
 						<a href="javascript:;" onclick="updateStatus('0','${cmSmalltype.smallTypeID}','crmValidFlag')">下架</a>
 					</c:if>

+ 10 - 9
src/main/webapp/WEB-INF/views/modules/hehe/heheHomeTypeList.jsp

@@ -60,19 +60,19 @@
 		var typeId_sort = '';
 		function confirmSortIndex(index) {
 			var $sort = $("#sort" + index).val();
-			var $smallTypeId = $("#smallTypeId" + index).text();
+			var $typeId = $("#typeId" + index).text();
 			if (!isNaN($sort)) {
 				if($sort % 1 === 0 && $sort >0){
-					typeId_sort += $smallTypeId+"_"+$sort+","
+					typeId_sort += $typeId+"_"+$sort+","
 				}else{
 					alertx("排序只能输入大于0的整数");
-					$.get("${ctx}/hehe/heheHomeType/smallType",{'id':$smallTypeId}, function (data) {
+					$.get("${ctx}/hehe/heheHomeType/smallType",{'id':$typeId}, function (data) {
 						$("#sort" + index).val(data.data.sort);
 					})
 				}
 			}else{
 				alertx("排序只能输入大于0的整数");
-				$.get("${ctx}/hehe/heheHomeType/smallType",{'id':$smallTypeId},function (data) {
+				$.get("${ctx}/hehe/heheHomeType/smallType",{'id':$typeId},function (data) {
 					$("#sort" + index).val(data.data.sort);
 				})
 			}
@@ -80,7 +80,7 @@
 
 		//批量保存排序
 		function updateSortIndex() {
-			$.post("${ctx}/hehe/heheHomeType/updateSortIndex",{'smallTypeIdSortIndexs':typeId_sort},function(result){
+			$.post("${ctx}/hehe/heheHomeType/updateSortIndex",{'typeIdSortIndexs':typeId_sort},function(result){
 				$.jBox.tip(result.data, 'info');
 				setTimeout(function () {
 					$("#searchForm").submit();
@@ -121,7 +121,7 @@
 		<c:forEach items="${page.list}" var="heheHomeType"  varStatus="state">
 			<tr>
 				<td>
-					<label id="smallTypeId${state.index}">${heheHomeType.id}</label>
+					<label id="typeId${state.index}">${heheHomeType.id}</label>
 				</td>
 				<td>
 						${heheHomeType.name}
@@ -144,17 +144,18 @@
 						   style="width: 50px">
 				</td>
 				<td>
-						${heheHomeType.addTime}
+					<fmt:formatDate value="${heheHomeType.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
 				</td>
 				<td>
-					<a href="${ctx}/hehe/heheHomeType/form?id=${heheHomeType.id}">编辑</a>
 					<c:if test="${heheHomeType.status eq 1 }">
 						<a href="javascript:;" onclick="updateStatus('0','${heheHomeType.id}','status')">下架</a>
 					</c:if>
 					<c:if test="${heheHomeType.status ne 1 }">
 						<a href="javascript:;" onclick="updateStatus('1','${heheHomeType.id}','status')">上架</a>
 					</c:if>
-					<a href="${ctx}/hehe/heheHomeType/delete?id=${heheHomeType.id}">删除</a>
+                    <a href="${ctx}/hehe/heheHomeType/form?id=${heheHomeType.id}&mallType=2">编辑</a>
+                    <a href="${ctx}/hehe/heheHomeTypeProduct/?homeTypeId=${heheHomeType.id}">商品列表</a>
+                    <a href="${ctx}/hehe/heheHomeType/delete?id=${heheHomeType.id}">删除</a>
 				</td>
 			</tr>
 		</c:forEach>

+ 48 - 0
src/main/webapp/WEB-INF/views/modules/hehe/heheHomeTypeProductForm.jsp

@@ -0,0 +1,48 @@
+<%@ 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}/hehe/heheHomeTypeProduct/">商品列表</a></li>
+		<li class="active"><a href="${ctx}/hehe/heheHomeTypeProduct/form?id=${heheHomeTypeProduct.id}">商品<shiro:hasPermission name="hehe:heheHomeTypeProduct:edit">${not empty heheHomeTypeProduct.id?'编辑':'添加'}</shiro:hasPermission><shiro:lacksPermission name="hehe:heheHomeTypeProduct:edit">查看</shiro:lacksPermission></a></li>
+	</ul><br/>
+	<form:form id="inputForm" modelAttribute="heheHomeTypeProduct" action="${ctx}/hehe/heheHomeTypeProduct/save" method="post" class="form-horizontal">
+		<form:hidden path="id"/>
+		<sys:message content="${message}"/>		
+		<div class="control-group">
+			<label class="control-label">状态:0已下架,1已上架:</label>
+			<div class="controls">
+				<form:input path="status" htmlEscape="false" class="input-xlarge  digits"/>
+			</div>
+		</div>
+		<div class="form-actions">
+			<shiro:hasPermission name="hehe:heheHomeTypeProduct:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
+			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+		</div>
+	</form:form>
+</body>
+</html>

+ 193 - 0
src/main/webapp/WEB-INF/views/modules/hehe/heheHomeTypeProductList.jsp

@@ -0,0 +1,193 @@
+<%@ 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;
+        }
+
+		function update(status, ids, type) {
+			var msg = '确定上架该商品吗?';
+			if ('0' == status) {
+				msg = '确定下架该商品吗?';
+			}
+			top.$.jBox.confirm(msg, '系统提示', function (v, h, f) {
+				if (v == 'ok') {
+					$.post("${ctx}/hehe/homeTypeProduct/updateStatus", {
+						'status': status,
+						'id': ids
+					}, function (data) {
+						if (true == data.success) {
+							$.jBox.tip(data.msg, 'info');
+						} else {
+							$.jBox.tip(data.msg, 'error');
+						}
+						$("#searchForm").submit();
+					}, "JSON");//这里返回的类型有:json,html,xml,text
+				}
+				return;
+			}, {buttonsFocus: 1, persistent: true});
+		}
+
+		//选择添加
+		function showSelect() {
+			var url = '';
+			var title = '';
+			url = "${ctx}/hehe/heheHomeTypeProduct/findProductPage";
+			title = "添加商品";
+			top.$.jBox("iframe:" + url, {
+				iframeScrolling: 'yes',
+				width: $(top.document).width() - 600,
+				height: $(top.document).height() - 160,
+				persistent: true,
+				title: 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(0);
+						if (items.length > 0) {
+							console.log(items);
+							//添加数据
+							$.post("${ctx}/hehe/heheHomeTypeProduct/addProducts?homeTypeId=${heheHomeTypeProduct.homeTypeId}&productIds=" + items, function (data) {
+								if (true == data.success) {
+									$.jBox.tip(data.info, 'info');
+									setTimeout(function () {
+										window.location.href = "${ctx}/hehe/heheHomeTypeProduct/list?homeTypeId=${heheHomeTypeProduct.homeTypeId}"
+									}, 1300);
+								} else {
+									$.jBox.tip(data.info, 'error');
+								}
+							}, "JSON");//这里返回的类型有:json,html,xml,text
+							return true;
+						} else {
+							top.$.jBox.tip("请先勾选商品...");
+							return false;
+						}
+					}
+					return true;
+				}
+			});
+		}
+
+		function updateStatus(status, ids) {
+			var msg = '确定上架该商品吗?';
+			if ('0' == status) {
+				msg = '确定下架该商品吗?';
+			}
+			top.$.jBox.confirm(msg, '系统提示', function (v, h, f) {
+				if (v == 'ok') {
+					$.post("${ctx}/hehe/heheHomeTypeProduct/updateStatus", {
+						'status': status,
+						'id': ids
+					}, function (data) {
+						if (true == data.success) {
+							$.jBox.tip(data.msg, 'info');
+						} else {
+							$.jBox.tip(data.msg, 'error');
+						}
+						$("#searchForm").submit();
+					}, "JSON");//这里返回的类型有:json,html,xml,text
+				}
+				return;
+			}, {buttonsFocus: 1, persistent: true});
+		}
+	</script>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li><a href="${ctx}/hehe/heheHomeType">首页分类导航</a></li>
+		<li class="active"><a href="${ctx}/hehe/heheHomeTypeProduct/?homeTypeId=${heheHomeTypeProduct.homeTypeId}">商品列表</a></li>
+	</ul>
+	<form:form id="searchForm" modelAttribute="heheHomeTypeProduct" action="${ctx}/hehe/heheHomeTypeProduct/" 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}"/>
+		<form:hidden path="homeTypeId"/>
+		<div class="ul-form">
+			 <label>商品ID:</label>
+				<form:input path="productId" htmlEscape="false" class="input-medium"/>
+			 <label>商品名称:</label>
+			 	<form:input path="name" htmlEscape="false" class="input-medium"/>
+			 <label>供应商名称:</label>
+			 	<form:input path="shopName" htmlEscape="false" class="input-medium"/>
+			 <label>状态:</label>
+				<form:select path="status" class="input-medium">
+					<form:option value="" label="请选择"/>
+					<form:option value="1" label="已上架"/>
+					<form:option value="0" label="已下架"/>
+				</form:select>
+			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+			&nbsp;&nbsp;<input class="btn btn-primary" style="width: 80px" onclick="showSelect()" value="上线商品"/>
+			<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>
+				<th>操作</th>
+			</tr>
+		</thead>
+		<tbody>
+		<c:forEach items="${page.list}" var="heheHomeTypeProduct">
+			<tr>
+				<td>
+					${heheHomeTypeProduct.productId}
+				</td>
+				<td>
+					<img class="mainImage" src="${heheHomeTypeProduct.mainImage}" width="50px" height="50px">
+				</td>
+				<td>
+						${heheHomeTypeProduct.name}
+				</td>
+				<td>
+						${heheHomeTypeProduct.shopName}
+				</td>
+				<td>
+					<c:if test="${heheHomeTypeProduct.status eq 1 }">
+						<font color="green" style="margin-right: 10px">已上架</font>
+					</c:if>
+					<c:if test="${heheHomeTypeProduct.status ne 1 }">
+						<font color="red" style="margin-right: 10px">已下架</font>
+					</c:if>
+				</td>
+				<td>
+					<fmt:formatDate value="${heheHomeTypeProduct.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<c:if test="${heheHomeTypeProduct.status eq 1 }">
+						<a href="javascript:;" onclick="updateStatus('0','${heheHomeTypeProduct.id}')">下架</a>
+					</c:if>
+					<c:if test="${heheHomeTypeProduct.status ne 1 }">
+						<a href="javascript:;" onclick="updateStatus('1','${heheHomeTypeProduct.id}')">上架</a>
+					</c:if>
+					<a href="${ctx}/hehe/heheHomeTypeProduct/delete?id=${heheHomeTypeProduct.id}" onclick="return confirmx('确认要删除该商品吗?', this.href)">删除</a>
+				</td>
+			</tr>
+		</c:forEach>
+		</tbody>
+	</table>
+	<div class="pagination">${page}</div>
+</body>
+</html>