|
@@ -3,6 +3,7 @@ package org.dromara.server.consume.business;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
@@ -181,9 +182,9 @@ public class CheckBusiness {
|
|
|
return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "不在交易时段", "不在交易时段"));
|
|
return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "不在交易时段", "不在交易时段"));
|
|
|
}
|
|
}
|
|
|
// 3.折扣\限额\限次验证
|
|
// 3.折扣\限额\限次验证
|
|
|
- Boolean b = checkLimitDeal(bo, userAccountVo, useTermVo, userCardVo, mealType);
|
|
|
|
|
- if (!b) {
|
|
|
|
|
- return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "消费限制判断存在问题", "消费限制判断存在问题"));
|
|
|
|
|
|
|
+ result = checkLimitDeal(bo, userAccountVo, useTermVo, userCardVo, mealType);
|
|
|
|
|
+ if (R.isError(result)) {
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "消费限制判断存在问题", JSONUtil.toJsonStr(result.getData())));
|
|
|
}
|
|
}
|
|
|
// 4.根据消费机的消费模式验证余额,如果余额不足则返回
|
|
// 4.根据消费机的消费模式验证余额,如果余额不足则返回
|
|
|
List<PtBagVo> bagVos = new ArrayList<>();
|
|
List<PtBagVo> bagVos = new ArrayList<>();
|
|
@@ -424,15 +425,17 @@ public class CheckBusiness {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public Boolean checkLimitDeal(ConsumptionBo bo, RemoteUserAccountVo userAccountVo, XfTermVo termVo, RemoteCardVo userCardVo,
|
|
|
|
|
- RemoteMealTypeVo mealTypeVo) {
|
|
|
|
|
|
|
+ public R<ErrorInfo> checkLimitDeal(ConsumptionBo bo, RemoteUserAccountVo userAccountVo, XfTermVo termVo, RemoteCardVo userCardVo,
|
|
|
|
|
+ RemoteMealTypeVo mealTypeVo) {
|
|
|
Long termNo = termVo.getTermNo();
|
|
Long termNo = termVo.getTermNo();
|
|
|
String mealTypeId = mealTypeVo.getTypeId();
|
|
String mealTypeId = mealTypeVo.getTypeId();
|
|
|
if (termNo == 0 && ObjectUtil.equal("0", mealTypeId)) {
|
|
if (termNo == 0 && ObjectUtil.equal("0", mealTypeId)) {
|
|
|
- return Boolean.TRUE;
|
|
|
|
|
|
|
+ return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
+ // 当前卡片类型
|
|
|
|
|
+ int cardTypeId = userCardVo.getCardType().intValue();
|
|
|
// 设备允许卡类
|
|
// 设备允许卡类
|
|
|
- Integer termCardTypeId = termVo.getCardType() == null ? 0 : termVo.getCardType();
|
|
|
|
|
|
|
+ int termCardTypeId = termVo.getCardType() == null ? 0 : termVo.getCardType();
|
|
|
// 设备每天最大消费次数
|
|
// 设备每天最大消费次数
|
|
|
Integer termDayCount = termVo.getDayCount() == null ? 0 : termVo.getDayCount();
|
|
Integer termDayCount = termVo.getDayCount() == null ? 0 : termVo.getDayCount();
|
|
|
// 每天最大消费金额
|
|
// 每天最大消费金额
|
|
@@ -446,7 +449,11 @@ public class CheckBusiness {
|
|
|
// 设备是否启用了卡有效
|
|
// 设备是否启用了卡有效
|
|
|
Boolean termUseValidity = Objects.equals(termVo.getTermValidity(), "0") ? Boolean.FALSE : Boolean.TRUE;
|
|
Boolean termUseValidity = Objects.equals(termVo.getTermValidity(), "0") ? Boolean.FALSE : Boolean.TRUE;
|
|
|
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ int offsetTypeId = (int) Math.pow(2, (cardTypeId - 1));
|
|
|
|
|
+ if ((offsetTypeId & termCardTypeId) != offsetTypeId) {
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, type, "卡类限制", ""));
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private RemoteOperatorVo getOperatorVo(ConsumptionBo bo) {
|
|
private RemoteOperatorVo getOperatorVo(ConsumptionBo bo) {
|