From b88a288f4f787b509463678e3cd9ccfa3f37014b Mon Sep 17 00:00:00 2001
From: chengf <cgf12138@163.com>
Date: 星期三, 11 三月 2026 12:01:05 +0800
Subject: [PATCH] 导入测试
---
service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java | 161 +++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 124 insertions(+), 37 deletions(-)
diff --git a/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java b/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java
index cbc60cd..33c9969 100644
--- a/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java
+++ b/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java
@@ -6,9 +6,11 @@
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.CommunitySettingFactory;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.core.log.LoggerFactory;
import com.java110.core.smo.IComputeFeeSMO;
+import com.java110.dto.account.AccountDetailDto;
import com.java110.dto.account.AccountDto;
import com.java110.dto.community.CommunityDto;
import com.java110.dto.coupon.CouponUserDto;
@@ -17,16 +19,22 @@
import com.java110.dto.fee.FeeDetailDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.fee.ComputeDiscountDto;
-import com.java110.intf.acct.IAccountDetailInnerServiceSMO;
-import com.java110.intf.acct.IAccountInnerServiceSMO;
-import com.java110.intf.acct.ICouponUserV1InnerServiceSMO;
+import com.java110.dto.payment.PaymentPoolDto;
+import com.java110.dto.payment.PaymentPoolValueDto;
+import com.java110.dto.wechat.SmallWeChatDto;
+import com.java110.intf.acct.*;
import com.java110.intf.community.ICommunityV1InnerServiceSMO;
import com.java110.intf.community.IRepairUserInnerServiceSMO;
import com.java110.intf.community.IRoomInnerServiceSMO;
import com.java110.intf.fee.*;
import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.po.account.AccountDetailPo;
+import com.java110.po.account.AccountPo;
import com.java110.utils.cache.CommonCache;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.MappingConstant;
import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.constant.WechatConstant;
import com.java110.utils.exception.CmdException;
import com.java110.utils.exception.ListenerExecuteException;
import com.java110.utils.util.*;
@@ -42,6 +50,7 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
/**
* 绫昏〃杩帮細鍒犻櫎
@@ -63,6 +72,12 @@
@Autowired
private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
+
+ @Autowired
+ private IPaymentPoolV1InnerServiceSMO paymentPoolV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IPaymentPoolValueV1InnerServiceSMO paymentPoolValueV1InnerServiceSMOImpl;
@Autowired
private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
@@ -95,13 +110,19 @@
private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
@Autowired
- private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
-
- @Autowired
private IAccountDetailInnerServiceSMO accountDetailInnerServiceSMOImpl;
@Autowired
+ private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
+
+ @Autowired
private IFeeAccountDetailServiceSMO feeAccountDetailServiceSMOImpl;
+
+ //閿�(绉垎璐︽埛鏈�澶т娇鐢ㄧН鍒�)
+ public static final String MAXIMUM_NUMBER = "MAXIMUM_NUMBER";
+
+ //閿�(绉垎璐︽埛鎶垫墸姣斾緥)
+ public static final String DEDUCTION_PROPORTION = "DEDUCTION_PROPORTION";
@Override
public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
@@ -165,7 +186,7 @@
String appId = cmdDataFlowContext.getReqHeaders().get("app-id");
reqJson.put("appId", appId);
- reqJson.put("userId",userId);
+ reqJson.put("userId", userId);
FeeDto feeDto = new FeeDto();
feeDto.setFeeId(reqJson.getString("feeId"));
@@ -182,10 +203,13 @@
//todo 璁$畻搴旀敹
BigDecimal receivableAmount = new BigDecimal(feePriceAll.get("feePrice").toString());
BigDecimal cycles = new BigDecimal(Double.parseDouble(reqJson.getString("cycles")));
- double tmpReceivableAmount = cycles.multiply(receivableAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ double tmpReceivableAmount = cycles.multiply(receivableAmount).setScale(4, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+ tmpReceivableAmount = MoneyUtil.computePriceScale(tmpReceivableAmount, feeDto.getScale(), Integer.parseInt(feeDto.getDecimalPlace()));
+
JSONObject paramOut = new JSONObject();
paramOut.put("receivableAmount", tmpReceivableAmount);
- paramOut.put("oId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_oId));
+ SmallWeChatDto smallWeChatDto = get(reqJson.getString("communityId"));
+ paramOut.put("oId", smallWeChatDto.getOrderPre() + GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_oId));
//瀹炴敹閲戦
@@ -224,6 +248,43 @@
reqJson.putAll(paramOut);
CommonCache.setValue("payFeePre" + paramOut.getString("oId"), reqJson.toJSONString(), 24 * 60 * 60);
cmdDataFlowContext.setResponseEntity(responseEntity);
+ }
+
+ public SmallWeChatDto get(String community){
+ SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
+ //鐢变簬瀵屾湁鏀粯鏂瑰紡瑕佷粠鏁版嵁搴撻噷闈㈠彇鍊硷紝鎵�浠ユ澶勮鏌ヨ
+ PaymentPoolDto paymentPoolDto = new PaymentPoolDto();
+// paymentPoolDto.setCommunityId(community);
+ paymentPoolDto.setPage(1);
+ paymentPoolDto.setRow(10);
+ List<PaymentPoolDto> paymentPoolDtos = paymentPoolV1InnerServiceSMOImpl.queryPaymentPools(paymentPoolDto);
+ List<PaymentPoolDto> collect = paymentPoolDtos.stream().filter(e -> e.getPaymentType().equals("FUIOU")).collect(Collectors.toList());
+ PaymentPoolValueDto paymentPoolValueDto = new PaymentPoolValueDto();
+ paymentPoolValueDto.setPpId(collect.get(0).getPpId());
+ paymentPoolValueDto.setCommunityId(community);
+ List<PaymentPoolValueDto> values = paymentPoolValueV1InnerServiceSMOImpl.queryPaymentPoolValues(paymentPoolValueDto);
+ Map<String, List<PaymentPoolValueDto>> payMap = values.stream().collect(Collectors.groupingBy(PaymentPoolValueDto::getColumnKey));
+ if(payMap.containsKey("FUIOU_APP_ID")){
+ smallWeChatDto.setAppId(payMap.get("FUIOU_APP_ID").get(0).getColumnValue());
+ }else{
+ smallWeChatDto.setAppId(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appId"));
+ }
+ if(payMap.containsKey("FUIOU_MCHNT_KEY")){
+ smallWeChatDto.setAppSecret(payMap.get("FUIOU_MCHNT_KEY").get(0).getColumnValue());
+ }else{
+ smallWeChatDto.setAppSecret(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appSecret"));
+ }
+ if(payMap.containsKey("FUIOU_MERCHANT_ID")){
+ smallWeChatDto.setMchId(payMap.get("FUIOU_MERCHANT_ID").get(0).getColumnValue());
+ }else{
+ smallWeChatDto.setMchId(MappingCache.getValue(MappingConstant.WECHAT_STORE_DOMAIN, "mchId"));
+ }
+ if(payMap.containsKey("FUIOU_ORDER_PRE")){
+ smallWeChatDto.setOrderPre(payMap.get("FUIOU_ORDER_PRE").get(0).getColumnValue());
+ }else{
+ smallWeChatDto.setOrderPre("1066");
+ }
+ return smallWeChatDto;
}
private String getObjName(FeeDto feeDto) {
@@ -284,50 +345,76 @@
accountDto.setAcctIds(acctIds.toArray(new String[acctIds.size()]));
List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
- if (accountDtos == null || accountDtos.size() < 1) {
+ if (ListUtil.isNull(accountDtos)) {
reqJson.put("deductionAmount", 0.0);
return 0.0;
}
BigDecimal money = new BigDecimal(0);
- BigDecimal totalAccountAmount = new BigDecimal(0);
+ BigDecimal cashMoney = new BigDecimal("0.00"); //鎶垫墸鐨勭幇閲戣处鎴�
+ BigDecimal pointsMoney = new BigDecimal(0.00); //鎶垫墸鐨勭Н鍒嗘暟
+ BigDecimal pointsMoneyNow = new BigDecimal(0.00); //绉垎杞崲涓虹幇閲戠殑瀹為檯鏁�
+ BigDecimal totalAccountAmount = new BigDecimal(0.00);
+ //鑾峰彇搴旀敹閲戦
+ BigDecimal dedAmount = new BigDecimal("0.00");
+ if (reqJson.containsKey("receivedMoney") && !StringUtil.isEmpty(reqJson.getString("receivedMoney"))) {
+ dedAmount = new BigDecimal(reqJson.getString("receivedMoney"));
+ } else {
+ dedAmount = new BigDecimal(reqJson.getString("deductionAmount"));
+ }
for (AccountDto tmpAccountDto : accountDtos) {
- if (AccountDto.ACCT_TYPE_CASH.equals(tmpAccountDto.getAcctType())) { //鐜伴噾璐︽埛
+ int compare = dedAmount.compareTo(BigDecimal.ZERO);
+ if (AccountDto.ACCT_TYPE_CASH.equals(tmpAccountDto.getAcctType()) && compare > 0) { //鐜伴噾璐︽埛
//璐︽埛閲戦
BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount());
- //鑾峰彇搴旀敹閲戦
- BigDecimal dedAmount = new BigDecimal("0.00");
- if (reqJson.containsKey("receivedMoney") && !StringUtil.isEmpty(reqJson.getString("receivedMoney"))) {
- dedAmount = new BigDecimal(reqJson.getString("receivedMoney"));
- } else {
- dedAmount = new BigDecimal(reqJson.getString("deductionAmount"));
- }
int flag = amount.compareTo(dedAmount);
+ if (flag == 1 || flag == 0) { //鐜伴噾璐︽埛澶т簬搴旀敹閲戦锛屾垨鐜伴噾璐︽埛绛変簬搴旀敹閲戦锛屽氨鐢ㄥ簲鏀堕噾棰濇姷鎵�
+ cashMoney = dedAmount;
+ dedAmount = new BigDecimal("0.0");
+ }
+ if (flag == -1) { //鐜伴噾璐︽埛灏忎簬搴旀敹閲戦锛屽氨鐢ㄧ幇閲戣处鎴锋姷鎵�
+ cashMoney = amount;
+ dedAmount = dedAmount.subtract(amount);
+ }
+ money = money.add(cashMoney);
+ } else if ("2004".equals(tmpAccountDto.getAcctType()) && compare > 0) { //绉垎璐︽埛
+ //绉垎璐︽埛鏈�澶т娇鐢ㄧН鍒�
+ String maximumNumber = CommunitySettingFactory.getValue(reqJson.getString("communityId"), MAXIMUM_NUMBER);
+ BigDecimal maxNumber = new BigDecimal(maximumNumber);
+ //绉垎璐︽埛鎶垫墸姣斾緥
+ String deductionProportion = CommunitySettingFactory.getValue(reqJson.getString("communityId"), DEDUCTION_PROPORTION);
+ BigDecimal deductionProportionNum = new BigDecimal(deductionProportion);
+ //绉垎璐︽埛閲戦
+ BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount());
+ int flag = amount.compareTo(maxNumber);
+ if (flag == -1) { //绉垎璐︽埛閲戦灏忎簬绉垎璐︽埛鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤绉垎璐︽埛鎶垫墸
+ pointsMoney = amount;
+ } else if (flag == 0) { //绉垎璐︽埛閲戦绛変簬绉垎璐︽埛鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤绉垎璐︽埛鎶垫墸
+ pointsMoney = amount;
+ } else if (flag == 1) { //绉垎璐︽埛閲戦澶т簬绉垎璐︽埛鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤鏈�澶т娇鐢ㄧН鍒嗘姷鎵�
+ pointsMoney = maxNumber;
+ }
+ //璁$畻鎶垫墸绉垎鎶垫墸鐨勯噾棰� 绉垎闄や互姣斾緥绛変簬璐︽埛鑳芥姷鎵g殑閽辨暟
+ BigDecimal integralMoney = pointsMoney.divide(deductionProportionNum);
BigDecimal redepositAmount = new BigDecimal("0.00");
- BigDecimal integralAmount = new BigDecimal("0.00");
- if (flag == 1) { //鐜伴噾璐︽埛澶т簬搴旀敹閲戦锛屽氨鐢ㄥ簲鏀堕噾棰濇姷鎵�
+ int count = integralMoney.compareTo(dedAmount);
+ if (count == 1 || count == 0) { //绉垎鎶垫墸鐨勯噾棰濆ぇ浜庡簲鏀堕噾棰濓紝鎴栫Н鍒嗘姷鎵g殑閲戦绛変簬搴旀敹閲戦锛屽氨鐢ㄥ簲鏀堕噾棰濇姷鎵�
redepositAmount = dedAmount;
- integralAmount = amount.subtract(dedAmount);
+ pointsMoney = dedAmount.multiply(deductionProportionNum);//搴旀敹閲戦涔樹互鎶垫墸姣斾緥鍗充负闇�瑕佹墸闄ょ殑绉垎鏁�
+ pointsMoneyNow = dedAmount;
+ dedAmount = new BigDecimal("0.0");
}
- if (flag > -1) { //鐜伴噾璐︽埛澶т簬绛変簬搴旀敹閲戦锛屽氨鐢ㄥ簲鏀堕噾棰濇姷鎵�
- redepositAmount = dedAmount;
- integralAmount = amount.subtract(dedAmount);
- }
- if (flag == -1) { //鐜伴噾璐︽埛灏忎簬瀹炴敹閲戦锛屽氨鐢ㄧ幇閲戣处鎴锋姷鎵�
- redepositAmount = amount;
- }
- if (flag < 1) { //鐜伴噾璐︽埛灏忎簬绛変簬搴旀敹閲戦锛屽氨鐢ㄧ幇閲戣处鎴锋姷鎵�
- redepositAmount = amount;
- }
- if (flag == 0) { //鐜伴噾璐︽埛绛変簬搴旀敹閲戦
- redepositAmount = amount;
+ if (count == -1) { //绉垎鎶垫墸鐨勯噾棰濆皬浜庡簲鏀堕噾棰濓紝灏辩敤绉垎鎶垫墸鐨勯噾棰濇姷鎵�
+ redepositAmount = integralMoney;
+ dedAmount = dedAmount.subtract(integralMoney);//鍓╀綑搴旀敹閲戦
+ pointsMoneyNow = integralMoney;
}
money = money.add(redepositAmount);
}
-// totalAccountAmount = totalAccountAmount.add(new BigDecimal(tmpAccountDto.getAmount()));
}
-
-
reqJson.put("deductionAmount", money.doubleValue());
+ reqJson.put("cashMoney", cashMoney); //鐜伴噾鎶垫墸
+ reqJson.put("pointsMoney", pointsMoney); //绉垎鎶垫墸鎵i櫎鏁�
+ reqJson.put("pointsMoneyNow", pointsMoneyNow); //绉垎鎶垫墸 瀹為檯鐜伴噾鏁�
reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos));
return money.doubleValue();
}
--
Gitblit v1.8.0