Authored by 郝肖肖

weixin openid

@@ -11,6 +11,7 @@ var loading = require('../plugin/loading'), @@ -11,6 +11,7 @@ var loading = require('../plugin/loading'),
11 // 点击微信显示加载 11 // 点击微信显示加载
12 var $loadingToast = $(".loading-toast"); 12 var $loadingToast = $(".loading-toast");
13 var theOrderCode = document.getElementById('ordercode').value; 13 var theOrderCode = document.getElementById('ordercode').value;
  14 +var openId = document.getElementById('openId').value;
14 15
15 var wxPayEl = document.getElementById('weixin'), 16 var wxPayEl = document.getElementById('weixin'),
16 wxHammer = wxPayEl && new Hammer(wxPayEl); 17 wxHammer = wxPayEl && new Hammer(wxPayEl);
@@ -54,15 +55,7 @@ function jsApiCall(orderCode, jsApiParameters) { @@ -54,15 +55,7 @@ function jsApiCall(orderCode, jsApiParameters) {
54 'getBrandWCPayRequest', 55 'getBrandWCPayRequest',
55 jsApiParameters, 56 jsApiParameters,
56 function (res) { 57 function (res) {
57 - //发送支付确认  
58 - $.ajax({  
59 - type: 'GET',  
60 - url: '/shopping/pay/wechatPayConfirm?order_code=' + orderCode,  
61 - dataType: 'json',  
62 - success: function (res) {  
63 - window.location.href = '/home/orders/detail?order_code=' + orderCode;  
64 - }  
65 - }); 58 + window.location.href = '/home/orders/detail?order_code=' + orderCode + '&openId=' + openId;
66 } 59 }
67 ); 60 );
68 } 61 }
@@ -82,7 +75,11 @@ function callpay(orderCode) { @@ -82,7 +75,11 @@ function callpay(orderCode) {
82 } else { 75 } else {
83 $.ajax({ 76 $.ajax({
84 type: 'GET', 77 type: 'GET',
85 - url: '/shopping/pay/wechatwapapi?order_code=' + orderCode, 78 + url: '/shopping/pay/wechatwapapi',
  79 + data: {
  80 + 'order_code': orderCode,
  81 + 'openId': openId,
  82 + },
86 dataType: 'json', 83 dataType: 'json',
87 success: function (res) { 84 success: function (res) {
88 if (res.code === 200) { 85 if (res.code === 200) {
@@ -2,12 +2,13 @@ @@ -2,12 +2,13 @@
2 <div class="pay-page yoho-page"> 2 <div class="pay-page yoho-page">
3 {{#if orderCode}} 3 {{#if orderCode}}
4 <input id='ordercode' type="hidden" value="{{orderCode}}"> 4 <input id='ordercode' type="hidden" value="{{orderCode}}">
  5 + <input id='openId' type="hidden" value="{{openId}}">
5 {{/if}} 6 {{/if}}
6 <div class="payapp-list"> 7 <div class="payapp-list">
7 {{# payAppInfo}} 8 {{# payAppInfo}}
8 - {{#if payLink}}  
9 - <a href="{{payLink}}">  
10 - {{/if}} 9 + {{#if payLink}}
  10 + <a href="{{payLink}}">
  11 + {{/if}}
11 <div class="box" id="{{appId}}"> 12 <div class="box" id="{{appId}}">
12 <div class="icon"> 13 <div class="icon">
13 {{#if appIcon}} 14 {{#if appIcon}}
@@ -26,9 +27,9 @@ @@ -26,9 +27,9 @@
26 </div> 27 </div>
27 <div class="iconfont">&#xe604</div> 28 <div class="iconfont">&#xe604</div>
28 </div> 29 </div>
29 - {{#if payLink}}  
30 - </a>  
31 - {{/if}} 30 + {{#if payLink}}
  31 + </a>
  32 + {{/if}}
32 {{/ payAppInfo}} 33 {{/ payAppInfo}}
33 </div> 34 </div>
34 <div class="loading-toast hide"></div> 35 <div class="loading-toast hide"></div>
@@ -979,7 +979,7 @@ class HomeController extends AbstractAction @@ -979,7 +979,7 @@ class HomeController extends AbstractAction
979 if (!empty($orderDetail['isPay'])) { 979 if (!empty($orderDetail['isPay'])) {
980 $this->go(Helpers::url('/home/orderdetail', array('order_code' => $orderCode))); 980 $this->go(Helpers::url('/home/orderdetail', array('order_code' => $orderCode)));
981 } 981 }
982 - 982 + $openId = '';
983 $hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false; 983 $hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
984 if ($hasWxShare) { 984 if ($hasWxShare) {
985 $openId = $this->getSession('weixinOpenId' . $orderCode); 985 $openId = $this->getSession('weixinOpenId' . $orderCode);
@@ -1013,6 +1013,7 @@ class HomeController extends AbstractAction @@ -1013,6 +1013,7 @@ class HomeController extends AbstractAction
1013 ), 1013 ),
1014 ), 1014 ),
1015 'hasWxShare' => $hasWxShare, 1015 'hasWxShare' => $hasWxShare,
  1016 + 'openId' => $openId,
1016 'orderCode' => $orderCode, 1017 'orderCode' => $orderCode,
1017 'orderTotal' => isset($orderDetail['goodsAmount']) ? $orderDetail['goodsAmount'] : 0, 1018 'orderTotal' => isset($orderDetail['goodsAmount']) ? $orderDetail['goodsAmount'] : 0,
1018 'orderTotalFormat' => isset($orderDetail['goodsAmount']) ? sprintf("%d", $orderDetail['goodsAmount']) : 0, 1019 'orderTotalFormat' => isset($orderDetail['goodsAmount']) ? sprintf("%d", $orderDetail['goodsAmount']) : 0,
@@ -1111,6 +1112,11 @@ class HomeController extends AbstractAction @@ -1111,6 +1112,11 @@ class HomeController extends AbstractAction
1111 $this->setTitle('订单详情'); 1112 $this->setTitle('订单详情');
1112 $this->setNavHeader('订单详情', true, false); 1113 $this->setNavHeader('订单详情', true, false);
1113 1114
  1115 + $openId = $this->get('openId', '');
  1116 + if (!empty($openId)) {
  1117 + //微信支付成功,发送支付确认接口
  1118 + OrderData::payConfirm($orderCode, 22, $this->_uid);
  1119 + }
1114 1120
1115 $this->_view->display('order-detail', array( 1121 $this->_view->display('order-detail', array(
1116 'orderDetailPage' => true, 1122 'orderDetailPage' => true,
@@ -122,8 +122,14 @@ class PayController extends AbstractAction @@ -122,8 +122,14 @@ class PayController extends AbstractAction
122 122
123 $totalFee = strval($orderDetail['data']['payment_amount'] * 100); 123 $totalFee = strval($orderDetail['data']['payment_amount'] * 100);
124 $openId = $this->getSession('weixinOpenId' . $orderCode); 124 $openId = $this->getSession('weixinOpenId' . $orderCode);
  125 +
  126 + if (empty($openId)) {
  127 + $openId = $this->get('openId');
  128 + UdpLog::info('【wechat支付】通过get 获取openId: ', array('orderCode' => $orderCode, 'uid' => $uid, 'openId' => $openId);
  129 + }
  130 +
125 if (empty($openId)) { 131 if (empty($openId)) {
126 - UdpLog::info('【wechat支付】获取wechat标识为空', 'orderCode:'.$orderCode.'uid:'.$uid.'返回openId:'.$openId); 132 + UdpLog::info('【wechat支付】获取wechat标识为空', array('orderCode' => $orderCode, 'uid' => $uid, 'openId' => $openId);
127 break; 133 break;
128 } 134 }
129 135