FengChaoYu il y a 5 mois
Parent
commit
8db12b3dbe

+ 11 - 7
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminUserLogic.java

@@ -174,7 +174,6 @@ public class AdminUserLogic {
                         .count();
                 // 没有签成功并且审核通过未过期的记录,进行下一步检查
                 if (existCount == 0) {
-                    adminUserCom.setIsJumpSign(true);
                     // 查询是否有状态为待签约或待审核的
                     existCount = websitContractSignRecordService.lambdaQuery()
                             .eq(WebsitContractSignRecord::getWebsitId, websit.getWebsitId())
@@ -185,10 +184,11 @@ public class AdminUserLogic {
                     if (existCount == 0) {
                         List<ContractTemplate> contractList = commonMapper.queryNeedContract(adminUser.getCompanyWechatId(), websit.getWebsitId(), DateUtil.date());
                         if (CollectionUtil.isEmpty(contractList)) {
-                            adminUserCom.setContractSignInfo("未发现网点需要签约合同,请联系管理员处理");
+//                            adminUserCom.setContractSignInfo("未发现网点需要签约合同,请联系管理员处理");
                         } else if (CollectionUtil.isNotEmpty(contractList) && contractList.size() > 1) {
                             adminUserCom.setContractSignInfo("发现网点需要签约合同多份,请联系管理员处理");
                         } else {
+                            adminUserCom.setIsJumpSign(true);
                             final WebsitFollowConfigItem item = websitFollowConfigItemService.lambdaQuery()
                                     .eq(WebsitFollowConfigItem::getCompanyWechatId, websit.getCompanyWechatId())
                                     .eq(WebsitFollowConfigItem::getSubWebsitId, websit.getWebsitId())
@@ -974,12 +974,16 @@ public class AdminUserLogic {
                             .count();
                     // 没有签成功并且审核通过未过期的记录,只有签约菜单
                     if (existCount == 0 && CollectionUtil.isNotEmpty(trees)) {
-                        List<AdminModuleTree> filterTree = trees.stream().filter(v -> v.getLevel() == 1 && v.getNotSign()).collect(Collectors.toList());
-                        if (CollectionUtil.isNotEmpty(filterTree)) {
-                            for (AdminModuleTree moduleTree : filterTree) {
-                                moduleTree.setChildren(this.treeModule(trees, moduleTree.getModuleId(), hasModule, admin, true));
+                        // 是否有需要签约的合同
+                        List<ContractTemplate> contractList = commonMapper.queryNeedContract(adminUser.getCompanyWechatId(), websit.getWebsitId(), DateUtil.date());
+                        if (CollectionUtil.isNotEmpty(contractList)) {
+                            List<AdminModuleTree> filterTree = trees.stream().filter(v -> v.getLevel() == 1 && v.getNotSign()).collect(Collectors.toList());
+                            if (CollectionUtil.isNotEmpty(filterTree)) {
+                                for (AdminModuleTree moduleTree : filterTree) {
+                                    moduleTree.setChildren(this.treeModule(trees, moduleTree.getModuleId(), hasModule, admin, true));
+                                }
+                                return filterTree;
                             }
-                            return filterTree;
                         }
                     }
                 }

+ 143 - 135
mall-server-api/src/main/java/com/gree/mall/manager/logic/settle/WorkerSettleExpenseLogic.java

@@ -709,99 +709,40 @@ public class WorkerSettleExpenseLogic {
         }
 
 
-        final List<SettleExpense> expenseList = settleExpenseService.lambdaQuery()
+        final List<SettleExpense> expenseAllList = settleExpenseService.lambdaQuery()
                 .eq(SettleExpense::getCompanyWechatId, companyWechatId)
                 .in(SettleExpense::getId, bean.getIds())
                 .in(SettleExpense::getStatus, SettleExpenseStatusEnum.NO.getKey(), SettleExpenseStatusEnum.NOT.getKey())
                 .list();
 
-        final List<String> ids = expenseList.stream().map(SettleExpense::getId).collect(Collectors.toList());
+        // 按网点分组汇总
+        final Map<String, List<SettleExpense>> websitMap = expenseAllList.stream().collect(Collectors.groupingBy(SettleExpense::getWebsitId));
 
-        final List<SettleExpenseItem> expenseItemList = settleExpenseItemService.lambdaQuery()
-                .eq(SettleExpenseItem::getCompanyWechatId, companyWechatId)
-                .in(SettleExpenseItem::getSettleExpenseId, ids)
-                .list();
+        for (Map.Entry<String, List<SettleExpense>> websitEntry : websitMap.entrySet()) {
+            List<SettleExpense> expenseList = websitEntry.getValue();
 
-        String settleMonthWagesId = IdWorker.getIdStr();
-        List<SettleMonthWagesWorker> wagesWorker1List = new ArrayList<>();
-        // 师傅1分组
-        final Map<String, List<SettleExpenseItem>> worker1GroupMap = expenseItemList.stream()
-                .collect(Collectors.groupingBy(SettleExpenseItem::getWorkerName1));
-
-        // 师傅2分组
-        final Map<String, List<SettleExpenseItem>> worker2GroupMap = expenseItemList.stream()
-                .filter(v ->
-                        StringUtils.isNotBlank(v.getWorkerName2())
-                                && Objects.nonNull(v.getWorkerSettleAmount2())
-                                && v.getWorkerSettleAmount2().compareTo(BigDecimal.ZERO) > 0
-                ).collect(Collectors.groupingBy(SettleExpenseItem::getWorkerName2));
-
-        for (Map.Entry<String, List<SettleExpenseItem>> entry : worker1GroupMap.entrySet()) {
-            BigDecimal installAmount = BigDecimal.ZERO;
-            BigDecimal installHomeAmount = BigDecimal.ZERO;
-            BigDecimal installOtherAmount = BigDecimal.ZERO;
-            BigDecimal repairAmount = BigDecimal.ZERO;
-            BigDecimal otherAmount = BigDecimal.ZERO;
-            int installHomeCount = 0;
-            int installOtherCount = 0;
-            int repairCount = 0;
-            int otherCount = 0;
-            if (CollectionUtil.isNotEmpty(worker2GroupMap) && worker2GroupMap.containsKey(entry.getKey())) {
-                // 师傅2分组里存在师傅1分组的师傅名称,合并到师傅1分组处理
-                entry.getValue().addAll(worker2GroupMap.get(entry.getKey()));
-                worker2GroupMap.remove(entry.getKey());
-            }
-            for (SettleExpenseItem expenseItem : entry.getValue()) {
-                if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())
-                        || expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey()) ) {
-                    installAmount = installAmount.add(expenseItem.getWorkerSettleAmount1());
-                    if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())) {
-                        installHomeAmount = installHomeAmount.add(expenseItem.getWorkerSettleAmount1());
-                        installHomeCount++;
-                    }
-                    if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey())) {
-                        installOtherAmount = installOtherAmount.add(expenseItem.getWorkerSettleAmount1());
-                        installOtherCount++;
-                    }
-                }
-                if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.REPAIR.getKey()) ) {
-                    repairAmount = repairAmount.add(expenseItem.getWorkerSettleAmount1());
-                    repairCount++;
-                }
-                if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.OTHER.getKey()) ) {
-                    otherAmount = otherAmount.add(expenseItem.getWorkerSettleAmount1());
-                    otherCount++;
-                }
-            }
-            if (installAmount.compareTo(BigDecimal.ZERO) == 0
-                    && repairAmount.compareTo(BigDecimal.ZERO) == 0
-                    && otherAmount.compareTo(BigDecimal.ZERO) == 0) {
-                // 三大结算费用都为0忽略此师傅
-                continue;
-            }
-            SettleMonthWagesWorker wagesWorker = new SettleMonthWagesWorker();
-            wagesWorker.setSettleMonthWagesId(settleMonthWagesId)
-                    .setCompanyWechatId(companyWechatId)
-                    .setCompanyWechatName(companyWechatName)
-                    .setWorkerId(entry.getValue().get(0).getWorkerId1())
-                    .setWorkerName(entry.getValue().get(0).getWorkerName1())
-                    .setWorkerMobile(entry.getValue().get(0).getWorkerMobile1())
-                    .setInstallAmount(installAmount)
-                    .setRepairAmount(repairAmount)
-                    .setOtherAmount(otherAmount)
-                    .setSettleAmount(installAmount.add(repairAmount).add(otherAmount))
-                    .setInstallHomeAmount(installHomeAmount)
-                    .setInstallOtherAmount(installOtherAmount)
-                    .setInstallHomeCount(installHomeCount)
-                    .setInstallOtherCount(installOtherCount)
-                    .setRepairCount(repairCount)
-                    .setOtherCount(otherCount);
-            wagesWorker1List.add(wagesWorker);
-        }
+            final List<String> ids = expenseList.stream().map(SettleExpense::getId).collect(Collectors.toList());
 
-        // 剩余师傅2分组
-        if (CollectionUtil.isNotEmpty(worker2GroupMap)) {
-            for (Map.Entry<String, List<SettleExpenseItem>> entry : worker2GroupMap.entrySet()) {
+            final List<SettleExpenseItem> expenseItemList = settleExpenseItemService.lambdaQuery()
+                    .eq(SettleExpenseItem::getCompanyWechatId, companyWechatId)
+                    .in(SettleExpenseItem::getSettleExpenseId, ids)
+                    .list();
+
+            String settleMonthWagesId = IdWorker.getIdStr();
+            List<SettleMonthWagesWorker> wagesWorker1List = new ArrayList<>();
+            // 师傅1分组
+            final Map<String, List<SettleExpenseItem>> worker1GroupMap = expenseItemList.stream()
+                    .collect(Collectors.groupingBy(SettleExpenseItem::getWorkerName1));
+
+            // 师傅2分组
+            final Map<String, List<SettleExpenseItem>> worker2GroupMap = expenseItemList.stream()
+                    .filter(v ->
+                            StringUtils.isNotBlank(v.getWorkerName2())
+                                    && Objects.nonNull(v.getWorkerSettleAmount2())
+                                    && v.getWorkerSettleAmount2().compareTo(BigDecimal.ZERO) > 0
+                    ).collect(Collectors.groupingBy(SettleExpenseItem::getWorkerName2));
+
+            for (Map.Entry<String, List<SettleExpenseItem>> entry : worker1GroupMap.entrySet()) {
                 BigDecimal installAmount = BigDecimal.ZERO;
                 BigDecimal installHomeAmount = BigDecimal.ZERO;
                 BigDecimal installOtherAmount = BigDecimal.ZERO;
@@ -811,37 +752,46 @@ public class WorkerSettleExpenseLogic {
                 int installOtherCount = 0;
                 int repairCount = 0;
                 int otherCount = 0;
+                if (CollectionUtil.isNotEmpty(worker2GroupMap) && worker2GroupMap.containsKey(entry.getKey())) {
+                    // 师傅2分组里存在师傅1分组的师傅名称,合并到师傅1分组处理
+                    entry.getValue().addAll(worker2GroupMap.get(entry.getKey()));
+                    worker2GroupMap.remove(entry.getKey());
+                }
                 for (SettleExpenseItem expenseItem : entry.getValue()) {
                     if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())
                             || expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey()) ) {
-                        installAmount = installAmount.add(expenseItem.getWorkerSettleAmount2());
+                        installAmount = installAmount.add(expenseItem.getWorkerSettleAmount1());
                         if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())) {
-                            installHomeAmount = installHomeAmount.add(expenseItem.getWorkerSettleAmount2());
+                            installHomeAmount = installHomeAmount.add(expenseItem.getWorkerSettleAmount1());
                             installHomeCount++;
                         }
                         if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey())) {
-                            installOtherAmount = installOtherAmount.add(expenseItem.getWorkerSettleAmount2());
+                            installOtherAmount = installOtherAmount.add(expenseItem.getWorkerSettleAmount1());
                             installOtherCount++;
                         }
                     }
                     if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.REPAIR.getKey()) ) {
-                        repairAmount = repairAmount.add(expenseItem.getWorkerSettleAmount2());
+                        repairAmount = repairAmount.add(expenseItem.getWorkerSettleAmount1());
                         repairCount++;
                     }
                     if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.OTHER.getKey()) ) {
-                        otherAmount = otherAmount.add(expenseItem.getWorkerSettleAmount2());
+                        otherAmount = otherAmount.add(expenseItem.getWorkerSettleAmount1());
                         otherCount++;
                     }
                 }
-
-                // 师傅id添加对象
+                if (installAmount.compareTo(BigDecimal.ZERO) == 0
+                        && repairAmount.compareTo(BigDecimal.ZERO) == 0
+                        && otherAmount.compareTo(BigDecimal.ZERO) == 0) {
+                    // 三大结算费用都为0忽略此师傅
+                    continue;
+                }
                 SettleMonthWagesWorker wagesWorker = new SettleMonthWagesWorker();
                 wagesWorker.setSettleMonthWagesId(settleMonthWagesId)
                         .setCompanyWechatId(companyWechatId)
                         .setCompanyWechatName(companyWechatName)
-                        .setWorkerId(entry.getValue().get(0).getWorkerId2())
-                        .setWorkerName(entry.getValue().get(0).getWorkerName2())
-                        .setWorkerMobile(entry.getValue().get(0).getWorkerMobile2())
+                        .setWorkerId(entry.getValue().get(0).getWorkerId1())
+                        .setWorkerName(entry.getValue().get(0).getWorkerName1())
+                        .setWorkerMobile(entry.getValue().get(0).getWorkerMobile1())
                         .setInstallAmount(installAmount)
                         .setRepairAmount(repairAmount)
                         .setOtherAmount(otherAmount)
@@ -852,51 +802,109 @@ public class WorkerSettleExpenseLogic {
                         .setInstallOtherCount(installOtherCount)
                         .setRepairCount(repairCount)
                         .setOtherCount(otherCount);
-
                 wagesWorker1List.add(wagesWorker);
             }
-        }
 
-        int byCount = wagesWorker1List.size();
-        BigDecimal settleAmount = BigDecimal.ZERO;
-        for (SettleMonthWagesWorker wagesWorker : wagesWorker1List) {
-            settleAmount = settleAmount.add(wagesWorker.getSettleAmount());
-            wagesWorker.setName(bean.getName());
-        }
+            // 剩余师傅2分组
+            if (CollectionUtil.isNotEmpty(worker2GroupMap)) {
+                for (Map.Entry<String, List<SettleExpenseItem>> entry : worker2GroupMap.entrySet()) {
+                    BigDecimal installAmount = BigDecimal.ZERO;
+                    BigDecimal installHomeAmount = BigDecimal.ZERO;
+                    BigDecimal installOtherAmount = BigDecimal.ZERO;
+                    BigDecimal repairAmount = BigDecimal.ZERO;
+                    BigDecimal otherAmount = BigDecimal.ZERO;
+                    int installHomeCount = 0;
+                    int installOtherCount = 0;
+                    int repairCount = 0;
+                    int otherCount = 0;
+                    for (SettleExpenseItem expenseItem : entry.getValue()) {
+                        if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())
+                                || expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey()) ) {
+                            installAmount = installAmount.add(expenseItem.getWorkerSettleAmount2());
+                            if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_HOME.getKey())) {
+                                installHomeAmount = installHomeAmount.add(expenseItem.getWorkerSettleAmount2());
+                                installHomeCount++;
+                            }
+                            if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.INSTALL_OTHER.getKey())) {
+                                installOtherAmount = installOtherAmount.add(expenseItem.getWorkerSettleAmount2());
+                                installOtherCount++;
+                            }
+                        }
+                        if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.REPAIR.getKey()) ) {
+                            repairAmount = repairAmount.add(expenseItem.getWorkerSettleAmount2());
+                            repairCount++;
+                        }
+                        if (expenseItem.getCategoryType().equals(SettleCategoryTypEnum.OTHER.getKey()) ) {
+                            otherAmount = otherAmount.add(expenseItem.getWorkerSettleAmount2());
+                            otherCount++;
+                        }
+                    }
 
-        SettleMonthWages wages = new SettleMonthWages();
-        wages.setId(settleMonthWagesId);
-        wages.setCompanyWechatId(companyWechatId);
-        wages.setCompanyWechatName(companyWechatName);
-        wages.setName(bean.getName());
-        wages.setSettleByCount(byCount);
-        wages.setSettleAmount(settleAmount);
-        wages.setWaitByCount(byCount);
-        wages.setWaitAmount(settleAmount);
-        wages.setStatus(SettleWagesStatusEnum.NOT.getKey());
-        wages.insert();
-
-        // 保存汇总明细
-        settleMonthWagesWorkerService.saveBatch(wagesWorker1List);
-
-        // 填充师傅结算汇总
-        settleExpenseService.lambdaUpdate()
-                .set(SettleExpense::getRejectBy, null)
-                .set(SettleExpense::getRejectTime, null)
-                .set(SettleExpense::getName, wages.getName())
-                .set(SettleExpense::getGatherBatchNo, wages.getId())
-                .set(SettleExpense::getGatherBy, wages.getCreateBy())
-                .set(SettleExpense::getGatherTime, wages.getCreateTime())
-                .set(SettleExpense::getStatus, SettleExpenseStatusEnum.YES.getKey())
-                .eq(SettleExpense::getCompanyWechatId, companyWechatId)
-                .in(SettleExpense::getId, ids)
-                .update();
+                    // 师傅id添加对象
+                    SettleMonthWagesWorker wagesWorker = new SettleMonthWagesWorker();
+                    wagesWorker.setSettleMonthWagesId(settleMonthWagesId)
+                            .setCompanyWechatId(companyWechatId)
+                            .setCompanyWechatName(companyWechatName)
+                            .setWorkerId(entry.getValue().get(0).getWorkerId2())
+                            .setWorkerName(entry.getValue().get(0).getWorkerName2())
+                            .setWorkerMobile(entry.getValue().get(0).getWorkerMobile2())
+                            .setInstallAmount(installAmount)
+                            .setRepairAmount(repairAmount)
+                            .setOtherAmount(otherAmount)
+                            .setSettleAmount(installAmount.add(repairAmount).add(otherAmount))
+                            .setInstallHomeAmount(installHomeAmount)
+                            .setInstallOtherAmount(installOtherAmount)
+                            .setInstallHomeCount(installHomeCount)
+                            .setInstallOtherCount(installOtherCount)
+                            .setRepairCount(repairCount)
+                            .setOtherCount(otherCount);
+
+                    wagesWorker1List.add(wagesWorker);
+                }
+            }
+
+            int byCount = wagesWorker1List.size();
+            BigDecimal settleAmount = BigDecimal.ZERO;
+            for (SettleMonthWagesWorker wagesWorker : wagesWorker1List) {
+                settleAmount = settleAmount.add(wagesWorker.getSettleAmount());
+                wagesWorker.setName(bean.getName());
+            }
+
+            SettleMonthWages wages = new SettleMonthWages();
+            wages.setId(settleMonthWagesId);
+            wages.setCompanyWechatId(companyWechatId);
+            wages.setCompanyWechatName(companyWechatName);
+            wages.setName(bean.getName());
+            wages.setSettleByCount(byCount);
+            wages.setSettleAmount(settleAmount);
+            wages.setWaitByCount(byCount);
+            wages.setWaitAmount(settleAmount);
+            wages.setStatus(SettleWagesStatusEnum.NOT.getKey());
+            wages.insert();
+
+            // 保存汇总明细
+            settleMonthWagesWorkerService.saveBatch(wagesWorker1List);
+
+            // 填充师傅结算汇总
+            settleExpenseService.lambdaUpdate()
+                    .set(SettleExpense::getRejectBy, null)
+                    .set(SettleExpense::getRejectTime, null)
+                    .set(SettleExpense::getName, wages.getName())
+                    .set(SettleExpense::getGatherBatchNo, wages.getId())
+                    .set(SettleExpense::getGatherBy, wages.getCreateBy())
+                    .set(SettleExpense::getGatherTime, wages.getCreateTime())
+                    .set(SettleExpense::getStatus, SettleExpenseStatusEnum.YES.getKey())
+                    .eq(SettleExpense::getCompanyWechatId, companyWechatId)
+                    .in(SettleExpense::getId, ids)
+                    .update();
+
+            settleExpenseItemService.lambdaUpdate()
+                    .set(SettleExpenseItem::getSettleMonthWagesId, wages.getId())
+                    .eq(SettleExpenseItem::getCompanyWechatId, companyWechatId)
+                    .in(SettleExpenseItem::getSettleExpenseId, ids)
+                    .update();
+        }
 
-        settleExpenseItemService.lambdaUpdate()
-                .set(SettleExpenseItem::getSettleMonthWagesId, wages.getId())
-                .eq(SettleExpenseItem::getCompanyWechatId, companyWechatId)
-                .in(SettleExpenseItem::getSettleExpenseId, ids)
-                .update();
     }
 
     public DataBoardBean dataBoard() {

+ 6 - 0
mall-server-api/src/main/resources/mapper/CommonMapper.xml

@@ -916,6 +916,12 @@
         ${ex.selected}
         FROM settle_month_wages a
         ${ex.query}
+        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
+            AND a.websit_id IN
+            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         <if test="ex.orderBy == null or ex.orderBy ==''">
             ORDER BY a.create_time DESC
         </if>