From c54b2f12e52194f2ea226b3ee4b91e5d202b1338 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期四, 03 六月 2021 16:54:16 +0800
Subject: [PATCH] 优化app 支付报错问题

---
 service-front/src/main/java/com/java110/front/smo/payment/impl/RentingToPaySMOImpl.java |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/service-front/src/main/java/com/java110/front/smo/payment/impl/RentingToPaySMOImpl.java b/service-front/src/main/java/com/java110/front/smo/payment/impl/RentingToPaySMOImpl.java
old mode 100644
new mode 100755
index e32df85..8681118
--- a/service-front/src/main/java/com/java110/front/smo/payment/impl/RentingToPaySMOImpl.java
+++ b/service-front/src/main/java/com/java110/front/smo/payment/impl/RentingToPaySMOImpl.java
@@ -6,15 +6,21 @@
 import com.java110.core.context.PageData;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.rentingConfig.RentingConfigDto;
 import com.java110.dto.rentingPool.RentingPoolDto;
 import com.java110.dto.smallWeChat.SmallWeChatDto;
 import com.java110.front.properties.WechatAuthProperties;
 import com.java110.front.smo.AppAbstractComponentSMO;
 import com.java110.front.smo.payment.IRentingToPaySMO;
+import com.java110.front.smo.payment.adapt.IPayAdapt;
 import com.java110.utils.cache.CommonCache;
+import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.ServiceConstant;
+import com.java110.utils.constant.WechatConstant;
+import com.java110.utils.factory.ApplicationContextFactory;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -104,18 +110,27 @@
         if (RentingPoolDto.STATE_TO_PAY.equals(rentingPoolDto.getState())) {
             rate = Double.parseDouble(rentingPoolDto.getServiceTenantRate());
             feeName += "(绉熷)";
-        } else if (RentingPoolDto.STATE_TO_PAY.equals(rentingPoolDto.getState())) {
+        } else if (RentingPoolDto.STATE_OWNER_TO_PAY.equals(rentingPoolDto.getState())) {
             rate = Double.parseDouble(rentingPoolDto.getServiceOwnerRate());
             feeName += "(涓氫富)";
         } else {
             throw new IllegalAccessException("褰撳墠鐘舵�佷笉鏄敮浠樼姸鎬�");
         }
-
+        String rentingFormula = rentingPoolDto.getRentingFormula();
         BigDecimal serviceDec = new BigDecimal(service);
         BigDecimal rateDec = new BigDecimal(rate);
-        double money = serviceDec.multiply(rateDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
-
-        Map result = super.java110Payment(outRestTemplate, feeName, WechatAuthProperties.TRADE_TYPE_NATIVE, orderId, money, "", smallWeChatDto);
+        double money = 0.0;
+        if (RentingConfigDto.RENTING_FORMULA_RATE.equals(rentingFormula)) {
+            BigDecimal monthMoney = new BigDecimal(rentingPoolDto.getPrice());
+            money = serviceDec.multiply(rateDec).multiply(monthMoney).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        } else {
+            money = serviceDec.multiply(rateDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        }
+        String payAdapt = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_ADAPT);
+        payAdapt = StringUtil.isEmpty(payAdapt) ? DEFAULT_PAY_ADAPT : payAdapt;
+        //鏀粯閫傞厤鍣�
+        IPayAdapt tPayAdapt = ApplicationContextFactory.getBean(payAdapt, IPayAdapt.class);
+        Map result = tPayAdapt.java110Payment(outRestTemplate, feeName, WechatAuthProperties.TRADE_TYPE_NATIVE, orderId, money, "", smallWeChatDto, wechatAuthProperties.getRentingNotifyUrl());
         result.put("money", money);
         responseEntity = new ResponseEntity(JSONObject.toJSONString(result), HttpStatus.OK);
         if (!"0".equals(result.get("code"))) {

--
Gitblit v1.8.0