|
@@ -83,23 +83,20 @@ 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,
|
|
|
+ @RequestParam(value = "productName", required = false)String productName,
|
|
|
@RequestParam(value = "productType", defaultValue = "1") Integer productType,
|
|
|
@RequestParam(value = "productRentType", defaultValue = "1") Integer productRentType) throws Exception {
|
|
|
-
|
|
|
- ResultMsg remsg= new ResultMsg();
|
|
|
- Member member = WechatUtils.getUserBySession(request);
|
|
|
- //member.setUserId(11907);
|
|
|
- //member.setUserOpenid("o-icas-WiwbEXfwO1wLGDKQ1iWJU");
|
|
|
+ // 获取当前登陆的用户
|
|
|
+ WechatUtils.getUserBySession(request);
|
|
|
+ // 组装查询数据
|
|
|
Product product = new Product();
|
|
|
- if (null != productName && !"".equals(productName)) {
|
|
|
- product.setProductName(productName);
|
|
|
- }
|
|
|
+ product.setProductName(productName);
|
|
|
product.getProductType().setTypeId(productType);
|
|
|
product.setProductRentType(productRentType);
|
|
|
product.getPage().setPageNumber(pageNO);
|
|
|
product.getPage().setPageSize(pageSize);
|
|
|
product.getPage().initRecordBegin();
|
|
|
+ // 查询产品
|
|
|
List<Product> productList = productInfoService.selectPageProduct(product);
|
|
|
Promotions promotions = activityUtil.getAllPromotions();
|
|
|
if(promotions != null){
|
|
@@ -116,17 +113,13 @@ public class ProductInfoHandler {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ // 返回数据
|
|
|
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<String, Object> map = new HashMap<String, Object>(2);
|
|
|
map.put("productList", productList);
|
|
|
map.put("total", count);
|
|
|
- remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
- remsg.setStatus(true);
|
|
|
- remsg.setData(map);
|
|
|
- return remsg;
|
|
|
+ return ResultMsg.SUCCESS().setData(map);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -145,15 +138,10 @@ public class ProductInfoHandler {
|
|
|
IndexProduct seccoluproduct = new IndexProduct();
|
|
|
seccoluproduct.setIndeProdType(2);
|
|
|
// 开始返回
|
|
|
- ResultMsg remsg= new ResultMsg();
|
|
|
- Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>(2);
|
|
|
map.put("firColuProductList", indexProductService.getIndexProductList(firColuProduct));
|
|
|
map.put("SecColuProductList", indexProductService.getIndexProductList(seccoluproduct));
|
|
|
- remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
- remsg.setStatus(true);
|
|
|
- remsg.setData(map);
|
|
|
- return remsg;
|
|
|
+ return ResultMsg.SUCCESS().setData(map);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -166,32 +154,15 @@ public class ProductInfoHandler {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/getProductByProductId")
|
|
|
- public ResultMsg getProductByProductId(HttpServletRequest request,HttpServletResponse response,
|
|
|
- @RequestParam(value = "productId",defaultValue = "") String productId,
|
|
|
- @RequestParam("colorId") Integer colorId
|
|
|
- ) throws Exception {
|
|
|
-
|
|
|
- ResultMsg remsg = new ResultMsg();
|
|
|
+ public ResultMsg getProductByProductId(
|
|
|
+ HttpServletRequest request,
|
|
|
+ HttpServletResponse response,
|
|
|
+ @RequestParam(value = "productId") String productId,
|
|
|
+ @RequestParam("colorId") Integer colorId) throws Exception {
|
|
|
+ // 获取当前登陆的用户信息
|
|
|
Member member = WechatUtils.getUserBySession(request);
|
|
|
- //member.setUserId(11907);
|
|
|
- //member.setUserOpenid("o-icas-WiwbEXfwO1wLGDKQ1iWJU");
|
|
|
+ ResultMsg remsg = new ResultMsg();
|
|
|
Map<String, Object> map=null;
|
|
|
- /*
|
|
|
- * 判断用户信息及其参数
|
|
|
- */
|
|
|
- if (member == null || member.getUserOpenid() == null) {
|
|
|
- remsg.setMessage(ResultInfo.loginOutError);
|
|
|
- remsg.setStatus(false);
|
|
|
- remsg.setMessage(ResultInfo.loginOutError);
|
|
|
- return remsg;
|
|
|
- }
|
|
|
- if (productId == null) {
|
|
|
- remsg.setStatus(false);
|
|
|
- remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
- return remsg;
|
|
|
- }
|
|
|
-
|
|
|
if (StaticInfo.pattern.matcher(productId).find()) {
|
|
|
Product product = this.productInfoService.getProductByProductId(Integer.parseInt(productId),colorId);
|
|
|
|
|
@@ -217,18 +188,11 @@ public class ProductInfoHandler {
|
|
|
/*
|
|
|
* 组装数据
|
|
|
*/
|
|
|
- map = new HashMap<String, Object>();
|
|
|
-// map.put("isShow", ResultInfo.ISSHOW);
|
|
|
-// map.put("cartDesc", ResultInfo.CARTDESC);
|
|
|
-// map.put("cart_url", ResultInfo.CART_URL);
|
|
|
+ map = new HashMap<String, Object>(3);
|
|
|
map.put("product", product);
|
|
|
map.put("shareOpenid", member.getUserOpenid());
|
|
|
map.put("colorList", colorList);
|
|
|
- remsg.setData(map);
|
|
|
- remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
- remsg.setStatus(true);
|
|
|
- return remsg;
|
|
|
+ return ResultMsg.SUCCESS().setData(map);
|
|
|
}
|
|
|
|
|
|
try {
|
|
@@ -239,21 +203,13 @@ public class ProductInfoHandler {
|
|
|
/*
|
|
|
* 组装数据
|
|
|
*/
|
|
|
- map = new HashMap<String, Object>();
|
|
|
-// map.put("isShow", ResultInfo.ISSHOW);
|
|
|
-// map.put("cartDesc", ResultInfo.CARTDESC);
|
|
|
-// map.put("cart_url", ResultInfo.CART_URL);
|
|
|
+ map = new HashMap<String, Object>(2);
|
|
|
map.put("product", product);
|
|
|
map.put("shareOpenid", member.getUserOpenid());
|
|
|
- remsg.setData(map);
|
|
|
- remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
+ return ResultMsg.SUCCESS().setData(map);
|
|
|
} catch (Exception e) {
|
|
|
- remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- remsg.setStatus(false);
|
|
|
+ return ResultMsg.ERROR().setData(e.getMessage());
|
|
|
}
|
|
|
- return remsg;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -266,37 +222,20 @@ public class ProductInfoHandler {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/getPictureByProductId")
|
|
|
- public ResultMsg getPictureByProductId(HttpServletRequest request,HttpServletResponse response,
|
|
|
- @RequestParam(value = "productId",defaultValue = "") String productId) throws Exception {
|
|
|
- ResultMsg remsg = new ResultMsg();
|
|
|
- if (productId == null) {
|
|
|
- remsg.setStatus(false);
|
|
|
- remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
- return remsg;
|
|
|
- }
|
|
|
+ public ResultMsg getPictureByProductId(@RequestParam(value = "productId") String productId) throws Exception {
|
|
|
if (StaticInfo.pattern.matcher(productId).find()) {
|
|
|
ProductImageText productImageText = productImageTextService.getProductImageTextByProduectId(Integer.parseInt(productId));
|
|
|
- remsg.setData(productImageText);
|
|
|
- remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
- remsg.setStatus(true);
|
|
|
- return remsg;
|
|
|
+ return ResultMsg.SUCCESS().setData(productImageText);
|
|
|
}
|
|
|
try {
|
|
|
String productIdString = StaticInfo.md5.decrypt(productId);
|
|
|
ProductImageText productImageText = productImageTextService.getProductImageTextByProduectId(Integer.parseInt(productId));
|
|
|
List<ProductPicture> pictureList = productPictureService.getProductPictureByproductId(Integer.parseInt(productIdString));
|
|
|
productImageText.setPictureList(pictureList);
|
|
|
- remsg.setData(productImageText);
|
|
|
- remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
+ return ResultMsg.SUCCESS().setData(productImageText);
|
|
|
} catch (Exception e) {
|
|
|
- remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- remsg.setStatus(false);
|
|
|
+ return ResultMsg.ERROR().setData(e.getMessage());
|
|
|
}
|
|
|
- return remsg;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -309,65 +248,52 @@ public class ProductInfoHandler {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/getProductByProductName")
|
|
|
- public ResultMsg getProductByProductName(HttpServletRequest request,HttpServletResponse response,
|
|
|
- @RequestParam(value = "productName", defaultValue = "")String productName) throws Exception {
|
|
|
-
|
|
|
- List<Product> productList = new ArrayList<Product>();
|
|
|
- ResultMsg remsg=new ResultMsg();
|
|
|
+ public ResultMsg getProductByProductName(
|
|
|
+ HttpServletRequest request,
|
|
|
+ HttpServletResponse response,
|
|
|
+ @RequestParam(value = "productName", required = false) String productName) throws Exception {
|
|
|
+ // 获取登陆的用户
|
|
|
Member member = WechatUtils.getUserBySession(request);
|
|
|
-
|
|
|
+ // 查询
|
|
|
+ List<Product> productList = productInfoService.getProductByProductName(productName);
|
|
|
+ if (productList == null || productList.isEmpty()) {
|
|
|
+ return ResultMsg.SUCCESS().setData(productList);
|
|
|
+ }
|
|
|
/*
|
|
|
- * 判断用户信息及其参数
|
|
|
+ * 优惠价计算
|
|
|
*/
|
|
|
- if (member == null || member.getUserOpenid() == null) {
|
|
|
- remsg.setMessage(ResultInfo.loginOutError);
|
|
|
- remsg.setStatus(false);
|
|
|
- remsg.setMessage(ResultInfo.loginOutError);
|
|
|
- return remsg;
|
|
|
- }
|
|
|
-
|
|
|
- if (null != productName && !"".equals(productName)) {
|
|
|
- productName = "%" + productName + "%";
|
|
|
- }
|
|
|
- productList = this.productInfoService.getProductByProductName(productName);
|
|
|
-
|
|
|
- if (productList != null && productList.size() >= 1) {
|
|
|
- /*
|
|
|
- * 优惠价计算
|
|
|
- */
|
|
|
- boolean isPrice = false;
|
|
|
- if (member.getUserIdentity() != null && member.getUserIdentity() == 2) { // 微代理:优惠价
|
|
|
+ boolean isPrice = false;
|
|
|
+ if (member.getUserIdentity() != null && member.getUserIdentity() == 2) {
|
|
|
+ // 微代理:优惠价
|
|
|
+ isPrice = true;
|
|
|
+ } else {
|
|
|
+ if (member.getUserResType() != null && (member.getUserResType() == 2 || member.getUserResType() == 3)) {
|
|
|
+ // 来源他人二维码:优惠价
|
|
|
isPrice = true;
|
|
|
} else {
|
|
|
- if (member.getUserResType() != null && (member.getUserResType() == 2 || member.getUserResType() == 3)) { // 来源他人二维码:优惠价
|
|
|
+ Member tempMember = memberService.selectUserResAndIdSByOpenId(member.getUserOpenid());
|
|
|
+ member.setUserIdentity(tempMember.getUserIdentity());
|
|
|
+ member.setUserResType(tempMember.getUserResType());
|
|
|
+ if (tempMember.getUserIdentity() == 2) {
|
|
|
+ // 微代理:优惠价
|
|
|
isPrice = true;
|
|
|
} else {
|
|
|
- Member tempMember = memberService.selectUserResAndIdSByOpenId(member.getUserOpenid());
|
|
|
- member.setUserIdentity(tempMember.getUserIdentity());
|
|
|
- member.setUserResType(tempMember.getUserResType());
|
|
|
- if (tempMember.getUserIdentity() == 2) {// 微代理:优惠价
|
|
|
+ if (tempMember.getUserResType() == 2 || tempMember.getUserResType() == 3) {
|
|
|
+ // 来源他人二维码:优惠价
|
|
|
isPrice = true;
|
|
|
- } else {
|
|
|
- if (tempMember.getUserResType() == 2 || tempMember.getUserResType() == 3) { // 来源他人二维码:优惠价
|
|
|
- isPrice = true;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (isPrice) {
|
|
|
- int price = systemService.selectOneShopRuleById(22).getRuleNum().intValue();
|
|
|
- for (Product product2 : productList) {
|
|
|
- product2.setProductPrice(product2.getProductDiscount());
|
|
|
- product2.setProductDiscount(price);
|
|
|
- }
|
|
|
+ }
|
|
|
+ if (isPrice) {
|
|
|
+ int price = systemService.selectOneShopRuleById(22).getRuleNum().intValue();
|
|
|
+ for (Product product2 : productList) {
|
|
|
+ product2.setProductPrice(product2.getProductDiscount());
|
|
|
+ product2.setProductDiscount(price);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
- remsg.setStatus(true);
|
|
|
- remsg.setData(productList);
|
|
|
- return remsg;
|
|
|
+ return ResultMsg.SUCCESS().setData(productList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -379,32 +305,16 @@ public class ProductInfoHandler {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/shareProductUrl", method = RequestMethod.POST)
|
|
|
public ResultMsg shareProductUrl(
|
|
|
- @RequestParam(value = "productId", required = false) Integer productId,
|
|
|
+ @RequestParam(value = "productId") Integer productId,
|
|
|
HttpServletRequest request
|
|
|
) throws Exception {
|
|
|
- ResultMsg msg = new ResultMsg();
|
|
|
- msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
-
|
|
|
Member member = WechatUtils.getUserBySession(request);
|
|
|
- if (member == null || member.getUserOpenid() == null) {
|
|
|
- msg.setMessage(ResultInfo.loginOutError);
|
|
|
- return msg;
|
|
|
- }
|
|
|
- if (productId == null) {
|
|
|
- msg.setMessage(ResultInfo.paramFormatError);
|
|
|
- return msg;
|
|
|
- }
|
|
|
-
|
|
|
- StringBuffer buffer = new StringBuffer(NameUtils.getConfig("WECHAT_PRODUCT_SHARE_URL"));
|
|
|
- buffer.append("?shareUser=" + StaticInfo.md5.encrypt(member.getUserOpenid()));
|
|
|
- buffer.append("&productId=" + StaticInfo.md5.encrypt(productId.toString()));
|
|
|
- buffer.append("&isShare=true&isProduct=true&isEnable=true"); // 是否分享,是否为产品,是否启动
|
|
|
-
|
|
|
- msg.setData(buffer.toString());
|
|
|
- msg.setStatus(true);
|
|
|
- msg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
- msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
- return msg;
|
|
|
+ // 是否分享,是否为产品,是否启动
|
|
|
+ String buffer = NameUtils.getConfig("WECHAT_PRODUCT_SHARE_URL") +
|
|
|
+ "?shareUser=" + StaticInfo.md5.encrypt(member.getUserOpenid()) +
|
|
|
+ "&productId=" + StaticInfo.md5.encrypt(productId.toString()) +
|
|
|
+ "&isShare=true&isProduct=true&isEnable=true";
|
|
|
+ return ResultMsg.SUCCESS().setData(buffer);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -415,15 +325,10 @@ public class ProductInfoHandler {
|
|
|
* @throws ServletException
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
@RequestMapping(value = "/desc", method = RequestMethod.GET)
|
|
|
- public void productDesc(
|
|
|
- @RequestParam("productId") Integer productId,
|
|
|
+ public void productDesc(@RequestParam("productId") Integer productId,
|
|
|
HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
- // 校验数据
|
|
|
- if (productId == null || "".equals(productId)) {
|
|
|
- request.getRequestDispatcher(NameUtils.getConfig("WECHAT_SHOP_PRODUCT_LIST_PAGE")).forward(request, response);return;
|
|
|
- }
|
|
|
-
|
|
|
//如果是分享 则绑定关系
|
|
|
Member member = WechatUtils.getUserBySession(request);
|
|
|
String shareOpenid = request.getParameter("shareOpenid");
|
|
@@ -431,8 +336,6 @@ public class ProductInfoHandler {
|
|
|
memberService.buildChildUser(shareOpenid, member,1,1);
|
|
|
}
|
|
|
request.getRequestDispatcher(NameUtils.getConfig("WECHAT_SHOP_PRODUCT_DESC_PAGE")).forward(request, response);
|
|
|
- //response.sendRedirect(NameUtils.getConfig("WECHAT_SHOP_PRODUCT_DESC_PAGE"));
|
|
|
- return;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -442,6 +345,7 @@ public class ProductInfoHandler {
|
|
|
* @param request
|
|
|
* @param response
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
@RequestMapping(value = "/toLeasepProductDetails", method = RequestMethod.GET)
|
|
|
public void toLeasepProductDetails(
|
|
|
@RequestParam("productId") Integer productId,
|
|
@@ -455,6 +359,7 @@ public class ProductInfoHandler {
|
|
|
/**
|
|
|
* 获取租赁产品详情
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
@RequestMapping(value = "/leasepProductDetails", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public ResultMsg leasepProductDetails(@RequestParam("productId") Integer productId,
|