dongxin 1 год назад
Родитель
Сommit
afe629066c

+ 62 - 0
commons/src/main/java/com/jzg/commons/entity/dto/AgreementContactAddParam.java

@@ -0,0 +1,62 @@
+package com.jzg.commons.entity.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "外部协议表新增dto")
+@Data
+public class AgreementContactAddParam {
+
+    @Schema(description = "协议名称")
+    @Size(min=1,max=50,message = "协议名称长度不能大于50")
+    @NotNull(message = "协议名称不能为空")
+    private String agreementTitle;
+
+    @Schema(description = "协议简称")
+    @Size(min=1,max=50,message = "协议简称长度不能大于50")
+    @NotNull(message = "协议简称不能为空")
+    private String agreementAbbreviation;
+
+    @Schema(description = "协议生效时间")
+//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @NotNull(message = "协议生效时间不能为空")
+    private LocalDateTime startDate;
+
+    @Schema(description = "协议失效时间")
+//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @NotNull(message = "协议失效时间不能为空")
+    private LocalDateTime endDate;
+
+    @Schema(description = "是否含增值税结算 0-否 1-是")
+    @NotNull(message = "请选择增是否含增值税结算")
+    private Integer withTax;
+
+    @Schema(description = "结算周期")
+    @NotNull(message = "请输入结算周期")
+    private Integer moneyTime;
+
+    @Size(min=1,max=500,message = "协议描述长度不能大于3")
+    @Schema(description = "协议描述")
+    @NotNull(message = "请输入协议描述")
+    private String agreementName;
+
+    @Schema(description = "协议归属id")
+    @NotNull(message = "请选择协议归属")
+    private String deptId;
+
+    @Schema(description = "关联-保险公司id")
+    @NotNull(message = "请选择保险公司")
+    private String companyId;
+
+    @Schema(description = "协议类型 1-平台协议-平台结算 2-私有协议-自行结算 3-网销协议-自行结算")
+    @NotNull(message = "请选择协议类型")
+    private Integer agreementType;
+
+    @Schema(description = "对接管理人id")
+    @NotNull(message = "请选择协议管理人")
+    private String custodianId;
+}

+ 64 - 0
commons/src/main/java/com/jzg/commons/entity/dto/AgreementContactEditParam.java

@@ -0,0 +1,64 @@
+package com.jzg.commons.entity.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "外部协议表修改dto")
+@Data
+public class AgreementContactEditParam {
+
+    @NotNull(message = "协议id不能为空")
+    @Schema(description = "协议id")
+    private String id;
+
+    @Schema(description = "协议名称")
+    @Size(min=1,max=50,message = "协议名称长度不能大于50")
+    @NotNull(message = "协议名称不能为空")
+    private String agreementTitle;
+
+    @Schema(description = "协议简称")
+    @Size(min=1,max=50,message = "协议简称长度不能大于50")
+    @NotNull(message = "协议简称不能为空")
+    private String agreementAbbreviation;
+
+    @Schema(description = "协议生效时间")
+    @NotNull(message = "协议生效时间不能为空")
+    private LocalDateTime startDate;
+
+    @Schema(description = "协议失效时间")
+    @NotNull(message = "协议失效时间不能为空")
+    private LocalDateTime endDate;
+
+    @Schema(description = "是否含增值税结算 0-否 1-是")
+    @NotNull(message = "请选择增是否含增值税结算")
+    private Integer withTax;
+
+    @Schema(description = "结算周期")
+    @NotNull(message = "请输入结算周期")
+    private Integer moneyTime;
+
+    @Size(min=1,max=500,message = "协议描述长度不能大于3")
+    @Schema(description = "协议描述")
+    @NotNull(message = "请输入协议描述")
+    private String agreementName;
+
+    @Schema(description = "协议归属id")
+    @NotNull(message = "请选择协议归属")
+    private String deptId;
+
+    @Schema(description = "关联-保险公司id")
+    @NotNull(message = "请选择保险公司")
+    private String companyId;
+
+    @Schema(description = "协议类型 1-平台协议-平台结算 2-私有协议-自行结算 3-网销协议-自行结算")
+    @NotNull(message = "请选择协议类型")
+    private Integer agreementType;
+
+    @Schema(description = "对接管理人id")
+    @NotNull(message = "请选择协议管理人")
+    private String custodianId;
+}

+ 3 - 0
commons/src/main/java/com/jzg/commons/entity/dto/AgreementParam.java

@@ -37,6 +37,9 @@ public class AgreementParam extends PageRequest {
     @Schema(description = "出单账号")
     private String attributionName;
 
+    @Schema(description = "是否是外部订单的费用  0 否 1 是")
+    private Integer isExternal;
+
     @Schema(description = "生效开始时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime takeStartDate;

+ 43 - 4
tenant/organization/src/main/java/com/jzg/organization/controller/AgreementController.java

@@ -13,7 +13,6 @@ import com.jzg.organization.service.PtlAgreementDeptService;
 import com.jzg.organization.service.PtlAgreementService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.annotation.Resource;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -32,7 +31,7 @@ import java.util.List;
 @RequestMapping("/agreement")
 public class AgreementController extends BaseController {
 
-    @Resource
+    @Autowired
     private PtlAgreementService agreementService;
 
     @Autowired
@@ -69,7 +68,7 @@ public class AgreementController extends BaseController {
     @PostMapping("/agreementAdd")
     public HttpResult agreementAdd(@Validated @RequestBody AgreementAddParam param) {
 
-        boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), null);
+        boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), null, 0);
         AssertionUtils.isFail(nameExists,"协议名称重复!");
         LocalDateTime startDate = param.getStartDate();
         LocalDateTime endDate = param.getEndDate();
@@ -89,7 +88,7 @@ public class AgreementController extends BaseController {
     @PostMapping("/agreementEdit")
     public HttpResult agreementEdit(@Validated @RequestBody AgreementEditParam param) {
 
-        boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), param.getId());
+        boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), param.getId(), 0);
         AssertionUtils.isFail(nameExists,"协议名称重复!");
         LocalDateTime startDate = param.getStartDate();
         LocalDateTime endDate = param.getEndDate();
@@ -182,4 +181,44 @@ public class AgreementController extends BaseController {
         agreementService.agreementCopy(param);
         return HttpResult.ok("复制成功");
     }
+
+    /**
+     * 外部协议添加
+     * @param param
+     * @return
+     */
+    @Operation(summary = "外部协议添加")
+    @PostMapping("/contactAdd")
+    public HttpResult contactAdd(@Validated @RequestBody AgreementContactAddParam param) {
+
+        boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), null,1);
+        AssertionUtils.isFail(nameExists,"协议名称重复!");
+        LocalDateTime startDate = param.getStartDate();
+        LocalDateTime endDate = param.getEndDate();
+        if(endDate.isBefore(startDate) || startDate.isEqual(endDate)){
+            AssertionUtils.isFail(nameExists,"协议生效时间不能大于失效时间!");
+        }
+        agreementService.contactAdd(param);
+        return HttpResult.ok("新增成功");
+    }
+
+    /**
+     * 外部协议修改
+     * @param param
+     * @return
+     */
+    @Operation(summary = "外部协议修改")
+    @PostMapping("/contactEdit")
+    public HttpResult contactEdit(@Validated @RequestBody AgreementContactEditParam param) {
+
+        boolean nameExists = agreementService.isExistsName(param.getAgreementTitle(), param.getId(),1);
+        AssertionUtils.isFail(nameExists,"协议名称重复!");
+        LocalDateTime startDate = param.getStartDate();
+        LocalDateTime endDate = param.getEndDate();
+        if(endDate.isBefore(startDate) || startDate.isEqual(endDate)){
+            AssertionUtils.isFail(nameExists,"协议生效时间不能大于失效时间!");
+        }
+        agreementService.contactEdit(param);
+        return HttpResult.ok("修改成功");
+    }
 }

+ 16 - 5
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementService.java

@@ -1,10 +1,7 @@
 package com.jzg.organization.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.jzg.commons.entity.dto.AgreementAddParam;
-import com.jzg.commons.entity.dto.AgreementCopyParam;
-import com.jzg.commons.entity.dto.AgreementEditParam;
-import com.jzg.commons.entity.dto.AgreementParam;
+import com.jzg.commons.entity.dto.*;
 import com.jzg.commons.entity.po.PtlAgreement;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jzg.commons.entity.po.PtlAgreementCost;
@@ -46,11 +43,13 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
 
     /**
      * 根据名称 判断是否存在数据
+     *
      * @param agreementTitle
      * @param id
+     * @param isExternal
      * @return
      */
-    boolean isExistsName(String agreementTitle, String id);
+    boolean isExistsName(String agreementTitle, String id, int isExternal);
 
     /**
      * 协议新增
@@ -113,4 +112,16 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
                          List<String> costIds,
                          List<PtlAgreementCost> costList,
                          PtlAgreement newAgreement);
+
+    /**
+     * 外部协议新增
+     * @param param
+     */
+    void contactAdd(AgreementContactAddParam param);
+
+    /**
+     * 外部协议修改
+     * @param param
+     */
+    void contactEdit(AgreementContactEditParam param);
 }

+ 53 - 7
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementServiceImpl.java

@@ -7,10 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
-import com.jzg.commons.entity.dto.AgreementAddParam;
-import com.jzg.commons.entity.dto.AgreementCopyParam;
-import com.jzg.commons.entity.dto.AgreementEditParam;
-import com.jzg.commons.entity.dto.AgreementParam;
+import com.jzg.commons.entity.dto.*;
 import com.jzg.commons.entity.enums.YesNoEnum;
 import com.jzg.commons.entity.po.*;
 import com.jzg.commons.entity.vo.*;
@@ -24,7 +21,6 @@ import com.jzg.organization.service.*;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -48,7 +44,6 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
     @Autowired
     private PtlAgreementDeptService agreementDeptService;
 
-    @Qualifier("baseController")
     @Autowired
     private BaseController baseController;
 
@@ -126,9 +121,10 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
     }
 
     @Override
-    public boolean isExistsName(String agreementTitle, String id) {
+    public boolean isExistsName(String agreementTitle, String id, int isExternal) {
         long count = this.count(new LambdaQueryWrapper<PtlAgreement>()
                 .eq(PtlAgreement::getAgreementTitle, agreementTitle)
+                .eq(PtlAgreement::getIsExternal, isExternal)
                 .ne(StringUtils.isNotNull(id),PtlAgreement::getId, id)
                 .eq(PtlAgreement::getIsDelete,0)
         );
@@ -362,6 +358,56 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         });
     }
 
+    @Override
+    public void contactAdd(AgreementContactAddParam param) {
+        PtlAgreement ptlAgreement = new PtlAgreement();
+        BeanUtils.copyProperties(param,ptlAgreement);
+        String sysCode = baseController.getUserSystemCode();
+
+        // 获取保险公司信息
+        HttpResult<EsmInsCompany> result = companyClient.findById(param.getCompanyId());
+        String companyCode = "";
+        if(result.getCode() == 200 && Objects.nonNull(result.getData())){
+            companyCode = result.getData().getCompanyCode();
+        }else{
+            throw new SystemException("无法获取到保险公司信息");
+        }
+        // code生成规则 系统code + 保险公司code + 时间戳
+        ptlAgreement.setAgreementCode(sysCode + companyCode + +System.currentTimeMillis());
+        ptlAgreement.setSerialNumber(0);
+        ptlAgreement.setIsExternal(1);
+        ptlAgreement.setIsEnable(YesNoEnum.NO.getCode()); // 启用
+
+        // 判断生效状态
+        LocalDateTime startDate = param.getStartDate();
+        LocalDateTime endDate = param.getEndDate();
+        LocalDateTime now = LocalDateTime.now();
+        //更新是否有效
+        if (now.isEqual(startDate) || (now.isAfter(startDate) && now.isBefore(endDate))) {
+            ptlAgreement.setValidStatus("0");
+        } else {
+            ptlAgreement.setValidStatus("1");
+        }
+        save(ptlAgreement);
+    }
+
+    @Override
+    public void contactEdit(AgreementContactEditParam param) {
+        PtlAgreement ptlAgreement = new PtlAgreement();
+        BeanUtils.copyProperties(param,ptlAgreement);
+        // 判断生效状态
+        LocalDateTime startDate = param.getStartDate();
+        LocalDateTime endDate = param.getEndDate();
+        LocalDateTime now = LocalDateTime.now();
+        //更新是否有效
+        if (now.isEqual(startDate) || (now.isAfter(startDate) && now.isBefore(endDate))) {
+            ptlAgreement.setValidStatus("0");
+        } else {
+            ptlAgreement.setValidStatus("1");
+        }
+        updateById(ptlAgreement);
+    }
+
 }
 
 

+ 3 - 0
tenant/organization/src/main/resources/mapper/PtlAgreementMapper.xml

@@ -84,6 +84,9 @@
             <if test="param.withTax != null ">
                 and pa.with_tax = #{param.withTax}
             </if>
+            <if test="param.isExternal != null ">
+                and pa.is_external = #{param.isExternal}
+            </if>
             <if test="param.dockingPerson != null and param.dockingPerson != ''">
                 and ( pa.docking_person = #{param.dockingPerson} or pa.docking_phone = #{param.dockingPerson} )
             </if>