Эх сурвалжийг харах

1. 结算删除 结算统计调整

wuhp 2 жил өмнө
parent
commit
381865ac9e

+ 0 - 2
src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java

@@ -308,9 +308,7 @@ public class InsPlyIncomeController extends BaseController {
     @DeleteMapping("/delete")
     @ApiModelProperty(value = "删除")
     public HttpResult<InsPlyIncome> deleteById(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
-
         return insPlyIncomeService.deleteById(insPlyIncomeVo);
-
     }
 
     @GetMapping("/getById/{id}")

+ 1 - 0
src/main/java/com/ydtech/modules/fnc/dao/ImportAsyncMapper.java

@@ -11,4 +11,5 @@ import java.util.List;
 public interface ImportAsyncMapper  extends BaseMapper<ImportResult> {
     List<ImportResult> queryNew(HashMap<String, Object> params);
 
+    List<ImportResult> selectByIncomeId(String incomeId);
 }

+ 2 - 0
src/main/java/com/ydtech/modules/fnc/service/ImportAsyncService.java

@@ -24,4 +24,6 @@ public interface ImportAsyncService   extends IService<ImportResult> {
 
     void bxImportNoData(List<InsBxNoPlyIncomeExcelDto> dtoList, MultipartFile multipartFile, String taskId);
 
+
+    List<ImportResult> selectByIncomeId(String incomeId);
 }

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

@@ -1,5 +1,6 @@
 package com.ydtech.modules.fnc.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;

+ 5 - 0
src/main/java/com/ydtech/modules/fnc/service/impl/ImportAsyncServiceImpl.java

@@ -563,4 +563,9 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
         endTask.setHandStatus("1");
         baseMapper.updateById(endTask);
     }
+
+    @Override
+    public List<ImportResult> selectByIncomeId(String incomeId) {
+        return   baseMapper.selectByIncomeId(incomeId);
+    }
 }

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

@@ -4,6 +4,8 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -18,6 +20,7 @@ import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.esm.model.EsmInsCompany;
 import com.ydtech.modules.esm.service.EsmInsCompanyService;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
+import com.ydtech.modules.fnc.dao.SettlementDocumentaryFeesMapper;
 import com.ydtech.modules.fnc.entity.*;
 import com.ydtech.modules.fnc.service.*;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
@@ -125,8 +128,6 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             e.printStackTrace();
             return HttpResult.error("查询异常");
         }
-
-
     }
 
     @Override
@@ -1211,28 +1212,33 @@ handlingProportion,
              noSuperviseCostsProportion));  //手续费比例 = 商业手续费比例 +  交强手续费比例 + 非车手续费比例
             if (jqSuperviseCostsProportion != null && jqPremium != null) {
                 insPlyIncome.setJqSuperviseCostsPremiums(this.algorithmAmount(jqPremium, jqSuperviseCostsProportion));  //交强手续费
+                insPlyIncome.setJqSuperviseCostsProportion(jqSuperviseCostsProportion);
+
             }
             if (sySuperviseCostsProportion != null && syPremium != null) {
                 insPlyIncome.setSySuperviseCostsPremiums(this.algorithmAmount(syPremium, sySuperviseCostsProportion)); //商业手续费
+                insPlyIncome.setSySuperviseCostsProportion(sySuperviseCostsProportion);
             }
             if (noSuperviseCostsProportion != null && noPremium != null) {
                 insPlyIncome.setNoSuperviseCostsPremiums(this.algorithmAmount(noPremium, noSuperviseCostsProportion));  //非车手续费
+                insPlyIncome.setNoSuperviseCostsProportion(noSuperviseCostsProportion);
             }
             if (jqOtherCostsProportion != null && jqPremium != null) {
                 insPlyIncome.setJqOtherCostsPremium(this.algorithmAmount(jqPremium, jqOtherCostsProportion));    //交强跟单费
+                insPlyIncome.setJqOtherCostsProportion(jqOtherCostsProportion);
             }
             if (syOtherCostsProportion != null && syPremium != null) {
                 insPlyIncome.setSyOtherCostsPremium(this.algorithmAmount(syPremium, syOtherCostsProportion));  //商业跟单费
+                insPlyIncome.setSyOtherCostsProportion(syOtherCostsProportion);
             }
             if (noOtherCostsProportion != null && noPremium != null) {
                 insPlyIncome.setNoOtherCostsPremium(this.algorithmAmount(noPremium, noOtherCostsProportion));   //非车跟单费
+                insPlyIncome.setNoOtherCostsProportion(noOtherCostsProportion);
             }
-            insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),
-             insPlyIncome.getSySuperviseCostsPremiums(), insPlyIncome.getNoSuperviseCostsPremiums())); //手续费
+            insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(), insPlyIncome.getSySuperviseCostsPremiums(), insPlyIncome.getNoSuperviseCostsPremiums())); //手续费
             insPlyIncome.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion, sySuperviseCostsProportion,
-             noSuperviseCostsProportion));  //手续费比例
-            insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),
-             insPlyIncome.getSyOtherCostsPremium(), insPlyIncome.getNoOtherCostsPremium()));  //跟单费金额
+                    noSuperviseCostsProportion));  //手续费比例
+            insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(), insPlyIncome.getSyOtherCostsPremium(), insPlyIncome.getNoOtherCostsPremium()));  //跟单费金额
             insPlyIncome.setOtherFeerate(this.calculateTotal(jqOtherCostsProportion, syOtherCostsProportion, noOtherCostsProportion));
             //跟单费比例
             insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), insPlyIncome.getOtherFeevalue(), null)); // 总费用 =  手续费+跟单费
@@ -1279,16 +1285,12 @@ handlingProportion,
             }
 
             if ("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())) {  //保险  手续费 =不含税保费* 手续费比例
-                insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),
-                 insPlyIncome.getSySuperviseCostsPremiums(), null)); // 手续费
-                insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(),
-                 insPlyIncome.getSySuperviseCostsProportion(), null));//手续费比例
+                insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(), insPlyIncome.getSySuperviseCostsPremiums(), null)); // 手续费
+                insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(), insPlyIncome.getSySuperviseCostsProportion(), null));//手续费比例
                 insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), null, null));//总金额
             } else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())) { //保险跟单费  交强跟单+商业跟单
-                insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),
-                 insPlyIncome.getSyOtherCostsPremium(), null));
-                insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(),
-                 insPlyIncome.getSyOtherCostsProportion(), null));
+                insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(), insPlyIncome.getSyOtherCostsPremium(), null));
+                insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(), insPlyIncome.getSyOtherCostsProportion(), null));
                 insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(), null, null));//总金额
             }
             if ("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())) {// 非车
@@ -1395,33 +1397,45 @@ handlingProportion,
         return HttpResult.ok();
     }
 
+    /**
+     *   删除id  已开票或者已结算都不可以进行 删除
+     *    因为跟单没有关联表 也无法关联到开票表所以只能按照 条件去查询判断 保司机构 id
+     * @param insPlyIncomeVo
+     * @return
+     */
     @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());
-        insPlyIncomeVo.setCrudStatus("3");
-        this.saveLog(insPlyIncomeVo);
-        List<InsPlyIncome> list = this.baseMapper.NonSettlementQuery(params);
-        if (!CollectionUtils.isEmpty(list)) {
-            for (InsPlyIncome item : list) {
-                return HttpResult.ok(item.getIds());
+        params.put("id",insPlyIncomeVo.getId());
+        List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
+        InsPlyIncome insPlyIncome = insPlyIncomes.get(0);
+        if (StringUtils.isNotEmpty(insPlyIncome.getAgreementType()) && "1".equals(insPlyIncome.getAgreementType())) {
+            if ("1".equals(insPlyIncome.getHandlingFeesStatus())) {
+                throw new SystemException("已结算不可以进行删除");
+            }
+        } else if (StringUtils.isNotEmpty(insPlyIncome.getAgreementType()) && "2".equals(insPlyIncome.getAgreementType())) {
+            if ("0".equals(insPlyIncome.getIsNotDocumentary())) {
+                String taskId = insPlyIncome.getTaskId();
+                if (StringUtils.isNotEmpty(taskId)) {
+                    throw new SystemException("已开票不能进行删除");
+                }
+            } else {
+//                因为跟单没有关联表 也无法关联到开票表所以只能按照 条件去进行判断
+                String partnerCompaniesId = insPlyIncome.getPartnerCompaniesId();   // 保司机构id
+                if (StringUtils.isEmpty(partnerCompaniesId)) {
+                    throw new SystemException("该单据没有保司机构id");
+                }
+                LambdaQueryWrapper<SettlementDocumentaryFeesEntity> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.eq(SettlementDocumentaryFeesEntity::getPartnerCompaniesId, partnerCompaniesId)
+                        .eq(SettlementDocumentaryFeesEntity::getSettlementStatus, "2");
+                List<SettlementDocumentaryFeesEntity> settlementDocumentaryFeesEntities = settlementDocumentaryFeesService.getBaseMapper().selectList(queryWrapper);
+                if (settlementDocumentaryFeesEntities.size() > 0) {
+                    throw new SystemException("已开票不能进行删除");
+                }
             }
-        } else {
-            return HttpResult.ok(null);
-
         }
+        baseMapper.deleteById(insPlyIncomeVo.getId());   //删除 结算  然后删除结算表
         return HttpResult.ok("删除成功");
 
     }
@@ -1569,7 +1583,7 @@ handlingProportion,
             BigDecimal noInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票金额
             BigDecimal unSettledAmount; //未结算金额
             params.put("partnerCompaniesId", item.getPartnerCompaniesId());
-
+            params.remove("handlingFeesStatus");
             List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);  //金额总数
             for (InsPlyIncome all : insPlyIncomes) {
                 commissionFeevalue = commissionFeevalue.add(all.getCommissionFeevalue());

+ 38 - 0
src/main/resources/mapper/modules/fnc/ImportAsyncMapper.xml

@@ -46,6 +46,44 @@
             <if test="createTime !=null  and  createTime  !=''">
              AND   DATE(a.create_time) =#{createTime}
             </if>
+            <if test="incomeId !=null  and  incomeId  !=''">
+             AND    a.income_id  =#{incomeId}
+            </if>
+        </where>
+        order  by  a.create_time  desc
+    </select>
+
+
+    <select id="selectByIncomeId" resultType="com.ydtech.modules.fnc.entity.ImportResult">
+        select
+        a.id as "id",
+        a.create_time as "createTime",
+        a.created_at as "createdAt",
+        a.completed_at as "completedAt",
+        a.status as "status",
+        a.total_amount as "totalAmount",
+        a.upload_url as "uploadUrl",
+        a.company_id as "companyId",
+        a.partner_companies_id as "partnerCompaniesId",
+        a.agreement_id as "agreementId",
+        a.ids as "ids",
+        a.hand_status as "handStatus",
+        a.hand_status as "handStatus",
+        a.income_id as "incomeId",
+        eic.namesimple as "partnerCompaniesName"
+        from
+        import_task  a
+        LEFT  JOIN  esm_ins_company  eic  on  eic.id  = a.partner_companies_id
+        <where>
+            <if test="handStatus !=null  and  handStatus  !=''">
+               a.hand_status =#{handStatus}
+            </if>
+            <if test="createTime !=null  and  createTime  !=''">
+             AND   DATE(a.create_time) =#{createTime}
+            </if>
+            <if test="incomeId !=null  and  incomeId  !=''">
+             AND    a.income_id  =#{incomeId}
+            </if>
         </where>
         order  by  a.create_time  desc
     </select>

+ 4 - 0
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -186,6 +186,10 @@
                 and a.handling_fees_status =#{handlingFeesStatus}
             </if>
 
+            <if test="id !=null  and  id  !=''">
+                and a.id =#{id}
+            </if>
+
             <if test="allPartnerCompaniesId !=null  and  allPartnerCompaniesId  !=''">
                 AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
             </if>