Commit b401feb3 by yu.sun

sunyu::merge branch about feature-getCartInfoByUser

parents 7eb16d87 07b2c1ab
......@@ -24,6 +24,8 @@ public class CartParamDto {
private String sessionId;
private String couponCode;
private String userId;
private String storeId;
......@@ -34,8 +36,6 @@ public class CartParamDto {
private String cartGoodsUid;
private String couponCode;
private Integer qty;
private MealClearOperationEnum operationType;
......
......@@ -58,6 +58,14 @@ public class MCoffeeShoppingCartController {
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 {
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 {
/**
* 调用聚合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获取缓存中购物车代金券信息
......@@ -192,38 +172,28 @@ public class AssortmentSdkService {
return JSONArray.parseArray(JSONObject.toJSONString(baseResponse.getResult()), CartGoods.class);
}
/**
* 调用SDK校验购物车
* 调用聚合sdk设置缓存中购物车信息
*
* @param oldAllCartGoodsList
* @param partnerId
* @param storeId
* @param shoppingCartGoodsResponseVo
* @param orderType
* @param useId
* @return
*/
public CheckCartRequest checkShoppingCartSdk(List<CartGoods> oldAllCartGoodsList, String partnerId, String storeId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo
, Integer orderType, String tableNumber, String menuType ,ShoppingCartBaseService shoppingCartService) {
CheckCartRequest checkCartRequest = new CheckCartRequest();
checkCartRequest.setCartGoodsList(JSONArray.parseArray(JSONObject.toJSONString(oldAllCartGoodsList), com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.class));
checkCartRequest.setOrderWay(orderType);
checkCartRequest.setPartnerId(partnerId);
checkCartRequest.setShoppingCartGoodsResponseVo(JSONObject.parseObject(JSONObject.toJSONString(shoppingCartGoodsResponseVo), com.freemud.sdk.api.assortment.shoppingcart.domain.ShoppingCartGoodsResponseVo.class));
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) {
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 baseResponse.getResult();
return JSONArray.parseArray(JSONObject.toJSONString(baseResponse.getResult()), CartGoods.class);
}
/**
* 【麦咖啡】调用SDK校验购物车
* 调用SDK校验购物车
*
* @param oldAllCartGoodsList
* @param partnerId
......@@ -231,7 +201,7 @@ public class AssortmentSdkService {
* @param shoppingCartGoodsResponseVo
* @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) {
CheckCartRequest checkCartRequest = new CheckCartRequest();
checkCartRequest.setCartGoodsList(JSONArray.parseArray(JSONObject.toJSONString(oldAllCartGoodsList), com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.class));
......
......@@ -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,
cartGoodsList, coupons, new ArrayList<>(), shoppingCartGoodsResponseVo, null);
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);
}
/**
* 查询购物车可用券
*/
......
......@@ -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<>();
CouponAvailableReq res = new CouponAvailableReq();
res.setProviderId(requestVo.getPartnerId());
res.setMerchantId(requestVo.getPartnerId());
res.setStoreId(requestVo.getStoreId());
res.setChannelIdList(commonService.getOrgCodes(requestVo.getPartnerId(), requestVo.getStoreId()));
res.setCouponCodes(couponCodes);
List<CouponProductVo> productList = new ArrayList<>();
res.setCouponCodes(StringUtils.isNotEmpty(moneyCoupon) ? Arrays.asList(moneyCoupon) :null);
res.setCouponCodes(couponCodes);
if (CollectionUtils.isNotEmpty(cartGoods)) {
cartGoods.forEach(cartGood -> {
if (StringUtils.isNotEmpty(cartGood.getCouponCode())) {
......@@ -361,28 +363,28 @@ public class CouponDiscountCalculation {
productList.add(couponProductVo);
}
if (CollectionUtils.isNotEmpty(cartGood.getProductComboList())) {
cartGood.getProductComboList().forEach(comboxGoods -> {
CouponProductVo couponProductVo = new CouponProductVo();
couponProductVo.setAmount(Integer.valueOf(comboxGoods.getAmount().toString()));
couponProductVo.setKeyProductCode(comboxGoods.getCustomerCode());
couponProductVo.setQuantity(comboxGoods.getQty());
couponProductVo.setProductId(comboxGoods.getGoodsId());
couponProductVo.setCategoryCode(null);
productList.add(couponProductVo);
});
}
if (CollectionUtils.isNotEmpty(cartGood.getProductGroupList())) {
cartGood.getProductGroupList().forEach(comboxGoods -> {
CouponProductVo couponProductVo = new CouponProductVo();
couponProductVo.setAmount(Integer.valueOf(comboxGoods.getAmount().toString()));
couponProductVo.setKeyProductCode(comboxGoods.getCustomerCode());
couponProductVo.setQuantity(comboxGoods.getQty());
couponProductVo.setProductId(comboxGoods.getGoodsId());
couponProductVo.setCategoryCode(null);
productList.add(couponProductVo);
});
}
// if (CollectionUtils.isNotEmpty(cartGood.getProductComboList())) {
// cartGood.getProductComboList().forEach(comboxGoods -> {
// CouponProductVo couponProductVo = new CouponProductVo();
// couponProductVo.setAmount(Integer.valueOf(comboxGoods.getAmount().toString()));
// couponProductVo.setKeyProductCode(comboxGoods.getCustomerCode());
// couponProductVo.setQuantity(comboxGoods.getQty());
// couponProductVo.setProductId(comboxGoods.getGoodsId());
// couponProductVo.setCategoryCode(null);
// productList.add(couponProductVo);
// });
// }
// if (CollectionUtils.isNotEmpty(cartGood.getProductGroupList())) {
// cartGood.getProductGroupList().forEach(comboxGoods -> {
// CouponProductVo couponProductVo = new CouponProductVo();
// couponProductVo.setAmount(Integer.valueOf(comboxGoods.getAmount().toString()));
// couponProductVo.setKeyProductCode(comboxGoods.getCustomerCode());
// couponProductVo.setQuantity(comboxGoods.getQty());
// couponProductVo.setProductId(comboxGoods.getGoodsId());
// couponProductVo.setCategoryCode(null);
// productList.add(couponProductVo);
// });
// }
});
res.setProductList(productList);
Long totalAmount = createProductRequest(cartGoods, productList);
......@@ -393,7 +395,6 @@ public class CouponDiscountCalculation {
}
// public String getAppSecret(String 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