| | |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.im.comm.Result; |
| | | import com.ruoyi.im.service.InsuranceProductService; |
| | | import com.ruoyi.im.service.MedicalInsuranceAccountService; |
| | | import com.ruoyi.im.service.impl.InsurancePositionServiceImpl; |
| | | import com.ruoyi.im.util.RedisDistributedLock; |
| | |
| | | |
| | | @Autowired |
| | | private RedisDistributedLock redisDistributedLock; |
| | | |
| | | @Autowired |
| | | InsuranceProductService insuranceProductService; |
| | | |
| | | /** |
| | | * 保险购买申请 |
| | |
| | | */ |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(@RequestParam(value = "account",required = false) String account, |
| | | @RequestParam(value = "status",defaultValue = "0") Integer status, |
| | | @RequestParam(value = "state",defaultValue = "0") Integer state, |
| | | @RequestParam(value = "productName",required = false) String productName) { |
| | | startPage(); |
| | | |
| | |
| | | |
| | | // 产品名称模糊查询 |
| | | if (org.apache.commons.lang3.StringUtils.isNotBlank(account)) { |
| | | wrapper.like(UserPolicy::getUserId, account); |
| | | wrapper.like(UserPolicy::getAccount, account); |
| | | } |
| | | |
| | | // 产品代码模糊查询 |
| | |
| | | } |
| | | |
| | | // 审批状态 |
| | | if (status != null && status != 3) { |
| | | if (state != null && state == 3) { |
| | | wrapper.ne(UserPolicy::getApprovalStatus, 0); |
| | | }else{ |
| | | wrapper.eq(UserPolicy::getApprovalStatus, 0); |
| | |
| | | if(approvalStatus == 2 && StringUtils.isEmpty(message)){ |
| | | return AjaxResult.error("驳回理由不能为空!"); |
| | | } |
| | | UserAccount userAccount = userAccountService.getById(userPolicy.getUserId()); |
| | | if(approvalStatus == 2){ |
| | | userPolicy.setApprovalStatus(approvalStatus); |
| | | userPolicy.setMessage(message); |
| | | userPolicy.setUpdatedAt(new Date()); |
| | | userPolicyService.updateById(userPolicy); |
| | | |
| | | userAccount.setBalance(userAccount.getBalance().add(userPolicy.getPremium())); |
| | | userAccountService.updateById(userAccount); |
| | | return AjaxResult.success("审批成功"); |
| | | } |
| | | |
| | | //计算到期时间 |
| | | LocalDate expirationTime = calculateInsuranceEndDateToDay(LocalDate.now(), userPolicy.getTerm()); |
| | |
| | | medicalInsuranceAccount.setUpdatedAt(new Date()); |
| | | medicalInsuranceAccountService.save(medicalInsuranceAccount); |
| | | |
| | | |
| | | //判断上级用户职位达成 |
| | | if(approvalStatus == 1){ |
| | | //查询当前用户 |
| | | UserAccount userAccount = userAccountService.getOne(new LambdaQueryWrapper<UserAccount>() |
| | | .eq(UserAccount::getId, userPolicy.getUserId()) |
| | | ); |
| | | if(StringUtils.isNotEmpty(userAccount.getInvitationAccount())){ |
| | | //上级 |
| | | UserAccount superiorUser = userAccountService.getOne(new LambdaQueryWrapper<UserAccount>() |
| | | .eq(UserAccount::getAccount, userAccount.getInvitationAccount()) |
| | |
| | | } |
| | | }); |
| | | userAccountService.updateById(superiorUser); |
| | | } |
| | | return AjaxResult.success("审批成功"); |
| | | } |
| | | return AjaxResult.success("审批成功"); |