Commit 60fab572 by 徐康

Merge remote-tracking branch 'origin/develop' into develop

parents c0a18e81 db4dc6b9
......@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>assortment-shoppingcart-sdk</artifactId>
<version>1.1.8-SNAPSHOT</version>
<version>1.1.9-SNAPSHOT</version>
<dependencies>
<dependency>
......
......@@ -6,4 +6,4 @@
| 1.1.2-SNAPSHOT| 券码接口新增参数:channelCodeList | 梁崇福 | 2020-05-13 |
| 1.1.4-SNAPSHOT| 券码接口修改为channel_codes | 梁崇福 | 2020-06-08 |
| 1.1.5-SNAPSHOT| 增加统计分类编号:classificationId,classificationName | | 2020-06-12 |
| 1.1.8-SNAPSHOT| 加料 | 李小二 | 2020-07-30 |
\ No newline at end of file
| 1.1.9-SNAPSHOT| 加料 | 李小二 | 2020-07-30 |
\ No newline at end of file
......@@ -321,6 +321,8 @@ public class ShoppingCartAdapter {
cartGoods.setWeight(isSkuProduct ? skuProduct.getWeight() : spuProduct.getWeight());
cartGoods.setUnit(isSkuProduct ? skuProduct.getUnit() : spuProduct.getUnit());
cartGoods.setWeightType(CommonsConstant.WEIGHT_PRODUCT.equals(spuProduct.getWeightType()));
cartGoods.setMaterialAmount(0L);
cartGoods.setOriginalMaterialAmount(0L);
// todo 设置加料
this.checkMaterialProduct(cartGoods, spuProduct);
......@@ -337,6 +339,7 @@ public class ShoppingCartAdapter {
* @param spuProduct
*/
private void checkMaterialProduct(CartGoods cartGoods, ProductBeanDTO spuProduct) {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return;
//加料信息为空
if (CollectionUtils.isEmpty(spuProduct.getAdditionalGroupList())) return;
......@@ -359,7 +362,7 @@ public class ShoppingCartAdapter {
material.setSpuId(detail.getProductId());
//行单价 \ 行总价
material.setFinalPrice(detail.getProductFinalPrice().longValue());
material.setAmount(detail.getProductFinalPrice().longValue());
material.setAmount(detail.getProductFinalPrice().longValue() * cartGoods.getQty());
//原行单价*数量
material.setOriginalAmount(detail.getProductFinalPrice().longValue() * cartGoods.getQty());
material.setOriginalPrice(detail.getProductFinalPrice().longValue());
......@@ -376,7 +379,7 @@ public class ShoppingCartAdapter {
//加料行记录原价总价
cartGoods.setOriginalMaterialAmount(originalMaterAmount);
cartGoods.setOriginalAmount(cartGoods.getOriginalAmount() + originalMaterAmount);
cartGoods.setSubName(materialSubName);
cartGoods.setSubName(StringUtils.strip(materialSubName, "/"));
}
private boolean updateComboxGoodsInfo(CartGoods cartGoods, CartGoods.ComboxGoods comboxGoods, ProductBeanDTO parentProductBean, List<ProductBeanDTO> productBeans, CartGoodsStates cartGoodsStates, List<String> invalidGoodsIdList) {
......
......@@ -167,7 +167,7 @@ public class GetMenuResponseDto {
private int updateStatus;
private boolean valid;
private int version;
private List<ProductLabelNameListBean> labelNames;
private List<ProductLabelNameBean> labelNames;
private List<ProductAttributeGroupListBean> productAttributeGroupList;
private List<ProductPictureListBean> productPictureList;
private List<?> productSpecification;
......@@ -239,7 +239,7 @@ public class GetMenuResponseDto {
@NoArgsConstructor
@Data
public static class ProductLabelNameListBean {
public static class ProductLabelNameBean {
private String id;
private String name;
private String partnerId;
......
......@@ -45,7 +45,7 @@
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>assortment-shoppingcart-sdk</artifactId>
<version>1.1.8-SNAPSHOT</version>
<version>1.1.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......
......@@ -66,6 +66,15 @@ public class MCoffeeShoppingCartController {
}
/**
* 查询购物车可使用优惠券
*/
@ApiAnnotation(logMessage = "availableCoupon")
@PostMapping(value = "/availableCoupon")
public BaseResponse availableCoupon(@Validated @LogParams @RequestBody ShoppingCartInfoRequestVo request) {
return shoppingCartMCoffeeService.availableCoupon(request);
}
/**
* 清空购物车
*/
@ApiAnnotation(logMessage = "clearCartGoods")
......
......@@ -86,6 +86,10 @@ public class ActivityCalculationDiscountRequestDto {
/**
* 商品ID
*/
private String goodsCode;
/**
* 商品ID
*/
private String goodsId;
/**
* 购物车行uid
......@@ -122,6 +126,7 @@ public class ActivityCalculationDiscountRequestDto {
CalculationDiscountGoods that = (CalculationDiscountGoods) o;
return Objects.equals(goodsId, that.goodsId) &&
Objects.equals(category, that.category) &&
Objects.equals(cartGoodsUid, that.cartGoodsUid) &&
Objects.equals(originalPrice, that.originalPrice);
}
......
......@@ -80,4 +80,14 @@ public class AddShoppingCartGoodsRequestVo extends BaseRequestVo{
*/
private String receiveId;
/**
* 操作类型 1= 添加商品券 2=加价购
*/
private Integer operationType;
/**
* 优惠券号
*/
private String couponCode;
}
......@@ -314,7 +314,9 @@ public class CartGoods {
originalString.append(goods.toString());
}
}
if (CollectionUtils.isNotEmpty(productMaterialList)) {
productMaterialList.stream().sorted(Comparator.comparing(MaterialGoods::getSpuId)).forEach(e -> originalString.append(e.getSpuId()));
}
//当前字符串
CartGoods cartGoods = (CartGoods) o;
......@@ -333,6 +335,9 @@ public class CartGoods {
currentString.append(goods.toString());
}
}
if (CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
cartGoods.getProductMaterialList().stream().sorted(Comparator.comparing(MaterialGoods::getSpuId)).forEach(e -> currentString.append(e.getSpuId()));
}
return StringUtils.equals(originalString.toString(), currentString.toString());
}
......
......@@ -59,10 +59,6 @@ public class BuySendPromotionService implements IPromotionService {
if (CollectionUtils.isEmpty(sendActivityList)) {
return;
}
//ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity sendActivity = getSendActivity(sendActivityList, ActivityTypeEnum.TYPE_61);
//if (sendActivity == null) {
// return;
//}
//Todo 获取多个赠品list
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity> sendActivityLists = getSendActivityList(ActivityTypeEnum.TYPE_61, sendActivityList);
......@@ -70,14 +66,6 @@ public class BuySendPromotionService implements IPromotionService {
if (sendActivityLists.size() == 0) {
return;
}
//List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods> sendGoodsList = sendActivity.getSendGoods();
//if (CollectionUtils.isEmpty(sendGoodsList)) {
// return;
//}
//Integer maxNum = sendActivity.getMaxNum();
//List<String> activitySpuIds = sendGoodsList.stream().map(each -> each.getCategory()).collect(Collectors.toList());
//Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods> sendGoodsMap = getSendGoodsMap(sendGoodsList);
//Todo
List<String> activitySpuIds = new ArrayList<>();
Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods> sendGoodsMap = new HashMap<>();
......@@ -130,11 +118,6 @@ public class BuySendPromotionService implements IPromotionService {
}
*/
for (CartGoods cartGoods : newCartGoodsList) {
//Integer max = maxNums.get(cartGoods.getGoodsId());
////if (max <= 0) continue;
//if (max < cartGoods.getQty()) {
// cartGoods.setQty(max);
//}
givePackAmount = givePackAmount + cartGoods.getPackPrice() * cartGoods.getQty();
giveTotalAmount = giveTotalAmount + cartGoods.getOriginalPrice() * cartGoods.getQty();
cartGoods.setOriginalAmount(cartGoods.getOriginalPrice() * cartGoods.getQty());
......@@ -265,13 +248,15 @@ public class BuySendPromotionService implements IPromotionService {
}
}
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity.SendGoods sendGoods = sendGoodsMap.get(cartGood.getGoodsId());
CartGoods cartGoods = shoppingCartConvertAdapter.convent2CartGoods(cartGood, sendGoods.getNowPrice());
cartGoods.setClassificationId(cartGood.getClassificationId());
cartGoods.setClassificationName(cartGood.getClassificationName());
cartGoods.setQty(sendGoods.getSendNumber() > 0 ? sendGoods.getSendNumber() : SEND_NUMBER);
String s = currentSubName(cartGood);
CartGoods newCartGoods = shoppingCartConvertAdapter.convent2CartGoods(cartGood, sendGoods.getNowPrice());
newCartGoods.setClassificationId(cartGood.getClassificationId());
newCartGoods.setClassificationName(cartGood.getClassificationName());
newCartGoods.setQty(sendGoods.getSendNumber() > 0 ? sendGoods.getSendNumber() : SEND_NUMBER);
//赠品不允许有加料
cartGood.setProductMaterialList(new ArrayList());
newCartGoodsList.add(cartGoods);
newCartGoods.setProductMaterialList(new ArrayList());
newCartGoods.setSubName(s);
newCartGoodsList.add(newCartGoods);
}
......@@ -289,7 +274,7 @@ public class BuySendPromotionService implements IPromotionService {
throw new ServiceException(ResponseResult.SHOPPING_CART_GIFTS_PRODUCT_NOT_EXIST);
}
for (CartGoods cartGoods :newCartGoodsList) {
for (CartGoods cartGoods : newCartGoodsList) {
Optional<ProductBeanDTO> productBeanDTO = productBeanList.stream().filter(productBean -> ObjectUtils.equals(productBean.getPid(), cartGoods.getGoodsId())).findFirst();
if (!productBeanDTO.isPresent()) {
continue;
......@@ -298,4 +283,21 @@ public class BuySendPromotionService implements IPromotionService {
cartGoods.setWeight(productBeanDTO.get().getWeight());
}
}
/**
* 提取当前属性名
*
* @param cartGoods
* @return
*/
private String currentSubName(CartGoods cartGoods) {
String subName = cartGoods.getSubName();
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) {
return subName;
}
StringBuilder currentString = new StringBuilder();
cartGoods.getProductMaterialList().stream().forEach(e -> currentString.append("/" + e.getSpuName()));
String replace = StringUtils.replace(subName, currentString.toString(), "");
return replace;
}
}
......@@ -44,11 +44,9 @@ public class MaterialPromotionService implements IPromotionService {
@Override
public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, UserLoginInfoDto userLoginInfoDto, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
HashMap<String, MaterialApportion> map = getApportionGoodsDetail(calculationDiscountResult);
if (map != null && !map.isEmpty()) {
if (map.size() > 0) {
for (CartGoods cartGoods : cartGoodsList) {
//非正常商品
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList()))
continue;
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) continue;
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
MaterialApportion apportion = map.get(materialGoods.getSpuId());
//设置小料行单价和行总价
......@@ -86,7 +84,7 @@ public class MaterialPromotionService implements IPromotionService {
public void updateShoppingCartGoodsApportion(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, ShoppingCartGoodsDto shoppingCartGoodsDto, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
HashMap<String, MaterialApportion> map = getApportionGoodsDetail(calculationDiscountResult);
List<ShoppingCartGoodsDto.CartGoodsDetailDto> products = shoppingCartGoodsDto.getProducts();
if (map != null && map.size() > 0) {
if (map.size() > 0) {
for (ShoppingCartGoodsDto.CartGoodsDetailDto product : products) {
if (CollectionUtils.isEmpty(product.getMaterialList())) continue;
for (ShoppingCartGoodsDto.CartGoodsDetailDto.MaterialGoods materialGoods : product.getMaterialList()) {
......@@ -126,12 +124,11 @@ public class MaterialPromotionService implements IPromotionService {
* @return
*/
private HashMap<String, MaterialApportion> getApportionGoodsDetail(ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult) {
HashMap<String, MaterialApportion> mApportion = new HashMap<>();
// 遍历促销
if (calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getApportionGoods())) {
return null;
return mApportion;
}
HashMap<String, MaterialApportion> mApportion = new HashMap<>();
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods apportionGood : calculationDiscountResult.getApportionGoods()) {
if (CollectionUtils.isEmpty(apportionGood.getSmallMaterial())) continue;
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.Material material : apportionGood.getSmallMaterial()) {
......
......@@ -261,6 +261,37 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.success(shoppingCartGoodsResponseVo);
}
/**
* 查询购物车可用券
*/
public BaseResponse availableCoupon(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
if (StringUtils.isEmpty(shoppingCartInfoRequestVo.getShopId())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
}
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
ActivityClassifyCouponBean availableCoupon = new ActivityClassifyCouponBean();
// 获取用户信息
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(shoppingCartInfoRequestVo.getSessionId());
String userId = assortmentCustomerInfoVo.getMemberId();
String partnerId = shoppingCartInfoRequestVo.getPartnerId();
String storeId = shoppingCartInfoRequestVo.getShopId();
String appId = shoppingCartInfoRequestVo.getAppId();
String couponCode = shoppingCartInfoRequestVo.getCouponCode();
String activityCode = shoppingCartInfoRequestVo.getActivityCode();
String menuType = shoppingCartInfoRequestVo.getMenuType();
Integer orderType = shoppingCartInfoRequestVo.getOrderType();
String receiveId = shoppingCartInfoRequestVo.getReceiveId();
// 获取购物车商品
List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, null, "", shoppingCartBaseService);
// 促销计算-查询用户券-券码校验可用券
availableCoupon = calculationService.availableCoupon(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), menuType, receiveId,null,
cartGoodsList, new ArrayList<>(), new ArrayList<>(), shoppingCartGoodsResponseVo);
return ResponseUtil.success(availableCoupon);
}
/**
* 清空购物车
*
......
......@@ -87,8 +87,12 @@ public class CalculationServiceImpl {
List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, appId, shoppingCartGoodsResponseVo);
Long deliveryAmount = 0L;
QueryDeliverDetailResponse response = calculateDeliveryAmount(receiveId, partnerId, storeId, appId);
if(response != null){
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(response.getDeliveryFeeZeroReason() != null ? response.getDeliveryFeeZeroReason() : 0);
deliveryAmount = response.getDeliveryAmount();
}
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscount = getCalculationDiscount(partnerId, storeId, userId, appId, orderType, isMember,
menuType, deliveryAmount, cartGoodsList, coupons, sendGoodsList);
......@@ -117,7 +121,7 @@ public class CalculationServiceImpl {
List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
for (CartGoods cartGoods : cartGoodsList) {
addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(), cartGoods.getMemberDiscount());
addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getCustomerCode(),cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(), cartGoods.getMemberDiscount());
}
if (BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) {
......@@ -126,7 +130,7 @@ public class CalculationServiceImpl {
// 当加价购商品不为空时
if (CollectionUtils.isNotEmpty(sendGoodsList)) {
for (ShoppingCartInfoRequestVo.SendGoods sendGoods : sendGoodsList) {
this.addCalculationDiscountGoods(calculationDiscountGoodsList, sendGoods.getGoodsId(), sendGoods.getQty(), sendGoods.getOriginalPrice(), 100);
this.addCalculationDiscountGoods(calculationDiscountGoodsList, sendGoods.getGoodsId(), sendGoods.getGoodsId(), sendGoods.getQty(), sendGoods.getOriginalPrice(), 100);
}
}
calculationDiscountGoodsList.removeIf(calculationDiscountGoods -> (calculationDiscountGoods.getGoodsQuantity().equals(0)));
......@@ -276,10 +280,10 @@ public class CalculationServiceImpl {
/**
* 配送金额
*/
private Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
Long deliveryAmount = 0L;
private QueryDeliverDetailResponse calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid) {
if (StringUtils.isBlank(receiveId)) {
return deliveryAmount;
return null;
}
String trackingNo = LogThreadLocal.getTrackingNo();
......@@ -302,10 +306,8 @@ public class CalculationServiceImpl {
if (queryDeliverDetailResponse.getData().getDeliveryAmount() == null) {
throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR);
}
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() != null ? queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() : 0);
deliveryAmount = queryDeliverDetailResponse.getData().getDeliveryAmount();
return deliveryAmount;
return queryDeliverDetailResponse.getData();
}
......@@ -343,8 +345,9 @@ public class CalculationServiceImpl {
* @param originalPrice
*/
private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList,
String goodsId, Integer goodsQuantity, Long originalPrice, Integer memberDiscount) {
String goodsCode,String goodsId, Integer goodsQuantity, Long originalPrice, Integer memberDiscount) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods();
calculationDiscountGoods.setGoodsCode(goodsCode);
calculationDiscountGoods.setGoodsId(goodsId);
calculationDiscountGoods.setGoodsQuantity(goodsQuantity);
calculationDiscountGoods.setOriginalPrice(originalPrice);
......@@ -385,4 +388,30 @@ public class CalculationServiceImpl {
}
/**
* 可选优惠券
*/
public ActivityClassifyCouponBean availableCoupon(String partnerId, String storeId, String userId, String appId, Integer orderType,
boolean isMember, String menuType, String receiveId,String couponCode,
List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
Long deliveryAmount = 0L;
QueryDeliverDetailResponse response = calculateDeliveryAmount(receiveId, partnerId, storeId, appId);
if(response != null){
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(response.getDeliveryFeeZeroReason() != null ? response.getDeliveryFeeZeroReason() : 0);
deliveryAmount = response.getDeliveryAmount();
}
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscount = getCalculationDiscount(partnerId, storeId, userId, appId, orderType, isMember,
menuType, deliveryAmount, cartGoodsList, coupons, sendGoodsList);
//优惠券
CouponPromotionVO couponPromotionVO = couponDiscountCalculation.getCouponPromotionVO(partnerId, storeId, userId, couponCode, orderType);
couponDiscountCalculation.updateShoppingCartGoodsDiscount(couponPromotionVO,calculationDiscount,cartGoodsList, shoppingCartGoodsResponseVo);
return shoppingCartGoodsResponseVo.getAvailableCoupon();
}
}
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