| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保险购买申请 |
| | | */ |
| | | @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("保单不存在"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | 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); |
| | |
| | | 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 "订单不存在"; |
| | |
| | | } |
| | | |
| | | userPolicy.setPayStatus(2); // 2-支付成功 |
| | | userPolicy.setPolicyStatus(UserPolicy.PolicyStatus.ACTIVE); |
| | | // userPolicy.setPolicyStatus(UserPolicy.PolicyStatus.ACTIVE); |
| | | userPolicy.setUpdatedAt(new Date()); |
| | | |
| | | boolean updateResult = userPolicyService.updateById(userPolicy); |
| | |
| | | } |
| | | 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("删除成功"); |
| | | } |
| | | |