Commit b89d576c by 周晓航

新增 购物车和订单 共同方法的使用,作用:订单直接删除购物车缓存

Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent a13a61f4
......@@ -80,6 +80,7 @@ import com.freemud.application.sdk.api.constant.ResponseResultEnum;
import com.freemud.application.sdk.api.couponcenter.offline.service.OfflineCouponSdkService;
import com.freemud.application.sdk.api.log.ErrorLog;
import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.ordercenter.common.OrderAndShoppingCommonRedisKey;
import com.freemud.application.sdk.api.ordercenter.entities.PayItem;
import com.freemud.application.sdk.api.ordercenter.enums.*;
import com.freemud.application.sdk.api.ordercenter.request.*;
......@@ -570,10 +571,11 @@ public class OrderServiceImpl implements Orderservice {
newShoppingCartClearDto.setBizType(orderBean.getBizType());
shoppingCartClient.clearShoppingCart(newShoppingCartClearDto);
/*
/**
主要 根据 ShoppingCartNewServiceImpl 次要 ShoppingCartMallServiceImpl
这里不处理商城
根据sessionId 判断是否是 围餐 , 标准点餐
看看围餐 是不是也可以 直接处理
*/
AssortmentCustomerInfoVo userLoginInfoDto = customerInfoManager.getCustomerInfoByObject(sessionId);
if (Objects.nonNull(userLoginInfoDto)) {
......@@ -583,7 +585,7 @@ public class OrderServiceImpl implements Orderservice {
shoppingCartClient.clearShoppingCart(newShoppingCartClearDto);
}else {
// saas订单, 直接订单服务清空购物车
redisCache.delete(OrderAndShoppingCommonRedisKey.getShoppingCartGoodsKey(partnerId,storeId,userId, orderBean.getBizType()));
}
}
}
......
package com.freemud.application.sdk.api.ordercenter.common;
import com.freemud.application.sdk.api.ordercenter.enums.BizTypeEnum;
import java.util.Objects;
/**
* @author : xh.Z
* @email : fisherman0510@163.com
* @Date : 2021/8/2 下午8:06
* @description : 订单和 购物车 共同使用方法
*/
public abstract class OrderAndShoppingCommonRedisKey {
/**
* 用户购物车在redis的key前缀 爱马哥蛋糕预定
*/
private final static String SAAS_SHOPPINGCART_AIMAGE_KEY_PREFIX = "saas:user:info:advance:cart:goods:";
/**
* 用户购物车在redis的key前缀
*/
private final static String SAAS_SHOPPINGCART_KEY_PREFIX = "saas:user:info:cart:goods:";
/**
* 获取记录购物车信息的key
*
* @param partnerId
* @param storeId
* @param userId
* @return
*/
public static String getShoppingCartGoodsKey(String partnerId, String storeId, String userId,Integer bizType) {
if(Objects.equals(BizTypeEnum.ADVANCE_ORDER.getBizType(),bizType)){
return SAAS_SHOPPINGCART_AIMAGE_KEY_PREFIX + partnerId + "_" + storeId + "_" + userId;
}
return SAAS_SHOPPINGCART_KEY_PREFIX + partnerId + "_" + storeId + "_" + userId;
}
}
......@@ -13,6 +13,8 @@
package cn.freemud.constant;
import com.freemud.application.sdk.api.ordercenter.common.OrderAndShoppingCommonRedisKey;
public class RedisKeyConstant {
/**
* userInfoMap的redisKey前缀
......@@ -23,12 +25,16 @@ public class RedisKeyConstant {
*/
public final static String SAAS_VERIFICATION_CODE_KEY_PREFIX = "saas:userSmsCode:mobile_";
/**
* 用户购物车在redis的key前缀
* 用户购物车在redis的key前缀 弃用
* @see OrderAndShoppingCommonRedisKey
*/
@Deprecated
public final static String SAAS_SHOPPINGCART_KEY_PREFIX = "saas:user:info:cart:goods:";
/**
* 用户购物车在redis的key前缀 爱马哥蛋糕预定
* 用户购物车在redis的key前缀 爱马哥蛋糕预定 弃用
* @see OrderAndShoppingCommonRedisKey
*/
@Deprecated
public final static String SAAS_SHOPPINGCART_AIMAGE_KEY_PREFIX = "saas:user:info:advance:cart:goods:";
/**
* 用户购物车总价在redis的key前缀
......
......@@ -16,6 +16,7 @@ import cn.freemud.constant.RedisKeyConstant;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.service.ShoppingCartNewBaseService;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.ordercenter.common.OrderAndShoppingCommonRedisKey;
import com.freemud.application.sdk.api.ordercenter.enums.BizTypeEnum;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -46,7 +47,9 @@ public class ShoppingCartNewBaseServiceImpl implements ShoppingCartNewBaseServic
@Override
public void clear(String partnerId, String storeId, String userId,Integer bizType) {
redisTemplate.delete(this.getShoppingCartGoodsKey(partnerId, storeId, userId,bizType));
// fisherman 提供 订单 & 购物车 公共方法
// redisTemplate.delete(this.getShoppingCartGoodsKey(partnerId, storeId, userId,bizType));
redisTemplate.delete(OrderAndShoppingCommonRedisKey.getShoppingCartGoodsKey(partnerId,storeId,userId, bizType));
//redisTemplate.delete(this.getShoppingCartGoodsAmountKey(partnerId, storeId, userId));
}
......@@ -65,10 +68,7 @@ public class ShoppingCartNewBaseServiceImpl implements ShoppingCartNewBaseServic
* @return
*/
private String getShoppingCartGoodsKey(String partnerId, String storeId, String userId,Integer bizType) {
if(Objects.equals(BizTypeEnum.ADVANCE_ORDER.getBizType(),bizType)){
return RedisKeyConstant.SAAS_SHOPPINGCART_AIMAGE_KEY_PREFIX + partnerId + "_" + storeId + "_" + userId;
}
return RedisKeyConstant.SAAS_SHOPPINGCART_KEY_PREFIX + partnerId + "_" + storeId + "_" + userId;
return OrderAndShoppingCommonRedisKey.getShoppingCartGoodsKey(partnerId,storeId,userId, bizType);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment