From b0ba33dce8487581d2bb3c49f886d158724dc44e Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期一, 08 六月 2026 17:19:49 +0800
Subject: [PATCH] fix:产品列表接口
---
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentConfirmServiceImpl.java | 183 ++++++++++++++++++++++++++++++---------------
1 files changed, 121 insertions(+), 62 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 851c239..986a3a1 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
@@ -53,6 +53,7 @@
private final HistoryOverdueMapper historyOverdueMapper;
private final PaymentSlipMapper paymentSlipMapper;
private final BipRequestRecordMapper bipRequestRecordMapper;
+ private final ContractExecDateMapper contractExecDateMapper;
private final RemoteDeptService remoteDeptService;
private final RedisTemplate redisTemplate;
@@ -253,19 +254,25 @@
List<Contract> advanceContractList = new ArrayList<>();
//浠樻鏃堕棿
Date payDate = addDTO.getConfirmTime();
- for (Contract contract : customerContractList) {
+ Iterator<Contract> iterator = customerContractList.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();
+ }else {
+
}
//鍚堝悓鏈�杩戞槑缁嗘�婚涓�0 鎴� > 0 鎯呭喌涓�
if (lastTotal.compareTo(new BigDecimal("0")) >= 0) {
log.info("褰撳墠鍚堝悓鍙凤細{},鏄庣粏鎬婚鏃犲簲鏀舵", contract.getContractNo());
advanceContractList.add(contract);
- continue;
+ if (iterator.hasNext()) {
+ continue;
+ }
}
transtionRemainAmount = transtionRemainAmount.add(lastTotal);
@@ -281,9 +288,16 @@
entity.setBusGuestName(customer.getCompanyName());
entity.setBusinessType("瀹㈡埛浠樻");
if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) {
- entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1")));
- entity.setTotalAmount(new BigDecimal("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);
payContractList.add(contract);
} else if (transtionRemainAmount.compareTo(new BigDecimal("0")) == 0) {
@@ -371,7 +385,6 @@
// if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) {
// contract.setContractStatus(3);
// }
- contractService.updateById(contract);
if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) {
contract.setBillingStatus("2");
contract.setContractStatus(3);
@@ -381,32 +394,47 @@
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.toArray())){
+ 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(0);
- //淇濆瓨鏄庣粏
- saveNewPaymentConfirm(customer,null,lastContract,transtionRemainAmount,payDate);
- }
- if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isNotEmpty(advanceContractList.toArray())){
- //瀹㈡埛棰勪粯鏈夊墿浣� 娌℃湁棰勪粯娆剧殑鍚堝悓
- Contract lastContract = advanceContractList.get(0);
- //淇濆瓨鏄庣粏
- saveNewPaymentConfirm(customer,null,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,null,lastContract,transtionRemainAmount,payDate);
-
- }
- }
+// if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) {
+// if (ArrayUtil.isNotEmpty(payNoCompleteContractList.toArray())){
+// //浣欓 鏀惧埌浠樻鏈畬鎴愬悎鍚� 棰勬敹
+// Contract lastContract = payNoCompleteContractList.get(0);
+// //淇濆瓨鏄庣粏
+// saveNewPaymentConfirm(customer,null,lastContract,transtionRemainAmount,payDate);
+// }
+// if (ArrayUtil.isEmpty(payNoCompleteContractList.toArray())&&ArrayUtil.isNotEmpty(advanceContractList.toArray())){
+// //瀹㈡埛棰勪粯鏈夊墿浣� 娌℃湁棰勪粯娆剧殑鍚堝悓
+// Contract lastContract = advanceContractList.get(0);
+// //淇濆瓨鏄庣粏
+// saveNewPaymentConfirm(customer,null,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,null,lastContract,transtionRemainAmount,payDate);
+//
+// }
+// }
}
return R.ok();
}
@@ -437,7 +465,7 @@
String result = HttpUtil.post(url + "/yonbip/EFI/collection/list?access_token=" + finalAccessToken, params.toJSONString());
log.info("SK_CX Response:{}", result);
//淇濆瓨璇锋眰璁板綍
- saveBipRequestRecord(params, result);
+ saveBipRequestRecord(params,"<XSJZ_SK_CX_001>-鏀舵鍗曟煡璇㈡帴鍙�", result);
JSONObject resultJson = JSONObject.parseObject(result);
if (resultJson.containsKey("code") && resultJson.getString("code").equals("200")) {
handleAndSave(bipCode, resultJson);
@@ -465,7 +493,8 @@
return params;
}
- private void getAccessToken(String accessToken) {
+ @Override
+ public String getAccessToken(String accessToken) {
long timestamp = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("appKey", appKey);
@@ -486,20 +515,22 @@
JSONObject tokenJson = JSONObject.parseObject(getTokenResult);
if (!tokenJson.containsKey("code") || !tokenJson.getString("code").equals("200")) {
log.error("Get access_token ERROR");
- return;
+ return "";
}
if (ObjUtil.isNull(tokenJson.get("data")) || ObjUtil.isNull(JSONObject.parseObject(tokenJson.getString("data")))) {
log.error("access_token value exception");
- return;
+ 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);
+ return accessToken;
}
- private void saveBipRequestRecord(JSONObject params, String result) {
+ @Override
+ public void saveBipRequestRecord(JSONObject params, String methodName, String result) {
BipRequestRecord record = new BipRequestRecord();
- record.setInterfaceName("<XSJZ_SK_CX_001>-鏀舵鍗曟煡璇㈡帴鍙�");
+ record.setInterfaceName(methodName);
record.setRequestParams(params.toJSONString());
record.setResponseParams(result);
record.setResponseCode(JSONObject.parseObject(result).getString("code"));
@@ -569,7 +600,9 @@
List<Contract> advanceContractList = new ArrayList<>();
//浠樻鏃堕棿
Date payDate = DateUtil.parse(record.getString("billDate"), DatePattern.NORM_DATETIME_FORMAT);
- for (Contract contract : contractList) {
+ 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");
@@ -601,9 +634,16 @@
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.setTransationAmount(lastTotal.multiply(new BigDecimal("-1")));
- entity.setTotalAmount(new BigDecimal("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")));
@@ -683,43 +723,62 @@
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 (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);
-
- }
- }
+// 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) {
--
Gitblit v1.9.1