Quellcode durchsuchen

1.控制台 钱包机构负责人
2.数据大屏添加创建日记 签单日期的查询条件

wuhp vor 1 Jahr
Ursprung
Commit
2d3e9abc65

+ 3 - 0
src/main/java/com/ydtech/modules/admin/dao/SysPartnerAccountMapper.java

@@ -2,9 +2,12 @@ package com.ydtech.modules.admin.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ydtech.modules.admin.model.SysPartnerAccount;
+import com.ydtech.modules.admin.model.dto.DeptBalanceDto;
 import org.apache.ibatis.annotations.Mapper;
 
 @Mapper
 public interface SysPartnerAccountMapper extends BaseMapper<SysPartnerAccount> {
 
+    SysPartnerAccount getByDeptBalanceDto(DeptBalanceDto itemLeader);
+
 }

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

@@ -68,4 +68,10 @@ public class DeptBalanceDto implements Serializable {
         this.notWithdrawn = notWithdrawn;
         this.comLevel = comLevel;
     }
+
+
+
+    private String  beginDate;
+
+    private String  endDate;
 }

+ 32 - 34
src/main/java/com/ydtech/modules/admin/service/impl/DeptBalanceServiceImpl.java

@@ -98,42 +98,40 @@ public class DeptBalanceServiceImpl implements DeptBalanceService {
             List<DeptBalanceDto>  newList =new ArrayList<>();
             if (records !=null && records.size()>0) {
                 for (DeptBalanceDto itemLeader : records) {
-                    BigDecimal allTotalIncome = BigDecimal.ZERO;  // 总保费
-                    BigDecimal allDeptManagementFee = BigDecimal.ZERO;//机构管理费
-                    BigDecimal allWithdrawn = BigDecimal.ZERO;//已体现
-                    BigDecimal allNotWithdrawn = BigDecimal.ZERO;//未提现
-                    String deptId = itemLeader.getDeptId();
-                    String proportional = itemLeader.getProportional();
-                    Date updateTime = itemLeader.getUpdateTime();
-                    Date createTime = itemLeader.getCreateTime();
-                    String dateStr = "";
-                    if (updateTime != null) {
-                        dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(updateTime);
-                    } else {
-                        dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime);
-                    }
-                    HashMap<String, BigDecimal> orderAmount = deptBalanceMapper.getByDeptId(deptId, dateStr,deptBalanceVo.getBeginDate(),deptBalanceVo.getEndDate());
-                    if (orderAmount != null && !orderAmount.isEmpty()) {
-                        BigDecimal totalIncome = orderAmount.get("totalIncome")==null ? BigDecimal.ZERO : orderAmount.get("totalIncome");
-                        allTotalIncome = totalIncome.multiply(new BigDecimal(proportional))
-                                .divide(new BigDecimal("100")).setScale(2, RoundingMode.DOWN);
-                        allDeptManagementFee = this.calculateTotal(orderAmount.get("deptManagementFee"), allDeptManagementFee, null);
-                    }
-                    // 填充 已提现抽成费用和可提现抽成费用
-                    List<SysAgencyFeeApproval> sysAgencyFeeApprovals = sysAgencyFeeApprovalMapper.selectList(new LambdaQueryWrapper<SysAgencyFeeApproval>()
-                            .eq(SysAgencyFeeApproval::getUserId, itemLeader.getUserId())
-                            .eq(SysAgencyFeeApproval::getStatus, 1));
-                    if (sysAgencyFeeApprovals.size() > 0) {
-                        for (SysAgencyFeeApproval sysAgencyFeeApproval : sysAgencyFeeApprovals) {
-                            allWithdrawn = allWithdrawn.add(sysAgencyFeeApproval.getHistoryFee());
+                    String userId = itemLeader.getUserId();
+                    //已提现抽成费用
+                    BigDecimal historyFee = BigDecimal.ZERO;
+//                    SysPartnerAccount sysPartnerAccount = sysPartnerAccountMapper.selectOne(new LambdaQueryWrapper<SysPartnerAccount>().eq(SysPartnerAccount::getUserId, userId));
+                    itemLeader.setBeginDate(deptBalanceVo.getBeginDate());
+                    itemLeader.setEndDate(deptBalanceVo.getEndDate());
+
+                    SysPartnerAccount sysPartnerAccount =sysPartnerAccountMapper.getByDeptBalanceDto(itemLeader);
+                    if (sysPartnerAccount != null) {
+                        BigDecimal sumPremium = sysPartnerAccount.getSumPremium();
+                        BigDecimal extractFee = sysPartnerAccount.getExtractFee();
+                        itemLeader.setTotalIncome(sumPremium);
+                        itemLeader.setDeptManagementFee(extractFee);
+
+
+                        // 填充 已提现抽成费用和可提现抽成费用
+                        List<SysAgencyFeeApproval> sysAgencyFeeApprovals = sysAgencyFeeApprovalMapper.selectList(new LambdaQueryWrapper<SysAgencyFeeApproval>()
+                                .eq(SysAgencyFeeApproval::getUserId, itemLeader.getUserId())
+                                .eq(SysAgencyFeeApproval::getStatus, 1));
+                        if (sysAgencyFeeApprovals.size() > 0) {
+                            for (SysAgencyFeeApproval sysAgencyFeeApproval : sysAgencyFeeApprovals) {
+                                historyFee = historyFee.add(sysAgencyFeeApproval.getHistoryFee());
+                            }
                         }
+                        //已提现
+                        itemLeader.setWithdrawn(historyFee);
+                        //可提现 = 总抽成-已提现
+                        itemLeader.setNotWithdrawn(extractFee.subtract(historyFee));
+                    }else {
+                        itemLeader.setDeptManagementFee(BigDecimal.ZERO);
+                        itemLeader.setTotalIncome(BigDecimal.ZERO);
+                        itemLeader.setWithdrawn(BigDecimal.ZERO);
+                        itemLeader.setNotWithdrawn(BigDecimal.ZERO);
                     }
-                    //可提现 = 总抽成-已提现
-                    allNotWithdrawn = allTotalIncome.subtract(allWithdrawn);
-                    itemLeader.setDeptManagementFee(allTotalIncome);
-                    itemLeader.setTotalIncome(allDeptManagementFee);
-                    itemLeader.setWithdrawn(allWithdrawn);
-                    itemLeader.setNotWithdrawn(allNotWithdrawn);
                     newList.add(itemLeader);
                 }
             }

+ 14 - 0
src/main/java/com/ydtech/modules/largescreen/controller/DataController.java

@@ -58,6 +58,7 @@ public class DataController {
 
     @PostMapping("companySumData")
     public HttpResult companySumData(@RequestBody(required = false) DataQuery dataQuery) {
+        this.changeSignCreateTime(dataQuery);
         List<AgreementData> sumData = dataService.getCompanySumData(dataQuery);
         String[][] result = new String[sumData.size()][7];
 
@@ -83,6 +84,7 @@ public class DataController {
      */
     @PostMapping("orderStatusData")
     public HttpResult orderStatusData(@RequestBody(required = false) DataQuery dataQuery) {
+        this.changeSignCreateTime(dataQuery);
         List<CompanyData> sumData = dataService.getCompanyOrderStatusData(dataQuery);
 
         //转换格式
@@ -121,6 +123,7 @@ public class DataController {
      */
     @PostMapping("mapData")
     public HttpResult mapData(@RequestBody(required = false) DataQuery dataQuery) {
+        this.changeSignCreateTime(dataQuery);
         List<MapData> mapData = dataService.getMapData(dataQuery);
         return HttpResult.ok(mapData);
     }
@@ -198,6 +201,7 @@ public class DataController {
     @PostMapping("todayData")
     public HttpResult todayData(@RequestBody DataQuery dataQuery) {
         dataQuery.setOrderStatus("3");
+        this.changeSignCreateTime(dataQuery);
         List<OrderStatusData> orderStatusData = dataService.getOrderStatusData(dataQuery);
         if (orderStatusData.isEmpty()) {
             return HttpResult.error("当天无已承包数据");
@@ -209,6 +213,16 @@ public class DataController {
         return HttpResult.ok(toDayData);
     }
 
+    private void changeSignCreateTime(DataQuery dataQuery) {
+//      1.录单时间 2.签单时间
+        if(dataQuery.getTimeType().equals("2")){
+            dataQuery.setSignStartDate(dataQuery.getStartDate());
+            dataQuery.setSignEndDate(dataQuery.getEndDate());
+            dataQuery.setStartDate(null);
+            dataQuery.setEndDate(null);
+        }
+    }
+
 
     /**
      * 获取公司数据

+ 12 - 0
src/main/java/com/ydtech/modules/largescreen/model/query/DataQuery.java

@@ -19,4 +19,16 @@ public class DataQuery {
 
     @ApiModelProperty(value = "保险公司")
     private String companyId;
+
+
+    @ApiModelProperty(value = "时间类型")
+    private String timeType;
+
+
+
+    @ApiModelProperty(value = "签单起始日期")
+    private String signStartDate;
+
+    @ApiModelProperty(value = "签单结束日期")
+    private String signEndDate;
 }

+ 21 - 0
src/main/resources/mapper/modules/admin/SysPartnerAccountMapper.xml

@@ -13,4 +13,25 @@
     </resultMap>
 
 
+    <select id="getByDeptBalanceDto" resultType="com.ydtech.modules.admin.model.SysPartnerAccount">
+        select
+            a.id as "id",
+            a.user_id as "userId",
+            a.sum_Premium as "sumPremium",
+            a.extract_fee as "extractFee",
+            a.create_time as "createTime",
+            a.history_fee as "historyFee",
+            a.cash_fee as "cashFee"
+        from sys_partner_account a
+        <where>
+            <if test="beginDate !=null and beginDate !=''  and  endDate !=null and  endDate !=''">
+                AND DATE_FORMAT( a.create_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{beginDate}, '%Y-%m-%d') AND DATE_FORMAT(#{endDate}, '%Y-%m-%d')
+            </if>
+            <if test="userId !=null and userId !=''">
+                AND a.user_id =#{userId}
+            </if>
+        </where>
+
+    </select>
+
 </mapper>

+ 24 - 5
src/main/resources/mapper/modules/largescreen/AgreementDataMapper.xml

@@ -10,7 +10,7 @@
         COALESCE(SUM(jqpremium), 0) AS jqPremium,
         COALESCE(SUM(sypremium), 0) AS syPremium,
         COALESCE(SUM(taxamount), 0) AS taxPremium,
-        COALESCE(SUM(jqpremium) + SUM(sypremium), 0) AS sumPremium,
+        COALESCE(SUM(jqpremium) + SUM(sypremium)  + SUM(jypremium), 0) AS sumPremium,
         COALESCE(COUNT(iac.id), 0) as sumOrderNum
         FROM
         ptl_agreement pa
@@ -23,6 +23,11 @@
         <if test="startDate != null and startDate != ''">
             and iac.createtime BETWEEN #{startDate} and #{endDate}
         </if>
+
+        <if test="signStartDate != null and signStartDate != ''  and signEndDate !=null and signEndDate !=''">
+            and iac.signing_time BETWEEN #{signStartDate} and #{signEndDate}
+        </if>
+
         GROUP BY
         pa.insurance_company_id, pa.insurance_company
         order by
@@ -44,7 +49,7 @@
         COALESCE(SUM(jqpremium), 0) AS jqPremium,
         COALESCE(SUM(sypremium), 0) AS syPremium,
         COALESCE(SUM(taxamount), 0) AS taxPremium,
-        COALESCE(SUM(jqpremium) + SUM(sypremium), 0) AS sumPremium,
+        COALESCE(SUM(jqpremium) + SUM(sypremium) + SUM(jypremium), 0) AS sumPremium,
         COALESCE(COUNT(iac.id), 0) as sumOrderNum
         FROM
         ins_area_company iac
@@ -56,6 +61,11 @@
         <if test="startDate != null and startDate != ''">
             and iac.createtime BETWEEN #{startDate} and #{endDate}
         </if>
+
+        <if test="signStartDate != null and signStartDate != ''  and signEndDate !=null and signEndDate !=''">
+            and iac.signing_time BETWEEN #{signStartDate} and #{signEndDate}
+        </if>
+
         <if test="companyId != null and companyId != ''">
             and iac.company_id = #{companyId}
         </if>
@@ -87,6 +97,10 @@
         <if test="startDate != null and startDate != ''">
             and iac.createtime BETWEEN #{startDate} and #{endDate}
         </if>
+
+        <if test="signStartDate != null and signStartDate != ''  and signEndDate !=null and signEndDate !=''">
+            and iac.signing_time BETWEEN #{signStartDate} and #{signEndDate}
+        </if>
         AND
         sd.id != 9991401
         group by
@@ -99,13 +113,18 @@
     <select id="getOrderNumber" parameterType="com.ydtech.modules.largescreen.model.query.DataQuery"
             resultType="Integer">
         SELECT
-        count( orderno )
+        count( io.orderno )
         FROM
-        ins_orders
+        ins_orders io
+        left join  ins_area_company iac  on  iac.orderno  =io.orderno
         WHERE
         1=1
         <if test="startDate != null and startDate != ''">
-            and createtime BETWEEN #{startDate} and #{endDate}
+            and io.createtime BETWEEN #{startDate} and #{endDate}
+        </if>
+
+        <if test="signStartDate != null and signStartDate != ''  and signEndDate !=null and signEndDate !=''">
+            and iac.signing_time BETWEEN #{signStartDate} and #{signEndDate}
         </if>
     </select>