|
@@ -17,6 +17,7 @@ import org.dromara.backstage.api.domain.vo.RemoteUserAccountVo;
|
|
|
import org.dromara.common.core.constant.ApiErrorTypeConstants;
|
|
import org.dromara.common.core.constant.ApiErrorTypeConstants;
|
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.domain.model.ErrorInfo;
|
|
import org.dromara.common.core.domain.model.ErrorInfo;
|
|
|
|
|
+import org.dromara.common.core.enums.UserAccountStatusEnum;
|
|
|
import org.dromara.common.core.utils.RecordIdUtils;
|
|
import org.dromara.common.core.utils.RecordIdUtils;
|
|
|
import org.dromara.server.common.domain.consume.bo.ConsumptionBo;
|
|
import org.dromara.server.common.domain.consume.bo.ConsumptionBo;
|
|
|
import org.dromara.server.consume.domain.vo.PtBagVo;
|
|
import org.dromara.server.consume.domain.vo.PtBagVo;
|
|
@@ -89,7 +90,7 @@ public class CheckBusiness {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 消费记录人员、卡片检查,一切通过后获取到消费账户、卡片及设备的视图信息
|
|
|
|
|
|
|
+ * 消费记录人员、卡片检查,全部通过后获取到消费账户、卡片及设备的视图信息
|
|
|
*
|
|
*
|
|
|
* @param bo 消费记录
|
|
* @param bo 消费记录
|
|
|
* @param userAccountVo 消费账户
|
|
* @param userAccountVo 消费账户
|
|
@@ -104,6 +105,7 @@ public class CheckBusiness {
|
|
|
long factoryId = ObjectUtil.isEmpty(bo.getFactoryId()) ? 0 : bo.getFactoryId();
|
|
long factoryId = ObjectUtil.isEmpty(bo.getFactoryId()) ? 0 : bo.getFactoryId();
|
|
|
long userNo = ObjectUtil.isEmpty(bo.getUserNo()) ? 0 : bo.getUserNo();
|
|
long userNo = ObjectUtil.isEmpty(bo.getUserNo()) ? 0 : bo.getUserNo();
|
|
|
String userNumb = bo.getUserNumb() == null ? null : bo.getUserNumb();
|
|
String userNumb = bo.getUserNumb() == null ? null : bo.getUserNumb();
|
|
|
|
|
+ // 获取设备信息
|
|
|
if (termNo > 0) {
|
|
if (termNo > 0) {
|
|
|
R<ErrorInfo> result = checkTerm(bo, useTermVo);
|
|
R<ErrorInfo> result = checkTerm(bo, useTermVo);
|
|
|
if (R.isError(result)) {
|
|
if (R.isError(result)) {
|
|
@@ -158,14 +160,37 @@ public class CheckBusiness {
|
|
|
* @param useTermVo 消费设备
|
|
* @param useTermVo 消费设备
|
|
|
* @return 验证结果
|
|
* @return 验证结果
|
|
|
*/
|
|
*/
|
|
|
- public R<ErrorInfo> checkConsume(ConsumptionBo bo, RemoteUserAccountVo userAccountVo, RemoteCardVo userCardVo,
|
|
|
|
|
- XfTermVo useTermVo) {
|
|
|
|
|
- // TODO 2024-11-03 14:36:42 luoyibo 1.获取传入的参数
|
|
|
|
|
- // TODO 2024-11-03 14:36:42 luoyibo 2.卡有效性验证
|
|
|
|
|
- // TODO 2024-11-03 14:39:21 luoyibo 3.消费账户状态验证
|
|
|
|
|
- // TODO 2024-11-03 14:39:49 luoyibo 4.餐类验证
|
|
|
|
|
- // TODO 2024-11-03 14:41:28 luoyibo 5.折扣\限额\限次验证
|
|
|
|
|
- // TODO 2024-11-03 14:45:18 luoyibo 6.根据消费机的消费模式验证余额
|
|
|
|
|
|
|
+ public R<ErrorInfo> checkConsume(ConsumptionBo bo, RemoteUserAccountVo userAccountVo, RemoteCardVo userCardVo, XfTermVo useTermVo) {
|
|
|
|
|
+ R<ErrorInfo> result;
|
|
|
|
|
+ // 1.消费账户状态验证,验证账户是否已开户、是否冻结、状态是否正常、是否过有效期
|
|
|
|
|
+ if ("Y".equals(userAccountVo.getFreezeStatus())) {
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "账户已被冻结", "账户已被冻结"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("N".equals(userAccountVo.getStatus())) {
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "账户状态不正常", "账户状态不正常"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!ObjectUtil.equal(userAccountVo.getAccountStatus(), UserAccountStatusEnum.IS_OPEN.code().toString())) {
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "账户尚未开户", "账户尚未开户"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (userAccountVo.getLifespan() != null && bo.getConsumeDate().getTime() > userAccountVo.getLifespan().getTime()) {
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "账户已过有效期", "账户已过有效期"));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 2.餐类验证
|
|
|
|
|
+ RemoteMealTypeVo mealType = remoteMealTypeService.queryMealTypeVoByTime(bo.getConsumeDate());
|
|
|
|
|
+ if (ObjectUtil.isEmpty(mealType)) {
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "不在交易时段", "不在交易时段"));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 3.折扣\限额\限次验证
|
|
|
|
|
+ Boolean b = checkLimitDeal(bo, userAccountVo, useTermVo, userCardVo, mealType);
|
|
|
|
|
+ if (!b) {
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, ApiErrorTypeConstants.NOT_FOUND, "消费限制判断存在问题", "消费限制判断存在问题"));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 4.根据消费机的消费模式验证余额,如果余额不足则返回
|
|
|
|
|
+ List<PtBagVo> bagVos = new ArrayList<>();
|
|
|
|
|
+ result = checkDeductionBag(bo, userAccountVo, useTermVo, bagVos);
|
|
|
|
|
+ if (R.isError(result)) {
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -223,11 +248,12 @@ public class CheckBusiness {
|
|
|
|
|
|
|
|
return R.fail(errorInfo);
|
|
return R.fail(errorInfo);
|
|
|
}
|
|
}
|
|
|
- if (!Objects.equals(cardVo.getFactoryId(), bo.getFactoryId())) {
|
|
|
|
|
- errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片不正确",
|
|
|
|
|
- "物理卡号不一致,不允许交易");
|
|
|
|
|
|
|
+ if (bo.getFactoryId() > 0) {
|
|
|
|
|
+ if (!Objects.equals(cardVo.getFactoryId(), bo.getFactoryId())) {
|
|
|
|
|
+ errorInfo = new ErrorInfo(400, ApiErrorTypeConstants.PARAM_ERROR, "卡片不正确", "物理卡号不一致,不允许交易");
|
|
|
|
|
|
|
|
- return R.fail(errorInfo);
|
|
|
|
|
|
|
+ return R.fail(errorInfo);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
RemoteUserAccountVo accountVo = remoteUserAccountService.getUserAccountVoById(cardVo.getUserId());
|
|
RemoteUserAccountVo accountVo = remoteUserAccountService.getUserAccountVoById(cardVo.getUserId());
|
|
|
setUserInfo(bo, accountVo);
|
|
setUserInfo(bo, accountVo);
|
|
@@ -349,9 +375,8 @@ public class CheckBusiness {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public R<ErrorInfo> checkDeductionBag(ConsumptionBo bo, RemoteUserAccountVo userAccountVo, XfTermVo termVo,
|
|
|
|
|
- List<PtBagVo> bagVos) {
|
|
|
|
|
- // 设备的扣费钱包串
|
|
|
|
|
|
|
+ public R<ErrorInfo> checkDeductionBag(ConsumptionBo bo, RemoteUserAccountVo userAccountVo, XfTermVo termVo, List<PtBagVo> bagVos) {
|
|
|
|
|
+ // 设备的扣费钱包字符串
|
|
|
String consumeType = termVo.getConsumeType();
|
|
String consumeType = termVo.getConsumeType();
|
|
|
// 分解扣费钱包
|
|
// 分解扣费钱包
|
|
|
List<String> bagCodes = StrUtil.split(consumeType, ",");
|
|
List<String> bagCodes = StrUtil.split(consumeType, ",");
|
|
@@ -399,6 +424,31 @@ public class CheckBusiness {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public Boolean checkLimitDeal(ConsumptionBo bo, RemoteUserAccountVo userAccountVo, XfTermVo termVo, RemoteCardVo userCardVo,
|
|
|
|
|
+ RemoteMealTypeVo mealTypeVo) {
|
|
|
|
|
+ Long termNo = termVo.getTermNo();
|
|
|
|
|
+ String mealTypeId = mealTypeVo.getTypeId();
|
|
|
|
|
+ if (termNo == 0 && ObjectUtil.equal("0", mealTypeId)) {
|
|
|
|
|
+ return Boolean.TRUE;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 设备允许卡类
|
|
|
|
|
+ Integer termCardTypeId = termVo.getCardType() == null ? 0 : termVo.getCardType();
|
|
|
|
|
+ // 设备每天最大消费次数
|
|
|
|
|
+ Integer termDayCount = termVo.getDayCount() == null ? 0 : termVo.getDayCount();
|
|
|
|
|
+ // 每天最大消费金额
|
|
|
|
|
+ BigDecimal termDayMoney = termVo.getDayMoney() == null ? BigDecimal.ZERO : termVo.getDayMoney();
|
|
|
|
|
+ // 每餐最大消费次数
|
|
|
|
|
+ Integer termmealCount = termVo.getMealCount() == null ? 0 : termVo.getMealCount();
|
|
|
|
|
+ // 单次最大消费金额
|
|
|
|
|
+ BigDecimal termSignleMoney = termVo.getSingleMoney() == null ? BigDecimal.ZERO : termVo.getSingleMoney();
|
|
|
|
|
+ // 二次可用最大时间间隔
|
|
|
|
|
+ Integer termSwipeInterval = termVo.getSwipeInterval() == null ? 0 : termVo.getSwipeInterval();
|
|
|
|
|
+ // 设备是否启用了卡有效
|
|
|
|
|
+ Boolean termUseValidity = Objects.equals(termVo.getTermValidity(), "0") ? Boolean.FALSE : Boolean.TRUE;
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private RemoteOperatorVo getOperatorVo(ConsumptionBo bo) {
|
|
private RemoteOperatorVo getOperatorVo(ConsumptionBo bo) {
|
|
|
RemoteOperatorVo operatorVo = remoteOperatorService.getVoById(bo.getOperatorId());
|
|
RemoteOperatorVo operatorVo = remoteOperatorService.getVoById(bo.getOperatorId());
|
|
|
if (ObjectUtil.isEmpty(operatorVo)) {
|
|
if (ObjectUtil.isEmpty(operatorVo)) {
|