فهرست منبع

1. 结算需求修改优化

wuhp 2 سال پیش
والد
کامیت
25023b19ed

+ 36 - 6
sql/Online.sql

@@ -42,12 +42,19 @@ 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 (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);
+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, '手续费待提现', '663', '/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 (645, '非跟单待提现', '665', '/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, '推广待提现', '664', '/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, '手续费已提现', '663', '/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, '非跟单已提现', '665', '/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, '推广已提现', '664', '/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 (651, '审核提现', '643', NULL, 'sys:withdrawalProceduresPending:examinepay', 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 (653, '审核提现', '645', NULL, 'sys:nonDocumentaryPending:examinepay', 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 (654, '审核提现', '646', NULL, 'sys:generalizationPending:examinepay', 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 (663, '手续费提现', '201', 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 (664, '推广费提现', '201', 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 (665, '非跟单费提现', '201', NULL, NULL, 0, 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`;
@@ -113,3 +120,26 @@ INSERT INTO `sys_menu` (`name`, `parent_id`, `url`, `perms`, `type`, `icon`, `or
 --  add by hxl   2024-04-18 添加子订单表新操作人和新操作人名称
 ALTER TABLE ins_area_company ADD COLUMN new_operator_id VARCHAR(30) COMMENT '新操作人';
 ALTER TABLE ins_area_company ADD COLUMN new_operator_name VARCHAR(100) COMMENT '新操作人名称';
+
+
+-- 2024-0419  武鸿鹏
+ALTER TABLE `settlement_documentary_log` ADD COLUMN `company_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '保险公司id' AFTER `handing_amount`;
+ALTER TABLE `settlement_documentary_log` ADD COLUMN `year` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '年度' AFTER `company_id`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `is_not_documentary` varchar(5) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '是否是跟单' AFTER `is_not_car`;
+
+
+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 (663, '手续费提现', '201', 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 (664, '推广费提现', '201', 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 (665, '非跟单费提现', '201', 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 (667, '车险结算', '200', '/financialManagement/carInsurance/platformSettlement/carInsuranceBalance', 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 (668, '非车结算', '200', '/financialManagement/carInsurance/platformSettlement/nonVehicleBalance', 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 (669, '车险', '199', 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 (670, '非车', '199', 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 (671, '手续费结算', '669', '/financialManagement/carInsurance/companySettlement/carInsurance/handlingFees', 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 (672, '手续费结算', '670', '/financialManagement/carInsurance/companySettlement/noCarInsurance/handlingFees', 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 (673, '跟单费结算', '669', '/financialManagement/carInsurance/companySettlement/carInsurance/documentaryFees', 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 (674, '跟单费结算', '670', '/financialManagement/carInsurance/companySettlement/noCarInsurance/documentaryFees', 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 (675, '结算', '673', NULL, 'sys:', 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 (676, '结算', '674', NULL, NULL, 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 (677, '结算', '673', NULL, 'sys:documentaryFees1: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 (678, '结算', '674', NULL, 'sys:documentaryFees2:balance', 2, NULL, 0, NULL, NULL, NULL, NULL, 0);

+ 55 - 4
src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java

@@ -4,17 +4,18 @@ import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
 import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
 import com.ydtech.modules.fnc.service.InsPlyIncomeService;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
+import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.vo.OrderQueryVo;
 import com.ydtech.utils.StringUtils;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiModelProperty;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
 import java.time.LocalDate;
@@ -87,7 +88,7 @@ public class InsPlyIncomeController extends BaseController {
         return result;
     }
 
-    @PutMapping("/batchBalance")
+        @PutMapping("/batchBalance")
     @ApiModelProperty(value = "批量跟单费")
     public HttpResult<Object> batchBalance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
 
@@ -96,4 +97,54 @@ public class InsPlyIncomeController extends BaseController {
 
 
 
+    @PostMapping("/NonSettlementQuery")
+    @ApiOperation(value = "非跟单查询")
+    public HttpResult<BasePageResult<InsPlyIncome>>NonSettlementQuery(@Valid  @RequestBody InsPlyIncomeVo  insPlyIncomeVo) {
+        HttpResult<BasePageResult<InsPlyIncome>> result=insPlyIncomeService.nonSettlementQuery(insPlyIncomeVo);
+        return result;
+    }
+
+    @PostMapping("/NonSettldetail")
+    @ApiOperation(value = "非跟单明细查询")
+    public HttpResult<List<InsPlyIncome>>   NonSettldetail (@Valid  @RequestBody InsPlyIncomeVo  insPlyIncomeVo){
+        return  insPlyIncomeService.nonSettldetail(insPlyIncomeVo);
+    }
+    @PostMapping("/importData")
+    @ApiOperation(value = "渠道数据导入(excel)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file")
+    })
+    public HttpResult importData(@RequestPart MultipartFile file , @RequestBody InsPlyIncomeVo  insPlyIncomeVo ) {
+
+        insPlyIncomeService.importData(file,insPlyIncomeVo);
+
+        return HttpResult.ok("导入成功");
+    }
+
+    @PutMapping("/update")
+    @ApiModelProperty(value = "修改")
+    public HttpResult<Object> updateByEntity(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        insPlyIncomeService.updateByEntity(insPlyIncomeVo);
+        return HttpResult.ok("修改成功");
+    }
+    @PostMapping("/insert")
+    @ApiModelProperty(value = "新增")
+    public HttpResult<InsPlyIncome> insertByEntity(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return insPlyIncomeService.insertByEntity(insPlyIncomeVo);
+    }
+    @DeleteMapping("/delete")
+    @ApiModelProperty(value = "删除")
+    public HttpResult<InsPlyIncome>  deleteById(@RequestBody InsPlyIncomeVo insPlyIncomeVo){
+
+        return  insPlyIncomeService.deleteById(insPlyIncomeVo);
+
+    }
+    @GetMapping("/getById/{id}")
+    @ApiModelProperty(value = "回显")
+    public HttpResult<InsPlyIncome> getById(@PathVariable("id") String  id){
+        InsPlyIncome item = insPlyIncomeService.getById(id);
+        return  HttpResult.ok(item) ;
+    }
+
+
 }

+ 4 - 0
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -83,4 +83,8 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
 
     void uopdateByOrderno(InsPlyIncome insPlyIncome);
 
+    List<InsPlyIncome> NonSettlementQuery(HashMap<String, Object> params);
+
+    InsPlyIncome findByLicenseno(@Param("licenseno") String licenseno);
+
 }

+ 0 - 2
src/main/java/com/ydtech/modules/fnc/dao/SettlementDocumentaryFeesMapper.java

@@ -15,8 +15,6 @@ public interface SettlementDocumentaryFeesMapper  extends BaseMapper<SettlementD
 
     List<SettlementDocumentaryFeesEntity> querySettle(HashMap<String, Object> params);
 
-    List<SettlementDocumentaryFeesEntity> checkDate(HashMap<String, Object> params);
 
-    List<SettlementDocumentaryFeesEntity> selectAll(HashMap<String, Object> params);
 
 }

+ 34 - 0
src/main/java/com/ydtech/modules/fnc/entity/InsPlyIncome.java

@@ -27,6 +27,11 @@ public class InsPlyIncome implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+    @ApiModelProperty("id")
+    @TableField("id")
+    private String id;
+
+
     @ApiModelProperty("订单号")
     @TableField("orderno")
     private String orderno;
@@ -148,6 +153,10 @@ public class InsPlyIncome implements Serializable {
     @TableField("is_not_car")
     private String isNotCar;
 
+    @ApiModelProperty("是否是跟单")
+    @TableField("is_not_documentary")
+    private String isNotDocumentary;
+
 
     @ApiModelProperty("总单数")
     @TableField(exist = false)
@@ -173,5 +182,30 @@ public class InsPlyIncome implements Serializable {
     private String timeFrame;
 
 
+    @ApiModelProperty("保险跟单费总额")
+    @TableField(exist = false)
+    private BigDecimal allLOtherFeevalue;
+
+    @ApiModelProperty("跟单费结算金额")
+    @TableField(exist = false)
+    private BigDecimal settlementAmount;
+
+    @ApiModelProperty("跟单费未结算金额")
+    @TableField(exist = false)
+    private BigDecimal unsettledAmount;
+
+    @ApiModelProperty("开始时间")
+    @TableField(exist = false)
+    private BigDecimal sdfStartTime;
+
+
+    @ApiModelProperty("结束时间")
+    @TableField(exist = false)
+    private BigDecimal sdfEndTime;
+    @ApiModelProperty("月数")
+    @TableField(exist = false)
+    private String monthSigdate;
+
+
 
 }

+ 8 - 3
src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryFeesEntity.java

@@ -11,6 +11,7 @@ import lombok.Setter;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 @Getter
@@ -49,16 +50,20 @@ public class SettlementDocumentaryFeesEntity implements Serializable {
 
     @ApiModelProperty("创建时间")
     @TableField("create_time")
-    private LocalDateTime createTime;
+    private LocalDate createTime;
 
 
     @ApiModelProperty("开始时间")
     @TableField("start_time")
-    private LocalDateTime startTime;
+    private LocalDate startTime;
 
     @ApiModelProperty("结束时间")
     @TableField("end_time")
-    private LocalDateTime endTime;
+    private LocalDate endTime;
+
+    @ApiModelProperty("保险id")
+    @TableField("company_id")
+    private String companyId;
 
 
 

+ 23 - 3
src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java

@@ -1,10 +1,14 @@
 package com.ydtech.modules.fnc.service;
 
 import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.fnc.entity.InsAreaCompany;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.order.entity.BasePageResult;
+import com.ydtech.modules.order.entity.InsOrders;
+import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
@@ -19,9 +23,6 @@ import java.util.List;
 public interface InsPlyIncomeService extends IService<InsPlyIncome> {
     public HttpResult<BasePageResult<InsPlyIncome>> queryplyIncome(InsPlyIncomeVo insPlyIncomeVo);
 
-    void saveBalance(String companyId, String orderno);
-
-
 
     void uodateBalance(InsPlyIncomeVo insPlyIncomeVo);
 
@@ -31,4 +32,23 @@ public interface InsPlyIncomeService extends IService<InsPlyIncome> {
     HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo);
 
     HttpResult<BasePageResult<InsPlyIncome>> queryNew(InsPlyIncomeVo insPlyIncomeVo);
+
+
+    HttpResult<BasePageResult<InsPlyIncome>> nonSettlementQuery(InsPlyIncomeVo insPlyIncomeVo);
+
+
+    void saveBalanceNew(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany);
+
+    HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo);
+
+
+    void importData(MultipartFile file, InsPlyIncomeVo insPlyIncomeVo);
+
+    void updateByEntity(InsPlyIncomeVo insPlyIncomeVo);
+
+
+    HttpResult<InsPlyIncome> deleteById(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<InsPlyIncome> insertByEntity(InsPlyIncomeVo insPlyIncomeVo);
+
 }

+ 1 - 1
src/main/java/com/ydtech/modules/fnc/service/SettlementDocumentaryFeesService.java

@@ -3,6 +3,7 @@ package com.ydtech.modules.fnc.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
+import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
 import com.ydtech.modules.order.entity.BasePageResult;
 
@@ -13,7 +14,6 @@ public interface SettlementDocumentaryFeesService extends IService<SettlementDoc
 
     HttpResult inertSettle(SettlementDocumentaryFeesVo settlementDocumentaryFeesVo);
 
-    String checkDate(HashMap<String, Object> params);
 
     HttpResult documentarySettle(SettlementDocumentaryFeesVo settlementDocumentaryFeesVo);
 

+ 5 - 1
src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java

@@ -18,6 +18,7 @@ import com.ydtech.modules.fnc.dao.InsFeeAuditMapper;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.service.InsFeeAuditService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.fnc.service.InsPlyIncomeService;
 import com.ydtech.modules.ins.model.InsCommission;
 import com.ydtech.modules.ins.model.InsCompanyFee;
 import com.ydtech.modules.ins.model.InsDeptFee;
@@ -83,6 +84,8 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
 
     @Autowired
     private SysDeptAccountHistoryService sysDeptAccountHistoryService;
+    @Autowired
+    private InsPlyIncomeService insPlyIncomeService;
 
 
     public InsFeeAuditServiceImpl(FncInsAreaCompanyMapper insAreaCompanyMapper, InsOrdersMapper insOrdersMapper, InsFeeOrderService insFeeOrderService,InsDeptFeeService insDeptFeeService,EsmUserReferrerService esmUserReferrerService,SysUserService sysUserService,InsCommissionService insCommissionService,InsCompanyFeeService insCompanyFeeService,InsPlyIncomeMapper insPlyIncomeMapper) {
@@ -140,7 +143,8 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
 //        saveRetail(order,insFeeOrderNew,insAreaCompany);
         //个代费用生成
 //        saveInsCompanyFee(order,insFeeOrderNew,insAreaCompany);
-
+//        结算费用生成
+        insPlyIncomeService.saveBalanceNew(order,insFeeOrderNew,insAreaCompany);
 
 //      生成  用户账户表  数据
         if(StringUtils.isNotEmpty(order.getUserid())){

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

@@ -1,5 +1,6 @@
 package com.ydtech.modules.fnc.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -8,8 +9,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ydtech.core.page.HttpResult;
-import com.ydtech.modules.admin.model.po.SysAmountAuditingEntity;
-import com.ydtech.modules.admin.model.po.SysUserAccountHistory;
+import com.ydtech.exception.SystemException;
+import com.ydtech.modules.esm.model.EsmInsCompany;
+import com.ydtech.modules.fnc.entity.InsAreaCompany;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryLogEntity;
@@ -19,25 +21,36 @@ import com.ydtech.modules.fnc.service.SettlementDocumentaryFeesService;
 import com.ydtech.modules.fnc.service.SettlementDocumentaryLogService;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
+import com.ydtech.modules.inv.model.InvChannelsExternalBillsDetails;
+import com.ydtech.modules.inv.model.dto.InsPlyIncomeExcelDto;
+import com.ydtech.modules.inv.model.dto.InvChannelExcelDto;
 import com.ydtech.modules.order.entity.BasePageResult;
-import com.ydtech.modules.order.entity.InsAreaCompany;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.service.InsAreaCompanyService;
 import com.ydtech.modules.order.service.InsOrdersService;
+import com.ydtech.modules.protocol.entity.po.PtlAgreement;
+import com.ydtech.modules.protocol.entity.vo.PtlAgreementQueryVo;
+import com.ydtech.modules.protocol.service.PtlAgreementService;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
+import com.ydtech.utils.SnowFlakeUtil;
+import com.ydtech.utils.excel.ExcelEasypoiUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
+import redis.clients.jedis.params.Params;
 
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -52,6 +65,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
 
 
     @Autowired
+    @Lazy
     private InsOrdersService insOrdersService;
     @Autowired
     private InsAreaCompanyService insAreaCompanyService;
@@ -62,6 +76,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     private SettlementDocumentaryFeesService settlementDocumentaryFeesService;
     @Autowired
     private SettlementDocumentaryLogService settlementDocumentaryLogService;
+    @Autowired
+    private PtlAgreementService  ptlAgreementService;
 
 
     public HttpResult<BasePageResult<InsPlyIncome>> queryplyIncome(InsPlyIncomeVo insPlyIncomeVo){
@@ -84,100 +100,262 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     }
 
     @Override
-    public void saveBalance(String companyId, String orderno) {
-        InsOrders insOrders = insOrdersService.getById(orderno);
-        InsAreaCompany insAreaCompany = insAreaCompanyService.getById(companyId);
-        InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(companyId);
-        this.saveBalanc(insFeeOrderNew, insOrders, insAreaCompany);
-    }
-
+    public void saveBalanceNew(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
+        if (ObjectUtils.isEmpty(order) || ObjectUtils.isEmpty(insFeeOrderNew) || ObjectUtils.isEmpty(insAreaCompany)) {
+            return;
+        }
 
+        String agreeType = this.judgeAgreeType(insAreaCompany.getAgreementId());
+        if (StringUtils.isNotEmpty(agreeType)) {
+//            判断协议类型 平台  保险
+            if ("1".equals(agreeType)) {
+                // 平台逻辑处理   判断是否是 和手续费 非车
+                if (insFeeOrderNew.getJqSuperviseCostsPremiums() != null || insFeeOrderNew.getSySuperviseCostsPremiums() != null) { //平台车险
+//                    生成手续费  跟单费和手续费是一条单据
+                    this.savePinTai(order,insFeeOrderNew,insAreaCompany);
+                }
+                if(insFeeOrderNew.getNoSuperviseCostsPremiums() != null || insFeeOrderNew.getNoOtherCostsPremiums() != null){ // 平台非车
+                    this.saveNoPinTai(order,insFeeOrderNew,insAreaCompany);
+                }
+            }else {  // 保险  逻辑: 手续费生成一条  跟单费生成一条   非车手续费一条  非车跟单费一条
+                if (insFeeOrderNew.getJqSuperviseCostsPremiums() != null || insFeeOrderNew.getSySuperviseCostsPremiums() != null) { //手续费
+                    this.saveInsuranceProcedures(order,insFeeOrderNew,insAreaCompany);
+                }
+                if(insFeeOrderNew.getJqOtherCostsPremiums()!=null ){   //跟单费
+                    this.saveOtherAmount(order,insFeeOrderNew,insAreaCompany);
+                }
+                if(insFeeOrderNew.getNoSuperviseCostsPremiums()  !=null){  // 非车手续费
+                    this.saveNoSupervise(order,insFeeOrderNew,insAreaCompany);
+                }
+                if(insFeeOrderNew.getNoOtherCostsPremiums() !=null){  // 非车跟单费
+                    this.saveNoOtherAmount(order,insFeeOrderNew,insAreaCompany);
+                }
+            }
+        }
+    }
 
-    private void saveBalanc(InsFeeOrderNew insFeeOrderNew, InsOrders insOrders, InsAreaCompany insAreaCompany) {
+    private void saveNoOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
         InsPlyIncome insPlyIncome = new InsPlyIncome();
+        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
+        String noPolicyno  = this.setNoPolicyno(insAreaCompany);
+        if(StringUtils.isNotEmpty(noPolicyno)){
+            insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
+        }
+        insPlyIncome.setOtherFeevalue(insFeeOrderNew.getNoOtherCostsPremiums());  //非车跟单费
+        insPlyIncome.setOtherFeerate(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费用比例
+        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
+        insPlyIncome.setRiskcode(order.getProductid());
+        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
+        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
+        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
+        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
+        insPlyIncome.setLicenseno(order.getLicenseno());
+        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
+        insPlyIncome.setCreateTime(LocalDateTime.now());
+        insPlyIncome.setDocumentaryFeesStatus("0");
+        insPlyIncome.setHandlingFeesStatus("0");
+        insPlyIncome.setIsNotCar("1");
+        insPlyIncome.setIsNotDocumentary("1");
+        insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoOtherCostsPremiums());
+    }
 
-
+    private void saveNoSupervise(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
         insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
-//      存储保单号
-        try {
-            this.setPolicyno(insPlyIncome,insAreaCompany);
-        } catch (JsonProcessingException e) {
-            throw new RuntimeException(e);
+        insPlyIncome.setCommissionFeevalue(insFeeOrderNew.getNoSuperviseCostsPremiums());// 非车手续费
+        insPlyIncome.setCommissionFeerate(insFeeOrderNew.getNoSuperviseCostsProportion());// 非车手续费比例
+        String noPolicyno  = this.setNoPolicyno(insAreaCompany);
+        if(StringUtils.isNotEmpty(noPolicyno)){
+            insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
         }
+        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
+        insPlyIncome.setRiskcode(order.getProductid());
+        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
+        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
+        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
+        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
+        insPlyIncome.setLicenseno(order.getLicenseno());
+        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
+        insPlyIncome.setCreateTime(LocalDateTime.now());
+        insPlyIncome.setDocumentaryFeesStatus("0");
+        insPlyIncome.setHandlingFeesStatus("0");
+        insPlyIncome.setIsNotCar("1");
+        insPlyIncome.setIsNotDocumentary("0");
+        insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoSuperviseCostsPremiums());
+        baseMapper.insert(insPlyIncome);
+    }
 
+    private void saveOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
+        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
+        insPlyIncome.setPolicyno(insAreaCompany.getJqpolicyno());  // 商业保单号
+        insPlyIncome.setSyPolicyno(insAreaCompany.getSypolicyno());  // 商业保单号
+        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums());
+        insPlyIncome.setOtherFeevalue(otherAmount);//跟单费用
+        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion());
+        insPlyIncome.setOtherFeerate(otherProportion); // 跟单非比例
         insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(insOrders.getProductid());
+        insPlyIncome.setRiskcode(order.getProductid());
         insPlyIncome.setPayDate(insAreaCompany.getPayDate());
         insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
         insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
         insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
-        insPlyIncome.setLicenseno(insOrders.getLicenseno());
+        insPlyIncome.setLicenseno(order.getLicenseno());
         insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
+        insPlyIncome.setCreateTime(LocalDateTime.now());
+        insPlyIncome.setDocumentaryFeesStatus("0");
+        insPlyIncome.setHandlingFeesStatus("0");
+        insPlyIncome.setIsNotCar("0");
+        insPlyIncome.setIsNotDocumentary("1");
+        insPlyIncome.setAllFeeValue(otherAmount);
+        baseMapper.insert(insPlyIncome);
+    }
+
+    private void saveInsuranceProcedures(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
+//        保险手续费
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
+        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
+        insPlyIncome.setPolicyno(insAreaCompany.getJqpolicyno());   // 交强保单号
+        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums());
+        insPlyIncome.setCommissionFeevalue(handlingAmount);//手续费
+        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion());
+        insPlyIncome.setCommissionFeerate(handlingProportion);// 手续费比例
 
-        BigDecimal bigDecimal = this.sumAmount(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), insFeeOrderNew.getNoNoTaxPremium());
-        //      不含保费
-        insPlyIncome.setNoTaxPremium(bigDecimal);
-//      手续费比例
-        BigDecimal CostsProportion = this.sumAmount(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion(), insFeeOrderNew.getNoSuperviseCostsProportion());
-        insPlyIncome.setCommissionFeerate(CostsProportion);
-//      其他费用比例
-        BigDecimal OtherCostsProportion = this.sumAmount(insFeeOrderNew.getJqOtherCostsProportion(), insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getNoOtherCostsProportion());
-        insPlyIncome.setOtherFeerate(OtherCostsProportion);
-//        手续费金额
-        BigDecimal SuperviseCostsPremiums = this.sumAmount(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums(), insFeeOrderNew.getNoSuperviseCostsPremiums());
-        insPlyIncome.setCommissionFeevalue(SuperviseCostsPremiums);
-//      其他费用金额
-        BigDecimal OtherCostsPremiums = this.sumAmount(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(), insFeeOrderNew.getNoOtherCostsPremiums());
-        insPlyIncome.setOtherFeevalue(OtherCostsPremiums);
-        insPlyIncome.setAllFeeValue(SuperviseCostsPremiums.add(OtherCostsPremiums));
+        insPlyIncome.setSyPolicyno(insAreaCompany.getSypolicyno()); //商业保单号
+        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
+        insPlyIncome.setRiskcode(order.getProductid());
+        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
+        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
+        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
+        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
+        insPlyIncome.setLicenseno(order.getLicenseno());
+        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
         insPlyIncome.setCreateTime(LocalDateTime.now());
         insPlyIncome.setDocumentaryFeesStatus("0");
         insPlyIncome.setHandlingFeesStatus("0");
+        insPlyIncome.setIsNotCar("0");
+        insPlyIncome.setIsNotDocumentary("0");
+        insPlyIncome.setAllFeeValue(handlingAmount);
         baseMapper.insert(insPlyIncome);
+    }
 
+    private void saveNoPinTai(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
+        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
+        String noPolicyno  = this.setNoPolicyno(insAreaCompany);
+        if(StringUtils.isNotEmpty(noPolicyno)){
+            insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
+        }
+        insPlyIncome.setCommissionFeevalue(insFeeOrderNew.getNoSuperviseCostsPremiums());// 非车手续费
+        insPlyIncome.setCommissionFeerate(insFeeOrderNew.getNoSuperviseCostsProportion()); // 非车手续费比例
+        insPlyIncome.setOtherFeevalue(insFeeOrderNew.getNoOtherCostsPremiums());  //非车跟单费
+        insPlyIncome.setOtherFeerate(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费用比例
+        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
+        insPlyIncome.setRiskcode(order.getProductid());
+        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
+        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
+        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
+        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
+        insPlyIncome.setLicenseno(order.getLicenseno());
+        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
+        insPlyIncome.setCreateTime(LocalDateTime.now());
+        insPlyIncome.setDocumentaryFeesStatus("0");
+        insPlyIncome.setHandlingFeesStatus("0");
+        insPlyIncome.setIsNotCar("1");
+        insPlyIncome.setIsNotDocumentary("0");
+        insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
+        baseMapper.insert(insPlyIncome);
     }
 
-    private void setPolicyno(InsPlyIncome insPlyIncome, InsAreaCompany insAreaCompany) throws JsonProcessingException {
-        ObjectMapper objJson = new ObjectMapper();
+    private String setNoPolicyno(com.ydtech.modules.fnc.entity.InsAreaCompany insAreaCompany) {
+        String crossInsurance = insAreaCompany.getCrossInsurance();
 
-        String jqpolicyno = insAreaCompany.getJqpolicyno();  // 交强保单号
-        String sypolicyno = insAreaCompany.getSypolicyno();  // 商业保单号
-        JSONArray crossInsurance = insAreaCompany.getCrossInsurance();  // 非车保单号
+        if (StringUtils.isEmpty(crossInsurance)) {
+            return null;
+        }
 
-        if(ObjectUtils.isNotEmpty(jqpolicyno)){
-            insPlyIncome.setPolicyno(jqpolicyno);
+        try {
+            ObjectMapper objJson = new ObjectMapper();
+            JsonNode jsonArryNode = objJson.readTree(crossInsurance);
 
-        }
-        if(ObjectUtils.isNotEmpty(sypolicyno)){
-            insPlyIncome.setSyPolicyno(sypolicyno);
-        }
-        if(ObjectUtils.isNotEmpty(crossInsurance)){
-         JsonNode   jsonArryNode= objJson.readTree(crossInsurance.toJSONString());
-            if (jsonArryNode.isArray()) {
-                for (JsonNode jsonNode : jsonArryNode) {
-                    JsonNode jsonNode1 = jsonNode.get("policyNumber");//非车保单号
-                    if(ObjectUtils.isNotEmpty(jsonNode1)){
-                        insPlyIncome.setNoPolicyno(jsonNode1.asText());
-                    }else {
-                       String  nopolicy =   jsonNode.get("policy").asText();   //非车保单号
-                        insPlyIncome.setNoPolicyno(nopolicy);
-                    }
+            if (jsonArryNode.isArray() && jsonArryNode.size() > 0) {
+                JsonNode firstNode = jsonArryNode.get(0);
+                JsonNode policyNumberNode = firstNode.get("policyNumber");
+
+                if (policyNumberNode != null) {
+                    return policyNumberNode.asText();
+                } else {
+                    return firstNode.get("policy").asText();
                 }
             }
-
+        } catch (IOException e) {
+            e.printStackTrace(); // 可以打印异常信息
         }
 
+        return null;
+    }
 
+    private void savePinTai(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
+        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
+        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums());
+        insPlyIncome.setCommissionFeevalue(handlingAmount);//手续费
+        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion());
+        insPlyIncome.setCommissionFeerate(handlingProportion);// 手续费比例
+        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums());
+        insPlyIncome.setOtherFeevalue(otherAmount);//跟单费用
+        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion());
+        insPlyIncome.setOtherFeerate(otherProportion); // 跟单非比例
+        //保单号
+        insPlyIncome.setPolicyno(insAreaCompany.getJqpolicyno());  // 交强保单号
+        insPlyIncome.setSyPolicyno(insAreaCompany.getSypolicyno()); //商业保单号
+        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
+        insPlyIncome.setRiskcode(order.getProductid());
+        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
+        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
+        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
+        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
+        insPlyIncome.setLicenseno(order.getLicenseno());
+        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
+        insPlyIncome.setCreateTime(LocalDateTime.now());
+        insPlyIncome.setDocumentaryFeesStatus("0");
+        insPlyIncome.setHandlingFeesStatus("0");
+        insPlyIncome.setIsNotCar("0");
+        insPlyIncome.setIsNotDocumentary("0");
+        insPlyIncome.setAllFeeValue(otherAmount.add(handlingAmount));
+        baseMapper.insert(insPlyIncome);
     }
 
-    private BigDecimal sumAmount(BigDecimal amount1, BigDecimal amount2, BigDecimal amount3) {
-        BigDecimal jqNoTaxPremium = (amount1 != null) ? amount1 : BigDecimal.ZERO;
-        BigDecimal syNoTaxPremium = (amount2 != null) ? amount2 : BigDecimal.ZERO;
-        BigDecimal noNoTaxPremium = (amount3 != null) ? amount3 : BigDecimal.ZERO;
+    private BigDecimal calculateTotal(BigDecimal value1, BigDecimal value2) {
+        BigDecimal total = BigDecimal.ZERO;
+
+        if (value1 != null) {
+            total = total.add(value1);
+        }
+
+        if (value2 != null) {
+            total = total.add(value2);
+        }
 
-        return jqNoTaxPremium.add(syNoTaxPremium).add(noNoTaxPremium);
+        return total;
     }
 
+    private String judgeAgreeType(Long agreementId) {
+        if (agreementId == null) {
+            return null;
+        }
+
+        HttpResult<PtlAgreementQueryVo> byAgreementId = ptlAgreementService.getByAgreementId(agreementId.toString());
+        if (byAgreementId != null && ObjectUtils.isNotEmpty(byAgreementId.getData())) {
+            PtlAgreement agreement = byAgreementId.getData().getAgreement();
+            String agreementType = agreement.getAgreementType();
+            if (StringUtils.isNotEmpty(agreementType)) {
+                return agreementType;
+            }
+        }
+
+        return null;
+    }
 
     public HttpResult<BasePageResult<InsPlyIncome>> queryNew(InsPlyIncomeVo insPlyIncomeVo){
         try{
@@ -199,6 +377,16 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             if(StringUtils.isNotEmpty(insPlyIncomeVo.getPolicyno())){
                 params.put("policyno",insPlyIncomeVo.getPolicyno());
             }
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
+                params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
+            }
+
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
+                params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
+            }
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType())){
+                params.put("agreementType",insPlyIncomeVo.getAgreementType());
+            }
 
             List<InsPlyIncome> list= this.baseMapper.queryNew(params);
             pageHelper=new PageInfo(list);
@@ -210,6 +398,160 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         }
     }
 
+    @Override
+    public HttpResult<BasePageResult<InsPlyIncome>> nonSettlementQuery(InsPlyIncomeVo insPlyIncomeVo) {
+        try{
+            HashMap<String, Object> params = new HashMap<>();
+            PageInfo<List<InsPlyIncome>> pageHelper = null;
+            PageHelper.startPage(insPlyIncomeVo.getPageNum(),insPlyIncomeVo.getPageSize());
+            params.put("pageNum",insPlyIncomeVo.getPageNum());
+            params.put("pageSize",insPlyIncomeVo.getPageSize());
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
+                params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
+            }
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
+                params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
+            }
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+                params.put("year",insPlyIncomeVo.getYear());
+            }
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+                params.put("year",insPlyIncomeVo.getYear());
+            }
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())){
+                params.put("documentaryFeesStatus",insPlyIncomeVo.getDocumentaryFeesStatus());
+            }
+            List<InsPlyIncome> list= this.baseMapper.NonSettlementQuery(params);
+            pageHelper=new PageInfo(list);
+            BasePageResult<InsPlyIncome> pageResult=new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
+            return HttpResult.ok(pageResult);
+        }catch (Exception e){
+            e.printStackTrace();
+            return HttpResult.error("查询异常");
+        }
+    }
+
+    @Override
+    public HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
+        try {
+            String ids = insPlyIncomeVo.getIds();
+            ArrayList<InsPlyIncome> resultList = new ArrayList<>();
+            if (ObjectUtils.isNotEmpty(ids)) {
+                String[] split = ids.split(",");
+                    for (int i =0; i <split.length ; i++) {
+                    String id = split[i];
+                    resultList.add(baseMapper.selectById(id));
+                }
+            }
+            return HttpResult.ok(resultList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return HttpResult.error("查询异常");
+        }
+    }
+
+    @Override
+    public void importData(MultipartFile file, InsPlyIncomeVo insPlyIncomeVo) {
+//InsPlyIncomeExcelDto
+        List<InsPlyIncome> list = null;
+        try {
+            List<InsPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(file, InsPlyIncomeExcelDto.class, 0, 1, 1);
+            for (InsPlyIncomeExcelDto excelItem : dtoList) {
+                String licenseno = excelItem.getLicenseno();//车牌号
+                if(ObjectUtils.isNotEmpty(licenseno)){
+                    InsPlyIncome insPlyIncome=baseMapper.findByLicenseno(licenseno);
+                    if(ObjectUtils.isNotEmpty(insPlyIncome)){
+                        insPlyIncome.setContractFileId(insPlyIncomeVo.getContractFileId());
+                        insPlyIncome.setContractId(insPlyIncomeVo.getContractId());
+                        insPlyIncome.setVoucherNumber(insPlyIncomeVo.getVoucherNumber());
+                        baseMapper.updateById(insPlyIncome);
+                    }
+                }
+            }
+        } catch (IOException e) {
+            throw new SystemException("导入失败!");
+        }
+    }
+
+    @Override
+    public void updateByEntity(InsPlyIncomeVo insPlyIncomeVo) {
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
+        BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
+        baseMapper.updateById(insPlyIncome);
+    }
+
+//    @Override
+//    public void insertByEntity(InsPlyIncomeVo insPlyIncomeVo) {
+
+//    }
+
+    @Override
+    public HttpResult<InsPlyIncome> insertByEntity(InsPlyIncomeVo insPlyIncomeVo) {
+        Long id = new SnowFlakeUtil().nextId();
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
+        insPlyIncomeVo.setOrderno(id.toString());
+        BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
+        insPlyIncome.setDocumentaryFeesStatus("0");
+        insPlyIncome.setHandlingFeesStatus("0");
+        insPlyIncome.setIsNotCar("0");
+        insPlyIncome.setIsNotDocumentary("1");
+        baseMapper.insert(insPlyIncome);
+        HashMap<String, Object> params = new HashMap<>();
+
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
+            params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
+        }
+        params.put("isOther","1");
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            params.put("year",insPlyIncomeVo.getYear());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
+            params.put("companyId",insPlyIncomeVo.getCompanyId());
+        }
+
+        List<InsPlyIncome> list= this.baseMapper.NonSettlementQuery(params);
+        if(!CollectionUtils.isEmpty(list)){
+            for (InsPlyIncome item :list){
+                return HttpResult.ok(item.getIds());
+            }
+        }
+        return null;
+    }
+
+    @Override
+    @Transactional
+    public HttpResult<InsPlyIncome> deleteById(InsPlyIncomeVo insPlyIncomeVo) {
+
+        HashMap<String, Object> params = new HashMap<>();
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
+            params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
+        }
+            params.put("isOther","1");
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            params.put("year",insPlyIncomeVo.getYear());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
+            params.put("companyId",insPlyIncomeVo.getCompanyId());
+        }
+        baseMapper.deleteById(insPlyIncomeVo.getId());
+
+        List<InsPlyIncome> list = this.baseMapper.NonSettlementQuery(params);
+        if (!CollectionUtils.isEmpty(list)) {
+            for (InsPlyIncome item : list) {
+                return HttpResult.ok(item.getIds());
+            }
+        } else  {
+            return HttpResult.ok(null);
+
+        }
+        return HttpResult.ok("删除成功");
+
+    }
+
+
+
+
+
     @Override
     @Transactional
     public void uodateBalance(InsPlyIncomeVo insPlyIncomeVo) {
@@ -225,7 +567,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue());  // 跟单费金额
         }
         settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getCommissionFeevalue());  // 手续费金额
-        settlementDocumentaryLogEntity.setSettlementDocumentaryId(insPlyIncomeVo.getOrderno()); // 关联id
+        settlementDocumentaryLogEntity.setSettlementDocumentaryId(insPlyIncomeVo.getId()); // 关联id
         settlementDocumentaryLogEntity.setAmountType("1");  //手续费结算
         settlementDocumentaryLogEntity.setCreateTime(new Date());
         settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
@@ -236,14 +578,28 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     public HttpResult<BasePageResult<InsPlyIncome>> totalQuery(InsPlyIncomeVo insPlyIncomeVo) {
         HashMap<String, Object> params = new HashMap<>();
         PageInfo<List<InsPlyIncome>> pageHelper = null;
-        params.put("startDate",insPlyIncomeVo.getStartDate().toString());
-        params.put("endDate",insPlyIncomeVo.getEndDate().toString());
-//      判断非跟单结算日期是否已经存在
-        String resultDate = this.JudgingDate(params);
-        if(StringUtils.isNotEmpty(resultDate)){
-            return HttpResult.error("该时间段已近有单据做过结算,请结算");
-        }
+        if(insPlyIncomeVo.getStartDate()!=null){
+            params.put("startDate",insPlyIncomeVo.getStartDate().toString());
 
+        }
+        if(insPlyIncomeVo.getEndDate()!=null){
+            params.put("endDate",insPlyIncomeVo.getEndDate().toString());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            params.put("year",insPlyIncomeVo.getYear());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
+            params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
+            params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())){
+            params.put("documentaryFeesStatus",insPlyIncomeVo.getDocumentaryFeesStatus());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
+            params.put("companyId",insPlyIncomeVo.getCompanyId());
+        }
         params.put("pageNum",insPlyIncomeVo.getPageNum());
         params.put("pageSize",insPlyIncomeVo.getPageSize());
         List<InsPlyIncome> list= this.baseMapper.totalQuery(params);
@@ -252,33 +608,30 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         return  HttpResult.ok(new BasePageResult<>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list));
     }
 
-    private String JudgingDate(HashMap<String, Object> params) {
-        if(ObjectUtils.isNotEmpty(params.get("startDate"))  &&  ObjectUtils.isNotEmpty(params.get("endDate")) ){
-            String   checkResult = settlementDocumentaryFeesService.checkDate(params);
-            if(StringUtils.isNotEmpty(checkResult)){
-                return checkResult;
-            }
-        }
-        return  null;
-
-    }
 
     @Override
     @Transactional
     public HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo) {
-//      生成新数据
-        SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();
+//  通过ids 查出跟单非结算单
+        String ids = insPlyIncomeVo.getIds();
+        if(StringUtils.isNotEmpty(ids)){
+            String[] split = ids.split(",");
+            for (int i =0; i <split.length ; i++) {
+                String id = split[i];
+                InsPlyIncome insPlyIncome = baseMapper.selectById(id);
+                insPlyIncome.setContractId(insPlyIncomeVo.getContractId()); // 合同id
+                insPlyIncome.setContractFileId(insPlyIncomeVo.getContractFileId());
+                insPlyIncome.setVoucherNumber(insPlyIncomeVo.getVoucherNumber());
+                insPlyIncome.setDocumentaryFeesStatus("1"); //1  为跟单费已经结算
+                baseMapper.updateById(insPlyIncome);
+            }
+        }
+        SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();  // 生成跟单费结算表
+        settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
+        settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
+        settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());
         settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getTotAmount());
-        settlementDocumentaryFeesVo.setTotalOrders(insPlyIncomeVo.getTotalorders());
-        settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getTimeFrame());
-        settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
-        settlementDocumentaryFeesVo.setStartTime(insPlyIncomeVo.getStartDate().atStartOfDay());
-        settlementDocumentaryFeesVo.setEndTime(insPlyIncomeVo.getEndDate().atStartOfDay());
-        settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//  结算金额
-        settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getTotAmount().subtract(insPlyIncomeVo.getSettlementAmount()));  //未结算金额
-
         return  settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
-
 //
     }
 }

+ 1 - 9
src/main/java/com/ydtech/modules/fnc/service/impl/SettlementDocumentaryFeesServiceImpl.java

@@ -12,6 +12,7 @@ import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryLogEntity;
 import com.ydtech.modules.fnc.service.SettlementDocumentaryFeesService;
 import com.ydtech.modules.fnc.service.SettlementDocumentaryLogService;
+import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.order.entity.InsOrders;
@@ -55,7 +56,6 @@ public class SettlementDocumentaryFeesServiceImpl extends ServiceImpl<Settlement
     @Transactional
     public HttpResult inertSettle(SettlementDocumentaryFeesVo settlementDocumentaryFeesVo) {
 
-
         int i = this.compareAmount(settlementDocumentaryFeesVo.getTotalAmount(), settlementDocumentaryFeesVo.getSettlementAmount());
         if (i < 0) {
             return HttpResult.error("结算金额大于总金额,请重新结算");
@@ -74,15 +74,7 @@ public class SettlementDocumentaryFeesServiceImpl extends ServiceImpl<Settlement
         return HttpResult.ok("结算成功");
     }
 
-    @Override
-    public String checkDate(HashMap<String, Object> params) {
 
-        List<SettlementDocumentaryFeesEntity> startList = baseMapper.checkDate(params);
-        if (startList.size() > 0) {
-            return "有重复";
-        }
-        return null;
-    }
 
     @Override
     @Transactional

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

@@ -33,6 +33,10 @@ public class InsPlyIncomeVo implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+
+    @ApiModelProperty("主键id")
+    private String id;
+
     @ApiModelProperty("订单号")
     private String orderno;
 
@@ -126,4 +130,13 @@ public class InsPlyIncomeVo implements Serializable {
     @ApiModelProperty("手续费结算金额")
     private BigDecimal handingAmount;
 
+    @ApiModelProperty("是否跟单")
+    private  String isNotDocumentary;
+    @ApiModelProperty("年度")
+    @JsonFormat(pattern = "yyyy", timezone = "GMT+8")
+    private  String year;
+
+    @ApiModelProperty("其他费用比例")
+    private BigDecimal otherFeerate;
+
 }

+ 12 - 3
src/main/java/com/ydtech/modules/fnc/vo/SettlementDocumentaryFeesVo.java

@@ -1,6 +1,7 @@
 package com.ydtech.modules.fnc.vo;
 
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -9,6 +10,7 @@ import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 @Data
@@ -40,12 +42,12 @@ public class SettlementDocumentaryFeesVo implements Serializable {
     private BigDecimal unsettledAmount;
 
     @ApiModelProperty("开始时间")
-    @TableField("start_time")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private LocalDateTime startTime;
 
     @ApiModelProperty("结束时间")
-    @TableField("end_time")
-    private LocalDateTime endTime;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDate endTime;
 
     @ApiModelProperty(value = "每页页数")
     @Min(value = 20, message = "页数最小为20")
@@ -55,4 +57,11 @@ public class SettlementDocumentaryFeesVo implements Serializable {
     @ApiModelProperty(value = "页数")
     @Min(value = 1, message = "页数最小为1")
     private int pageNum=1;
+    @ApiModelProperty("保险公司")
+    private String companyId;
+
+
+    @ApiModelProperty("签单日期")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private LocalDate signingTime;
 }

+ 14 - 0
src/main/java/com/ydtech/modules/inv/model/dto/InsPlyIncomeExcelDto.java

@@ -0,0 +1,14 @@
+package com.ydtech.modules.inv.model.dto;
+
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class InsPlyIncomeExcelDto {
+    /**
+     * 等级
+     */
+    @Excel(name = "车牌号")
+    private String licenseno;
+}

+ 0 - 2
src/main/java/com/ydtech/modules/order/service/impl/DaJiaOrderServiceImpl.java

@@ -732,7 +732,6 @@ public class DaJiaOrderServiceImpl implements DaJiaOrderService {
      * @return
      */
     @Override
-    @Transactional
     public HttpResult<Object> verifyPayment(String companyId) {
         try {
             InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(companyId);
@@ -810,7 +809,6 @@ public class DaJiaOrderServiceImpl implements DaJiaOrderService {
                         //如果为自动审核 则自动进行审核
                         insFeeAuditService.autoFeeAudit( insAreaCompany.getOrderno(),insAreaCompany.getId());
                     }
-                    insPlyIncomeService.saveBalance(companyId,insAreaCompany.getOrderno());
                 }
             }
             return HttpResult.ok("查询订单状态成功");

+ 124 - 24
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -4,8 +4,9 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.ydtech.modules.fnc.entity.InsPlyIncome">
-        <id column="orderno" property="orderno" />
-        <id column="policyno" property="policyno" />
+        <id column="id" property="id" />
+        <result column="orderno" property="orderno" />
+        <result column="policyno" property="policyno" />
         <result column="dept_id" property="deptId" />
         <result column="dept_name" property="deptName" />
         <result column="riskcode" property="riskcode" />
@@ -31,10 +32,13 @@
         <result column="documentary_fees_status" property="documentaryFeesStatus"/>
         <result column="no_policyno" property="noPolicyno"/>
         <result column="sy_policyno" property="syPolicyno"/>
+        <result column="is_not_car" property="isNotCar"/>
+        <result column="is_not_documentary" property="isNotDocumentary"/>
     </resultMap>
 
     <select id="queryNew"  resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
             select
+                a.id      as  "id",
                 a.orderno  as  "orderno",
                 a.policyno  as  "policyno",
                 a.dept_id  as  "deptId",
@@ -60,6 +64,8 @@
                 a.no_policyno  as  "noPolicyno",
                 a.sy_policyno  as  "syPolicyno",
                 a.documentary_fees_status  as  "documentaryFeesStatus",
+                a.is_not_car  as  "isNotCar",
+                a.is_not_documentary  as  "isNotDocumentary",
                 a.create_time  as  "createTime"
                 from  ins_ply_income a
                 LEFT  JOIN  ptl_agreement  pa  on  a.agreement_id  = pa.id
@@ -85,36 +91,50 @@
                 <if test="documentaryFeesStatus !=null  and  documentaryFeesStatus  !=''">
                     and a.documentary_fees_status =#{documentaryFeesStatus}
                 </if>
-            </where>
-    </select>
-
 
-    <select id="totalQuery"  resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
-            select
-                sum(a.other_feevalue) as "totAmount",
-                GROUP_CONCAT(orderno) as  "ids",
-                count(1) as "totalorders"
-                from  ins_ply_income a
-                LEFT  JOIN  ptl_agreement  pa  on  a.agreement_id  = pa.id
-            <where>
-                <if test="startDate !=null  and  startDate!='' and  endDate !=null and endDate !=''">
-                    and DATE_FORMAT( a.signdate, '%Y-%m-%d')  between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
-                </if>
-
-                <if test="agreementtype !=null  and  agreementtype  !=''">
-                    and pa.agreement_type =#{agreementtype}
+                <if test="isNotCar !=null  and  isNotCar  !=''">
+                    and a.is_not_car =#{isNotCar}
                 </if>
 
-                <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
-                    and a.handling_fees_status =#{handlingFeesStatus}
+                <if test="isOther !=null  and  isOther  !=''">
+                    and a.is_not_documentary   =#{isOther}
                 </if>
 
-                <if test="documentaryFeesStatus !=null  and  documentaryFeesStatus  !=''">
-                    and a.documentary_fees_status =#{documentaryFeesStatus}
-                </if>
             </where>
     </select>
 
+
+    <select id="totalQuery"  resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        select
+              count(MONTH(a.signdate))  as "totalorders",
+              MONTH(a.signdate)    as  "monthSigdate",
+              sum(a.other_feevalue)    as  "allLOtherFeevalue",
+              GROUP_CONCAT(a.id) as  "ids"
+              from  ins_ply_income a
+              LEFT  JOIN  ptl_agreement  pa  on  a.agreement_id  = pa.id
+        <where>
+            <if test="isNotCar !=null  and  isNotCar  !=''" >
+                 a.is_not_car =#{isNotCar}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+            <if test="agreementType !=null  and  agreementType  !=''">
+                and pa.agreement_type =#{agreementType}
+            </if>
+            <if test="documentaryFeesStatus !=null  and  documentaryFeesStatus  !=''">
+                and a.documentary_fees_status =#{documentaryFeesStatus}
+            </if>
+            <if test="companyId !=null  and  companyId  !=''">
+                and a.company_id =#{companyId}
+            </if>
+            <if test="year !=null  and  year  !=''">
+                and YEAR(a.signdate) =#{year}
+            </if>
+            group by  MONTH(a.signdate)
+        </where>
+    </select>
+
     <update id="uopdateByOrderno" parameterType="com.ydtech.modules.fnc.entity.InsPlyIncome">
         update ins_ply_income
         <set>
@@ -136,4 +156,84 @@
         </set>
         where  orderno  =#{orderno}
     </update>
+
+
+    <select id="NonSettlementQuery"  resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        SELECT
+        a.companyId  as  "companyId",
+        a.totalorders  as  "totalorders",
+        a.ids as  "ids",
+        a.allLOtherFeevalue as  "allLOtherFeevalue"
+        FROM
+        (
+        SELECT
+        a.company_id AS "companyId",
+        count(a.orderno)  as  "totalorders",
+        sum( a.other_feevalue ) AS "allLOtherFeevalue",
+        GROUP_CONCAT(a.id) as  "ids"
+        FROM
+        ins_ply_income a
+        LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+        WHERE
+         pa.agreement_type = '2'
+        <if test="isNotCar !=null  and  isNotCar  !=''" >
+                and a.is_not_car =#{isNotCar}
+        </if>
+        <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
+            AND  a.documentary_fees_status = #{documentaryFeesStatus},
+        </if>
+
+        <if test="isOther !=null  and  isOther  !=''">
+            and a.is_not_documentary   =#{isOther}
+        </if>
+        <if test="companyId !=null  and  companyId  !=''">
+            and a.company_id   =#{companyId}
+        </if>
+        <if test="year !=null  and  year  !=''">
+            and YEAR(a.signdate) =#{year}
+        </if>
+        GROUP BY
+        a.company_id
+        ) a
+        LEFT JOIN ptl_agreement pa ON a.companyId = pa.association_companies_id
+    </select>
+
+    <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+       select
+            a.id      as  "id",
+            a.orderno  as  "orderno",
+            a.policyno  as  "policyno",
+            a.dept_id  as  "deptId",
+            a.riskcode  as  "riskcode",
+            a.pay_date  as  "payDate",
+            a.signdate  as  "signdate",
+            a.company_id  as  "companyId",
+            a.agreement_id  as  "agreementId",
+            a.licenseno  as  "licenseno",
+            a.taxamount  as  "taxamount",
+            a.no_tax_premium  as  "noTaxPremium",
+            a.commission_feerate  as  "commissionFeerate",
+            a.other_feerate  as  "otherFeerate",
+            a.commission_feevalue  as  "commissionFeevalue",
+            a.other_feevalue  as  "otherFeevalue",
+            a.all_fee_value  as  "allFeeValue",
+            a.final_fee_value  as  "finalFeeValue",
+            a.doing_fee_value  as  "doingFeeValue",
+            a.voucher_number  as  "voucherNumber",
+            a.contract_id  as  "contractId",
+            a.contract_file_id  as  "contractFileId",
+            a.handling_fees_status  as  "handlingFeesStatus",
+            a.no_policyno  as  "noPolicyno",
+            a.sy_policyno  as  "syPolicyno",
+            a.documentary_fees_status  as  "documentaryFeesStatus",
+            a.is_not_car  as  "isNotCar",
+            a.is_not_documentary  as  "isNotDocumentary",
+            a.create_time  as  "createTime"
+        from  ins_ply_income a
+        <where>
+            <if test="licenseno !=null  and  licenseno !=''">
+                a.licenseno=#{licenseno}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 1 - 23
src/main/resources/mapper/modules/fnc/SettlementDocumentaryFeesMapper.xml

@@ -13,6 +13,7 @@
         <result column="end_time" property="endTime"/>
         <result column="settlement_amount" property="settlementAmount"/>
         <result column="unsettled_amount" property="unsettledAmount"/>
+        <result column="company_id" property="companyId"/>
     </resultMap>
 
 
@@ -31,31 +32,8 @@
             from  settlement_documentary_fees  a
     </select>
 
-    <select id="selectAll" resultType="com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity">
-        select
-            *
-            from  settlement_documentary_fees  a
-    </select>
 
 
-    <select id="checkDate" resultType="com.ydtech.modules.fnc.entity.SettlementDocumentaryLogEntity">
-        select a.id                as "id",
-        a.total_orders      as "totalOrders",
-        a.time_frame        as "timeFrame",
-        a.total_amount      as "totalAmount",
-        a.create_time       as "createTime",
-        a.start_time        as "startTime",
-        a.end_time          as "endTime",
-        a.settlement_amount as "settlementAmount",
-        a.unsettled_amount  as "unsettledAmount"
-        from settlement_documentary_fees a
-        <where>
-            <if test="startDate !=null  and  startDate  !=''  and endDate !=null  and  endDate  !=''" >
-                (start_time &lt; #{endDate} AND start_time &gt; #{startDate}) OR (end_time &lt;  #{endDate} AND end_time &gt; #{startDate})
-            </if>
-        </where>
-    </select>
-
 
 
 </mapper>