|
@@ -158,17 +158,17 @@ public class CartHandlers {
|
|
|
|
|
|
/**
|
|
|
* 首页添加商品到购物车
|
|
|
- * @param productId
|
|
|
* @param cartNum
|
|
|
* @param request
|
|
|
* @return ResultMsg
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/addProductToCart")
|
|
|
- public ResultMsg addProductToCart(@RequestParam("productId") String productId,
|
|
|
- @RequestParam("productColorId") String productColorId,
|
|
|
+ public ResultMsg addProductToCart(@RequestParam("productColorId") String productColorId,
|
|
|
+ @RequestParam(value = "cartIsSource", required = false, defaultValue = "1") Integer cartIsSource,
|
|
|
@RequestParam(value = "cartNum", required = false, defaultValue = "1") Integer cartNum,
|
|
|
HttpServletRequest request) throws Exception {
|
|
|
+
|
|
|
String openId = wechatUtils.getUserBySession(request).getUserOpenid();
|
|
|
CartDto cartDto = new CartDto();
|
|
|
ResultMsg remsg=new ResultMsg();
|
|
@@ -177,25 +177,13 @@ public class CartHandlers {
|
|
|
if (productColorId != null && !"".equals(productColorId) && !"null".equals(productColorId) && StaticInfo.pattern.matcher(productColorId).find()) {
|
|
|
cid = Integer.parseInt(productColorId);
|
|
|
} else {
|
|
|
- if (productColorId == null || "".equals(productColorId)) {
|
|
|
- remsg.setMessage(ResultInfo.ERRORINFO);
|
|
|
- remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- remsg.setStatus(false);
|
|
|
- return remsg;
|
|
|
- }
|
|
|
- try {
|
|
|
- String productIdString = StaticInfo.md5.decrypt(productColorId);
|
|
|
- cid = Integer.parseInt(productIdString);
|
|
|
- } catch (Exception e) {
|
|
|
- remsg.setMessage(ResultInfo.ERRORINFO);
|
|
|
- remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- remsg.setStatus(false);
|
|
|
- return remsg;
|
|
|
- }
|
|
|
+ remsg.setMessage(ResultInfo.ERRORINFO);
|
|
|
+ remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
+ remsg.setStatus(false);
|
|
|
return remsg;
|
|
|
}
|
|
|
-
|
|
|
cartDto.setCartOpenId(openId);
|
|
|
+ cartDto.setCartIsSource(cartIsSource); //商品来源 1:产品颜色表 2:配件表
|
|
|
cartDto.setCartColorId(cid);
|
|
|
//根据颜色id和商品id查询购物车中是否存在
|
|
|
CartDto cart = cartService.getCartByCartProductId(cartDto);
|