Просмотр исходного кода

1.跟单费结算金额逻辑调整

wuhp 2 лет назад
Родитель
Сommit
f12c250596

+ 4 - 1
src/main/java/com/ydtech/modules/fnc/entity/InsPlyIncome.java

@@ -333,7 +333,7 @@ public class InsPlyIncome implements Serializable {
 
 
     @ApiModelProperty("跟单费未结算金额")
     @ApiModelProperty("跟单费未结算金额")
     @TableField(exist = false)
     @TableField(exist = false)
-    private BigDecimal unsettledAmount;
+    private BigDecimal unSettledAmount;
 
 
     @ApiModelProperty("开始时间")
     @ApiModelProperty("开始时间")
     @TableField(exist = false)
     @TableField(exist = false)
@@ -372,6 +372,9 @@ public class InsPlyIncome implements Serializable {
     @ApiModelProperty("开票ids")
     @ApiModelProperty("开票ids")
     @TableField(exist = false)
     @TableField(exist = false)
     private String incomeIds;
     private String incomeIds;
+    @ApiModelProperty("已经开票未结算ids")
+    @TableField(exist = false)
+    private String invoicIds;
 
 
 
 
     public InsPlyIncome(String orderno, String policyno, String syPolicyno, String noPolicyno, String settleno, String deptId, String deptName, String riskcode, LocalDateTime payDate, LocalDateTime signDate, String companyId, String companyName, String agreementId, String licenseno, BigDecimal taxamount, BigDecimal noTaxPremium, BigDecimal commissionFeerate, BigDecimal otherFeerate, BigDecimal commissionFeevalue, BigDecimal otherFeevalue, BigDecimal allFeeValue, BigDecimal finalFeeValue, BigDecimal doingFeeValue, LocalDate createTime, String voucherNumber, String contractId, String contractFileId, String handlingFeesStatus, String documentaryFeesStatus, String isNotCar, String isNotDocumentary) {
     public InsPlyIncome(String orderno, String policyno, String syPolicyno, String noPolicyno, String settleno, String deptId, String deptName, String riskcode, LocalDateTime payDate, LocalDateTime signDate, String companyId, String companyName, String agreementId, String licenseno, BigDecimal taxamount, BigDecimal noTaxPremium, BigDecimal commissionFeerate, BigDecimal otherFeerate, BigDecimal commissionFeevalue, BigDecimal otherFeevalue, BigDecimal allFeeValue, BigDecimal finalFeeValue, BigDecimal doingFeeValue, LocalDate createTime, String voucherNumber, String contractId, String contractFileId, String handlingFeesStatus, String documentaryFeesStatus, String isNotCar, String isNotDocumentary) {

+ 14 - 2
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -17,6 +17,7 @@ import com.ydtech.modules.esm.service.EsmInsCompanyService;
 import com.ydtech.modules.fnc.entity.InsAreaCompany;
 import com.ydtech.modules.fnc.entity.InsAreaCompany;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryLogEntity;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryLogEntity;
 import com.ydtech.modules.fnc.service.InsPlyIncomeService;
 import com.ydtech.modules.fnc.service.InsPlyIncomeService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -762,7 +763,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Transactional
     @Transactional
     public HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo) {
     public HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo) {
 //  通过ids 查出跟单非结算单
 //  通过ids 查出跟单非结算单
-        String ids = insPlyIncomeVo.getIncomeIds();
+        String ids = insPlyIncomeVo.getIds();
         if(StringUtils.isNotEmpty(ids)){
         if(StringUtils.isNotEmpty(ids)){
             String[] split = ids.split(",");
             String[] split = ids.split(",");
             for (int i =0; i <split.length ; i++) {
             for (int i =0; i <split.length ; i++) {
@@ -868,7 +869,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Transactional
     @Transactional
     public HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo) {
     public HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo) {
         //  通过ids 查出跟单非结算单
         //  通过ids 查出跟单非结算单
-        String ids = insPlyIncomeVo.getIncomeIds();
+        String ids = insPlyIncomeVo.getIds();
         if(StringUtils.isNotEmpty(ids)){
         if(StringUtils.isNotEmpty(ids)){
             String[] split = ids.split(",");
             String[] split = ids.split(",");
             for (int i =0; i <split.length ; i++) {
             for (int i =0; i <split.length ; i++) {
@@ -885,10 +886,20 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
         if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
             settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
             settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
         }
         }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            settlementDocumentaryFeesVo.setYear(insPlyIncomeVo.getYear());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
+            settlementDocumentaryFeesVo.setMonth(insPlyIncomeVo.getMonth());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getDay())){
+            settlementDocumentaryFeesVo.setDay(insPlyIncomeVo.getDay());
+        }
         settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
         settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
         settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue());  //其他费用金额
         settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue());  //其他费用金额
         settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
         settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
         settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
         settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
+        settlementDocumentaryFeesVo.setCreateTime(LocalDate.now());
         settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
         settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
         settlementDocumentaryFeesVo.setSettlementStatus("1");
         settlementDocumentaryFeesVo.setSettlementStatus("1");
         return  settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
         return  settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
@@ -983,6 +994,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     public InsPlyIncome bxTotalAmount(InsPlyIncomeVo insPlyIncomeVo) {
     public InsPlyIncome bxTotalAmount(InsPlyIncomeVo insPlyIncomeVo) {
         HashMap<String, Object> params = new HashMap<>();
         HashMap<String, Object> params = new HashMap<>();
         params = this.saveParams(insPlyIncomeVo, params);
         params = this.saveParams(insPlyIncomeVo, params);
+        params.remove("handlingFeesStatus");
         InsPlyIncome totalledAmount =baseMapper.bxTotalAmount(params);  //总金额
         InsPlyIncome totalledAmount =baseMapper.bxTotalAmount(params);  //总金额
         return totalledAmount;
         return totalledAmount;
     }
     }

+ 3 - 0
src/main/java/com/ydtech/modules/fnc/vo/InsPlyIncomeVo.java

@@ -238,4 +238,7 @@ public class InsPlyIncomeVo implements Serializable {
     @ApiModelProperty("商业跟单金额")
     @ApiModelProperty("商业跟单金额")
     private BigDecimal syOtherCostsPremium;
     private BigDecimal syOtherCostsPremium;
 
 
+    @ApiModelProperty("已经开票未结算ids")
+    private String invoicIds;
+
 }
 }

+ 9 - 2
src/main/java/com/ydtech/modules/fnc/vo/SettlementDocumentaryFeesVo.java

@@ -31,7 +31,7 @@ public class SettlementDocumentaryFeesVo implements Serializable {
     private BigDecimal totalAmount;
     private BigDecimal totalAmount;
 
 
     @ApiModelProperty("创建时间")
     @ApiModelProperty("创建时间")
-    private LocalDateTime createTime;
+    private LocalDate createTime;
 
 
     @ApiModelProperty("结算金额")
     @ApiModelProperty("结算金额")
     @TableField("settlement_amount")
     @TableField("settlement_amount")
@@ -43,7 +43,7 @@ public class SettlementDocumentaryFeesVo implements Serializable {
 
 
     @ApiModelProperty("开始时间")
     @ApiModelProperty("开始时间")
     @JsonFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
-    private LocalDateTime startTime;
+    private LocalDate startTime;
 
 
     @ApiModelProperty("结束时间")
     @ApiModelProperty("结束时间")
     @JsonFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
@@ -69,4 +69,11 @@ public class SettlementDocumentaryFeesVo implements Serializable {
 
 
     @ApiModelProperty("结算ids")
     @ApiModelProperty("结算ids")
     private String ids;
     private String ids;
+
+    @ApiModelProperty("年")
+    private String year;
+    @ApiModelProperty("月")
+    private String month;
+    @ApiModelProperty("日")
+    private String day;
 }
 }

+ 8 - 9
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -740,19 +740,18 @@
             a.company_id AS "companyId",
             a.company_id AS "companyId",
             MAX( a.company_name ) AS "companyName",
             MAX( a.company_name ) AS "companyName",
             MAX( a.partner_companies_name) as "partnerCompaniesName",
             MAX( a.partner_companies_name) as "partnerCompaniesName",
-            IF(MAX( c.unsettledAmount ) IS NULL , sum( a.other_feevalue ),  sum( a.other_feevalue ) - MAX(d.settleMentAmount) ) AS "noInvoicCommissionFeevalue",
-            GROUP_CONCAT(a.id) as  "incomeIds",
-            MAX(d.settleMentAmount) as "invoicCommissionFeevalue",
-            MAX(e.settleMentAmount) as "settleMentAmount",
-            IF(MAX( f.unSettledAmount ) is null ,MAX( d.settleMentAmount ) ,MAX( f.unSettledAmount )) AS "unSettledAmount",
+            IF(MAX( c.unsettledAmount ) IS NULL , sum( a.other_feevalue ),  MAX( c.unsettledAmount ) ) AS "noInvoicCommissionFeevalue",
+            IF(MAX(c.invoicIds) IS NULL ,  GROUP_CONCAT(a.id),MAX(c.invoicIds) ) as  "incomeIds",
+            MAX(c.settleMentAmount) -MAX( f.settleMentAmount )  AS "invoicCommissionFeevalue",
+            MAX(f.settleMentAmount) as "settleMentAmount",
+            GROUP_CONCAT(a.id) as "ids",
+            IF(MAX( f.unSettledAmount ) is null ,MAX( c.settleMentAmount ) ,MAX( f.unSettledAmount )) AS "unSettledAmount",
             sum( a.other_feevalue ) AS "otherFeevalue"
             sum( a.other_feevalue ) AS "otherFeevalue"
         FROM
         FROM
             ins_ply_income a
             ins_ply_income a
                 LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
                 LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
-                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( a.unsettled_amount ) AS "unsettledAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '1' GROUP BY company_id ) c ON c.companyId = a.company_id
-                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '1' GROUP BY company_id ) d ON d.companyId = a.company_id
-                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '2' GROUP BY company_id ) e ON e.companyId = a.company_id
-                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( unsettled_amount ) AS "unSettledAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '2' GROUP BY company_id ) f ON f.companyId = a.company_id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", MIN( a.unsettled_amount ) AS "unsettledAmount" ,sum( settlement_amount ) AS "settleMentAmount", GROUP_CONCAT(a.id) as "invoicIds" FROM settlement_documentary_fees a WHERE a.settlement_status = '1' GROUP BY company_id ) c ON c.companyId = a.company_id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", MIN( unsettled_amount ) AS "unSettledAmount",sum( settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '2' GROUP BY company_id ) f ON f.companyId = a.company_id
        <where>
        <where>
            1=1
            1=1
            <if test="agreementType !=null  and agreementType!='' ">
            <if test="agreementType !=null  and agreementType!='' ">