|
@@ -230,6 +230,7 @@ public class CartHandlers {
|
|
|
@RequestMapping(value = "/addCart",method = RequestMethod.GET)
|
|
|
public ResultMsg addCart(HttpServletRequest request,
|
|
|
@RequestParam("productColorId") String productColorId,
|
|
|
+ @RequestParam(value = "cartIsSource", required = false, defaultValue = "1") Integer cartIsSource,
|
|
|
@RequestParam(value = "cartNum", required = false, defaultValue = "1") Integer cartNum) throws Exception {
|
|
|
String openId = wechatUtils.getUserBySession(request).getUserOpenid();
|
|
|
ResultMsg remsg=new ResultMsg();
|
|
@@ -244,6 +245,7 @@ public class CartHandlers {
|
|
|
}
|
|
|
CartDto cartDto = new CartDto();
|
|
|
cartDto.setCartOpenId(openId);
|
|
|
+ cartDto.setCartIsSource(cartIsSource);
|
|
|
cartDto.setCartColorId(cid);
|
|
|
Integer productNum = cartService.getCartNumByOpenId(cartDto);
|
|
|
cartDto.setCartNum(productNum + cartNum);
|
|
@@ -270,20 +272,23 @@ public class CartHandlers {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/deleteCart",method = RequestMethod.GET)
|
|
|
- public ResultMsg deleteCart(HttpServletRequest request,@RequestParam("productColorId") Integer productColorId,
|
|
|
+ public ResultMsg deleteCart(HttpServletRequest request,
|
|
|
+ @RequestParam("productColorId") Integer productColorId,
|
|
|
+ @RequestParam(value = "cartIsSource", required = false, defaultValue = "1") Integer cartIsSource,
|
|
|
@RequestParam(value = "cartNum", required = false, defaultValue = "1") Integer cartNum) throws Exception {
|
|
|
String openId = wechatUtils.getUserBySession(request).getUserOpenid();
|
|
|
ResultMsg remsg=new ResultMsg();
|
|
|
CartDto cartDto = new CartDto();
|
|
|
cartDto.setCartOpenId(openId);
|
|
|
cartDto.setCartColorId(productColorId);
|
|
|
+ cartDto.setCartIsSource(cartIsSource);
|
|
|
Integer productNum = cartService.getCartNumByOpenId(cartDto);
|
|
|
Integer num = 0;
|
|
|
if (productNum > 1) {
|
|
|
cartDto.setCartNum(productNum - cartNum);
|
|
|
num = cartService.updateCartByOpenId(cartDto);
|
|
|
} else {
|
|
|
- this.deleteCartByProductId(request,productColorId);
|
|
|
+ this.deleteCartByProductId(request,productColorId,cartIsSource);
|
|
|
}
|
|
|
if (num > 0) {
|
|
|
remsg.setMessage(ResultInfo.SUCCESSINFO);
|
|
@@ -304,11 +309,15 @@ public class CartHandlers {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/deleteCartByProductId",method = RequestMethod.GET)
|
|
|
- public ResultMsg deleteCartByProductId(HttpServletRequest request,@RequestParam("productColorId") Integer productColorId) throws Exception{
|
|
|
+ public ResultMsg deleteCartByProductId(HttpServletRequest request,
|
|
|
+ @RequestParam("productColorId") Integer productColorId,
|
|
|
+ @RequestParam(value = "cartIsSource", required = false, defaultValue = "1") Integer cartIsSource
|
|
|
+ ) throws Exception{
|
|
|
String openId = wechatUtils.getUserBySession(request).getUserOpenid();
|
|
|
CartDto cartDto = new CartDto();
|
|
|
ResultMsg remsg=new ResultMsg();
|
|
|
cartDto.setCartOpenId(openId);
|
|
|
+ cartDto.setCartIsSource(cartIsSource);
|
|
|
cartDto.setCartColorId(productColorId);
|
|
|
if (cartService.deleteCartByCartId(cartDto) >= 1) {
|
|
|
remsg.setMessage(ResultInfo.SUCCESSINFO);
|