‘linchangsheng’ 1 tuần trước cách đây
mục cha
commit
38cfa5969a

+ 24 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/user/WorkerController.java

@@ -59,10 +59,11 @@ public class WorkerController {
     @ApiOperation("我的意外保险")
     public ResponseHelper<Page<PolicyOrder>> myPolicy(
 
+            @ApiParam(required = true, value = "AC 意外险 DS 第三者") @RequestParam(required = true) String type,
             @ApiParam(required = true, value = "pageNum") @RequestParam(required = true) Integer pageNum,
             @ApiParam(required = true, value = "pageSize") @RequestParam(required = true)Integer pageSize
     ){
-        Page<PolicyOrder> workerPolicies = workerLogic.myPolicy(pageNum,pageSize);
+        Page<PolicyOrder> workerPolicies = workerLogic.myPolicy(pageNum,pageSize,type);
         return ResponseHelper.success(workerPolicies);
     }
 
@@ -78,7 +79,7 @@ public class WorkerController {
 
 
     @PostMapping("/myWebsit")
-    @ApiOperation("我的续保网点")
+    @ApiOperation("我的意外续保网点")
     public ResponseHelper<List<AdminWebsit>> myWebsit(
     ){
         List<AdminWebsit> adminWebsitPage = workerLogic.myWebsit();
@@ -86,6 +87,27 @@ public class WorkerController {
     }
 
 
+    @PostMapping("/myDsWebsit")
+    @ApiOperation("我的第三者续保网点")
+    public ResponseHelper<List<AdminWebsit>> myDsWebsit(
+    ){
+        List<AdminWebsit> adminWebsitPage = workerLogic.myDsWebsit();
+        return ResponseHelper.success(adminWebsitPage);
+    }
+
+
+    @PostMapping("/dsPolicy")
+    @ApiOperation("购买第三者保险")
+    public ResponseHelper<Page<Policy>> dsPolicy(
+            @ApiParam(required = true, value = "网点id") @RequestParam(required = true) String websitId,
+            @ApiParam(required = true, value = "pageNum") @RequestParam(required = true) Integer pageNum,
+            @ApiParam(required = true, value = "pageSize") @RequestParam(required = true)Integer pageSize
+    ){
+        Page<Policy> workerPolicies = workerLogic.dsPolicy(websitId,pageNum,pageSize);
+        return ResponseHelper.success(workerPolicies);
+    }
+
+
     @PostMapping("/agreementList")
     @ApiOperation("保险协议列表")
     public ResponseHelper<List<Agreement>> agreementList(

+ 92 - 3
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/policy/WorkerLogic.java

@@ -261,7 +261,7 @@ public class WorkerLogic {
     }
 
 
-    public Page<PolicyOrder> myPolicy(Integer pageNum, Integer pageSize) {
+    public Page<PolicyOrder> myPolicy(Integer pageNum, Integer pageSize,String type) {
 
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
 
@@ -274,7 +274,7 @@ public class WorkerLogic {
 
         Page<PolicyOrder> page = policyOrderService.lambdaQuery()
                 .in(PolicyOrder::getWebsitUserId,collect)
-                .eq(PolicyOrder::getType,"AC")
+                .in(PolicyOrder::getType,type)
                 .eq(PolicyOrder::getIsPay,IsYesNoEnum.YES.getKey())
                 .orderByDesc(PolicyOrder::getCreateTime)
                 .page(new Page<>(pageNum, pageSize));
@@ -494,7 +494,7 @@ public class WorkerLogic {
         policyOrder.setWorkerNumber(currentCompanyWechat.getUser().getWorkerNumber());
         policyOrder.setBuyUnit(adminWebsit.getInsureSteadUnit());
         policyOrder.setBuyUnit(adminWebsit.getInsureSteadUnit());
-        policyOrder.setType("AC");
+        policyOrder.setType(policy.getType());
 
         policyOrder.insert();
 
@@ -773,4 +773,93 @@ public class WorkerLogic {
         }
         return true;
     }
+
+    public List<AdminWebsit> myDsWebsit() {
+
+        Mailbox mailbox = mailboxService.getById("1");
+
+        CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
+
+        List<WebsitUser> websitUsers = websitUserService.lambdaQuery().eq(WebsitUser::getUserId, currentCompanyWechat.getUserId())
+                .ne(WebsitUser::getExamineStatus,"WAIT").list();
+
+        List<AdminWebsit> adminWebsits = new ArrayList<>();
+
+        Policy policy = policyService.lambdaQuery()
+                .eq(Policy::getType, "DS")
+                .orderByDesc(Policy::getEndTime)
+                .last("limit 1").one();
+        if (policy == null)
+            return new ArrayList<>();
+        for (WebsitUser websitUser : websitUsers) {
+
+            if (  policyOrderService.lambdaQuery()
+                    .eq(PolicyOrder::getWebsitUserId,websitUser.getId())
+                    .eq(PolicyOrder::getType,"DS")
+                    .eq(PolicyOrder::getIsPay,IsYesNoEnum.YES.getKey())
+                    .and(item -> item
+                            .isNull(PolicyOrder::getStartTime)
+                            .or().ge(PolicyOrder::getEndTime, policy.getEndTime())
+
+                    )
+                    .eq(PolicyOrder::getWebsitUserId,websitUser.getId())
+                    .count() < 1){
+                AdminWebsit adminWebsit = adminWebsitService.getById(websitUser.getWebsitId());
+
+                adminWebsits.add(adminWebsit);
+            }
+
+        }
+
+        return adminWebsits;
+    }
+
+    public Page<Policy> dsPolicy(String websitId, Integer pageNum, Integer pageSize) {
+
+        CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
+
+        WebsitUser websitUser = websitUserService.lambdaQuery()
+                .eq(WebsitUser::getWebsitId, websitId)
+                .eq(WebsitUser::getUserId, currentCompanyWechat.getUserId()).last("limit 1").one();
+
+        List<PolicyWebsit> policyWebsits = policyWebsitService.lambdaQuery().eq(PolicyWebsit::getWebsitId, websitId).list();
+
+        if (CollectionUtils.isEmpty(policyWebsits))
+            return new Page<>();
+
+
+        PolicyOrder policyOrder = policyOrderService
+                .lambdaQuery()
+                .eq(PolicyOrder::getType, "DS")
+                .isNotNull(PolicyOrder::getEndTime)
+                .eq(PolicyOrder::getIsPay, IsYesNoEnum.YES.getKey())
+                .eq(PolicyOrder::getWebsitUserId, websitUser.getId())
+                .orderByDesc(PolicyOrder::getEndTime)
+                .last("limit 1").one();
+
+        List<PolicyOrder> policyOrders = policyOrderService
+                .lambdaQuery()
+                .eq(PolicyOrder::getType, "DS")
+                .isNull(PolicyOrder::getEndTime)
+                .eq(PolicyOrder::getIsPay, IsYesNoEnum.YES.getKey())
+                .eq(PolicyOrder::getWebsitUserId, websitUser.getId())
+                .list();
+
+
+        List<String> policyIds = policyOrders.stream().map(PolicyOrder::getPolicyId).collect(Collectors.toList());
+
+
+        Page<Policy> page = policyService.lambdaQuery()
+                .notIn(policyOrder == null && CollectionUtil.isNotEmpty(policyOrders), Policy::getId, policyIds)
+                .ge(policyOrder != null, Policy::getEndTime, policyOrder.getEndTime())
+                .eq(Policy::getIsBuy, IsYesNoEnum.YES.getKey())
+                .le(Policy::getPolicyStartTime, new Date())
+                .ge(Policy::getEndTime, new Date())
+                .in(Policy::getId, policyWebsits.stream().map(PolicyWebsit::getPolicyId).collect(Collectors.toList()))
+                .orderByAsc(Policy::getEndTime)
+                .page(new Page<>(pageNum, pageSize));
+
+
+        return page;
+    }
 }

+ 95 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/policy/PolicyOrderDsVO.java

@@ -0,0 +1,95 @@
+package com.gree.mall.manager.bean.policy;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.gree.mall.manager.annotation.ZfireField;
+import com.gree.mall.manager.enums.IsYesNoEnum;
+import com.gree.mall.manager.enums.PolicyOrderStatusEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@ApiModel
+@Data
+public class PolicyOrderDsVO {
+
+    @ApiModelProperty(value = "订单号")
+    @TableId(value = "id", type = IdType.ID_WORKER_STR)
+    private String id;
+
+    @ApiModelProperty(value = "保单状态")
+    private PolicyOrderStatusEnum policyOrderStatus;
+
+    @ApiModelProperty(value = "保单名称")
+    private String policyName;
+
+    @ApiModelProperty(value = "保单编号")
+    private String policyNumber;
+
+    @ApiModelProperty(value = "所属公司")
+    private String belongCompany;
+
+    @ApiModelProperty(value = "所属公司编号")
+    private String belongCompanyCode;
+
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "所属公司")
+    private String companyWechatName;
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "所属公司编号")
+    private String companyWechatId;
+
+    @ApiModelProperty(value = "网点名称")
+    private String websitName;
+
+    @ApiModelProperty(value = "网点编号")
+    private String websitId;
+
+    @ApiModelProperty(value = "工程师编号")
+    private String workerNumber;
+
+    @ApiModelProperty(value = "工程师")
+    private String workerName;
+
+    @ApiModelProperty(value = "身份证")
+    private String workerIdcard;
+
+    @ApiModelProperty(value = "工程师电话")
+    private String workerMobile;
+
+    @ApiModelProperty(value = "支付金额")
+    private String payAmount;
+
+    @ApiModelProperty(value = "微信流水号")
+    private String transactionId;
+
+    @ApiModelProperty(value = "支付时间")
+    private Date payTime;
+
+    @ApiModelProperty(value = "生效日期")
+    private Date startTime;
+
+    @ApiModelProperty(value = "截止日期")
+    private Date endTime;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private Date createTime;
+
+    @ApiModelProperty(value = "创建人")
+    @TableField(fill = FieldFill.INSERT)
+    private String createBy;
+
+    @ApiModelProperty(value = "修改时间")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
+
+    @ApiModelProperty(value = "修改人")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private String updateBy;
+
+}

+ 4 - 2
mall-server-api/src/main/java/com/gree/mall/manager/bean/policy/PolicyVo.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.gree.mall.manager.annotation.ZfireField;
 import com.gree.mall.manager.enums.IsYesNoEnum;
+import com.gree.mall.manager.enums.PolicyTypeEnum;
 import com.gree.mall.manager.plus.entity.Policy;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -16,7 +17,7 @@ import java.util.Date;
 
 @ApiModel
 @Data
-public class PolicyVo   {
+public class PolicyVo    {
 
 
     @ZfireField(hide = true)
@@ -60,7 +61,8 @@ public class PolicyVo   {
     @TableField(fill = FieldFill.INSERT_UPDATE)
     private String updateBy;
 
-
+    @ApiModelProperty(value = "保单类型")
+    private PolicyTypeEnum type;
 
 
 }

+ 2 - 0
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/PolicyCMapper.java

@@ -25,4 +25,6 @@ public interface PolicyCMapper {
     IPage<PolicyOrderEmVO> listEm(Page page, @Param("ex")ZfireParamBean zfireParam,@Param("adminCompanyIds") List<String> adminCompanyIds);
 
     IPage<PolicyOrderInVO> listIn(Page page, @Param("ex")ZfireParamBean zfireParam, @Param("adminCompanyIds") List<String> adminCompanyIds);
+
+    IPage<PolicyOrderDsVO> listDs(Page page,@Param("ex")  ZfireParamBean zfireParam, @Param("adminCompanyIds")List<String> adminCompanyIds);
 }

+ 40 - 4
mall-server-api/src/main/java/com/gree/mall/manager/controller/policy/PolicyOrderController.java

@@ -4,10 +4,7 @@ import cn.hutool.core.lang.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.annotation.ZfireList;
-import com.gree.mall.manager.bean.policy.PolicyDetail;
-import com.gree.mall.manager.bean.policy.PolicyOrderEmVO;
-import com.gree.mall.manager.bean.policy.PolicyOrderInVO;
-import com.gree.mall.manager.bean.policy.PolicyOrderVO;
+import com.gree.mall.manager.bean.policy.*;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.helper.ResponseHelper;
 import com.gree.mall.manager.logic.policy.PolicyOrderLogic;
@@ -40,6 +37,45 @@ public class PolicyOrderController {
 
 
     @ZfireList
+    @PostMapping("/listDs")
+    @ApiOperation(value = "第三者险订单列表")
+    public ResponseHelper<IPage<PolicyOrderDsVO>> listDs(
+            @RequestBody ZfireParamBean zfireParamBean
+    ) throws RemoteServiceException {
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        IPage<PolicyOrderDsVO> policyOrderVOIPage = policyOrderLogic.listDs(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);
+        return ResponseHelper.success(policyOrderVOIPage, new TypeReference<PolicyOrderDsVO>() {});
+    }
+
+    @PostMapping("/listDs/export")
+    @ApiOperation(value = "第三者险订单列表导出")
+    public void listDsExport(
+            @RequestBody ZfireParamBean zfireParamBean,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        //1.组装查询条件
+        ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean);
+        //2.查询要导出的内容
+        IPage<PolicyOrderDsVO> policyOrderVOIPage = policyOrderLogic.listDs(new Page(zfireParam.getPageNum(), zfireParam.getPageSize()), zfireParam);
+        //3.导出
+        FieldUtils.exportData(policyOrderVOIPage.getRecords(), zfireParam.getExportFields(), request, response);
+    }
+
+
+
+    @PostMapping("/importDs")
+    @ApiOperation(value = "第三者险导入")
+    public ResponseHelper importDs(
+            @RequestParam MultipartFile file
+    ) throws RemoteServiceException, IOException {
+        List<Object> objects = ExcelUtils.importExcel(file);
+        policyOrderLogic.importDs(objects);
+        return ResponseHelper.success();
+    }
+
+
+    @ZfireList
     @PostMapping("/list")
     @ApiOperation(value = "意外保险订单列表")
     public ResponseHelper<IPage<PolicyOrderVO>> list(

+ 1 - 0
mall-server-api/src/main/java/com/gree/mall/manager/enums/PolicyTypeEnum.java

@@ -11,6 +11,7 @@ public enum  PolicyTypeEnum implements BaseEnum {
     AC("AC","意外险"),
     EM("EM","雇主险"),
     IN("IN","工伤险"),
+    DS("DS","第三者责任险"),
 
 
             ;

+ 107 - 4
mall-server-api/src/main/java/com/gree/mall/manager/logic/policy/PolicyOrderLogic.java

@@ -1,15 +1,14 @@
 package com.gree.mall.manager.logic.policy;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
-import com.gree.mall.manager.bean.policy.PolicyOrderEmVO;
-import com.gree.mall.manager.bean.policy.PolicyOrderInVO;
-import com.gree.mall.manager.bean.policy.PolicyOrderVO;
-import com.gree.mall.manager.bean.policy.PolicyVo;
+import com.gree.mall.manager.bean.policy.*;
 import com.gree.mall.manager.commonmapper.PolicyCMapper;
 import com.gree.mall.manager.enums.IsYesNoEnum;
 import com.gree.mall.manager.enums.PolicyOrderEmStutasEnum;
@@ -568,4 +567,108 @@ public class PolicyOrderLogic {
         return Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant());
     }
 
+    public IPage<PolicyOrderDsVO> listDs(Page page, ZfireParamBean zfireParam) {
+
+        //获取当前登录企业id
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        List<String> adminCompanyIds = adminUser.getCompanyWechatIds();
+        //1.组装查询条件
+        zfireParam = FieldUtils.supplyParam(zfireParam, PolicyOrderDsVO.class, adminUser);
+
+        IPage<PolicyOrderDsVO> policyOrderVOIPage = policyCMapper.listDs(page, zfireParam, adminCompanyIds);
+        return policyOrderVOIPage;
+    }
+
+
+    @Transactional(rollbackFor = Exception.class)
+    public void importDs(List<Object> objects) {
+
+        for (Object o : objects) {
+            List<Object> row = (List<Object>) o;
+
+            AdminWebsit adminWebsit = adminWebsitService.lambdaQuery().eq(AdminWebsit::getWebsitNumber, (String) row.get(1)).one();
+
+
+            User user = userService.lambdaQuery().eq(User::getIdCard, (String) row.get(4))
+                    .one();
+
+            if (user == null)
+                throw new RemoteServiceException((String) row.get(4)+"身份证找不到对应师傅");
+
+            WebsitUser websitUser = websitUserService.lambdaQuery()
+                    .eq(WebsitUser::getWebsitId, (String) row.get(1))
+                    .eq(WebsitUser::getUserId, user.getUserId())
+                    .one();
+
+
+            List<PolicyOrder> policyOrders = policyOrderService.lambdaQuery()
+                    .eq(PolicyOrder::getWebsitUserId, websitUser.getId())
+                    .eq(PolicyOrder::getType, "DS")
+                    .in(PolicyOrder::getPolicyOrderStatus,
+                            PolicyOrderEmStutasEnum.DSX.getKey()
+                    ).list();
+
+            if (CollectionUtil.isEmpty(policyOrders)){
+                throw new RemoteServiceException((String) row.get(4)+"找不到对应订单号");
+            }
+            PolicyOrder policyOrder = policyOrders.get(0);
+
+            policyOrder.setStartTime(DateUtil.parse((String) row.get(6), "yyyy-MM-dd"));
+            policyOrder.setEndTime(this.getEndOfDay(DateUtil.parse((String) row.get(7), "yyyy-MM-dd")));
+            policyOrder.setBelongCompany(adminWebsit.getBelongCompany());
+            policyOrder.setBelongCompanyCode(adminWebsit.getBelongCompanyCode());
+            policyOrder.setCompanyWechatId(adminWebsit.getCompanyWechatId());
+            policyOrder.setCompanyWechatName(adminWebsit.getCompanyWechatName());
+
+            policyOrder.setWebsitId(adminWebsit.getWebsitId());
+            policyOrder.setWebsitName(adminWebsit.getName());
+
+            if (policyOrder.getStartTime().after(policyOrder.getEndTime()))
+                throw new RemoteServiceException((String) row.get(4)+"开始时间不能大于结束时间");
+
+            if (new Date().after(policyOrder.getStartTime()) && new Date().before(policyOrder.getEndTime()))
+                policyOrder.setPolicyOrderStatus("BZZ");
+            else if (new Date().after(policyOrder.getEndTime()))
+                policyOrder.setPolicyOrderStatus("YSX");
+            else {
+                policyOrder.setPolicyOrderStatus("DSX");
+            }
+
+            policyOrder.updateById();
+
+
+            List<PolicyOrder> policyOrderList = policyOrderService.lambdaQuery()
+                    .eq(PolicyOrder::getWebsitUserId, websitUser.getId())
+                    .eq(PolicyOrder::getType, "DS")
+                    .in(PolicyOrder::getPolicyOrderStatus,
+                            PolicyOrderEmStutasEnum.DSX.getKey(),
+                            PolicyOrderEmStutasEnum.BZZ.getKey()
+                    ).list();
+
+            Boolean wp = this.hasOverlapPolicy(policyOrderList);
+
+            if (wp)
+                throw new RemoteServiceException(user.getIdCard()+"第三者险有相同覆盖范围内的保险");
+
+
+
+        }
+    }
+
+    public Boolean hasOverlapPolicy(List<PolicyOrder> policyOrders){
+
+        for (int i= 0; i<policyOrders.size();i++){
+            PolicyOrder workerPolicy = policyOrders.get(i);
+            for (int j = i+1; j <policyOrders.size() ; j++) {
+                PolicyOrder workerPolicy2 = policyOrders.get(j);
+                if (workerPolicy.getEndTime().after(workerPolicy2.getStartTime()) && workerPolicy2.getEndTime().after(workerPolicy.getStartTime())){
+                    return true;
+                }
+            }
+        }
+
+        return false;
+
+    }
 }

+ 24 - 0
mall-server-api/src/main/resources/mapper/PolicyCMapper.xml

@@ -136,4 +136,28 @@
         </if>
         ${ex.orderBy}
     </select>
+    <select id="listDs" resultType="com.gree.mall.manager.bean.policy.PolicyOrderDsVO">
+        SELECT
+        ${ex.selected}
+        FROM policy_order a
+        ${ex.query}
+        and a.type = 'DS'
+        and a.is_pay = 'YES'
+        <if test="adminCompanyIds != null and adminCompanyIds.size > 0">
+            AND a.company_wechat_id IN
+            <foreach item="item" index="index" collection="adminCompanyIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
+            AND a.websit_id IN
+            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
 </mapper>

BIN
mall-server-api/src/main/resources/template/第三者保险导入.xlsx