Commit f8a74900 by roamer

Merge branch 'refs/heads/feature/box/三方券订单退款退券' into develop

parents 3a6702f9 da6f7ab5
...@@ -267,6 +267,16 @@ public class OrderController { ...@@ -267,6 +267,16 @@ public class OrderController {
return ResponseUtil.success(); return ResponseUtil.success();
} }
/**
* 退款预校验
*/
@ApiAnnotation(logMessage = "退款预校验")
@PostMapping("/preValidRefund")
public BaseResponse<Void> preValidRefund(@Validated @LogParams @RequestBody PreValidRefundReq reqVo) {
refundService.preValidRefund(reqVo.getPartnerId(), reqVo.getOrderCode(), reqVo.getRefundMode());
return ResponseUtil.success();
}
/** /**
* 获取订单排队号 * 获取订单排队号
......
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: GetProductVo
* @Package cn.freemud.entities.vo
* @Description:
* @author: liming.guo
* @date: 2018/5/16 17:35
* @version V1.0
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.vo;
import com.freemud.application.sdk.api.ordercenter.enums.RefundModeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 退款预校验参数
*
* @author haibo.jiang 2019/11/20
* @author shichang.wang 2021/4/15
*/
@ApiModel("退款预校验参数")
@Data
public class PreValidRefundReq {
@NotBlank(message = "商户号为空")
private String partnerId;
@NotBlank(message = "订单号为空")
private String orderCode;
/**
* 微商城退款方式
*
* @see RefundModeEnum#getIndex()
*/
@ApiModelProperty(value = "微商城退款方式", notes = RefundModeEnum.API_DOC)
private Byte refundMode;
}
...@@ -96,7 +96,7 @@ public class RefundService { ...@@ -96,7 +96,7 @@ public class RefundService {
private final OrderCouponHandle orderCouponHandle; private final OrderCouponHandle orderCouponHandle;
private final ThirdCouponOrderHandle thirdCouponOrderHandle; private final ThirdCouponOrderHandle thirdCouponOrderHandle;
private OrderInfoReqs preValidRefund(String partnerId, String orderCode, Byte refundMode) { public OrderInfoReqs preValidRefund(String partnerId, String orderCode, Byte refundMode) {
// 查询订单信息 // 查询订单信息
QueryByCodeResponse orderResp = orderSdkService.getOrderInfo(partnerId, orderCode); QueryByCodeResponse orderResp = orderSdkService.getOrderInfo(partnerId, orderCode);
if (null == orderResp || null == orderResp.getResult()) throw new ServiceException("订单信息不存在"); if (null == orderResp || null == orderResp.getResult()) throw new ServiceException("订单信息不存在");
...@@ -126,7 +126,7 @@ public class RefundService { ...@@ -126,7 +126,7 @@ public class RefundService {
} }
// 如果券没有冲正,判断核销时间,默认使用订单的创建时间 // 如果券没有冲正,判断核销时间,默认使用订单的创建时间
if (!coupon.isCanceled()) { if (!coupon.isCanceled()) {
if (ThirdCouponOrderHandle.isCancelTimeout(new Date(Long.parseLong(order.getCreateTime())), coupon.getEcologyChannelType())) { if (ThirdCouponOrderHandle.isCancelTimeout(coupon, new Date(Long.parseLong(order.getCreateTime())))) {
throw new ServiceException("三方券核销时间过长,无法申请退款"); throw new ServiceException("三方券核销时间过长,无法申请退款");
} }
} }
...@@ -457,7 +457,7 @@ public class RefundService { ...@@ -457,7 +457,7 @@ public class RefundService {
boolean couponUsed = couponQueryHandle.isCouponUsed(partnerId, couponCodes); boolean couponUsed = couponQueryHandle.isCouponUsed(partnerId, couponCodes);
if (couponUsed) { if (couponUsed) {
throw new ServiceException("识别到您已使用过该券包中的部分或全部券,故不支持退款。"); throw new ServiceException("已使用券包中的部分或全部券,故不支持退款。");
} }
// 冻结券 // 冻结券
boolean freeze = orderCouponHandle.freezeCodes(partnerId, orderInfo.getUserId(), couponCodes, "买券订单退款"); boolean freeze = orderCouponHandle.freezeCodes(partnerId, orderInfo.getUserId(), couponCodes, "买券订单退款");
......
...@@ -113,12 +113,22 @@ public class ThirdCouponOrderHandle { ...@@ -113,12 +113,22 @@ public class ThirdCouponOrderHandle {
* @param channelTypeEnum * @param channelTypeEnum
* @return * @return
*/ */
public static boolean isCancelTimeout(Date redeemDate, @Nullable EcologyChannelTypeEnum channelTypeEnum) { public static boolean isCancelTimeout(ThirdCouponOrderHandle.ThirdCouponDto couponDto, @Nullable Date redeemDate) {
EcologyChannelTypeEnum channelTypeEnum = couponDto.getEcologyChannelType();
if (redeemDate == null) {
redeemDate = couponDto.getRedeemTime();
}
if (EcologyChannelTypeEnum.MEITUAN.equals(channelTypeEnum)) { if (EcologyChannelTypeEnum.MEITUAN.equals(channelTypeEnum)) {
// 美团券不能超过 60天 // 商家核销的美团券不能超过 60天,自助核销的美团券不能超过 24小时
if (DateUtil.addDays(redeemDate, 60).compareTo(new Date()) < 0) { if (DateUtil.addDays(redeemDate, 60).compareTo(new Date()) < 0) {
return true; return true;
} }
// 如果不是逗号分隔的纯数字,认为是加密券号(自助核销的券号是加密的)
if (couponDto.getCouponCodes().stream().anyMatch(code -> !code.matches("^[0-9,]+$"))) {
if (redeemDate.getTime() + 24 * 3600_000 < System.currentTimeMillis()) {
return true;
}
}
} else if (EcologyChannelTypeEnum.TIKTOK.equals(channelTypeEnum)) { } else if (EcologyChannelTypeEnum.TIKTOK.equals(channelTypeEnum)) {
// 抖音券不能超过 1 小时(3600秒) // 抖音券不能超过 1 小时(3600秒)
if (redeemDate.getTime() + 3600_000 < System.currentTimeMillis()) { if (redeemDate.getTime() + 3600_000 < System.currentTimeMillis()) {
...@@ -192,7 +202,7 @@ public class ThirdCouponOrderHandle { ...@@ -192,7 +202,7 @@ public class ThirdCouponOrderHandle {
if (coupon.isCanceled()) { if (coupon.isCanceled()) {
return; return;
} }
if (ThirdCouponOrderHandle.isCancelTimeout(coupon.getRedeemTime(), coupon.getEcologyChannelType())) { if (ThirdCouponOrderHandle.isCancelTimeout(coupon, null)) {
throw new RuntimeException("核销时间超过可冲正期限,撤销核销失败"); throw new RuntimeException("核销时间超过可冲正期限,撤销核销失败");
} }
// 美团、抖音平台三方券 // 美团、抖音平台三方券
......
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