| | |
| | | import com.ruoyi.im.comm.Result; |
| | | import com.ruoyi.im.service.MedicalInsuranceAccountService; |
| | | import com.ruoyi.system.domain.MedicalInsuranceAccount; |
| | | import com.ruoyi.system.domain.UserAccount; |
| | | import com.ruoyi.system.domain.UserPolicy; |
| | | import com.ruoyi.system.domain.dto.UserPolicyDto; |
| | | import com.ruoyi.im.service.UserPolicyService; |
| | | import com.ruoyi.system.service.UserAccountService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | |
| | | @Autowired |
| | | MedicalInsuranceAccountService medicalInsuranceAccountService; |
| | | |
| | | @Autowired |
| | | UserAccountService userAccountService; |
| | | |
| | | /** |
| | | * 保险购买申请 |
| | | */ |
| | | @PostMapping("/purchaseApplication") |
| | | public Result purchaseApplication(@Valid @RequestBody UserPolicyDto dto) { |
| | | public Result purchaseApplication(UserPolicyDto dto) { |
| | | try { |
| | | return userPolicyService.purchaseApplication(dto); |
| | | }catch (Exception e){ |
| | | e.getMessage(); |
| | | e.printStackTrace(); |
| | | return Result.error("购买失败"); |
| | | } |
| | | } |
| | |
| | | * 根据用户id查询保单 |
| | | */ |
| | | @GetMapping("/getPolicyById") |
| | | public Result getPolicyById(@RequestParam(value = "id") Integer id) { |
| | | public Result getPolicyById(@RequestParam(value = "account") String account) { |
| | | try { |
| | | List<UserPolicy> list = userPolicyService.list(new LambdaQueryWrapper<UserPolicy>().eq(UserPolicy::getUserId, id)); |
| | | UserAccount userAccount = userAccountService.getOne(new LambdaQueryWrapper<UserAccount>() |
| | | .eq(UserAccount::getAccount,account)); |
| | | List<UserPolicy> list = userPolicyService.list(new LambdaQueryWrapper<UserPolicy>().eq(UserPolicy::getUserId, userAccount.getId())); |
| | | return Result.success(list); |
| | | }catch (Exception e){ |
| | | e.getMessage(); |
| | | return Result.error("购买失败"); |
| | | e.printStackTrace(); |
| | | return Result.error("查询失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保单审批 |
| | | */ |
| | | @PostMapping("/examine") |
| | | @GetMapping("/examine") |
| | | @Transactional |
| | | public AjaxResult examine(@RequestParam(value = "id") Integer id, @RequestParam(value = "approvalStatus") Integer approvalStatus, @RequestParam(value = "message",required = false) String message) { |
| | | public AjaxResult examine(@RequestParam(value = "id") Integer id, |
| | | @RequestParam(value = "approvalStatus") Integer approvalStatus, |
| | | @RequestParam(value = "message",required = false) String message) { |
| | | try { |
| | | UserPolicy userPolicy = userPolicyService.getById(id); |
| | | if(ObjectUtil.isEmpty(userPolicy)){ |
| | |
| | | medicalInsuranceAccountService.save(medicalInsuranceAccount); |
| | | return AjaxResult.success("审批成功"); |
| | | }catch (Exception e){ |
| | | e.getMessage(); |
| | | e.printStackTrace(); |
| | | // 手动设置回滚 |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return AjaxResult.error("审批失败!"); |
| | | } |
| | | } |