|
@@ -11,6 +11,7 @@ import java.util.Map;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import com.iamberry.wechat.core.entity.product.Product;
|
|
|
+import com.iamberry.wechat.core.entity.product.ProductColor;
|
|
|
import com.iamberry.wechat.core.entity.product.QrcodeGift;
|
|
|
import com.iamberry.wechat.face.apparatus.ApparatusService;
|
|
|
import com.iamberry.wechat.face.order.CodeService;
|
|
@@ -151,14 +152,13 @@ public class CartHandlers {
|
|
|
|
|
|
/**
|
|
|
* 首页添加商品到购物车post
|
|
|
- * @param productId
|
|
|
* @param cartNum
|
|
|
* @param request
|
|
|
* @return ResultMsg
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/addProductToCart")
|
|
|
- public ResultMsg addProductToCart(@RequestParam("productId") String productId,
|
|
|
+ public ResultMsg addProductToCart(
|
|
|
@RequestParam("colorId") Integer colorId,
|
|
|
@RequestParam(value = "cartNum", required = false, defaultValue = "1") Integer cartNum,
|
|
|
HttpServletRequest request) throws Exception {
|
|
@@ -166,31 +166,19 @@ public class CartHandlers {
|
|
|
CartDto cartDto = new CartDto();
|
|
|
ResultMsg remsg=new ResultMsg();
|
|
|
|
|
|
- Integer pid = 0;
|
|
|
- if (productId != null && !"".equals(productId) && !"null".equals(productId) && StaticInfo.pattern.matcher(productId).find()) {
|
|
|
- pid = Integer.parseInt(productId);
|
|
|
- } else {
|
|
|
- if (productId == null || "".equals(productId)) {
|
|
|
- remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- remsg.setStatus(false);
|
|
|
- return remsg;
|
|
|
- }
|
|
|
- try {
|
|
|
- String productIdString = StaticInfo.md5.decrypt(productId);
|
|
|
- pid = Integer.parseInt(productIdString);
|
|
|
- } catch (Exception e) {
|
|
|
- remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
- remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
- remsg.setStatus(false);
|
|
|
- return remsg;
|
|
|
- }
|
|
|
+ if (colorId == null || "".equals(colorId) || "null".equals(colorId)) {
|
|
|
+ remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
+ remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
+ remsg.setStatus(false);
|
|
|
return remsg;
|
|
|
}
|
|
|
+ ProductColor productColor = new ProductColor();
|
|
|
+ productColor.setColorId(colorId);
|
|
|
+ productColor = productInfoService.getProductColor(productColor);
|
|
|
|
|
|
cartDto.setCartOpenId(openId);
|
|
|
- cartDto.setCartProductId(pid);
|
|
|
cartDto.setCartColorId(colorId);
|
|
|
+ cartDto.setCartProductId(productColor.getColorProductId());
|
|
|
//根据用户id和商品id查询购物车中是否存在
|
|
|
CartDto cart = cartService.getCartByCartProductId(cartDto);
|
|
|
if (null != cart) {
|
|
@@ -228,22 +216,33 @@ public class CartHandlers {
|
|
|
/**
|
|
|
* 点击加号按钮添加商品到购物车
|
|
|
* @param request
|
|
|
- * @param productId
|
|
|
* @param cartNum
|
|
|
* @return ResultMsg
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/addCart")
|
|
|
- public ResultMsg addCart(HttpServletRequest request,@RequestParam("productId") Integer productId,
|
|
|
+ public ResultMsg addCart(HttpServletRequest request,
|
|
|
@RequestParam("colorId") Integer colorId,
|
|
|
@RequestParam(value = "cartNum", required = false, defaultValue = "1") Integer cartNum) throws Exception {
|
|
|
- String openId = WechatUtils.getUserBySession(request).getUserOpenid();
|
|
|
+// String openId = WechatUtils.getUserBySession(request).getUserOpenid();
|
|
|
+ String openId = "oZ9pv02WMRQgyDVRY1a_daYecwHI";
|
|
|
ResultMsg remsg=new ResultMsg();
|
|
|
+
|
|
|
+ if (colorId == null || "".equals(colorId) || "null".equals(colorId)) {
|
|
|
+ remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
+ remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
+ remsg.setStatus(false);
|
|
|
+ return remsg;
|
|
|
+ }
|
|
|
+ ProductColor productColor = new ProductColor();
|
|
|
+ productColor.setColorId(colorId);
|
|
|
+ productColor = productInfoService.getProductColor(productColor);
|
|
|
+
|
|
|
CartDto cartDto = new CartDto();
|
|
|
cartDto.setCartOpenId(openId);
|
|
|
cartDto.setCartColorId(colorId);
|
|
|
- cartDto.setCartProductId(productId);
|
|
|
+ cartDto.setCartProductId(productColor.getColorProductId());
|
|
|
Integer productNum = cartService.getCartNumByOpenId(cartDto);
|
|
|
cartDto.setCartNum(productNum + cartNum);
|
|
|
Integer num = cartService.updateCartByOpenId(cartDto);
|
|
@@ -262,23 +261,31 @@ public class CartHandlers {
|
|
|
/**
|
|
|
* 点击减号按钮删除商品
|
|
|
* @param request
|
|
|
- * @param productId
|
|
|
* @param cartNum
|
|
|
* @return ResultMsg
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/deleteCart")
|
|
|
- public ResultMsg deleteCart(HttpServletRequest request,@RequestParam("productId") Integer productId,
|
|
|
+ public ResultMsg deleteCart(HttpServletRequest request,
|
|
|
@RequestParam("colorId") Integer colorId,
|
|
|
@RequestParam(value = "cartNum", required = false, defaultValue = "1") Integer cartNum) throws Exception {
|
|
|
String openId = WechatUtils.getUserBySession(request).getUserOpenid();
|
|
|
-
|
|
|
ResultMsg remsg=new ResultMsg();
|
|
|
+ if (colorId == null || "".equals(colorId) || "null".equals(colorId)) {
|
|
|
+ remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
+ remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
+ remsg.setStatus(false);
|
|
|
+ return remsg;
|
|
|
+ }
|
|
|
+ ProductColor productColor = new ProductColor();
|
|
|
+ productColor.setColorId(colorId);
|
|
|
+ productColor = productInfoService.getProductColor(productColor);
|
|
|
+
|
|
|
CartDto cartDto = new CartDto();
|
|
|
cartDto.setCartOpenId(openId);
|
|
|
cartDto.setCartColorId(colorId);
|
|
|
- cartDto.setCartProductId(productId);
|
|
|
+ cartDto.setCartProductId(productColor.getColorProductId());
|
|
|
Integer productNum = cartService.getCartNumByOpenId(cartDto);
|
|
|
Integer num = 0;
|
|
|
if (productNum != null && productNum > 1) {
|
|
@@ -305,14 +312,23 @@ public class CartHandlers {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/deleteCartByProductId")
|
|
|
public ResultMsg deleteCartByProductId(HttpServletRequest request,
|
|
|
- @RequestParam("productId") Integer productId,
|
|
|
@RequestParam("colorId") Integer colorId) throws Exception{
|
|
|
String openId = WechatUtils.getUserBySession(request).getUserOpenid();
|
|
|
- CartDto cartDto = new CartDto();
|
|
|
ResultMsg remsg=new ResultMsg();
|
|
|
+ if (colorId == null || "".equals(colorId) || "null".equals(colorId)) {
|
|
|
+ remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
+ remsg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
+ remsg.setStatus(false);
|
|
|
+ return remsg;
|
|
|
+ }
|
|
|
+ ProductColor productColor = new ProductColor();
|
|
|
+ productColor.setColorId(colorId);
|
|
|
+ productColor = productInfoService.getProductColor(productColor);
|
|
|
+
|
|
|
+ CartDto cartDto = new CartDto();
|
|
|
cartDto.setCartOpenId(openId);
|
|
|
cartDto.setCartColorId(colorId);
|
|
|
- cartDto.setCartProductId(productId);
|
|
|
+ cartDto.setCartProductId(productColor.getColorProductId());
|
|
|
if (cartService.deleteCartByCartId(cartDto) >= 1) {
|
|
|
remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
remsg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
@@ -534,13 +550,14 @@ public class CartHandlers {
|
|
|
//获取账户余额,判断是否在可用范围内
|
|
|
int balancePayAmount=shopSalesOrderDto.getBalancePayAmount();
|
|
|
int total = shopSalesOrderDto.getSalesYetAmount();
|
|
|
+
|
|
|
//判断余额支付金额是否大于用户余额
|
|
|
- if(balancePayAmount > 0 && member.getUserIncome() > balancePayAmount) {
|
|
|
+ /*if(balancePayAmount > 0 && member.getUserIncome() > balancePayAmount) {
|
|
|
total = total - balancePayAmount > 0 ? total - balancePayAmount : 0;
|
|
|
} else if(balancePayAmount > 0 && member.getUserIncome() < balancePayAmount) {
|
|
|
msg.setMessage(ResultInfo.NO_ENOUGH_FOR_PAY);
|
|
|
return msg;
|
|
|
- }
|
|
|
+ }*/
|
|
|
// 发起支付
|
|
|
PayResult result = payService.requestPay(openId, orderId, total, orderItemList.get(0).getItemProductName() + "...", NameUtils.getConfig("WECHAT_ORDER_BACK"));
|
|
|
if (result.isPaySuccess()) {
|