增加查询购物车功能
This commit is contained in:
@@ -50,7 +50,9 @@ public class CartConsumer {
|
|||||||
throw new MsgException("商品数量错误");
|
throw new MsgException("商品数量错误");
|
||||||
}
|
}
|
||||||
cartService.createCart(jsonObject);
|
cartService.createCart(jsonObject);
|
||||||
}else if(jsonObject.getString("type").equals("createOrder")){
|
}else if (jsonObject.getString("type").equals("queryCart") ) {
|
||||||
|
cartService.queryCart(jsonObject);
|
||||||
|
} else if(jsonObject.getString("type").equals("createOrder")){
|
||||||
String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId));
|
String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId));
|
||||||
if (StringUtils.isEmpty(cartDetail)){
|
if (StringUtils.isEmpty(cartDetail)){
|
||||||
throw new MsgException("购物车为空无法下单");
|
throw new MsgException("购物车为空无法下单");
|
||||||
|
|||||||
@@ -701,4 +701,22 @@ public class CartService {
|
|||||||
e.getMessage();
|
e.getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void queryCart(JSONObject jsonObject) throws IOException {
|
||||||
|
String shopId = jsonObject.getString("shopId");
|
||||||
|
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||||
|
BigDecimal amount = BigDecimal.ZERO;
|
||||||
|
for (int i = 0; i < array.size(); i++) {
|
||||||
|
JSONObject object = array.getJSONObject(i);
|
||||||
|
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||||
|
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
|
}
|
||||||
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
|
jsonObject1.put("status", "success");
|
||||||
|
jsonObject1.put("msg", "成功");
|
||||||
|
jsonObject1.put("type", jsonObject.getString("type"));
|
||||||
|
jsonObject1.put("data", array);
|
||||||
|
jsonObject1.put("amount", amount);
|
||||||
|
AppWebSocketServer.AppSendInfo(jsonObject1, jsonObject.getString("tableId").concat("-").concat(shopId), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ public class IntegralService {
|
|||||||
log.error("该店铺未开启优惠券功能");
|
log.error("该店铺未开启优惠券功能");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TbParams params = tbShopUserMapper.selectParams();
|
TbParams params = tbShopUserMapper.selectParams();
|
||||||
TbUserCoupons userCoupons = new TbUserCoupons();
|
TbUserCoupons userCoupons = new TbUserCoupons();
|
||||||
userCoupons.setUserId(orderInfo.getUserId());
|
userCoupons.setUserId(orderInfo.getUserId());
|
||||||
|
|||||||
Reference in New Issue
Block a user