Commit b401feb3 by yu.sun

sunyu::merge branch about feature-getCartInfoByUser

parents 7eb16d87 07b2c1ab
...@@ -24,6 +24,8 @@ public class CartParamDto { ...@@ -24,6 +24,8 @@ public class CartParamDto {
private String sessionId; private String sessionId;
private String couponCode;
private String userId; private String userId;
private String storeId; private String storeId;
...@@ -34,8 +36,6 @@ public class CartParamDto { ...@@ -34,8 +36,6 @@ public class CartParamDto {
private String cartGoodsUid; private String cartGoodsUid;
private String couponCode;
private Integer qty; private Integer qty;
private MealClearOperationEnum operationType; private MealClearOperationEnum operationType;
......
...@@ -1036,4 +1036,8 @@ public interface ShoppingCartBaseService { ...@@ -1036,4 +1036,8 @@ public interface ShoppingCartBaseService {
} }
return null; return null;
} }
} }
...@@ -58,6 +58,14 @@ public class MCoffeeShoppingCartController { ...@@ -58,6 +58,14 @@ public class MCoffeeShoppingCartController {
return shoppingCartMCoffeeService.updateGoodsQty(request); return shoppingCartMCoffeeService.updateGoodsQty(request);
} }
@ApiAnnotation(logMessage = "getCartInfoByUser")
@PostMapping(value = "/getCartInfoByUser")
public BaseResponse getCartInfoByUser(@Validated @LogParams @RequestBody QueryCartInfoRequestVo requestVo){
return shoppingCartMCoffeeService.getCartInfoByUser(requestVo);
}
/** /**
* 修改或者新增购物车中商品 * 修改或者新增购物车中商品
*/ */
...@@ -76,13 +84,6 @@ public class MCoffeeShoppingCartController { ...@@ -76,13 +84,6 @@ public class MCoffeeShoppingCartController {
return shoppingCartMCoffeeService.getGoodsList(request); return shoppingCartMCoffeeService.getGoodsList(request);
} }
@ApiAnnotation(logMessage = "getCartInfoByUser")
@PostMapping(value = "/getCartInfoByUser")
public BaseResponse getCartInfoByUser(@Validated @LogParams @RequestBody QueryCartInfoRequestVo requestVo){
return shoppingCartMCoffeeService.getCartInfoByUser(requestVo);
}
/** /**
* 查询购物车可使用优惠券 * 查询购物车可使用优惠券
*/ */
......
...@@ -130,26 +130,6 @@ public class AssortmentSdkService { ...@@ -130,26 +130,6 @@ public class AssortmentSdkService {
/**
* 调用聚合sdk设置缓存中购物车信息
*
* @param partnerId
* @param storeId
* @param useId
* @return
*/
public List<CartGoods> setShoppingCart(String partnerId, String storeId, String useId, List<CartGoods> cartGoodsList, String sessionId, String tableNumber, ShoppingCartBaseService shoppingCartService) {
com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = getCartParamDto(partnerId, storeId, useId);
cartParamDto.setSessionId(sessionId);
cartParamDto.setTableNumber(tableNumber);
cartParamDto.setCartGoodsList(JSONArray.parseArray(JSONObject.toJSONString(cartGoodsList), com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.class));
BaseResponse<List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods>> baseResponse = shoppingCartService.setCartGoodsList(cartParamDto, LogThreadLocal.getTrackingNo());
if (baseResponse == null || !ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode())) {
return null;
}
return JSONArray.parseArray(JSONObject.toJSONString(baseResponse.getResult()), CartGoods.class);
}
/** /**
* 调用聚合sdk获取缓存中购物车代金券信息 * 调用聚合sdk获取缓存中购物车代金券信息
...@@ -192,38 +172,28 @@ public class AssortmentSdkService { ...@@ -192,38 +172,28 @@ public class AssortmentSdkService {
return JSONArray.parseArray(JSONObject.toJSONString(baseResponse.getResult()), CartGoods.class); return JSONArray.parseArray(JSONObject.toJSONString(baseResponse.getResult()), CartGoods.class);
} }
/** /**
* 调用SDK校验购物车 * 调用聚合sdk设置缓存中购物车信息
* *
* @param oldAllCartGoodsList
* @param partnerId * @param partnerId
* @param storeId * @param storeId
* @param shoppingCartGoodsResponseVo * @param useId
* @param orderType * @return
*/ */
public CheckCartRequest checkShoppingCartSdk(List<CartGoods> oldAllCartGoodsList, String partnerId, String storeId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo public List<CartGoods> setShoppingCart(String partnerId, String storeId, String useId, List<CartGoods> cartGoodsList, String sessionId, String tableNumber, ShoppingCartBaseService shoppingCartService) {
, Integer orderType, String tableNumber, String menuType ,ShoppingCartBaseService shoppingCartService) { com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = getCartParamDto(partnerId, storeId, useId);
CheckCartRequest checkCartRequest = new CheckCartRequest(); cartParamDto.setSessionId(sessionId);
checkCartRequest.setCartGoodsList(JSONArray.parseArray(JSONObject.toJSONString(oldAllCartGoodsList), com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.class)); cartParamDto.setTableNumber(tableNumber);
checkCartRequest.setOrderWay(orderType); cartParamDto.setCartGoodsList(JSONArray.parseArray(JSONObject.toJSONString(cartGoodsList), com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.class));
checkCartRequest.setPartnerId(partnerId); BaseResponse<List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods>> baseResponse = shoppingCartService.setCartGoodsList(cartParamDto, LogThreadLocal.getTrackingNo());
checkCartRequest.setShoppingCartGoodsResponseVo(JSONObject.parseObject(JSONObject.toJSONString(shoppingCartGoodsResponseVo), com.freemud.sdk.api.assortment.shoppingcart.domain.ShoppingCartGoodsResponseVo.class)); if (baseResponse == null || !ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode())) {
checkCartRequest.setStoreId(storeId);
checkCartRequest.setTableNumber(tableNumber);
checkCartRequest.setTrackingNo(LogThreadLocal.getTrackingNo());
checkCartRequest.setMenuType(BusinessTypeEnum.getByType(menuType).getCode());
BaseResponse<CheckCartRequest> baseResponse ;
baseResponse= shoppingCartService.checkAllCartGoodsNew(checkCartRequest);
if (baseResponse == null) {
return null; return null;
} }
return baseResponse.getResult(); return JSONArray.parseArray(JSONObject.toJSONString(baseResponse.getResult()), CartGoods.class);
} }
/** /**
* 【麦咖啡】调用SDK校验购物车 * 调用SDK校验购物车
* *
* @param oldAllCartGoodsList * @param oldAllCartGoodsList
* @param partnerId * @param partnerId
...@@ -231,7 +201,7 @@ public class AssortmentSdkService { ...@@ -231,7 +201,7 @@ public class AssortmentSdkService {
* @param shoppingCartGoodsResponseVo * @param shoppingCartGoodsResponseVo
* @param orderType * @param orderType
*/ */
public CheckCartRequest checkShoppingCartSdkForMCoffee(List<CartGoods> oldAllCartGoodsList, String partnerId, String storeId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo public CheckCartRequest checkShoppingCartSdk(List<CartGoods> oldAllCartGoodsList, String partnerId, String storeId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo
, Integer orderType, String tableNumber, String menuType ,ShoppingCartBaseService shoppingCartService) { , Integer orderType, String tableNumber, String menuType ,ShoppingCartBaseService shoppingCartService) {
CheckCartRequest checkCartRequest = new CheckCartRequest(); CheckCartRequest checkCartRequest = new CheckCartRequest();
checkCartRequest.setCartGoodsList(JSONArray.parseArray(JSONObject.toJSONString(oldAllCartGoodsList), com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.class)); checkCartRequest.setCartGoodsList(JSONArray.parseArray(JSONObject.toJSONString(oldAllCartGoodsList), com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.class));
......
...@@ -438,12 +438,14 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -438,12 +438,14 @@ public class ShoppingCartMCoffeeServiceImpl {
calculationService.updateShoppingCartGoodsDiscount(requestVo.getPartnerId(), requestVo.getStoreId(), requestVo.getUserId(), requestVo.getAppId(), requestVo.getOrderType(), assortmentCustomerInfoVo.isMemberPaid(), requestVo.getMenuType(), requestVo.getReceiveId(), null, calculationService.updateShoppingCartGoodsDiscount(requestVo.getPartnerId(), requestVo.getStoreId(), requestVo.getUserId(), requestVo.getAppId(), requestVo.getOrderType(), assortmentCustomerInfoVo.isMemberPaid(), requestVo.getMenuType(), requestVo.getReceiveId(), null,
cartGoodsList, coupons, new ArrayList<>(), shoppingCartGoodsResponseVo, null); cartGoodsList, coupons, new ArrayList<>(), shoppingCartGoodsResponseVo, null);
String moneyCoupon = assortmentSdkService.getShoppingCartCoupon(requestVo.getPartnerId(), requestVo.getStoreId(), requestVo.getUserId(), shoppingCartBaseService, SaveCouponType.COUPON.getCode()); String moneyCoupon = assortmentSdkService.getShoppingCartCoupon(requestVo.getPartnerId(), requestVo.getStoreId(), requestVo.getUserId(), shoppingCartBaseService, SaveCouponType.COUPON.getCode());
List<CouponAvailableReq> resList = couponDiscountCalculation.buildAvailableCoupons(requestVo,cartGoodsList,moneyCoupon); String deliveryFeeCoupon = assortmentSdkService.getShoppingCartCoupon(requestVo.getPartnerId(),requestVo.getStoreId(),requestVo.getUserId(),shoppingCartBaseService,SaveCouponType.FREIGHT_COUPON.getCode());
List<String> couponCodes = new ArrayList<>();
couponCodes.add(deliveryFeeCoupon);
couponCodes.add(moneyCoupon);
List<CouponAvailableReq> resList = couponDiscountCalculation.buildAvailableCoupons(requestVo,cartGoodsList,couponCodes);
return ResponseUtil.success(resList); return ResponseUtil.success(resList);
} }
/** /**
* 查询购物车可用券 * 查询购物车可用券
*/ */
......
...@@ -339,15 +339,17 @@ public class CouponDiscountCalculation { ...@@ -339,15 +339,17 @@ public class CouponDiscountCalculation {
} }
public List<CouponAvailableReq> buildAvailableCoupons(QueryCartInfoRequestVo requestVo,List<CartGoods> cartGoods,String moneyCoupon){ public List<CouponAvailableReq> buildAvailableCoupons(QueryCartInfoRequestVo requestVo,List<CartGoods> cartGoods,
List<String> couponCodes){
List<CouponAvailableReq> resList = new ArrayList<>(); List<CouponAvailableReq> resList = new ArrayList<>();
CouponAvailableReq res = new CouponAvailableReq(); CouponAvailableReq res = new CouponAvailableReq();
res.setProviderId(requestVo.getPartnerId()); res.setProviderId(requestVo.getPartnerId());
res.setMerchantId(requestVo.getPartnerId()); res.setMerchantId(requestVo.getPartnerId());
res.setStoreId(requestVo.getStoreId()); res.setStoreId(requestVo.getStoreId());
res.setChannelIdList(commonService.getOrgCodes(requestVo.getPartnerId(), requestVo.getStoreId())); res.setChannelIdList(commonService.getOrgCodes(requestVo.getPartnerId(), requestVo.getStoreId()));
res.setCouponCodes(couponCodes);
List<CouponProductVo> productList = new ArrayList<>(); List<CouponProductVo> productList = new ArrayList<>();
res.setCouponCodes(StringUtils.isNotEmpty(moneyCoupon) ? Arrays.asList(moneyCoupon) :null); res.setCouponCodes(couponCodes);
if (CollectionUtils.isNotEmpty(cartGoods)) { if (CollectionUtils.isNotEmpty(cartGoods)) {
cartGoods.forEach(cartGood -> { cartGoods.forEach(cartGood -> {
if (StringUtils.isNotEmpty(cartGood.getCouponCode())) { if (StringUtils.isNotEmpty(cartGood.getCouponCode())) {
...@@ -361,28 +363,28 @@ public class CouponDiscountCalculation { ...@@ -361,28 +363,28 @@ public class CouponDiscountCalculation {
productList.add(couponProductVo); productList.add(couponProductVo);
} }
if (CollectionUtils.isNotEmpty(cartGood.getProductComboList())) { // if (CollectionUtils.isNotEmpty(cartGood.getProductComboList())) {
cartGood.getProductComboList().forEach(comboxGoods -> { // cartGood.getProductComboList().forEach(comboxGoods -> {
CouponProductVo couponProductVo = new CouponProductVo(); // CouponProductVo couponProductVo = new CouponProductVo();
couponProductVo.setAmount(Integer.valueOf(comboxGoods.getAmount().toString())); // couponProductVo.setAmount(Integer.valueOf(comboxGoods.getAmount().toString()));
couponProductVo.setKeyProductCode(comboxGoods.getCustomerCode()); // couponProductVo.setKeyProductCode(comboxGoods.getCustomerCode());
couponProductVo.setQuantity(comboxGoods.getQty()); // couponProductVo.setQuantity(comboxGoods.getQty());
couponProductVo.setProductId(comboxGoods.getGoodsId()); // couponProductVo.setProductId(comboxGoods.getGoodsId());
couponProductVo.setCategoryCode(null); // couponProductVo.setCategoryCode(null);
productList.add(couponProductVo); // productList.add(couponProductVo);
}); // });
} // }
if (CollectionUtils.isNotEmpty(cartGood.getProductGroupList())) { // if (CollectionUtils.isNotEmpty(cartGood.getProductGroupList())) {
cartGood.getProductGroupList().forEach(comboxGoods -> { // cartGood.getProductGroupList().forEach(comboxGoods -> {
CouponProductVo couponProductVo = new CouponProductVo(); // CouponProductVo couponProductVo = new CouponProductVo();
couponProductVo.setAmount(Integer.valueOf(comboxGoods.getAmount().toString())); // couponProductVo.setAmount(Integer.valueOf(comboxGoods.getAmount().toString()));
couponProductVo.setKeyProductCode(comboxGoods.getCustomerCode()); // couponProductVo.setKeyProductCode(comboxGoods.getCustomerCode());
couponProductVo.setQuantity(comboxGoods.getQty()); // couponProductVo.setQuantity(comboxGoods.getQty());
couponProductVo.setProductId(comboxGoods.getGoodsId()); // couponProductVo.setProductId(comboxGoods.getGoodsId());
couponProductVo.setCategoryCode(null); // couponProductVo.setCategoryCode(null);
productList.add(couponProductVo); // productList.add(couponProductVo);
}); // });
} // }
}); });
res.setProductList(productList); res.setProductList(productList);
Long totalAmount = createProductRequest(cartGoods, productList); Long totalAmount = createProductRequest(cartGoods, productList);
...@@ -393,7 +395,6 @@ public class CouponDiscountCalculation { ...@@ -393,7 +395,6 @@ public class CouponDiscountCalculation {
} }
// public String getAppSecret(String partnerId) { // public String getAppSecret(String partnerId) {
// // 获取券服务的密钥 // // 获取券服务的密钥
// String couponAppSecret = RedisUtil.getCouponAppSecret(partnerId); // String couponAppSecret = RedisUtil.getCouponAppSecret(partnerId);
......
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