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

[POS][修改]:券核销类型检查及核销券后剩余金额处理

release_toaliyun_real
Stormeye Wu 6 лет назад
Родитель
Сommit
1c674c02bc
3 измененных файлов: 58 добавлений и 15 удалений
  1. +1
    -1
      mallinkPosApi/src/main/java/com/iformall/controller/PosController.java
  2. +55
    -14
      mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java
  3. +2
    -0
      mallinkService/src/main/java/com/iformall/pay/WxPayConstant.java

+ 1
- 1
mallinkPosApi/src/main/java/com/iformall/controller/PosController.java Просмотреть файл

@@ -107,7 +107,7 @@ public class PosController extends BaseController {
"\"bu_user_id\":\"string(必填)\"," +
"\"coupon_order_id\":\"string(必填)\"," +
"\"nonce_str\":\"string(必填)\"," +
"\"verify\":\"independent, pay(必填)\"," +
"\"verify_type\":\"independent, pay(必填)\"," +
"\"pos_order_id\":\"string(选填)\"," +
"\"pos_amount\":\"单位(分)(选填)\"}")
@PostMapping("/checkCouponOrderForVerify")


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

@@ -224,6 +224,7 @@ public class PosServiceImpl implements PosService {
String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID
String merchantIdStr = params.get(WxPayConstant.MERCHANT_ID); // 商户ID
String buUserIdStr = params.get(WxPayConstant.BUSER_ID); // POS操作员ID
String verifyType = params.get(WxPayConstant.VERIFY_TYPE); // 核销类型
String couponOrderIdStr = params.get(WxPayConstant.COUPON_ORDER_ID); // 券ID
String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID
String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单总额(单位:分)
@@ -246,6 +247,20 @@ public class PosServiceImpl implements PosService {
String errMessage = "request params[coupon_order_id] error.";
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage);
}
if (actionType.equals(EnumVerifyActionType.CHECK)) {
if (StringUtils.isBlank(verifyType)) {
String errMessage = "request params[verify_type] error.";
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage);
}
if ((!verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_INDEPENT) || verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_PAY))) {
String errMessage = "request params[verify_type] only support independent or pay.";
throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), errMessage);
}
} else if (actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT)) {
verifyType = WxPayConstant.VERIFY_INDEPENT;
} else if (actionType.equals(EnumVerifyActionType.VERIFY_PAY)) {
verifyType = WxPayConstant.VERIFY_PAY;
}
if (actionType.equals(EnumVerifyActionType.PRE_VERIFY) ||
actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT) ||
actionType.equals(EnumVerifyActionType.VERIFY_PAY)) {
@@ -304,7 +319,8 @@ public class PosServiceImpl implements PosService {
JSONArray coRetArr = new JSONArray();
if (couponOrderIdStr != null) {
try {
Map<String,String> oneRetMap = doVerifyActionForOneCouponOrder(actionType,
Map<String,String> oneRetMap = doVerifyActionForOneCouponOrder(
actionType, verifyType,
tenantId, merchantIdStr, merchantId,
buUserIdStr, buUserId,
posOrderIdStr, posOrderId, posAmount,
@@ -329,6 +345,7 @@ public class PosServiceImpl implements PosService {
String posOrderIdStr = params.get(WxPayConstant.POS_ORDER_ID); // POS订单ID
String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单总额(单位:分)
String selCoListStr = params.get(WxPayConstant.SELECTED_COUPON_ORDER_LIST); // 选中的优惠券列表
String verifyType = WxPayConstant.VERIFY_PAY; // 此接口只有支付使用

if (StringUtils.isBlank(tenantId)) {
String errMessage = "request params[tenant_id] error.";
@@ -406,7 +423,8 @@ public class PosServiceImpl implements PosService {
String couponOrderIdStr = selCoArr.getString(i);
if (couponOrderIdStr != null) {
try {
Map<String,String> oneRetMap = doVerifyActionForOneCouponOrder(actionType,
Map<String,String> oneRetMap = doVerifyActionForOneCouponOrder(
actionType, verifyType,
tenantId, merchantIdStr, merchantId,
buUserIdStr, buUserId,
posOrderIdStr, posOrderId, posAmount,
@@ -425,7 +443,7 @@ public class PosServiceImpl implements PosService {
}

private Map<String, String> doVerifyActionForOneCouponOrder(
EnumVerifyActionType actionType,
EnumVerifyActionType actionType, String verifyType,
String tenantId, String merchantIdStr, Long merchantId,
String buUserIdStr, Long buUserId,
String posOrderIdStr, Long posOrderId, Integer posAmount,
@@ -484,6 +502,25 @@ public class PosServiceImpl implements PosService {
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)) {
@@ -523,10 +560,6 @@ public class PosServiceImpl implements PosService {
return retMap;
}
} else if (actionType.equals(EnumVerifyActionType.PRE_VERIFY)) {
if (couponOrderCVo.getPrice() > posAmount) {
logger.error(ErrorCode.VERIFY_PRE_POS_ORDER_PRICE_ISSUE.getMessage());
throw new MallinkException(ErrorCode.VERIFY_PRE_POS_ORDER_PRICE_ISSUE);
}
if (!(couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MULTIMCH) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_MANJIAN) ||
couponOrderCVo.getCouponType().equals(EnumCouponType.COUPON_DAIJIN)
@@ -551,20 +584,28 @@ public class PosServiceImpl implements PosService {
logger.error(ErrorCode.VERIFY_PRE_POS_ORDER_NOT_EQUAL.getMessage() + ": " + posOrderIdStr);
throw new MallinkException(ErrorCode.VERIFY_PRE_POS_ORDER_NOT_EQUAL);
}
Integer remainAmount = posAmount - couponOrderCVo.getPrice();
if (remainAmount < 0) {
remainAmount = 0;
}
retMap.put(WxPayConstant.ID, couponOrderIdStr);
retMap.put(WxPayConstant.PRE_VERIFY, "true");
retMap.put(WxPayConstant.DEDUCT_AMOUNT, String.valueOf(couponOrderCVo.getPrice()));
retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(posAmount - couponOrderCVo.getPrice()));
retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(remainAmount));
return retMap;
}
if (couponOrderCVo.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode())) {
logger.info("券可以被预核销: " + couponOrderIdStr);
try {
doPreVerify(couponOrderCVo, buUserId, posOrderId);
Integer remainAmount = posAmount - couponOrderCVo.getPrice();
if (remainAmount < 0) {
remainAmount = 0;
}
retMap.put(WxPayConstant.ID, couponOrderIdStr);
retMap.put(WxPayConstant.PRE_VERIFY, "true");
retMap.put(WxPayConstant.DEDUCT_AMOUNT, String.valueOf(couponOrderCVo.getPrice()));
retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(posAmount - couponOrderCVo.getPrice()));
retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(remainAmount));
return retMap;
} catch (MallinkException e) {
logger.error(e.getMessage());
@@ -594,10 +635,6 @@ public class PosServiceImpl implements PosService {
logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage());
throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT);
}
if (couponOrderCVo.getPrice() > posAmount) {
logger.error(ErrorCode.VERIFY_PRE_POS_ORDER_PRICE_ISSUE.getMessage());
throw new MallinkException(ErrorCode.VERIFY_PRE_POS_ORDER_PRICE_ISSUE);
}
}
boolean blVerify = false;
if (couponOrderCVo.getCouponOrderStatus().equals(EnumCouponOrderStatus.POS_PRE_VERIFY.getCode())) {
@@ -625,10 +662,14 @@ public class PosServiceImpl implements PosService {
if (blVerify) {
try {
doVerify(couponOrderCVo, wxCoupon, merchantId, buUserId, posOrderId, retMap);
Integer remainAmount = posAmount - couponOrderCVo.getPrice();
if (remainAmount < 0) {
remainAmount = 0;
}
retMap.put(WxPayConstant.ID, couponOrderIdStr);
retMap.put(WxPayConstant.VERIFY, "true");
retMap.put(WxPayConstant.DEDUCT_AMOUNT, String.valueOf(couponOrderCVo.getPrice()));
retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(posAmount - couponOrderCVo.getPrice()));
retMap.put(WxPayConstant.REMAIN_AMOUNT, String.valueOf(remainAmount));
return retMap;
} catch (MallinkException e) {
logger.error(e.getMessage());


+ 2
- 0
mallinkService/src/main/java/com/iformall/pay/WxPayConstant.java Просмотреть файл

@@ -28,6 +28,8 @@ public class WxPayConstant {
public final static String MEM_ID = "mem_id";
public final static String MEM_PHONE = "mem_phone";
public final static String VERIFY_TYPE = "verify_type";
public final static String VERIFY_INDEPENT = "independent";
public final static String VERIFY_PAY = "pay";

public final static String REG_QRCODE_URL = "qrcode_url";
public final static String POS_QRCODE_RULE = "pos_qrcode_rule";


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