|
@@ -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
|