Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
郝肖肖
8 years ago
Commit
ca74939959836783df2327fb8e1fbad7970f72d8
1 parent
9bd5cbd1
支付 判断订单 是否到期
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
5 deletions
apps/shopping/controllers/pay.js
apps/shopping/helpers/pay/common.js
apps/shopping/helpers/payment.js
apps/shopping/models/pay-api.js
apps/shopping/router.js
public/js/shopping/pay.page.js
apps/shopping/controllers/pay.js
View file @
ca74939
...
...
@@ -207,7 +207,17 @@ const callback = (req, res, next) => {
});
}
}).
catch
(
next
);
};
// 支付确认
const
sendPayConfirm
=
(
req
,
res
,
next
)
=>
{
let
code
=
req
.
body
.
code
;
let
payment
=
req
.
body
.
payment
;
let
uid
=
req
.
user
.
uid
;
PayData
.
sendPayConfirm
(
code
,
payment
,
uid
).
then
(
result
=>
{
res
.
json
(
result
);
}).
catch
(
next
);
};
...
...
@@ -216,5 +226,6 @@ module.exports = {
callback
,
toPay
,
weixinQr
,
weixinPayState
weixinPayState
,
sendPayConfirm
};
...
...
apps/shopping/helpers/pay/common.js
View file @
ca74939
...
...
@@ -18,7 +18,7 @@ const common = {
if
(
diff
>
0
)
{
return
Math
.
floor
(
diff
/
1000
/
60
);
}
else
{
return
defaultValue
;
return
0
;
}
}
else
{
...
...
apps/shopping/helpers/payment.js
View file @
ca74939
...
...
@@ -13,6 +13,7 @@ const Alipay = require('./pay/alipay');
const
Alibank
=
require
(
'./pay/alibank'
);
const
Wechat
=
require
(
'./pay/wechat'
);
const
Promise
=
require
(
'bluebird'
);
const
common
=
require
(
'./pay/common'
);
const
co
=
Promise
.
coroutine
;
const
logger
=
global
.
yoho
.
logger
;
...
...
@@ -31,6 +32,21 @@ const Payment = {
return
result
;
}
if
(
!
order
.
orderCode
)
{
result
.
message
=
'没有找到该订单'
;
return
result
;
}
if
(
order
.
isCancel
&&
order
.
isCancel
===
'Y'
)
{
result
.
message
=
'该订单已经取消'
;
return
result
;
}
if
(
order
.
payExpire
&&
common
.
getPayExpireMin
(
order
.
payExpire
)
<=
0
)
{
result
.
message
=
'当前订单不可支付'
;
// 该订单已超过2个小时
return
result
;
}
let
method
=
paymentPars
[
0
]
*
1
;
if
(
method
===
PayData
.
payments
.
wechat
)
{
...
...
apps/shopping/models/pay-api.js
View file @
ca74939
...
...
@@ -12,7 +12,7 @@ const api = global.yoho.API;
const
getPayProvider
=
()
=>
{
return
api
.
get
(
''
,
{
method
:
'web.SpaceOrders.getPaymentList'
});
}
,
{
cache
:
true
}
);
};
// 获取单个支付方式相关详细信息
...
...
@@ -20,7 +20,7 @@ const getPaymentInfo = (id) => {
return
api
.
get
(
''
,
{
method
:
'web.SpaceOrders.getPaymentById'
,
id
:
id
});
}
,
{
cache
:
true
}
);
};
/* 获取上次使用的支付方式*/
...
...
apps/shopping/router.js
View file @
ca74939
...
...
@@ -35,6 +35,7 @@ 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
);
router
.
post
(
'/pay/online/sendPayConfirm'
,
auth
,
pay
.
sendPayConfirm
);
// 支付回调
router
.
get
(
'/pay/callback/:type'
,
auth
,
pay
.
callback
);
...
...
public/js/shopping/pay.page.js
View file @
ca74939
...
...
@@ -19,7 +19,7 @@ var tpl = '<div class="pay-page-tips">' +
'<h3>请您在新打开的页面完成付款</h3>'
+
'<p>付款完成前请不要关闭此窗口</p>'
+
'<p>完成付款后请根据您的情况点击下面的按钮</p>'
+
'<div><a href="
/me/ord
er"><span class="btn">已完成付款</span></a>'
+
'<div><a href="
javascript:void(0);" class="pay-ov
er"><span class="btn">已完成付款</span></a>'
+
'<span class="btn white close-btn">更换支付方式</span>'
+
'</div>'
+
'</div>'
;
...
...
@@ -104,3 +104,20 @@ $goPayBtn.click(function() {
}
});
});
// 发送支付确认
$
(
'.pay-info-dialog'
).
on
(
'click'
,
'.pay-over'
,
function
()
{
var
payment
=
$
(
'.pay-type-icon.active'
).
data
(
'id'
);
var
order
=
$goPayBtn
.
data
(
'order'
);
$
.
ajax
({
type
:
'POST'
,
url
:
'/shopping/pay/online/sendPayConfirm'
,
data
:
{
code
:
order
,
payment
:
payment
}
}).
then
(
function
()
{
location
.
href
=
'/me/order'
;
});
});
...
...
Please
register
or
login
to post a comment