Browse Source

Merge branch 'test' of http://www.baoxianzhanggui.com:8090/sxzgd/java-insagent-pc into test

hxl13994548489 2 năm trước cách đây
mục cha
commit
ec2178cf45
22 tập tin đã thay đổi với 415 bổ sung70 xóa
  1. 10 12
      sql/Online.sql
  2. 4 6
      src/main/java/com/ydtech/modules/admin/controller/SysDeptAccountWithdrawController.java
  3. 2 2
      src/main/java/com/ydtech/modules/admin/dao/SysDeptAccountHistoryMapper.java
  4. 4 0
      src/main/java/com/ydtech/modules/admin/dao/SysDeptAccountWithdrawMapper.java
  5. 1 2
      src/main/java/com/ydtech/modules/admin/model/SysDeptAccountWithdraw.java
  6. 8 0
      src/main/java/com/ydtech/modules/admin/model/dto/SysDeptAccountDto.java
  7. 8 1
      src/main/java/com/ydtech/modules/admin/model/dto/SysDeptAccountHistoryDto.java
  8. 6 0
      src/main/java/com/ydtech/modules/admin/model/vo/SysDeptAccountByUserVo.java
  9. 8 6
      src/main/java/com/ydtech/modules/admin/model/vo/SysDeptAccountWithdrawVo.java
  10. 7 6
      src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountHistoryServiceImpl.java
  11. 4 3
      src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountServiceImpl.java
  12. 4 17
      src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountWithdrawServiceImpl.java
  13. 8 0
      src/main/java/com/ydtech/modules/fnc/service/InsFeeAuditService.java
  14. 242 0
      src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java
  15. 9 2
      src/main/java/com/ydtech/modules/inv/model/po/InvSource.java
  16. 9 6
      src/main/java/com/ydtech/modules/inv/service/impl/InvReceivableServiceImpl.java
  17. 16 4
      src/main/java/com/ydtech/modules/order/service/impl/DaJiaOrderServiceImpl.java
  18. 6 0
      src/main/java/com/ydtech/modules/protocol/entity/po/PtlAgreement.java
  19. 2 1
      src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementUndwrtRulesNewServiceImpl.java
  20. 8 0
      src/main/resources/mapper/modules/admin/SysDeptAccountHistoryMapper.xml
  21. 12 2
      src/main/resources/mapper/modules/admin/SysDeptAccountMapper.xml
  22. 37 0
      src/main/resources/mapper/modules/admin/SysDeptAccountWithdrawMapper.xml

+ 10 - 12
sql/Online.sql

@@ -42,15 +42,13 @@ CREATE TABLE `settlement_documentary_log`  (
 SET FOREIGN_KEY_CHECKS = 1;
 
 --     菜单sql   结算菜单   提现菜单
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (641, '结算', '640', NULL, 'sys:nonDocumentary:balance', 2, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (642, '提现管理', '121', NULL, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (643, '手续费待提现', '656', '/financialManagement/withdrawalManagement/withdrawalProceduresPending', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (644, '前线人员协议配置', '432', '/Sys/SysUserLinkPtlAgreement/SysUserLinkPtlAgreement', NULL, 1, 'el-icon-menu', 3, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (645, '非跟单待提现', '657', '/financialManagement/withdrawalManagement/nonDocumentaryPending', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (646, '推广待提现', '658', '/financialManagement/withdrawalManagement/generalizationPending', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (647, '手续费已提现', '656', '/financialManagement/withdrawalManagement/withdrawalProceduresEnd', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (648, '非跟单已提现', '657', '/financialManagement/withdrawalManagement/nonDocumentaryEnd', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (649, '推广已提现', '658', '/financialManagement/withdrawalManagement/generalizationEnd', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (656, '手续费管理', '642', NULL, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (657, '非跟单管理', '642', NULL, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (658, '推广管理', '642', NULL, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 0);
+INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (645, '非跟单待提现', '201', '/financialManagement/withdrawalManagement/nonDocumentaryPending', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
+INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (646, '推广待提现', '201', '/financialManagement/withdrawalManagement/generalizationPending', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
+INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (647, '手续费已提现', '201', '/financialManagement/withdrawalManagement/withdrawalProceduresEnd', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
+INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (648, '非跟单已提现', '201', '/financialManagement/withdrawalManagement/nonDocumentaryEnd', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
+INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (649, '推广已提现', '201', '/financialManagement/withdrawalManagement/generalizationEnd', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
+INSERT INTO `sys_menu`(`id`, `name`, `parent_id`, `url`, `perms`, `type`, `icon`, `order_num`, `create_by`, `create_time`, `last_update_by`, `last_update_time`, `del_flag`) VALUES (643, '手续费待提现', '201', '/financialManagement/withdrawalManagement/withdrawalProceduresPending', NULL, 1, NULL, 0, NULL, NULL, NULL, NULL, 0);
+
+--  inv_source表 新增修改人名字 修改人id
+ALTER TABLE `inv_source` ADD COLUMN `update_name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '修改人名字' AFTER `revenue_userid`;
+ALTER TABLE `inv_source` ADD COLUMN `update_userid` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '修改人id' AFTER `update_name`;

+ 4 - 6
src/main/java/com/ydtech/modules/admin/controller/SysDeptAccountWithdrawController.java

@@ -1,8 +1,6 @@
 package com.ydtech.modules.admin.controller;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ydtech.core.page.HttpResult;
-import com.ydtech.core.page.PageResult;
 import com.ydtech.modules.admin.model.SysDeptAccountWithdraw;
 import com.ydtech.modules.admin.model.vo.SysDeptAccountWithdrawVo;
 import com.ydtech.modules.admin.service.SysDeptAccountWithdrawService;
@@ -15,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.text.ParseException;
+
 @Api(tags = "机构账户审核")
 @RequestMapping("/sysDeptAccountWithdraw")
 @RestController
@@ -24,10 +24,8 @@ public class SysDeptAccountWithdrawController extends BaseController {
 
     @PostMapping("/queryStatus")
     @ApiOperation(value = "机构账户审核状态查询")
-    public HttpResult queryStatus(@RequestBody SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo){
-        IPage<SysDeptAccountWithdraw> getAnnualAuditOrderPage = sysDeptAccountWithdrawService.getList(sysDeptAccountWithdrawVo);
-        PageResult pageResult = buildPageResponse(getAnnualAuditOrderPage);
-        return HttpResult.ok(pageResult);
+    public HttpResult queryStatus(@RequestBody SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo) throws ParseException {
+        return HttpResult.ok("",sysDeptAccountWithdrawService.getList(sysDeptAccountWithdrawVo));
     }
 
     @PostMapping("/audit")

+ 2 - 2
src/main/java/com/ydtech/modules/admin/dao/SysDeptAccountHistoryMapper.java

@@ -1,14 +1,14 @@
 package com.ydtech.modules.admin.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydtech.modules.admin.model.SysDeptAccountHistory;
 import com.ydtech.modules.admin.model.dto.SysDeptAccountHistoryDto;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
-import java.util.List;
 
 @Mapper
 public interface SysDeptAccountHistoryMapper extends BaseMapper<SysDeptAccountHistory> {
-    List<SysDeptAccountHistoryDto> getDeptHistory(@Param("sysDeptAccountHistoryDto") SysDeptAccountHistoryDto sysDeptAccountHistoryDto);
+    Page<SysDeptAccountHistoryDto> getDeptHistory(Page page,@Param("sysDeptAccountHistoryDto") SysDeptAccountHistoryDto sysDeptAccountHistoryDto);
 }

+ 4 - 0
src/main/java/com/ydtech/modules/admin/dao/SysDeptAccountWithdrawMapper.java

@@ -1,11 +1,15 @@
 package com.ydtech.modules.admin.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydtech.modules.admin.model.SysDeptAccountWithdraw;
+import com.ydtech.modules.admin.model.vo.SysDeptAccountWithdrawVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 
 
 @Mapper
 public interface SysDeptAccountWithdrawMapper extends BaseMapper<SysDeptAccountWithdraw> {
+    Page<SysDeptAccountWithdraw> selectSysDeptAccountWithdraw(Page page,@Param("sysDeptAccountWithdrawVo") SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo);
 }

+ 1 - 2
src/main/java/com/ydtech/modules/admin/model/SysDeptAccountWithdraw.java

@@ -9,7 +9,6 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
-import java.util.Date;
 
 
 @Data
@@ -42,5 +41,5 @@ public class SysDeptAccountWithdraw implements Serializable {
 
     @TableField(value = "create_time")
     @ApiModelProperty("创建时间")
-    private Date createTime;
+    private String createTime;
 }

+ 8 - 0
src/main/java/com/ydtech/modules/admin/model/dto/SysDeptAccountDto.java

@@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 @Data
@@ -19,4 +20,11 @@ public class SysDeptAccountDto {
     @JsonFormat(pattern = "yyyy-MM-dd")
     private LocalDateTime createTime;
 
+    @ApiModelProperty(value = "提现中金额")
+    @JsonFormat(pattern = "0.00")
+    private BigDecimal waitAmount;
+
+    @ApiModelProperty(value = "已提现金额")
+    @JsonFormat(pattern = "0.00")
+    private BigDecimal totalAmount;
 }

+ 8 - 1
src/main/java/com/ydtech/modules/admin/model/dto/SysDeptAccountHistoryDto.java

@@ -3,7 +3,6 @@ package com.ydtech.modules.admin.model.dto;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.annotation.JsonFormat;
-import com.ydtech.core.page.PageRequest;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -58,4 +57,12 @@ public class SysDeptAccountHistoryDto{
     @ApiModelProperty(value = "备注")
     @TableField(value = "remark")
     private String remark;
+
+    private String createTimeStart;
+
+    private String createTimeEnd;
+
+    private int pageNo;
+
+    private int pageSize;
 }

+ 6 - 0
src/main/java/com/ydtech/modules/admin/model/vo/SysDeptAccountByUserVo.java

@@ -27,4 +27,10 @@ public class SysDeptAccountByUserVo {
 
     @ApiModelProperty("提现人员id")
     private String userId;
+
+    @ApiModelProperty("提现中金额")
+    private BigDecimal waitAmount;
+
+    @ApiModelProperty("已提现金额")
+    private BigDecimal totalAmount;
 }

+ 8 - 6
src/main/java/com/ydtech/modules/admin/model/vo/SysDeptAccountWithdrawVo.java

@@ -2,16 +2,14 @@ package com.ydtech.modules.admin.model.vo;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
-import com.ydtech.core.page.PageRequest;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
-import java.util.Date;
 
 @Data
-public class SysDeptAccountWithdrawVo extends PageRequest implements Serializable {
+public class SysDeptAccountWithdrawVo implements Serializable {
     @TableId(value = "id")
     @ApiModelProperty(value = "主键id")
     private String id;
@@ -38,13 +36,17 @@ public class SysDeptAccountWithdrawVo extends PageRequest implements Serializabl
 
     @TableField(value = "create_time")
     @ApiModelProperty(value = "创建时间")
-    private Date createTime;
+    private String createTime;
 
     @ApiModelProperty(value = "创建时间开始时间")
-    private Date createTimeStart;
+    private String createTimeStart;
 
 
     @ApiModelProperty(value = "创建时间结束时间")
-    private Date createTimeEnd;
+    private String createTimeEnd;
+
+    private int pageNo;
+
+    private int pageSize;
 
 }

+ 7 - 6
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountHistoryServiceImpl.java

@@ -3,6 +3,7 @@ package com.ydtech.modules.admin.service.impl;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.core.page.PageRequest;
 import com.ydtech.modules.admin.dao.SysDeptAccountHistoryMapper;
 import com.ydtech.modules.admin.model.SysDeptAccountHistory;
 import com.ydtech.modules.admin.model.dto.SysDeptAccountHistoryDto;
@@ -10,7 +11,6 @@ import com.ydtech.modules.admin.service.SysDeptAccountHistoryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
 
 @Service
 public class SysDeptAccountHistoryServiceImpl extends ServiceImpl<SysDeptAccountHistoryMapper, SysDeptAccountHistory> implements SysDeptAccountHistoryService {
@@ -21,10 +21,11 @@ public class SysDeptAccountHistoryServiceImpl extends ServiceImpl<SysDeptAccount
     private SysDeptAccountHistoryMapper sysDeptAccountHistoryMapper;
     @Override
     public IPage<SysDeptAccountHistoryDto> selectList(SysDeptAccountHistoryDto sysDeptAccountHistoryDto) {
-        Page<SysDeptAccountHistoryDto> page = new Page<>();
-        List<SysDeptAccountHistoryDto> deptHistoryList = sysDeptAccountHistoryMapper.getDeptHistory(sysDeptAccountHistoryDto);
-        page.setRecords(deptHistoryList);
-        page.setTotal(deptHistoryList.size());
-        return page;
+        PageRequest pageRequest = new PageRequest();
+        pageRequest.setPageNum(sysDeptAccountHistoryDto.getPageNo());
+        pageRequest.setPageSize(sysDeptAccountHistoryDto.getPageSize());
+        Page page = PageRequest.buildPageRequest(pageRequest);
+        Page<SysDeptAccountHistoryDto> deptHistoryList = sysDeptAccountHistoryMapper.getDeptHistory(page,sysDeptAccountHistoryDto);
+        return deptHistoryList;
     }
 }

+ 4 - 3
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.constants.sys.SysDeptAccountStatus;
 import com.ydtech.core.page.HttpResult;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.dao.SysDeptAccountMapper;
 import com.ydtech.modules.admin.model.*;
 import com.ydtech.modules.admin.model.dto.SysDeptAccountDto;
@@ -77,10 +78,10 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
         SysDept sysDept = sysDeptService.getOne(queryWrapper);
 
         if (!BaseController.getUser().getId().equals(sysDept.getWithdrawUser())) {
-            return HttpResult.error("您不为该机构账户提现人员");
+            throw new SystemException("您不为该机构账户提现人员");
         }
         if (sysDeptAccount.getAmount().compareTo(deptAccount.getManagementFee()) > 0) {
-            return HttpResult.error("提现金额大于机构账户金额");
+            throw new SystemException("提现金额大于机构账户金额");
         }
         // 减去提现金额
         deptAccount.setManagementFee(deptAccount.getManagementFee().subtract(sysDeptAccount.getAmount()));
@@ -108,7 +109,7 @@ public class SysDeptAccountServiceImpl extends ServiceImpl<SysDeptAccountMapper,
         sysDeptAccountWithdraw.setAmount(sysDeptAccount.getAmount());
         sysDeptAccountWithdraw.setStatus(SysDeptAccountStatus.WAIT.getCode()); //待审核
         sysDeptAccountWithdraw.setRemark("");
-        sysDeptAccountWithdraw.setCreateTime(new Date());
+        sysDeptAccountWithdraw.setCreateTime(String.valueOf(new Date()));
         sysDeptAccountWithdrawService.save(sysDeptAccountWithdraw);
 
         return HttpResult.ok("", sysDeptAccount);

+ 4 - 17
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptAccountWithdrawServiceImpl.java

@@ -1,6 +1,6 @@
 package com.ydtech.modules.admin.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -27,27 +27,14 @@ public class SysDeptAccountWithdrawServiceImpl extends ServiceImpl<SysDeptAccoun
     private SysDeptAccountWithdrawService sysDeptAccountWithdrawService;
     @Autowired
     private SysDeptAccountService sysDeptAccountService;
-
     @Override
     public IPage<SysDeptAccountWithdraw> getList(SysDeptAccountWithdrawVo sysDeptAccountWithdrawVo) {
         PageRequest pageRequest = new PageRequest();
-        pageRequest.setPageNum(sysDeptAccountWithdrawVo.getPageNum());
+        pageRequest.setPageNum(sysDeptAccountWithdrawVo.getPageNo());
         pageRequest.setPageSize(sysDeptAccountWithdrawVo.getPageSize());
         Page page = PageRequest.buildPageRequest(pageRequest);
-        LambdaQueryWrapper<SysDeptAccountWithdraw> queryWrapper = new LambdaQueryWrapper<>();
-        //审核状态
-        if (sysDeptAccountWithdrawVo.getStatus() != null && !"".equals(sysDeptAccountWithdrawVo.getStatus())) {
-            queryWrapper.eq(SysDeptAccountWithdraw::getStatus, sysDeptAccountWithdrawVo.getStatus());
-        }
-        //创建时间区间
-        if (sysDeptAccountWithdrawVo.getCreateTimeStart() != null && !"".equals(sysDeptAccountWithdrawVo.getCreateTimeStart())) {
-            queryWrapper.ge(SysDeptAccountWithdraw::getCreateTime, sysDeptAccountWithdrawVo.getCreateTimeStart());
-        }
-        if (sysDeptAccountWithdrawVo.getCreateTimeEnd() != null && !"".equals(sysDeptAccountWithdrawVo.getCreateTimeEnd())) {
-            queryWrapper.le(SysDeptAccountWithdraw::getCreateTime, sysDeptAccountWithdrawVo.getCreateTimeEnd());
-        }
-        Page pageData = sysDeptAccountWithdrawMapper.selectPage(page, queryWrapper);
-        return pageData;
+        Page<SysDeptAccountWithdraw> iPage = sysDeptAccountWithdrawMapper.selectSysDeptAccountWithdraw(page,sysDeptAccountWithdrawVo);
+        return iPage;
     }
 
     @Override

+ 8 - 0
src/main/java/com/ydtech/modules/fnc/service/InsFeeAuditService.java

@@ -15,4 +15,12 @@ public interface InsFeeAuditService extends IService<InsFeeAudit> {
 
      void feeAudit(String orderNo,String insOrderNo) throws Exception;
 
+     /**
+      * 自动审核
+      * @param orderNo
+      * @param insOrderNo
+      * @return
+      */
+     boolean autoFeeAudit(String orderNo,String insOrderNo) throws Exception;
+
 }

+ 242 - 0
src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java

@@ -338,6 +338,248 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         }
     }
 
+    @Override
+    public boolean autoFeeAudit(String orderNo, String insOrderNo) throws Exception {
+        //保存审核表
+        InsFeeAudit insFeeAudit=new InsFeeAudit();
+        insFeeAudit.setOrderno(orderNo);
+        insFeeAudit.setInsOrderNo(insOrderNo);
+        insFeeAudit.setAuditstatus("1");
+        insFeeAudit.setAudittime(LocalDateTime.now());
+        insFeeAudit.setAudituser("自动审核");
+        this.save(insFeeAudit);
+
+
+        InsOrders order=insOrdersMapper.selectById(orderNo);
+        InsFeeOrderNew insFeeOrder=insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insFeeAudit.getInsOrderNo());
+        InsAreaCompany insAreaCompany=insAreaCompanyMapper.selectById(insFeeAudit.getInsOrderNo());
+
+        //获取该订单的费用
+        InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getOne(new LambdaQueryWrapper<InsFeeOrderNew>()
+                .eq(InsFeeOrderNew::getInsOrderNo, insFeeAudit.getInsOrderNo()));
+
+
+        //获取操作人员的机构来源
+        String deptId=order.getDeptid();
+
+        List<SysDept> teamList = sysDeptService.findTeamList(deptId);
+        teamList.forEach(sysDept -> {
+
+            if(StringUtils.isNotEmpty(sysDept.getComlevel()) &&  sysDept.getComlevel().equals("1")){
+                BigDecimal jqDeptPremiumsLevel1 = insFeeOrderNew.getJqDeptPremiumsLevel1();
+            }
+        });
+
+
+        //bigdecimal为null时设置为0
+//        handleBigdecimal(insFeeOrder);
+        //生成保司费用(应收费用)
+        gene_orderIncome( order, insFeeOrderNew,insAreaCompany);
+        //生成机构费用
+        gene_deptfee( order, insFeeOrderNew,insAreaCompany);
+        //生成分销费用
+//        saveRetail(order,insFeeOrderNew,insAreaCompany);
+        //个代费用生成
+//        saveInsCompanyFee(order,insFeeOrderNew,insAreaCompany);
+
+
+//      生成  用户账户表  数据
+        if(StringUtils.isNotEmpty(order.getUserid())){
+//            用戶賬戶表
+            SysUserAccount sysUserAccount = new SysUserAccount();
+
+            sysUserAccount.setUserId(order.getUserid());
+            if (ObjectUtils.isNotEmpty(insFeeOrderNew) ) {
+//                手续非佣金  =  交强监管费用 + 商业监管费用 + 非车监管费用
+//                非跟单费用  = 交强非跟单费用 + 商业非跟单费用 + 非车非跟单费用
+                //手续费入口费用
+//                BigDecimal jqPremiumAmount = this.zeroBigdecimal(insFeeOrderNew.getJqSuperviseCostsPremiums());//交强监管费
+//                BigDecimal syPremiumAmount = this.zeroBigdecimal(insFeeOrderNew.getSySuperviseCostsPremiums());//商业监管费
+//                BigDecimal noPremiumAmount = this.zeroBigdecimal(insFeeOrderNew.getNoSuperviseCostsPremiums());//非车监管费用
+//                BigDecimal totalPremiumAmount = jqPremiumAmount.add(syPremiumAmount).add(noPremiumAmount);    // 手续非佣金
+//                //其他费用入口费用
+//                BigDecimal jqOtherCostsPremiums  =this.zeroBigdecimal(insFeeOrderNew.getJqOtherCostsPremiums());//交强其他费用
+//                BigDecimal syOtherCostsPremiums  =this.zeroBigdecimal(insFeeOrderNew.getSyOtherCostsPremiums()); //商业其他费用
+//                BigDecimal noOtherCostsProportion = this.zeroBigdecimal(insFeeOrderNew.getNoOtherCostsPremiums());//非车其他费用
+//                BigDecimal totalOtherPremiumAmount = jqOtherCostsPremiums.add(syOtherCostsPremiums).add(noOtherCostsProportion);  //非跟单费用
+
+                //总机构 交强管理比例
+                BigDecimal sumJqDeptProportion = insFeeOrderNew.getJqDeptProportionLevel1()
+                        .add(insFeeOrderNew.getJqDeptProportionLevel2())
+                        .add(insFeeOrderNew.getJqDeptProportionLevel3())
+                        .add(insFeeOrderNew.getJqDeptProportionLevel4())
+                        .add(insFeeOrderNew.getJqDeptProportionLevel5());
+
+                //总机构 商业管理比例
+                BigDecimal sumSyDeptProportion = insFeeOrderNew.getSyDeptProportionLevel1()
+                        .add(insFeeOrderNew.getSyDeptProportionLevel2())
+                        .add(insFeeOrderNew.getSyDeptProportionLevel3())
+                        .add(insFeeOrderNew.getSyDeptProportionLevel4())
+                        .add(insFeeOrderNew.getSyDeptProportionLevel5());
+
+                //总机构 非车管理比例
+                BigDecimal sumNoDeptProportion = insFeeOrderNew.getNoDeptProportionLevel1()
+                        .add(insFeeOrderNew.getNoDeptProportionLevel2())
+                        .add(insFeeOrderNew.getNoDeptProportionLevel3())
+                        .add(insFeeOrderNew.getNoDeptProportionLevel4())
+                        .add(insFeeOrderNew.getNoDeptProportionLevel5());
+
+                //总分销比例
+                BigDecimal sumRetail = insFeeOrderNew.getFirstDetailProportion().add(insFeeOrderNew.getSecondDetailProportion()).add(insFeeOrderNew.getThirdDetailProportion());
+
+                //交强出口比例
+                BigDecimal jqExportProceduresProportion = new BigDecimal(0);
+                if(insFeeOrderNew.getJqCostsProportion().compareTo(sumJqDeptProportion.add(sumRetail))>0){
+                    jqExportProceduresProportion = insFeeOrderNew.getJqCostsProportion().subtract(sumJqDeptProportion).subtract(sumRetail);
+                }
+                //商业出口比例
+                BigDecimal syExportProceduresProportion = new BigDecimal(0);
+                if(insFeeOrderNew.getSyCostsProportion().compareTo(sumSyDeptProportion.add(sumRetail))>0){
+                    syExportProceduresProportion = insFeeOrderNew.getSyCostsProportion().subtract(sumSyDeptProportion).subtract(sumRetail);
+                }
+                //非车出口比例
+                BigDecimal noExportProceduresProportion = new BigDecimal(0);
+                if(insFeeOrderNew.getNoCostsProportion().compareTo(sumNoDeptProportion.add(sumRetail))>0){
+                    noExportProceduresProportion = insFeeOrderNew.getNoCostsProportion().subtract(sumNoDeptProportion).subtract(sumRetail);
+                }
+
+                //交强手续费出口比例
+                BigDecimal jqExportProceduresFee = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqSuperviseCostsProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+                //交强跟单出口费用
+                BigDecimal jqExportOtherFee = insFeeOrderNew.getJqPremium()
+                        .multiply(jqExportProceduresProportion
+                                .subtract(insFeeOrderNew.getJqSuperviseCostsProportion()).divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+
+                //商业手续费出口比例
+                BigDecimal syExportProceduresFee = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSySuperviseCostsProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+                //商业跟单出口比例
+                BigDecimal syExportOtherFee = insFeeOrderNew.getSyPremium()
+                        .multiply(syExportProceduresProportion
+                                .subtract(insFeeOrderNew.getSySuperviseCostsProportion()).divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+
+                //非车手续费出口比例
+                BigDecimal noExportProceduresFee = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoSuperviseCostsProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+                //非车跟单出口比例
+                BigDecimal noExportOtherFee = insFeeOrderNew.getNoPremium()
+                        .multiply(noExportProceduresProportion
+                                .subtract(insFeeOrderNew.getNoSuperviseCostsProportion()).divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+
+                //用户出口手续费
+                BigDecimal totalPremiumAmount = new BigDecimal(0);
+                totalPremiumAmount = totalPremiumAmount.add(jqExportProceduresFee).add(syExportProceduresFee).add(noExportProceduresFee);
+
+                //用户出口跟单费
+                BigDecimal totalOtherPremiumAmount = new BigDecimal(0);
+                totalOtherPremiumAmount = totalOtherPremiumAmount.add(jqExportOtherFee).add(syExportOtherFee).add(noExportOtherFee);
+
+
+//              用戶
+                sysUserAccount.setHandlingFee(totalPremiumAmount);
+                sysUserAccount.setDocumentary(totalOtherPremiumAmount);
+//              算佣金
+                this.countUserAmount(insFeeOrderNew,orderNo);
+                sysUserAccount.setDocumentaryStatus("2");  // 收入
+                sysUserAccount.setSuborderId(orderNo);  // 订单Id
+                sysUserAccountService.addOrUpdate(sysUserAccount);
+
+
+                String deptid = insFeeOrderNew.getDeptId();
+                String distributionStatus = insFeeOrderNew.getDistributionStatus();
+                // 定义一个数组来存储各级机构的管理费
+                BigDecimal[] jqDeptPremiumsLevels = {insFeeOrderNew.getJqDeptPremiumsLevel1(), insFeeOrderNew.getJqDeptPremiumsLevel2(),
+                        insFeeOrderNew.getJqDeptPremiumsLevel3(), insFeeOrderNew.getJqDeptPremiumsLevel4(),
+                        insFeeOrderNew.getJqDeptPremiumsLevel5()};
+                BigDecimal[] syDeptPremiumsLevels = {insFeeOrderNew.getSyDeptPremiumsLevel1(), insFeeOrderNew.getSyDeptPremiumsLevel2(),
+                        insFeeOrderNew.getSyDeptPremiumsLevel3(), insFeeOrderNew.getSyDeptPremiumsLevel4(),
+                        insFeeOrderNew.getSyDeptPremiumsLevel5()};
+                BigDecimal[] noDeptPremiumsLevels = {insFeeOrderNew.getNoDeptPremiumsLevel1(), insFeeOrderNew.getNoDeptPremiumsLevel2(),
+                        insFeeOrderNew.getNoDeptPremiumsLevel3(), insFeeOrderNew.getNoDeptPremiumsLevel4(),
+                        insFeeOrderNew.getNoDeptPremiumsLevel5()};
+
+                for (int i = 1; i <= 5; i++) {
+                    // 根据循环次数确定机构ID的长度,第五级为11
+                    String levelDeptId = deptid.substring(0, (i == 5) ? 11 : i * 2);
+                    // 获取对应级别的机构信息
+                    SysDeptAccount levelSysDeptAccount = sysDeptAccountService.getOne(new LambdaQueryWrapper<SysDeptAccount>()
+                            .eq(SysDeptAccount::getDeptId, levelDeptId));
+
+                    // 初始化管理费总额为0
+                    BigDecimal sumManagementFee = BigDecimal.ZERO;
+
+                    // 根据分销等级和分销用户情况计算分销费用
+                    BigDecimal distributionFee = BigDecimal.ZERO;
+                    if (i == 5) {
+                        if (InsFeeAuditDistributionStatusEnum.DS_2.getCode().equals(distributionStatus) && insFeeOrderNew.getTwoLevelUserId() == null) {
+                            distributionFee = insFeeOrderNew.getSecondDetailPremiums();
+                        } else if (InsFeeAuditDistributionStatusEnum.DS_3.getCode().equals(distributionStatus) && insFeeOrderNew.getThreeLevelUserId() == null) {
+                            distributionFee = insFeeOrderNew.getThirdDetailPremiums();
+                        }
+                    }
+
+                    // 根据分销等级计算管理费总额
+                    if (i == 5) {
+                        sumManagementFee = sumManagementFee.add(jqDeptPremiumsLevels[i - 1])
+                                .add(syDeptPremiumsLevels[i - 1])
+                                .add(noDeptPremiumsLevels[i - 1])
+                                .add(distributionFee);
+                    } else {
+                        sumManagementFee = sumManagementFee.add(jqDeptPremiumsLevels[i - 1])
+                                .add(syDeptPremiumsLevels[i - 1])
+                                .add(noDeptPremiumsLevels[i - 1]);
+                    }
+
+                    // 如果机构信息不为空,更新管理费并记录历史
+                    if (levelSysDeptAccount != null) {
+                        levelSysDeptAccount.setManagementFee(levelSysDeptAccount.getManagementFee().add(sumManagementFee));
+                        sysDeptAccountService.updateById(levelSysDeptAccount);
+                        // 记录历史信息
+                        SysDeptAccountHistory sysDeptAccountHistory = new SysDeptAccountHistory();
+                        sysDeptAccountHistory.setId(IdGenerate.nextId());
+                        sysDeptAccountHistory.setDeptId(levelDeptId);
+                        sysDeptAccountHistory.setAmount(sumManagementFee);
+                        sysDeptAccountHistory.setSurplusAmount(levelSysDeptAccount.getManagementFee());
+                        sysDeptAccountHistory.setDocumentary("2"); //收入
+                        sysDeptAccountHistory.setSuborder(orderNo);
+                        sysDeptAccountHistory.setFromBankCard(null);
+                        sysDeptAccountHistory.setToBankCard(null);
+                        sysDeptAccountHistory.setUserId(BaseController.getUser().getId());
+                        sysDeptAccountHistory.setCreateTime(new Date());
+                        sysDeptAccountHistory.setRemark("交强" + i + "级机构管理费:" + jqDeptPremiumsLevels[i - 1] +
+                                ",商业" + i + "级机构管理费:" + syDeptPremiumsLevels[i - 1] +
+                                ",非车" + i + "级机构管理费:" + noDeptPremiumsLevels[i - 1] +
+                                ",分销费:" + distributionFee);
+                        sysDeptAccountHistoryService.save(sysDeptAccountHistory);
+                    } else {
+                        // 如果机构信息为空,新建机构信息并记录历史
+                        SysDeptAccount sysDeptAccount = new SysDeptAccount();
+                        sysDeptAccount.setDeptId(levelDeptId);
+                        sysDeptAccount.setManagementFee(sumManagementFee);
+                        sysDeptAccount.setCreateTime(new Date());
+                        sysDeptAccountService.save(sysDeptAccount);
+                        // 记录历史信息
+                        SysDeptAccountHistory sysDeptAccountHistory = new SysDeptAccountHistory();
+                        sysDeptAccountHistory.setId(IdGenerate.nextId());
+                        sysDeptAccountHistory.setDeptId(levelDeptId);
+                        sysDeptAccountHistory.setAmount(sumManagementFee);
+                        sysDeptAccountHistory.setSurplusAmount(sumManagementFee);
+                        sysDeptAccountHistory.setDocumentary("2"); //收入
+                        sysDeptAccountHistory.setSuborder(orderNo);
+                        sysDeptAccountHistory.setFromBankCard(null);
+                        sysDeptAccountHistory.setToBankCard(null);
+                        sysDeptAccountHistory.setUserId(BaseController.getUser().getId());
+                        sysDeptAccountHistory.setCreateTime(new Date());
+                        sysDeptAccountHistory.setRemark("交强" + i + "级机构管理费:" + jqDeptPremiumsLevels[i - 1] +
+                                ",商业" + i + "级机构管理费:" + syDeptPremiumsLevels[i - 1] +
+                                ",非车" + i + "级机构管理费:" + noDeptPremiumsLevels[i - 1] +
+                                ",分销费:" + distributionFee);
+                        sysDeptAccountHistoryService.save(sysDeptAccountHistory);
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
     private void countUserAmount(InsFeeOrderNew insFeeOrderNew ,String orderNo) {
         String distributionStatus = insFeeOrderNew.getDistributionStatus();
         if(StringUtils.isNotEmpty(distributionStatus)){

+ 9 - 2
src/main/java/com/ydtech/modules/inv/model/po/InvSource.java

@@ -1,6 +1,5 @@
 package com.ydtech.modules.inv.model.po;
 
-import cn.hutool.core.date.DateTime;
 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.annotation.write.style.HeadFontStyle;
@@ -379,8 +378,16 @@ public class InvSource implements Serializable {
     @ApiModelProperty("导入人Id")
     private String revenueUserId;
 
+    @TableField(value = "update_name")
+    @ApiModelProperty("修改人名字")
+    private String updateName;
+
+    @TableField(value = "update_userid")
+    @ApiModelProperty("修改人Id")
+    private String updateUserId;
+
     @TableField(value = "inv_source_type")
-    @ApiModelProperty("应收类型(平台,私有)")
+    @ApiModelProperty("应收类型(含税,不含税)")
     private String invSourceType;
 
     @TableField(exist = false)

+ 9 - 6
src/main/java/com/ydtech/modules/inv/service/impl/InvReceivableServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
+import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.esm.model.EsmInsCompany;
 import com.ydtech.modules.inv.dao.InvReceivableMapper;
 import com.ydtech.modules.inv.dao.InvSettlementSourceMapper;
@@ -457,6 +458,8 @@ public class InvReceivableServiceImpl implements InvReceivableService {
                 "已结算".equals(invSource.getClearingState()) ? "1" : invSource.getClearingState());
         invSource.setInsuranceClearingState("未结算".equals(invSource.getInsuranceClearingState()) ? "0" :
                 "已结算".equals(invSource.getInsuranceClearingState()) ? "1" : invSource.getInsuranceClearingState());
+        invSource.setUpdateUserId(BaseController.getUser().getId());
+        invSource.setUpdateName(BaseController.getUser().getName());
         return invSourceMapper.updateById(invSource) > 0;
     }
 
@@ -627,9 +630,9 @@ public class InvReceivableServiceImpl implements InvReceivableService {
         invSource.builder();
         BigDecimal tax = new BigDecimal(1.06);
         /**
-         * jqPremiumTax  交强险保费
-         * syPremiumTax  商业险保费
-         * nonCarPremiumTax 非车保费
+         * jqPremiumTax  交强险保费(含税)
+         * syPremiumTax  商业险保费(含税)
+         * nonCarPremiumTax 非车保费(含税)
          * jqReceivableRatio 交强应收比例
          * syReceivableRatio 商业应收比列
          * nonCarReceivableRatio 非车应收比列
@@ -668,13 +671,13 @@ public class InvReceivableServiceImpl implements InvReceivableService {
                 .add(invSource.getSyPremium().multiply(invSource.getSyPremiumRatio())
                         .add(invSource.getNonCarPremium().multiply(invSource.getNonCarPremiumRatio()))));
 
-        //非跟单金额  nonCopying
+        //非跟单金额  nonCopying 不含税保费 * 非跟单比例
         invSource.setNonCopying(invSource.getJqPremium().multiply(invSource.getJqNonCopyingRatio())
                 .add(invSource.getSyPremium().multiply(invSource.getSyNonCopyingRatio())
                         .add(invSource.getNonCarPremium().multiply(invSource.getNonCarNonCopyingRatio()))));
 
 
-        //选择类型为平台类型时 应收金额 = 含税保费 * 应收比例
+        //选择类型为含税类型时 应收金额 = 含税保费 * 应收比例
         if (invSource.getInvSourceType().equals("platform")) {
             //处理应收金额
             invSource.setReceivable(invSource.getJqPremiumTax().multiply(invSource.getJqReceivableRatio())
@@ -685,7 +688,7 @@ public class InvReceivableServiceImpl implements InvReceivableService {
                     invSource.getReceivable().add(invSource.getSubsidyAmount()));
         }
 
-        //选择类型为私有类型时 应收金额 = ( 不含税保费 * 手续费 )+ (不含税保费 * 非跟单比例)
+        //选择类型为不含税类型时 应收金额 = (不含税保费 * 手续费)+ (不含税保费 * 非跟单比例)
         if (invSource.getInvSourceType().equals("privately")) {
             //应收金额
             invSource.setReceivable(invSource.getPremium().add(invSource.getNonCopying()));

+ 16 - 4
src/main/java/com/ydtech/modules/order/service/impl/DaJiaOrderServiceImpl.java

@@ -11,6 +11,8 @@ import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.model.vo.PersonAreaVo;
 import com.ydtech.modules.admin.service.SysAreaService;
 import com.ydtech.modules.fee.service.FeeRuleSchemeService;
+import com.ydtech.modules.fnc.entity.InsFeeAudit;
+import com.ydtech.modules.fnc.service.InsFeeAuditService;
 import com.ydtech.modules.fnc.service.InsPlyIncomeService;
 import com.ydtech.modules.ins.model.vo.*;
 import com.ydtech.modules.order.components.ConfigureParametersComponents;
@@ -34,6 +36,7 @@ import com.ydtech.modules.order.entity.vo.dajia.AccidentalInsuranceQueryVo;
 import com.ydtech.modules.order.entity.vo.dajia.InsAccidentalDrivingDajia;
 import com.ydtech.modules.order.entity.vo.dajia.InsAccidentalDrivingSubDajia;
 import com.ydtech.modules.order.service.*;
+import com.ydtech.modules.protocol.entity.po.PtlAgreement;
 import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
 import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
 import com.ydtech.modules.protocol.service.PtlAgreementService;
@@ -48,12 +51,10 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import static com.ydtech.modules.order.components.gouren.GuorenDuplicateInsuranceComponent.*;
@@ -98,6 +99,9 @@ public class DaJiaOrderServiceImpl implements DaJiaOrderService {
     @Autowired
     private InsImagesUploadCacheComponents insImagesUploadCacheComponents;
 
+    @Autowired
+    private InsFeeAuditService insFeeAuditService;
+
     @Autowired
     private InsPlyIncomeService insPlyIncomeService;
 
@@ -720,6 +724,7 @@ public class DaJiaOrderServiceImpl implements DaJiaOrderService {
         return !collect.isEmpty();
     }
 
+
     /**
      * 查询订单状态
      *
@@ -798,6 +803,13 @@ public class DaJiaOrderServiceImpl implements DaJiaOrderService {
                     insAreaCompany.setOrderstatus(InsOrderStatusEnum.ACCEPT_INSURANCE.getCode());
                     insAreaCompanyService.updateCompanyAndOrders(insAreaCompany);
 //                    生成结算
+                    //判断协议是否为人工还是自动审核
+                    PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
+                    if(ptlAgreement.getAuditType() == 2)
+                    {
+                        //如果为自动审核 则自动进行审核
+                        insFeeAuditService.autoFeeAudit( insAreaCompany.getOrderno(),insAreaCompany.getId());
+                    }
                     insPlyIncomeService.saveBalance(companyId,insAreaCompany.getOrderno());
                 }
             }

+ 6 - 0
src/main/java/com/ydtech/modules/protocol/entity/po/PtlAgreement.java

@@ -196,6 +196,12 @@ public class PtlAgreement implements Serializable {
     @TableField(value = "update_time")
     private LocalDateTime updateTime;
 
+    /**
+     * 审核类型
+     */
+    @TableField(value = "audit_type")
+    private Integer auditType;
+
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 

+ 2 - 1
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementUndwrtRulesNewServiceImpl.java

@@ -109,7 +109,8 @@ public class PtlAgreementUndwrtRulesNewServiceImpl extends ServiceImpl<PtlAgreem
     @Override
     public List<PtlAgreementUndwrtRulesNew> rulesList(String agreementId) {
         List<PtlAgreementUndwrtRulesNew> rulesList = baseMapper.selectList(new LambdaQueryWrapper<PtlAgreementUndwrtRulesNew>()
-                .eq(PtlAgreementUndwrtRulesNew::getAgreementId, agreementId));
+                .eq(PtlAgreementUndwrtRulesNew::getAgreementId, agreementId)
+                .eq(PtlAgreementUndwrtRulesNew::getValidInd, "1"));
         List<PtlAgreementUndwrtRulesAttrLink> ptlAgreementUndwrtRulesAttrLinkList = ptlAgreementUndwrtRulesAttrLinkService.list();
         rulesList.forEach(item -> {
             List<PtlAgreementUndwrtRulesAttrLink> collect = ptlAgreementUndwrtRulesAttrLinkList.stream().filter(x -> Objects.equals(x.getRulesId(), item.getId())).collect(Collectors.toList());

+ 8 - 0
src/main/resources/mapper/modules/admin/SysDeptAccountHistoryMapper.xml

@@ -13,6 +13,8 @@
         <result column="user_id" jdbcType="VARCHAR" property="userId"/>
         <result column="remark" jdbcType="VARCHAR" property="remark"/>
         <result column="create_date" jdbcType="TIMESTAMP" property="createTime"/>
+        <result property="createTimeStart" column="createTimeStart" jdbcType="VARCHAR"/>
+        <result property="createTimeEnd" column="createTimeEnd" jdbcType="VARCHAR"/>
     </resultMap>
 
     <select id="getDeptHistory" resultMap="BaseResultMap">
@@ -41,6 +43,12 @@
         <if test="sysDeptAccountHistoryDto.documentary != null and sysDeptAccountHistoryDto.documentary != ''">
             AND a.documentary = #{sysDeptAccountHistoryDto.documentary}
         </if>
+        <if test="sysDeptAccountHistoryDto.createTimeStart != null and sysDeptAccountHistoryDto.createTimeStart != ''">
+            and DATE(a.create_time) &gt;= #{sysDeptAccountHistoryDto.createTimeStart}
+        </if>
+        <if test="sysDeptAccountHistoryDto.createTimeEnd != null and sysDeptAccountHistoryDto.createTimeEnd != ''">
+            and DATE(a.create_time) &lt;= #{sysDeptAccountHistoryDto.createTimeEnd}
+        </if>
     </select>
 
 </mapper>

+ 12 - 2
src/main/resources/mapper/modules/admin/SysDeptAccountMapper.xml

@@ -8,6 +8,8 @@
         <result column="name" jdbcType="VARCHAR" property="deptName"/>
         <result column="management_fee" jdbcType="DECIMAL" property="managementFee"/>
         <result column="create_date" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="waitAmount" jdbcType="DECIMAL" property="waitAmount"/>
+        <result column="totalAmount" jdbcType="DECIMAL" property="totalAmount"/>
     </resultMap>
 
     <select id="getDept" resultMap="BaseResultMap">
@@ -15,10 +17,13 @@
         a.dept_id,
         b.NAME,
         a.management_fee,
-        DATE(a.create_time) as create_date
+        DATE(a.create_time) as create_date,
+        SUM(CASE WHEN c.status = 0 THEN c.amount ELSE 0 END) AS waitAmount,
+        SUM(CASE WHEN c.status = 1 THEN c.amount ELSE 0 END) AS totalAmount
         FROM
         sys_dept_account a
         LEFT JOIN sys_dept b ON a.dept_id = b.id
+        LEFT JOIN sys_dept_account_withdraw c on a.dept_id = c.dept_id
         where
             b.del_flag = 0
         <if test="sysDeptAccountDto.deptId != null and sysDeptAccountDto.deptId != ''">
@@ -27,6 +32,7 @@
         <if test="sysDeptAccountDto.deptName != null and sysDeptAccountDto.deptName != ''">
             AND b.name like concat(#{sysDeptAccountDto.deptName},'%')
         </if>
+        group by a.dept_id
     </select>
 
 
@@ -48,15 +54,19 @@
         a.comattribute,
         a.comtype,
         b.management_fee,
-        a.withdraw_user
+        a.withdraw_user,
+        SUM(CASE WHEN c.status = 0 THEN c.amount ELSE 0 END) AS waitAmount,
+        SUM(CASE WHEN c.status = 1 THEN c.amount ELSE 0 END) AS totalAmount
         FROM
         sys_dept a
         RIGHT JOIN sys_dept_account b ON a.id = b.dept_id
+        LEFT JOIN sys_dept_account_withdraw c on a.id = c.dept_id
         where
         a.del_flag = 0
         <if test="userId != null and userId != ''">
             AND a.withdraw_user = #{userId}
         </if>
+        group by a.id
     </select>
 
     <select id="getDeptAccountByDept" resultMap="SysAccountByUserMap">

+ 37 - 0
src/main/resources/mapper/modules/admin/SysDeptAccountWithdrawMapper.xml

@@ -1,4 +1,41 @@
 <?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.SysDeptAccountWithdrawMapper">
+    <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.vo.SysDeptAccountWithdrawVo">
+        <id property="id" column="id" jdbcType="VARCHAR"/>
+        <result property="deptId" column="dept_id" jdbcType="VARCHAR"/>
+        <result property="name" column="name" jdbcType="VARCHAR"/>
+        <result property="amount" column="amount" jdbcType="DECIMAL"/>
+        <result property="status" column="status" jdbcType="VARCHAR"/>
+        <result property="remark" column="remark" jdbcType="VARCHAR"/>
+        <result property="createTime" column="create_date" jdbcType="TIMESTAMP"/>
+        <result property="createTimeStart" column="createTimeStart" jdbcType="VARCHAR"/>
+        <result property="createTimeEnd" column="createTimeEnd" jdbcType="VARCHAR"/>
+    </resultMap>
+
+
+    <select id="selectSysDeptAccountWithdraw" resultMap="BaseResultMap">
+        select
+        id,
+        dept_id,
+        name,amount,
+        status,
+        remark,
+        DATE(create_time) as create_date
+        from sys_dept_account_withdraw
+        where
+        <if test="sysDeptAccountWithdrawVo.status != null and sysDeptAccountWithdrawVo.status != ''">
+             status = #{sysDeptAccountWithdrawVo.status}
+        </if>
+        <if test="sysDeptAccountWithdrawVo.deptId != null and sysDeptAccountWithdrawVo.deptId != ''">
+            and dept_id  = #{sysDeptAccountWithdrawVo.deptId}
+        </if>
+        <if test="sysDeptAccountWithdrawVo.createTimeStart != null and sysDeptAccountWithdrawVo.createTimeStart != ''">
+            and create_time &gt;= #{sysDeptAccountWithdrawVo.createTimeStart}
+        </if>
+        <if test="sysDeptAccountWithdrawVo.createTimeEnd != null and sysDeptAccountWithdrawVo.createTimeEnd != ''">
+            and create_time &lt;= #{sysDeptAccountWithdrawVo.createTimeEnd}
+        </if>
+    </select>
+
 </mapper>