Commit 3310ad63 by 孙昱

Merge branch 'feature/20201125_多规格商品下添加单规格商品_yu.sun' into feature/20201112_套餐价格计算_yu.sun

# Conflicts:
#	shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
parents 6a2cd0aa 372d54c7
......@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>assortment-ordercenter-sdk</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.5-RELEASE</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -38,7 +38,7 @@
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>ordercenter-sdk</artifactId>
<version>1.3.19.RELEASE</version>
<version>1.3.20.RELEASE</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......
......@@ -82,3 +82,5 @@
| 2.0.16.RELEASE | 麦咖啡问题修复 | 徐康 | 2020-11-09 |
| 2.1.2.RELEASE | 活动扣减库存 | 缪晖 | 2020-11-11 |
| 2.1.3-RELEASE | 退款增加自动退款配置的null判断 | 刘鹏飞 | 2020-11-12 |
| 2.1.4-RELEASE | 退款增加自动退款配置的null判断 | 刘鹏飞 | 2020-11-12 |
| 2.1.5-RELEASE | 麦咖啡权益卡金额入机 | 徐康 | 2020-11-23 |
\ No newline at end of file
......@@ -493,6 +493,7 @@ public class OrderSdkAdapter {
//1=订单,2=订单商品,3=售后单
orderCostCreateReq.setBillType(1);
orderCostCreateReq.setProductId(accountRequest.getProductId());
orderCostCreateReq.setNote(accountRequest.getNote());
orderCostCreateReqs.add(orderCostCreateReq);
} else {
OrderSettlementCreateReq orderSettlementCreateReq = new OrderSettlementCreateReq();
......@@ -1324,6 +1325,9 @@ public class OrderSdkAdapter {
case "MEMBER_PRICE_DISCOUNT":
type=220;
break;
case "GATHER_SPOT":
type=221;
break;
default:
break;
}
......
......@@ -42,6 +42,7 @@ public enum OldOrderAccountType {
NEW_USER_DISCOUNT(101, "新用户立减", "NEW_USER_DISCOUNT"),
PRICE_DEDUCTION_COUPON(103, "抵价券", "PRICE_DEDUCTION_COUPON"),
TOTAL_DISCOUNT(205, "优惠总金额", "TOTAL_DISCOUNT"),
GATHER_SPOT(221, "集点活动","GATHER_SPOT"),
MEMBER_PRICE_DISCOUNT(220, "会员价优惠", "MEMBER_PRICE_DISCOUNT");
private Integer code;
......
......@@ -39,6 +39,7 @@ public enum QueryOrderAccountType {
ONLINE_PAY("ONLINE_PAY", "线上支付"),
FULL_DISTRIBUTION_FEE("FULL_DISTRIBUTION_FEE", "满减配送费"),
OFFLINE_PAY("OFFLINE_PAY", "线下支付"),
GATHER_SPOT("GATHER_SPOT", "集点活动"),
MEMBER_PRICE_DISCOUNT("MEMBER_PRICE_DISCOUNT","会员价优惠"),
MCCAFE_MONTH_CARD("MCCAFE_MONTH_CARD","麦咖啡月卡"),
WITH_ORDER_BUY_COUPON_FEE("WITH_ORDER_BUY_COUPON_FEE", "随单买月卡"),
......
......@@ -40,6 +40,8 @@ public class CreateOrderAccountRequest extends BaseConfig {
*/
private String addInfo;
private String note;
private String productId;
private Integer discountQty;
......
......@@ -40,7 +40,7 @@
<dependency>
<groupId>cn.freemud</groupId>
<artifactId>assortment-ordercenter-sdk</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.5-RELEASE</version>
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......@@ -88,7 +88,7 @@
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<artifactId>storecenter-sdk</artifactId>
<version>3.1.9.RELEASE</version>
<version>3.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>cn.freemud</groupId>
......
......@@ -185,7 +185,7 @@ public class DeliveryAdapter {
if (CollectionUtils.isNotEmpty(order.getProductList())) {
order.getProductList().forEach(productList -> {
ProductInfo deliveryProductInfo = new ProductInfo();
deliveryProductInfo.setProductCode(productList.getProductId());
deliveryProductInfo.setProductCode(productList.getProductId().substring(4));
String productName = StringUtils.isBlank(productList.getSpecificationName()) ? productList.getProductName() : productList.getSpecificationName();
OrderProductAddInfoDto extInfo = JSON.parseObject(productList.getExtInfo(), OrderProductAddInfoDto.class);
if(CollectionUtils.isNotEmpty(extInfo.getSpecialAttrs())) {
......@@ -221,7 +221,7 @@ public class DeliveryAdapter {
if(CollectionUtils.isNotEmpty(productList.getComboProduct())) {
productList.getComboProduct().forEach(comboProduct -> {
ProductInfo deliveryComboProductInfo = new ProductInfo();
deliveryComboProductInfo.setProductCode(comboProduct.getProductId());
deliveryComboProductInfo.setProductCode(comboProduct.getProductId().length()>4?comboProduct.getProductId().substring(4):comboProduct.getProductId());
String productNameCombo = StringUtils.isBlank(comboProduct.getSpecificationName()) ? comboProduct.getProductName() : comboProduct.getSpecificationName();
OrderProductAddInfoDto extInfoCombo = JSON.parseObject(comboProduct.getExtInfo(), OrderProductAddInfoDto.class);
if(CollectionUtils.isNotEmpty(extInfoCombo.getSpecialAttrs())) {
......@@ -251,7 +251,7 @@ public class DeliveryAdapter {
deliveryComboProductInfo.setTaxId(StringUtils.isNotEmpty(orderComboProductAddInfoDto.getTaxId()) ? orderComboProductAddInfoDto.getTaxId() : "10");
deliveryComboProductInfo.setTaxRate(orderComboProductAddInfoDto.getTax() > 0 ? orderComboProductAddInfoDto.getTax() : 6);
deliveryComboProductInfo.setParentCode(Long.valueOf(comboProduct.getParentProductId().replace("_", "")));
deliveryComboProductInfo.setParentCode(Long.valueOf(comboProduct.getParentProductId().replace("_", "").substring(4)));
deliveryProductInfo.setProductCode(deliveryComboProductInfo.getParentCode()+"");
if(CollectionUtils.isNotEmpty(comboProduct.getMaterialProduct())) {
......
......@@ -79,6 +79,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
......@@ -182,6 +183,7 @@ public class OrderAdapter {
}
}
createOrderDto.setProducts(products);
boolean hasDeliveryMonthCard = false;
for (ActivityDiscountsDto activityDiscountsDto : activityDiscountsDtos) {
CreateOrderAccountRequest createOrderAccountDto = CreateOrderAccountRequest.builder()
.accountId(activityDiscountsDto.getActivityCode())
......@@ -198,6 +200,9 @@ public class OrderAdapter {
jsonObject.put("tenderId", activityDiscountsDto.getTenderId());
} else if(ActivityTypeEnum.TYPE_34.getCode().equals(activityDiscountsDto.getActivityType())) {
jsonObject.put("customerCode", activityDiscountsDto.getTenderId());
if(null != activityDiscountsDto.getExtendType() && activityDiscountsDto.getExtendType() == 2) {
hasDeliveryMonthCard = true;
}
}
if(null != activityDiscountsDto.getExtendType()) {
jsonObject.put("extendType", activityDiscountsDto.getExtendType());
......@@ -216,6 +221,9 @@ public class OrderAdapter {
.sequence(orderAccountIndex++)
.actualPrice(discountDeliveryAmount)
.build();
if(hasDeliveryMonthCard && StringUtils.isNotBlank(storeResponseDto.getBenefitCardDiscountAmount())) {
createOrderAccountDto.setNote((Integer.parseInt(storeResponseDto.getBenefitCardDiscountAmount())*100)+"");
}
orderAccountDtos.add(createOrderAccountDto);
}
if (packageAmount > 0) {
......@@ -1109,6 +1117,10 @@ public class OrderAdapter {
responseVo.setPayStatusDesc(Optional.ofNullable(PayStatus.getByCode(ordersBean.getPayStatus()))
.map(PayStatus::getDesc).orElse(""));
responseVo.setPayVoucher(orderExtInfoDto != null ? orderExtInfoDto.getPayTransId() : "");
if(mcCafePartnerId.equals(ordersBean.getCompanyId())) {
responseVo.setPayVoucherBarCode(Base64.getEncoder().encodeToString(
BarcodeUtil.generateBarCode128(responseVo.getPayVoucher(),null,null, true, true)));
}
responseVo.setPayCreateTime(orderExtInfoDto != null ? orderExtInfoDto.getPayDate() : "");
responseVo.setPayChannel(ordersBean.getPayChannel());
if (StringUtils.isNotBlank(ordersBean.getPayChannel())) {
......@@ -1156,7 +1168,7 @@ public class OrderAdapter {
if (CollectionUtils.isNotEmpty(ordersBean.getRefundList())) {
responseVo.setRefundTips(orderViewStatusDto.getRefundStatusText());
}
if(OrderStatus.COMPLETE.getCode().equals(ordersBean.getStatus())) {
if(OrderStatus.COMPLETE.getCode().equals(ordersBean.getStatus()) && null != ordersBean.getGmtCompleteTime() && 0l != ordersBean.getGmtCompleteTime()) {
responseVo.setCompleteTime(DateUtil.convert2String(new Date(ordersBean.getGmtCompleteTime()), "yyyy-MM-dd HH:mm:ss"));
}
responseVo.setTakeMealFlows(getTakeMealFlows(ordersBean));
......@@ -2480,6 +2492,9 @@ public class OrderAdapter {
if (ActivityTypeEnum.TYPE_23.getCode().equals(activityType)){
return OldOrderAccountType.SUPER_PURCHASE;
}
if (ActivityTypeEnum.TYPE_221.getCode().equals(activityType)){
return OldOrderAccountType.GATHER_SPOT;
}
return OldOrderAccountType.BUYM_SENDN;
}
......
......@@ -203,6 +203,10 @@ public class QueryOrderResponseVo {
*/
private String payVoucher;
/**
* 付款单号条形码
*/
private String payVoucherBarCode;
/**
* 退款状态 enum refundStatus
*/
private Integer refundStatus;
......
......@@ -54,6 +54,7 @@ public enum ActivityTypeEnum {
TYPE_PACKAGE(900, "包装费"),
TYPE_DELIVERY(901, "配送费"),
TYPE_211(211, "套餐优惠"),
TYPE_221(221, "集点活动"),
TYPE_320(320, "会员价优惠");
private Integer code;
......
......@@ -557,12 +557,21 @@ public class CheckMCCafeOrder {
throw new ServiceException(ResponseResult.SHOPPING_CART_GETINFO_INVAILD);
}
List<MCCafeCouponVo> mcCafeCouponVos = new ArrayList<>();
Map<String, String> mcCafeUsedCoupon = new HashMap<>();
if(CollectionUtils.isNotEmpty(shoppingCartGoodsDto.getActivityDiscountsDtos())) {
shoppingCartGoodsDto.getActivityDiscountsDtos().forEach(o-> {
if(ActivityTypeEnum.TYPE_3.getCode().equals(o.getActivityType()) || ActivityTypeEnum.TYPE_32.getCode().equals(o.getActivityType())
|| ActivityTypeEnum.TYPE_34.getCode().equals(o.getActivityType()) || ActivityTypeEnum.TYPE_35.getCode().equals(o.getActivityType())) {
mcCafeCouponVos.add(new MCCafeCouponVo(o.getActivityCode()));
}
if(ActivityTypeEnum.TYPE_32.getCode().equals(o.getActivityType()) && null != o.getExtendType()
&& (0 == o.getExtendType() || 3 == o.getExtendType() || 4 == o.getExtendType() || 5 == o.getExtendType())) {
if(StringUtils.isNotBlank(mcCafeUsedCoupon.get(o.getActivityCode()))) {
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, o.getActivityName() + "不可以重复使用");
} else {
mcCafeUsedCoupon.put(o.getActivityCode(), o.getActivityName());
}
}
});
}
if(CollectionUtils.isNotEmpty(mcCafeCouponVos)) {
......
......@@ -175,7 +175,21 @@ public class OrderAdapterServiceImpl implements OrderAdapterService {
if(ObjectUtils.notEqual(baseResponse.getCode(),ResponseResult.SUCCESS.getCode())){
return baseResponse;
}
// 添加分布式锁,如果没有取得锁直接返回失败;整个方法执行完毕后会删掉该锁
// 锁定秒数从apollo获取,如果apollo没有设置,默认5秒
String createOrderKey = CREATE_ORDER_KEY + assortmentCustomerInfoVo.getMemberId();
try {
Long expire = Long.valueOf(createOrderKeyExpire);
if(!LockUtils.lock(redisCache.getRedisTemplate(),createOrderKey,expire)){
return ResponseUtil.error(ResponseResult.ORDER_NOT_CREATE_ERROR);
}
return mcCafeOrderService.createMCCafeOrder(createOrderVo);
} catch (Exception e) {
throw e;
} finally {
//LockUtils.unlock(redisCache.getRedisTemplate(),createOrderKey);
}
}
@Override
......
......@@ -14,7 +14,7 @@ public class DateUtils {
if (date == null ){
return null;
}
String[] week={"(周一)","(周二)","(周三)","(周四)","(周五)","(周六)","(周日)"};
String[] week={"(周日)","(周一)","(周二)","(周三)","(周四)","(周五)","(周六)"};
Calendar calendar =Calendar.getInstance();
calendar.setTime(date);
int w = calendar.get(Calendar.DAY_OF_WEEK) -1 ;
......
......@@ -122,7 +122,12 @@ public class OrderManagerAdapter {
//查询订单
QueryOrdersResponse.DataBean.OrderBean orderBean = orderBaseService.getByOrderCode(request.getOrderId());
//订单接单参数校验
BaseResponse verifyResponse = orderVerifyHandle.orderRejectVerify(orderBean, request);
BaseResponse verifyResponse;
if (!macCafePartnerId.equals(orderBean.getCompanyId())) {
verifyResponse = orderVerifyHandle.orderRejectVerify(orderBean, request);
} else {
verifyResponse = orderVerifyHandle.mcCafeOrderRejectVerify(orderBean, request);
}
if (ObjectUtils.notEqual(verifyResponse.getCode(), ResponseResult.SUCCESS.getCode())) {
return handleResponse(request,orderBean,verifyResponse);
}
......
......@@ -19,6 +19,7 @@ import com.freemud.sdk.api.assortment.order.adapter.OrderSdkAdapter;
import com.freemud.sdk.api.assortment.order.domain.ResponseCodeConstant;
import com.freemud.sdk.api.assortment.message.enums.OrderType;
import com.freemud.sdk.api.assortment.order.enums.OldOrderAccountType;
import com.freemud.sdk.api.assortment.order.enums.OldOrderType;
import com.freemud.sdk.api.assortment.order.enums.RefundStatus;
import com.freemud.sdk.api.assortment.order.request.order.CancelOrderRequest;
import com.freemud.sdk.api.assortment.order.response.order.BaseOrderResponse;
......@@ -216,6 +217,40 @@ public class OrderVerifyHandle {
}
/**
* 拒单
*
* @param orderBean
* @param request
* @return
*/
public BaseResponse mcCafeOrderRejectVerify(QueryOrdersResponse.DataBean.OrderBean orderBean, OrderManagerRequest request) {
if (orderBean == null) {
return ResponseUtil.error(ResponseResult.ORDER_NOT_EXIST);
}
Integer status = orderBean.getStatus();
//判断订单是否已经被拒单
if (OrderStatus.REFUSE.getCode().equals(status)) {
return ResponseUtil.error(ResponseResult.REJECT_FAIL_REPETITION, getOrderManagerResponse(orderBean));
}
//判断订单是否已经取消
if (OrderStatus.CANCEL.getCode().equals(status)) {
return ResponseUtil.error(ResponseResult.ORDER_HAS_CANCELED, getOrderManagerResponse(orderBean));
}
//判断订单是否在配送中
if (OrderStatus.DISTRIBUTION.getCode().equals(status)) {
return ResponseUtil.error(ResponseResult.REJECT_FAIL_ORDER_IS_DELIVERY, getOrderManagerResponse(orderBean));
}
//判断订单是否已送达
if (OrderStatus.COMPLETE.getCode().equals(status)) {
return ResponseUtil.error(ResponseResult.REJECT_FAIL_ORDER_IS_COMPLETE, getOrderManagerResponse(orderBean));
}
if (!OrderStatus.TAKE_ORDER.getCode().equals(status) && !OldOrderType.TAKE_OUT.getCode().equals(orderBean.getOrderType())) {
return ResponseUtil.error(ResponseResult.REJECT_FAIL_ORDER_IS_NOT_NEW, getOrderManagerResponse(orderBean));
}
return ResponseUtil.success();
}
/**
* 同意退款
*
* @param orderBean
......
......@@ -8,7 +8,7 @@
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>1.3.19.RELEASE</version>
<version>1.3.20.RELEASE</version>
<artifactId>ordercenter-sdk</artifactId>
<dependencies>
......
......@@ -52,4 +52,5 @@
| 1.3.16.RELEASE | 麦咖啡多规格 | 徐康 | 2020-10-09 |
| 1.3.17.RELEASE | 集点推送改造 | 梁崇福 | 2020-10-28 |
| 1.3.18.RELEASE | 麦咖啡加料 | 徐康 | 2020-10-30 |
| 1.3.20.RELEASE | 麦咖啡权益卡金额入机 | 徐康 | 2020-11-23 |
package cn.freemud.entities.dto.product;
import lombok.Data;
import java.util.List;
/**
* All rights Reserved, Designed By sunary.site
*
* @version v1.0
* @Title: IntelliJ IDEA
* @Package cn.freemud.entities.dto.product
* @Description: 请简单描述下这个类是做什么用的
* @author: yu.sun
* @date: 2020-11-25 11:51:44
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
*/
@Data
public class ProductTypeBeanDTO {
private String businessNo;
private String barcode;
private String brandId;
private String brandName;
private String category;
private String categoryName;
private String companyId;
private String customerCode;
private String productCode;
private Long finalPrice;
private Integer isSkuProduct;
private String name;
private Long originalPrice;
private Long packPrice;
private String picture;
private String pid;
private String specification;
private Integer status;
private Integer stock;
private Integer stockLimit;
private int type;
private String unit;
private Integer riseSell;
private String rawMaterial;
private Double tax;
private String taxId;
private Integer openMemberDiscount;
private Integer memberDiscount;
private List<ProductAttributeGroupListBean> productAttributeGroupList;
private List<ProductPictureListBean> productPictureList;
private List<SkuProductBean> skuList;
private List<ProductComboType> productComboList;
private List<ProductGroupType> productGroupList;
private List<SkuProductBean.SkuSpecValue> skuSpecValues;
private List<PackageProductTypeDto> packageProductTypes;
private List<ProductGroupType> additionalGroupList;
private List<ProductComboDetailTypeDto> productComboInfos;
private Integer isDishware;
private Integer weightType;
private Double weight;
public Integer getMemberDiscountResult() {
return this.openMemberDiscount != null && this.openMemberDiscount == 1 ? this.memberDiscount : 100;
}
public ProductTypeBeanDTO() {
}
@Data
public static class ProductComboDetailTypeDto {
private String productId;
private Integer quantity;
private Integer sequence;
public ProductComboDetailTypeDto() {
}
}
@Data
public static class ProductAttributeGroupListBean {
private String attributeName;
private Integer attributeType;
private List<AttributeValueBean> attributeValues;
public ProductAttributeGroupListBean() {
}
}
@Data
public static class AttributeValueBean {
private String attributeId;
private String attributeValue;
private Long id;
private Long price;
private Integer sequence;
private Integer status;
public AttributeValueBean() {
}
}
@Data
public static class PackageProductTypeDto {
private Long groupId;
private Integer sequence;
public PackageProductTypeDto() {
}
}
@Data
public static class ProductGroupType {
private String pgid;
private String linkId;
private String groupCode;
private String options;
private String name;
private Integer must;
private Integer allowRepeat;
private Integer minNumber;
private Integer maxNumber;
private String remark;
private Integer total;
private List<ProductGroupType.GroupDetailType> groupDetail;
public ProductGroupType() {
}
@Data
public static class GroupDetailType {
private String productId;
private String productName;
private String customerCode;
private Integer productPrice;
protected Integer productFinalPrice;
protected Integer markUpPrice;
private String picture;
private Integer stockLimit;
protected String unit;
protected String productCode;
private Integer weightType;
private Double weight;
private Double tax;
private String taxId;
}
}
@Data
public static class ProductComboType {
private String productId;
private String productName;
private String customerCode;
private Integer originalPrice;
protected Integer finalPrice;
protected Integer packPrice;
private String picture;
protected String unit;
protected String productCode;
private Integer quantity;
private Integer weightType;
private Double weight;
private Double tax;
private String taxId;
}
@Data
public static class ProductPictureListBean {
private String pictureId;
private String productId;
private String sequence;
private String type;
private String url;
@Data
public static class AttributeValueBean {
private String attributeId;
private String attributeValue;
private Long id;
private Long price;
private Integer sequence;
private Integer status;
public AttributeValueBean() {
}
}
}
@Data
public static class ProductLabelNameListBean {
private String id;
private String name;
private String partnerId;
List<?> productList;
private String storeId;
private String type;
public ProductLabelNameListBean() {
}
}
@Data
public static class SpecificationGroupBean {
private String partnerId;
private Integer sequence;
private String specId;
private String specName;
private List<SpecificationGroupBean.SpecValueVo> specValueVos;
public SpecificationGroupBean() {
}
@Data
public static class SpecValueVo {
private Integer sequence;
private String specId;
private String specValue;
private String specValueId;
public SpecValueVo() {
}
}
}
@Data
public static class SkuProductBean {
private String customerCode;
private String productCode;
private Long finalPrice;
private Long originalPrice;
private String productName;
private Integer productType;
private Integer sequence;
private String skuCode;
private String skuId;
private Integer status;
private Integer stockLimit;
private Integer stockQty;
private Long packPrice;
private Integer riseSell;
private String rawMaterial;
private Double tax;
private String taxId;
private List<SkuProductBean.SkuSpecValue> skuSpecValues;
private List<ProductGroupType> additionalGroupList;
private Double weight;
protected String unit;
private Integer openMemberDiscount;
private Integer memberDiscount;
public Integer getMemberDiscountResult() {
return this.openMemberDiscount != null && this.openMemberDiscount == 1 ? this.memberDiscount : 100;
}
public SkuProductBean() {
}
@Data
public static class SkuSpecValue {
private String productId;
private Integer sequence;
private String specId;
private String specName;
private String specValue;
private String specValueId;
public SkuSpecValue() {
}
}
@Data
public static class PackageProductTypeDto {
private Long groupId;
private Integer sequence;
public PackageProductTypeDto() {
}
}
}
}
package cn.freemud.entities.dto.product;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import lombok.Data;
import java.util.Map;
......@@ -24,9 +24,9 @@ public class ValiadShopProductResult {
private String message;
private String skuId;
private String spuId;
private ProductBeanDTO productType;
private ProductTypeBeanDTO productType;
private String uuid;
private Map<String,ProductBeanDTO> subProductTypeMap;
private Map<String,ProductTypeBeanDTO> subProductTypeMap;
}
......@@ -25,7 +25,9 @@ public enum ShoppingCartPromotionEnum {
TwoN_DISCOUNT(9, "twoNDiscountService"),
BUY_GIFTS(10, "buyAndGiftsPromotionService"),
MEMBER_DISCOUNT(11, "memberDiscountService"),
Material(12, "MaterialPromotionService");
Material(12, "MaterialPromotionService"),
// 集点活动类
GATHER_SPOT(13, "gatherSpotPromotionService");
private Integer type;
private String msgType;
......
package cn.freemud.service.impl;
import cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.service.IPromotionService;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* All rights Reserved, Designed By www.freemud.cn
* 集点活动
*
* @version V1.0
* @Title: BuyAndGiftsPromotionService
* @Package cn.freemud.service.impl
* @Description:
* @author: pengfei.liu
* @date: 2020/11/16
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Service("gatherSpotPromotionService")
public class GatherSpotPromotionService implements IPromotionService {
/**
* 集点活动只有赠送的点数,没有优惠金额<br/>
* 优惠金额不做处理
* @param couponPromotionVO
* @param activityQueryDto
* @param calculationDiscountResult
* @param cartGoodsList
* @param shoppingCartGoodsResponseVo
* @param userLoginInfoDto
* @param shoppingCartInfoRequestVo
*/
@Override
public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto,
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult,
List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo,
UserLoginInfoDto userLoginInfoDto, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
return;
}
/**
* 活动类型-TYPE_221筛选出集点活动
* 集点活动没有优惠金额,所以促销金额设置为0
* @param shoppingCartGoodsResponseVo
* @param calculationDiscountResult
* @param shoppingCartGoodsDto
* @param premiumExchangeActivity
* @param shoppingCartInfoRequestVo
*/
@Override
public void updateShoppingCartGoodsApportion(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, ShoppingCartGoodsDto shoppingCartGoodsDto, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
if (calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getDiscounts())) {
return;
}
// 活动类型-TYPE_221筛选出集点活动
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> gatherSpots = calculationDiscountResult.getDiscounts().stream().filter(activityPrompt -> null != activityPrompt.getType() && ActivityTypeEnum.TYPE_221.getCode().intValue() == activityPrompt.getType().intValue()).collect(Collectors.toList());
if (CollectionUtils.isEmpty(gatherSpots)) {
return;
}
// 其他活动已经计算出来的促销活动
List<ActivityDiscountsDto> activityDiscountsDtos = shoppingCartGoodsDto.getActivityDiscountsDtos() == null ? new ArrayList<>() : shoppingCartGoodsDto.getActivityDiscountsDtos();
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount gatherSpot : gatherSpots) {
//设置优惠活动
ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto();
activityDiscountsDto.setActivityCode(gatherSpot.getActivityCode());
activityDiscountsDto.setActivityName(gatherSpot.getActivityName());
activityDiscountsDto.setActivityType(gatherSpot.getType());
activityDiscountsDto.setDiscountAmount(0);
activityDiscountsDtos.add(activityDiscountsDto);
}
shoppingCartGoodsDto.setActivityDiscountsDtos(activityDiscountsDtos);
}
}
......@@ -1371,6 +1371,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
BuyAndGiftsPromotionService buyAndGiftsPromotionService = (BuyAndGiftsPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.BUY_GIFTS);
buyAndGiftsPromotionService.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
// 集点活动
GatherSpotPromotionService gatherSpotPromotionService = (GatherSpotPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.GATHER_SPOT);
gatherSpotPromotionService.updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
/**
* 设置加料商品行记录
*/
......@@ -1855,7 +1859,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
public boolean grayPush(String partnerId, String storeId, String version) {
if (StringUtils.isBlank(sharing)) return false;
CalculateCenter center = JSON.parseObject(sharing, CalculateCenter.class);
Boolean enable = false;
if (!center.getEnable()) return false;
......@@ -1864,21 +1867,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
enable = true;
break;
case 1: {
if (StringUtils.isBlank(center.getPartnerId())) {
enable = false;
} else {
if (Arrays.asList(center.getPartnerId().split(",")).contains(partnerId)) {
//商户+门店级别
String real = partnerId.concat(storeId);
if (Arrays.asList(center.getGrayList().split(",")).contains(real)) {
enable = true;
} else {
enable = false;
}
if (Arrays.asList(center.getStoreId().split(",")).contains(storeId)) {
//商户级别
else if (Arrays.asList(center.getGrayList().split(",")).contains(partnerId)) {
enable = true;
} else {
enable = false;
}
}
break;
}
}
if (center.getEnable() && enable) {
......
......@@ -22,12 +22,7 @@ public class CalculateCenter {
/**
* 商户
*/
private String partnerId;
/**
* 门店
*/
private String storeId;
private String grayList;
/**
* 是否启用新的算价中心
......
......@@ -202,6 +202,7 @@ public class CalculationSharingDiscountService {
}
}
/**
* 实物商品
* @param calculationDiscountGoodsList
......@@ -209,11 +210,18 @@ public class CalculationSharingDiscountService {
*/
private void setCommonDiscountGoods(List<CalculationSharingDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList
, CartGoods cartGoods) {
CalculationSharingDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new CalculationSharingDiscountRequestDto.CalculationDiscountGoods();
calculationDiscountGoods.setGoodsId(cartGoods.getGoodsId());
calculationDiscountGoods.setCartGoodsUid(cartGoods.getCartGoodsUid());
calculationDiscountGoods.setGoodsQuantity(cartGoods.getQty());
//if (cartGoods.getGoodsType().equals(GoodsTypeEnum.SET_MEAL_GOODS))
if (CollectionUtils.isNotEmpty(cartGoods.getProductGroupList()) || CollectionUtils.isNotEmpty(cartGoods.getProductComboList())) {
calculationDiscountGoods.setOriginalPrice(cartGoods.getFinalPrice()!=null ? cartGoods.getFinalPrice() : cartGoods.getOriginalPrice());
}
else {
calculationDiscountGoods.setOriginalPrice(cartGoods.getOriginalPrice());
}
calculationDiscountGoods.setMemberDiscount(cartGoods.getMemberDiscount());
calculationDiscountGoods.setSpuId(cartGoods.getSpuId());
//商品加料
......
......@@ -9,6 +9,7 @@ import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.activity.ActivityQueryResponseDto;
import cn.freemud.entities.dto.product.ProductTypeBeanDTO;
import cn.freemud.entities.dto.product.ValiadShopProductResponse;
import cn.freemud.entities.dto.product.ValiadShopProductResult;
import cn.freemud.entities.dto.product.ValidateShopProductRequest;
......@@ -33,6 +34,7 @@ import cn.freemud.service.thirdparty.CustomerApplicationClient;
import cn.freemud.utils.BeanUtil;
import cn.freemud.service.thirdparty.ProductClient;
import cn.freemud.utils.ResponseUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
......@@ -169,7 +171,6 @@ public class ShoppingCartMCoffeeServiceImpl {
if (CollectionUtils.isEmpty(oldCartGoodsList)) {
oldCartGoodsList = new ArrayList<>();
}
//商品券已添加情况校验
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = checkGoodsCoupon(oldCartGoodsList, operationType, couponCode,goodsId, addShoppingCartGoodsRequestVo);
CartGoods addCartGoods = convent2CartGoods(addShoppingCartGoodsRequestVo, goodsId ,vo);
......@@ -1039,7 +1040,7 @@ public class ShoppingCartMCoffeeServiceImpl {
newCartGoods.add(addCartGoods);
//加购商品校验
List<CartGoods> allCartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, newCartGoods);
List<CartGoods> allCartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType,shoppingCartGoodsResponseVo, newCartGoods);
List<CartGoods> nowCartGoodsList = new ArrayList<>();
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
......@@ -1512,7 +1513,6 @@ public class ShoppingCartMCoffeeServiceImpl {
try {
ValidateShopProductRequest validateShopProductRequest = shoppingCartConvertAdapter.getValidateShopProductRequest(checkCartRequest);
ProductBaseResponse<ValiadShopProductResponse> valiadResponse = productClient.validateShopProductAboutReason(validateShopProductRequest);
if (valiadResponse == null || !CartResponseConstant.SUCCESS.getCode().equals(valiadResponse.getErrcode().toString()) || valiadResponse.getData()==null) {
checkCartRequest.getCartGoodsList().clear();
checkCartRequest.getShoppingCartGoodsResponseVo().setChanged(true);
......@@ -1556,7 +1556,8 @@ public class ShoppingCartMCoffeeServiceImpl {
}
if (PRODUCT_PRICE_CHANGE == validaProduct.getCode()) {
changePriceSpu.add(spuName);
List<ProductBeanDTO> productList = validateResult.getFailureList().stream().map(ValiadShopProductResult::getProductType).collect(Collectors.toList());
List<ProductTypeBeanDTO> productList =
validateResult.getFailureList().stream().map(ValiadShopProductResult::getProductType).collect(Collectors.toList());
shoppingCartConvertAdapter.updateCartGoodsInfoForMCoffee(cartGoods, productList);
}
if (PRODUCT_GROUP_PRICE_CHANGE == validaProduct.getCode()) {
......@@ -1600,9 +1601,9 @@ public class ShoppingCartMCoffeeServiceImpl {
continue;
}
for (ValiadShopProductResult valiadShopProductResult : validateResult.getSuccessList()){
ProductBeanDTO productType = valiadShopProductResult.getProductType();
ProductTypeBeanDTO productType = valiadShopProductResult.getProductType();
if(ObjectUtils.equals(productType.getPid(), cartGoods.getSpuId())){
Map<String,ProductBeanDTO> subProductTypeMap = valiadShopProductResult.getSubProductTypeMap();
Map<String,ProductTypeBeanDTO> subProductTypeMap = valiadShopProductResult.getSubProductTypeMap();
shoppingCartConvertAdapter.updateCartGoodsInfo(cartGoods, productType,subProductTypeMap);
break;
}
......
......@@ -412,7 +412,8 @@ public class CalculationServiceImpl {
material.setType(2);
material.setGoodsId(materialGoods.getGoodsId());
material.setGoodsQuantity(materialGoods.getQty());
material.setOriginalPrice(materialGoods.getFinalPrice());
material.setOriginalPrice(null != materialGoods.getFinalPrice() ?
materialGoods.getFinalPrice() : 0);
materials.add(material);
}
}
......@@ -430,7 +431,8 @@ public class CalculationServiceImpl {
material.setType(1);
material.setGoodsId(materialGoods2.getSpuId());
material.setGoodsQuantity(1);
material.setOriginalPrice(materialGoods2.getFinalPrice());
material.setOriginalPrice(null != materialGoods2.getFinalPrice() ?
materialGoods2.getFinalPrice() : 0);
materials.add(material);
}
}
......@@ -438,14 +440,15 @@ public class CalculationServiceImpl {
}
//加料
if (cartGoods != null && CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
if (null != cartGoods && CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material material = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods.Material();
material.setType(1);
material.setGoodsId(materialGoods.getSpuId());
material.setGoodsQuantity(1);
material.setOriginalPrice(materialGoods.getOriginalPrice());
material.setNowPrice(materialGoods.getFinalPrice().intValue());
material.setOriginalPrice(null != materialGoods.getOriginalPrice() ?
materialGoods.getOriginalPrice() : 0);
material.setNowPrice(null != materialGoods.getFinalPrice() ? materialGoods.getFinalPrice().intValue():0);
materials.add(material);
}
}
......
......@@ -83,7 +83,7 @@ public class SetMealCalculation {
Long comboxmaterialPrice = 0L;
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
for (CartGoods.MaterialGoods materialGoods : comboxGoods.getProductMaterialList()){
comboxmaterialPrice+= materialGoods.getFinalPrice() * cartGoods.getQty();
comboxmaterialPrice+= null != materialGoods.getFinalPrice() ? materialGoods.getFinalPrice() * cartGoods.getQty() : 0;
}
}
comboxGoods.setAmount((null == comboxGoods.getAmount() ? 0 :
......
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