Sfoglia il codice sorgente

访问平安微服务方式的调整

yujia 8 anni fa
parent
commit
4a77e4e41c

+ 15 - 0
src/main/java/com/uas/platform/b2c/core/config/SysConf.java

@@ -154,6 +154,12 @@ public class SysConf {
 	@Value("#{sys.searchUrl}")
 	private String messageServiceIp;
 
+	/**
+	 * 平安微服务访问的地址
+	 */
+	@Value("#{sys.pingAnUrl}")
+	private String pingAnUrl;
+
 	public Boolean getRebuildIndexesOnRefresh() {
 		return rebuildIndexesOnRefresh;
 	}
@@ -333,4 +339,13 @@ public class SysConf {
 	public void setYesGateway(String yesGateway) {
 		this.yesGateway = yesGateway;
 	}
+
+	public String getPingAnUrl() {
+		return pingAnUrl;
+	}
+
+	public SysConf setPingAnUrl(String pingAnUrl) {
+		this.pingAnUrl = pingAnUrl;
+		return this;
+	}
 }

+ 19 - 0
src/main/java/com/uas/platform/b2c/fa/payment/constant/PingAnRequestUrlPostfix.java

@@ -0,0 +1,19 @@
+package com.uas.platform.b2c.fa.payment.constant;
+
+/**
+ * 平安微服务的后缀接口
+ *
+ * @author yuj 2018-01-10 16:55
+ */
+public class PingAnRequestUrlPostfix {
+
+    /**
+     * 平安见证宝系统开户的接口
+     */
+    public static final String PINGANOPENACCOUNT = "/pingan/account/openAccount";
+
+    /**
+     * 获取见证宝系统资金汇总账户信息
+     */
+    public static final String PINGANGETBASEACCOUNTINFO = "/pingan/account/base/account";
+}

+ 6 - 13
src/main/java/com/uas/platform/b2c/fa/payment/controller/BankReceiptsController.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
 import com.uas.platform.b2c.fa.payment.service.BankReceiptsService;
 import com.uas.platform.core.logging.BufferedLoggerManager;
+import com.uas.sso.common.IpHelper;
 import org.apache.http.HttpStatus;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -60,6 +61,7 @@ public class BankReceiptsController {
     }
 
     /**
+     * 微信预支付的接口,银联快捷支付的短信接口
      *
      * @param json 传入的数据
      *            currency 币别 RMB 3个字符
@@ -113,23 +115,14 @@ public class BankReceiptsController {
 
 
     @RequestMapping(value = "/test/eBank", method = RequestMethod.POST)
-    public HttpServletResponse testPay(HttpServletRequest request, HttpServletResponse response) {
+    public void testPay(HttpServletRequest request, HttpServletResponse response) {
+        String ipAddr = IpHelper.getIpAddr(request);
+        System.out.println(ipAddr);
         response.setStatus(HttpStatus.SC_OK);
-        return response;
+        System.out.println("ok");
     }
 
 
-    /**
-     * 微信预支付的接口
-     *
-     * @param json  传入的支付信息
-     * @return String
-     */
-    @RequestMapping(value = "/weChat/prePay", method = RequestMethod.POST)
-    public String weChatPrePay(@RequestBody JSONObject json) {
-        return bankReceiptsService.weChatPrePay(json);
-    }
-
     /**
      *
      * 微信支付的接口

+ 1 - 11
src/main/java/com/uas/platform/b2c/fa/payment/service/BankReceiptsService.java

@@ -1,7 +1,6 @@
 package com.uas.platform.b2c.fa.payment.service;
 
 import com.alibaba.fastjson.JSONObject;
-import org.springframework.web.bind.annotation.RequestBody;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -57,20 +56,11 @@ public interface BankReceiptsService {
     String eBankPay(JSONObject json, Boolean isPersonal);
 
 
-    /**
-     * 微信预支付的接口
-     *
-     * @param json  传入的支付信息
-     * @return String
-     */
-    String weChatPrePay(JSONObject json);
-
-
     /**
      *
      * 微信支付的接口
      * @param json  传入的数据
      * @return String
      */
-    String weChatPay(@RequestBody JSONObject json);
+    String weChatPay(JSONObject json);
 }

+ 15 - 16
src/main/java/com/uas/platform/b2c/fa/payment/service/impl/BankReceiptsServiceImpl.java

@@ -9,7 +9,6 @@ import com.uas.platform.b2c.fa.payment.support.UserInfoSupport;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.client.RestTemplate;
 
 import javax.servlet.http.HttpServletRequest;
@@ -148,10 +147,10 @@ public class BankReceiptsServiceImpl implements BankReceiptsService {
             map.put(PingAnField.VERIFYCODE, verifyCode);
         } else {
             map.putAll(infoMap);
-            map.put(PingAnField.ORDERID, "200031114620180109UHTX1CS0");
+            map.put(PingAnField.ORDERID, "200031114620180109UJRBAWB0");
             map.put(PingAnField.CURRENCY, "RMB");
             map.put("amount", "10.00");
-            map.put("paydate", "20180109112109");
+            map.put("paydate", "20180109195546");
             map.put("customerId", "19901120");
             map.put("verifyCode", "111111");
             map.put("issInsCode", "HXB");
@@ -204,17 +203,6 @@ public class BankReceiptsServiceImpl implements BankReceiptsService {
         return loadHtml;
     }
 
-    /**
-     * 微信预支付的接口
-     *
-     * @param json 传入的支付信息
-     * @return String
-     */
-    @Override
-    public String weChatPrePay(JSONObject json) {
-        return null;
-    }
-
     /**
      * 微信支付的接口
      *
@@ -222,7 +210,18 @@ public class BankReceiptsServiceImpl implements BankReceiptsService {
      * @return String
      */
     @Override
-    public String weChatPay(@RequestBody JSONObject json) {
-        return null;
+    public String weChatPay(JSONObject json) {
+        HashMap<String, String> map = new HashMap<>();
+        if (json == null || json.size() == 0) {
+            map.put("orderId", "200031114620180109UJZMZWY0");
+            map.put("currency", "RMB");
+            map.put("amount", "10.00");
+            map.put("objectName", "");
+            map.put("paydate", "20180109220355");
+        } else {
+            //TODO
+        }
+        String loadHtml = restTemplate.postForObject("http://192.168.253.119:20280/weChat/pay", map, String.class);
+        return loadHtml;
     }
 }

+ 8 - 3
src/main/java/com/uas/platform/b2c/fa/payment/service/impl/PingAnAccountServiceImpl.java

@@ -1,5 +1,7 @@
 package com.uas.platform.b2c.fa.payment.service.impl;
 
+import com.uas.platform.b2c.core.config.SysConf;
+import com.uas.platform.b2c.fa.payment.constant.PingAnRequestUrlPostfix;
 import com.uas.platform.b2c.fa.payment.service.PingAnAccountService;
 import com.uas.platform.b2c.fa.payment.support.UserInfoSupport;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,10 +22,13 @@ public class PingAnAccountServiceImpl implements PingAnAccountService {
 
     private final RestTemplate restTemplate;
 
+    private final SysConf sysConf;
+
     @Autowired
-    public PingAnAccountServiceImpl(UserInfoSupport userInfoSupport, RestTemplate restTemplate) {
+    public PingAnAccountServiceImpl(UserInfoSupport userInfoSupport, RestTemplate restTemplate, SysConf sysConf) {
         this.userInfoSupport = userInfoSupport;
         this.restTemplate = restTemplate;
+        this.sysConf = sysConf;
     }
 
     /**
@@ -35,7 +40,7 @@ public class PingAnAccountServiceImpl implements PingAnAccountService {
     @Override
     public String openAccount(Boolean isPersonal) {
         Map<String, String> userInfoMap = userInfoSupport.getUserInfoMap(isPersonal);
-        String resultStr = restTemplate.postForObject("http://192.168.253.119:20280/pingan/account/openAccount", userInfoMap, String.class);
+        String resultStr = restTemplate.postForObject(sysConf.getPingAnUrl() + PingAnRequestUrlPostfix.PINGANOPENACCOUNT, userInfoMap, String.class);
         return resultStr;
     }
 
@@ -46,7 +51,7 @@ public class PingAnAccountServiceImpl implements PingAnAccountService {
      */
     @Override
     public String getBaseAccountInfo() {
-        String resultStr = restTemplate.postForObject("http://192.168.253.119:20280/pingan/base/account", null, String.class);
+        String resultStr = restTemplate.postForObject(sysConf.getPingAnUrl() + PingAnRequestUrlPostfix.PINGANGETBASEACCOUNTINFO, null, String.class);
         return resultStr;
     }
 

+ 2 - 0
src/main/resources/dev/sys.properties

@@ -42,3 +42,5 @@ messageServiceIp=http://message.ubtob.com/
 
 # Kafka
 kafka-bootstrap-servers=10.10.100.11:9292,10.10.100.12:9292,10.10.100.13:9292,10.10.100.14:9292,10.10.100.15:9292,10.10.100.16:9292
+# \u5E73\u5B89\u5FAE\u670D\u52A1\u8BBF\u95EE\u7684\u5730\u5740
+pingAnUrl = http://192.168.253.119:20280

+ 3 - 0
src/main/resources/prod/sys.properties

@@ -44,3 +44,6 @@ messageServiceIp=http://message.ubtob.com/
 
 # Kafka
 kafka-bootstrap-servers=10.10.100.11:9292,10.10.100.12:9292,10.10.100.13:9292,10.10.100.14:9292,10.10.100.15:9292,10.10.100.16:9292
+
+# \u5E73\u5B89\u5FAE\u670D\u52A1\u8BBF\u95EE\u7684\u5730\u5740
+pingAnUrl = http://192.168.253.119:20280

+ 3 - 0
src/main/resources/test/sys.properties

@@ -43,3 +43,6 @@ messageServiceIp=http://message.ubtob.com/
 
 # Kafka
 kafka-bootstrap-servers=10.10.100.11:9292,10.10.100.12:9292,10.10.100.13:9292,10.10.100.14:9292,10.10.100.15:9292,10.10.100.16:9292
+
+# \u5E73\u5B89\u5FAE\u670D\u52A1\u8BBF\u95EE\u7684\u5730\u5740
+pingAnUrl = http://192.168.253.119:20280

+ 1 - 0
src/main/webapp/WEB-INF/spring/webmvc.xml

@@ -95,6 +95,7 @@
 		<mvc:interceptor>
 			<mvc:mapping path="/**"/>
 			<mvc:exclude-mapping path="/WEB-INF/**" />
+			<mvc:exclude-mapping path="/bankReceipts/test/**"/>
 			<mvc:exclude-mapping path="/**/static/**" />
 			<mvc:exclude-mapping path="/" />
 			<mvc:exclude-mapping path="/login/**" />