|
@@ -28,6 +28,7 @@ import com.payment.platform.module.payment.notification.mapper.PayBillVoucherMap
|
|
|
import com.payment.platform.module.payment.openapi.service.OpenapiService;
|
|
import com.payment.platform.module.payment.openapi.service.OpenapiService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -239,7 +240,19 @@ public class BillHandler extends BaseNotifyHandler {
|
|
|
if (existing != null) {
|
|
if (existing != null) {
|
|
|
payBillMapper.updateById(bill);
|
|
payBillMapper.updateById(bill);
|
|
|
} else {
|
|
} else {
|
|
|
- payBillMapper.insert(bill);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ payBillMapper.insert(bill);
|
|
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
|
|
+ // 并发:另一条通知(同一pay_no)抢先插入 → 重新查出已存在记录并更新
|
|
|
|
|
+ PayBillEntity dup = payBillMapper.selectOne(
|
|
|
|
|
+ new LambdaQueryWrapper<PayBillEntity>().eq(PayBillEntity::getPayNo, payNo));
|
|
|
|
|
+ if (dup != null) {
|
|
|
|
|
+ bill.setId(dup.getId());
|
|
|
|
|
+ payBillMapper.updateById(bill);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
log.info("保存账单基础数据: pay_no={}, type={}, amount={}, employee_id={}",
|
|
log.info("保存账单基础数据: pay_no={}, type={}, amount={}, employee_id={}",
|
|
|
payNo, consumeType, consumeAmount, employeeId);
|
|
payNo, consumeType, consumeAmount, employeeId);
|