|
@@ -996,4 +996,178 @@ public class DailyImportSummaryLogic {
|
|
|
|
|
|
return commonMapper.repairSettleDailyincrDecrCostList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
|
|
|
}
|
|
|
+
|
|
|
+ public IPage<DailyReduceCostGatherVO> reduceTotalPage(ZfireParamBean zfireParamBean) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ FieldUtils.supplyParam(zfireParamBean, DailyReduceCostGatherVO.class, adminUser);
|
|
|
+
|
|
|
+ return commonMapper.reduceTotalList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ public IPage<DailyReduceCostVO> reducePage(ZfireParamBean zfireParamBean) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ FieldUtils.supplyParam(zfireParamBean, DailyReduceCostVO.class, adminUser);
|
|
|
+
|
|
|
+ return commonMapper.reduceList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void reduceListDelete(String importBatchNo) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+
|
|
|
+ if (adminUser.getType() == 2) {
|
|
|
+ throw new RemoteServiceException("平台账号禁止操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer count = settleDailyReduceCostService.lambdaQuery()
|
|
|
+ .eq(SettleDailyReduceCost::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .eq(SettleDailyReduceCost::getImportBatchNo, importBatchNo)
|
|
|
+ .eq(SettleDailyReduceCost::getDoStatus, DailyConstant.DO_STATUS_HAS)
|
|
|
+ .count();
|
|
|
+
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RemoteServiceException("存在已执行的数据,无法删除。");
|
|
|
+ }
|
|
|
+ settleDailyReduceCostService.lambdaUpdate()
|
|
|
+ .eq(SettleDailyReduceCost::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .eq(SettleDailyReduceCost::getImportBatchNo, importBatchNo)
|
|
|
+ .eq(SettleDailyReduceCost::getDoStatus, DailyConstant.DO_STATUS_NOT)
|
|
|
+ .remove();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void reduceItemDelete(List<Integer> ids) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+
|
|
|
+ if (adminUser.getType() == 2) {
|
|
|
+ throw new RemoteServiceException("平台账号禁止操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer count = settleDailyReduceCostService.lambdaQuery()
|
|
|
+ .eq(SettleDailyReduceCost::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .in(SettleDailyReduceCost::getId, ids)
|
|
|
+ .eq(SettleDailyReduceCost::getDoStatus, DailyConstant.DO_STATUS_HAS)
|
|
|
+ .count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RemoteServiceException("存在已执行的数据,无法删除。");
|
|
|
+ }
|
|
|
+ settleDailyReduceCostService.lambdaUpdate()
|
|
|
+ .eq(SettleDailyReduceCost::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .in(SettleDailyReduceCost::getId, ids)
|
|
|
+ .eq(SettleDailyReduceCost::getDoStatus, DailyConstant.DO_STATUS_NOT)
|
|
|
+ .remove();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void reduceListDo(String importBatchNo) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+
|
|
|
+ if (adminUser.getType() == 2) {
|
|
|
+ throw new RemoteServiceException("平台账号禁止操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ String opName = adminUser.getNickName();
|
|
|
+
|
|
|
+ List<SettleDailyReduceCost> reduceList = settleDailyReduceCostService.lambdaQuery()
|
|
|
+ .eq(SettleDailyReduceCost::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .eq(SettleDailyReduceCost::getImportBatchNo, importBatchNo)
|
|
|
+ .eq(SettleDailyReduceCost::getDoStatus, DailyConstant.DO_STATUS_NOT).list();
|
|
|
+
|
|
|
+ if (reduceList.size() == 0) {
|
|
|
+ throw new RemoteServiceException("暂无可扣回的数据");
|
|
|
+ }
|
|
|
+ summaryReduce(reduceList, opName, importBatchNo, null, adminUser);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void summaryReduce(List<SettleDailyReduceCost> reduceList, String opName, String importBatchNo, List<Integer> ids, AdminUserCom adminUser) {
|
|
|
+ String doBatchNo = commonLogic.generateNo("ZX", "dailyDoBatch", 13);
|
|
|
+ List<SettleDailyIssueSummaryRecord> records = new ArrayList<>();
|
|
|
+// List<String> serviceNumberList = new ArrayList<>();
|
|
|
+// List<String> websiteNumberList = new ArrayList<>();
|
|
|
+ List<SettleDailyReduceCost> reduceUpdateList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (SettleDailyReduceCost bean : reduceList) {
|
|
|
+ SettleDailyIssueSummaryRecord issueRecord = settleDailyIssueSummaryRecordService.getOne(
|
|
|
+ Wrappers.<SettleDailyIssueSummaryRecord>lambdaQuery()
|
|
|
+ .eq(SettleDailyIssueSummaryRecord::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
|
|
|
+ .eq(SettleDailyIssueSummaryRecord::getStatus, DailyConstant.ISSUE_STATUS_NOT)
|
|
|
+ .eq(SettleDailyIssueSummaryRecord::getServiceNumber, bean.getWorkerNumber())
|
|
|
+ .eq(SettleDailyIssueSummaryRecord::getWebsitNumber, bean.getWebsitNumber())
|
|
|
+ .orderByDesc(SettleDailyIssueSummaryRecord::getIssueCost)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (issueRecord != null) {
|
|
|
+ BigDecimal reduceCost = new BigDecimal(0);
|
|
|
+ if (issueRecord.getShouldReduceCost() != null) {
|
|
|
+ reduceCost = reduceCost.add(issueRecord.getShouldReduceCost());
|
|
|
+ }
|
|
|
+ reduceCost = reduceCost.add(bean.getTotalFee());
|
|
|
+ BigDecimal subAmount = issueRecord.getIssueCost().subtract(reduceCost);
|
|
|
+ issueRecord.setShouldReduceCost(reduceCost);
|
|
|
+ issueRecord.setReduceCost(new BigDecimal(0));
|
|
|
+ issueRecord.setUpdateBy(opName);
|
|
|
+ issueRecord.setUpdateTime(new Date());
|
|
|
+ bean.setDoBatchNo(doBatchNo);
|
|
|
+ bean.setReduceDate(new Date());
|
|
|
+ bean.setDoTime(new Date());
|
|
|
+ bean.setDoBy(opName);
|
|
|
+ bean.setIssueSalaryId(issueRecord.getId());
|
|
|
+ bean.setDoStatus(DailyConstant.DO_STATUS_HAS);
|
|
|
+ bean.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
|
|
|
+ bean.setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName());
|
|
|
+ reduceUpdateList.add(bean);
|
|
|
+
|
|
|
+ if (subAmount.doubleValue() < 0) {
|
|
|
+ //不够扣的处理
|
|
|
+ saveRemaineBuckle(subAmount, DictCodeEnum.REDUCE_DAILY.toString(), bean.getWorkerNumber(),
|
|
|
+ bean.getSummaryNumber(), bean.getWebsitName(), bean.getWebsitNumber(), opName);
|
|
|
+ //设置为0
|
|
|
+ issueRecord.setReduceCost(issueRecord.getIssueCost());
|
|
|
+ issueRecord.setIssueCost(BigDecimal.valueOf(0));
|
|
|
+ } else {
|
|
|
+ //够扣的处理
|
|
|
+ issueRecord.setReduceCost(reduceCost);
|
|
|
+ issueRecord.setIssueCost(subAmount);
|
|
|
+ }
|
|
|
+ records.add(issueRecord);
|
|
|
+// serviceNumberList.add(bean.getWorkerNumber());
|
|
|
+// websiteNumberList.add(bean.getWebsitNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (records.size() == 0) {
|
|
|
+ throw new RemoteServiceException("暂无可扣回的数据");
|
|
|
+ }
|
|
|
+ settleDailyIssueSummaryRecordService.updateBatchById(records);
|
|
|
+ settleDailyReduceCostService.updateBatchById(reduceUpdateList);
|
|
|
+// dailyReduceCostService.lambdaUpdate()
|
|
|
+// .set(DailyReduceCost::getDoBatchNo, doBatchNo)
|
|
|
+// .set(DailyReduceCost::getReduceDate, new Date())
|
|
|
+// .set(DailyReduceCost::getDoTime, new Date())
|
|
|
+// .set(DailyReduceCost::getDoBy, opName)
|
|
|
+// .set(DailyReduceCost::getDoStatus, DailyConstant.DO_STATUS_HAS)
|
|
|
+// .eq(StringUtils.isNotEmpty(importBatchNo), DailyReduceCost::getImportBatchNo, importBatchNo)
|
|
|
+// .in(ids != null, DailyReduceCost::getId, ids)
|
|
|
+// .in(DailyReduceCost::getWebsitNumber, websiteNumberList)
|
|
|
+// .in(DailyReduceCost::getWorkerNumber, serviceNumberList)
|
|
|
+// .eq(DailyReduceCost::getDoStatus, DailyConstant.DO_STATUS_NOT).update();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void reduceItemDo(List<Integer> ids) {
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+
|
|
|
+ if (adminUser.getType() == 2) {
|
|
|
+ throw new RemoteServiceException("平台账号禁止操作");
|
|
|
+ }
|
|
|
+ String opName = adminUser.getNickName();
|
|
|
+ List<SettleDailyReduceCost> reduceList = settleDailyReduceCostService.lambdaQuery()
|
|
|
+ .in(SettleDailyReduceCost::getId, ids)
|
|
|
+ .eq(SettleDailyReduceCost::getDoStatus, DailyConstant.DO_STATUS_NOT).list();
|
|
|
+
|
|
|
+ if (reduceList.size() == 0) {
|
|
|
+ throw new RemoteServiceException("暂无可扣回的数据");
|
|
|
+ }
|
|
|
+ summaryReduce(reduceList, opName, null, ids, adminUser);
|
|
|
+ }
|
|
|
}
|