Просмотр исходного кода

[POS][修改]:券预核销及预核销取消

release_toaliyun_real
Stormeye Wu 6 лет назад
Родитель
Сommit
948607c38c
2 измененных файлов: 69 добавлений и 80 удалений
  1. +66
    -77
      mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java
  2. +3
    -3
      mallinkPosApi/src/test/java/com/iformall/pos/test/PosAppTest.java

+ 66
- 77
mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java Просмотреть файл

@@ -510,15 +510,67 @@ public class PosServiceImpl implements PosService {
logger.error(ErrorCode.COUPON_ORDER_IS_NULL.getMessage() + ": " + couponOrderIdStr);
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}
// 4.1 检查券类型
if (actionType.equals(EnumVerifyActionType.CHECK)) {
if (verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_INDEPENT)) {
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_LIPIN.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_PRESS.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_GROUP.getCode())
)) {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
}
if (verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_PAY)) {
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_DAIJIN.getCode())
)) {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
}
} else if (actionType.equals(EnumVerifyActionType.PRE_VERIFY) || actionType.equals(EnumVerifyActionType.VERIFY_PAY)) {
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_DAIJIN.getCode())
)) {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
if (couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN.getCode())) {
if (posAmount < couponOrderCVo.getUsePrice()) {
logger.error(ErrorCode.VERIFY_MANJIAN_USER_PRICE_NOT_TOUCH.getMessage());
throw new MallinkException(ErrorCode.VERIFY_MANJIAN_USER_PRICE_NOT_TOUCH);
}
}
} else if (actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT)) {
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_LIPIN.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_PRESS.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_GROUP.getCode())
)) {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
}

Long couponOrderId = couponOrderCVo.getId();

// 5. get coupon
WxCoupon wxCoupon = couponMapper.selectByPrimaryKey(couponOrderCVo.getCouponId());
if (wxCoupon == null) {
logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
// 4.2. 券包状态检查
if (couponOrderCVo.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) {
logger.error("已过期: couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME);
}
if (couponOrderCVo.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()) {
logger.error("已作废: couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID);
}
if (couponOrderCVo.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()) {
logger.error("已经核销过的券: couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED);
}

Long couponOrderId = couponOrderCVo.getId();

// 5. 检查有效期
if (couponOrderCVo.getValidStartDate() != null && couponOrderCVo.getValidEndDate() != null) {
@@ -543,39 +595,7 @@ public class PosServiceImpl implements PosService {
throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL);
}

// 7. 券包状态检查
if (couponOrderCVo.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) {
logger.error("已过期: couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME);
}
if (couponOrderCVo.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()) {
logger.error("已作废: couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID);
}
if (couponOrderCVo.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()) {
logger.error("已经核销过的券: couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED);
}
if (actionType.equals(EnumVerifyActionType.CHECK)) {
if (verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_INDEPENT)) {
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_LIPIN.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_PRESS.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_GROUP.getCode())
)) {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
}
if (verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_PAY)) {
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_DAIJIN.getCode())
)) {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
}
if (couponOrderCVo.getCouponOrderStatus().equals(EnumCouponOrderStatus.POS_PRE_VERIFY.getCode())) {
logger.info("券已被预核销: " + couponOrderIdStr);
if (!couponOrderCVo.getBUserId().equals(buUserId)) {
@@ -615,19 +635,6 @@ public class PosServiceImpl implements PosService {
return retMap;
}
} else if (actionType.equals(EnumVerifyActionType.PRE_VERIFY)) {
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_DAIJIN)
)) {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
if (couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN)) {
if (posAmount < couponOrderCVo.getUsePrice()) {
logger.error(ErrorCode.VERIFY_MANJIAN_USER_PRICE_NOT_TOUCH.getMessage());
throw new MallinkException(ErrorCode.VERIFY_MANJIAN_USER_PRICE_NOT_TOUCH);
}
}
if (couponOrderCVo.getCouponOrderStatus().equals(EnumCouponOrderStatus.POS_PRE_VERIFY.getCode())) {
logger.info("券已被预核销: " + couponOrderIdStr);
if (!couponOrderCVo.getBUserId().equals(buUserId)) {
@@ -678,31 +685,6 @@ public class PosServiceImpl implements PosService {
}
} else {
// if (actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT ) ||actionType.equals(EnumVerifyActionType.VERIFY_PAY))
if (actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT)) {
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_LIPIN.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_PRESS.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_GROUP.getCode())
)) {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
}
if (actionType.equals(EnumVerifyActionType.VERIFY_PAY)) {
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN.getCode()) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_DAIJIN.getCode())
)) {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
if (couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN)) {
if (posAmount < couponOrderCVo.getUsePrice()) {
logger.error(ErrorCode.VERIFY_MANJIAN_USER_PRICE_NOT_TOUCH.getMessage());
throw new MallinkException(ErrorCode.VERIFY_MANJIAN_USER_PRICE_NOT_TOUCH);
}
}
}
boolean blVerify = false;
if (couponOrderCVo.getCouponOrderStatus().equals(EnumCouponOrderStatus.POS_PRE_VERIFY.getCode())) {
logger.info("券已被预核销: " + couponOrderIdStr);
@@ -727,6 +709,13 @@ public class PosServiceImpl implements PosService {
blVerify = true;
}
if (blVerify) {
// 5. get coupon
WxCoupon wxCoupon = couponMapper.selectByPrimaryKey(couponOrderCVo.getCouponId());
if (wxCoupon == null) {
logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrderCVo.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}

try {
doVerify(actionType, couponOrderCVo, wxCoupon, merchantId, buUserId, posOrderId, retMap);
Integer remainAmount = posAmount - couponOrderCVo.getPrice();


+ 3
- 3
mallinkPosApi/src/test/java/com/iformall/pos/test/PosAppTest.java Просмотреть файл

@@ -199,7 +199,7 @@ public class PosAppTest {
reqObj.put(WxPayConstant.TENANT_ID, tenantId);
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId);
reqObj.put(WxPayConstant.BUSER_ID, buUserId);
reqObj.put(WxPayConstant.COUPON_ORDER_ID, "321878123232591872");
reqObj.put(WxPayConstant.COUPON_ORDER_ID, "321878223800205312");
reqObj.put(WxPayConstant.NONCE_STR, "1");
reqObj.put(WxPayConstant.VERIFY_TYPE, "pay");
reqObj.put(WxPayConstant.POS_ORDER_ID, "1");
@@ -280,7 +280,7 @@ public class PosAppTest {
reqObj.put(WxPayConstant.TENANT_ID, tenantId);
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId);
reqObj.put(WxPayConstant.BUSER_ID, buUserId);
reqObj.put(WxPayConstant.COUPON_ORDER_ID, "318978990426783744");
reqObj.put(WxPayConstant.COUPON_ORDER_ID, "321878223800205312");
reqObj.put(WxPayConstant.NONCE_STR, "1");
reqObj.put(WxPayConstant.POS_ORDER_ID, "1");
reqObj.put(WxPayConstant.POS_AMOUNT, "200");
@@ -307,7 +307,7 @@ public class PosAppTest {
reqObj.put(WxPayConstant.TENANT_ID, tenantId);
reqObj.put(WxPayConstant.MERCHANT_ID, merchantId);
reqObj.put(WxPayConstant.BUSER_ID, buUserId);
reqObj.put(WxPayConstant.COUPON_ORDER_ID, "318978990426783744");
reqObj.put(WxPayConstant.COUPON_ORDER_ID, "321878223800205312");
reqObj.put(WxPayConstant.NONCE_STR, "1");
reqObj.put(WxPayConstant.POS_ORDER_ID, "1");
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey));


Загрузка…
Отмена
Сохранить