|
@@ -102,7 +102,8 @@ public class ApiCarFreeChargeServiceImpl implements ApiCarFreeChargeService {
|
|
|
BigDecimal balance = userBalanceDto.getBalance();
|
|
|
//计费
|
|
|
for (InvoiceResult t : newSearchInvoiceResultList) {
|
|
|
- if (!redisTemplate.hasKey(CommonConstant.TRANSACTION_ID_KEY + t.getTransactionId())) {
|
|
|
+ List<InvoiceResult> invoiceResultList = searchInvoiceResultService.getInvoiceByTransactionId(t.getTransactionId());
|
|
|
+ if (invoiceResultList.size() == 0) {
|
|
|
// 计算余额
|
|
|
balance = balance.subtract(userDto.getPrice());
|
|
|
// 实际扣费数据
|
|
@@ -113,8 +114,6 @@ public class ApiCarFreeChargeServiceImpl implements ApiCarFreeChargeService {
|
|
|
realChargeDto.setTransactionId(t.getTransactionId());
|
|
|
realChargeService.saveRealCharge(realChargeDto);
|
|
|
log.warn("计费用户id:{},计费流水号:{},计费日志:{}", po.getUserId(), t.getTransactionId(), JSON.toJSONString(t));
|
|
|
- //存入redis交易id
|
|
|
- redisTemplate.opsForValue().set(CommonConstant.TRANSACTION_ID_KEY + t.getTransactionId(), t.getTransactionId());
|
|
|
}
|
|
|
}
|
|
|
userBalanceDto.setBalance(balance);
|
|
@@ -122,15 +121,14 @@ public class ApiCarFreeChargeServiceImpl implements ApiCarFreeChargeService {
|
|
|
|
|
|
// 保存发票信息
|
|
|
for (InvoiceResult t : invoiceResultDto.getResult()) {
|
|
|
- if (!redisTemplate.hasKey(CommonConstant.NUM_FIND_INVOICE_KEY + t.getInvoiceNum() + "_" + t.getInvoiceCode())) {
|
|
|
+ List<InvoiceResult> invoiceResultList = searchInvoiceResultService.getInvoiceByInvoiceNum(t.getInvoiceNum(), t.getInvoiceCode());
|
|
|
+ if (invoiceResultList.size() == 0) {
|
|
|
SearchInvoiceResultDto dto = new SearchInvoiceResultDto();
|
|
|
BeanUtil.copyProperties(dto, t);
|
|
|
dto.setUserId(po.getUserId());
|
|
|
//插入发票信息
|
|
|
searchInvoiceResultService.saveSearchInvoiceResult(dto);
|
|
|
log.info("插入的发票信息:{}", JSON.toJSONString(t));
|
|
|
- //存入redis发票信息
|
|
|
- redisTemplate.opsForValue().set(CommonConstant.NUM_FIND_INVOICE_KEY + t.getInvoiceNum() + "_" + t.getInvoiceCode(), JSON.toJSONString(t));
|
|
|
}
|
|
|
}
|
|
|
}
|