Commit 21372771 by zhiheng.zhang

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

# Conflicts:
#	assortment-ordercenter-sdk/readme.md
#	order-application-service/src/main/java/cn/freemud/service/impl/OrderServiceImpl.java
parents 59d2478d a44ee5f2
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
| 1.8.10-SNAPSHOT | 集点为0时不调用会员接口 | 梁崇福 | 2020-06-01 | | 1.8.10-SNAPSHOT | 集点为0时不调用会员接口 | 梁崇福 | 2020-06-01 |
| 1.9.1-SNAPSHOT | 修改客如云接口名 | 海波 | 2020-06-05 | | 1.9.1-SNAPSHOT | 修改客如云接口名 | 海波 | 2020-06-05 |
| 1.9.2-SNAPSHOT| 预约单任务删除 | wuping | 2020-06-05 | | 1.9.2-SNAPSHOT| 预约单任务删除 | wuping | 2020-06-05 |
<<<<<<< HEAD
| 1.9.3-SNAPSHOT| 围餐 | dingkai | 2020-06-08 | | 1.9.3-SNAPSHOT| 围餐 | dingkai | 2020-06-08 |
| 1.9.4-SNAPSHOT| 券码接口修改为channel_code | 梁崇福 | 2020-06-08 | | 1.9.4-SNAPSHOT| 券码接口修改为channel_code | 梁崇福 | 2020-06-08 |
| 1.9.5-SNAPSHOT| 商品统计分类编号保存 | wuping | 2020-06-09 | | 1.9.5-SNAPSHOT| 商品统计分类编号保存 | wuping | 2020-06-09 |
...@@ -143,4 +142,5 @@ ...@@ -143,4 +142,5 @@
| 2.1.10-RELEASE | coco | 刘鹏飞 | 2020-12-17 | | 2.1.10-RELEASE | coco | 刘鹏飞 | 2020-12-17 |
| 2.1.11-RELEASE | 农工商添加设备号 | 梁崇福 | 2020-12-17 | | 2.1.11-RELEASE | 农工商添加设备号 | 梁崇福 | 2020-12-17 |
| 2.2.25-SNAPSHOT | 订单详情查询接口增加配送类型字段 | 张志恒 | 2020-12-23 | | 2.2.25-SNAPSHOT | 订单详情查询接口增加配送类型字段 | 张志恒 | 2020-12-23 |
\ No newline at end of file | 2.2.25-SNAPSHOT| coco定制核销优惠券 | 刘鹏飞 | 2020-12-23 |
\ No newline at end of file
...@@ -1951,7 +1951,7 @@ public class OrderSdkAdapter { ...@@ -1951,7 +1951,7 @@ public class OrderSdkAdapter {
* *
* @return * @return
*/ */
private Integer getOldOrderAccountType(int newOrderAccountType) { public Integer getOldOrderAccountType(int newOrderAccountType) {
// 新订单服务枚举 OrderSettlementType // 新订单服务枚举 OrderSettlementType
switch (newOrderAccountType) { switch (newOrderAccountType) {
case 1: case 1:
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<dependency> <dependency>
<groupId>cn.freemud</groupId> <groupId>cn.freemud</groupId>
<artifactId>assortment-ordercenter-sdk</artifactId> <artifactId>assortment-ordercenter-sdk</artifactId>
<version>2.2.22-SNAPSHOT</version> <version>2.2.25-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.freemud.application.service.sdk</groupId> <groupId>com.freemud.application.service.sdk</groupId>
......
...@@ -406,4 +406,15 @@ public class OrderController { ...@@ -406,4 +406,15 @@ public class OrderController {
return orderservice.queryOrderRider(requestVo); return orderservice.queryOrderRider(requestVo);
} }
/**
* 用户开放平台,订单支付完成回调
* @param requestVo
* @return
*/
@ApiAnnotation(logMessage = "platform/paysuccess")
@PostMapping("/platform/paysuccess")
public BaseResponse platformPaysuccess(@Validated @LogParams @RequestBody PlatformPaySuccessRequest requestVo){
return orderservice.platformPaysuccess(requestVo);
}
} }
...@@ -17,12 +17,35 @@ import lombok.Data; ...@@ -17,12 +17,35 @@ import lombok.Data;
*/ */
@Data @Data
public class CouponCodeBaseDto { public class CouponCodeBaseDto {
/**
* 版本号
*/
private Integer ver; private Integer ver;
// 71代表核销
/**
* 操作类型:71核销,0查询,3冲正
*/
private Integer reqtype; private Integer reqtype;
/**
* 商户号
*/
private String partnerId; private String partnerId;
/**
* 门店号
*/
private String store_id; private String store_id;
/**
* 线下pos编号, 除coco外,其他商户必填
*/
private String station_id; private String station_id;
/**
* 操作员编号,除coco外,其他商户必填
*/
private String operator_id; private String operator_id;
// 组织机构ID,(String 类型的集合) // 组织机构ID,(String 类型的集合)
......
...@@ -18,11 +18,30 @@ import java.util.List; ...@@ -18,11 +18,30 @@ import java.util.List;
*/ */
@Data @Data
public class CouponCodeVerificationDto extends CouponCodeBaseDto { public class CouponCodeVerificationDto extends CouponCodeBaseDto {
/**
* 流水号
*/
private String trans_id; private String trans_id;
/**
* 核销时间:yyyy-MM-dd
*/
private String business_date; private String business_date;
/**
* 渠道,例如:pickup,delivery
*/
private String channel; private String channel;
/**
* 会员编号
*/
private String memberId; private String memberId;
/**
* 核销交易信息
*/
private List<CouponCodeVerificationTransDto> transactions; private List<CouponCodeVerificationTransDto> transactions;
} }
...@@ -2,6 +2,8 @@ package cn.freemud.entities.dto; ...@@ -2,6 +2,8 @@ package cn.freemud.entities.dto;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
/** /**
* All rights Reserved, Designed By www.freemud.cn * All rights Reserved, Designed By www.freemud.cn
* *
...@@ -16,8 +18,44 @@ import lombok.Data; ...@@ -16,8 +18,44 @@ import lombok.Data;
*/ */
@Data @Data
public class CouponCodeVerificationProductDto { public class CouponCodeVerificationProductDto {
private Integer seq ;
private String pID; /**
* 核销数量
*/
private Integer consume_num ; private Integer consume_num ;
/**
* 商品编号
*/
private String pID;
/**
* BigDecimal, 暂未使用
*/
private BigDecimal redeem_price;
/**
* 商品序号或者行数
*/
private Integer seq ;
/**
* 商品名称
*/
private String productName ;
/**
* 线下原价,单位:分
*/
private Integer initPrice ;
/**
* 优惠后价格,单位:分
*/
private Integer nowPrice ;
/**
* 应收金额,单位:分
*/
private Integer payMoney ;
} }
...@@ -19,8 +19,41 @@ import java.util.List; ...@@ -19,8 +19,41 @@ import java.util.List;
*/ */
@Data @Data
public class CouponCodeVerificationTransDto { public class CouponCodeVerificationTransDto {
/**
* 券号
*/
private String code; private String code;
private String ebcode; //private String ebcode;
private Integer totalAmount;
/**
* 实收金额单位:分
*/
private Integer pay_amount;
/**
* 商品信息
*/
private List<CouponCodeVerificationProductDto> products; private List<CouponCodeVerificationProductDto> products;
/**
* 总优惠金额单位:分
*/
private Integer totalAmount;
/**
* 订单号,coco核销使用
*/
private String orderNumber;
/**
* 应收金额,单位:分,coco核销使用
*/
private Integer amountRec;
/**
* 实收金额,单位:分
*/
private Integer amountPaid;
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
package cn.freemud.entities.dto; package cn.freemud.entities.dto;
import com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderCostResp; import com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderCostResp;
import com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderSettlementResp;
import com.freemud.sdk.api.assortment.order.response.order.QueryOrdersResponse; import com.freemud.sdk.api.assortment.order.response.order.QueryOrdersResponse;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -196,6 +197,8 @@ public class QueryOrdersResponseDto { ...@@ -196,6 +197,8 @@ public class QueryOrdersResponseDto {
private List<ProductBean> productList; private List<ProductBean> productList;
private List<RefundBean> refundList; private List<RefundBean> refundList;
private List<OrderSettlementResp> orderSettlementDetailList;
private AddDeliveryInfo addInfo; private AddDeliveryInfo addInfo;
private List<OrderCostResp> orderCostDetailList; private List<OrderCostResp> orderCostDetailList;
......
package cn.freemud.entities.vo;
import lombok.Data;
import org.hibernate.validator.constraints.NotEmpty;
@Data
public class PlatformPaySuccessRequest {
@NotEmpty(message = "orderCode 不能为空")
private String orderCode;
@NotEmpty(message = "商户号 不能为空")
private String partnerId;
}
...@@ -147,4 +147,8 @@ public interface Orderservice { ...@@ -147,4 +147,8 @@ public interface Orderservice {
BaseResponse timeOutOrderRefund(TimeOutOrderVo timeOutOrderVo); BaseResponse timeOutOrderRefund(TimeOutOrderVo timeOutOrderVo);
BaseResponse queryOrderRider(OrderRiderRequestVo requestVo); BaseResponse queryOrderRider(OrderRiderRequestVo requestVo);
BaseResponse platformPaysuccess(PlatformPaySuccessRequest requestVo);
} }
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: OrderRelationFactory
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.service.coupon;
public interface CouponRelationFactory {
/**
* 获取优惠券核销参数构建实现类
* @param partnerId
* @return
*/
CouponRelationService getVerificationCouponService(String partnerId);
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: OrderRelationService
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.service.coupon;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.dto.QueryOrdersResponseDto;
import cn.freemud.entities.vo.CreateOrderVo;
import cn.freemud.entities.vo.QueryOrderResponseVo;
import cn.freemud.enums.CouponReqType;
import com.freemud.application.sdk.api.storecenter.response.StoreResponse;
import com.freemud.sdk.api.assortment.order.response.order.QueryOrderByIdResponse;
import java.util.List;
public interface CouponRelationService {
/**
* 获取优惠券核销参数构建实现类
* @param
*/
BaseResponse verificationCoupon(List<QueryOrdersResponseDto.DataBean.OrderBean.AccountBean> accountList,
QueryOrdersResponseDto.DataBean.OrderBean orderBean,
CouponReqType couponReqType);
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: OrderRelationFactoryImpl
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.service.coupon.impl;
import cn.freemud.service.coupon.CouponRelationFactory;
import cn.freemud.service.coupon.CouponRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CounponRelationFactoryImpl implements CouponRelationFactory {
/**
* coco商户
*/
@Value("#{'${coco.partnerId}'.split(',')}")
private List<String> cocoPartnerId;
/**
* coco的订单相关
*/
@Autowired
@Qualifier("cocoCouponRelationService")
CouponRelationService cocoCouponRelationService;
/**
* 平台的订单相关
*/
@Autowired
@Qualifier("platformCouponRelationService")
CouponRelationService platformCouponRelationService;
@Override
public CouponRelationService getVerificationCouponService(String partnerId) {
if(cocoPartnerId.contains(partnerId)){
return cocoCouponRelationService;
}else{
return platformCouponRelationService;
}
}
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: PlatformOrderRelationServiceImpl
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.service.coupon.impl;
import cn.freemud.adapter.CouponAdapter;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.dto.CouponCodeResponseDto;
import cn.freemud.entities.dto.CouponCodeVerificationDto;
import cn.freemud.entities.dto.CouponCodeVerificationProductDto;
import cn.freemud.entities.dto.QueryOrdersResponseDto;
import cn.freemud.entities.vo.CreateOrderVo;
import cn.freemud.entities.vo.QueryOrderResponseVo;
import cn.freemud.enums.ActivityChannelEnum;
import cn.freemud.enums.CouponReqType;
import cn.freemud.enums.OrderAccountType;
import cn.freemud.enums.ResponseResult;
import cn.freemud.service.coupon.CouponRelationFactory;
import cn.freemud.service.coupon.CouponRelationService;
import cn.freemud.service.impl.StoreServiceImpl;
import cn.freemud.service.order.OrderRelationService;
import cn.freemud.service.thirdparty.CouponOfflineClient;
import cn.freemud.utils.LogUtil;
import cn.freemud.utils.PropertyConvertUtil;
import cn.freemud.utils.ResponseUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.freemud.application.sdk.api.couponcenter.offline.service.OfflineCouponSdkService;
import com.freemud.application.sdk.api.log.ErrorLog;
import com.freemud.application.sdk.api.log.ThirdPartyLog;
import com.freemud.application.sdk.api.service.EmailAlertService;
import com.freemud.application.sdk.api.storecenter.response.StoreResponse;
import com.freemud.sdk.api.assortment.order.response.order.QueryOrderByIdResponse;
import com.google.common.base.Throwables;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service("platformCouponRelationService")
public class PlatformCouponRelationServiceImpl implements CouponRelationService {
@Autowired
private CouponAdapter couponAdapter;
@Autowired
private CouponOfflineClient couponOfflineClient;
@Autowired
private EmailAlertService emailAlertService;
@Autowired
private StoreServiceImpl storeService;
@Override
public BaseResponse verificationCoupon(List<QueryOrdersResponseDto.DataBean.OrderBean.AccountBean> accountList, QueryOrdersResponseDto.DataBean.OrderBean orderBean, CouponReqType couponReqType) {
for (QueryOrdersResponseDto.DataBean.OrderBean.AccountBean accountBean : accountList) {
List<CouponCodeVerificationProductDto> products = new ArrayList<>();
//商品券核销核销参数
if (OrderAccountType.PRODUCT_COUPON.getCode().equals(accountBean.getType())) {
for (int i = 0; i < orderBean.getProductList().size(); i++) {
QueryOrdersResponseDto.DataBean.OrderBean.ProductBean 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<QueryOrdersResponseDto.DataBean.OrderBean.ProductBean.ProductDiscount> discounts = orderBean.getProductList().get(i).getDiscountList().stream().
filter(productDiscount -> productDiscount.getDiscountId().equals(accountBean.getAccountId())).collect(Collectors.toList());
for (QueryOrdersResponseDto.DataBean.OrderBean.ProductBean.ProductDiscount 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);
products.add(couponCodeVerificationProductDto);
}
}
}
}
Integer orderType = orderBean.getType();
ActivityChannelEnum activityChannelEnum = PropertyConvertUtil.orderTypeEnumConvert2ActivityChannel(orderType);
if (activityChannelEnum == null) {
activityChannelEnum = ActivityChannelEnum.pickup;
}
if (OrderAccountType.COUPON.getCode().equals(accountBean.getType())
|| OrderAccountType.PRODUCT_COUPON.getCode().equals(accountBean.getType())
|| OrderAccountType.DISCOUNT_COUPON.getCode().equals(accountBean.getType())) {
CouponCodeVerificationDto couponCodeVerificationDto = couponAdapter.convert2CouponCodeVerificationDto(activityChannelEnum, accountBean.getAccountId(), orderBean.getOid(), orderBean.getCompanyId(), orderBean.getShopId(), orderBean.getUserId(), products, accountBean.getPrice().intValue(),couponReqType);
// 核销券新增参数:组织机构ID
couponCodeVerificationDto.setChannel_codes(storeService.getOrgIdsArr(orderBean.getCompanyId(), orderBean.getShopId()));
try {
//71.券核销
for (int i = 2; i >= 0; i--) {
LogUtil.info("核销券码开始==", JSON.toJSONString(couponCodeVerificationDto), null);
CouponCodeResponseDto couponCodeResponseDto = couponOfflineClient.verification(couponCodeVerificationDto);
LogUtil.info("核销券码返回==", JSON.toJSONString(couponCodeVerificationDto), null);
ThirdPartyLog.infoConvertJson(System.currentTimeMillis(), System.currentTimeMillis(), "/api", couponCodeVerificationDto, couponCodeResponseDto);
if (Objects.equals(couponCodeResponseDto.getStatusCode(), ResponseResult.SUCCESS.getCode())) {
LogUtil.info("CouponReverseServiceImpl", JSON.toJSONString(couponCodeVerificationDto), JSON.toJSONString(couponCodeResponseDto));
break;
}
if (!Objects.equals(couponCodeResponseDto.getStatusCode(), ResponseResult.SUCCESS.getCode())) {
emailAlertService.sendEmailAlert("核销券码失败", String.format("request:%s \r\nresponse:%s", JSONObject.toJSONString(couponCodeVerificationDto), JSONObject.toJSONString(couponCodeResponseDto)));
return ResponseUtil.error(ResponseResult.COUPON_VERIFICATION_FAIL);
}
}
} catch (Exception ex) {
emailAlertService.sendEmailAlert("核销券码异常", String.format("request:%s \r\nexception:%s", JSONObject.toJSONString(couponCodeVerificationDto), Throwables.getStackTraceAsString(ex)));
ErrorLog.printErrorLog("verification_error", "/api", couponCodeVerificationDto, ex);
return ResponseUtil.error(ResponseResult.COUPON_VERIFICATION_FAIL);
}
}
}
return ResponseUtil.success();
}
}
...@@ -9,6 +9,8 @@ import cn.freemud.entities.vo.ActivityCouponBean; ...@@ -9,6 +9,8 @@ import cn.freemud.entities.vo.ActivityCouponBean;
import cn.freemud.enums.*; import cn.freemud.enums.*;
import cn.freemud.service.CouponActivityService; import cn.freemud.service.CouponActivityService;
import cn.freemud.service.StoreService; import cn.freemud.service.StoreService;
import cn.freemud.service.coupon.CouponRelationFactory;
import cn.freemud.service.coupon.CouponRelationService;
import cn.freemud.service.thirdparty.CouponClient; import cn.freemud.service.thirdparty.CouponClient;
import cn.freemud.service.thirdparty.CouponOfflineClient; import cn.freemud.service.thirdparty.CouponOfflineClient;
import cn.freemud.utils.LogUtil; import cn.freemud.utils.LogUtil;
...@@ -29,6 +31,7 @@ import com.google.gson.Gson; ...@@ -29,6 +31,7 @@ import com.google.gson.Gson;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
...@@ -41,6 +44,12 @@ import java.util.stream.Collectors; ...@@ -41,6 +44,12 @@ import java.util.stream.Collectors;
@Service @Service
public class CouponActivityServiceImpl implements CouponActivityService { public class CouponActivityServiceImpl implements CouponActivityService {
/**
* coco商户
*/
@Value("#{'${coco.partnerId}'.split(',')}")
private List<String> cocoPartnerId;
@Autowired @Autowired
private CouponAdapter couponAdapter; private CouponAdapter couponAdapter;
@Autowired @Autowired
...@@ -52,6 +61,9 @@ public class CouponActivityServiceImpl implements CouponActivityService { ...@@ -52,6 +61,9 @@ public class CouponActivityServiceImpl implements CouponActivityService {
@Autowired @Autowired
private StoreServiceImpl storeService; private StoreServiceImpl storeService;
@Autowired
private CouponRelationFactory couponRelationFactory;
/** /**
* 核销优惠券 * 核销优惠券
* *
...@@ -63,67 +75,10 @@ public class CouponActivityServiceImpl implements CouponActivityService { ...@@ -63,67 +75,10 @@ public class CouponActivityServiceImpl implements CouponActivityService {
if (CollectionUtils.isEmpty(accountList) || CollectionUtils.isEmpty(orderBean.getProductList())) { if (CollectionUtils.isEmpty(accountList) || CollectionUtils.isEmpty(orderBean.getProductList())) {
return ResponseUtil.success(); return ResponseUtil.success();
} }
for (QueryOrdersResponseDto.DataBean.OrderBean.AccountBean accountBean : accountList) {
List<CouponCodeVerificationProductDto> products = new ArrayList<>();
//商品券核销核销参数
if (OrderAccountType.PRODUCT_COUPON.getCode().equals(accountBean.getType())) {
for (int i = 0; i < orderBean.getProductList().size(); i++) {
QueryOrdersResponseDto.DataBean.OrderBean.ProductBean 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<QueryOrdersResponseDto.DataBean.OrderBean.ProductBean.ProductDiscount> discounts = orderBean.getProductList().get(i).getDiscountList().stream().
filter(productDiscount -> productDiscount.getDiscountId().equals(accountBean.getAccountId())).collect(Collectors.toList());
for (QueryOrdersResponseDto.DataBean.OrderBean.ProductBean.ProductDiscount 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);
products.add(couponCodeVerificationProductDto);
}
}
}
}
Integer orderType = orderBean.getType(); // 平台走老的逻辑,cooc定制参数
ActivityChannelEnum activityChannelEnum = PropertyConvertUtil.orderTypeEnumConvert2ActivityChannel(orderType); CouponRelationService couponRelationService = couponRelationFactory.getVerificationCouponService(orderBean.getCompanyId());
if (activityChannelEnum == null) { return couponRelationService.verificationCoupon(accountList,orderBean,couponReqType);
activityChannelEnum = ActivityChannelEnum.pickup;
}
if (OrderAccountType.COUPON.getCode().equals(accountBean.getType())
|| OrderAccountType.PRODUCT_COUPON.getCode().equals(accountBean.getType())
|| OrderAccountType.DISCOUNT_COUPON.getCode().equals(accountBean.getType())) {
CouponCodeVerificationDto couponCodeVerificationDto = couponAdapter.convert2CouponCodeVerificationDto(activityChannelEnum, accountBean.getAccountId(), orderBean.getOid(), orderBean.getCompanyId(), orderBean.getShopId(), orderBean.getUserId(), products, accountBean.getPrice().intValue(),couponReqType);
// 核销券新增参数:组织机构ID
couponCodeVerificationDto.setChannel_codes(storeService.getOrgIdsArr(orderBean.getCompanyId(), orderBean.getShopId()));
try {
//71.券核销
for (int i = 2; i >= 0; i--) {
LogUtil.info("核销券码开始==", JSON.toJSONString(couponCodeVerificationDto), null);
CouponCodeResponseDto couponCodeResponseDto = couponOfflineClient.verification(couponCodeVerificationDto);
LogUtil.info("核销券码返回==", JSON.toJSONString(couponCodeVerificationDto), null);
ThirdPartyLog.infoConvertJson(System.currentTimeMillis(), System.currentTimeMillis(), "/api", couponCodeVerificationDto, couponCodeResponseDto);
if (Objects.equals(couponCodeResponseDto.getStatusCode(), ResponseResult.SUCCESS.getCode())) {
LogUtil.info("CouponReverseServiceImpl", JSON.toJSONString(couponCodeVerificationDto), JSON.toJSONString(couponCodeResponseDto));
break;
}
if (!Objects.equals(couponCodeResponseDto.getStatusCode(), ResponseResult.SUCCESS.getCode())) {
emailAlertService.sendEmailAlert("核销券码失败", String.format("request:%s \r\nresponse:%s", JSONObject.toJSONString(couponCodeVerificationDto), JSONObject.toJSONString(couponCodeResponseDto)));
return ResponseUtil.error(ResponseResult.COUPON_VERIFICATION_FAIL);
}
}
} catch (Exception ex) {
emailAlertService.sendEmailAlert("核销券码异常", String.format("request:%s \r\nexception:%s", JSONObject.toJSONString(couponCodeVerificationDto), Throwables.getStackTraceAsString(ex)));
ErrorLog.printErrorLog("verification_error", "/api", couponCodeVerificationDto, ex);
return ResponseUtil.error(ResponseResult.COUPON_VERIFICATION_FAIL);
}
}
}
return ResponseUtil.success();
} }
@Override @Override
......
...@@ -58,6 +58,8 @@ import cn.freemud.interceptor.ServiceException; ...@@ -58,6 +58,8 @@ import cn.freemud.interceptor.ServiceException;
import cn.freemud.management.thirdparty.MulitiPaymentClient; import cn.freemud.management.thirdparty.MulitiPaymentClient;
import cn.freemud.redis.RedisCache; import cn.freemud.redis.RedisCache;
import cn.freemud.service.*; import cn.freemud.service.*;
import cn.freemud.service.coupon.CouponRelationFactory;
import cn.freemud.service.coupon.CouponRelationService;
import cn.freemud.service.order.OrderRelationFactory; import cn.freemud.service.order.OrderRelationFactory;
import cn.freemud.service.order.OrderRelationService; import cn.freemud.service.order.OrderRelationService;
import cn.freemud.service.thirdparty.*; import cn.freemud.service.thirdparty.*;
......
...@@ -758,7 +758,6 @@ public class ShoppingCartConvertAdapter { ...@@ -758,7 +758,6 @@ public class ShoppingCartConvertAdapter {
productComboType = parentProductBean.getProductComboList().stream().filter(p -> ObjectUtils.equals(comboxGoods.getGoodsId(), p.getProductId())).findFirst().orElse(new ProductTypeBeanDTO.ProductComboType()); productComboType = parentProductBean.getProductComboList().stream().filter(p -> ObjectUtils.equals(comboxGoods.getGoodsId(), p.getProductId())).findFirst().orElse(new ProductTypeBeanDTO.ProductComboType());
} else { } else {
Map<String, ProductTypeBeanDTO.ProductGroupType.GroupDetailType> map = new HashMap<>(); Map<String, ProductTypeBeanDTO.ProductGroupType.GroupDetailType> map = new HashMap<>();
// subProductTypeMap.get(comboxGoods.getSkuId()).getAdditionalGroupList().stream().map(t->t.getGroupDetail()).forEach(group->group.forEach(detailType-> map.put(detailType.getProductId(),detailType)));
parentProductBean.getProductGroupList().stream().map(t -> t.getGroupDetail()).forEach(group -> group.forEach(detailType -> map.put(detailType.getProductId(), detailType))); parentProductBean.getProductGroupList().stream().map(t -> t.getGroupDetail()).forEach(group -> group.forEach(detailType -> map.put(detailType.getProductId(), detailType)));
groupDetailType = map.get(comboxGoods.getGoodsId()); groupDetailType = map.get(comboxGoods.getGoodsId());
} }
...@@ -800,26 +799,26 @@ public class ShoppingCartConvertAdapter { ...@@ -800,26 +799,26 @@ public class ShoppingCartConvertAdapter {
comboxGoods.getProductMaterialList().stream().forEach(materialGood -> materialList.add(materialMap.get(materialGood.getSpuId()))); comboxGoods.getProductMaterialList().stream().forEach(materialGood -> materialList.add(materialMap.get(materialGood.getSpuId())));
List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods> productMaterialList = new ArrayList<>(); List<com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods> productMaterialList = new ArrayList<>();
Long materialAmount = 0L;
Long originalMaterAmount = 0L;
if (CollectionUtils.isNotEmpty(materialList)){ if (CollectionUtils.isNotEmpty(materialList)){
for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType detailType : materialList) { for (ProductTypeBeanDTO.ProductGroupType.GroupDetailType detailType : materialList) {
com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods(); com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods();
materialGoods.setCustomerCode(StringUtils.isNotEmpty(detailType.getCustomerCode()) ? materialGoods.setCustomerCode(StringUtils.isNotEmpty(detailType.getCustomerCode()) ? detailType.getCustomerCode() : "");
detailType.getCustomerCode() : ""); materialGoods.setAmount(null != detailType.getMarkUpPrice() ? detailType.getMarkUpPrice().longValue() : 0);
materialGoods.setAmount(null != detailType.getMarkUpPrice() ? materialGoods.setFinalPrice(null != detailType.getProductFinalPrice() ? detailType.getProductFinalPrice().longValue() : 0);
detailType.getMarkUpPrice().longValue() : 0); materialGoods.setSpuName(StringUtils.isNotEmpty(detailType.getProductName()) ? detailType.getProductName() : "");
materialGoods.setFinalPrice(null != detailType.getProductFinalPrice() ? materialGoods.setSpuId(StringUtils.isNotEmpty(detailType.getProductId()) ? detailType.getProductId() : "");
detailType.getProductFinalPrice().longValue() : 0); materialGoods.setOriginalPrice(null != detailType.getProductFinalPrice() ? detailType.getProductFinalPrice().longValue() : 0);
materialGoods.setSpuName(StringUtils.isNotEmpty(detailType.getProductName()) ? materialGoods.setOriginalAmount(null != detailType.getProductFinalPrice() ? detailType.getProductFinalPrice().longValue() * comboxGoods.getQty() : 0);
detailType.getProductName() : "");
materialGoods.setSpuId(StringUtils.isNotEmpty(detailType.getProductId()) ?
detailType.getProductId() : "");
materialGoods.setOriginalPrice(null != detailType.getProductFinalPrice() ?
detailType.getProductFinalPrice().longValue() : 0);
materialGoods.setOriginalAmount(null != detailType.getProductFinalPrice() ?
detailType.getProductFinalPrice().longValue() : 0);
productMaterialList.add(materialGoods); productMaterialList.add(materialGoods);
materialAmount += detailType.getProductFinalPrice().longValue() * comboxGoods.getQty();
originalMaterAmount += detailType.getProductFinalPrice().longValue() * comboxGoods.getQty();
} }
} }
comboxGoods.setMaterialAmount(materialAmount);
comboxGoods.setProductMaterialList(productMaterialList); comboxGoods.setProductMaterialList(productMaterialList);
} }
} }
...@@ -839,7 +838,9 @@ public class ShoppingCartConvertAdapter { ...@@ -839,7 +838,9 @@ public class ShoppingCartConvertAdapter {
private void checkMaterialProductForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, ProductTypeBeanDTO spuProduct) { private void checkMaterialProductForMCoffee(com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods cartGoods, ProductTypeBeanDTO spuProduct) {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return; if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) {
return;
}
//加料信息为空 //加料信息为空
if (CollectionUtils.isEmpty(spuProduct.getAdditionalGroupList())) { if (CollectionUtils.isEmpty(spuProduct.getAdditionalGroupList())) {
checkSkuMaterialProductForMccafe(cartGoods,spuProduct); checkSkuMaterialProductForMccafe(cartGoods,spuProduct);
...@@ -868,7 +869,9 @@ public class ShoppingCartConvertAdapter { ...@@ -868,7 +869,9 @@ public class ShoppingCartConvertAdapter {
String materialSubName = cartGoods.getSubName(); String materialSubName = cartGoods.getSubName();
for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) { for (com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
ProductTypeBeanDTO.ProductGroupType.GroupDetailType detail = materialHash.get(materialGoods.getSpuId()); ProductTypeBeanDTO.ProductGroupType.GroupDetailType detail = materialHash.get(materialGoods.getSpuId());
if (detail == null) continue; if (detail == null) {
continue;
}
com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods material = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods(); com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods material = new com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoods.MaterialGoods();
material.setSpuName(detail.getProductName()); material.setSpuName(detail.getProductName());
material.setSpuId(detail.getProductId()); material.setSpuId(detail.getProductId());
...@@ -960,6 +963,11 @@ public class ShoppingCartConvertAdapter { ...@@ -960,6 +963,11 @@ public class ShoppingCartConvertAdapter {
} }
} }
} }
//可选商品组加料价格加到购物车行记录上
Long materialAmount =
cartGoods.getProductGroupList().stream().mapToLong(group -> (null != group.getMaterialAmount() ? group.getMaterialAmount() : 0)).sum();
cartGoods.setOriginalMaterialAmount(materialAmount);
cartGoods.setMaterialAmount(materialAmount);
} }
} }
//更新当前商品行价格 //更新当前商品行价格
...@@ -987,12 +995,16 @@ public class ShoppingCartConvertAdapter { ...@@ -987,12 +995,16 @@ public class ShoppingCartConvertAdapter {
cartGoods.setWeight(isSkuProduct ? skuProduct.getWeight() : spuProduct.getWeight()); cartGoods.setWeight(isSkuProduct ? skuProduct.getWeight() : spuProduct.getWeight());
cartGoods.setUnit(isSkuProduct ? skuProduct.getUnit() : spuProduct.getUnit()); cartGoods.setUnit(isSkuProduct ? skuProduct.getUnit() : spuProduct.getUnit());
cartGoods.setWeightType(CommonsConstant.WEIGHT_PRODUCT.equals(spuProduct.getWeightType())); cartGoods.setWeightType(CommonsConstant.WEIGHT_PRODUCT.equals(spuProduct.getWeightType()));
cartGoods.setMaterialAmount(0L); if (null == cartGoods.getMaterialAmount()) {
cartGoods.setOriginalMaterialAmount(0L); cartGoods.setMaterialAmount(0L);
}
if (null == cartGoods.getOriginalMaterialAmount()) {
cartGoods.setOriginalMaterialAmount(0L);
}
// todo 设置加料 // todo 设置加料
this.checkMaterialProductForMCoffee(cartGoods, spuProduct); this.checkMaterialProductForMCoffee(cartGoods, spuProduct);
} catch (Exception ex) { } catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
ErrorLog.infoConvertJson(this.getClass(), "updateCartGoodsInfoForMCoffee_Error", ex); ErrorLog.infoConvertJson(this.getClass(), "updateCartGoodsInfoForMCoffee_Error", ex);
cartGoods.setCartGoodsUid(null); cartGoods.setCartGoodsUid(null);
} }
......
...@@ -118,6 +118,19 @@ public class ShoppingCartMccafeAdapter { ...@@ -118,6 +118,19 @@ public class ShoppingCartMccafeAdapter {
return cartGoodsDetailDtos; return cartGoodsDetailDtos;
} }
/**
* @param cartGoods
* @return
*/
public List<ShoppingCartGoodsDto.CartGoodsDetailDto> convertCartGoods2DetailGoodsList(CartGoods cartGoods, List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods> apportionGoodsList, Map<String, String> duplicateGoodsMap) {
List<ShoppingCartGoodsDto.CartGoodsDetailDto> cartGoodsDetailDtos = new ArrayList<>();
if (StringUtils.isEmpty(cartGoods.getCouponCode()) && GoodsTypeEnum.SET_MEAL_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
return cartGoodsDetailDtos;
} else {
cartGoodsDetailDtos.add(convertCartGoods2DetailGoods(cartGoods, apportionGoodsList, duplicateGoodsMap));
}
return cartGoodsDetailDtos;
}
/** /**
* @param cartGoods * @param cartGoods
...@@ -267,4 +280,4 @@ public class ShoppingCartMccafeAdapter { ...@@ -267,4 +280,4 @@ public class ShoppingCartMccafeAdapter {
} }
cartGoodsDetailDto.setActivityDiscountsDtos(activityDiscountsDtoList); cartGoodsDetailDto.setActivityDiscountsDtos(activityDiscountsDtoList);
} }
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package cn.freemud.service.impl.mcoffee.calculation; ...@@ -2,6 +2,7 @@ package cn.freemud.service.impl.mcoffee.calculation;
import cn.freemud.adapter.ActivityAdapter; import cn.freemud.adapter.ActivityAdapter;
import cn.freemud.adapter.ShoppingCartConvertAdapter; import cn.freemud.adapter.ShoppingCartConvertAdapter;
import cn.freemud.adapter.ShoppingCartMccafeAdapter;
import cn.freemud.base.entity.BaseResponse; import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.ResponseCodeConstant; import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
...@@ -12,7 +13,6 @@ import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; ...@@ -12,7 +13,6 @@ import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityChannelEnum; import cn.freemud.enums.ActivityChannelEnum;
import cn.freemud.enums.ActivityTypeEnum; import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.enums.GoodsTypeEnum;
import cn.freemud.enums.ResponseResult; import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException; import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.CommonService; import cn.freemud.service.CommonService;
...@@ -24,9 +24,7 @@ import com.freemud.application.sdk.api.log.LogThreadLocal; ...@@ -24,9 +24,7 @@ import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest; import com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest;
import com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse; import com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse;
import com.freemud.application.sdk.api.membercenter.service.MemberCenterService; import com.freemud.application.sdk.api.membercenter.service.MemberCenterService;
import com.freemud.application.sdk.api.storecenter.request.QueryDeliveryRequest;
import com.freemud.application.sdk.api.storecenter.request.StoreInfoRequest; import com.freemud.application.sdk.api.storecenter.request.StoreInfoRequest;
import com.freemud.application.sdk.api.storecenter.response.QueryDeliverDetailResponse;
import com.freemud.application.sdk.api.storecenter.response.StoreResponse; import com.freemud.application.sdk.api.storecenter.response.StoreResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService; import com.freemud.application.sdk.api.storecenter.service.StoreCenterService;
import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum; import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum;
...@@ -81,8 +79,9 @@ public class CalculationServiceImpl { ...@@ -81,8 +79,9 @@ public class CalculationServiceImpl {
@Autowired @Autowired
private MaterialCalculation materialCalculation; private MaterialCalculation materialCalculation;
@Autowired @Autowired
private ShoppingCartConvertAdapter shoppingCartConvertAdapter; private ShoppingCartMccafeAdapter shoppingCartMccafeAdapter;
/** /**
* 更新购物车行优惠信息 * 更新购物车行优惠信息
...@@ -205,7 +204,8 @@ public class CalculationServiceImpl { ...@@ -205,7 +204,8 @@ public class CalculationServiceImpl {
}); });
for (int i = 0, len = cartGoodsList.size(); i < len; i++) { for (int i = 0, len = cartGoodsList.size(); i < len; i++) {
CartGoods cartGoods = cartGoodsList.get(i); CartGoods cartGoods = cartGoodsList.get(i);
List<ShoppingCartGoodsDto.CartGoodsDetailDto> cartGoodsDetailDtos = shoppingCartConvertAdapter.convertCartGoods2DetailGoodsList(cartGoods, apportionGoodsList,duplicateGoodsMap); // List<ShoppingCartGoodsDto.CartGoodsDetailDto> cartGoodsDetailDtos = shoppingCartConvertAdapter.convertCartGoods2DetailGoodsList(cartGoods, apportionGoodsList,duplicateGoodsMap);
List<ShoppingCartGoodsDto.CartGoodsDetailDto> cartGoodsDetailDtos = shoppingCartMccafeAdapter.convertCartGoods2DetailGoodsList(cartGoods, apportionGoodsList,duplicateGoodsMap);
cartGoodsDetailDtoList.addAll(cartGoodsDetailDtos); cartGoodsDetailDtoList.addAll(cartGoodsDetailDtos);
} }
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discounts = calculationDiscountResult == null ? new ArrayList<>() : calculationDiscountResult.getDiscounts(); List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discounts = calculationDiscountResult == null ? new ArrayList<>() : calculationDiscountResult.getDiscounts();
...@@ -510,7 +510,7 @@ public class CalculationServiceImpl { ...@@ -510,7 +510,7 @@ public class CalculationServiceImpl {
//单品、多规格加料 //单品、多规格加料
if(CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())){ if(CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())){
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()){ for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()){
materialPrice+= materialGoods.getFinalPrice() * cartGoods.getQty(); materialPrice+= (null != materialGoods.getFinalPrice() ? materialGoods.getFinalPrice() : 0) * (null != cartGoods.getQty() ? cartGoods.getQty() : 0);
} }
} }
return materialPrice; return materialPrice;
......
...@@ -92,6 +92,21 @@ public class SetMealCalculation { ...@@ -92,6 +92,21 @@ public class SetMealCalculation {
} }
} }
//套餐可选商品加料
if(CollectionUtils.isNotEmpty(cartGoods.getProductGroupList())){
for (CartGoods.ComboxGoods comboxGoods : cartGoods.getProductGroupList()){
Long productGroupmaterialPrice = 0L;
if(CollectionUtils.isNotEmpty(comboxGoods.getProductMaterialList())){
for (CartGoods.MaterialGoods materialGoods : comboxGoods.getProductMaterialList()){
productGroupmaterialPrice+= null != materialGoods.getFinalPrice() ? materialGoods.getFinalPrice() * cartGoods.getQty() : 0;
}
}
comboxGoods.setAmount((null == comboxGoods.getAmount() ? 0 :
comboxGoods.getAmount())+productGroupmaterialPrice);
materialPrice = materialPrice + productGroupmaterialPrice;
}
}
Long amount = null != cartGoods.getFinalPrice() ? cartGoods.getFinalPrice()*cartGoods.getQty() + productGroupTotalAmount + materialPrice : Long amount = null != cartGoods.getFinalPrice() ? cartGoods.getFinalPrice()*cartGoods.getQty() + productGroupTotalAmount + materialPrice :
productGroupTotalAmount + productComboTotalAmount + materialPrice; productGroupTotalAmount + productComboTotalAmount + materialPrice;
......
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