Authored by 姜枫

添加检查微信支付状态 定时器

projectKey=fe:yohoblk
serverUrl=http://localhost:9009
dashboardUrl=http://localhost:9009/dashboard/index/fe:yohoblk
ceTaskId=AVbF8e0O_lOupzaXV3Wr
ceTaskUrl=http://localhost:9009/api/ce/task?id=AVbF8e0O_lOupzaXV3Wr
... ...
... ... @@ -122,6 +122,26 @@ const weixinQr = (req, res, next) => {
}).catch(next);
};
const weixinPayState = (req, res) => {
let code = req.query.code;
let uid = req.user.uid;
OrderData.orderDetail(uid, code).then(result => {
if (result && result.data && result.data.payment_status === 'Y') {
res.json({
code: 200,
data: {
href: helpers.urlFormat('/me/order/detail', {orderCode: code})
}
});
} else {
return res.json({});
}
}).catch(() => {
return res.json({});
});
};
/**
* 支付成功回调
* @param req
... ... @@ -165,5 +185,6 @@ module.exports = {
online,
callback,
toPay,
weixinQr
weixinQr,
weixinPayState
};
... ...
... ... @@ -33,6 +33,7 @@ router.post('/order/submit', auth, order.orderSub);
// 支付
router.get('/pay/online', auth, pay.online);
router.get('/pay/online/weixin', auth, pay.weixinQr);
router.get('/pay/online/weixin/state', auth, pay.weixinPayState);
router.post('/pay/online/go', auth, pay.toPay);
// 支付回调
... ...
... ... @@ -47,6 +47,6 @@
{{/order}}
<div class="qr-content">
<div class="qr-code" data-qr="{{url}}"></div>
<div class="qr-code" data-qr="{{url}}" data-code="{{order.orderCode}}"></div>
</div>
</div>
... ...
... ... @@ -23,8 +23,8 @@ module.exports = {
cookieDomain: 'yohoblk.com',
domains: {
singleApi: 'http://single.yoho.cn/',
api: 'http://api.yoho.yohoops.org/',
service: 'http://service.yoho.yohoops.org/',
api: 'http://dev-api.yohops.com:9999/',
service: 'http://dev-service.yohops.com:9999/',
search: 'http://search.yohoops.org/yohosearch/'
},
useOneapm: false,
... ...
... ... @@ -14,4 +14,16 @@ $(function() {
text: $(this).data('qr')
});
});
function queryOrderState() {
var code = $('.qr-code').data('code');
$.get('/shopping/pay/online/weixin/state', {code: code}, function(data) {
if (data && data.code === 200) {
location.href = data.data.href;
}
});
}
setInterval(queryOrderState, 1000);
});
... ...
sonar.projectKey=fe:yohoblk
# this is the name displayed in the SonarQube UI
sonar.projectName=yoho-blk
sonar.projectVersion=0.0.1
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=apps
... ...