|
@@ -27,7 +27,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
|
-import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
import java.time.ZoneOffset;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -506,34 +505,27 @@ public class CheckBusiness {
|
|
|
// 餐限次验证
|
|
// 餐限次验证
|
|
|
String lastMeal = userCardVo.getLastMeal().toString();
|
|
String lastMeal = userCardVo.getLastMeal().toString();
|
|
|
int mealCount = userCardVo.getMealCount().intValue();
|
|
int mealCount = userCardVo.getMealCount().intValue();
|
|
|
- BigDecimal mealValue = userCardVo.getMealTotal();
|
|
|
|
|
if (!ObjectUtil.equals(lastMeal, mealTypeId)
|
|
if (!ObjectUtil.equals(lastMeal, mealTypeId)
|
|
|
|| !currentLocalDt.toLocalDate().isEqual(lastPayLocalDt.toLocalDate())) {
|
|
|| !currentLocalDt.toLocalDate().isEqual(lastPayLocalDt.toLocalDate())) {
|
|
|
|
|
+ // 如果当前餐类!=消费餐类,初始化卡片的餐类消费数据
|
|
|
remoteCardService.initCardMealData(userCardVo.getCardNo(), mealTypeId);
|
|
remoteCardService.initCardMealData(userCardVo.getCardNo(), mealTypeId);
|
|
|
- lastMeal = mealTypeId;
|
|
|
|
|
- mealCount = 0;
|
|
|
|
|
- mealValue = BigDecimal.ZERO;
|
|
|
|
|
} else {
|
|
} else {
|
|
|
if (termMealCount != 0 && mealCount >= termMealCount) {
|
|
if (termMealCount != 0 && mealCount >= termMealCount) {
|
|
|
- return R.fail(new ErrorInfo(400, TradeStatusEnum.MealLimitTimes.toString(), "餐限次", TradeStatusEnum.MealLimitTimes.getName()));
|
|
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, TradeStatusEnum.MealLimitTimes.toString(), "设备餐限次", TradeStatusEnum.MealLimitTimes.getName()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 日限次 日限额效验(每日第一次消费)
|
|
// 日限次 日限额效验(每日第一次消费)
|
|
|
int dayCount = userCardVo.getDayCount().intValue();
|
|
int dayCount = userCardVo.getDayCount().intValue();
|
|
|
BigDecimal dayValue = userCardVo.getDayTotal();
|
|
BigDecimal dayValue = userCardVo.getDayTotal();
|
|
|
-
|
|
|
|
|
- LocalDate t1 = currentLocalDt.toLocalDate();
|
|
|
|
|
- LocalDate t2 = lastPayLocalDt.toLocalDate();
|
|
|
|
|
if (!currentLocalDt.toLocalDate().isEqual(lastPayLocalDt.toLocalDate())) {
|
|
if (!currentLocalDt.toLocalDate().isEqual(lastPayLocalDt.toLocalDate())) {
|
|
|
|
|
+ // 如果当前日期!=消费日期,初始化卡片的日消费数据
|
|
|
remoteCardService.initCardDayData(userCardVo.getCardNo());
|
|
remoteCardService.initCardDayData(userCardVo.getCardNo());
|
|
|
- dayCount = 0;
|
|
|
|
|
- dayValue = BigDecimal.ZERO;
|
|
|
|
|
} else {
|
|
} else {
|
|
|
if (termDayCount > 0 && dayCount >= termDayCount) {
|
|
if (termDayCount > 0 && dayCount >= termDayCount) {
|
|
|
- return R.fail(new ErrorInfo(400, TradeStatusEnum.DayLimitTimes.toString(), "日限次", TradeStatusEnum.DayLimitTimes.getName()));
|
|
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, TradeStatusEnum.DayLimitTimes.toString(), "设备日限次", TradeStatusEnum.DayLimitTimes.getName()));
|
|
|
}
|
|
}
|
|
|
if (termDayMoney.compareTo(BigDecimal.ZERO) > 0 && termDayMoney.compareTo(dayValue.add(consumeValue)) < 0) {
|
|
if (termDayMoney.compareTo(BigDecimal.ZERO) > 0 && termDayMoney.compareTo(dayValue.add(consumeValue)) < 0) {
|
|
|
- return R.fail(new ErrorInfo(400, TradeStatusEnum.DayLimitMoney.toString(), "日限额", TradeStatusEnum.DayLimitMoney.getName()));
|
|
|
|
|
|
|
+ return R.fail(new ErrorInfo(400, TradeStatusEnum.DayLimitMoney.toString(), "设备日限额", TradeStatusEnum.DayLimitMoney.getName()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
R<ErrorInfo> result = checkCardLimitDeal(bo, termVo, userCardVo, mealTypeVo);
|
|
R<ErrorInfo> result = checkCardLimitDeal(bo, termVo, userCardVo, mealTypeVo);
|
|
@@ -547,48 +539,24 @@ public class CheckBusiness {
|
|
|
LocalDateTime currentLocalDt = LocalDateTime.now();
|
|
LocalDateTime currentLocalDt = LocalDateTime.now();
|
|
|
Long cardNo = userCardVo.getCardNo();
|
|
Long cardNo = userCardVo.getCardNo();
|
|
|
Long mealTypeId = Long.valueOf(mealTypeVo.getTypeId());
|
|
Long mealTypeId = Long.valueOf(mealTypeVo.getTypeId());
|
|
|
|
|
+ Date lastPayDate = userCardVo.getLastPay();
|
|
|
|
|
+ // 获取卡片的限制信息
|
|
|
XfCardLimitedVo cardLimitedVo = cardLimitedService.queryByCardNo(cardNo);
|
|
XfCardLimitedVo cardLimitedVo = cardLimitedService.queryByCardNo(cardNo);
|
|
|
if (ObjectUtil.isEmpty(cardLimitedVo)) {
|
|
if (ObjectUtil.isEmpty(cardLimitedVo)) {
|
|
|
- cardLimitedVo = initXfCardLimited(cardNo, mealTypeVo.getMealId(), userCardVo);
|
|
|
|
|
- }
|
|
|
|
|
- // 每天限制消费次数
|
|
|
|
|
- Long dayLimitCount = cardLimitedVo.getDayCount();
|
|
|
|
|
- // 每餐限制消费次数
|
|
|
|
|
- Long mealLimitCount = cardLimitedVo.getMealCount();
|
|
|
|
|
- // 每天限制消费金额
|
|
|
|
|
- BigDecimal dayLimitValue = cardLimitedVo.getDayMoney();
|
|
|
|
|
- // 每餐限制消费金额
|
|
|
|
|
- BigDecimal mealLimitValue = cardLimitedVo.getDayMoney();
|
|
|
|
|
- // 每天折扣限制消费次数
|
|
|
|
|
- Long zkDayCount = cardLimitedVo.getDayDiscountCount();
|
|
|
|
|
- // 每餐折扣限制消费次数
|
|
|
|
|
- Long zkMealCount = cardLimitedVo.getMealDiscountCount();
|
|
|
|
|
|
|
+ cardLimitedVo = initXfCardLimited(cardNo, mealTypeVo.getMealId(), lastPayDate);
|
|
|
|
|
+ }
|
|
|
// 最后交易时间
|
|
// 最后交易时间
|
|
|
LocalDateTime lastPayLimitLocalDt = LocalDateTime.ofInstant(cardLimitedVo.getLastPay().toInstant(),
|
|
LocalDateTime lastPayLimitLocalDt = LocalDateTime.ofInstant(cardLimitedVo.getLastPay().toInstant(),
|
|
|
- ZoneOffset.of("+8"));
|
|
|
|
|
|
|
+ ZoneOffset.of("+8"));
|
|
|
// 最后交易餐类
|
|
// 最后交易餐类
|
|
|
Long lastPayLimitMealType = cardLimitedVo.getLastMeal();
|
|
Long lastPayLimitMealType = cardLimitedVo.getLastMeal();
|
|
|
- // 判断交易是否为新的一天(重置各项数据)
|
|
|
|
|
|
|
+ // 判断交易是否为新的一天,如果是则需要重置日消费数据
|
|
|
if (!lastPayLimitLocalDt.toLocalDate().isEqual(currentLocalDt.toLocalDate())) {
|
|
if (!lastPayLimitLocalDt.toLocalDate().isEqual(currentLocalDt.toLocalDate())) {
|
|
|
cardLimitedVo = cardLimitedService.resetDayCardLimitedData(cardNo, mealTypeId.toString());
|
|
cardLimitedVo = cardLimitedService.resetDayCardLimitedData(cardNo, mealTypeId.toString());
|
|
|
- if (ObjectUtil.isNotEmpty(cardLimitedVo)) {
|
|
|
|
|
- lastPayLimitMealType = mealTypeId;
|
|
|
|
|
- dayLimitCount = 0L;
|
|
|
|
|
- mealLimitCount = 0L;
|
|
|
|
|
- dayLimitValue = BigDecimal.ZERO;
|
|
|
|
|
- mealLimitValue = BigDecimal.ZERO;
|
|
|
|
|
- zkDayCount = 0L;
|
|
|
|
|
- zkMealCount = 0L;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
- // 判断是否为新的餐类
|
|
|
|
|
|
|
+ // 判断是否为新的餐类,如果是则需要重置餐类消费数据
|
|
|
if (!Objects.equals(lastPayLimitMealType, mealTypeId)) {
|
|
if (!Objects.equals(lastPayLimitMealType, mealTypeId)) {
|
|
|
cardLimitedVo = cardLimitedService.resetMealCardLimitedData(cardNo, mealTypeId.toString());
|
|
cardLimitedVo = cardLimitedService.resetMealCardLimitedData(cardNo, mealTypeId.toString());
|
|
|
- if (ObjectUtil.isNotEmpty(cardLimitedVo)) {
|
|
|
|
|
- mealLimitCount = zkMealCount = 0L;
|
|
|
|
|
- mealLimitValue = BigDecimal.ZERO;
|
|
|
|
|
- zkMealCount = 0L;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
// 卡类限次检查
|
|
// 卡类限次检查
|
|
|
R<ErrorInfo> result = checkCardLimited(termVo, userCardVo, cardLimitedVo, mealTypeVo);
|
|
R<ErrorInfo> result = checkCardLimited(termVo, userCardVo, cardLimitedVo, mealTypeVo);
|
|
@@ -598,6 +566,15 @@ public class CheckBusiness {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 卡片的限次验证处理
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param termVo 设备信息
|
|
|
|
|
+ * @param userCardVo 卡片信息
|
|
|
|
|
+ * @param cardLimitedVo 卡片限制信息
|
|
|
|
|
+ * @param mealTypeVo 餐类信息
|
|
|
|
|
+ * @return 验证结果
|
|
|
|
|
+ */
|
|
|
private R<ErrorInfo> checkCardLimited(XfTermVo termVo, RemoteCardVo userCardVo, XfCardLimitedVo cardLimitedVo, RemoteMealTypeVo mealTypeVo) {
|
|
private R<ErrorInfo> checkCardLimited(XfTermVo termVo, RemoteCardVo userCardVo, XfCardLimitedVo cardLimitedVo, RemoteMealTypeVo mealTypeVo) {
|
|
|
String useLimited = remotePtParameterService.getPtParameterByKey("XC_CONSUME");
|
|
String useLimited = remotePtParameterService.getPtParameterByKey("XC_CONSUME");
|
|
|
String mealType = mealTypeVo.getTypeId();
|
|
String mealType = mealTypeVo.getTypeId();
|
|
@@ -676,12 +653,13 @@ public class CheckBusiness {
|
|
|
/**
|
|
/**
|
|
|
* 更新其它消费信息
|
|
* 更新其它消费信息
|
|
|
* 1.更新卡片交易信息
|
|
* 1.更新卡片交易信息
|
|
|
- * @param bo 交易业务对象
|
|
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bo 交易业务对象
|
|
|
* @param userCardVo 卡片视图对象
|
|
* @param userCardVo 卡片视图对象
|
|
|
* @param mealTypeVo 餐类视图对象
|
|
* @param mealTypeVo 餐类视图对象
|
|
|
- * @param termVo 设备视图对象
|
|
|
|
|
|
|
+ * @param termVo 设备视图对象
|
|
|
*/
|
|
*/
|
|
|
- private void updateOtherConsumeInfo(ConsumptionBo bo, RemoteCardVo userCardVo, RemoteMealTypeVo mealTypeVo,XfTermVo termVo) {
|
|
|
|
|
|
|
+ private void updateOtherConsumeInfo(ConsumptionBo bo, RemoteCardVo userCardVo, RemoteMealTypeVo mealTypeVo, XfTermVo termVo) {
|
|
|
Long mealType = Long.parseLong(mealTypeVo.getTypeId());
|
|
Long mealType = Long.parseLong(mealTypeVo.getTypeId());
|
|
|
Date consumeDate = bo.getConsumeDate();
|
|
Date consumeDate = bo.getConsumeDate();
|
|
|
String currentDateStr = DateFormatUtils.format(new Date(), "yyyy-MM-dd");
|
|
String currentDateStr = DateFormatUtils.format(new Date(), "yyyy-MM-dd");
|
|
@@ -718,7 +696,7 @@ public class CheckBusiness {
|
|
|
// 有卡类的限额信息并已启用
|
|
// 有卡类的限额信息并已启用
|
|
|
if (ObjectUtil.isNotEmpty(remoteQuotaVo) && ObjectUtil.equals(remoteQuotaVo.getStatus(), "1")) {
|
|
if (ObjectUtil.isNotEmpty(remoteQuotaVo) && ObjectUtil.equals(remoteQuotaVo.getStatus(), "1")) {
|
|
|
// 更新卡类的限额信息
|
|
// 更新卡类的限额信息
|
|
|
- result = cardLimitedService.updateQuotaData(userCardVo.getCardNo(),bo.getConsumeMoney());
|
|
|
|
|
|
|
+ result = cardLimitedService.updateQuotaData(userCardVo.getCardNo(), bo.getConsumeMoney());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -744,9 +722,16 @@ public class CheckBusiness {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private XfCardLimitedVo initXfCardLimited(Long cardNo, Long mealType, RemoteCardVo userCardVo) {
|
|
|
|
|
- LocalDateTime lastPayLocalDt = LocalDateTime.ofInstant(userCardVo.getLastPay().toInstant(), ZoneOffset.of("+8"));
|
|
|
|
|
- ;
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 初始化卡片限制信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param cardNo 卡流水号
|
|
|
|
|
+ * @param mealType 餐类
|
|
|
|
|
+ * @param lastPayDate 最后消费时间
|
|
|
|
|
+ * @return 卡片限制信息
|
|
|
|
|
+ */
|
|
|
|
|
+ private XfCardLimitedVo initXfCardLimited(Long cardNo, Long mealType, Date lastPayDate) {
|
|
|
|
|
+ LocalDateTime lastPayLocalDt = LocalDateTime.ofInstant(lastPayDate.toInstant(), ZoneOffset.of("+8"));
|
|
|
XfCardLimitedBo bo = new XfCardLimitedBo();
|
|
XfCardLimitedBo bo = new XfCardLimitedBo();
|
|
|
bo.setCardNo(cardNo);
|
|
bo.setCardNo(cardNo);
|
|
|
bo.setDayCount(0L);
|
|
bo.setDayCount(0L);
|
|
@@ -761,6 +746,11 @@ public class CheckBusiness {
|
|
|
return cardLimitedService.insertReturnByBo(bo);
|
|
return cardLimitedService.insertReturnByBo(bo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取营业员信息
|
|
|
|
|
+ * @param bo 消费业务对象
|
|
|
|
|
+ * @return 营业员信息
|
|
|
|
|
+ */
|
|
|
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)) {
|