wuhp 2 lat temu
rodzic
commit
10725753aa

+ 45 - 0
src/main/java/com/ydtech/modules/admin/controller/deptBalance/DeptBalanceController.java

@@ -0,0 +1,45 @@
+package com.ydtech.modules.admin.controller.deptBalance;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.dto.DeptBalanceDto;
+import com.ydtech.modules.admin.model.vo.DeptBalanceVo;
+import com.ydtech.modules.admin.service.DeptBalanceService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(tags = "机构管理费统计")
+@RequestMapping("/deptBalance")
+@RestController
+public class DeptBalanceController {
+
+    @Autowired
+    private DeptBalanceService deptBalanceService;
+
+
+
+    /**
+     *  @version
+     *  @author: whp
+     *  @Date: 2024/08/14 9:04
+     *  @Description:  机构负责人统计
+     */
+    @PostMapping("deptLeaderStatistics")
+    @ApiOperation(value = "机构负责人统计")
+    public HttpResult<IPage<DeptBalanceDto>> queryDeptLeaderStatistics(@RequestBody DeptBalanceVo deptBalanceVo) {
+            HttpResult<IPage<DeptBalanceDto>> result = deptBalanceService.queryDeptLeaderStatistics(deptBalanceVo);
+            return result;
+    }
+
+
+
+
+
+
+}

+ 16 - 0
src/main/java/com/ydtech/modules/admin/controller/profitAnalysis/ProfitAnalysisController.java

@@ -45,6 +45,22 @@ public class ProfitAnalysisController {
         }
     }
 
+    /**
+     *  @version
+     *  @author: whp
+     *  @Date: 2024/8/16 15:35
+     *  @Description:  查询利润分析统计
+     */
+    @PostMapping("getProfitAnalysisQueryList")
+    @ApiOperation(value = "查询利润分析数据")
+    public HttpResult<List<ProfitAnalysisDto>> getProfitAnalysisQueryList(@RequestBody ProfitAnalysisQueryDto profitAnalysisQueryDto) {
+        try{
+            List<ProfitAnalysisDto> result = profitAnalysisService.getProfitAnalysisQueryList(profitAnalysisQueryDto);
+            return HttpResult.ok("查询数据成功", result);
+        }catch (Exception e){
+            return HttpResult.error("查询错误"+e.getMessage());
+        }
+    }
 
 
 }

+ 13 - 0
src/main/java/com/ydtech/modules/admin/dao/DeptBalanceMapper.java

@@ -0,0 +1,13 @@
+package com.ydtech.modules.admin.dao;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.modules.admin.model.dto.DeptBalanceDto;
+import com.ydtech.modules.admin.model.vo.DeptBalanceVo;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface DeptBalanceMapper {
+    IPage<DeptBalanceDto> queryDeptLeaderStatistics(Page page, DeptBalanceVo deptBalanceVo);
+
+}

+ 43 - 0
src/main/java/com/ydtech/modules/admin/model/dto/DeptBalanceDto.java

@@ -0,0 +1,43 @@
+package com.ydtech.modules.admin.model.dto;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ *  机构管理费统计dto
+ */
+@Data
+@ApiModel("机构管理费")
+@NoArgsConstructor
+public class DeptBalanceDto implements Serializable {
+
+    @ApiModelProperty(value = "机构名称")
+    private String deptName;
+
+    @ApiModelProperty(value = "机构负责人")
+    private String deptLeader;
+
+    @ApiModelProperty(value = "机构地址")
+    private String deptAddress;
+
+    @ApiModelProperty(value = "机构管理费")
+    private BigDecimal deptManagementFee;
+
+    @ApiModelProperty(value = "总收入")
+    private BigDecimal totalIncome;
+
+    @ApiModelProperty(value = "已提现")
+    private BigDecimal withdrawn;
+
+    @ApiModelProperty(value = "未体现")
+    private BigDecimal notWithdrawn;
+
+    @ApiModelProperty(value = "机构级别")
+    private BigDecimal comLevel;
+}

+ 33 - 0
src/main/java/com/ydtech/modules/admin/model/vo/DeptBalanceVo.java

@@ -0,0 +1,33 @@
+package com.ydtech.modules.admin.model.vo;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import java.io.Serializable;
+
+@Data
+@ApiModel("机构负责人统计")
+public class DeptBalanceVo implements Serializable {
+
+    @ApiModelProperty(value = "省机构id")
+    private String provinceId;
+
+    @ApiModelProperty(value = "市机构id")
+    private String cityId;
+
+    @ApiModelProperty(value = "县机构id")
+    private String countyId;
+
+    @ApiModelProperty(value = "门店机构id")
+    private String houseId;
+
+    @ApiModelProperty(value = "每页页数")
+    private int pageSize;
+
+    @ApiModelProperty(value = "页数")
+    @Min(value = 1, message = "页数最小为1")
+    private int pageNum;
+}

+ 17 - 0
src/main/java/com/ydtech/modules/admin/service/DeptBalanceService.java

@@ -0,0 +1,17 @@
+package com.ydtech.modules.admin.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.model.dto.DeptBalanceDto;
+import com.ydtech.modules.admin.model.vo.DeptBalanceVo;
+
+public interface DeptBalanceService {
+
+    /**
+     *  @version
+     *  @author: whp
+     *  @Date: 2024/08/14 9:04
+     *  @Description:  机构负责人统计
+     */
+    HttpResult<IPage<DeptBalanceDto>> queryDeptLeaderStatistics(DeptBalanceVo deptBalanceVo);
+}

+ 2 - 0
src/main/java/com/ydtech/modules/admin/service/ProfitAnalysisService.java

@@ -20,6 +20,8 @@ public interface ProfitAnalysisService {
      *  @Description:  利润分析
      */
     List<ProfitAnalysisDto> queryPage(ProfitAnalysisQueryDto profitAnalysisQueryDto);
+
+    List<ProfitAnalysisDto> getProfitAnalysisQueryList(ProfitAnalysisQueryDto profitAnalysisQueryDto);
 }
 
 

+ 54 - 0
src/main/java/com/ydtech/modules/admin/service/impl/DeptBalanceServiceImpl.java

@@ -0,0 +1,54 @@
+package com.ydtech.modules.admin.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.admin.dao.DeptBalanceMapper;
+import com.ydtech.modules.admin.model.dto.DeptBalanceDto;
+import com.ydtech.modules.admin.model.dto.EsmUserReferrerDTO;
+import com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto;
+import com.ydtech.modules.admin.model.vo.DeptBalanceVo;
+import com.ydtech.modules.admin.service.DeptBalanceService;
+import com.ydtech.modules.admin.service.SysAgencyLeaderService;
+import com.ydtech.modules.base.model.vo.PageVo;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesSumEntity;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Service
+public class DeptBalanceServiceImpl implements DeptBalanceService {
+
+
+    @Autowired
+    private SysAgencyLeaderService sysAgencyLeaderService;
+
+    @Autowired
+    private DeptBalanceMapper deptBalanceMapper;
+
+    /**
+     *  @version
+     *  @author: whp
+     *  @Date: 2024/08/14 9:04
+     *  @Description:  机构负责人统计
+     */
+    @Override
+    public HttpResult<IPage<DeptBalanceDto>> queryDeptLeaderStatistics(DeptBalanceVo deptBalanceVo) {
+        try {
+            PageVo<DeptBalanceDto> pageVo = new PageVo<>();
+            Page page = new Page(deptBalanceVo.getPageNum(), deptBalanceVo.getPageSize());
+            pageVo.setPageNum(deptBalanceVo.getPageNum());
+            pageVo.setPageSize(deptBalanceVo.getPageSize());
+            IPage<DeptBalanceDto> sysUserListPage = deptBalanceMapper.queryDeptLeaderStatistics(page, deptBalanceVo);
+            return HttpResult.ok(sysUserListPage);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return HttpResult.error("查询异常");
+        }
+    }
+
+}

+ 11 - 0
src/main/java/com/ydtech/modules/admin/service/impl/ProfitAnalysisServiceImpl.java

@@ -41,6 +41,17 @@ public class ProfitAnalysisServiceImpl implements ProfitAnalysisService {
         List<ProfitAnalysisDto> list = insPlyIncomeMapper.queryPage(profitAnalysisQueryDto);
         return list;
     }
+    /**
+     *  @version
+     *  @author: whp
+     *  @Date: 2024/8/16 15:35
+     *  @Description:  查询利润分析统计
+     */
+    @Override
+    public List<ProfitAnalysisDto> getProfitAnalysisQueryList(ProfitAnalysisQueryDto profitAnalysisQueryDto) {
+
+        return insPlyIncomeMapper.getProfitAnalysisQueryList(profitAnalysisQueryDto);
+    }
 
     /**
      *  @version

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

@@ -2098,10 +2098,10 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                 BigDecimal subtract = totalAmount.subtract(settlementAmount);
                 item.setRemainingAmount(subtract);
                 item.setCreateTime(LocalDateTime.now());
+                item.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());
+                item.setSigningTime(localDateTime);
+                item.setTotalAmount(item.getRemainingAmount());
             }
-            item.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());
-            item.setSigningTime(localDateTime);
-            item.setTotalAmount(item.getRemainingAmount());
         }
         insuranceHandlingSettlementMonthService.saveBatch(insuranceHandlingList);
 

+ 50 - 0
src/main/resources/mapper/modules/admin/DeptBalanceMapper.xml

@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ydtech.modules.admin.dao.DeptBalanceMapper">
+
+
+    <select id="queryDeptLeaderStatistics" resultType="com.ydtech.modules.admin.model.dto.DeptBalanceDto">
+        SELECT
+        sd.id as "deptId",
+        sd.name as "deptName",
+        sd.address as "deptAddress",
+        su.name as "userName",
+        su.comlevel as "comLevel",
+        IFNULL(b.sumPremium,0)  as "deptManagementFee",
+        IFNULL(b.sumPremium,0) * IFNULL((sal.proportional /100),0) as "totalIncome",
+        IFNULL(b.sumPremium,0) * IFNULL((sal.proportional /100)) -IFNULL(c.sumHistoryFee,0) as "notWithdrawn",
+        IFNULL(c.sumHistoryFee,0) as "withdrawn"
+        FROM
+        sys_dept  sd
+        left  join  sys_agency_leader sal on sal.dept_id =sd.id
+        left  join  sys_user su on su.id =sal.user_id
+        left join  (
+        select io.userid as "userId", sum(iac.sumpremium) as "sumPremium"  from  ins_orders  io
+
+        where iac.orderstatus='3'
+        GROUP BY   io.userid
+        )  b  on b.userId = su.id
+        left  join  (
+        select sum(safa.history_fee) as "sumHistoryFee",safa.user_id  as "userId"  from  sys_agency_fee_approval_record safa
+        where safa.`status`='1'
+        group  by  safa.user_id
+        )  c  on  c.userId =su.id
+        <where>
+            1=1
+            <if test="vo.provinceId != null and vo.provinceId != ''">
+                and sd.id like  concat('%',#{vo.provinceId},'%')
+            </if>
+            <if test="vo.cityId != null and vo.cityId != ''">
+                and sd.id like concat('%',#{vo.cityId},'%')
+            </if>
+            <if test="vo.countyId != null and vo.countyId != ''">
+                and sd.id like concat('%',#{vo.countyId},'%')
+            </if>
+            <if test="vo.houseId != null and vo.houseId != ''">
+                and sd.id like concat('%',#{vo.houseId},'%')
+            </if>
+        </where>
+    </select>
+
+
+</mapper>

+ 38 - 45
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -2462,54 +2462,47 @@
 
     <select id="queryDateByType"
             resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
-        select
-        a.years as yearAndMonth,
-        a.commissionFeevalue as commissionFeevalue,
-        a.noInvoicCommissionFeevalue as noInvoicCommissionFeevalue,
-        a.readyCommissionFeevalue  as readyCommissionFeevalue,
-        ifnull(b.settlementAmount,0) as settlementAmount,
-        ifnull(b.noSettlementAmount,0) as noSettlementAmount
-        from (
         SELECT
-        DATE_FORMAT( a.create_time, '%Y-%m' ) as years,
-        SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS commissionFeevalue,
-        SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS noInvoicCommissionFeevalue,
-        SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS readyCommissionFeevalue
+            a.subSigning as "yearAndMonth",
+            a.allAmount as "commissionFeevalue",
+            b.commSettLement +c.otherSettlementAmount as "noInvoicCommissionFeevalue",
+            a.allAmount-( b.commSettLement +c.otherSettlementAmount) as "readyCommissionFeevalue",
+            (c.invoicAmount - c.otherSettlementAmount) +  (b.remainingAmount) as "settlementAmount"
         FROM
-        ins_ply_income a
-        LEFT JOIN
-        ptl_agreement pa ON pa.id = a.agreement_id
-        <where>
-            1=1
-            <if test="vo.type !=null  and  vo.type  !=''">
-                and pa.agreement_type =#{vo.type}
-            </if>
-            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                AND  a.create_time  BETWEEN #{vo.beginDate} AND #{vo.endDate}
-            </if>
-        </where>
-        GROUP BY
-        DATE_FORMAT( a.create_time, '%Y-%m' )
+            (
+                SELECT
+                    sum( a.all_fee_value ) AS "allAmount",
+                    DATE_FORMAT( a.signdate, '%Y-%m' ) AS "subSigning"
+                FROM
+                    ins_ply_income a
+                        LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
+                WHERE
+                    pa.agreement_type = '2'
+                GROUP BY
+                    DATE_FORMAT( a.signdate, '%Y-%m' )
+            )  a    left  join  (
+                SELECT
+                    sum( a.settlement_amount ) as "commSettLement",
+                    sum( a.remaining_amount ) as "remainingAmount",
+                    DATE_FORMAT( a.signing_time, '%Y-%m' )  as "subSigning"
+                FROM
+                    sys_insurance_handling_settlement_month a
+                GROUP BY
+                    DATE_FORMAT( a.signing_time, '%Y-%m' )
+            ) b  on  b.subSigning=a.subSigning
+                    left  join  (
+                SELECT
+                    SUM( CASE WHEN a.settlement_status = '2' THEN IFNULL( a.settlement_amount, 0 ) ELSE 0 END ) AS "otherSettlementAmount",
+                    SUM( CASE WHEN a.settlement_status = '1' THEN IFNULL( a.settlement_amount, 0 ) ELSE 0 END ) AS "invoicAmount",
+                    DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigning"
+                FROM
+                    settlement_documentary_fees a
+                WHERE
+                    a.handling_fees_status = '1'
+                GROUP BY
+                    DATE_FORMAT( a.signing_time, '%Y-%m' )
+            )  c  on  c.subSigning=a.subSigning
 
-        )  a   left join
-        (
-        SELECT
-        DATE_FORMAT( a.create_time, '%Y-%m' ) as years,
-        SUM(IFNULL(a.settlement_amount ,0 )) as  settlementAmount,
-        SUM(IFNULL(a.total_amount ,0 ) -IFNULL(a.settlement_amount ,0 ) ) AS noSettlementAmount
-        FROM
-        settlement_documentary_fees a
-        <where>
-            a.settlement_status=2
-            <if test="vo.type !=null  and  vo.type  !=''">
-                and  a.agreement_type =#{vo.type}
-            </if>
-            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                AND  a.create_time  BETWEEN #{vo.beginDate} AND #{vo.endDate}
-            </if>
-        </where>
-        GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' )
-        )  b  on a.years =b.years
     </select>
 
     <select id="queryDateByTypeMonthSumAmount" resultType="java.math.BigDecimal">