Browse Source

2024年1月27日10:03:51

纪新园 1 year ago
parent
commit
acad0ab4dc

+ 2 - 2
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/mapper/BillsMapper.xml

@@ -341,10 +341,10 @@
             and find_in_set(acc.branch_id,#{acc.branchId})
         </if>
         <if test='acc.type != null and acc.type != "" and acc.type == "2"'>
-            and acc.amount_dr_loc > acc.stl_amount_dr_loc + fee.applied_amount
+            and fee.amount > fee.stl_ttl_amount
         </if>
         <if test='acc.type != null and acc.type != "" and acc.type == "3"'>
-            and acc.amount_cr_loc > acc.stl_amount_cr_loc + fee.applied_amount
+            AND fee.amount > fee.stl_ttl_amount + fee.applied_amount - fee.applied_amount_stl
         </if>
         <if test='acc.type != null and acc.type != "" and acc.type == "4"'>
             and fee.amount > fee.uninvoiced_amount + fee.applied_invoice_amount - fee.applied_invoice_amount_stl

+ 18 - 18
blade-service/blade-los/src/main/java/org/springblade/los/finance/invoices/service/impl/FinInvoicesServiceImpl.java

@@ -353,22 +353,22 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 					feeCenter.setInvoiceById(detail.getCreateUser());
 					feeCenter.setInvoiceByName(detail.getCreateUserName());
 					if (feeCenter.getAmount().subtract(feeCenter.getUninvoicedAmount()).compareTo(currentStlAmount) > 0) {
-						feeCenter.setUninvoicedAmount(feeCenter.getUninvoicedAmount().add(currentStlAmount));
-						if (ObjectUtils.isNull(item.getApplySrcId())) {
-							feeCenter.setAppliedInvoiceAmountStl(feeCenter.getAmount().subtract(feeCenter.getUnsettledAmount()).subtract(feeCenter.getAppliedInvoiceAmountStl()));
+						if (ObjectUtils.isNotNull(item.getApplySrcId())) {
+							feeCenter.setAppliedInvoiceAmountStl(feeCenter.getAppliedInvoiceAmountStl().add(currentStlAmount));
 						}
+						feeCenter.setUninvoicedAmount(feeCenter.getUninvoicedAmount().add(currentStlAmount));
 						currentStlAmount = new BigDecimal("0.00");
 					} else if (feeCenter.getAmount().subtract(feeCenter.getStlTtlAmount()).compareTo(currentStlAmount) == 0) {
-						feeCenter.setUninvoicedAmount(feeCenter.getAmount());
-						if (ObjectUtils.isNull(item.getApplySrcId())) {
-							feeCenter.setAppliedInvoiceAmountStl(feeCenter.getAmount().subtract(feeCenter.getUnsettledAmount()).subtract(feeCenter.getAppliedInvoiceAmountStl()));
+						if (ObjectUtils.isNotNull(item.getApplySrcId())) {
+							feeCenter.setAppliedInvoiceAmountStl(feeCenter.getAmount());
 						}
+						feeCenter.setUninvoicedAmount(feeCenter.getAmount());
 						currentStlAmount = new BigDecimal("0.00");
 					} else {
-						feeCenter.setUninvoicedAmount(feeCenter.getAmount());
-						if (ObjectUtils.isNull(item.getApplySrcId())) {
-							feeCenter.setAppliedInvoiceAmountStl(feeCenter.getAmount().subtract(feeCenter.getUnsettledAmount()).subtract(feeCenter.getAppliedInvoiceAmountStl()));
+						if (ObjectUtils.isNotNull(item.getApplySrcId())) {
+							feeCenter.setAppliedInvoiceAmountStl(feeCenter.getAmount());
 						}
+						feeCenter.setUninvoicedAmount(feeCenter.getAmount());
 						currentStlAmount = currentStlAmount.subtract(feeCenter.getAmount());
 					}
 					feeCenterList.add(feeCenter);
@@ -540,23 +540,23 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 					feeCenter.setUninvoicedAmount(feeCenter.getUninvoicedAmount().add(new BigDecimal("0.00").subtract(detail.getAmountLoc())));
 					feeCenter.setInvoiceById(detail.getCreateUser());
 					feeCenter.setInvoiceByName(detail.getCreateUserName());
-					if (feeCenter.getAmount().subtract(feeCenter.getUninvoicedAmount()).compareTo(currentStlAmount) > 0) {
-						feeCenter.setUninvoicedAmount(feeCenter.getUninvoicedAmount().subtract(currentStlAmount));
-						if (ObjectUtils.isNull(item.getApplySrcId())) {
+					if (feeCenter.getUninvoicedAmount().compareTo(currentStlAmount) > 0) {
+						if (ObjectUtils.isNotNull(item.getApplySrcId())) {
 							feeCenter.setAppliedInvoiceAmountStl(feeCenter.getAppliedInvoiceAmountStl().subtract(currentStlAmount));
 						}
-						currentStlAmount = new BigDecimal("0.00");
-					} else if (feeCenter.getAmount().subtract(feeCenter.getStlTtlAmount()).compareTo(currentStlAmount) == 0) {
 						feeCenter.setUninvoicedAmount(feeCenter.getUninvoicedAmount().subtract(currentStlAmount));
-						if (ObjectUtils.isNull(item.getApplySrcId())) {
+						currentStlAmount = new BigDecimal("0.00");
+					} else if (feeCenter.getStlTtlAmount().compareTo(currentStlAmount) == 0) {
+						if (ObjectUtils.isNotNull(item.getApplySrcId())) {
 							feeCenter.setAppliedInvoiceAmountStl(feeCenter.getAppliedInvoiceAmountStl().subtract(currentStlAmount));
 						}
+						feeCenter.setUninvoicedAmount(feeCenter.getUninvoicedAmount().subtract(currentStlAmount));
 						currentStlAmount = new BigDecimal("0.00");
 					} else {
-						feeCenter.setUninvoicedAmount(feeCenter.getUninvoicedAmount().subtract(currentStlAmount));
-						if (ObjectUtils.isNull(item.getApplySrcId())) {
+						if (ObjectUtils.isNotNull(item.getApplySrcId())) {
 							feeCenter.setAppliedInvoiceAmountStl(new BigDecimal("0.00"));
 						}
+						feeCenter.setUninvoicedAmount(feeCenter.getUninvoicedAmount().subtract(currentStlAmount));
 						currentStlAmount = currentStlAmount.subtract(item.getAmount());
 					}
 					feeCenterList.add(feeCenter);
@@ -672,7 +672,7 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 			}
 		}
 		if (invoiceAmount.compareTo(finInvoices.getAmountLoc()) > 0) {
-			throw new RuntimeException("开票金额大于合计金额,保存失败");
+			throw new RuntimeException("开票金额为负数,保存失败");
 		}
 		detail.setStatus(3);
 		baseMapper.updateById(detail);

+ 21 - 17
blade-service/blade-pay/src/main/java/org/springblade/pay/tonglianPayment/utils/SybPayService.java

@@ -1,8 +1,8 @@
 package org.springblade.pay.tonglianPayment.utils;
 
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import org.springblade.pay.tonglianPayment.dto.PaymentDTO;
 
-import java.util.HashMap;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -115,9 +115,9 @@ public class SybPayService {
 	}
 
 	public Map<String, String> payNew(long trxamt, String reqsn, String paytype, String body, String remark, String acct, String validtime, String notify_url, String limit_pay,
-								   String idno, String truename, String asinfo, String sub_appid, String goods_tag, String benefitdetail, String chnlstoreid, String subbranch,
-								   String extendparams, String cusip, String fqnum, String cusId, String appId, String orgid, String transactionType, String sybMdAppkey,
-								   String sybRsacusprikey, String sybRsatlpubkey, String sybSmpprivatekey, String sybSmtlpubkey) throws Exception {
+									  String idno, String truename, String asinfo, String sub_appid, String goods_tag, String benefitdetail, String chnlstoreid, String subbranch,
+									  String extendparams, String cusip, String fqnum, String cusId, String appId, String orgid, String transactionType, String sybMdAppkey,
+									  String sybRsacusprikey, String sybRsatlpubkey, String sybSmpprivatekey, String sybSmtlpubkey) throws Exception {
 
 
 		TreeMap<String, String> params = new TreeMap<String, String>();
@@ -125,14 +125,18 @@ public class SybPayService {
 		params.put("appid", appId);
 		if (!SybUtil.isEmpty(orgid)) {
 			params.put("orgid", orgid);
-		}else{
+		} else {
 			params.put("orgid", "");
 		}
 		params.put("version", "12");
 		params.put("trxamt", String.valueOf(trxamt));
 		params.put("reqsn", reqsn);
 		params.put("notify_url", notify_url);
-		params.put("body", body);
+		if (ObjectUtils.isNotNull(body)) {
+			params.put("body", body.substring(0, 20));
+		} else {
+			params.put("body", body);
+		}
 		params.put("remark", remark);
 		params.put("validtime", validtime);
 		params.put("limit_pay", "");
@@ -144,13 +148,13 @@ public class SybPayService {
 			appkey = sybRsacusprikey;
 		} else if (transactionType.equals("SM2")) {
 			appkey = sybSmpprivatekey;
-		}else if (transactionType.equals("RSA2")) {
+		} else if (transactionType.equals("RSA2")) {
 			appkey = sybRsatlpubkey;
 		} else {
 			appkey = sybMdAppkey;
 		}
 		params.put("sign", String.valueOf(SybUtil.unionSign(params, appkey, transactionType)));
-		System.out.println("支付数据:"+params);
+		System.out.println("支付数据:" + params);
 		return params;
 	}
 
@@ -175,9 +179,9 @@ public class SybPayService {
 		String appkey = "";
 		if (SybConstants.SIGN_TYPE.equals("RSA")) {
 			appkey = SybConstants.SYB_RSACUSPRIKEY;
-		}else if (SybConstants.SIGN_TYPE.equals("SM2")) {
+		} else if (SybConstants.SIGN_TYPE.equals("SM2")) {
 			appkey = SybConstants.SYB_SM2PPRIVATEKEY;
-		}else {
+		} else {
 			appkey = SybConstants.SYB_MD5_APPKEY;
 		}
 		params.put("sign", SybUtil.unionSign(params, appkey, SybConstants.SIGN_TYPE));
@@ -189,7 +193,7 @@ public class SybPayService {
 	}
 
 	public Map<String, String> refund(long trxamt, String reqsn, String oldtrxid, String oldreqsn, String cusId, String appId, String orgid, String transactionType, String sybMdAppkey,
-									  String sybRsacusprikey, String sybRsatlpubkey, String sybSmpprivatekey, String sybSmtlpubkey,String url) throws Exception {
+									  String sybRsacusprikey, String sybRsatlpubkey, String sybSmpprivatekey, String sybSmtlpubkey, String url) throws Exception {
 		TreeMap<String, String> params = new TreeMap<String, String>();
 		if (!SybUtil.isEmpty(orgid)) {
 			params.put("orgid", orgid);
@@ -214,11 +218,11 @@ public class SybPayService {
 	}
 
 	public Map<String, String> refundNew(long trxamt, String reqsn, String oldtrxid, String oldreqsn, String cusId, String appId, String orgid, String transactionType, String sybMdAppkey,
-									  String sybRsacusprikey, String sybRsatlpubkey, String sybSmpprivatekey, String sybSmtlpubkey,String url,String sybRsaPublickey) throws Exception {
+										 String sybRsacusprikey, String sybRsatlpubkey, String sybSmpprivatekey, String sybSmtlpubkey, String url, String sybRsaPublickey) throws Exception {
 		TreeMap<String, String> params = new TreeMap<String, String>();
 		if (!SybUtil.isEmpty(orgid)) {
 			params.put("orgid", orgid);
-		}else{
+		} else {
 			params.put("orgid", "");
 		}
 		params.put("cusid", cusId);
@@ -260,9 +264,9 @@ public class SybPayService {
 		String appkey = "";
 		if (SybConstants.SIGN_TYPE.equals("RSA")) {
 			appkey = SybConstants.SYB_RSACUSPRIKEY;
-		}else if (SybConstants.SIGN_TYPE.equals("SM2")) {
+		} else if (SybConstants.SIGN_TYPE.equals("SM2")) {
 			appkey = SybConstants.SYB_SM2PPRIVATEKEY;
-		}else {
+		} else {
 			appkey = SybConstants.SYB_MD5_APPKEY;
 		}
 		params.put("sign", SybUtil.unionSign(params, appkey, SybConstants.SIGN_TYPE));
@@ -286,9 +290,9 @@ public class SybPayService {
 			String appkey = "";
 			if (transactionType.equals("RSA")) {
 				appkey = sybRsacusprikey;
-			}else if (transactionType.equals("SM2")) {
+			} else if (transactionType.equals("SM2")) {
 				appkey = sybSmpprivatekey;
-			}else {
+			} else {
 				appkey = sybMdAppkey;
 			}
 			if (SybUtil.validSign(tmap, appkey, transactionType)) {