Browse Source

支付接口imid参数引入

huangct 8 years ago
parent
commit
0a06cd1da7

+ 15 - 3
donate-service/src/main/java/com/uas/service/donate/controller/AlipayController.java

@@ -519,11 +519,23 @@ public class AlipayController {
     }
 
     private ProjectRecode createProjectRecode(String jsonStr) throws Exception {
-        ProjectRecode projectRecode= JSONObject.parseObject(jsonStr,ProjectRecode.class);
-        
+        JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+        String imid = jsonObject.getString("imid");
+        logger.info("移动端imid=" + imid);
+        String uuid = null;
         User user = SystemSession.getUser();
         if (user != null) {
-            projectRecode.setUuid(user.getUserUU());
+            uuid = user.getUserUU().toString();
+        }
+
+        if (!StringUtils.isEmpty(imid)) {
+            jsonObject.remove("imid");
+            //TODO 通过imid获取uuid
+        }
+
+        ProjectRecode projectRecode= JSONObject.parseObject(jsonStr,ProjectRecode.class);
+        if (!StringUtils.isEmpty(uuid)) {
+            projectRecode.setUuid(Long.parseLong(uuid));
         }
 
         projectRecode.setTime(new Date());

+ 10 - 10
donate-service/src/main/webapp/resources/js/pay.js

@@ -10,7 +10,7 @@
 const userAgent = navigator.userAgent;
 const isMobile = /(iPhone|iPad|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)/ig.test(userAgent);
 
-var pay =function (proId, amount, payWay, uuid) {
+var pay =function (proId, amount, payWay, imid) {
      var customAmount = $("#custom-amount" + proId).val();
     if ($.trim(customAmount) != "") {
         var reg = "^(([0-9]+\.[0-9]{1,2})|([0-9]*[1-9][0-9]*\.[0-9]{1,2})|([0-9]*[1-9][0-9]*))$";
@@ -41,17 +41,17 @@ var pay =function (proId, amount, payWay, uuid) {
 
     //获取支付方式
     if(payWay == "支付宝") {
-        aliPay(proId, amount, payWay, uuid);
+        aliPay(proId, amount, payWay, imid);
     } else if (payWay == "微信支付") {
-        wxPay(proId, amount, payWay, uuid);
+        wxPay(proId, amount, payWay, imid);
     } else if (payWay == "网银支付") {
         unionPay();
     }
 }
 
 
-var wxPay = function (proId, amount, payWay, uuid) {
-    var jsonStr = getJson(proId, amount, payWay, uuid);
+var wxPay = function (proId, amount, payWay, imid) {
+    var jsonStr = getJson(proId, amount, payWay, imid);
 
     //公众号支付js模板 需引入http://res.wx.qq.com/open/js/jweixin-1.0.0.js
     //对浏览器的UserAgent进行正则匹配,不含有微信独有标识的则为其他浏览器
@@ -111,8 +111,8 @@ var wxPay = function (proId, amount, payWay, uuid) {
     }
 }
 
-var aliPay = function (proId, amount, payWay, uuid) {
-    var jsonStr = getJson(proId, amount, payWay, uuid);
+var aliPay = function (proId, amount, payWay, imid) {
+    var jsonStr = getJson(proId, amount, payWay, imid);
     var url = "/alipay/pcPay";
 
     if (isMobile) {
@@ -192,8 +192,8 @@ var webPay = function (jsonStr) {
     // }).success();
 }
 
-var getJson = function (proId, amount, payWay, uuid) {
-    if (typeof uuid == 'undefined') {
+var getJson = function (proId, amount, payWay, imid) {
+    if (typeof imid == 'undefined') {
         return jsonStr = "{proId:" + proId + "," +
             "amount:" + amount + "," +
             "way:" + "\"" + payWay + "\"" +
@@ -202,7 +202,7 @@ var getJson = function (proId, amount, payWay, uuid) {
         return jsonStr = "{proId:" + proId + "," +
             "amount:" + amount + "," +
             "way:" + "\"" + payWay + "\"" + "," +
-            "uuid:" + uuid +
+            "imid:" + imid +
             "}";
     }