From fe3b0f4a3c46892f08421dd4c4d0937fb8a87f93 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期二, 06 六月 2023 17:55:10 +0800
Subject: [PATCH] 优化代码
---
service-acct/src/main/java/com/java110/acct/payment/adapt/pingan/PinganPaymentFactoryAdapt.java | 64 ++++++++++++++++++--------------
1 files changed, 36 insertions(+), 28 deletions(-)
diff --git a/service-acct/src/main/java/com/java110/acct/payment/adapt/pingan/PinganPaymentFactoryAdapt.java b/service-acct/src/main/java/com/java110/acct/payment/adapt/pingan/PinganPaymentFactoryAdapt.java
index 45c52ed..cec8ca9 100644
--- a/service-acct/src/main/java/com/java110/acct/payment/adapt/pingan/PinganPaymentFactoryAdapt.java
+++ b/service-acct/src/main/java/com/java110/acct/payment/adapt/pingan/PinganPaymentFactoryAdapt.java
@@ -8,16 +8,16 @@
import com.java110.core.log.LoggerFactory;
import com.java110.dto.app.AppDto;
import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.payment.NotifyPaymentOrderDto;
import com.java110.dto.payment.PaymentOrderDto;
import com.java110.dto.smallWeChat.SmallWeChatDto;
import com.java110.intf.store.ISmallWechatV1InnerServiceSMO;
import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
import com.java110.utils.cache.MappingCache;
+import com.java110.utils.cache.UrlCache;
+import com.java110.utils.constant.MappingConstant;
import com.java110.utils.constant.WechatConstant;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.utils.util.DateUtil;
-import com.java110.utils.util.PayUtil;
+import com.java110.utils.util.*;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
@@ -89,29 +89,34 @@
String appId = context.getReqHeaders().get("app-id");
String userId = context.getReqHeaders().get("user-id");
String tradeType = reqJson.getString("tradeType");
- String notifyUrl = MappingCache.getValue("OWNER_WECHAT_URL") + "/app/payment/notify/wechat/992020011134400001";
+ String notifyUrl = UrlCache.getOwnerUrl() + "/app/payment/notify/wechat/992020011134400001/"+smallWeChatDto.getObjId();
- String appType = OwnerAppUserDto.APP_TYPE_WECHAT_MINA;
- if (AppDto.WECHAT_OWNER_APP_ID.equals(appId)) {
- appType = OwnerAppUserDto.APP_TYPE_WECHAT;
- } else if (AppDto.WECHAT_MINA_OWNER_APP_ID.equals(appId)) {
- appType = OwnerAppUserDto.APP_TYPE_WECHAT_MINA;
- } else {
- appType = OwnerAppUserDto.APP_TYPE_APP;
+ String openId = reqJson.getString("openId");
+
+ if(StringUtil.isEmpty(openId)) {
+ String appType = OwnerAppUserDto.APP_TYPE_WECHAT_MINA;
+ if (AppDto.WECHAT_OWNER_APP_ID.equals(appId)) {
+ appType = OwnerAppUserDto.APP_TYPE_WECHAT;
+ } else if (AppDto.WECHAT_MINA_OWNER_APP_ID.equals(appId)) {
+ appType = OwnerAppUserDto.APP_TYPE_WECHAT_MINA;
+ } else {
+ appType = OwnerAppUserDto.APP_TYPE_APP;
+ }
+
+ OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+ ownerAppUserDto.setUserId(userId);
+ ownerAppUserDto.setAppType(appType);
+ List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+
+ Assert.listOnlyOne(ownerAppUserDtos, "鏈壘鍒板紑鏀捐处鍙蜂俊鎭�");
+ openId = ownerAppUserDtos.get(0).getOpenId();
}
-
- OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
- ownerAppUserDto.setUserId(userId);
- ownerAppUserDto.setAppType(appType);
- List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
-
- Assert.listOnlyOne(ownerAppUserDtos, "鏈壘鍒板紑鏀捐处鍙蜂俊鎭�");
logger.debug("銆愬皬绋嬪簭鏀粯銆� 缁熶竴涓嬪崟寮�濮�, 璁㈠崟缂栧彿=" + paymentOrderDto.getOrderId());
SortedMap<String, String> resultMap = new TreeMap<String, String>();
//鐢熸垚鏀粯閲戦锛屽紑鍙戠幆澧冨鐞嗘敮浠橀噾棰濇暟鍒�0.01銆�0.02銆�0.03鍏�
- double payAmount = PayUtil.getPayAmountByEnv(MappingCache.getValue("HC_ENV"), paymentOrderDto.getMoney());
+ double payAmount = PayUtil.getPayAmountByEnv(MappingCache.getValue(MappingConstant.ENV_DOMAIN,"HC_ENV"), paymentOrderDto.getMoney());
//娣诲姞鎴栨洿鏂版敮浠樿褰�(鍙傛暟璺熻繘鑷繁涓氬姟闇�姹傛坊鍔�)
JSONObject resMap = null;
@@ -119,7 +124,7 @@
paymentOrderDto.getOrderId(),
tradeType,
payAmount,
- ownerAppUserDtos.get(0).getOpenId(),
+ openId,
smallWeChatDto,
notifyUrl
);
@@ -196,8 +201,8 @@
@Override
- public PaymentOrderDto java110NotifyPayment(String param) {
-
+ public PaymentOrderDto java110NotifyPayment(NotifyPaymentOrderDto notifyPaymentOrderDto) {
+ String param = notifyPaymentOrderDto.getParam();
PaymentOrderDto paymentOrderDto = new PaymentOrderDto();
JSONObject resJson = new JSONObject();
@@ -210,7 +215,7 @@
if ("000000".equals(resultCode)) {
//鏇存柊鏁版嵁
- int result = confirmPayFee(map, paymentOrderDto);
+ int result = confirmPayFee(map, paymentOrderDto,notifyPaymentOrderDto);
if (result > 0) {
//鏀粯鎴愬姛
resJson.put("result_code", "000000");
@@ -225,8 +230,8 @@
return paymentOrderDto;
}
- public int confirmPayFee(JSONObject map, PaymentOrderDto paymentOrderDto) {
- String appId;
+ public int confirmPayFee(JSONObject map, PaymentOrderDto paymentOrderDto,NotifyPaymentOrderDto notifyPaymentOrderDto) {
+ String appId = null;
//鍏煎 娓竵浜ゆ槗鏃� 鎴栬�呭井淇℃湁鏃朵笉浼氭帀鍙傛暟鐨勯棶棰�
if (map.containsKey("wId")) {
String wId = map.get("wId").toString();
@@ -246,6 +251,7 @@
//String appId = WechatFactory.getAppId(wId);
JSONObject paramIn = new JSONObject();
paramIn.put("appId", appId);
+ paramIn.put("communityId",notifyPaymentOrderDto.getCommunityId());
SmallWeChatDto smallWeChatDto = getSmallWechat(paramIn);
String sign = createSign(map, smallWeChatDto.getPayPassword());
@@ -273,8 +279,10 @@
smallWeChatDto = new SmallWeChatDto();
smallWeChatDto.setAppId(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appId"));
smallWeChatDto.setAppSecret(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appSecret"));
- smallWeChatDto.setMchId(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "mchId"));
- smallWeChatDto.setPayPassword(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "key"));
+ smallWeChatDto.setMchId(MappingCache.getValue(MappingConstant.WECHAT_STORE_DOMAIN, "mchId"));
+ smallWeChatDto.setPayPassword(MappingCache.getValue(MappingConstant.WECHAT_STORE_DOMAIN, "key"));
+ smallWeChatDto.setObjId(paramIn.getString("communityId"));
+
return smallWeChatDto;
}
--
Gitblit v1.8.0