Commit f10bef64 by 孙昱

Merge branch 'feature-yu.sun-getCartInfoByUser-20200925'

parents 9b7f03a1 104e3a5f
...@@ -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;
......
...@@ -98,6 +98,17 @@ public interface ShoppingCartBaseService { ...@@ -98,6 +98,17 @@ public interface ShoppingCartBaseService {
*/ */
BaseResponse clear(CartParamDto cartParamDto, String trackingNo); BaseResponse clear(CartParamDto cartParamDto, String trackingNo);
/**
* 获取购物车商品代金券
*
* @param cartParamDto
* @return
*/
default BaseResponse<String> getCartCouponCode(CartParamDto cartParamDto, String trackingNo) {
return null;
}
/** /**
* 获取商品详细信息 * 获取商品详细信息
* *
...@@ -1008,4 +1019,8 @@ public interface ShoppingCartBaseService { ...@@ -1008,4 +1019,8 @@ public interface ShoppingCartBaseService {
} }
return null; return null;
} }
} }
...@@ -57,6 +57,14 @@ public class MCoffeeShoppingCartController { ...@@ -57,6 +57,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);
}
/** /**
* 查询购物车信息 * 查询购物车信息
*/ */
......
...@@ -19,6 +19,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest; ...@@ -19,6 +19,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest;
import com.freemud.sdk.api.assortment.shoppingcart.request.GetProductInfoRequest; import com.freemud.sdk.api.assortment.shoppingcart.request.GetProductInfoRequest;
import com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService; import com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -108,59 +109,67 @@ public class AssortmentSdkService { ...@@ -108,59 +109,67 @@ public class AssortmentSdkService {
} }
/** /**
* 调用聚合sdk设置缓存中购物车信息 * 调用聚合sdk获取缓存中购物车信息
* *
* @param partnerId * @param partnerId
* @param storeId * @param storeId
* @param useId * @param useId
* @return * @return
*/ */
public List<CartGoods> setShoppingCart(String partnerId, String storeId, String useId, List<CartGoods> cartGoodsList, String sessionId, String tableNumber, ShoppingCartBaseService shoppingCartService) { public List<CartGoods> getShoppingCartForCoupon(String partnerId, String storeId, String useId, String tableNumber, ShoppingCartBaseService shoppingCartService) {
com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = getCartParamDto(partnerId, storeId, useId); com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = getCartParamDto(partnerId, storeId, useId);
cartParamDto.setSessionId(sessionId);
cartParamDto.setTableNumber(tableNumber); 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()); BaseResponse<List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods>> baseResponse = shoppingCartService.getCartGoodsList(cartParamDto, LogThreadLocal.getTrackingNo());
if (baseResponse == null || !ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode())) { if (baseResponse == null || !ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode()) || CollectionUtils.isEmpty(baseResponse.getResult())) {
return null; return new ArrayList<>();
} }
return JSONArray.parseArray(JSONObject.toJSONString(baseResponse.getResult()), CartGoods.class); return JSONArray.parseArray(JSONObject.toJSONString(baseResponse.getResult()), CartGoods.class);
} }
/**
* 调用聚合sdk获取缓存中购物车代金券信息
*
* @param partnerId
* @param storeId
* @param useId
* @return
*/
public String getShoppingCartCoupon(String partnerId, String storeId, String useId, ShoppingCartBaseService shoppingCartService) {
com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = getCartParamDto(partnerId, storeId, useId);
BaseResponse<String> baseResponse = shoppingCartService.getCartCouponCode(cartParamDto, LogThreadLocal.getTrackingNo());
if (baseResponse == null || !ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode()) || StringUtils.isEmpty(baseResponse.getResult())) {
return "";
}
return baseResponse.getResult();
}
/** /**
* 调用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
...@@ -168,7 +177,7 @@ public class AssortmentSdkService { ...@@ -168,7 +177,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));
......
...@@ -23,6 +23,7 @@ import cn.freemud.service.impl.FullSubtractionActivityServiceImpl; ...@@ -23,6 +23,7 @@ import cn.freemud.service.impl.FullSubtractionActivityServiceImpl;
import cn.freemud.service.impl.mcoffee.calculation.CalculationServiceImpl; import cn.freemud.service.impl.mcoffee.calculation.CalculationServiceImpl;
import cn.freemud.service.impl.mcoffee.calculation.CouponDiscountCalculation; import cn.freemud.service.impl.mcoffee.calculation.CouponDiscountCalculation;
import cn.freemud.service.impl.mcoffee.entity.CopyShoppingCartRequestVo; import cn.freemud.service.impl.mcoffee.entity.CopyShoppingCartRequestVo;
import cn.freemud.service.impl.mcoffee.entity.CouponAvailableReq;
import cn.freemud.service.impl.mcoffee.entity.MCoffeeAddGoodsRequestVo; import cn.freemud.service.impl.mcoffee.entity.MCoffeeAddGoodsRequestVo;
import cn.freemud.service.impl.mcoffee.entity.SwitchShoppingCartRequestVo; import cn.freemud.service.impl.mcoffee.entity.SwitchShoppingCartRequestVo;
import cn.freemud.service.thirdparty.CustomerApplicationClient; import cn.freemud.service.thirdparty.CustomerApplicationClient;
...@@ -339,6 +340,28 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -339,6 +340,28 @@ public class ShoppingCartMCoffeeServiceImpl {
} }
/**
* 券码用-查询购物车最新信息,计算优惠
* @param requestVo
* @return
*/
public BaseResponse getCartInfoByUser(QueryCartInfoRequestVo requestVo){
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
// 获取用户信息
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(requestVo.getSessionId());
// 获取购物车商品
List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCartForCoupon(requestVo.getPartnerId(), requestVo.getStoreId(), requestVo.getUserId(), "", shoppingCartBaseService);
// 当couponCode不为空时,需参与价格计算
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = getCoupon(null, null, cartGoodsList);
// 促销活动的优惠金额计算
calculationService.updateShoppingCartGoodsDiscount(requestVo.getPartnerId(), requestVo.getStoreId(), requestVo.getUserId(), requestVo.getAppId(), requestVo.getOrderType(), assortmentCustomerInfoVo.isMemberPaid(), requestVo.getMenuType(), requestVo.getReceiveId(), null,
cartGoodsList, coupons, new ArrayList<>(), shoppingCartGoodsResponseVo);
String moneyCoupon = assortmentSdkService.getShoppingCartCoupon(requestVo.getPartnerId(), requestVo.getStoreId(), requestVo.getUserId(), shoppingCartBaseService);
List<CouponAvailableReq> resList = couponDiscountCalculation.buildAvailableCoupons(requestVo,cartGoodsList,moneyCoupon);
return ResponseUtil.success(resList);
}
// /** // /**
// * 券码用-查询购物车最新信息,计算优惠 // * 券码用-查询购物车最新信息,计算优惠
// * @param requestVo // * @param requestVo
......
...@@ -326,45 +326,50 @@ public class CouponDiscountCalculation { ...@@ -326,45 +326,50 @@ public class CouponDiscountCalculation {
} }
public List<CouponAvailableReq> buildAvailableCoupons(QueryCartInfoRequestVo requestVo,List<CartGoods> cartGoods){ public List<CouponAvailableReq> buildAvailableCoupons(QueryCartInfoRequestVo requestVo,List<CartGoods> cartGoods,String moneyCoupon){
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());
// List<String> couponList = new ArrayList<>();
res.setChannelIdList(commonService.getOrgCodes(requestVo.getPartnerId(), requestVo.getStoreId())); res.setChannelIdList(commonService.getOrgCodes(requestVo.getPartnerId(), requestVo.getStoreId()));
List<CouponProductVo> productList = new ArrayList<>(); List<CouponProductVo> productList = new ArrayList<>();
res.setCouponCodes(StringUtils.isNotEmpty(moneyCoupon) ? Arrays.asList(moneyCoupon) :null);
if (CollectionUtils.isNotEmpty(cartGoods)) { if (CollectionUtils.isNotEmpty(cartGoods)) {
cartGoods.forEach(cartGood -> { cartGoods.forEach(cartGood -> {
// if (StringUtils.isNotEmpty(cartGood.getCouponCode())) { if (StringUtils.isNotEmpty(cartGood.getCouponCode())) {
// couponList.add(cartGood.getCouponCode());
// res.setCouponCodes(couponList);
// }
if (CollectionUtils.isNotEmpty(cartGood.getProductComboList())) {
cartGood.getProductComboList().forEach(comboxGoods -> {
CouponProductVo couponProductVo = new CouponProductVo(); CouponProductVo couponProductVo = new CouponProductVo();
couponProductVo.setAmount(Integer.valueOf(comboxGoods.getAmount().toString())); couponProductVo.setAmount(cartGood.getAmount().intValue());
couponProductVo.setKeyProductCode(comboxGoods.getCustomerCode()); couponProductVo.setKeyProductCode(cartGood.getCustomerCode());
couponProductVo.setQuantity(comboxGoods.getQty()); couponProductVo.setQuantity(cartGood.getQty());
couponProductVo.setProductId(comboxGoods.getGoodsId()); couponProductVo.setProductId(cartGood.getGoodsId());
couponProductVo.setCouponCode(cartGood.getCouponCode()); couponProductVo.setCouponCode(cartGood.getCouponCode());
couponProductVo.setCategoryCode(null); couponProductVo.setCategoryCode(null);
productList.add(couponProductVo); 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.setCouponCode(cartGood.getCouponCode());
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); res.setProductList(productList);
Long totalAmount = createProductRequest(cartGoods, productList); Long totalAmount = createProductRequest(cartGoods, productList);
......
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