public class OrderVO {
private String orderId;
private MerchantOrdersVO merchantOrdersVO;
private List<ShopcartBO> toBeRemovedShopcatdList;
public List<ShopcartBO> getToBeRemovedShopcatdList() {
return toBeRemovedShopcatdList;
}
public void setToBeRemovedShopcatdList(List<ShopcartBO> toBeRemovedShopcatdList) {
this.toBeRemovedShopcatdList = toBeRemovedShopcatdList;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public MerchantOrdersVO getMerchantOrdersVO() {
return merchantOrdersVO;
}
public void setMerchantOrdersVO(MerchantOrdersVO merchantOrdersVO) {
this.merchantOrdersVO = merchantOrdersVO;
}
}
// 5. 构建自定义订单vo
OrderVO orderVO = new OrderVO();
orderVO.setOrderId(orderId);
orderVO.setMerchantOrdersVO(merchantOrdersVO);
orderVO.setToBeRemovedShopcatdList(toBeRemovedShopcatdList);
// 2. 创建订单以后,移除购物车中已结算(已提交)的商品
/**
* 1001
* 2002 -> 用户购买
* 3003 -> 用户购买
* 4004
*/
// 清理覆盖现有的redis汇总的购物数据
shopcartList.removeAll(orderVO.getToBeRemovedShopcatdList());
redisOperator.set(FOODIE_SHOPCART + ":" + submitOrderBO.getUserId(), JsonUtils.objectToJson(shopcartList));
// 整合redis之后,完善购物车中的已结算商品清除,并且同步到前端的cookie
CookieUtils.setCookie(request, response, FOODIE_SHOPCART, JsonUtils.objectToJson(shopcartList), true);