Browse Source

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	donate-service/src/main/webapp/resources/js/mobile/app.js
#	donate-service/src/main/webapp/resources/js/mobile/controllers/MobileProjectDetailCtrl.js
dongbw 8 years ago
parent
commit
cd04501255

+ 17 - 8
donate-service/src/main/java/com/uas/service/donate/controller/WxpayController.java

@@ -93,7 +93,7 @@ public class WxpayController {
         }
 
         WxPayUnifiedOrderRequest wxPayUnifiedOrderRequest = createWxPayUnifiedOrderRequest(request, projectRecode, WxPayConstants.TradeType.NATIVE);
-        Map map = unifiedOrder(wxPayUnifiedOrderRequest);
+        Map map = unifiedOrder(wxPayUnifiedOrderRequest, null);
         if ("FAIL".equals(map.get("status"))) {
             modelMap.put("error", map.get("message"));
         } else {
@@ -101,7 +101,6 @@ public class WxpayController {
             modelMap.put("outTradeNo", projectRecode.getId());
         }
 
-
         return modelMap;
     }
 
@@ -157,7 +156,7 @@ public class WxpayController {
             wxPayUnifiedOrderRequest.setSubOpenid(openId);//否是 trade_type=JSAPI,此参数必传,用户在子商户appid下的唯一标识。openid和sub_openid可以选传其中之一,如果选择传sub_openid,则必须传sub_appid。
         }
 
-        Map map = unifiedOrder(wxPayUnifiedOrderRequest);
+        Map map = unifiedOrder(wxPayUnifiedOrderRequest, null);
 
         if ("FAIL".equals(map.get("status"))) {
             modelMap.put("error", map.get("message"));
@@ -201,7 +200,7 @@ public class WxpayController {
      */
     @ResponseBody
     @RequestMapping(value = "/wapPay", method = RequestMethod.POST)
-    public ModelMap wapPay(@RequestParam("jsonStr") String jsonStr, HttpServletRequest request, HttpServletResponse response) throws Exception {
+    public ModelMap wapPay(@RequestParam("jsonStr") String jsonStr, @RequestParam("currentUrl") String currentUrl, HttpServletRequest request, HttpServletResponse response) throws Exception {
         ModelMap modelMap = new ModelMap();
         ProjectRecode projectRecode= null;
         try {
@@ -213,7 +212,7 @@ public class WxpayController {
         }
 
         WxPayUnifiedOrderRequest wxPayUnifiedOrderRequest = createWxPayUnifiedOrderRequest(request, projectRecode, WxPayConstants.TradeType.MWEB);
-        Map map = unifiedOrder(wxPayUnifiedOrderRequest);
+        Map map = unifiedOrder(wxPayUnifiedOrderRequest, currentUrl);
         if ("FAIL".equals(map.get("status"))) {
             modelMap.put("error", map.get("message"));
         } else {
@@ -225,7 +224,11 @@ public class WxpayController {
 
 
     //通过统一下单接口发起请求,获得prepay_id(预支付交易会话标识),这个标示是微信提交支付的关键数据
-    public Map unifiedOrder(WxPayUnifiedOrderRequest wxPayUnifiedOrderRequest) throws Exception {
+    public Map unifiedOrder(WxPayUnifiedOrderRequest wxPayUnifiedOrderRequest, String currentUrl) throws Exception {
+        //TODO 服务商模式  线程安全 synchronized
+//        wxPayApi.getConfig().setSubAppId("wxbc1f8607137d3b8a");
+//        wxPayApi.getConfig().setSubMchId("huangchengtianusoftchina1234567
+
         Map map = new HashMap();
         WxPayUnifiedOrderResult wxPayUnifiedOrderResult = null;
         try {
@@ -234,8 +237,14 @@ public class WxpayController {
             //map.put("status", "SUCCESS");
             if (WxPayConstants.TradeType.MWEB.equals(wxPayUnifiedOrderRequest.getTradeType())) {
                 /*H5支付开发步骤:https://pay.weixin.qq.com/wiki/doc/api/H5.php?chapter=15_4*/
-                String mwebUrl = wxPayUnifiedOrderResult.getMwebUrl() + "&redirect_url=" + URLEncoder.encode("http://lj.ubtob.com/project#/donationsOver/" + wxPayUnifiedOrderRequest.getOutTradeNo(),"UTF-8");
-                //String mwebUrl = wxPayUnifiedOrderResult.getMwebUrl();
+                //String mwebUrl = wxPayUnifiedOrderResult.getMwebUrl() + "&redirect_url=" + URLEncoder.encode("http://lj.ubtob.com/project#/donationsOver/" + wxPayUnifiedOrderRequest.getOutTradeNo(),"UTF-8");
+                String mwebUrl = null;
+                if (currentUrl != null) {
+                    logger.error("当前用户所在页面url:{}", currentUrl);
+                    mwebUrl = wxPayUnifiedOrderResult.getMwebUrl() + "&redirect_url=" + URLEncoder.encode(currentUrl + "/" + wxPayUnifiedOrderRequest.getOutTradeNo(),"UTF-8");;
+                } else {
+                    mwebUrl = wxPayUnifiedOrderResult.getMwebUrl();
+                }
                 map.put("mwebUrl", mwebUrl);
             } else if (WxPayConstants.TradeType.NATIVE.equals(wxPayUnifiedOrderRequest.getTradeType())) {
                 //扫码支付

+ 6 - 0
donate-service/src/main/webapp/resources/js/mobile/app.js

@@ -28,6 +28,12 @@ define([ 'angularAMD', 'ngRoute', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTab
             templateUrl : 'static/view/mobile/mobile_project_detail.html',
             controller : 'MobileProjectDetailCtrl',
             controllerUrl : 'app/controllers/MobileProjectDetailCtrl'
+        })).state("projectDetailAfterPay", angularAMD.route({
+            url : '/project/detail/:id/:imId/:outTradeNo',
+            title : '项目详情',
+            templateUrl : 'static/view/mobile/mobile_project_detail.html',
+            controller : 'MobileProjectDetailCtrl',
+            controllerUrl : 'app/controllers/MobileProjectDetailCtrl'
         })).state("project_detail_sharing", angularAMD.route({
             url : '/project/detail/:id',
             title : '项目详情分享页',

+ 42 - 3
donate-service/src/main/webapp/resources/js/mobile/controllers/MobileProjectDetailCtrl.js

@@ -4,6 +4,7 @@ define([ 'app/app' ], function(app) {
         function ($scope, $rootScope, Project, $stateParams, $http, toaster, User, $sce) {
         $rootScope.page = 'project';
         var id = $stateParams.id;
+        $scope.outTradeNo = $stateParams.outTradeNo;
         $scope.imId = null;
         if (!angular.isUndefined($stateParams.imId)) {
             $scope.imId = $stateParams.imId;
@@ -11,10 +12,8 @@ define([ 'app/app' ], function(app) {
         var init = function () {
 
             Project.getDetailById({ id: id}, {}, function (data) {
-                console.log('detail', data);
                 $scope.project = data;
-                $scope.styCode = '<div id="detail" class="show-all" style="max-height: 70px; overflow: hidden; font-size=12px;!important;">' + $scope.project.introduction + '</div>';
-                console.log($scope.styCode);
+                $scope.styCode = $scope.project.introduction;
                 $scope.introduction = $sce.trustAsHtml($scope.styCode);
                 $scope.organization = data.organization;
                 $scope.percentage = data.totalAmount / data.target;
@@ -63,6 +62,10 @@ define([ 'app/app' ], function(app) {
             Project.getCarousels({useFor: useFor}, {}, function(data) {
                 $scope.carousels = data;
             });
+
+            User.getUserUUByImId({imId : imId}, {}, function(data) {
+                $scope.uuid = data.userUU;
+            });
         };
         init();
 
@@ -107,5 +110,41 @@ define([ 'app/app' ], function(app) {
         $scope.selfProjectToggle = function (status) {
             $scope.projectContentShow = status;
         };
+
+        /**
+         * 刷新页面 回到无订单号参数页
+         */
+        $scope.payAgain = function () {
+            window.location.href = "/mobile#/project/detail/" + id + "/" + imId;
+        }
+
+        /**
+         * 查询订单
+         */
+        $scope.queryTradeStatus = function () {
+            $.ajax({
+                type : "POST",
+                url : "/wxpay/queryProjectRecodeState",
+                dataType : "json",
+                data: {
+                    outTradeNo : $scope.outTradeNo
+                },
+                success : function(res){
+                    if ("SUCCESS" == res) {
+                        window.location.href = "/project#/donationsOver/" + outTradeNo;
+                    } else if ("WAITING" == res) {
+                        //TODO 新弹框 继续支付  取消支付
+                        console.log("微信订单待支付");
+                    } else if ("EXCEPTION" == res) {
+                        console.log("订单异常");
+                    } else if ("ERROR" == res) {
+                        console.log("查询订单失败");
+                    }
+                },
+                error : function () {
+                    console.log("查询支付状态请求失败");
+                }
+            });
+        }
     }]);
 });

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

@@ -88,7 +88,8 @@ var wxPay = function (proId, amount, payWay, imid) {
             async: false,
             //contentType : 'application/json;charset=UTF-8',
             data: {
-                jsonStr : jsonStr
+                jsonStr : jsonStr,
+                currentUrl : window.location.href
             },
             success : function(res){
                 if (isMobile) {

+ 30 - 11
donate-service/src/main/webapp/resources/view/mobile/mobile_project_detail.html

@@ -280,6 +280,18 @@
         /*max-height: 13rem;*/
         /*overflow: hidden;*/
     }
+    .project-intro .bottom .list-show .show-all p{
+        margin-top: 0;
+        margin-bottom: .22rem;
+        font-size: .28rem !important ;
+        color: #666;
+    }
+    .project-intro .bottom .list-show .show-all a{
+        width: 100% !important;
+    }
+    .project-intro .bottom .list-show .show-all a img{
+        width: 100% !important;
+    }
     .project-intro .bottom p{
         line-height: .42rem;
         font-size: .28rem;
@@ -437,6 +449,11 @@
         color: #1e1e1e;
     }
     /*结项报告*/
+    .footer{
+        position: fixed;
+        bottom: 0;
+        left: 0;
+    }
     .footer a.looks{
         width: 100%;
         height: 1rem;
@@ -988,13 +1005,13 @@
             </form>
         </div>
         <!--捐款完成弹出框-->
-        <div class="donationOver" style="display: none">
+        <div class="donationOver" ng-show="outTradeNo != null"><!--style="display: none"-->
             <div class="header">
                请确认微信支付是否完成?
             </div>
             <div class="body">
-                <div class="pay-list"><a href="" class="finish">已完成支付</a></div>
-                <div class="pay-list"><a href="" class="return">支付遇到问题,重新支付</a></div>
+                <div class="pay-list"><a ng-click="queryTradeStatus()" class="finish">已完成支付</a></div>
+                <div class="pay-list"><a ng-click="payAgain()" class="return">支付遇到问题,重新支付</a></div>
             </div>
         </div>
     </div>
@@ -1010,17 +1027,19 @@
     //    展开全文
     $(document).ready(function() {
 //        debugger
-        var $showAll = $('#detail');
-        var $height =$showAll.height();
-        if ($height > 70) {
+        var $showAll = $('.show-all');
+
+        var $height = document.documentElement.clientHeight;
+        console.log($height)
+        if ($height > 700) {
             $showAll.css({
-                height: 70,
-                overflow: 'hidden'
+                'height': '6rem',
+                'overflow': 'hidden'
             }).next().css('display','block');
         } else {
             $showAll.css({
-                height: 'auto',
-                overflow: 'visible'
+                'height': 'auto',
+                'overflow': 'visible'
             }).next().css('display','none');
         }
     });
@@ -1035,7 +1054,7 @@
     $('.btnUp').on('click',function(){
 //        debugger
         $(this).css('display','none').prev().prev().css({
-            height: 700,
+            height: '6rem',
             overflow: 'hidden'
         })
         $(this).prev().css('display','block')