提交 30ef05a5 authored 作者: hzh's avatar hzh

保险功能实现

上级 7f3900fc
...@@ -3,10 +3,15 @@ package org.dromara.mall.controller.weishi.app; ...@@ -3,10 +3,15 @@ package org.dromara.mall.controller.weishi.app;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.weishi.model.req.ApplyRequest; import org.dromara.common.weishi.model.req.ApplyRequest;
import org.dromara.common.weishi.model.req.ProposalRequest; import org.dromara.common.weishi.model.req.ProposalRequest;
import org.dromara.common.weishi.model.res.*; import org.dromara.common.weishi.model.res.*;
import org.dromara.common.weishi.service.WeishiService; import org.dromara.common.weishi.service.WeishiService;
import org.dromara.mall.controller.weishi.admin.bo.InsureBo;
import org.dromara.mall.controller.weishi.admin.vo.InsureVo;
import org.dromara.mall.service.weishi.IInsureService; import org.dromara.mall.service.weishi.IInsureService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -107,6 +112,7 @@ public class WeishiController { ...@@ -107,6 +112,7 @@ public class WeishiController {
@PostMapping("/insureCancel/{orderNum}") @PostMapping("/insureCancel/{orderNum}")
public R<Void> insureCancel(@PathVariable String orderNum) { public R<Void> insureCancel(@PathVariable String orderNum) {
weishiService.insureCancel(getToken(), orderNum); weishiService.insureCancel(getToken(), orderNum);
insureService.insureCancel(orderNum);
return R.ok(); return R.ok();
} }
...@@ -118,9 +124,21 @@ public class WeishiController { ...@@ -118,9 +124,21 @@ public class WeishiController {
@PostMapping("/policyCancel/{policyNum}") @PostMapping("/policyCancel/{policyNum}")
public R<Void> policyCancel(@PathVariable String policyNum) { public R<Void> policyCancel(@PathVariable String policyNum) {
weishiService.policyCancel(getToken(), policyNum); weishiService.policyCancel(getToken(), policyNum);
insureService.policyCancel(policyNum);
return R.ok(); return R.ok();
} }
/**
* 订单列表
*/
@GetMapping("/insureList")
public TableDataInfo<InsureVo> list(PageQuery pageQuery) {
InsureBo bo = new InsureBo();
bo.setUserId(LoginHelper.getUserId());
return insureService.queryPageList(bo, pageQuery);
}
/** /**
* 获取token * 获取token
* *
......
package org.dromara.mall.domain.weishi; package org.dromara.mall.domain.weishi;
import lombok.experimental.Accessors;
import org.dromara.common.tenant.core.TenantEntity; import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Data; import lombok.Data;
...@@ -15,6 +16,7 @@ import java.io.Serial; ...@@ -15,6 +16,7 @@ import java.io.Serial;
* @date 2025-05-14 * @date 2025-05-14
*/ */
@Data @Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("weishi_insure_insureds") @TableName("weishi_insure_insureds")
public class InsureInsureds extends TenantEntity { public class InsureInsureds extends TenantEntity {
......
package org.dromara.mall.domain.weishi; package org.dromara.mall.domain.weishi;
import lombok.experimental.Accessors;
import org.dromara.common.tenant.core.TenantEntity; import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Data; import lombok.Data;
...@@ -14,6 +15,7 @@ import java.io.Serial; ...@@ -14,6 +15,7 @@ import java.io.Serial;
* @date 2025-05-14 * @date 2025-05-14
*/ */
@Data @Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("weishi_insure_policy_holder") @TableName("weishi_insure_policy_holder")
public class InsurePolicyHolder extends TenantEntity { public class InsurePolicyHolder extends TenantEntity {
......
package org.dromara.mall.domain.weishi; package org.dromara.mall.domain.weishi;
import lombok.experimental.Accessors;
import org.dromara.common.tenant.core.TenantEntity; import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Data; import lombok.Data;
...@@ -14,6 +15,7 @@ import java.io.Serial; ...@@ -14,6 +15,7 @@ import java.io.Serial;
* @date 2025-05-14 * @date 2025-05-14
*/ */
@Data @Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("weishi_insure_taxpayer") @TableName("weishi_insure_taxpayer")
public class InsureTaxpayer extends TenantEntity { public class InsureTaxpayer extends TenantEntity {
......
...@@ -30,4 +30,18 @@ public interface IInsureService extends IBaseService<InsureVo, InsureBo, Insure> ...@@ -30,4 +30,18 @@ public interface IInsureService extends IBaseService<InsureVo, InsureBo, Insure>
*/ */
void apply(ApplyRequest req, ApplyResponse res); void apply(ApplyRequest req, ApplyResponse res);
/**
* 订单取消
*
* @param orderNum 订单号
*/
void insureCancel(String orderNum);
/**
* 保单取消
*
* @param policyNum 保单号
*/
void policyCancel(String policyNum);
} }
...@@ -140,8 +140,8 @@ public class InsureServiceImpl extends AbstractBaseService<InsureVo, InsureBo, I ...@@ -140,8 +140,8 @@ public class InsureServiceImpl extends AbstractBaseService<InsureVo, InsureBo, I
//保存投保人信息 //保存投保人信息
ApplyResponse.PolicyHolder ph = unit.getPolicyHolder(); ApplyResponse.PolicyHolder ph = unit.getPolicyHolder();
InsurePolicyHolder iph = BeanUtil.copyProperties(ph, InsurePolicyHolder.class); InsurePolicyHolder iph = BeanUtil.copyProperties(ph, InsurePolicyHolder.class);
iph.setOrderNum(res.getOrderNum()); iph.setOrderNum(res.getOrderNum())
iph.setPolicyNum(unit.getPolicyNum()); .setPolicyNum(unit.getPolicyNum());
policyHolderMapper.insert(iph); policyHolderMapper.insert(iph);
//保存被保人信息 //保存被保人信息
List<ApplyResponse.Insured> insureds = unit.getInsureds(); List<ApplyResponse.Insured> insureds = unit.getInsureds();
...@@ -149,13 +149,67 @@ public class InsureServiceImpl extends AbstractBaseService<InsureVo, InsureBo, I ...@@ -149,13 +149,67 @@ public class InsureServiceImpl extends AbstractBaseService<InsureVo, InsureBo, I
for (ApplyResponse.Insured insured : insureds) { for (ApplyResponse.Insured insured : insureds) {
InsureInsureds ins = BeanUtil.copyProperties(insured, InsureInsureds.class); InsureInsureds ins = BeanUtil.copyProperties(insured, InsureInsureds.class);
IssueResponse.Insured iri = StreamUtils.findFirst(arInsureds, a -> StringUtils.equals(a.getIDNum(), insured.getIDNum())); IssueResponse.Insured iri = StreamUtils.findFirst(arInsureds, a -> StringUtils.equals(a.getIDNum(), insured.getIDNum()));
ins.setOrderNum(res.getOrderNum());
ins.setPolicyNum(unit.getPolicyNum());
assert iri != null; assert iri != null;
ins.setActRefund(iri.getActRefund()); ins.setOrderNum(res.getOrderNum())
ins.setStdRefund(iri.getStdRefund()); .setPolicyNum(unit.getPolicyNum())
.setActRefund(iri.getActRefund())
.setStdRefund(iri.getStdRefund());
insuredsMapper.insert(ins); insuredsMapper.insert(ins);
} }
} }
} }
@Transactional(rollbackFor = Exception.class)
@Override
public void insureCancel(String orderNum) {
//获取订单详情
IssueResponse issueRes = weishiService.insureDetail(getToken(), orderNum);
//获取投保单位
List<InsureUnit> unitList = unitMapper.selectList(InsureUnit::getOrderNum, orderNum);
//获取被保人信息
List<InsureInsureds> insuredList = insuredsMapper.selectList(InsureInsureds::getOrderNum, orderNum);
//跟新退款信息
updateRefundInfo(issueRes, unitList, insuredList);
}
@Override
public void policyCancel(String policyNum) {
//获取投保单位
List<InsureUnit> unitList = unitMapper.selectList(InsureUnit::getPolicyNum, policyNum);
//获取被保人信息
List<InsureInsureds> insuredList = insuredsMapper.selectList(InsureInsureds::getPolicyNum, policyNum);
//获取订单详情
IssueResponse issueRes = weishiService.insureDetail(getToken(), unitList.get(0).getOrderNum());
updateRefundInfo(issueRes, unitList, insuredList);
}
/**
* 跟新退款信息
*
* @param issueRes 订单详情
* @param unitList 投保单位集合
* @param insuredList 被保人信息集合
*/
private void updateRefundInfo(IssueResponse issueRes, List<InsureUnit> unitList, List<InsureInsureds> insuredList) {
//跟新退款信息
List<IssueResponse.Unit> units = issueRes.getUnits();
for (InsureUnit unit : unitList) {
//跟新投保信息
IssueResponse.Unit iru = StreamUtils.findFirst(units, u -> StringUtils.equals(u.getPolicyNum(), unit.getPolicyNum()));
assert iru != null;
unit.setActRefund(iru.getActRefund())
.setStdRefund(iru.getStdRefund());
unitMapper.updateById(unit);
//跟新被保人信息
List<InsureInsureds> insureds = StreamUtils.filter(insuredList, i -> StringUtils.equals(i.getPolicyNum(), unit.getPolicyNum()));
List<IssueResponse.Insured> iriList = iru.getInsureds();
for (InsureInsureds insured : insureds) {
IssueResponse.Insured iri = StreamUtils.findFirst(iriList, i -> StringUtils.equals(i.getIDNum(), insured.getIdNum()));
assert iri != null;
insured.setActRefund(iri.getActRefund())
.setStdRefund(iri.getStdRefund());
insuredsMapper.updateById(insured);
}
}
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论