浏览代码

Merge branch 'master' of http://git.iamberry.com/hexiugang/iamberry-common-parent

liuzhiwei 7 年之前
父节点
当前提交
00d750b994

+ 10 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/product/Product.java

@@ -57,6 +57,8 @@ public class Product implements java.io.Serializable{
 	private ProductImageText productImageText = new ProductImageText();
 	
 	private List<ProductPicture> pictureList = new ArrayList<ProductPicture>();
+
+	private List<ProductColor> ProductColorList; //颜色集合
 	
 	private Integer minMoney;		//页面显示   最小金额
 	
@@ -251,6 +253,14 @@ public class Product implements java.io.Serializable{
 		this.page = page;
 	}
 
+	public List<ProductColor> getProductColorList() {
+		return ProductColorList;
+	}
+
+	public void setProductColorList(List<ProductColor> productColorList) {
+		ProductColorList = productColorList;
+	}
+
 	@Override
 	public String toString() {
 		return "Product [productId=" + productId + ", productName="

+ 10 - 1
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/product/ProductColor.java

@@ -3,6 +3,7 @@ package com.iamberry.wechat.core.entity.product;
 import com.iamberry.wechat.core.entity.PageBean;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 产品颜色表
@@ -25,7 +26,7 @@ public class ProductColor implements java.io.Serializable {
     private String color69Code;			//产品69码
     private Date colorCretaeTime;		//创建时间
     private Date colorUpdateTime;	//修改时间
-
+    private List<SalesUserGift> salesUserGiftList; //赠品集合
     private PageBean page = new PageBean();		//分页
 
     public Integer getColorStatus() {
@@ -139,4 +140,12 @@ public class ProductColor implements java.io.Serializable {
     public void setPage(PageBean page) {
         this.page = page;
     }
+
+    public List<SalesUserGift> getSalesUserGiftList() {
+        return salesUserGiftList;
+    }
+
+    public void setSalesUserGiftList(List<SalesUserGift> salesUserGiftList) {
+        this.salesUserGiftList = salesUserGiftList;
+    }
 }

+ 8 - 1
iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/cart/ProductInfoService.java

@@ -4,11 +4,12 @@ import java.util.List;
 
 import com.iamberry.wechat.core.entity.product.Product;
 import com.iamberry.wechat.core.entity.product.ProductColor;
+import com.iamberry.wechat.core.entity.product.ProductType;
 
 public interface ProductInfoService {
 
 	//分页查询商品信息
-	public List<Product> selectPageProduct(int pageSize, int pageNO, String productName);
+	public List<Product> selectPageProduct(int pageSize, int pageNO, String productName,Integer typeId);
 	
 	//根据productID查询商品信息
 	public Product getProductByProductId(Integer productId);
@@ -42,4 +43,10 @@ public interface ProductInfoService {
 	 * @return
 	 */
 	ProductColor getProductColor(ProductColor productColor);
+
+	/**
+	 * 获取所有产品类型
+	 * @return
+	 */
+	List<ProductType> selectProductType();
 }

+ 10 - 1
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/ProductInfoServiceImpl.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import com.iamberry.wechat.core.entity.product.ProductColor;
+import com.iamberry.wechat.core.entity.product.ProductType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -25,7 +26,7 @@ public class ProductInfoServiceImpl implements ProductInfoService {
 	private CartDao cartDao;
 
 	
-	public List<Product> selectPageProduct(int pageSize, int pageNO, String productName) {
+	public List<Product> selectPageProduct(int pageSize, int pageNO, String productName,Integer typeId) {
 		// TODO Auto-generated method stub
 		PaperBean bean = new PaperBean();
 		if (pageNO == 1) {
@@ -37,6 +38,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
 		if (null != productName && !"".equals(productName)) {
 			bean.setStr(productName);
 		}
+		if (null != typeId) {
+			bean.setOtherInt(typeId);
+		}
 		return productInfoDao.selectPageProduct(bean);
 	}
 
@@ -85,4 +89,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
 	public ProductColor getProductColor(ProductColor productColor) {
 		return productInfoDao.getProductColor(productColor);
 	}
+
+	@Override
+	public List<ProductType> selectProductType() {
+		return productInfoDao.selectProductType();
+	}
 }

+ 7 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/dao/ProductInfoDao.java

@@ -6,6 +6,7 @@ import com.iamberry.wechat.core.entity.PaperBean;
 import com.iamberry.wechat.core.entity.cart.ShopOrderItemDto;
 import com.iamberry.wechat.core.entity.product.Product;
 import com.iamberry.wechat.core.entity.product.ProductColor;
+import com.iamberry.wechat.core.entity.product.ProductType;
 
 public interface ProductInfoDao {
 
@@ -39,4 +40,10 @@ public interface ProductInfoDao {
 	 * @return
 	 */
 	ProductColor getProductColor(ProductColor productColor);
+
+	/**
+	 * 获取所有产品类型
+	 * @return
+	 */
+	List<ProductType> selectProductType();
 }

+ 6 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/dao/impl/ProductInfoDaoImpl.java

@@ -3,6 +3,7 @@ package com.iamberry.wechat.service.cart.dao.impl;
 import java.util.List;
 
 import com.iamberry.wechat.core.entity.product.ProductColor;
+import com.iamberry.wechat.core.entity.product.ProductType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 
@@ -58,4 +59,9 @@ public class ProductInfoDaoImpl implements ProductInfoDao {
 	public ProductColor getProductColor(ProductColor productColor) {
 		return productInfoMapper.getProductColor(productColor);
 	}
+
+	@Override
+	public List<ProductType> selectProductType() {
+		return productInfoMapper.selectProductType();
+	}
 }

+ 7 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/ProductInfoMapper.java

@@ -5,6 +5,7 @@ import com.iamberry.wechat.core.entity.PaperBean;
 import com.iamberry.wechat.core.entity.cart.ShopOrderItemDto;
 import com.iamberry.wechat.core.entity.product.Product;
 import com.iamberry.wechat.core.entity.product.ProductColor;
+import com.iamberry.wechat.core.entity.product.ProductType;
 
 public interface ProductInfoMapper {
 	
@@ -38,4 +39,10 @@ public interface ProductInfoMapper {
 	 * @return
 	 */
 	ProductColor getProductColor(ProductColor productColor);
+
+	/**
+	 * 获取所有产品类型
+	 * @return
+	 */
+	List<ProductType> selectProductType();
 }

+ 42 - 35
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/cartMapper.xml

@@ -7,46 +7,22 @@ PUBLIC
 	namespace:必须与对应的接口全类名一致
  -->
 <mapper namespace="com.iamberry.wechat.service.mapper.CartMapper">
-	<resultMap id="cartMap" type="CartDto">
-		<id column="cart_id" property="cartId"/>
-		<result column="CART_PRODUCT_ID" property="cartProductId"/>
-		<result column="CART_NUM" property="cartNum"/>
-		<result column="PRODUCT_NAME" property="productName"/>
-		<result column="color_discount" property="productPrice"/>
-		<result column="PRODUCT_STATUS" property="productStatus"/>
-		<result column="color_name" property="productColor"/>
-		<result column="color_product_pic" property="productIntroduceImg"/>
-		<result column="PRODUCT_REMARK" property="productRemark"/>
-		<result column="color_id" property="colorId"/>
-		<collection property="salesUserGiftList" column="color_id" ofType="SalesUserGift" select="listGift"/>
-	</resultMap>
 
-	<select id="listGift" resultType="salesUserGiftList" parameterType="Integer">
-		SELECT
-			ug.user_id userId,
-			ug.user_product_id userProductId,
-			ug.user_color_id userColorId,
-			ug.user_gift_id userGiftId,
-			ug.user_gift_color userGiftColor,
-			ug.user_gift_count userGiftCount,
-			ug.user_status userStatus,
-			ug.user_status userCreateTime,
-			pi.product_name productName
-		FROM
-			tb_iamberry_sales_user_gift ug
-		LEFT JOIN tb_iamberry_product_color pc on pc.color_id = 1
-		LEFT JOIN tb_iamberry_product_info pi on pi.product_id = pc.color_product_id
-		WHERE
-			ug.user_color_id = 1
-	</select>
 
 	<!-- 查询用户购物车所有信息 -->
 	<select id="selectCartByOpenId" parameterType="String" resultMap="cartMap">
 		SELECT 
-			C.CART_ID cartId, C.CART_PRODUCT_ID cartProductId, C.CART_NUM cartNum,P.PRODUCT_NAME productName,
-			pc.color_discount productPrice, P.PRODUCT_STATUS productStatus, pc.color_name productColor,
-			pc.color_product_pic productIntroduceImg, PRODUCT_REMARK productRemark,pc.color_id colorId
-		FROM 
+			C.CART_ID,
+			C.CART_PRODUCT_ID,
+			C.CART_NUM,
+			P.PRODUCT_NAME,
+			pc.color_discount,
+			P.PRODUCT_STATUS,
+			pc.color_name,
+			pc.color_product_pic,
+			PRODUCT_REMARK,
+			pc.color_id
+		FROM
 			TB_IAMBERRY_SHOP_CART C
 			LEFT JOIN TB_IAMBERRY_PRODUCT_INFO P ON C.CART_PRODUCT_ID = P.PRODUCT_ID
 			LEFT JOIN TB_IAMBERRY_PRODUCT_COLOR  pc on C.CART_PRODUCT_ID = pc.color_product_id
@@ -54,7 +30,38 @@ PUBLIC
 			C.CART_OPENID = #{openId} 
 		ORDER BY C.CART_ID DESC 
 	</select>
+	<resultMap id="cartMap" type="CartDto">
+		<id column="cart_id" property="cartId"/>
+		<result column="cart_product_id" property="cartProductId"/>
+		<result column="cart_num" property="cartNum"/>
+		<result column="product_name" property="productName"/>
+		<result column="color_discount" property="productPrice"/>
+		<result column="product_status" property="productStatus"/>
+		<result column="color_name" property="productColor"/>
+		<result column="color_product_pic" property="productIntroduceImg"/>
+		<result column="product_remark" property="productRemark"/>
+		<result column="color_id" property="cartColorId"/>
+		<collection property="salesUserGiftList" column="color_id" ofType="SalesUserGift" select="listGift"/>
+	</resultMap>
 
+	<select id="listGift" resultType="SalesUserGift" parameterType="Integer">
+		SELECT
+		ug.user_id userId,
+		ug.user_product_id userProductId,
+		ug.user_color_id userColorId,
+		ug.user_gift_id userGiftId,
+		ug.user_gift_color userGiftColor,
+		ug.user_gift_count userGiftCount,
+		ug.user_status userStatus,
+		ug.user_create_time userCreateTime,
+		pi.product_name productName
+		FROM
+		tb_iamberry_sales_user_gift ug
+		LEFT JOIN tb_iamberry_product_color pc on pc.color_id = #{cartColorId}
+		LEFT JOIN tb_iamberry_product_info pi on pi.product_id = pc.color_product_id
+		WHERE
+		ug.user_color_id = #{cartColorId}
+	</select>
 
 
 	<select id="getCartNumByCartOpenId" parameterType="String" resultType="Integer">

+ 82 - 19
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/productInfoMapper.xml

@@ -8,38 +8,97 @@
 		PRODUCT_INTRODUCE_IMG productIntroduceImg, PRODUCT_PARAMETER_IMG productParameterImg, PRODUCT_CREATE_DATE productCreateDate, 
 		PRODUCT_SORT_NUM productSortNum, PRODUCT_COLOR_DES productColorDes, PRODUCT_REMARK productRemark,PRODUCT_COLOR productColor 
 	</sql>
-	
+
+	<resultMap id="productMap" type="Product">
+		<id column="product_id" property="productId"/>
+		<result column="product_name" property="productName"/>
+		<result column="product_abbreviation" property="productAbbreviation"/>
+		<result column="product_salesnum" property="productSalesnum"/>
+		<result column="product_accessnum" property="productAccessnum"/>
+		<result column="product_status" property="productStatus"/>
+		<result column="product_parameter_img" property="productParameterImg"/>
+		<result column="PRODUCT_CREATE_DATE" property="productCreateDate"/>
+		<result column="PRODUCT_SORT_NUM" property="productSortNum"/>
+		<result column="PRODUCT_COLOR_DES" property="productColorDes"/>
+		<result column="PRODUCT_REMARK" property="productRemark"/>
+		<collection property="ProductColorList" column="product_id" ofType="colorMap" select="selectProductColor"/>
+	</resultMap>
+
+	<resultMap id="colorMap" type="ProductColor">
+		<id column="color_id" property="colorId"/>
+		<result column="color_product_id" property="colorProductId"/>
+		<result column="color_name" property="colorName"/>
+		<result column="color_discount" property="colorDiscount"/>
+		<result column="color_price" property="colorPrice"/>
+		<result column="color_69code" property="color69Code"/>
+		<result column="color_code" property="colorCode"/>
+		<result column="color_product_pic" property="colorProductPic"/>
+		<result column="color_status" property="colorStatus"/>
+		<result column="color_cretae_time" property="colorCretaeTime"/>
+		<result column="color_update_time" property="colorUpdateTime"/>
+		<collection property="salesUserGiftList" column="color_id" ofType="SalesUserGift" select="listGift"/>
+	</resultMap>
+
 	<!-- 分页查询商品信息 -->
-	<select id="selectPageProduct" parameterType="PaperBean" resultType="Product">
+	<select id="selectPageProduct" parameterType="PaperBean" resultMap="productMap">
 		SELECT
-		PRODUCT_ID productId,
-		PRODUCT_NAME productName,
-		PRODUCT_ABBREVIATION productAbbreviation,
-		color_discount productDiscount,
-		color_price productPrice,
-		PRODUCT_SALESNUM productSalesnum,
-		PRODUCT_ACCESSNUM productAccessnum,
-		PRODUCT_STATUS productStatus,
-		color_product_pic productIntroduceImg,
-		PRODUCT_PARAMETER_IMG productParameterImg,
-		PRODUCT_CREATE_DATE productCreateDate,
-		PRODUCT_SORT_NUM productSortNum,
-		PRODUCT_COLOR_DES productColorDes,
-		PRODUCT_REMARK productRemark,
-		color_name productColor
+		PRODUCT_ID,
+		PRODUCT_NAME,
+		PRODUCT_ABBREVIATION,
+		PRODUCT_SALESNUM,
+		PRODUCT_ACCESSNUM,
+		PRODUCT_STATUS,
+		PRODUCT_PARAMETER_IMG,
+		PRODUCT_CREATE_DATE,
+		PRODUCT_SORT_NUM,
+		PRODUCT_COLOR_DES,
+		PRODUCT_REMARK
 		FROM 
 			TB_IAMBERRY_PRODUCT_INFO
-		LEFT JOIN TB_IAMBERRY_PRODUCT_COLOR
-		on TB_IAMBERRY_PRODUCT_INFO.product_id = TB_IAMBERRY_PRODUCT_COLOR.color_product_id
+		LEFT JOIN TB_IAMBERRY_PRODUCT_COLOR on TB_IAMBERRY_PRODUCT_INFO.product_id = TB_IAMBERRY_PRODUCT_COLOR.color_product_id
+		LEFT JOIN tb_iamberry_product_child_type on tb_iamberry_product_child_type.child_type_id = TB_IAMBERRY_PRODUCT_INFO.product_child_type
 		WHERE
 			PRODUCT_STATUS = 1 
 			<if test="str != null and str != ''">
 				AND PRODUCT_NAME like #{str} 
 			</if>
+			<if test="otherInt != null and otherInt != ''">
+				AND tb_iamberry_product_child_type.type_id  = #{otherInt}
+			</if>
 			ORDER BY PRODUCT_CREATE_DATE DESC 
 		LIMIT 
 			#{minNum},#{maxNum}
 	</select>
+
+	<!-- 根据产品id获取所有颜色信息 -->
+	<select id="selectProductColor" parameterType="Integer" resultMap="colorMap">
+		SELECT
+		c.*
+		FROM
+		tb_iamberry_product_color c
+		<where>
+			c.color_product_id = #{productId}
+		</where>
+	</select>
+
+	<select id="listGift" resultType="SalesUserGift" parameterType="Integer">
+		SELECT
+		ug.user_id userId,
+		ug.user_product_id userProductId,
+		ug.user_color_id userColorId,
+		ug.user_gift_id userGiftId,
+		ug.user_gift_color userGiftColor,
+		ug.user_gift_count userGiftCount,
+		ug.user_status userStatus,
+		ug.user_create_time userCreateTime,
+		pi.product_name productName
+		FROM
+		tb_iamberry_sales_user_gift ug
+		LEFT JOIN tb_iamberry_product_color pc on pc.color_id = #{cartColorId}
+		LEFT JOIN tb_iamberry_product_info pi on pi.product_id = pc.color_product_id
+		WHERE
+		ug.user_color_id = #{cartColorId}
+	</select>
 	
 	<select id="selectProductCount" resultType="Integer" parameterType="Product">
 		SELECT 
@@ -157,4 +216,8 @@
 			</if>
 		</where>
 	</select>
+
+	<select id="selectProductType" resultType="ProductType">
+		select * from tb_iamberry_product_type where type_state = 1
+	</select>
 </mapper>

+ 13 - 2
iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/cart/ProductInfoHandler.java

@@ -10,6 +10,7 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.iamberry.wechat.core.entity.product.ProductType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -77,7 +78,8 @@ public class ProductInfoHandler {
 	public ResultMsg productIndex(HttpServletRequest request,
 			@RequestParam(value= "pageSize",defaultValue= "6" ,required=false) Integer pageSize, 
 			@RequestParam(value = "pageNO", defaultValue = "1") Integer pageNO,
-			@RequestParam(value = "productName", defaultValue = "")String productName) throws Exception {
+			@RequestParam(value = "productName", defaultValue = "")String productName,
+			@RequestParam(value = "typeId", defaultValue = "")Integer typeId) throws Exception {
 		
 		ResultMsg remsg=new ResultMsg();
 		Member member =  wechatUtils.getUserBySession(request);
@@ -87,17 +89,26 @@ public class ProductInfoHandler {
 			remsg.setMessage(ResultInfo.loginOutError);
 			return remsg;
 		}
+		//查询所有产品类型
+		List<ProductType> productTypeList = productInfoService.selectProductType();
 		if (null != productName && !"".equals(productName)) {
 			productName = "%" + productName + "%";
 		}
+		if (null == typeId) {
+			typeId = productTypeList.get(0).getTypeId();
+		}
+		ProductType productType = new ProductType();
+		productType.setTypeId(typeId);
 		Product product = new Product();
 		product.setProductName(productName);
-		List<Product> productList = productInfoService.selectPageProduct(pageSize, pageNO,productName);
+		product.setProductType(productType);
+		List<Product> productList = productInfoService.selectPageProduct(pageSize, pageNO,productName,typeId);
 
 		int num = this.productInfoService.selectProductCount(product);
 		int count = num % pageSize == 0? num/pageSize:(num/pageSize)+1;
 		Map<String, Object> map = new HashMap<String, Object>();
 		map.put("productList", productList);
+		map.put("productTypeList", productTypeList);
 		map.put("total", count);
 		remsg.setMessage(ResultInfo.SUCCESSINFO);
 		remsg.setResultCode(ResultInfo.SUCCESSCODE);