huangct 8 лет назад
Родитель
Сommit
b74f185fb8

+ 65 - 7
donate-service/src/main/java/com/uas/service/donate/controller/AlipayController.java

@@ -10,9 +10,11 @@ import com.alipay.api.domain.AlipayTradeWapPayModel;
 import com.alipay.api.internal.util.AlipaySignature;
 import com.alipay.api.request.AlipaySystemOauthTokenRequest;
 import com.alipay.api.request.AlipayTradeAppPayRequest;
+import com.alipay.api.request.AlipayTradeQueryRequest;
 import com.alipay.api.request.AlipayUserInfoShareRequest;
 import com.alipay.api.response.AlipaySystemOauthTokenResponse;
 import com.alipay.api.response.AlipayTradeAppPayResponse;
+import com.alipay.api.response.AlipayTradeQueryResponse;
 import com.alipay.api.response.AlipayUserInfoShareResponse;
 import com.uas.platform.core.util.HttpUtil;
 import com.uas.platform.core.util.serializer.FlexJsonUtils;
@@ -34,6 +36,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -281,6 +284,8 @@ public class AlipayController {
             String notifySellerId = params.get("seller_id") == null ? "" : params.get("seller_id");
             String notifySellerEmail = params.get("seller_email") == null ? "" : params.get("seller_id");
 
+            System.out.print("*************************异步通知********************************* 商户订单号:" + notifyOutTradeNo);
+
             //商户系统订单支付状态
             short projectRecodePayStatus = 1;
             if ("TRADE_SUCCESS".equals(notifyTradeStatus)) {
@@ -356,7 +361,8 @@ public class AlipayController {
      */
     @ResponseBody
     @RequestMapping("/returnUrl")
-    public String returnUrl(HttpServletRequest request){
+    public ModelAndView returnUrl(HttpServletRequest request, HttpServletResponse response){
+        ModelAndView modelAndView = new ModelAndView();
         Map<String, String> params = AlipayApi.toMap(request);
         String data = AlipayApi.getRequestData(request); // data json格式
         System.out.print(data);
@@ -364,21 +370,70 @@ public class AlipayController {
         try {
             signVerified = AlipaySignature.rsaCheckV1(params, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.CHARSET, AlipayConfig.SIGNTYPE);
         } catch (AlipayApiException e) {
-            System.out.print("fail");
-            return "fail";
+            //TODO 此处让用户自己判断有没有支付成功。
         }
 
         if(signVerified){
             // TODO 验签成功后,按照支付结果异步通知中的描述,对支付结果中的业务内容进行二次校验,校验成功后在response中返回success并继续商户自身业务处理,校验失败返回failure
-            System.out.print("success");
-            return data;
+            String notifyOutTradeNo = params.get("out_trade_no");//通知返回的商户订单号
+            String notifyTradeNo = params.get("trade_no");//通知返回的支付宝交易号
+            AlipayTradeQueryResponse tradeQueryResponse = queryTrade(notifyOutTradeNo, notifyTradeNo);
+
+            if (tradeQueryResponse == null) {
+                //TODO 提示系统繁忙(其实是查询支付宝订单报错)
+            } else {
+                if ("10000".equals(tradeQueryResponse.getCode())) {
+                    if ("TRADE_SUCCESS".equals(tradeQueryResponse.getTradeStatus())) {
+                        String url = "/project#/donationsOver/" +  notifyOutTradeNo;
+                        modelAndView.setViewName("redirect:" + url);
+                    }
+                    //TODO 其他状态判断
+                } else {
+                }
+            }
+
         }else{
+            //TODO 此处让用户自己判断有没有支付成功。
             // TODO 验签失败则记录异常日志,并在response中返回failure.
-            System.out.print("fail");
-            return "fail";
         }
+        return modelAndView;
     }
 
+    /**
+     * 查询支付宝订单
+     * @param outTradeNo
+     * @param tradeNo
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping(value = "/queryTrade", method = RequestMethod.GET)
+    public AlipayTradeQueryResponse queryTrade(String outTradeNo, String tradeNo){
+        AlipayTradeQueryRequest tradeQueryRequest = new AlipayTradeQueryRequest();
+        tradeQueryRequest.setBizContent("{" +
+                "\"out_trade_no\":" + outTradeNo + "," +
+                "\"trade_no\":" + tradeNo +
+                "}");
+        AlipayTradeQueryResponse tradeQueryResponse = null;
+        try {
+            tradeQueryResponse = alipayClient.execute(tradeQueryRequest);
+        } catch (AlipayApiException e) {
+            e.printStackTrace();
+            return null;
+        }
+
+        return tradeQueryResponse;
+    }
+
+
+
+
+
+
+
+
+
+
+
     /**
      * 判断是否需要用户授权获取会员信息
      */
@@ -396,6 +451,9 @@ public class AlipayController {
 
     /**
      * 拼接用户授权接口url
+     * https://docs.open.alipay.com/289/105656
+     * https://docs.open.alipay.com/284/106001
+     *
      * 正式url拼接规则:https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=APPID&scope=SCOPE&redirect_uri=ENCODED_URL
      * 沙箱url拼接规则:https://openauth.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=APPID&scope=SCOPE&redirect_uri=ENCODED_URL
      */

+ 1 - 1
donate-service/src/main/java/com/uas/service/donate/model/MicroServicesConf.java

@@ -29,7 +29,7 @@ public class MicroServicesConf {
     /**
      * 轮播
      */
-    @Value("#{'10.10.101.23'}")
+    @Value("#{'10.10.100.23'}")
     private String carouselMicroServiceIp;
 
   /*  public String getMicroServiceIp() {

+ 1 - 1
donate-service/src/main/resources/templates/index.ftl

@@ -722,7 +722,7 @@
             <div class="list-item clearfix" id="projectList">
                 <div>
                 <div class="project-img fl">
-                    <a href="projectDetailsAndProgress"><img src="${project.pcImg!''}" alt=""/></a>
+                    <a href="/project#/detail/${project.id}"><img src="${project.pcImg!''}" alt=""/></a>
                 </div>
                 <div class="project-detail fl">
                     <p><a href="projectDetailsAndProgress">${project.name!''}</a></p>

+ 20 - 1
donate-service/src/main/webapp/resources/js/project/app.js

@@ -56,7 +56,12 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'commo
             templateUrl: "static/view/project/launch_project_3.html",
             controller: "ProjectNewCtrl",
             controllerUrl: "app/controllers/ProjectNewCtrl"
-        }));
+        })).state("paySucccess", {
+            url : '/donationsOver/:tradeNo',
+            title : '支付完成',
+            templateUrl : 'static/view/project/donationsOver.html',
+            controller : 'donationsOverCtrl'
+        });
 	}]);
 
 	// app.run(['$rootScope', 'BaseService', 'StoreInfo', function($rootScope, BaseService, StoreInfo) {
@@ -68,5 +73,19 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'commo
 	//
 	// }]);
 
+    app.controller('donationsOverCtrl', ['$scope', '$stateParams', '$http', function ($scope, $stateParams, $http) {
+        var loadData = function () {
+            var tradeNo = $stateParams.tradeNo;
+            $http.get('/projectrecode/detail/' + tradeNo, {
+            }).success(function (data) {
+                $scope.projectRecode = data;
+            }).error(function () {
+                alert("查询支付结果出错");
+            });
+
+        };
+        loadData();
+    }]);
+
 	return app;
 });

+ 199 - 0
donate-service/src/main/webapp/resources/view/project/donationsOver.html

@@ -0,0 +1,199 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <title>捐款完成!-一元捐</title>
+    <meta name="keywords" content="">
+    <meta name="description" content="">
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <meta name="renderer" content="webkit">
+    <!--css begin-->
+    <link href="/static/images/icon/u.png" rel="icon" type="image/x-icon" />
+    <link rel="stylesheet" href="/static/lib/bootstrap/css/bootstrap.min.css">
+    <link rel="stylesheet" href="/static/css/base.css">
+    <style>
+        body{
+            font-family: "Microsoft Yahei", "微软雅黑";
+            box-sizing: border-box;
+        }
+        .fl{
+            float: left;
+        }
+        .fr{
+            float: right;
+        }
+        .clearfix {
+            clear: both;
+        }
+        /*头部导航*/
+        #nav{
+            width: 100%;
+            margin: 0 auto;
+            background: #474443;
+        }
+        #nav .container{
+            margin: 0 auto;
+            padding: 0;
+            width: 1140px;
+            height: 60px;
+            line-height: 60px;
+            text-align: center;
+        }
+        #nav .fl{
+            position: relative;
+        }
+        #nav .fl img{
+            margin-right: 32px;
+            width: 65px;
+            height: 22px;
+        }
+        #nav .fl span{
+            font-size: 16px;
+            color: #fff;
+        }
+        #nav .fl span:before{
+            content: '';
+            position: absolute;
+            top: 25px;
+            left: 80px;
+            width: 1px;
+            height: 14px;
+            background: #a0a0a0;
+        }
+        #nav .fl a.return{
+            margin-left: 28px;
+            font-size: 12px;
+            color: #b4b4b4;
+            text-decoration: none;
+        }
+        #nav .fr a{
+            margin-right: 45px;
+            font-size: 14px;
+            color: #fff;
+        }
+        #nav .fr a:last-child {
+            margin-right: 0;
+        }
+        .main{
+            width: 100%;
+            margin: 24px 0 150px 0;
+        }
+        .main .container{
+            width: 1140px;
+            margin: 0 auto;
+            padding: 0;
+        }
+        .main .section{
+            width: 100%;
+            overflow: hidden;
+            text-align: center;
+            margin: 0 auto;
+        }
+        .main .section .section-top{
+            text-align: center;
+            margin: 45px 0 55px 0;
+        }
+        .main .section .section-top img{
+            margin: -15px 25px 0 0;
+            width: 55px;
+            height: 55px;
+        }
+        .main .section .section-top span{
+            font-size: 28px;
+            color: #323232;
+        }
+        .main .section .section-top span em{
+            font-size: 28px;
+            color: #47b260;
+        }
+        .main .section .section-bottom{
+            margin: 0 auto;
+            padding: 25px 0 0px 40px;
+            width: 980px;
+            height: 140px;
+            background: #f1f8f1;
+            text-align: left;
+            border: 1px solid #dcdcdc;
+        }
+        .main .section .section-bottom .item{
+            width: 350px;
+            margin-right: 90px;
+        }
+        .main .section .section-bottom .item:last-child{
+            margin-right: 0;
+        }
+        .main .section .section-bottom .item p{
+            font-size: 14px;
+            color: #333333;
+        }
+        .main .section .section-bottom .item p:nth-last-of-type(2) {
+            margin: 20px 0;
+        }
+        .main .section div.txt{
+            margin: 43px 0 46px 0;
+            font-size: 16px;
+            color: #323232;
+        }
+        .main .section .txt span{
+            margin: 0 5px;
+            font-size: 16px;
+            color: #ff6000;
+        }
+        .main .section .txt a{
+            margin-left: 10px;
+            font-size: 16px;
+            color: #0651e8;
+        }
+        .main .section div.return{
+            width: 100%;
+            margin: 0 auto;
+            margin-top: 40px;
+            text-align: center;
+        }
+        .main .section .return a{
+            display: inline-block;
+            width: 140px;
+            height: 36px;
+            line-height: 36px;
+            font-size: 16px;
+            color: #323232;
+            border: 1px solid #dcdcdc;
+        }
+    </style>
+</head>
+<body>
+<!--
+<div ng-include src="'static/view/common/nav.html'"></div>
+-->
+<div class="main">
+    <div class="container">
+        <div class="section">
+            <div class="section-top">
+                <span property="testCode"></span>
+                <img src="/static/images/over01.png" alt=""/><span>感谢您的爱心,<em></em>捐款完成!</span>
+            </div>
+            <div class="section-bottom clearfix">
+                <div class="item fl">
+                    <p>捐款金额:{{projectRecode.amount}}元</p>
+                    <p>捐款项目:{{projectRecode.projectName}}</p>
+                    <p>捐款时间:{{projectRecode.time | date:'yyyy-MM-dd HH:mm:ss'}}</p>
+                </div>
+                <div class="item fl">
+                    <p>捐款方式:{{projectRecode.way}}</p>
+                    <p>执行机构:{{projectRecode.orgName}}</p>
+                    <p>参与活动:</p>
+                </div>
+            </div>
+            <div class="txt">捐款成功后自动参与<span>【优软一元捐感恩回馈07】</span>活动,将有机会获得丰厚奖品。<a href="">立即查看</a></div>
+            <div class="return"><a href="/">返回首页</a></div>
+        </div>
+    </div>
+</div>
+<!--js begin-->
+<script src="/static/lib/jquery/jquery.min.js"></script>
+<script src="/static/lib/bootstrap/js/bootstrap.min.js"></script>
+<script>
+</script>
+</body>
+</html>