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
姜枫
9 years ago
Commit
ffe1b861c10cf73a6bf31a7af810000064f7160f
1 parent
ae37f451
master
...
develop
feature/catch
feature/docker
feature/login-msg
feature/login-ua-ip
feature/removCamel
feature/safe-bug
feature/sessionKey
feature/setting
feature/vip
feature/webpack2
feature/wsl5.3
gray
release/2.0
release/fontBack2.0
add pay method
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
5 deletions
apps/shopping/controllers/pay.js
apps/shopping/helpers/pay.js
apps/shopping/helpers/pay/alipay.js
apps/shopping/helpers/sign.js → apps/shopping/helpers/pay/sign.js
apps/shopping/models/pay-api.js
apps/shopping/models/pay.js
apps/shopping/router.js
config/common.js
apps/shopping/controllers/pay.js
View file @
ffe1b86
...
...
@@ -7,6 +7,9 @@
'use strict'
;
const
PayData
=
require
(
'../models/pay'
);
const
OrderData
=
require
(
'../models/order'
);
const
PayHelpers
=
require
(
'../helpers/pay'
);
const
camelCase
=
global
.
yoho
.
camelCase
;
const
online
=
(
req
,
res
,
next
)
=>
{
let
orderCode
=
req
.
query
.
code
;
...
...
@@ -25,11 +28,32 @@ const online = (req, res, next) => {
};
const
toPay
=
(
req
,
res
,
next
)
=>
{
let
orderCode
=
req
.
query
.
code
;
let
method
=
req
.
query
.
method
;
let
uid
=
req
.
user
.
uid
;
OrderData
.
orderDetail
(
uid
,
orderCode
).
then
(
result
=>
{
if
(
result
&&
result
.
data
)
{
let
order
=
camelCase
(
result
.
data
);
return
PayHelpers
.
pay
(
order
,
method
);
}
else
{
return
{
code
:
400
,
message
:
'获取订单失败'
};
}
}).
then
(
result
=>
{
res
.
json
(
result
);
}).
catch
(
next
);
};
const
callback
=
()
=>
{
};
module
.
exports
=
{
online
,
callback
callback
,
toPay
};
...
...
apps/shopping/helpers/pay.js
0 → 100644
View file @
ffe1b86
/**
* 各种支付的入口
*
* @author: jiangfeng<jeff.jiang@yoho.cn>
* @date: 16/7/22
*/
const
PayData
=
require
(
'../models/pay'
);
const
Alipay
=
require
(
'./pay/alipay'
);
const
Payment
=
{
pay
(
order
,
method
)
{
return
PayData
.
getPaymentInfo
(
method
).
then
(
result
=>
{
console
.
log
(
result
);
if
(
method
===
'Alipay'
)
{
Alipay
.
pay
(
order
);
}
});
}
};
module
.
exports
=
Payment
;
...
...
apps/shopping/helpers/pay/alipay.js
0 → 100644
View file @
ffe1b86
/**
*
* @author: jiangfeng<jeff.jiang@yoho.cn>
* @date: 16/7/22
*/
const
Alipay
=
{
pay
(
order
,
config
)
{
console
.
log
(
order
,
config
);
}
};
module
.
exports
=
Alipay
;
...
...
apps/shopping/helpers/sign.js → apps/shopping/helpers/
pay/
sign.js
View file @
ffe1b86
apps/shopping/models/pay-api.js
View file @
ffe1b86
...
...
@@ -12,6 +12,14 @@ const getPayProvider = () => {
});
};
const
getPaymentInfo
=
(
id
)
=>
{
return
api
.
get
(
''
,
{
method
:
'web.SpaceOrders.getPaymentById'
,
id
:
id
});
};
module
.
exports
=
{
getPayProvider
getPayProvider
,
getPaymentInfo
};
...
...
apps/shopping/models/pay.js
View file @
ffe1b86
...
...
@@ -25,7 +25,7 @@ const getOnlinePayProvider = () => {
.
filter
(
i
=>
_
.
includes
([
'Alipay'
,
'Wechatqrcode'
],
i
.
payCode
))
.
map
(
i
=>
{
return
{
id
:
i
.
payCode
,
id
:
i
.
id
,
name
:
i
.
payName
,
img
:
i
.
payIcon
,
selected
:
i
.
payCode
===
'Alipay'
...
...
@@ -71,7 +71,21 @@ const getPayInfo = (uid, code) => {
})();
};
/**
*
* @param id
*/
const
getPaymentInfo
=
(
id
)
=>
{
return
co
(
function
*
()
{
let
payment
=
yield
api
.
getPaymentInfo
(
id
);
return
payment
;
})();
};
module
.
exports
=
{
getPayInfo
getPayInfo
,
getPaymentInfo
};
...
...
apps/shopping/router.js
View file @
ffe1b86
...
...
@@ -34,6 +34,8 @@ router.post('/order/submit', auth, order.orderSub);
// 支付
router
.
get
(
'/pay/online'
,
pay
.
online
);
router
.
get
(
'/pay/online/go'
,
pay
.
toPay
);
// 在线支持完成
router
.
get
(
'/pay/online/success'
,
finish
.
success
);
...
...
config/common.js
View file @
ffe1b86
...
...
@@ -19,7 +19,7 @@ module.exports = {
},
cookieDomain
:
'yohobuy.com'
,
domains
:
{
api
:
'http://
testapi.yoho.cn:28078
/'
,
// devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
api
:
'http://
api.yoho.cn
/'
,
// devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service
:
'http://testservice.yoho.cn:28077/'
,
// testservice.yoho.cn:28077 devservice.yoho.cn:58077
search
:
'http://192.168.102.216:8080/yohosearch/'
},
...
...
Please
register
or
login
to post a comment