From 9437600612eb0243a3371ff1e4fa3689cce8c83a Mon Sep 17 00:00:00 2001
From: dd <gitluke@outlook.com>
Date: Sat, 29 Nov 2025 22:40:41 +0800
Subject: [PATCH] 1
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserPolicyController.java | 75 +++++++++++++++++++++++++++++++------
1 files changed, 62 insertions(+), 13 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserPolicyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserPolicyController.java
index 33b8258..7eddc25 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserPolicyController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserPolicyController.java
@@ -22,6 +22,7 @@
import com.ruoyi.system.domain.dto.UserPolicyDto;
import com.ruoyi.im.service.UserPolicyService;
import com.ruoyi.system.domain.out.UserTeamAndPositionOut;
+import com.ruoyi.system.service.FundsLogService;
import com.ruoyi.system.service.PaymentRecordService;
import com.ruoyi.system.service.UserAccountService;
import lombok.extern.slf4j.Slf4j;
@@ -70,6 +71,9 @@
@Autowired
PaymentRecordService paymentRecordService;
+ @Autowired
+ FundsLogService fundsLogService;
+
@Value("${pay.key}")
private String key;
@@ -103,6 +107,23 @@
redisDistributedLock.releaseLock(lockKey);
}
}
+ }
+ }
+
+ /**
+ * 保险购买申请
+ */
+ @PostMapping("/updatePolicy")
+ public AjaxResult updatePolicy(UserPolicyDto dto) {
+
+ UserPolicy userPolicy = userPolicyService.getById(dto.getId());
+ if(ObjectUtil.isNotEmpty(userPolicy)){
+ userPolicy.setPhone(dto.getPhone());
+ userPolicy.setBirthDate(LocalDate.parse(dto.getBirthDate()));
+ userPolicyService.updateById(userPolicy);
+ return AjaxResult.success("更新成功");
+ }else{
+ return AjaxResult.error("保单不存在");
}
}
@@ -243,6 +264,8 @@
userAccount.setBalance(userAccount.getBalance().add(userPolicy.getPremium()));
userAccountService.updateById(userAccount);
+ fundsLogService.addLog(userAccount.getId(), userAccount.getAccount(), userPolicy.getPremium(), OperationType.REFUND);
+
return AjaxResult.success("审批成功");
}
@@ -314,8 +337,10 @@
List<InsurancePosition> positions = insurancePositionService.list();
positions.forEach(f->{
if(activePolicies >= f.getNumberPeople()){
- superiorUser.setPosition(f.getPosition());
- superiorUser.setAgreedTime(LocalDate.now());
+ if(!superiorUser.getPosition().equals(f.getPosition())){
+ superiorUser.setPosition(f.getPosition());
+ superiorUser.setAgreedTime(LocalDate.now());
+ }
}
});
userAccountService.updateById(superiorUser);
@@ -393,10 +418,16 @@
log.error("签名验证失败: {}", callbackDTO.getOrderId());
return "签名验证失败";
}
-
+ PaymentRecord paymentRecord = paymentRecordService.getOne(new LambdaQueryWrapper<PaymentRecord>()
+ .eq(PaymentRecord::getPayOrdeNo, callbackDTO.getOrderId())
+ );
+ if (paymentRecord == null) {
+ log.error("支付订单不存在: {}", paymentRecord.getPayOrdeNo());
+ return "支付订单不存在";
+ }
// 2. 根据订单号查询保单
UserPolicy userPolicy = userPolicyService.getOne(new LambdaQueryWrapper<UserPolicy>()
- .eq(UserPolicy::getOrderNo, callbackDTO.getOrderId()));
+ .eq(UserPolicy::getId, paymentRecord.getOrderId()));
if (userPolicy == null) {
log.error("订单不存在: {}", callbackDTO.getOrderId());
return "订单不存在";
@@ -482,7 +513,7 @@
}
userPolicy.setPayStatus(2); // 2-支付成功
- userPolicy.setPolicyStatus(UserPolicy.PolicyStatus.ACTIVE);
+// userPolicy.setPolicyStatus(UserPolicy.PolicyStatus.ACTIVE);
userPolicy.setUpdatedAt(new Date());
boolean updateResult = userPolicyService.updateById(userPolicy);
@@ -555,18 +586,36 @@
}
if(byId.getPaymentStatus() == 2){
return AjaxResult.error("订单已支付,禁止删除");
+ }else{
+ paymentRecordService.removeById(byId);
}
UserPolicy userPolicy = userPolicyService.getById(byId.getOrderId());
- if(ObjectUtil.isEmpty(userPolicy)){
- return AjaxResult.error("保单不存在!");
- }
- if(userPolicy.getPayStatus() == 2){
- return AjaxResult.error("订单已支付,禁止删除");
- }
- paymentRecordService.removeById(byId);
- userPolicyService.removeById(userPolicy);
+ if(ObjectUtil.isNotEmpty(userPolicy) && userPolicy.getPayStatus() == 2){
+ return AjaxResult.error("订单已支付,禁止删除");
+ }else{
+ userPolicyService.removeById(userPolicy);
+ }
return AjaxResult.success("删除成功");
}
+ /**
+ * 保单列表
+ */
+ @GetMapping("/getFundsLogList")
+ public TableDataInfo getFundsLogList(@RequestParam(value = "account",required = false) String account,@RequestParam(value = "operationType",required = false) Integer operationType) {
+ startPage();
+
+ LambdaQueryWrapper<FundsLog> wrapper = new LambdaQueryWrapper<>();
+
+ if(StringUtils.isNotEmpty(account)){
+ wrapper.eq(FundsLog::getAccount,account);
+ }
+ if (ObjectUtil.isNotEmpty(operationType)){
+ wrapper.eq(FundsLog::getOperationType,operationType);
+ }
+ wrapper.orderByDesc(FundsLog::getCreateTime);
+ List<FundsLog> list = fundsLogService.list(wrapper);
+ return getDataTable(list);
+ }
}
--
Gitblit v1.9.3