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

Merge remote-tracking branch 'origin/test' into test

wks 1 год назад
Родитель
Сommit
35aeb58644

+ 22 - 0
src/main/java/com/ydtech/modules/admin/controller/taskStatistics/TaskStatisticsController.java

@@ -530,6 +530,27 @@ public class TaskStatisticsController {
         }
     }
 
+
+    /**
+     * @description:   控制台 - 业务数据 -渠道明细导出
+     * @author: whp
+     **/
+    @PostMapping("/detailExport")
+    @ApiOperation(value = "任务统计-代理人导出")
+    public HttpResult detailExport(@RequestBody TaskStatisticsVo taskStatisticsVo, HttpServletRequest httpServerRequest) {
+        KztGetDeptUtils kztGetDeptUtils = new KztGetDeptUtils();
+        KztGetDeptUtilsDto kztGetDeptUtilsDto = kztGetDeptUtils.KztGetDeptIds(httpServerRequest.getRequestURL().toString());
+        if(ObjectUtils.isNotEmpty(kztGetDeptUtilsDto)){
+            if("1".equals(kztGetDeptUtilsDto.getType())){
+                taskStatisticsVo.setDeptIds(kztGetDeptUtilsDto.getIds());
+            } else if ("2".equals(kztGetDeptUtilsDto.getType())) {
+                taskStatisticsVo.setUserIds(kztGetDeptUtilsDto.getIds());
+            }
+        }
+        taskStatisticsVo.filterTime();
+        return this.taskStatisticsService.detailExport(taskStatisticsVo);
+    }
+
     /**
      * @description:   控制台 - 业务数据 -代理人导出
      * @author: whp
@@ -643,6 +664,7 @@ public class TaskStatisticsController {
         }
     }
 
+
     /**
      *
      * @param taskStatisticsVo

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

@@ -3,6 +3,7 @@ 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.SysUser;
+import com.ydtech.modules.admin.model.dto.ChannelDetailsExport;
 import com.ydtech.modules.admin.model.dto.OrdersDetailsExcel;
 import com.ydtech.modules.admin.model.vo.BusinessAgentData;
 import com.ydtech.modules.admin.model.vo.BusinessOrderData;
@@ -65,4 +66,6 @@ public interface TaskStatisticsMapper extends BaseMapper<TaskStatisticsDto> {
      */
     List<OrdersDetailsExcel> ordersDetailsExcel(@Param("taskStatisticsVo") TaskStatisticsVo taskStatisticsVo);
 
+    List<ChannelDetailsExport> getAgentDataDetails(@Param("vo") TaskStatisticsVo taskStatisticsVo);
+
 }

+ 54 - 0
src/main/java/com/ydtech/modules/admin/model/dto/ChannelDetailsExport.java

@@ -0,0 +1,54 @@
+package com.ydtech.modules.admin.model.dto;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Data
+public class ChannelDetailsExport  implements Serializable {
+    @ExcelProperty(value = "姓名", index = 0)
+    private String userName;
+
+    @ExcelProperty(value = "工号", index = 1)
+    private String userId;
+
+    @ExcelProperty(value = "归属机构", index = 2)
+    private String deptName;
+
+    @ExcelProperty(value = "管理人", index = 3)
+    private String leaderName;
+
+    @ExcelProperty(value = "机构来源", index = 4)
+    private String managementSource;
+
+
+    @ExcelProperty(value = "保险公司名称", index = 5)
+    private String insuranceCompany;
+
+    @ExcelProperty(value = "签单日期", index = 6)
+    private LocalDateTime signingTime;
+
+    @ExcelProperty(value = "车牌号", index = 7)
+    private String licenseno;
+
+
+    @ExcelProperty(value = "交强险保费", index = 8)
+    private BigDecimal jqpremium;
+
+    @ExcelProperty(value = "商业险保费", index = 9)
+    private BigDecimal sypremium;
+
+    @ExcelProperty(value = "非车险保费", index = 10)
+    private BigDecimal jypremium;
+
+
+    @ExcelIgnore
+    private String deptId;
+
+
+}

+ 6 - 0
src/main/java/com/ydtech/modules/admin/service/TaskStatisticsService.java

@@ -201,4 +201,10 @@ public interface TaskStatisticsService {
      **/
     IPage<TaskStatisticsDto> costReviewer(TaskStatisticsVo taskStatisticsVo);
 
+    /**
+     *  控制台 - 业务数据 -渠道明细导出
+     * @param taskStatisticsVo
+     * @return
+     */
+    HttpResult detailExport(TaskStatisticsVo taskStatisticsVo);
 }

+ 70 - 0
src/main/java/com/ydtech/modules/admin/service/impl/TaskStatisticsServiceImpl.java

@@ -31,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
 import java.math.BigDecimal;
@@ -38,6 +39,7 @@ import java.math.RoundingMode;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -1526,4 +1528,72 @@ public class TaskStatisticsServiceImpl implements TaskStatisticsService {
         return list;
     }
 
+    /**
+     *      控制台 - 业务数据 -渠道明细导出
+     * @param taskStatisticsVo
+     * @return
+     */
+    @Override
+    public HttpResult detailExport(TaskStatisticsVo taskStatisticsVo) {
+        if (StringUtils.isNotEmpty(taskStatisticsVo.getTreeType())) {
+            if ((StringUtils.isNotEmpty(taskStatisticsVo.getTreeUserId()) && "2".equals(taskStatisticsVo.getTreeType()))) {
+                List<String> userIds = this.getNextLevel(taskStatisticsVo.getTreeUserId());
+                if (!userIds.isEmpty() && userIds.get(0) != null) {
+                    taskStatisticsVo.setUserIds(userIds);
+                } else {
+                    taskStatisticsVo.setUserId(taskStatisticsVo.getTreeUserId());
+                }
+            } else if (StringUtils.isNotEmpty(taskStatisticsVo.getTreeUserId()) && "1".equals(taskStatisticsVo.getTreeType())) {
+                taskStatisticsVo.setDeptId(taskStatisticsVo.getTreeUserId());
+                taskStatisticsVo.setTreeUserId(null);
+                taskStatisticsVo.setUserIds(new ArrayList<>());
+            }
+        }
+        PageVo<TaskStatisticsVo> pageVo = new PageVo<>();
+        Page<TaskStatisticsVo> page = new Page<>(taskStatisticsVo.getPageNum(), taskStatisticsVo.getPageSize());
+        page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
+        pageVo.setPageNum(taskStatisticsVo.getPageNum());
+        pageVo.setPageSize(taskStatisticsVo.getPageSize());
+
+        HashMap<String, String> dateMapByType = getDateMapByTypeNew(taskStatisticsVo.getDateType(), taskStatisticsVo.getCreatetimeStart(), taskStatisticsVo.getCreatetimeEnd());
+        taskStatisticsVo.setCreatetimeStart(dateMapByType.get("startDate"));
+        taskStatisticsVo.setCreatetimeEnd(dateMapByType.get("endDate"));
+        getDateByType(taskStatisticsVo.getDateType(), taskStatisticsVo);
+
+        IPage<BusinessAgentData> list = this.taskStatisticsMapper.getBusinessAgentData(page, taskStatisticsVo);
+        List<BusinessAgentData> records = list.getRecords();
+        List<String> ids = records.stream()
+                .map(BusinessAgentData::getUserId)  // 提取每个对象的id属性
+                .collect(Collectors.toList());  // 收集到新的List中
+        if(!CollectionUtils.isEmpty(taskStatisticsVo.getUserIds())){
+            ids.addAll(taskStatisticsVo.getUserIds());
+        }
+        taskStatisticsVo.setUserIds(ids);
+
+        List<ChannelDetailsExport> result = taskStatisticsMapper.getAgentDataDetails(taskStatisticsVo);
+        for (ChannelDetailsExport channelDetailsExport : result) {
+            BusinessAgentData businessAgentData = new BusinessAgentData();
+            businessAgentData.setDeptId(channelDetailsExport.getDeptId());
+            this.appendName(businessAgentData);
+            if (StringUtils.isNotEmpty(businessAgentData.getDeptName())) {
+                channelDetailsExport.setDeptName(businessAgentData.getDeptName());
+            }
+        }
+
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            try {
+                Files.createDirectories(path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String formattedDate = sdf.format(new Date());
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "渠道业务数据明细导出"+formattedDate, ChannelDetailsExport.class, result);
+        return HttpResult.ok("", uploadUrl + "excel/" + fileName);
+    }
+
 }

+ 2 - 2
src/main/java/com/ydtech/modules/fee/service/FeeRuleSchemeNewService.java

@@ -57,7 +57,7 @@ public interface FeeRuleSchemeNewService {
      * @param insAreaCompany
      * @param insOrders
      */
-    void verificationCostFactor(QuoteRespVo quoteRespVo, InsAreaCompany insAreaCompany, InsOrders insOrders, StringBuilder logs);
+    void verificationCostFactor(QuoteRespVo quoteRespVo, InsAreaCompany insAreaCompany, InsOrders insOrders, StringBuilder logs, boolean isInternalAgreement);
 
     /**
      * 查找匹配承保规则的因子
@@ -96,7 +96,7 @@ public interface FeeRuleSchemeNewService {
      *
      * @param costsId
      */
-    void calcCosts(String costsId, InsAreaCompany insAreaCompany);
+    void calcCosts(String costsId, InsAreaCompany insAreaCompany, boolean isInternalAgreement);
 
 
     void calcCostsTest(String costsId, InsAreaCompany insAreaCompany);

+ 11 - 5
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java

@@ -48,6 +48,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.math.RoundingMode;
 import java.text.DateFormat;
 import java.time.LocalDate;
@@ -138,7 +139,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
      * 校验费用因子
      */
     @Override
-    public void verificationCostFactor(QuoteRespVo quoteRespVo, InsAreaCompany insAreaCompany, InsOrders insOrders, StringBuilder logs) {
+    public void verificationCostFactor(QuoteRespVo quoteRespVo, InsAreaCompany insAreaCompany, InsOrders insOrders, StringBuilder logs, boolean isInternalAgreement) {
 
         List<AgreementProductCosts> agreementProductCostsNoMatched =
                 ptlAgreementProductCostsNewService.costsGetList(insAreaCompany.getAgreementId(), insAreaCompany.getProductid());
@@ -198,7 +199,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
             //遍历费用因子
             String costsId = verificationCosts(agreementProductCosts, quoteRespVo, insAreaCompany, insOrders, logs);
             if (costsId != null) {
-                calcCosts(costsId, insAreaCompany);
+                calcCosts(costsId, insAreaCompany, isInternalAgreement);
                 log.debug("费用因子校验通过,子订单id:" + insAreaCompany.getId() + ",费用id:" + costsId);
             }
         } else {
@@ -335,7 +336,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
      * @param insAreaCompany
      */
     @Override
-    public void calcCosts(String costsId, InsAreaCompany insAreaCompany) {
+    public void calcCosts(String costsId, InsAreaCompany insAreaCompany, boolean isInternalAgreement) {
         //获取协议信息
         PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
         InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
@@ -468,8 +469,13 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 .add(retailProportion.getNoRetailLevel2Proportion())
                 .add(retailProportion.getNoRetailLevel3Proportion());
 
-        // 外部订单比例
-        BigDecimal enterProportion = sysSwitchConfigService.getEnterProportion(insOrders.getDeptid(), insOrders.getEntryStatus());
+        BigDecimal enterProportion = new BigDecimal(BigInteger.ZERO);
+        
+        // 待客录单订单比例 根据前端传值 判断是否使用待客录单比例
+        if(!isInternalAgreement){
+            enterProportion = sysSwitchConfigService.getEnterProportion(insOrders.getDeptid(), insOrders.getEntryStatus());
+        }
+        
 
         //重新计算比例  入口是否超出支付的比例
         ReCalcuLateProportion jqReCalcuLateProportion = recalculateProportion(

+ 14 - 5
src/main/java/com/ydtech/modules/order/aop/aspect/QuoteVerificationAspect.java

@@ -35,11 +35,9 @@ import com.ydtech.modules.protocol.constants.TaxSourceStatusConstants;
 import com.ydtech.modules.protocol.dao.PtlTaxSourceNewMapper;
 import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
 import com.ydtech.modules.protocol.entity.po.PtlAgreement;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementGroupLinkAgreement;
 import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNew;
-import com.ydtech.modules.protocol.service.ITaxSourceExcludeService;
-import com.ydtech.modules.protocol.service.PtlAgreementDeptService;
-import com.ydtech.modules.protocol.service.PtlAgreementService;
-import com.ydtech.modules.protocol.service.PtlTaxSourceNewService;
+import com.ydtech.modules.protocol.service.*;
 import com.ydtech.modules.protocol.service.impl.TaxSourceServiceImpl;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
@@ -111,6 +109,8 @@ public class QuoteVerificationAspect {
 
     private final SysQuoteRedisService sysQuoteRedisService;
 
+    private final PtlAgreementGroupLinkAgreementService ptlAgreementGroupLinkAgreementService;
+
     @AfterReturning(pointcut = "@annotation(com.ydtech.modules.order.aop.QuoteVerification)", returning = "result")
     public void doAfter(HttpResult<QuoteRespVo> result) {
         //计算费用因子
@@ -120,6 +120,15 @@ public class QuoteVerificationAspect {
                     insAreaCompanyAccidentalDrivingService.getByCompanyId(insAreaCompany.getId());
             insAreaCompany.setAccidentalDriving(insAreaCompanyAccidentalDriving);
             InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
+            String agreementId = insAreaCompany.getAgreementId();
+            boolean isInternalAgreement = false;
+            // 查找是否是内部协议
+            PtlAgreementGroupLinkAgreement ptlAgreementGroupLinkAgreement = ptlAgreementGroupLinkAgreementService.getOne(new LambdaQueryWrapper<PtlAgreementGroupLinkAgreement>()
+                    .eq(PtlAgreementGroupLinkAgreement::getPtlAgreementId, agreementId)
+                    .eq(PtlAgreementGroupLinkAgreement::getPtlAgreementGroupId, 2));
+            if (ptlAgreementGroupLinkAgreement != null){
+                isInternalAgreement = true;
+            }
             // 更新数据
             if (StringUtils.isNotEmpty(insAreaCompany.getLeaderId())) {
                 SysUser sysUser = sysUserService.getById(insOrders.getUserid());
@@ -132,7 +141,7 @@ public class QuoteVerificationAspect {
             StringBuilder logs = new StringBuilder();
             //再进行费用因子判断
             try {
-                feeRuleSchemeNewService.verificationCostFactor(result.getData(), insAreaCompany, insOrders, logs);
+                feeRuleSchemeNewService.verificationCostFactor(result.getData(), insAreaCompany, insOrders, logs, isInternalAgreement);
                 InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
                 if (insFeeOrderNew != null) {
                     //出口

+ 82 - 0
src/main/resources/mapper/modules/admin/TaskStatisticsMapper.xml

@@ -724,4 +724,86 @@
 
 
     </select>
+
+    <select id="getAgentDataDetails" resultType="com.ydtech.modules.admin.model.dto.ChannelDetailsExport">
+        SELECT
+        io.userid AS "userId",
+        sd.id as"deptId",
+        sd.name as"deptName",
+        pa.insurance_company as "insuranceCompany",
+        CASE
+        WHEN sd.management_source = '1' THEN '渠道'
+        WHEN sd.management_source = '2' THEN '代理人'
+        WHEN sd.management_source = '3' THEN '电销'
+        END AS "managementSource",
+        io.licenseno as "licenseno",
+        su.id as "userId",
+        su.name AS "userName",
+        su.dept_id AS "deptId",
+        su.leader_name AS "leaderName",
+        iac.signing_time as "signingTime",
+        iac.jypremium,
+        sd.management_source AS "managementSource",
+        IFNULL(jqpremium, 0) + IFNULL(sypremium, 0) + IFNULL(jypremium, 0) AS "sumpremium",
+        IFNULL(jqpremium, 0) AS "jqpremium",
+        IFNULL(sypremium, 0) AS "sypremium",
+        IFNULL(taxamount, 0) AS "taxamount",
+        IFNULL(jypremium, 0) AS "jypremium"
+        FROM
+        ins_area_company iac
+        LEFT JOIN ins_orders io ON io.orderno = iac.orderno
+        LEFT JOIN sys_user su ON su.id = io.userid
+        LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
+        LEFT JOIN sys_dept sd ON sd.id = su.dept_id
+        LEFT JOIN sys_user_role sur ON sur.user_id = su.id
+        left join ptl_agreement pa on pa.id = iac.agreement_id
+        WHERE
+        iac.orderstatus = '3'
+        AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
+        <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
+            AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
+        </if>
+        <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
+            AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
+        </if>
+
+        <if test="vo.leaderName != null and vo.leaderName!='' ">
+            AND iac.leader_name = #{vo.leaderName}
+        </if>
+        <if test="vo.userIds  !=null  and vo.userIds!=''  and vo.userIds.size()>0">
+            AND su.leader_id IN
+            <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
+            AND sd.id IN
+            <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="vo.managementSource !=null  and vo.managementSource!=''">
+            AND sd.management_source = #{vo.managementSource}
+        </if>
+        <if test="vo.deptId !=null  and vo.deptId!=''">
+            AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
+        </if>
+
+        <if test="vo.userId !=null  and vo.userId!=''">
+            AND su.id = #{vo.userId}
+        </if>
+        <if test="vo.userName !=null  and vo.userName!=''">
+            AND su.name = #{vo.userName}
+        </if>
+        <choose>
+            <when test='vo.managementSource == "2"'>
+                AND (sur.role_id = 20 OR sur.role_id = 21)
+            </when>
+            <when test='vo.managementSource == "1"'>
+                AND (sur.role_id = 19 OR sur.role_id = 21)
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
 </mapper>