|
|
@@ -90,7 +90,7 @@ public class CheckBusiness {
|
|
|
// 检查交易人员标识
|
|
|
if (bo.getCardNo() <= 0 && bo.getFactoryId() == 0 && bo.getUserNo() <= 0 && StrUtil.isEmpty(bo.getUserNumb())) {
|
|
|
errorInfo = new ErrorInfo(1, ApiErrorTypeConstants.PARAM_ERROR, "交易人员标识不满足",
|
|
|
- "必须提供 [CardNo | FactoryId | userNo | userNumb] 中至少1项来标识交易用户");
|
|
|
+ "必须提供 [CardNo | FactoryId | userNo | userNumb] 中至少1项来标识交易用户");
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
return R.ok();
|
|
|
@@ -98,7 +98,8 @@ public class CheckBusiness {
|
|
|
|
|
|
/**
|
|
|
* 检查校验码
|
|
|
- * @param bo 消费信息
|
|
|
+ *
|
|
|
+ * @param bo 消费信息
|
|
|
* @param mac 校验码
|
|
|
* @return 检查结果
|
|
|
*/
|
|
|
@@ -108,7 +109,7 @@ public class CheckBusiness {
|
|
|
TermToken token = tokenManager.getTermToken().get(String.valueOf(termNo));
|
|
|
if (ObjectUtil.isEmpty(token)) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.INVALID_TOKEN, "Token不存在",
|
|
|
- MessageFormat.format("没有找到机号为[{0}]的设备的Token!",termNo));
|
|
|
+ MessageFormat.format("没有找到机号为[{0}]的设备的Token!", termNo));
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
if (ObjectUtil.isNotEmpty(mac)) {
|
|
|
@@ -117,6 +118,7 @@ public class CheckBusiness {
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 消费记录人员、卡片检查,全部通过后获取到消费账户、卡片及设备的视图信息
|
|
|
*
|
|
|
@@ -161,7 +163,7 @@ public class CheckBusiness {
|
|
|
XfTermVo termVo = termService.queryVoOneByNo(termNo);
|
|
|
if (ObjectUtil.isEmpty(termVo)) {
|
|
|
ErrorInfo errorInfo = new ErrorInfo(400, "", "设备不存在",
|
|
|
- MessageFormat.format("机号为[{0}]的设备不存在,不允许交易", termNo));
|
|
|
+ MessageFormat.format("机号为[{0}]的设备不存在,不允许交易", termNo));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
@@ -256,13 +258,13 @@ public class CheckBusiness {
|
|
|
RemoteCardVo cardVo = remoteCardService.queryCardByCardNo(cardNo);
|
|
|
if (ObjectUtil.isEmpty(cardVo)) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片不存在",
|
|
|
- MessageFormat.format("流水号为[{0}]的卡片不存在,不允许交易", cardNo));
|
|
|
+ MessageFormat.format("流水号为[{0}]的卡片不存在,不允许交易", cardNo));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
if (!"1".equals(cardVo.getStatus())) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片状态不正确",
|
|
|
- MessageFormat.format("流水号为[{0}]的卡片状态不正确,不允许交易", cardNo));
|
|
|
+ MessageFormat.format("流水号为[{0}]的卡片状态不正确,不允许交易", cardNo));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
@@ -288,14 +290,14 @@ public class CheckBusiness {
|
|
|
RemoteCardVo cardVo = remoteCardService.queryCardByFactoryId(factoryId);
|
|
|
if (ObjectUtil.isEmpty(cardVo)) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片不存在",
|
|
|
- MessageFormat.format("物理卡号为[{0}]的卡片不存在,不允许交易", factoryId));
|
|
|
+ MessageFormat.format("物理卡号为[{0}]的卡片不存在,不允许交易", factoryId));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
if (!"1".equals(cardVo.getStatus())) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片状态不正确",
|
|
|
- MessageFormat.format("物理卡号为[{0}]的卡片卡片状态不正确,不允许交易",
|
|
|
- factoryId));
|
|
|
+ MessageFormat.format("物理卡号为[{0}]的卡片卡片状态不正确,不允许交易",
|
|
|
+ factoryId));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
@@ -314,20 +316,20 @@ public class CheckBusiness {
|
|
|
RemoteUserAccountVo accountVo = remoteUserAccountService.getUserAccountVoByUserNo(userNo);
|
|
|
if (ObjectUtil.isEmpty(accountVo)) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "人员不存在",
|
|
|
- MessageFormat.format("流水号为[{0}]的人员不存在,不允许交易", userNo));
|
|
|
+ MessageFormat.format("流水号为[{0}]的人员不存在,不允许交易", userNo));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
RemoteCardVo cardVo = remoteCardService.queryMainCardByUserId(accountVo.getUserId());
|
|
|
if (ObjectUtil.isEmpty(cardVo)) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片不存在",
|
|
|
- MessageFormat.format("流水号为[{0}]的人员卡片不存在,不允许交易", userNo));
|
|
|
+ MessageFormat.format("流水号为[{0}]的人员卡片不存在,不允许交易", userNo));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
if (!"1".equals(cardVo.getStatus())) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片状态不正确",
|
|
|
- MessageFormat.format("流水号为[{0}]的人员卡片状态不正确,不允许交易", userNo));
|
|
|
+ MessageFormat.format("流水号为[{0}]的人员卡片状态不正确,不允许交易", userNo));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
@@ -347,20 +349,20 @@ public class CheckBusiness {
|
|
|
|
|
|
if (ObjectUtil.isEmpty(accountVo)) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "人员不存在",
|
|
|
- MessageFormat.format("编号为[{0}]的人员不存在,不允许交易", userNumb));
|
|
|
+ MessageFormat.format("编号为[{0}]的人员不存在,不允许交易", userNumb));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
RemoteCardVo cardVo = remoteCardService.queryMainCardByUserId(accountVo.getUserId());
|
|
|
if (ObjectUtil.isEmpty(cardVo)) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片不存在",
|
|
|
- MessageFormat.format("编号为[{0}]的人员卡片不存在,不允许交易", userNumb));
|
|
|
+ MessageFormat.format("编号为[{0}]的人员卡片不存在,不允许交易", userNumb));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
if (!"1".equals(cardVo.getStatus())) {
|
|
|
errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片状态不正确",
|
|
|
- MessageFormat.format("编号为[{0}]的人员卡片状态不正确,不允许交易", userNumb));
|
|
|
+ MessageFormat.format("编号为[{0}]的人员卡片状态不正确,不允许交易", userNumb));
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
|
@@ -376,18 +378,18 @@ public class CheckBusiness {
|
|
|
|
|
|
private R<ErrorInfo> checkOriginalRecord(ConsumptionBo bo) {
|
|
|
String originalId = RecordIdUtils.getRecordId(bo.getConsumeDate(), bo.getTermNo().shortValue(),
|
|
|
- bo.getTermRecordId().shortValue(), bo.getUserNo().intValue(), 0);
|
|
|
+ bo.getTermRecordId().shortValue(), bo.getUserNo().intValue(), 0);
|
|
|
XfConsumeDetailOriginalVo consumeDetailOriginalVo = consumeDetailOriginalService.queryById(originalId);
|
|
|
if (ObjectUtil.isEmpty(consumeDetailOriginalVo)) {
|
|
|
// TODO 正常应该是进行记录类型和脱机消费的检查,此处先按错误处理
|
|
|
return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "原始消费记录不存在",
|
|
|
- MessageFormat.format("标识为[{0}]的原始消费记录不存在", bo.getRecordId())));
|
|
|
+ MessageFormat.format("标识为[{0}]的原始消费记录不存在", bo.getRecordId())));
|
|
|
}
|
|
|
XfConsumeDetailVo consumeDetailVo = consumeDetailService.queryVoByOriginalId(originalId);
|
|
|
if (ObjectUtil.isNotEmpty(consumeDetailVo)) {
|
|
|
// 认为是重复上传,不再入账
|
|
|
return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.RECORD_IS_EXISTS, "原始消费记录已处理",
|
|
|
- MessageFormat.format("标识为[{0}]的原始消费记录已处理", bo.getRecordId())));
|
|
|
+ MessageFormat.format("标识为[{0}]的原始消费记录已处理", bo.getRecordId())));
|
|
|
}
|
|
|
bo.setOriginalId(originalId);
|
|
|
return R.ok();
|
|
|
@@ -435,15 +437,15 @@ public class CheckBusiness {
|
|
|
if (doMoney.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
// 循环扣费后,如果还有未扣的金额,表示钱包余额不足,不允许交易
|
|
|
return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.CONSUME_CHECK_FAIL, "钱包余额不足",
|
|
|
- MessageFormat.format("余额不足,余额[{0}],消费金额[{1}]", totalBalance,
|
|
|
- consumeMoney)));
|
|
|
+ MessageFormat.format("余额不足,余额[{0}],消费金额[{1}]", totalBalance,
|
|
|
+ consumeMoney)));
|
|
|
}
|
|
|
bo.setBalance(totalBalance.subtract(consumeMoney));
|
|
|
bagVos.addAll(doBagVos);
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
- public R<ErrorInfo> checkTermLimitDeal(ConsumptionBo bo, RemoteUserAccountVo userAccountVo, XfTermVo termVo, RemoteCardVo userCardVo,RemoteMealTypeVo mealTypeVo) {
|
|
|
+ public R<ErrorInfo> checkTermLimitDeal(ConsumptionBo bo, RemoteUserAccountVo userAccountVo, XfTermVo termVo, RemoteCardVo userCardVo, RemoteMealTypeVo mealTypeVo) {
|
|
|
Long termNo = termVo.getTermNo();
|
|
|
BigDecimal consumeValue = bo.getConsumeMoney();
|
|
|
Long factoryFixId = userCardVo.getFactoryId();
|
|
|
@@ -478,7 +480,7 @@ public class CheckBusiness {
|
|
|
|
|
|
// 设备消费间隔验证
|
|
|
if ((currentLocalDt.toEpochSecond(ZoneOffset.of("+8"))
|
|
|
- - lastPayLocalDt.toEpochSecond(ZoneOffset.of("+8"))) / 60 < termSwipeInterval && termSwipeInterval > 0) {// 消费间隔
|
|
|
+ - lastPayLocalDt.toEpochSecond(ZoneOffset.of("+8"))) / 60 < termSwipeInterval && termSwipeInterval > 0) {// 消费间隔
|
|
|
return R.fail(new ErrorInfo(400, TradeStatusEnum.TimeInterval.toString(), "超过设备单次限额", TradeStatusEnum.TimeInterval.getName()));
|
|
|
}
|
|
|
// 设备单次限额验证
|
|
|
@@ -499,8 +501,8 @@ public class CheckBusiness {
|
|
|
String lastMeal = userCardVo.getLastMeal().toString();
|
|
|
int mealCount = userCardVo.getMealCount().intValue();
|
|
|
BigDecimal mealValue = userCardVo.getMealTotal();
|
|
|
- if (!ObjectUtil.equals(lastMeal,mealTypeId)
|
|
|
- || !currentLocalDt.toLocalDate().isEqual(lastPayLocalDt.toLocalDate())) {
|
|
|
+ if (!ObjectUtil.equals(lastMeal, mealTypeId)
|
|
|
+ || !currentLocalDt.toLocalDate().isEqual(lastPayLocalDt.toLocalDate())) {
|
|
|
remoteCardService.initCardMealData(userCardVo.getCardNo(), mealTypeId);
|
|
|
lastMeal = mealTypeId;
|
|
|
mealCount = 0;
|
|
|
@@ -519,7 +521,7 @@ public class CheckBusiness {
|
|
|
dayCount = 0;
|
|
|
dayValue = BigDecimal.ZERO;
|
|
|
} else {
|
|
|
- if (termDayCount > 0 && dayCount >= termDayCount) {// 20190417:改为>=号,因为大于号会导致消费可以多刷一次
|
|
|
+ if (termDayCount > 0 && dayCount >= termDayCount) {
|
|
|
return R.fail(new ErrorInfo(400, TradeStatusEnum.DayLimitTimes.toString(), "日限次", TradeStatusEnum.DayLimitTimes.getName()));
|
|
|
}
|
|
|
if (termDayMoney.compareTo(BigDecimal.ZERO) > 0 && termDayMoney.compareTo(dayValue.add(consumeValue)) < 0) {
|
|
|
@@ -529,6 +531,10 @@ public class CheckBusiness {
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ public R<ErrorInfo> checkCardLimitDeal(ConsumptionBo bo, XfTermVo termVo, RemoteCardVo userCardVo, RemoteMealTypeVo mealTypeVo){
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
private RemoteOperatorVo getOperatorVo(ConsumptionBo bo) {
|
|
|
RemoteOperatorVo operatorVo = remoteOperatorService.getVoById(bo.getOperatorId());
|
|
|
if (ObjectUtil.isEmpty(operatorVo)) {
|