Browse Source

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

wangxiaoming 7 years ago
parent
commit
1d590b7b51

+ 23 - 3
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/product/Product.java

@@ -51,6 +51,10 @@ public class Product implements java.io.Serializable{
 	private String productColor;			//产品颜色		1:红色	2:橙色	3:黄色	4:绿色
 											//			5:青色	6:蓝色	7:紫色	8:白色
 	private ProductType productType;			//商品类型
+
+	private Integer productChoiceness;		//精选类型0:非精选1:精选置顶2:精选排后
+
+	private String productChoicenessIm;		//精选图片
 	
 	private PageBean page = new PageBean();	//分页信息
 	
@@ -58,7 +62,7 @@ public class Product implements java.io.Serializable{
 	
 	private List<ProductPicture> pictureList = new ArrayList<ProductPicture>();
 
-	private List<ProductColor> ProductColorList; //颜色集合
+	private List<ProductColor> productColorList; //颜色集合
 	
 	private Integer minMoney;		//页面显示   最小金额
 	
@@ -254,11 +258,27 @@ public class Product implements java.io.Serializable{
 	}
 
 	public List<ProductColor> getProductColorList() {
-		return ProductColorList;
+		return productColorList;
 	}
 
 	public void setProductColorList(List<ProductColor> productColorList) {
-		ProductColorList = productColorList;
+		productColorList = productColorList;
+	}
+
+	public Integer getProductChoiceness() {
+		return productChoiceness;
+	}
+
+	public void setProductChoiceness(Integer productChoiceness) {
+		this.productChoiceness = productChoiceness;
+	}
+
+	public String getProductChoicenessIm() {
+		return productChoicenessIm;
+	}
+
+	public void setProductChoicenessIm(String productChoicenessIm) {
+		this.productChoicenessIm = productChoicenessIm;
 	}
 
 	@Override

+ 9 - 0
iamberry-common-core/src/main/java/com/iamberry/wechat/core/entity/search/SearchInfo.java

@@ -15,6 +15,7 @@ public class SearchInfo implements java.io.Serializable {
     private String searchDetails;       //搜索内容
     private Integer searchNum;          //搜索次数
     private Date searchCreateDate;      //创建时间
+    private Date searchUpdateDate;     //修改时间
     private Integer searchTypeState;    //状态 1:使用中,2:停用
 
     public Integer getSearchId() {
@@ -64,4 +65,12 @@ public class SearchInfo implements java.io.Serializable {
     public void setSearchTypeState(Integer searchTypeState) {
         this.searchTypeState = searchTypeState;
     }
+
+    public Date getSearchUpdateDate() {
+        return searchUpdateDate;
+    }
+
+    public void setSearchUpdateDate(Date searchUpdateDate) {
+        this.searchUpdateDate = searchUpdateDate;
+    }
 }

+ 24 - 0
iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/cart/ProductInfoService.java

@@ -3,8 +3,10 @@ package com.iamberry.wechat.face.cart;
 import java.util.List;
 
 import com.iamberry.wechat.core.entity.product.Product;
+import com.iamberry.wechat.core.entity.product.ProductChildType;
 import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.core.entity.product.ProductType;
+import com.iamberry.wechat.core.entity.search.SearchInfo;
 
 public interface ProductInfoService {
 
@@ -49,4 +51,26 @@ public interface ProductInfoService {
 	 * @return
 	 */
 	List<ProductType> selectProductType();
+
+	/**
+	 *首页查询精选产品
+	 * **/
+	List<Product> selectIndexChoicenessProduct(Integer productChoiceness);
+
+	/**
+	 *根据配件类型id查询所有子类型
+	 * **/
+	List<ProductChildType> selectProductFittingsType(Integer typeId);
+
+	/**新增搜索记录**/
+	Integer insertSearchInfo(SearchInfo searchInfo);
+
+	/**查询是否已存在这条搜索记录**/
+	SearchInfo getSearchInfo(SearchInfo searchInfo);
+
+	/**查询是否已存在这条搜索记录**/
+	List<SearchInfo> selectSearchInfo(SearchInfo searchInfo);
+
+	/**修改历史搜索信息**/
+	Integer updateSearchInfo(SearchInfo searchInfo);
 }

+ 1 - 0
iamberry-wechat-interface/src/main/java/com/iamberry/wechat/face/porduct/ProductService.java

@@ -3,6 +3,7 @@ package com.iamberry.wechat.face.porduct;
 import java.util.List;
 
 import com.iamberry.wechat.core.entity.product.Product;
+import com.iamberry.wechat.core.entity.product.ProductChildType;
 
 /**
  * 产品信息处理service

+ 32 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/cart/ProductInfoServiceImpl.java

@@ -3,8 +3,10 @@ package com.iamberry.wechat.service.cart;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.iamberry.wechat.core.entity.product.ProductChildType;
 import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.core.entity.product.ProductType;
+import com.iamberry.wechat.core.entity.search.SearchInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -94,4 +96,34 @@ public class ProductInfoServiceImpl implements ProductInfoService {
 	public List<ProductType> selectProductType() {
 		return productInfoDao.selectProductType();
 	}
+
+	@Override
+	public List<Product> selectIndexChoicenessProduct(Integer productChoiceness) {
+		return productInfoDao.selectIndexChoicenessProduct(productChoiceness);
+	}
+
+
+	@Override
+	public List<ProductChildType> selectProductFittingsType(Integer typeId) {
+		return productInfoDao.selectProductFittingsType(typeId);
+	}
+	@Override
+	public Integer insertSearchInfo(SearchInfo searchInfo) {
+		return productInfoDao.insertSearchInfo(searchInfo);
+	}
+
+	@Override
+	public SearchInfo getSearchInfo(SearchInfo searchInfo) {
+		return productInfoDao.getSearchInfo(searchInfo);
+	}
+
+	@Override
+	public List<SearchInfo> selectSearchInfo(SearchInfo searchInfo) {
+		return productInfoDao.selectSearchInfo(searchInfo);
+	}
+
+	@Override
+	public Integer updateSearchInfo(SearchInfo searchInfo) {
+		return productInfoDao.updateSearchInfo(searchInfo);
+	}
 }

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

@@ -5,8 +5,10 @@ import java.util.List;
 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.ProductChildType;
 import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.core.entity.product.ProductType;
+import com.iamberry.wechat.core.entity.search.SearchInfo;
 
 public interface ProductInfoDao {
 
@@ -46,4 +48,26 @@ public interface ProductInfoDao {
 	 * @return
 	 */
 	List<ProductType> selectProductType();
+
+	/**
+	 *首页查询精选产品
+	 * **/
+	List<Product> selectIndexChoicenessProduct(Integer productChoiceness);
+
+	/**
+	 *根据配件类型id查询所有子类型
+	 * **/
+	List<ProductChildType> selectProductFittingsType(Integer typeId);
+
+	/**新增搜索记录**/
+	Integer insertSearchInfo(SearchInfo searchInfo);
+
+	/**查询是否已存在这条搜索记录**/
+	SearchInfo getSearchInfo(SearchInfo searchInfo);
+
+	/**查询是否已存在这条搜索记录**/
+	List<SearchInfo> selectSearchInfo(SearchInfo searchInfo);
+
+	/**修改历史搜索信息**/
+	Integer updateSearchInfo(SearchInfo searchInfo);
 }

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

@@ -2,8 +2,10 @@ package com.iamberry.wechat.service.cart.dao.impl;
 
 import java.util.List;
 
+import com.iamberry.wechat.core.entity.product.ProductChildType;
 import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.core.entity.product.ProductType;
+import com.iamberry.wechat.core.entity.search.SearchInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 
@@ -64,4 +66,34 @@ public class ProductInfoDaoImpl implements ProductInfoDao {
 	public List<ProductType> selectProductType() {
 		return productInfoMapper.selectProductType();
 	}
+
+	@Override
+	public List<Product> selectIndexChoicenessProduct(Integer productChoiceness) {
+		return productInfoMapper.selectIndexChoicenessProduct(productChoiceness);
+	}
+
+	@Override
+	public List<ProductChildType> selectProductFittingsType(Integer typeId) {
+		return productInfoMapper.selectProductFittingsType(typeId);
+	}
+
+	@Override
+	public Integer insertSearchInfo(SearchInfo searchInfo) {
+		return productInfoMapper.insertSearchInfo(searchInfo);
+	}
+
+	@Override
+	public SearchInfo getSearchInfo(SearchInfo searchInfo) {
+		return productInfoMapper.getSearchInfo(searchInfo);
+	}
+
+	@Override
+	public List<SearchInfo> selectSearchInfo(SearchInfo searchInfo) {
+		return productInfoMapper.selectSearchInfo(searchInfo);
+	}
+
+	@Override
+	public Integer updateSearchInfo(SearchInfo searchInfo) {
+		return productInfoMapper.updateSearchInfo(searchInfo);
+	}
 }

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

@@ -4,8 +4,10 @@ import java.util.List;
 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.ProductChildType;
 import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.core.entity.product.ProductType;
+import com.iamberry.wechat.core.entity.search.SearchInfo;
 
 public interface ProductInfoMapper {
 	
@@ -45,4 +47,25 @@ public interface ProductInfoMapper {
 	 * @return
 	 */
 	List<ProductType> selectProductType();
+
+	/**
+	 *首页查询精选产品
+	 * **/
+	List<Product> selectIndexChoicenessProduct(Integer productChoiceness);
+
+	/**
+	 *根据配件类型id查询所有子类型
+	 * **/
+	List<ProductChildType> selectProductFittingsType(Integer typeId);
+
+	/**新增搜索记录**/
+	Integer insertSearchInfo(SearchInfo searchInfo);
+	/**查询是否已存在这条搜索记录**/
+	SearchInfo getSearchInfo(SearchInfo searchInfo);
+
+	/**查询是否已存在这条搜索记录**/
+	List<SearchInfo> selectSearchInfo(SearchInfo searchInfo);
+
+	/**修改历史搜索信息**/
+	Integer updateSearchInfo(SearchInfo searchInfo);
 }

+ 81 - 2
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/productInfoMapper.xml

@@ -21,7 +21,9 @@
 		<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"/>
+		<result column="PRODUCT_CHOICENESS" property="productChoiceness"/>
+		<result column="product_choiceness_im" property="productChoicenessIm"/>
+		<collection property="productColorList" column="product_id" ofType="colorMap" select="selectProductColor"/>
 	</resultMap>
 
 	<resultMap id="colorMap" type="ProductColor">
@@ -216,8 +218,85 @@
 			</if>
 		</where>
 	</select>
-
+	<!-- 查询所有产品类型-->
 	<select id="selectProductType" resultType="ProductType">
 		select * from tb_iamberry_product_type where type_state = 1
 	</select>
+
+	<!--查询精选产品-->
+	<select id="selectIndexChoicenessProduct" resultMap="productMap" parameterType="Integer">
+			SELECT
+			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,
+			PRODUCT_CHOICENESS,
+			PRODUCT_CHOICENESS_IM
+			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_child_type on tb_iamberry_product_child_type.child_type_id = TB_IAMBERRY_PRODUCT_INFO.product_child_type
+			WHERE
+			PRODUCT_STATUS = 1
+			AND tb_iamberry_product_info.product_choiceness  = #{productChoiceness}
+			ORDER BY PRODUCT_CREATE_DATE DESC
+		</select>
+
+	<!--根据配件类型id查询所有子类型-->
+	<select id="selectProductFittingsType" resultType="ProductChildType" parameterType="Integer">
+		select * from tb_iamberry_product_child_type
+ 		where type_id = #{typeId}
+	</select>
+	<!--新增搜索记录-->
+	<insert id="insertSearchInfo" parameterType="SearchInfo">
+		insert into tb_iamberry_search_info (user_open_id,search_details,search_num,search_create_date,search_update_date,search_type_state)
+		VALUES (userOpenId,searchDetails,1,NOW(),NOW(),1)
+	</insert>
+
+	<update id="updateSearchInfo" parameterType="SearchInfo">
+		UPDATE tb_iamberry_search_info
+		SET search_num = search_num + 1,search_update_date = NOW()
+		WHERE
+		user_open_id = #{userOpenId} and search_details = #{searchDetails}
+	</update>
+	<!--查询是否已存在这条搜索记录-->
+	<select id="getSearchInfo" resultType="SearchInfo" parameterType="SearchInfo">
+		SELECT * from tb_iamberry_search_info
+		<where>
+			<if test="userOpenId != null and userOpenId != ''">
+				userOpenId = #{userOpenId}
+			</if>
+			<if test="searchDetails != null and searchDetails != ''">
+				search_details = #{searchDetails}
+			</if>
+			<if test="searchTypeState != null and searchTypeState != ''">
+				search_type_state = #{searchTypeState}
+			</if>
+		</where>
+	</select>
+	<!--查询前五条搜索记录-->
+	<select id="selectSearchInfo" resultType="SearchInfo" parameterType="SearchInfo">
+		SELECT TOP 5 * from tb_iamberry_search_info
+		<where>
+			<if test="userOpenId != null and userOpenId != ''">
+				userOpenId = #{userOpenId}
+			</if>
+			<if test="searchDetails != null and searchDetails != ''">
+				search_details like '%#{searchDetails}%'
+			</if>
+			<if test="searchTypeState != null and searchTypeState != ''">
+				search_type_state = #{searchTypeState}
+			</if>
+		</where>
+		ORDER BY
+		search_update_date DESC
+		LIMIT 5
+	</select>
 </mapper>

+ 1 - 0
iamberry-wechat-service/src/main/java/com/iamberry/wechat/service/product/ProductServiceImpl.java

@@ -2,6 +2,7 @@ package com.iamberry.wechat.service.product;
 
 import java.util.List;
 
+import com.iamberry.wechat.core.entity.product.ProductChildType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 

+ 52 - 6
iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/cart/ProductInfoHandler.java

@@ -10,7 +10,9 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import com.iamberry.wechat.core.entity.product.ProductType;
+import com.iamberry.wechat.core.entity.admin.ShopSystemRule;
+import com.iamberry.wechat.core.entity.product.*;
+import com.iamberry.wechat.core.entity.search.SearchInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -22,9 +24,6 @@ import org.apache.commons.lang.StringUtils;
 import com.iamberry.wechat.core.entity.ResultMsg;
 import com.iamberry.wechat.core.entity.WechatUtils;
 import com.iamberry.wechat.core.entity.member.Member;
-import com.iamberry.wechat.core.entity.product.Product;
-import com.iamberry.wechat.core.entity.product.ProductImageText;
-import com.iamberry.wechat.core.entity.product.ProductPicture;
 import com.iamberry.wechat.face.admin.SystemService;
 import com.iamberry.wechat.face.cart.ProductInfoService;
 import com.iamberry.wechat.face.home.HomeService;
@@ -92,6 +91,16 @@ public class ProductInfoHandler {
 		//查询所有产品类型
 		List<ProductType> productTypeList = productInfoService.selectProductType();
 		if (null != productName && !"".equals(productName)) {
+			//判断历史记录是否已存在
+			SearchInfo searchInfo = new SearchInfo();
+			searchInfo.setSearchDetails(productName);
+			searchInfo.setUserOpenId(member.getUserOpenid());
+			SearchInfo info = productInfoService.getSearchInfo(searchInfo);
+			if(info != null){
+				productInfoService.updateSearchInfo(searchInfo);
+			}else{
+				productInfoService.insertSearchInfo(searchInfo);
+			}
 			productName = "%" + productName + "%";
 		}
 		if (null == typeId) {
@@ -103,7 +112,6 @@ public class ProductInfoHandler {
 		product.setProductName(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>();
@@ -116,7 +124,45 @@ public class ProductInfoHandler {
 		remsg.setData(map);
 		return remsg;
 	}
-	
+
+	/**
+	 * 获取历史搜索记录前五
+	 * @param request
+	 * @return list
+	 * @throws Exception
+	 */
+	@ResponseBody
+	@RequestMapping(value = "/selectSearchInfo",method = RequestMethod.POST)
+	public ResultMsg productIndex(HttpServletRequest request,
+								  @RequestParam(value = "productName", defaultValue = "")String productName) throws Exception {
+		ResultMsg remsg=new ResultMsg();
+
+		if (null == productName || "".equals(productName)) {
+			remsg.setMessage(ResultInfo.loginOutError);
+			remsg.setStatus(false);
+			remsg.setMessage(ResultInfo.loginOutError);
+			return remsg;
+		}
+		Member member =  wechatUtils.getUserBySession(request);
+		if (member == null || member.getUserOpenid() == null) {
+			remsg.setMessage(ResultInfo.loginOutError);
+			remsg.setStatus(false);
+			remsg.setMessage(ResultInfo.loginOutError);
+			return remsg;
+		}
+		SearchInfo searchInfo = new SearchInfo();
+		searchInfo.setUserOpenId(member.getUserOpenid());
+		searchInfo.setSearchDetails(productName);
+		List<SearchInfo> listSearchInfo =  productInfoService.selectSearchInfo(searchInfo);
+		Map<String, Object> map = new HashMap<String, Object>();
+		map.put("listSearchInfo", listSearchInfo);
+		remsg.setMessage(ResultInfo.SUCCESSINFO);
+		remsg.setResultCode(ResultInfo.SUCCESSCODE);
+		remsg.setStatus(true);
+		remsg.setData(map);
+		return remsg;
+	}
+
 	/**
 	 * 进入产品详细信息页面
 	 * @param request

+ 13 - 4
iamberry-wechat-web/src/main/java/com/iamberry/wechat/handles/home/HomeHandler.java

@@ -8,6 +8,8 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.iamberry.wechat.core.entity.admin.ShopSystemRule;
+import com.iamberry.wechat.core.entity.product.ProductChildType;
 import com.iamberry.wechat.tools.WeixinUtil;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -90,8 +92,14 @@ public class HomeHandler {
 		
 		// 准备数据
 		Map<String, Object> returnMap = new HashMap<String, Object>();
-		List<Product> productList = productInfoService.selectIndexPageProduct();
-		
+		/*List<Product> productList = productInfoService.selectIndexPageProduct();*/
+		List<Product> selectProductTopper = productInfoService.selectIndexChoicenessProduct(1);//获取精选置顶产品
+		List<Product> selectProduct = productInfoService.selectIndexChoicenessProduct(2);//获取精选产品
+
+		//获取配件类型
+		ShopSystemRule shopSystemRule = systemService.selectOneShopRuleById(255);
+		List<ProductChildType> childTypesList = productInfoService.selectProductFittingsType(shopSystemRule.getRuleType());
+
 		List<ActionBannerImage> images = homeService.selectNowBannerByType(); 	// Banner、广告位
 		List<ActionBannerImage> banners = new ArrayList<ActionBannerImage>();	// banner
 		List<ActionBannerImage> advs = new ArrayList<ActionBannerImage>();		// 广告位
@@ -106,9 +114,10 @@ public class HomeHandler {
 		}
 		returnMap.put("advs", advs);
 		returnMap.put("banners", banners);
-		returnMap.put("products", productList); 							// 产品信息,10个
+		returnMap.put("selectProductTopper", selectProductTopper);
+		returnMap.put("selectProduct", selectProduct);
 		returnMap.put("memberOpenid", member.getUserOpenid()); 				// 当前用户信息 分享用
-		
+		returnMap.put("childTypesList", childTypesList);					// 配件子类型集合
 		msg.setData(returnMap); 											// 封装数据
 		msg.setMessage(ResultInfo.SUCCESSINFO);
 		msg.setResultCode(ResultInfo.SUCCESSCODE);