Commit 3d07ca58 by 周晓航

Merge branch 'KA-【华莱士】【半定制】一个订单多张优惠券使用场景-zxh' into qa

# Conflicts:
#	shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
parents 95a7e68d 3c9cb86b
......@@ -132,7 +132,7 @@ public class OrderSdkAdapter {
return var1;
}
public CancelOrderRequest getRejectRefundRequest(String operator, String reason,OrderBeanV1 orderBean) {
public CancelOrderRequest getRejectRefundRequest(String operator, String reason, OrderBeanV1 orderBean) {
CancelOrderRequest var1 = new CancelOrderRequest();
var1.setOrderId(orderBean.getOid());
var1.setReason(reason);
......@@ -228,7 +228,7 @@ public class OrderSdkAdapter {
// 20210730之前 默认设置为1
request.setBizType(CommonConstant.INTEGER_ONE);
}
request.setOrderType(getNewOrderType(requestVO.getOrderType(), requestVO.getGmtExpect(),request.getBizType()));
request.setOrderType(getNewOrderType(requestVO.getOrderType(), requestVO.getGmtExpect(), request.getBizType()));
request.setNote(requestVO.getRemark());
request.setBarCounter(requestVO.getBarCounter());
......@@ -301,7 +301,7 @@ public class OrderSdkAdapter {
request.setOrderSendCouponRespList(JSONArray.parseArray(JSONObject.toJSONString(requestVO.getChooseGoods()), CreateOrderRequest.ChooseGood.class));
}
// 【ID1030916】订单查询门店获取预计送达时间
if (requestVO.getEstimateDeliveryCompleteTime() !=null) {
if (requestVO.getEstimateDeliveryCompleteTime() != null) {
Date time = requestVO.getEstimateDeliveryCompleteTime();
request.setEstimateDeliveryCompleteTime(time.getTime() + "");
}
......@@ -394,7 +394,7 @@ public class OrderSdkAdapter {
//订单业务类型 1:普通订单 2:虚拟订单
request.setBizType(1);
request.setNote(requestVO.getRemark());
request.setOrderType(getNewOrderType(requestVO.getOrderType(), requestVO.getGmtExpect(),request.getBizType()));
request.setOrderType(getNewOrderType(requestVO.getOrderType(), requestVO.getGmtExpect(), request.getBizType()));
request.setBarCounter(requestVO.getBarCounter());
//商品信息转换
......@@ -505,7 +505,7 @@ public class OrderSdkAdapter {
createOrderRequest.setBizType(orderInfo.getBizType());
createOrderRequest.setIsParent(orderInfo.getIsParent());
createOrderRequest.setNote(orderInfo.getRemark());
createOrderRequest.setOrderType(getNewOrderType(orderInfo.getOrderType(), orderInfo.getGmtExpect(),createOrderRequest.getBizType()));
createOrderRequest.setOrderType(getNewOrderType(orderInfo.getOrderType(), orderInfo.getGmtExpect(), createOrderRequest.getBizType()));
createOrderRequest.setBarCounter(orderInfo.getBarCounter());
//商品信息转换
......@@ -564,7 +564,7 @@ public class OrderSdkAdapter {
private Long convertCreateOrderCost(Long originalAmount, List<OrderSettlementCreateReq> orderSettlementCreateReqList, List<OrderCostCreateReq> orderCostCreateReqs, List<CreateOrderAccountRequest> accounts) {
if (!CollectionUtils.isEmpty(accounts)) {
AssortOrderLogUtil.info("fisherman 构建order_cost_detail数据",accounts,JSON.toJSONString(accounts));
AssortOrderLogUtil.info("fisherman 构建order_cost_detail数据", accounts, JSON.toJSONString(accounts));
for (CreateOrderAccountRequest accountRequest : accounts) {
//老订单服务 1=配送费;3=包装费
if (QueryOrderAccountType.DELIVERY_AMOUNT.equals(accountRequest.getAccountType())
......@@ -881,7 +881,7 @@ public class OrderSdkAdapter {
* 老订单服务结算信息转化 order_account表
*/
private List<AccountBeanV1> getOldOrderAccountList(List<OrderSettlementResp> orderSettlementResps,
List<OrderCostResp> orderCostResps) {
List<OrderCostResp> orderCostResps) {
List<AccountBeanV1> accountList = new ArrayList<AccountBeanV1>();
//新订单服务优惠信息集合
......@@ -949,7 +949,7 @@ public class OrderSdkAdapter {
* 老订单服务商品信息转化 order_product 和produce_discount 表
*/
private List<ProductBeanV1> getOldOrderProductList(List<OrderSettlementResp> orderSettlementResps,
List<OrderItemResp> orderItemList) {
List<OrderItemResp> orderItemList) {
List<ProductBeanV1> productList = new ArrayList<ProductBeanV1>();
List<OrderItemResp> parentOrderItemList = orderItemList == null ? new ArrayList<>() : orderItemList.stream()
.filter(item -> StringUtils.isEmpty(item.getParentProductId()) || ObjectUtils.equals("0", item.getParentProductId()))
......@@ -1001,8 +1001,8 @@ public class OrderSdkAdapter {
if (StringUtils.isNotEmpty(sendProductBean.getCartGoodsUid()) && null != sendProductBean.getIsSendGoods() && !sendProductBean.getIsSendGoods()) {
sendProductBean.setSendProduct(
originalProductLists.stream().filter(productBean -> productBean.getOriginalGoodsUid().equalsIgnoreCase(sendProductBean.getCartGoodsUid()) && productBean.getIsSendGoods() == true)
.map(o -> JSON.parseObject(JSON.toJSONString(o), ProductBeanV1.class))
.collect(Collectors.toList()));
.map(o -> JSON.parseObject(JSON.toJSONString(o), ProductBeanV1.class))
.collect(Collectors.toList()));
}
}
}
......@@ -1375,13 +1375,13 @@ public class OrderSdkAdapter {
data.setOrderSendCouponRespList(orderInfoReqs.getOrderSendCouponRespList());
// 设置 额外拓展字段信息
OrderExtendedReq orderExtended = this.getOrderExtendedObj(orderInfoReqs.getOrderExtended());
OrderExtendedReq orderExtended = this.getOrderExtendedObj(orderInfoReqs.getOrderExtended());
data.setOrderExtended(orderExtended);
data.setNeedInvoice(orderInfoReqs.getNeedInvoice());
return data;
}
private OrderExtendedReq getOrderExtendedObj(OrderExtendedReq orderExtended){
private OrderExtendedReq getOrderExtendedObj(OrderExtendedReq orderExtended) {
if (Objects.isNull(orderExtended)) {
return null;
}
......@@ -1603,7 +1603,7 @@ public class OrderSdkAdapter {
/**
* 老订单类型转换新订单类型
*/
public Integer getNewOrderType(QueryOrderType orderType, Long gmtExpect,Integer bizType) {
public Integer getNewOrderType(QueryOrderType orderType, Long gmtExpect, Integer bizType) {
//订单服务订单类型 1=外卖 4=自提,5=堂食
//外卖平台订单类型 1=常规堂食,2=预约堂食,3=常规外送,4=预约外送,5=常规自取,6=预约自取
boolean isAdvance = bizType != null && bizType.compareTo(BizTypeEnum.ADVANCE_ORDER.getBizType()) == 0;
......@@ -3319,7 +3319,7 @@ public class OrderSdkAdapter {
if (null != product.getProductGroupId()) {
extInfo.setProductGroupId(product.getProductGroupId());
}
if (null != product.getIsSendGoods() && product.getIsSendGoods()){
if (null != product.getIsSendGoods() && product.getIsSendGoods()) {
extInfo.setIsSendGoods(true);
}
extInfo.setIsMonthCard(product.getIsMonthCard());
......@@ -3839,26 +3839,29 @@ public class OrderSdkAdapter {
|| account.getAccountType().equals(QueryOrderAccountType.DISCOUNT_COUPON)
|| account.getAccountType().equals(QueryOrderAccountType.FREIGHT_COUPON)
).collect(Collectors.toList());
AssortOrderLogUtil.info("优惠券转换,用于锁券操作 orderbean : accounts", orderBean, accounts);
if (CollectionUtils.isEmpty(couponList)) {
return null;
}
// fisherman end
if (couponList.size() > 1) {
// 找出 配送券
CreateOrderAccountRequest freightCouponAccountBean = couponList.stream().filter(account -> account.getAccountType().equals(QueryOrderAccountType.FREIGHT_COUPON)).findFirst().orElse(null);
TransactionVO couponCodeVerificationTransDto = null;
if (!Objects.isNull(freightCouponAccountBean)) {
couponCodeVerificationTransDto = new TransactionVO();
couponCodeVerificationTransDto.setCode(freightCouponAccountBean.getAccountId());
couponCodeVerificationTransDto.setTotalAmount(freightCouponAccountBean.getPrice());
}
// 过滤出 配送券
List<CreateOrderAccountRequest> collect = couponList.stream().filter(account -> !account.getAccountType().equals(QueryOrderAccountType.FREIGHT_COUPON)).collect(Collectors.toList());
return commonMethodVerification(couponCodeVerificationTransDto, collect, orderBean, openId);
} else {
return commonMethodVerification(null, couponList, orderBean, openId);
}
//fisherman 【01测16灰18全,【华莱士】【疑难专项】一个订单多张优惠券使用场景】 https://www.tapd.cn/43862731/prong/stories/view/1143862731001037477
return this.commonMethodVerificationNew(couponList,orderBean,openId);
// // fisherman end
// if (couponList.size() > 1) {
// // 找出 配送券
// CreateOrderAccountRequest freightCouponAccountBean = couponList.stream().filter(account -> account.getAccountType().equals(QueryOrderAccountType.FREIGHT_COUPON)).findFirst().orElse(null);
// TransactionVO couponCodeVerificationTransDto = null;
// if (!Objects.isNull(freightCouponAccountBean)) {
// couponCodeVerificationTransDto = new TransactionVO();
// couponCodeVerificationTransDto.setCode(freightCouponAccountBean.getAccountId());
// couponCodeVerificationTransDto.setTotalAmount(freightCouponAccountBean.getPrice());
// }
// // 过滤出 配送券
// List<CreateOrderAccountRequest> collect = couponList.stream().filter(account -> !account.getAccountType().equals(QueryOrderAccountType.FREIGHT_COUPON)).collect(Collectors.toList());
// return commonMethodVerification(couponCodeVerificationTransDto, collect, orderBean, openId);
// } else {
// return commonMethodVerification(null, couponList, orderBean, openId);
// }
}
private CouponRequest commonMethodVerification(TransactionVO freightCouponAccountBean,
......@@ -3888,10 +3891,7 @@ public class OrderSdkAdapter {
couponCodeVerificationTransDto.setCode(accountBean.getAccountId());
couponCodeVerificationTransDto.setOpenId(openId);
Integer discountPrice = accountBean.getPrice().intValue();
if (discountPrice != null && discountPrice < 0) {
discountPrice = 0 - discountPrice;
}
couponCodeVerificationTransDto.setTotalAmount(accountBean.getPrice().longValue());
couponCodeVerificationTransDto.setTotalAmount(Math.abs(discountPrice.longValue()));
//商品券预教研
List<ProductRedeemVO> products = new ArrayList<>();
if (QueryOrderAccountType.PRODUCT_COUPON.getCode().equals(accountBean.getAccountType().getCode())) {
......@@ -3928,6 +3928,73 @@ public class OrderSdkAdapter {
return couponRequest;
}
private CouponRequest commonMethodVerificationNew(List<CreateOrderAccountRequest> collect,
OrderBeanV1 orderBean,
String openId) {
CouponRequest couponRequest = new CouponRequest();
couponRequest.setReqtype(71);
couponRequest.setVer(Integer.valueOf(Version.VERSION_1));
couponRequest.setPartnerId(Integer.parseInt(orderBean.getCompanyId()));
ActivityChannelEnum activityChannelEnum = orderTypeEnumConvert2ActivityChannel(orderBean.getOrderType());
if (activityChannelEnum == null) {
activityChannelEnum = ActivityChannelEnum.pickup;
}
couponRequest.setChannel(activityChannelEnum.getCode());
couponRequest.setStation_id("-1");
couponRequest.setOperator_id("-1");
couponRequest.setStore_id(orderBean.getShopId());
// couponRequest.setMemberId(orderBean.getUserId());
couponRequest.setOpenid(openId);
// 订单号 替换成唯一序号
couponRequest.setTrans_id(orderBean.getOid());
couponRequest.setBusiness_date(DateUtil.convert2String(new Date(), DateUtil.FORMAT_yyyyMMdd));
List<TransactionVO> transactions = this.getTransactionList( collect, orderBean, openId);
// 配送券逻辑 end
couponRequest.setTransactions(transactions);
return couponRequest;
}
private List<TransactionVO> getTransactionList(List<CreateOrderAccountRequest> collect,
OrderBeanV1 orderBean,
String openId) {
List<TransactionVO> transactions = new ArrayList<>();
collect.forEach(accountBean -> {
TransactionVO couponCodeVerificationTransDto = new TransactionVO();
couponCodeVerificationTransDto.setCode(accountBean.getAccountId());
couponCodeVerificationTransDto.setOpenId(openId);
Integer discountPrice = accountBean.getPrice().intValue();
couponCodeVerificationTransDto.setTotalAmount(Math.abs(discountPrice.longValue()));
//商品券预教研
List<ProductRedeemVO> products = new ArrayList<>();
if (QueryOrderAccountType.PRODUCT_COUPON.getCode().equals(accountBean.getAccountType().getCode())) {
for (int i = 0; i < orderBean.getProductList().size(); i++) {
ProductBeanV1 productBean = orderBean.getProductList().get(i);
String pid = StringUtils.isNotBlank(productBean.getSpecification()) ? productBean.getSpecification() : productBean.getProductId();
if (!org.springframework.util.CollectionUtils.isEmpty(orderBean.getProductList().get(i).getDiscountList())) {
List<ProductDiscountV1> discounts = orderBean.getProductList().get(i).getDiscountList().stream().
filter(productDiscount -> productDiscount.getDiscountId().equals(accountBean.getAccountId())).collect(Collectors.toList());
for (ProductDiscountV1 productDiscount : discounts) {
if (productDiscount.getDiscountType() == null || productDiscount.getDiscountType() == 0) {
continue;
}
ProductRedeemVO couponCodeVerificationProductDto = new ProductRedeemVO();
couponCodeVerificationProductDto.setPid(pid);
couponCodeVerificationProductDto.setConsume_num(productDiscount.getDiscountQty());
couponCodeVerificationProductDto.setSeq(i + 1);
couponCodeVerificationProductDto.setRedeem_price(new BigDecimal(productBean.getPrice()));
products.add(couponCodeVerificationProductDto);
}
}
}
}
if (CollectionUtils.isNotEmpty(products)) {
couponCodeVerificationTransDto.setProducts(products);
}
transactions.add(couponCodeVerificationTransDto);
});
return transactions;
}
private ActivityChannelEnum orderTypeEnumConvert2ActivityChannel(Integer orderType) {
if (Objects.equals(OldOrderType.TAKE_OUT.getCode(), orderType)) {
return ActivityChannelEnum.delivery;
......
......@@ -32,8 +32,10 @@ import cn.freemud.management.entities.dto.request.order.MCCafeProductRedeemVo;
import cn.freemud.management.entities.dto.request.order.MCCafeTransactionVo;
import cn.freemud.management.entities.dto.response.coupon.McdNetBatchQueryResponse;
import cn.freemud.management.entities.dto.response.coupon.McdNetCouponProductRespDto;
import cn.freemud.management.enums.OrderSource;
import cn.freemud.service.mccafe.CouponClientService;
import cn.freemud.utils.BeanUtil;
import cn.freemud.utils.PropertyConvertUtil;
import com.alibaba.fastjson.JSON;
import com.freemud.application.sdk.api.ordercenter.entities.v1.AccountBeanV1;
import com.freemud.application.sdk.api.ordercenter.entities.v1.OrderBeanV1;
......@@ -787,4 +789,91 @@ public class CouponAdapter {
return mcCafeCouponLockRequest;
}
/**
* 新版本 支持多券 批量核销操作
* @param orderBean
* @param couponReqType
* @return
*/
public CouponCodeVerificationDto convert2CouponCodeVerificationDto(OrderBeanV1 orderBean, CouponReqType couponReqType) {
CouponCodeVerificationDto couponCodeVerificationDto = new CouponCodeVerificationDto();
couponCodeVerificationDto.setVer(Integer.valueOf(Version.VERSION_1));
couponCodeVerificationDto.setReqtype(couponReqType.getCode());
couponCodeVerificationDto.setPartnerId(orderBean.getCompanyId());
Integer orderType = orderBean.getType();
//商城单子用NewOrderType
if (Objects.equals(OrderSource.MALL.getSource(), orderBean.getSource())) {
orderType = orderBean.getNewOrderType();
}
ActivityChannelEnum activityChannelEnum = PropertyConvertUtil.orderTypeEnumConvert2ActivityChannel(orderType);
if (activityChannelEnum == null) {
activityChannelEnum = ActivityChannelEnum.pickup;
}
couponCodeVerificationDto.setChannel(activityChannelEnum.getCode());
couponCodeVerificationDto.setStation_id("-1");
couponCodeVerificationDto.setOperator_id("-1");
couponCodeVerificationDto.setStore_id(orderBean.getShopId());
couponCodeVerificationDto.setMemberId(orderBean.getUserId());
// 订单号 替换成唯一序号
couponCodeVerificationDto.setTrans_id(orderBean.getOid());
couponCodeVerificationDto.setBusiness_date(DateUtil.convert2Str(new Date(), DateUtil.FORMAT_yyyyMMdd));
List<CouponCodeVerificationTransDto> transactions = this.getTransactions(orderBean, couponCodeVerificationDto);
couponCodeVerificationDto.setTransactions(transactions);
return couponCodeVerificationDto;
}
/**
* 组装核销 参数
* @param orderBean
* @return
*/
private List<CouponCodeVerificationTransDto> getTransactions(OrderBeanV1 orderBean, CouponCodeVerificationDto couponCodeVerificationDto) {
List<AccountBeanV1> accountList = orderBean.getAccountList();
List<CouponCodeVerificationTransDto> transactions = new ArrayList<>();
long price = 0L;
for (AccountBeanV1 accountBean : accountList) {
if (OrderAccountType.verificationCoupon.contains(accountBean.getType())) {
List<CouponCodeVerificationProductDto> products = new ArrayList<>();
if (OrderAccountType.PRODUCT_COUPON.getCode().equals(accountBean.getType())) {
for (int i = 0; i < orderBean.getProductList().size(); i++) {
ProductBeanV1 productBean = orderBean.getProductList().get(i);
String pid = StringUtils.isNotBlank(productBean.getSpecification()) ? productBean.getSpecification() : productBean.getProductId();
if (!org.springframework.util.CollectionUtils.isEmpty(orderBean.getProductList().get(i).getDiscountList())) {
List<ProductDiscountV1> discounts = orderBean.getProductList().get(i).getDiscountList().stream().
filter(productDiscount -> productDiscount.getDiscountId().equals(accountBean.getAccountId())).collect(Collectors.toList());
for (ProductDiscountV1 productDiscount : discounts) {
if (productDiscount.getDiscountType() == null || productDiscount.getDiscountType() == 0) {
continue;
}
CouponCodeVerificationProductDto couponCodeVerificationProductDto = new CouponCodeVerificationProductDto();
couponCodeVerificationProductDto.setPID(pid);
couponCodeVerificationProductDto.setConsume_num(productDiscount.getDiscountQty());
couponCodeVerificationProductDto.setSeq(i + 1);
couponCodeVerificationProductDto.setRedeem_price(new BigDecimal(productBean.getPrice()));
products.add(couponCodeVerificationProductDto);
}
}
}
}
CouponCodeVerificationTransDto couponCodeVerificationTransDto = new CouponCodeVerificationTransDto();
if (!products.isEmpty()) {
couponCodeVerificationTransDto.setProducts(products);
}
couponCodeVerificationTransDto.setCode(accountBean.getAccountId());
Long discountPriceL = accountBean.getPrice();
if (discountPriceL != null) {
int abs = Math.abs(discountPriceL.intValue());
couponCodeVerificationTransDto.setTotalAmount(abs);
price += abs;
}
transactions.add(couponCodeVerificationTransDto);
}
}
// KA 【ID1032412】【订单聚合层】核销传入优惠金额之传劵优惠只设置券的优惠金额进行上报
couponCodeVerificationDto.setOrderDiscountAmount(price);
return transactions;
}
}
......@@ -1463,7 +1463,9 @@ public class OrderAdapter {
//积分抵扣金额
Long customerScoreAmount = 0L;
String customerScorePrompt = null;
List<CouponInfoVo> couponInfos = new ArrayList<>();
if (CollectionUtils.isNotEmpty(ordersBean.getAccountList())) {
// fisherman 组装一单多券 使用的券信息
for (AccountBeanV1 accountBean : ordersBean.getAccountList()) {
if (accountBean.getPrice() < 0 && !OldOrderAccountType.MONTH_CARD_TOTAL_DISCOUNT.getCode().equals(accountBean.getType())) {
discountTotalAmount = discountTotalAmount + (0 - accountBean.getPrice());
......@@ -1494,6 +1496,7 @@ public class OrderAdapter {
couponInfoVo.setCouponCode(accountBean.getAccountId());
couponInfoVo.setCouponName(accountBean.getName());
couponInfoVo.setCouponAmount(accountBean.getPrice() < 0 ? 0 - accountBean.getPrice() : accountBean.getPrice());
// fisherman 后续已维护到 couponinfos ,请停止维护 该字段
responseVo.setCouponInfo(couponInfoVo);
couponAmount = accountBean.getPrice() < 0 ? 0 - accountBean.getPrice() : accountBean.getPrice();
}
......@@ -1510,8 +1513,16 @@ public class OrderAdapter {
if (OldOrderAccountType.FREIGHT_COUPON.getCode().equals(accountBean.getType())) {
responseVo.setFreightCouponName(accountBean.getName());
}
if (OrderAccountType.verificationCoupon.contains(accountBean.getType())) {
CouponInfoVo couponInfoVo = new CouponInfoVo();
couponInfoVo.setCouponCode(accountBean.getAccountId());
couponInfoVo.setCouponName(accountBean.getName());
couponInfoVo.setCouponAmount(Math.abs(accountBean.getPrice()));
couponInfos.add(couponInfoVo);
}
}
}
responseVo.setCouponInfos(couponInfos);
responseVo.setDeliveryAmount(deliveryAmount);
responseVo.setOriginalDeliveryAmount(originalDeliveryAmount);
responseVo.setPackageAmount(packageAmount);
......
......@@ -16,7 +16,6 @@ import cn.freemud.entities.dto.PromotionMessageDto;
import cn.freemud.entities.dto.activity.PayGiftCheckAndJoinResponseDto;
import cn.freemud.entities.dto.activity.PayGiftCheckAndJoinResponseDtoNew;
import cn.freemud.entities.dto.promotion.QueryHistoryGroupVO;
import cn.freemud.entities.dto.promotion.QuerySpellGroupVo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.freemud.application.sdk.api.ordercenter.response.orderInfo.AfterSalesOrderResp;
......@@ -357,6 +356,8 @@ public class QueryOrderResponseVo {
/**
* 优惠券信息
* 后续优惠券信息 以维护到 couponInfos 请停止使用该字段 20211026
* 记得和前端对接下 小程序版本 是否支持 couponInfos
*/
private CouponInfoVo couponInfo;
......@@ -665,4 +666,12 @@ public class QueryOrderResponseVo {
//是否已开票,true已开票,默认false未开票
private Boolean needInvoice;
/**
* 可使用多张优惠券, 使用该字段展示所有使用的优惠券信息
* 包括 :
* cn.freemud.enums.OrderAccountType#verificationCoupon
* 后续 需要移除 该类里面的 couponinfo字段, 20211026
*/
private List<CouponInfoVo> couponInfos = new ArrayList<>();
}
......@@ -13,6 +13,7 @@
package cn.freemud.service.coupon.impl;
import cn.freemud.adapter.CouponAdapter;
import cn.freemud.amp.body.OrderBody;
import cn.freemud.amqp.Header;
import cn.freemud.amqp.MQAction;
import cn.freemud.amqp.MQMessage;
......@@ -80,28 +81,30 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
@Override
public BaseResponse verificationCoupon(List<AccountBeanV1> accountList, OrderBeanV1 orderBean, CouponReqType couponReqType) {
// AppLogUtil.infoLog("fiserhman 券码核销 begin", JSON.toJSONString(accountList), JSON.toJSONString(orderBean));
if (CollectionUtils.isEmpty(accountList)) {
return ResponseUtil.success();
}
// 需要判断 accountList 里面 是都 同时包含 配送券+ other券
boolean isDoubleCoupon = checkAccountList(accountList);
if (isDoubleCoupon) {
Integer code = OrderAccountType.FREIGHT_COUPON.getCode();
// 运费券 塞进 核销接口里面, 这里真的是贼恶心 逻辑不敢动
AccountBeanV1 freightCouponAccountBean = accountList.stream().filter(accountBean -> code.equals(accountBean.getType())).findFirst().orElse(null);
CouponCodeVerificationTransDto couponCodeVerificationTransDto = null;
if (!Objects.isNull(freightCouponAccountBean)) {
couponCodeVerificationTransDto = new CouponCodeVerificationTransDto();
couponCodeVerificationTransDto.setCode(freightCouponAccountBean.getAccountId());
couponCodeVerificationTransDto.setTotalAmount(freightCouponAccountBean.getPrice().intValue());
}
// 过滤出配送券
List<AccountBeanV1> collect = accountList.stream().filter(accountBean -> !code.equals(accountBean.getType())).collect(Collectors.toList());
return commonMethodVerification(couponCodeVerificationTransDto, collect, orderBean, couponReqType);
} else {
return commonMethodVerification(null, accountList, orderBean, couponReqType);
}
// fisherman 【01测16灰18全,【华莱士】【疑难专项】一个订单多张优惠券使用场景】 https://www.tapd.cn/43862731/prong/stories/view/1143862731001037477
BaseResponse baseResponse = this.batchCouponHandle(orderBean, couponReqType);
return baseResponse;
// // 需要判断 accountList 里面 是都 同时包含 配送券+ other券
// boolean isDoubleCoupon = checkAccountList(accountList);
// if (isDoubleCoupon) {
// Integer code = OrderAccountType.FREIGHT_COUPON.getCode();
// // 运费券 塞进 核销接口里面, 这里真的是贼恶心 逻辑不敢动
// AccountBeanV1 freightCouponAccountBean = accountList.stream().filter(accountBean -> code.equals(accountBean.getType())).findFirst().orElse(null);
// CouponCodeVerificationTransDto couponCodeVerificationTransDto = null;
// if (!Objects.isNull(freightCouponAccountBean)) {
// couponCodeVerificationTransDto = new CouponCodeVerificationTransDto();
// couponCodeVerificationTransDto.setCode(freightCouponAccountBean.getAccountId());
// couponCodeVerificationTransDto.setTotalAmount(freightCouponAccountBean.getPrice().intValue());
// }
// // 过滤出配送券
// List<AccountBeanV1> collect = accountList.stream().filter(accountBean -> !code.equals(accountBean.getType())).collect(Collectors.toList());
// return commonMethodVerification(couponCodeVerificationTransDto, collect, orderBean, couponReqType);
// } else {
// return commonMethodVerification(null, accountList, orderBean, couponReqType);
// }
}
/**
......@@ -237,6 +240,47 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
return ResponseUtil.success();
}
/**
* 单笔订单 多券核销
* @param orderBean
* @param couponReqType
* @return
*/
private BaseResponse batchCouponHandle(OrderBeanV1 orderBean, CouponReqType couponReqType) {
CouponCodeVerificationDto couponCodeVerificationDto = couponAdapter.convert2CouponCodeVerificationDto(orderBean, couponReqType);
if (Objects.isNull(couponCodeVerificationDto) || couponCodeVerificationDto.getTransactions().isEmpty()) {
return ResponseUtil.success();
}
couponCodeVerificationDto.setOrderTotalAmount(orderBean.getOriginalAmount() == null ? 0L : orderBean.getOriginalAmount().longValue());
couponCodeVerificationDto.setOrderPaymentAmount(orderBean.getAmount());
// 核销券新增参数:组织机构ID
couponCodeVerificationDto.setChannel_ids(storeService.getOrgIdsArr(orderBean.getCompanyId(), orderBean.getShopId()));
boolean ok = false;
Exception lastException = null;
CouponCodeResponseDto couponCodeResponseDto = null;
try {
couponCodeResponseDto = couponOfflineClient.verification(couponCodeVerificationDto);
ThirdPartyLog.infoConvertJson(System.currentTimeMillis(), System.currentTimeMillis(), "/api", couponCodeVerificationDto, couponCodeResponseDto);
if (Objects.nonNull(couponCodeResponseDto) && Objects.equals(couponCodeResponseDto.getStatusCode(), ResponseResult.SUCCESS.getCode())) {
ok = true;
}
} catch (Exception ex) {
lastException = ex;
ErrorLog.printErrorLog("verification_error", "/api", couponCodeVerificationDto, ex);
}
if (lastException != null) {
sendMessage(orderBean, LogThreadLocal.getTrackingNo(), couponCodeVerificationDto, lastException);
} else if (!ok || Objects.equals(baffleOpen, true)) {
sendMessage(orderBean, LogThreadLocal.getTrackingNo(), couponCodeVerificationDto, ok ? "模拟券核销失败" : couponCodeResponseDto);
}
if (!ok) {
emailAlertService.sendEmailAlert("核销券码失败", String.format("request:%s \r\nresponse:%s", JSONObject.toJSONString(couponCodeVerificationDto), JSONObject.toJSONString(lastException == null ? couponCodeResponseDto : lastException)));
return ResponseUtil.error(ResponseResult.COUPON_VERIFICATION_FAIL);
}
return ResponseUtil.success();
}
/**
* 发送消息
......
......@@ -283,6 +283,17 @@ public class ShoppingCartController {
return SDKCommonBaseContextWare.getBean(ShoppingCartNewServiceImpl.class).replaceGoodsByShop(request);
}
/**
* 一单多券
* 券码需要知道配置的数据 是否是V3算价
*
*/
@PostMapping(value = "/getV3Promotion")
@ApiAnnotation(logMessage = "/getV3Promotion")
public BaseResponse getV3Promotion(@LogParams @RequestBody @Validated BaseRequestVo request) {
return SDKCommonBaseContextWare.getBean(ShoppingCartNewServiceImpl.class).getV3Promotion(request);
}
@Autowired
private ShoppingCartBaseServiceImpl shoppingCartService;
......
......@@ -5,7 +5,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
public class ActivityBaseResponseDto {
public class ActivityBaseResponseDto<T> {
private int ver;
/**
......@@ -14,9 +14,9 @@ public class ActivityBaseResponseDto {
private String statusCode;
/**
*状态码描述
* 状态码描述
*/
private String msg;
private T result;
}
package cn.freemud.entities.dto.shoppingCart;
import lombok.Data;
/**
* @author : xh.Z
* @email : fisherman0510@163.com
* @Date : 2021/10/20 上午11:32
* @description :
*/
@Data
public class PromotionResultVO {
private boolean v3Promotion;
}
......@@ -315,4 +315,6 @@ public interface ShoppingCartNewService {
default BaseResponse<PremiumExchangeResponseVo> premiumExchange(PremiumExchangeRequestVo request){
return null;
};
BaseResponse getV3Promotion(BaseRequestVo request);
}
......@@ -940,6 +940,11 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
return nowCartGoodsList;
}
@Override
public BaseResponse getV3Promotion(BaseRequestVo request) {
return null;
}
public List<CartGoods> getShoppingCart(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo) {
return null;
}
......
......@@ -780,6 +780,11 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
return nowCartGoodsList;
}
@Override
public BaseResponse getV3Promotion(BaseRequestVo request) {
return null;
}
/**
* 添加非商品券商品
*
......
......@@ -678,6 +678,11 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService {
return oldAllCartGoodsList;
}
@Override
public BaseResponse getV3Promotion(BaseRequestVo request) {
return null;
}
private void checkBase(CustomerInfoVo assortmentCustomerInfoVo) {
if (assortmentCustomerInfoVo == null || assortmentCustomerInfoVo.getMemberId() == null) {
......
......@@ -35,6 +35,7 @@ import cn.freemud.entities.dto.openplatform.WeixinProductRequestDto;
import cn.freemud.entities.dto.openplatform.WeixinProductResponseDto;
import cn.freemud.entities.dto.pay.*;
import cn.freemud.entities.dto.product.CheckCartRequest;
import cn.freemud.entities.dto.shoppingCart.PromotionResultVO;
import cn.freemud.entities.dto.shoppingCart.SendPoint;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.dto.user.*;
......@@ -3193,6 +3194,19 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
@Override
public BaseResponse getV3Promotion(BaseRequestVo request) {
boolean grayPush = grayPush(request.getPartnerId(), request.getShopId(), "2");
PromotionResultVO vo = new PromotionResultVO();
if (grayPush) {
ActivityBaseResponseDto<PromotionResultVO> responseDto = activityClient.getV3Promotion(request);
if (responseDto != null && StringUtils.equals(responseDto.getStatusCode(),ResponseCodeConstant.RESPONSE_SUCCESS_STR)) {
vo.setV3Promotion(responseDto.getResult().isV3Promotion());
}
}
return ResponseUtil.success(vo);
}
private void removeByProductStock(List<PremiumExchangeResponseVo.PremiumExchangeProduct> products, List<ValidateProductInfosDto.ProductData> productDataList, String partnerId, String storeId, String channel) {
List<Long> limitSkuIds = new ArrayList<>();
productDataList.stream().forEach(ProductData -> {
......
......@@ -19,6 +19,8 @@ import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityQueryResponseDto;
import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountRequestDto;
import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountResponseDto;
import cn.freemud.entities.dto.shoppingCart.PromotionResultVO;
import cn.freemud.entities.vo.BaseRequestVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -73,4 +75,8 @@ public interface ActivityClient {
@PostMapping("/promotioncenter/calculateservice/discount/sharing")
//@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
ActivityCalculationDiscountResponseDto calculationSharingDiscount(ActivityCalculationDiscountRequestDto shareDiscountRequestDto);
@PostMapping("/activity/getV3Promotion")
@IgnoreFeignLogAnnotation(logMessage = "/activity/getV3Promotion",excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MSG)
ActivityBaseResponseDto<PromotionResultVO> getV3Promotion(BaseRequestVo request);
}
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