From 2db76f2066701cbe292f206ad49a7f8523b8aa9f Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期五, 14 八月 2026 16:30:25 +0800
Subject: [PATCH] feat:银行流水关联多个合同,新增预收款开票,所有List校验调整为ColUtil
---
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentConfirmServiceImpl.java | 440 +++++++++++++-----------------------------------------
1 files changed, 107 insertions(+), 333 deletions(-)
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentConfirmServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentConfirmServiceImpl.java
index 43eec9f..2df9d21 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentConfirmServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentConfirmServiceImpl.java
@@ -1,7 +1,7 @@
package com.by4cloud.platformx.business.service.impl;
import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjUtil;
@@ -15,6 +15,7 @@
import com.by4cloud.platformx.admin.api.feign.RemoteDeptService;
import com.by4cloud.platformx.business.dto.AgingQueryDTO;
import com.by4cloud.platformx.business.dto.PaymentConfirmAddDTO;
+import com.by4cloud.platformx.business.dto.SyncPaymentRecepitDTO;
import com.by4cloud.platformx.business.entity.*;
import com.by4cloud.platformx.business.mapper.*;
import com.by4cloud.platformx.business.service.BusinessCustomerService;
@@ -30,7 +31,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
@@ -42,6 +43,8 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
+
+;
/**
* 鏀舵纭
@@ -63,8 +66,9 @@
private final BipRequestRecordMapper bipRequestRecordMapper;
private final ContractExecDateMapper contractExecDateMapper;
private final MeterReadRecordMapper meterReadRecordMapper;
+ private final BankStatementMapper bankStatementMapper;
private final RemoteDeptService remoteDeptService;
- private final RedisTemplate redisTemplate;
+ private final StringRedisTemplate redisTemplate;
@Value("${bip.url}")
private String url;
@@ -105,11 +109,12 @@
//鏂板浠樻鍗�
PaymentSlip slip = new PaymentSlip();
slip.setBusGuestId(customer.getId());
- slip.setBusGuestName(customer.getRegisterName());
+ slip.setBusGuestName(customer.getCompanyName());
slip.setPayeeCompId(SecurityUtils.getUser().getCompId());
slip.setPaymentTime(addDTO.getConfirmTime());
slip.setPaymentAmount(addDTO.getTransationAmount());
slip.setPayType(addDTO.getPayType());
+ slip.setContractId(contract.getId());
paymentSlipMapper.insert(slip);
BigDecimal newtotal = addDTO.getTransationAmount().add(lastTotal);
@@ -122,7 +127,7 @@
entity.setScheduleName(lastConfirm.getScheduleName());
}
entity.setBusGuestId(customer.getId());
- entity.setBusGuestName(customer.getRegisterName());
+ entity.setBusGuestName(customer.getCompanyName());
entity.setBusinessType("瀹㈡埛浠樻");
if (newtotal.compareTo(new BigDecimal("0")) > 0) {
entity.setTransationAmount(addDTO.getTransationAmount());
@@ -147,7 +152,7 @@
List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
.eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3)
.orderByAsc(ContractPaymentSchedule::getCreateTime));
- if (ArrayUtil.isNotEmpty(scheduleList.toArray())) {
+ if (CollUtil.isNotEmpty(scheduleList)) {
BigDecimal remain = addDTO.getTransationAmount();
for (ContractPaymentSchedule schedule : scheduleList) {
BigDecimal lastRemain = remain;
@@ -215,7 +220,7 @@
List<MeterReadRecord> recordList = meterReadRecordMapper.selectList(Wrappers.<MeterReadRecord>lambdaQuery()
.eq(MeterReadRecord::getContractId,contract.getId())
.isNull(MeterReadRecord::getMeterReadNum));
- if (ArrayUtil.isEmpty(execDateList.toArray())&&ArrayUtil.isEmpty(recordList.toArray())){
+ if (CollUtil.isEmpty(execDateList)&&CollUtil.isEmpty(recordList)){
//鏇存柊鍚堝悓宸蹭粯娆�
BigDecimal paid = new BigDecimal("0");
if (ObjUtil.isNotNull(contract.getPaidAmount())) {
@@ -238,7 +243,7 @@
entity.setContractNo(addDTO.getContractNo());
entity.setBusGuestId(customer.getId());
- entity.setBusGuestName(customer.getRegisterName());
+ entity.setBusGuestName(customer.getCompanyName());
entity.setBusinessType("閫�娆�");
entity.setTransationAmount(addDTO.getTransationAmount());
BigDecimal newtotal = addDTO.getTransationAmount().multiply(new BigDecimal("-1")).add(lastConfirm.getTotalAmount());
@@ -260,7 +265,7 @@
// List<Contract> customerContractList = contractService.list(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyAId, addDTO.getBusGuestId())
// .eq(Contract::getPartyBId, SecurityUtils.getUser().getCompId()).orderByAsc(Contract::getCreateTime)
// .apply(" ((contract_category != 'water_house' and amount != paid_amount) or contract_category = 'water_house')"));
-// if (ArrayUtil.isEmpty(customerContractList.toArray())) {
+// if (ArrayUtil.isEmpty(customerContractList)) {
// return R.failed("涓烘煡璇㈠埌鏈粯娆惧悎鍚�");
// }
// BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery()
@@ -363,7 +368,7 @@
// .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2)
// .ne(ContractPaymentSchedule::getPaymentStatus, 3)
// .orderByAsc(ContractPaymentSchedule::getCreateTime));
-// if (ArrayUtil.isNotEmpty(scheduleList.toArray())) {
+// if (ArrayUtil.isNotEmpty(scheduleList)) {
// BigDecimal remain = transtionAmount;
// for (ContractPaymentSchedule schedule : scheduleList) {
// BigDecimal lastRemain = remain;
@@ -417,7 +422,7 @@
// List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
// .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0)
// .ne(ContractPaymentSchedule::getPaymentStatus, 3));
-// if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())) {
+// if (ArrayUtil.isNotEmpty(payComScheduleList)) {
// BigDecimal payTotal = payComScheduleList.stream().map(item -> StrUtil.equals(item.getPaymentStatus() + "", "2") ? item.getPlannedAmount() :
// item.getActualAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
// contract.setPaidAmount(payTotal);
@@ -436,10 +441,10 @@
// if (StrUtil.isNotEmpty(contract.getContractCategory()) && StrUtil.equals(contract.getContractCategory(), "water_house")) {
// List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery()
// .eq(ContractExecDate::getContractId, contract.getId()).eq(ContractExecDate::getGenFlag, "0"));
-// if (ArrayUtil.isEmpty(execDateList.toArray())) {
+// if (ArrayUtil.isEmpty(execDateList)) {
// List<ContractPaymentSchedule> contractPaymentScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
// .eq(ContractPaymentSchedule::getContractId, contract.getId()));
-// if (ArrayUtil.isNotEmpty(contractPaymentScheduleList.toArray()) && contractPaymentScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) {
+// if (ArrayUtil.isNotEmpty(contractPaymentScheduleList) && contractPaymentScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) {
// contract.setContractStatus(3);
// contractService.updateById(contract);
// }
@@ -453,20 +458,20 @@
//瀹㈡埛棰勪粯鏈夊墿浣� 涓� 鏈夐浠樻鐨勫悎鍚�
// if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) {
-// if (ArrayUtil.isNotEmpty(payNoCompleteContractList.toArray())){
+// if (ArrayUtil.isNotEmpty(payNoCompleteContractList)){
// //浣欓 鏀惧埌浠樻鏈畬鎴愬悎鍚� 棰勬敹
// Contract lastContract = payNoCompleteContractList.get(0);
// //淇濆瓨鏄庣粏
// saveNewPaymentConfirm(customer,null,lastContract,transtionRemainAmount,payDate);
// }
-// if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isNotEmpty(advanceContractList.toArray())){
+// if (ArrayUtil.isEmpty(payNoCompleteContractList)&&ArrayUtil.isNotEmpty(advanceContractList)){
// //瀹㈡埛棰勪粯鏈夊墿浣� 娌℃湁棰勪粯娆剧殑鍚堝悓
// Contract lastContract = advanceContractList.get(0);
// //淇濆瓨鏄庣粏
// saveNewPaymentConfirm(customer,null,lastContract,transtionRemainAmount,payDate);
// }
-// if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isEmpty(advanceContractList.toArray())
-// &&ArrayUtil.isNotEmpty(payCompleteContractList.toArray())) {
+// if (ArrayUtil.isEmpty(payNoCompleteContractList)&&ArrayUtil.isEmpty(advanceContractList)
+// &&ArrayUtil.isNotEmpty(payCompleteContractList)) {
// //瀹㈡埛棰勪粯鏈夊墿浣� 娌℃湁棰勪粯娆剧殑鍚堝悓
// Contract lastContract = payCompleteContractList.get(payCompleteContractList.size() - 1);
// //淇濆瓨鏄庣粏
@@ -479,20 +484,42 @@
}
@Override
- public R syncPaymentRecepit() {
+ public R syncPaymentRecepit(SyncPaymentRecepitDTO dto) {
String accessToken = "";
if (redisTemplate.hasKey("BIP_TOKEN")) {
accessToken = (String) redisTemplate.opsForValue().get("BIP_TOKEN");
} else {
- getAccessToken(accessToken);
+ accessToken = getAccessToken(accessToken);
}
if (StrUtil.isEmpty(accessToken)) {
return R.failed("鑾峰彇token澶辫触");
}
- String[] bipCodeArr = codes.split(",");
+ String[] bipCodeArr = StrUtil.isNotBlank(dto.getBipCode())?dto.getBipCode().split(","):codes.split(",");
for (String bipCode : bipCodeArr) {
//鍏ュ弬
- JSONObject params = genParams(bipCode);
+ JSONObject params = new JSONObject();
+ if (ObjUtil.isNotEmpty(dto.getPageSize())){
+ params.put("pageSize",dto.getPageSize());
+ }else {
+ params.put("pageSize",999);
+ }
+ if (ObjUtil.isNotEmpty(dto.getPageNum())){
+ params.put("pageNum",dto.getPageNum());
+ }else {
+ params.put("pageNum",1);
+ }
+ if (StrUtil.isNotBlank(dto.getStartDate())){
+ params.put("begindate",dto.getStartDate());
+ }else {
+ params.put("begindate", DateUtil.formatDate(DateUtil.offsetDay(new Date(), -1)));
+ }
+ if (StrUtil.isNotBlank(dto.getStartDate())){
+ params.put("enddate", dto.getEndDate());
+ }else {
+ params.put("enddate", DateUtil.today());
+ }
+ //鍗曟嵁鐘舵�佸凡瀹℃壒
+ params.put("accentity_code", bipCode);
String finalAccessToken = accessToken;
new Thread(() -> {
try {
@@ -500,11 +527,11 @@
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
- log.info("SK_CX Request:", params.toJSONString());
- String result = HttpUtil.post(url + "/yonbip/EFI/collection/list?access_token=" + finalAccessToken, params.toJSONString());
- log.info("SK_CX Response:{}", result);
+ log.info("閾惰娴佹按鏌ヨ Request:{}", params.toJSONString());
+ String result = HttpUtil.post(url + "/iuap-api-auth/yonbip/ctm/cmp/bankReconciliationQuery?access_token=" + finalAccessToken, params.toJSONString());
+ log.info("閾惰娴佹按鏌ヨ Response:{}", result);
//淇濆瓨璇锋眰璁板綍
- saveBipRequestRecord(params, "<XSJZ_SK_CX_001>-鏀舵鍗曟煡璇㈡帴鍙�", result);
+ saveBipRequestRecord(params, "閾惰娴佹按鏌ヨ鎺ュ彛", result);
JSONObject resultJson = JSONObject.parseObject(result);
if (resultJson.containsKey("code") && resultJson.getString("code").equals("200")) {
handleAndSave(bipCode, resultJson);
@@ -513,23 +540,6 @@
}).start();
}
return R.ok();
- }
-
- private JSONObject genParams(String bipCode) {
- JSONObject params = new JSONObject();
- params.put("pageIndex", 1);
- params.put("pageSize", 999);
- params.put("open_billDate_begin", DateUtil.offsetDay(new Date(), -1) + " 00:00:00");
- params.put("open_billDate_begin", DateUtil.today() + " 00:00:00");
- //鍗曟嵁鐘舵�佸凡瀹℃壒
- params.put("verifyState", new String[]{"2"});
- //寰�鏉ュ璞″鎴�
- params.put("objectType", new String[]{"1"});
- //鍗曚綅
- JSONObject simpleMap = new JSONObject();
- simpleMap.put("financeOrg.code", bipCode);
- params.put("simple", simpleMap);
- return params;
}
@Override
@@ -550,9 +560,9 @@
}
String getTokenResult = HttpUtil.get(url + "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken?appKey=" + appKey + "×tamp=" + timestamp
+ "&signature=" + signature);
- log.info("Get access_token Response:", getTokenResult);
+ log.info("Get access_token Response:{}", getTokenResult);
JSONObject tokenJson = JSONObject.parseObject(getTokenResult);
- if (!tokenJson.containsKey("code") || !tokenJson.getString("code").equals("200")) {
+ if (!tokenJson.containsKey("code") || !tokenJson.getString("code").equals("00000")) {
log.error("Get access_token ERROR");
return "";
}
@@ -561,8 +571,8 @@
return "";
}
accessToken = JSONObject.parseObject(tokenJson.getString("data")).getString("access_token");
- log.info("access_token value:", accessToken);
- redisTemplate.opsForValue().set("BIP_TOKEN", accessToken, tokenJson.getIntValue("expire") - 10, TimeUnit.SECONDS);
+ log.info("access_token value:{}", accessToken);
+ redisTemplate.opsForValue().set("BIP_TOKEN", accessToken, JSONObject.parseObject(tokenJson.getString("data")).getIntValue("expire") - 10, TimeUnit.SECONDS);
return accessToken;
}
@@ -583,301 +593,65 @@
return;
}
SysDept dept = r.getData();
- JSONObject dataJson = JSONObject.parseObject(resultJson.getString("data"));
+ JSONObject dataJson = resultJson.getJSONObject("data");
if (ObjUtil.isNull(dataJson)) {
log.error("杩斿洖缁撴灉涓璬ata瑙f瀽澶辫触");
return;
}
- JSONArray recordList = JSONArray.parseArray(resultJson.getString("recordList"));
- if (ArrayUtil.isEmpty(recordList.toArray())) {
+ JSONArray recordList = dataJson.getJSONArray("recordList");
+ if (CollUtil.isEmpty(recordList)) {
log.error("杩斿洖缁撴灉涓璻ecordList涓虹┖");
return;
}
- log.info("==================寮�濮嬪鐞嗘敹娆惧崟淇℃伅===================");
+ log.info("==================寮�濮嬪鐞嗛摱琛屾祦姘翠俊鎭�===================");
recordList.stream().forEach(record -> {
savePaymentConfirm((JSONObject) record, dept);
});
- log.info("==================缁撴潫澶勭悊鏀舵鍗曚俊鎭�===================");
+ log.info("==================缁撴潫澶勭悊閾惰娴佹按淇℃伅===================");
}
private void savePaymentConfirm(JSONObject record, SysDept dept) {
- List<Contract> contractList = contractService.list(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyA, record.getString("bodyItemCustomerName"))
- .eq(Contract::getPartyBId, dept.getDeptId()).orderByAsc(Contract::getCreateTime));
- if (ArrayUtil.isEmpty(contractList.toArray())) {
- log.error("浠樻鍗昳d锛歿},鐢叉柟锛歿},涔欐柟锛歿},鏃犵浉鍏冲悎鍚�", record.getString("id"), record.getString("bodyItemCustomerName"), dept.getName());
- return;
- }
+
BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery()
- .eq(StrUtil.isNotBlank(record.getString("bodyItemCustomerName")), BusinessCustomer::getRegisterName, record.getString("bodyItemCustomerName"))
+ .eq(BusinessCustomer::getCompanyName, record.getString("to_acct_name"))
+ .eq(BusinessCustomer::getCompId,dept.getDeptId())
);
- if (ObjUtil.isNull(customer)) {
- log.error("浠樻鍗昳d锛歿},瀹㈠晢鏌ヨ澶辫触锛岃妫�鏌ュ鍟�", record.getString("id"));
- return;
- }
- if (ObjUtil.isNull(record.getBigDecimal("bodyItemOriTaxExcludedAmount"))) {
- log.error("浠樻鍗昳d锛歿},浠樻鍗曟棤绋庨噾棰濓紝寮傚父", record.getString("id"));
- return;
- }
- //淇濆瓨浠樻鍗�
- Boolean codeFlag = savePaymentSlip(customer, record, dept);
+ //淇濆瓨浠樻鍗�
+ Boolean codeFlag = saveBankStatement(customer, record,dept);
if (codeFlag) {
log.error("浠樻鍗昳d锛歿},浠樻鍗曞凡瀛樺湪");
return;
}
- BigDecimal transtionAmount = record.getBigDecimal("bodyItemOriTaxExcludedAmount");
- //鍓╀綑浠樻
- BigDecimal transtionRemainAmount = transtionAmount;
- //鏀跺埌浠樻鐨勫悎鍚�
- List<Contract> payContractList = new ArrayList<>();
- //浠樻瀹屾垚鐨勫悎鍚�
- List<Contract> payCompleteContractList = new ArrayList<>();
- //浠樻鏈畬鎴愮殑鍚堝悓
- List<Contract> payNoCompleteContractList = new ArrayList<>();
- //鏈夐浠樻鐨勫悎鍚�
- List<Contract> advanceContractList = new ArrayList<>();
- //浠樻鏃堕棿
- Date payDate = DateUtil.parse(record.getString("billDate"), DatePattern.NORM_DATETIME_FORMAT);
- Iterator<Contract> iterator = contractList.iterator();
- while (iterator.hasNext()) {
- Contract contract = iterator.next();
- PaymentConfirm lastConfirm = baseMapper.selectOne(Wrappers.<PaymentConfirm>lambdaQuery().eq(PaymentConfirm::getContractId, contract.getId())
- .orderByDesc(PaymentConfirm::getCreateTime).last("limit 1"));
- BigDecimal lastTotal = new BigDecimal("0");
- if (ObjUtil.isNotNull(lastConfirm)) {
- lastTotal = lastConfirm.getTotalAmount();
- }
- //鍚堝悓鏈�杩戞槑缁嗘�婚涓�0 鎴� > 0 鎯呭喌涓�
- if (lastTotal.compareTo(new BigDecimal("0")) >= 0) {
- log.info("褰撳墠鍚堝悓鍙凤細{},鏄庣粏鎬婚鏃犲簲鏀舵", contract.getContractNo());
- advanceContractList.add(contract);
- continue;
- }
-
- transtionRemainAmount = transtionRemainAmount.add(lastTotal);
- PaymentConfirm entity = new PaymentConfirm();
- entity.setContractId(contract.getId());
- entity.setContractName(contract.getContractName());
- entity.setContractNo(contract.getContractNo());
- if (ObjUtil.isNotNull(lastConfirm)) {
- entity.setScheduleId(lastConfirm.getScheduleId());
- entity.setScheduleName(lastConfirm.getScheduleName());
- }
- entity.setBusGuestId(customer.getId());
- entity.setBusGuestName(customer.getRegisterName());
- entity.setBusinessType("瀹㈡埛浠樻");
- entity.setIsBip(1);
- entity.setPaymentCode(record.getString("code"));
- entity.setPayType(record.get("bodyItemSettleModeName") != null ? record.getString("bodyItemSettleModeName").contains("鎵垮厬姹囩エ") ? 1 : 0 : null);
- entity.setBipId(record.getString("id"));
- if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) {
- entity.setConfirmTime(payDate);
- // 鍒ゆ柇鏄惁鏄渶鍚庝竴涓�
- if (!iterator.hasNext()) {
- entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal));
- entity.setAdvanceAmount(transtionRemainAmount);
- entity.setTotalAmount(transtionRemainAmount);
- } else {
- entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1")));
- entity.setTotalAmount(new BigDecimal("0"));
- }
- baseMapper.insert(entity);
- } else if (transtionRemainAmount.compareTo(new BigDecimal("0")) == 0) {
- entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1")));
- entity.setTotalAmount(new BigDecimal("0"));
- entity.setConfirmTime(payDate);
- baseMapper.insert(entity);
- break;
- } else {
- entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal));
- entity.setTotalAmount(transtionAmount);
- entity.setConfirmTime(payDate);
- baseMapper.insert(entity);
- break;
- }
- }
-
- payContractList.stream().forEach(contract -> {
- //鏇存柊浠樻闃舵浠樻
- List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
- .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3)
- .orderByAsc(ContractPaymentSchedule::getCreateTime));
- if (ArrayUtil.isNotEmpty(scheduleList.toArray())) {
- BigDecimal remain = transtionAmount;
- for (ContractPaymentSchedule schedule : scheduleList) {
- BigDecimal lastRemain = remain;
- remain = remain.subtract(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount() :
- schedule.getPlannedAmount().subtract(schedule.getActualAmount()));
- if (remain.compareTo(new BigDecimal("0")) >= 0) {
- schedule.setActualAmount(schedule.getPlannedAmount());
- schedule.setPaymentDate(payDate);
- schedule.setPaymentStatus(2);
- contractPaymentScheduleMapper.updateById(schedule);
- //鏌ヨ鏄惁鏈夊綋鍓嶉�炬湡
- CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId())
- .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1"));
- if (ObjUtil.isNotNull(currentOverdue)) {
- //鏂板閫炬湡鍘嗗彶
- HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id");
- historyOverdue.setPaymentTime(payDate);
- historyOverdue.setCompId(schedule.getCompId());
- historyOverdueMapper.insert(historyOverdue);
- //鍒犻櫎褰撳墠閫炬湡
- currentOverdueMapper.deleteById(currentOverdue);
- }
- } else {
- schedule.setActualAmount(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount().add(remain) :
- schedule.getActualAmount().add(lastRemain));
- schedule.setPaymentDate(payDate);
- schedule.setPaymentStatus(1);
- contractPaymentScheduleMapper.updateById(schedule);
- //鏌ヨ鏄惁鏈夊綋鍓嶉�炬湡
- CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId())
- .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1"));
- if (ObjUtil.isNotNull(currentOverdue)) {
- //鏂板閫炬湡鍘嗗彶
- HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id");
- historyOverdue.setReceivableAmount(lastRemain);
- historyOverdue.setPaymentTime(payDate);
- historyOverdue.setCompId(schedule.getCompId());
- historyOverdueMapper.insert(historyOverdue);
- //鏌ヨ鍘嗗彶宸蹭粯閫炬湡閲戦
- List<HistoryOverdue> historyOverdueList = historyOverdueMapper.selectList(Wrappers.<HistoryOverdue>lambdaQuery().eq(HistoryOverdue::getScheduleId, currentOverdue.getScheduleId()));
- BigDecimal hisTotal = historyOverdueList.stream().map(item -> item.getReceivableAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
- //鏇存柊褰撳墠閫炬湡
- currentOverdue.setReceivableAmount(schedule.getPlannedAmount().subtract(hisTotal));
- currentOverdueMapper.updateById(currentOverdue);
- }
- break;
- }
- }
- }
- //鍚堝悓鎵�鏈変粯娆鹃樁娈�
- List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
- .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0).ne(ContractPaymentSchedule::getPaymentStatus, 3)
- );
- if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())) {
- BigDecimal payTotal = payComScheduleList.stream().map(item -> StrUtil.equals(item.getPaymentStatus() + "", "0") ? item.getPlannedAmount() :
- item.getActualAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
- contract.setPaidAmount(payTotal);
-// if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) {
-// contract.setContractStatus(3);
-// }
-// contractService.updateById(contract);
-// if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) {
-// payCompleteContractList.add(contract);
-// }
- if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) {
-// contract.setBillingStatus("2");
- contract.setContractStatus(3);
- payCompleteContractList.add(contract);
- }
- //浠樻 涓� 浠樻鏈叏浠�
- if (contract.getAmount().compareTo(contract.getPaidAmount()) > 0) {
- payNoCompleteContractList.add(contract);
- }
- if (StrUtil.isNotEmpty(contract.getContractCategory()) && StrUtil.equals(contract.getContractCategory(), "water_house")) {
- List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery()
- .eq(ContractExecDate::getContractId, contract.getId()).eq(ContractExecDate::getGenFlag, "0"));
- if (ArrayUtil.isEmpty(execDateList)) {
- List<ContractPaymentSchedule> contractPaymentScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
- .eq(ContractPaymentSchedule::getContractId, contract.getId()));
- if (ArrayUtil.isNotEmpty(contractPaymentScheduleList.toArray()) && contractPaymentScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) {
- contract.setContractStatus(3);
- contractService.updateById(contract);
- }
- }
- } else {
- contractService.updateById(contract);
- }
- }
- });
-
- //瀹㈡埛棰勪粯鏈夊墿浣� 涓� 鏈夐浠樻鐨勫悎鍚�
-// if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) {
-// if (ArrayUtil.isNotEmpty(payNoCompleteContractList.toArray())){
-// //浣欓 鏀惧埌浠樻鏈畬鎴愬悎鍚� 棰勬敹
-// Contract lastContract = payNoCompleteContractList.get(payNoCompleteContractList.size() - 1);
-// //淇濆瓨鏄庣粏
-// saveNewPaymentConfirm(customer,record,lastContract,transtionRemainAmount,payDate);
-// }
-// if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isNotEmpty(advanceContractList.toArray())){
-// //瀹㈡埛棰勪粯鏈夊墿浣� 娌℃湁棰勪粯娆剧殑鍚堝悓
-// Contract lastContract = payNoCompleteContractList.get(payNoCompleteContractList.size() - 1);
-// //淇濆瓨鏄庣粏
-// saveNewPaymentConfirm(customer,record,lastContract,transtionRemainAmount,payDate);
-// }
-// if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isEmpty(advanceContractList.toArray())
-// &&ArrayUtil.isNotEmpty(payCompleteContractList.toArray())) {
-// //瀹㈡埛棰勪粯鏈夊墿浣� 娌℃湁棰勪粯娆剧殑鍚堝悓
-// Contract lastContract = payCompleteContractList.get(payCompleteContractList.size() - 1);
-// //淇濆瓨鏄庣粏
-// saveNewPaymentConfirm(customer,record,lastContract,transtionRemainAmount,payDate);
-//
-// }
-// }
}
- private Boolean savePaymentSlip(BusinessCustomer customer, JSONObject record, SysDept dept) {
- PaymentSlip slip = new PaymentSlip();
- slip.setBusGuestId(customer.getId());
- slip.setBusGuestName(customer.getRegisterName());
- slip.setPayee(dept.getName());
- slip.setPayeeCompId(dept.getDeptId());
- slip.setPaymentTime(ObjUtil.isNotNull(record.get("billDate")) ?
- DateUtil.parse(record.getString("billDate"), DatePattern.NORM_DATETIME_FORMAT) : new Date());
- slip.setPaymentAmount(ObjUtil.isNotNull(record.get("bodyItemOriTaxExcludedAmount")) ? record.getBigDecimal("bodyItemOriTaxExcludedAmount") : new BigDecimal("0"));
- slip.setPayType(ObjUtil.isNotNull(record.get("bodyItemSettleModeName")) ? record.getString("bodyItemSettleModeName") : "");
- if (ObjUtil.isNotNull(record.get("code"))) {
- slip.setPaymentNumber(record.getString("code"));
- PaymentSlip paymentSlip = paymentSlipMapper.selectOne(Wrappers.<PaymentSlip>lambdaQuery().eq(PaymentSlip::getPaymentNumber, slip.getPaymentNumber()));
- if (ObjUtil.isNull(paymentSlip)) {
- paymentSlipMapper.insert(slip);
- return false;
- }
+ private Boolean saveBankStatement(BusinessCustomer customer, JSONObject record,SysDept dept) {
+ BankStatement bankStatement = new BankStatement();
+ bankStatement.setBankSeqNo(record.getString("bank_seq_no"));
+ bankStatement.setReceiveBankAcc(record.getString("bank_seq_no"));
+ bankStatement.setReceiveBankAccAcc(record.getString("bankaccount_account"));
+ bankStatement.setReceiveBankAccName(record.getString("bankaccount_acctName"));
+ bankStatement.setPayBankNo(record.getString("to_acct_no"));
+ bankStatement.setPayBankAccName(record.getString("to_acct_name"));
+ bankStatement.setTranDate(DateUtil.parseDateTime(record.getString("tran_date")));
+ bankStatement.setTranAmount(record.getBigDecimal("tran_amt"));
+ bankStatement.setDataId(record.getLong("id"));
+ bankStatement.setDataJson(record.toJSONString());
+ if (ObjUtil.isNotNull(customer)) {
+ bankStatement.setBusGuestId(customer.getId());
}
+ BankStatement statement = bankStatementMapper.selectOne(Wrappers.<BankStatement>lambdaQuery().eq(BankStatement::getDataId,record.getLong("id")));
+ if (ObjUtil.isNotNull(statement)){
+ return false;
+ }
+ bankStatement.setRemark(record.getString("remark"));
+ bankStatement.setCompId(dept.getDeptId());
+ bankStatementMapper.insert(bankStatement);
return true;
}
- public void saveNewPaymentConfirm(BusinessCustomer customer, JSONObject record, Contract contract, BigDecimal transtionRemainAmount
- , Date payDate) {
- PaymentConfirm entity = new PaymentConfirm();
- entity.setContractId(contract.getId());
- entity.setContractName(contract.getContractName());
- entity.setContractNo(contract.getContractNo());
- PaymentConfirm lastConfirm = baseMapper.selectOne(Wrappers.<PaymentConfirm>lambdaQuery().eq(PaymentConfirm::getContractId, contract.getId())
- .orderByDesc(PaymentConfirm::getCreateTime).last("limit 1"));
- BigDecimal lastTotal = new BigDecimal("0");
- if (ObjUtil.isNotNull(lastConfirm)) {
- lastTotal = lastConfirm.getTotalAmount();
- }
-
- if (ObjUtil.isNotNull(lastConfirm)) {
- entity.setScheduleId(lastConfirm.getScheduleId());
- entity.setScheduleName(lastConfirm.getScheduleName());
- }
-
- entity.setBusGuestId(customer.getId());
- entity.setBusGuestName(customer.getRegisterName());
- entity.setBusinessType("瀹㈡埛浠樻");
- if (ObjUtil.isNotNull(record)) {
- entity.setIsBip(1);
- entity.setPaymentCode(record.getString("code"));
- entity.setPayType(record.get("bodyItemSettleModeName") != null ? record.getString("bodyItemSettleModeName").contains("鎵垮厬姹囩エ") ? 1 : 0 : null);
- entity.setBipId(record.getString("id"));
- }
- entity.setConfirmTime(payDate);
- entity.setTransationAmount(transtionRemainAmount);
- entity.setTotalAmount(transtionRemainAmount.add(lastTotal));
- if (entity.getTotalAmount().compareTo(new BigDecimal("0")) > 0) {
- entity.setAdvanceAmount(entity.getTotalAmount());
- } else if (entity.getTotalAmount().compareTo(new BigDecimal("0")) < 0) {
- entity.setReceivableAmount(entity.getTotalAmount().multiply(new BigDecimal("-1")));
- }
- baseMapper.insert(entity);
- }
@Override
public R queryAllBusinessType() {
@@ -888,7 +662,7 @@
@Override
public R queryAging() {
List<AgingCompanyVo> companys = contractPaymentScheduleMapper.selectAgingCompany(null, DataScope.of("comp_id"));
- if (ArrayUtil.isEmpty(companys.toArray())) {
+ if (CollUtil.isEmpty(companys)) {
return R.failed("鏆傛棤璐﹂緞");
}
List<AgingAnalysisVo> result = new ArrayList<>();
@@ -901,14 +675,14 @@
queryDTO.setCompanyId(company.getCompanyId());
List<AgingVo> companyAgingVo = contractPaymentScheduleMapper.selectAgingTotal(queryDTO);
//琛ュ叏鏁版嵁
- if (ArrayUtil.isEmpty(companyAgingVo.toArray())) {
+ if (CollUtil.isEmpty(companyAgingVo)) {
companyAgingVo = new ArrayList<>();
- AgingVo agingVo1 = new AgingVo("0-30澶�", new BigDecimal("0"), null);
- AgingVo agingVo2 = new AgingVo("31-60澶�", new BigDecimal("0"), null);
- AgingVo agingVo3 = new AgingVo("61-90澶�", new BigDecimal("0"), null);
- AgingVo agingVo4 = new AgingVo("91-180澶�", new BigDecimal("0"), null);
- AgingVo agingVo5 = new AgingVo("181-365澶�", new BigDecimal("0"), null);
- AgingVo agingVo6 = new AgingVo("1骞翠互涓�", new BigDecimal("0"), null);
+ AgingVo agingVo1 = new AgingVo(1L,"0-30澶�", new BigDecimal("0"), null);
+ AgingVo agingVo2 = new AgingVo(2L,"31-60澶�", new BigDecimal("0"), null);
+ AgingVo agingVo3 = new AgingVo(3L,"61-90澶�", new BigDecimal("0"), null);
+ AgingVo agingVo4 = new AgingVo(4L,"91-180澶�", new BigDecimal("0"), null);
+ AgingVo agingVo5 = new AgingVo(5L,"181-365澶�", new BigDecimal("0"), null);
+ AgingVo agingVo6 = new AgingVo(6L,"1骞翠互涓�", new BigDecimal("0"), null);
companyAgingVo.add(agingVo1);
companyAgingVo.add(agingVo2);
companyAgingVo.add(agingVo3);
@@ -917,28 +691,28 @@
companyAgingVo.add(agingVo6);
} else {
List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList());
- if (!ArrayUtil.contains(overdueRanges.toArray(), "0-30澶�")) {
- AgingVo agingVo1 = new AgingVo("0-30澶�", new BigDecimal("0"), null);
+ if (!CollUtil.contains(overdueRanges, "0-30澶�")) {
+ AgingVo agingVo1 = new AgingVo(1L,"0-30澶�", new BigDecimal("0"), null);
companyAgingVo.add(agingVo1);
}
- if (!ArrayUtil.contains(overdueRanges.toArray(), "31-60澶�")) {
- AgingVo agingVo2 = new AgingVo("31-60澶�", new BigDecimal("0"), null);
+ if (!CollUtil.contains(overdueRanges, "31-60澶�")) {
+ AgingVo agingVo2 = new AgingVo(2L,"31-60澶�", new BigDecimal("0"), null);
companyAgingVo.add(agingVo2);
}
- if (!ArrayUtil.contains(overdueRanges.toArray(), "61-90澶�")) {
- AgingVo agingVo3 = new AgingVo("61-90澶�", new BigDecimal("0"), null);
+ if (!CollUtil.contains(overdueRanges, "61-90澶�")) {
+ AgingVo agingVo3 = new AgingVo(3L,"61-90澶�", new BigDecimal("0"), null);
companyAgingVo.add(agingVo3);
}
- if (!ArrayUtil.contains(overdueRanges.toArray(), "91-180澶�")) {
- AgingVo agingVo4 = new AgingVo("91-180澶�", new BigDecimal("0"), null);
+ if (!CollUtil.contains(overdueRanges, "91-180澶�")) {
+ AgingVo agingVo4 = new AgingVo(4L,"91-180澶�", new BigDecimal("0"), null);
companyAgingVo.add(agingVo4);
}
- if (!ArrayUtil.contains(overdueRanges.toArray(), "181-365澶�")) {
- AgingVo agingVo5 = new AgingVo("181-365澶�", new BigDecimal("0"), null);
+ if (!CollUtil.contains(overdueRanges, "181-365澶�")) {
+ AgingVo agingVo5 = new AgingVo(5L,"181-365澶�", new BigDecimal("0"), null);
companyAgingVo.add(agingVo5);
}
- if (!ArrayUtil.contains(overdueRanges.toArray(), "1骞翠互涓�")) {
- AgingVo agingVo6 = new AgingVo("1骞翠互涓�", new BigDecimal("0"), null);
+ if (!CollUtil.contains(overdueRanges, "1骞翠互涓�")) {
+ AgingVo agingVo6 = new AgingVo(6L,"1骞翠互涓�", new BigDecimal("0"), null);
companyAgingVo.add(agingVo6);
}
}
--
Gitblit v1.9.1