|
@@ -9,10 +9,12 @@ import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
import com.fjhx.common.entity.logistics.dto.LogisticsEndingAmountSelectDto;
|
|
import com.fjhx.common.entity.logistics.dto.LogisticsEndingAmountSelectDto;
|
|
|
|
+import com.fjhx.common.entity.logistics.po.LogisticsAmount;
|
|
import com.fjhx.common.entity.logistics.po.LogisticsCompanyInfo;
|
|
import com.fjhx.common.entity.logistics.po.LogisticsCompanyInfo;
|
|
import com.fjhx.common.entity.logistics.po.LogisticsEndingAmount;
|
|
import com.fjhx.common.entity.logistics.po.LogisticsEndingAmount;
|
|
import com.fjhx.common.entity.logistics.vo.LogisticsEndingAmountVo;
|
|
import com.fjhx.common.entity.logistics.vo.LogisticsEndingAmountVo;
|
|
import com.fjhx.common.mapper.logistics.LogisticsEndingAmountMapper;
|
|
import com.fjhx.common.mapper.logistics.LogisticsEndingAmountMapper;
|
|
|
|
+import com.fjhx.common.service.logistics.LogisticsAmountService;
|
|
import com.fjhx.common.service.logistics.LogisticsCompanyInfoService;
|
|
import com.fjhx.common.service.logistics.LogisticsCompanyInfoService;
|
|
import com.fjhx.common.service.logistics.LogisticsEndingAmountService;
|
|
import com.fjhx.common.service.logistics.LogisticsEndingAmountService;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
@@ -42,6 +44,8 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private LogisticsCompanyInfoService logisticsCompanyInfoService;
|
|
private LogisticsCompanyInfoService logisticsCompanyInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private LogisticsAmountService logisticsAmountService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 每月1日0点1分 赋值上月期末余额
|
|
* 每月1日0点1分 赋值上月期末余额
|
|
@@ -83,6 +87,14 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
|
|
}
|
|
}
|
|
one.setEndingBalance(endingBalance);
|
|
one.setEndingBalance(endingBalance);
|
|
|
|
|
|
|
|
+ //期末应付余额
|
|
|
|
+ BigDecimal endingPayableBalance = logisticsEndingAmountVo.getEndingPayableBalance();
|
|
|
|
+ if (ObjectUtil.isEmpty(endingPayableBalance)) {
|
|
|
|
+ endingPayableBalance = BigDecimal.ZERO;
|
|
|
|
+ }
|
|
|
|
+ one.setEndingPayableBalance(endingPayableBalance);
|
|
|
|
+
|
|
|
|
+
|
|
this.saveOrUpdate(one);
|
|
this.saveOrUpdate(one);
|
|
}
|
|
}
|
|
SecurityUtils.clearTenantId();
|
|
SecurityUtils.clearTenantId();
|
|
@@ -98,47 +110,77 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
|
|
dto.setYear(DateUtil.year(new Date()));
|
|
dto.setYear(DateUtil.year(new Date()));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //费控 预付、付款 信息
|
|
List<LogisticsEndingAmountVo> logisticsRechargeSummaryBos = baseMapper.logisticsRechargeSummary(dto);
|
|
List<LogisticsEndingAmountVo> logisticsRechargeSummaryBos = baseMapper.logisticsRechargeSummary(dto);
|
|
Map<Long, List<LogisticsEndingAmountVo>> logisticsRechargeMap = logisticsRechargeSummaryBos.stream()
|
|
Map<Long, List<LogisticsEndingAmountVo>> logisticsRechargeMap = logisticsRechargeSummaryBos.stream()
|
|
.collect(Collectors.groupingBy(LogisticsEndingAmountVo::getLogisticsCompanyId));
|
|
.collect(Collectors.groupingBy(LogisticsEndingAmountVo::getLogisticsCompanyId));
|
|
|
|
|
|
- List<LogisticsCompanyInfo> list = logisticsCompanyInfoService.list();
|
|
|
|
-
|
|
|
|
|
|
+ //快递公司 每月发生额
|
|
|
|
+ Map<Long, LogisticsAmount> logisticsAmountMap = logisticsAmountService.mapKEntity(LogisticsAmount::getLogisticsCompanyId, q -> q.eq(LogisticsAmount::getYear, dto.getYear()));
|
|
|
|
|
|
|
|
+ //遍历物流公司
|
|
|
|
+ List<LogisticsCompanyInfo> list = logisticsCompanyInfoService.list();
|
|
for (LogisticsCompanyInfo logisticsCompanyInfo : list) {
|
|
for (LogisticsCompanyInfo logisticsCompanyInfo : list) {
|
|
JSONObject logisticsCompanyInfoJson = JSONObject.parseObject(JSONObject.toJSONString(logisticsCompanyInfo));
|
|
JSONObject logisticsCompanyInfoJson = JSONObject.parseObject(JSONObject.toJSONString(logisticsCompanyInfo));
|
|
- //赋值年初余额
|
|
|
|
|
|
+ //赋值年初余额,年初应付
|
|
BigDecimal yearBeginBalance = BigDecimal.ZERO;
|
|
BigDecimal yearBeginBalance = BigDecimal.ZERO;
|
|
- String lastYearEndMonth = StrUtil.format("{}-12", dto.getYear() - 1);
|
|
|
|
|
|
+ BigDecimal yearBeginPayableBalance = BigDecimal.ZERO;
|
|
|
|
+
|
|
|
|
+ String lastYearEndMonth = StrUtil.format("{}-12", (dto.getYear() - 1));
|
|
LogisticsEndingAmount lastYearEndAmount = this.getOne(q -> q
|
|
LogisticsEndingAmount lastYearEndAmount = this.getOne(q -> q
|
|
.eq(LogisticsEndingAmount::getLogisticsCompanyId, logisticsCompanyInfo.getId())
|
|
.eq(LogisticsEndingAmount::getLogisticsCompanyId, logisticsCompanyInfo.getId())
|
|
.apply("DATE_FORMAT(account_date,'%Y-%m') = DATE_FORMAT( {0}, '%Y-%m' )", DateUtil.parse(lastYearEndMonth, "yyyy-MM"))
|
|
.apply("DATE_FORMAT(account_date,'%Y-%m') = DATE_FORMAT( {0}, '%Y-%m' )", DateUtil.parse(lastYearEndMonth, "yyyy-MM"))
|
|
);
|
|
);
|
|
if (ObjectUtil.isNotEmpty(lastYearEndAmount)) {
|
|
if (ObjectUtil.isNotEmpty(lastYearEndAmount)) {
|
|
yearBeginBalance = lastYearEndAmount.getEndingBalance();
|
|
yearBeginBalance = lastYearEndAmount.getEndingBalance();
|
|
|
|
+ yearBeginPayableBalance = lastYearEndAmount.getEndingPayableBalance();
|
|
}
|
|
}
|
|
logisticsCompanyInfoJson.put("yearBeginBalance", yearBeginBalance);
|
|
logisticsCompanyInfoJson.put("yearBeginBalance", yearBeginBalance);
|
|
|
|
+ logisticsCompanyInfoJson.put("yearBeginPayableBalance", yearBeginPayableBalance);
|
|
|
|
|
|
//上一期末余额
|
|
//上一期末余额
|
|
BigDecimal lastEndingBalance = yearBeginBalance;
|
|
BigDecimal lastEndingBalance = yearBeginBalance;
|
|
|
|
+ //上一期末应付余额
|
|
|
|
+ BigDecimal lastEndingPayableBalance = yearBeginPayableBalance;
|
|
|
|
|
|
//赋值每一个月信息
|
|
//赋值每一个月信息
|
|
List<LogisticsEndingAmountVo> list1 = logisticsRechargeMap.getOrDefault(logisticsCompanyInfo.getId(), new ArrayList<>());
|
|
List<LogisticsEndingAmountVo> list1 = logisticsRechargeMap.getOrDefault(logisticsCompanyInfo.getId(), new ArrayList<>());
|
|
Map<Integer, LogisticsEndingAmountVo> collect = list1.stream().collect(Collectors.toMap(LogisticsEndingAmountVo::getAccountPeriodMonth, Function.identity()));
|
|
Map<Integer, LogisticsEndingAmountVo> collect = list1.stream().collect(Collectors.toMap(LogisticsEndingAmountVo::getAccountPeriodMonth, Function.identity()));
|
|
for (int i = 1; i <= 12; i++) {
|
|
for (int i = 1; i <= 12; i++) {
|
|
LogisticsEndingAmountVo logisticsRecharge = collect.getOrDefault(i, new LogisticsEndingAmountVo());
|
|
LogisticsEndingAmountVo logisticsRecharge = collect.getOrDefault(i, new LogisticsEndingAmountVo());
|
|
|
|
+
|
|
|
|
+ //预付
|
|
BigDecimal advanceAmount = logisticsRecharge.getAdvanceAmount();
|
|
BigDecimal advanceAmount = logisticsRecharge.getAdvanceAmount();
|
|
if (advanceAmount == null) {
|
|
if (advanceAmount == null) {
|
|
advanceAmount = BigDecimal.ZERO;
|
|
advanceAmount = BigDecimal.ZERO;
|
|
}
|
|
}
|
|
|
|
+ //抵扣
|
|
BigDecimal deductionAmount = logisticsRecharge.getDeductionAmount();
|
|
BigDecimal deductionAmount = logisticsRecharge.getDeductionAmount();
|
|
if (deductionAmount == null) {
|
|
if (deductionAmount == null) {
|
|
deductionAmount = BigDecimal.ZERO;
|
|
deductionAmount = BigDecimal.ZERO;
|
|
}
|
|
}
|
|
|
|
+ //付款
|
|
|
|
+ BigDecimal paymentAmount = logisticsRecharge.getPaymentAmount();
|
|
|
|
+ if (paymentAmount == null) {
|
|
|
|
+ paymentAmount = BigDecimal.ZERO;
|
|
|
|
+ }
|
|
|
|
|
|
- //期末余额 = 期初余额 + 预付 - 抵扣
|
|
|
|
|
|
+ //期末余额 = 上期末余额 + 预付 - 抵扣
|
|
logisticsRecharge.setEndingBalance(lastEndingBalance.add(advanceAmount).subtract(deductionAmount));
|
|
logisticsRecharge.setEndingBalance(lastEndingBalance.add(advanceAmount).subtract(deductionAmount));
|
|
|
|
|
|
|
|
+ //获取 贷方发生额
|
|
|
|
+ LogisticsAmount logisticsAmount = logisticsAmountMap.getOrDefault(logisticsCompanyInfo.getId(), new LogisticsAmount());
|
|
|
|
+ JSONObject logisticsAmountJson = JSONObject.parseObject(JSONObject.toJSONString(logisticsAmount));
|
|
|
|
+ BigDecimal creditAmount = logisticsAmountJson.getBigDecimal(StrUtil.format("month{}Amount", i));
|
|
|
|
+ if (creditAmount == null) {
|
|
|
|
+ creditAmount = BigDecimal.ZERO;
|
|
|
|
+ }
|
|
|
|
+ logisticsRecharge.setCreditAmount(creditAmount);
|
|
|
|
+
|
|
|
|
+ //期末应付余额 = 上期末应付余额 + 贷方发生额 - 付款 - 抵扣
|
|
|
|
+ BigDecimal endingPayableBalance = lastEndingPayableBalance.add(creditAmount).subtract(paymentAmount).subtract(deductionAmount);
|
|
|
|
+ logisticsRecharge.setEndingPayableBalance(endingPayableBalance);
|
|
|
|
+
|
|
logisticsCompanyInfoJson.put("" + i, logisticsRecharge);
|
|
logisticsCompanyInfoJson.put("" + i, logisticsRecharge);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -147,4 +189,9 @@ public class LogisticsEndingAmountServiceImpl extends ServiceImpl<LogisticsEndin
|
|
|
|
|
|
return outList;
|
|
return outList;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<JSONObject> logisticsPayableSummary(LogisticsEndingAmountSelectDto dto) {
|
|
|
|
+ return logisticsRechargeSummary(dto);
|
|
|
|
+ }
|
|
}
|
|
}
|