Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
郝肖肖
8 years ago
Commit
096c489910b8de4ae916c3befbadc86c77486f62
1 parent
b1d7b4a0
'立即购买上下文'
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
146 deletions
apps/cart/controllers/easypay.js
apps/cart/models/easypay-api.js
apps/cart/controllers/easypay.js
View file @
096c489
...
...
@@ -17,7 +17,7 @@ const index = (req, res, next) => {
let
uid
=
req
.
user
.
uid
;
let
params
=
req
.
query
;
easypay
.
getEasypayOrderData
(
params
,
uid
).
then
(
result
=>
{
req
.
ctx
(
easypay
)
.
getEasypayOrderData
(
params
,
uid
).
then
(
result
=>
{
let
header
=
headerModel
.
setSimpleHeaderData
()
||
{};
result
.
stepper
=
stepper
;
...
...
@@ -39,7 +39,7 @@ const compute = (req, res, next) => {
let
uid
=
req
.
user
.
uid
;
let
params
=
req
.
body
;
easypay
.
getOrderComputeData
(
uid
,
'ordinary'
,
params
).
then
(
result
=>
{
req
.
ctx
(
easypay
)
.
getOrderComputeData
(
uid
,
'ordinary'
,
params
).
then
(
result
=>
{
res
.
json
(
result
);
}).
catch
(
next
);
};
...
...
@@ -53,7 +53,7 @@ const submit = (req, res, next) => {
return
next
();
}
easypay
.
easypayOrderSubmit
(
uid
,
'ordinary'
,
params
,
remoteIp
).
then
(
result
=>
{
req
.
ctx
(
easypay
)
.
easypayOrderSubmit
(
uid
,
'ordinary'
,
params
,
remoteIp
).
then
(
result
=>
{
res
.
json
(
result
);
}).
catch
(
next
);
};
...
...
apps/cart/models/easypay-api.js
View file @
096c489
...
...
@@ -5,71 +5,158 @@
*/
'use strict'
;
const
api
=
global
.
yoho
.
API
;
const
getEasyPaymentAsync
=
(
uid
,
goods
,
activity
)
=>
{
let
param
=
{
method
:
'app.Shopping.easyPayment'
,
uid
:
uid
,
cart_type
:
'ordinary'
,
product_sku_list
:
goods
,
yoho_coin_mode
:
0
,
is_support_apple_pay
:
'N'
};
if
(
activity
)
{
param
.
activity_id
=
activity
;
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
}
return
api
.
get
(
''
,
param
,
{
code
:
200
});
};
getEasyPaymentAsync
(
uid
,
goods
,
activity
)
{
let
param
=
{
method
:
'app.Shopping.easyPayment'
,
uid
:
uid
,
cart_type
:
'ordinary'
,
product_sku_list
:
goods
,
yoho_coin_mode
:
0
,
is_support_apple_pay
:
'N'
};
if
(
activity
)
{
param
.
activity_id
=
activity
;
}
return
this
.
get
({
data
:
param
});
}
/**
* 订单计算API
* @param uid [number] uid
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
* @param paymentType [number] 支付方式,1表示在线支付,2表示货到付款
* @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
* @param coin [number] 使用的有货币
* @param useRedEnvelops [number] 红包
* @param couponCode [string] 优惠券码
* @param promotionCode [string] 优惠码
* @param productSkuList [string] 限购商品
/**
* 订单计算API
* @param uid [number] uid
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
* @param paymentType [number] 支付方式,1表示在线支付,2表示货到付款
* @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
* @param coin [number] 使用的有货币
* @param useRedEnvelops [number] 红包
* @param couponCode [string] 优惠券码
* @param promotionCode [string] 优惠码
* @param productSkuList [string] 限购商品
*/
getEasypayComputeAsync
(
uid
,
cartType
,
paymentType
,
deliveryWay
,
other
)
{
let
param
=
{
method
:
'app.Shopping.easyCompute'
,
uid
:
uid
,
cart_type
:
cartType
||
'ordinary'
,
payment_type
:
paymentType
,
delivery_way
:
deliveryWay
};
// 其他可选参数
if
(
other
)
{
if
(
other
.
coin
)
{
Object
.
assign
(
param
,
{
use_yoho_coin
:
other
.
coin
/
100
});
}
*/
const
getEasypayComputeAsync
=
(
uid
,
cartType
,
paymentType
,
deliveryWay
,
other
)
=>
{
let
param
=
{
method
:
'app.Shopping.easyCompute'
,
uid
:
uid
,
cart_type
:
cartType
||
'ordinary'
,
payment_type
:
paymentType
,
delivery_way
:
deliveryWay
};
// 其他可选参数
if
(
other
)
{
if
(
other
.
useRedEnvelops
)
{
Object
.
assign
(
param
,
{
use_red_envelopes
:
other
.
useRedEnvelops
});
}
if
(
other
.
couponCode
)
{
Object
.
assign
(
param
,
{
coupon_code
:
other
.
couponCode
});
}
if
(
other
.
promotionCode
)
{
Object
.
assign
(
param
,
{
promotion_code
:
other
.
promotionCode
});
}
if
(
other
.
productSkuList
)
{
Object
.
assign
(
param
,
{
product_sku_list
:
other
.
productSkuList
});
if
(
other
.
bundle
)
{
Object
.
assign
(
param
,
{
activity_id
:
other
.
bundle
});
}
}
}
return
this
.
get
({
data
:
param
});
}
/**
* 订单提交API
* @param uid [number] uid
* @param cartType [String] 购物车类型,ordinary表示普通, advance表示预售
* @param addressId [String] 地址
* @param deliveryTime [number] 寄送时间类型
* @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
* @param invoicesType [number] 发票类型
* @param invoicesTitle [string] 发票抬头
* @param invoicesContent [int] 发票类型
* @param receiverMobile [string] 发票收人电话
* @param coin [number] 使用的有货币金额
* @param redEnvelopes [number] 使用的红包
* @param paymentId [number] 支付id
* @param paymentType [number] 支付类型
* @param remark [string] 备注
* @param couponCode [string] 优惠券码
* @param printPrice [string] 是否打印价格
*/
easypayOrderSubmitAsync
(
uid
,
cartType
,
addressId
,
deliveryTime
,
deliveryWay
,
paymentType
,
paymentId
,
printPrice
,
other
,
remoteIp
)
{
// eslint-disable-line
let
param
=
{
method
:
'app.Shopping.easySubmit'
,
uid
:
uid
,
cart_type
:
cartType
||
'ordinary'
,
address_id
:
addressId
,
delivery_time
:
deliveryTime
,
delivery_way
:
deliveryWay
,
payment_type
:
paymentType
,
payment_id
:
paymentId
,
is_print_price
:
printPrice
};
// 发票
if
(
other
.
invoicesType
)
{
Object
.
assign
(
param
,
{
invoices_type
:
other
.
invoicesType
,
invoices_title
:
other
.
invoicesTitle
,
invoice_content
:
other
.
invoicesContent
,
receiverMobile
:
other
.
receiver
});
}
// 有货币
if
(
other
.
coin
)
{
Object
.
assign
(
param
,
{
use_yoho_coin
:
other
.
coin
/
100
use_yoho_coin
:
other
.
coin
/
100
// 有货币稀释
});
}
if
(
other
.
useRedEnvelops
)
{
// 红包
if
(
other
.
redEnvelopes
)
{
Object
.
assign
(
param
,
{
use_red_envelopes
:
other
.
useRedEnvelop
s
use_red_envelopes
:
other
.
redEnvelope
s
});
}
if
(
other
.
couponCode
)
{
// 备注
if
(
other
.
remark
)
{
Object
.
assign
(
param
,
{
coupon_code
:
other
.
couponCode
remark
:
other
.
remark
});
}
if
(
other
.
promotionCode
)
{
// 优惠券码
if
(
other
.
couponCode
)
{
Object
.
assign
(
param
,
{
promotion_code
:
other
.
promoti
onCode
coupon_code
:
other
.
coup
onCode
});
}
...
...
@@ -85,106 +172,16 @@ const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other)
}
}
}
return
api
.
get
(
''
,
param
);
};
/**
* 订单提交API
* @param uid [number] uid
* @param cartType [String] 购物车类型,ordinary表示普通, advance表示预售
* @param addressId [String] 地址
* @param deliveryTime [number] 寄送时间类型
* @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
* @param invoicesType [number] 发票类型
* @param invoicesTitle [string] 发票抬头
* @param invoicesContent [int] 发票类型
* @param receiverMobile [string] 发票收人电话
* @param coin [number] 使用的有货币金额
* @param redEnvelopes [number] 使用的红包
* @param paymentId [number] 支付id
* @param paymentType [number] 支付类型
* @param remark [string] 备注
* @param couponCode [string] 优惠券码
* @param printPrice [string] 是否打印价格
*/
const
easypayOrderSubmitAsync
=
(
uid
,
cartType
,
addressId
,
deliveryTime
,
deliveryWay
,
paymentType
,
paymentId
,
printPrice
,
other
,
remoteIp
)
=>
{
// eslint-disable-line
let
param
=
{
method
:
'app.Shopping.easySubmit'
,
uid
:
uid
,
cart_type
:
cartType
||
'ordinary'
,
address_id
:
addressId
,
delivery_time
:
deliveryTime
,
delivery_way
:
deliveryWay
,
payment_type
:
paymentType
,
payment_id
:
paymentId
,
is_print_price
:
printPrice
};
// 发票
if
(
other
.
invoicesType
)
{
Object
.
assign
(
param
,
{
invoices_type
:
other
.
invoicesType
,
invoices_title
:
other
.
invoicesTitle
,
invoice_content
:
other
.
invoicesContent
,
receiverMobile
:
other
.
receiver
});
}
// 有货币
if
(
other
.
coin
)
{
Object
.
assign
(
param
,
{
use_yoho_coin
:
other
.
coin
/
100
// 有货币稀释
});
}
// 红包
if
(
other
.
redEnvelopes
)
{
Object
.
assign
(
param
,
{
use_red_envelopes
:
other
.
redEnvelopes
});
}
// 备注
if
(
other
.
remark
)
{
Object
.
assign
(
param
,
{
remark
:
other
.
remark
});
}
// 优惠券码
if
(
other
.
couponCode
)
{
Object
.
assign
(
param
,
{
coupon_code
:
other
.
couponCode
});
}
if
(
other
.
productSkuList
)
{
Object
.
assign
(
param
,
{
product_sku_list
:
other
.
productSkuList
});
if
(
other
.
bundle
)
{
if
(
other
.
udid
)
{
Object
.
assign
(
param
,
{
activity_id
:
other
.
bundle
udid
:
other
.
udid
});
}
}
if
(
other
.
udid
)
{
Object
.
assign
(
param
,
{
udid
:
other
.
udid
});
return
this
.
get
({
data
:
param
,
param
:
{
headers
:
{
'X-Forwarded-For'
:
remoteIp
||
''
}
}});
}
return
api
.
get
(
''
,
param
,
{
headers
:
{
'X-Forwarded-For'
:
remoteIp
||
''
}
});
};
module
.
exports
=
{
getEasyPaymentAsync
,
getEasypayComputeAsync
,
easypayOrderSubmitAsync
};
...
...
Please
register
or
login
to post a comment