Authored by 郝肖肖

Merge branch 'feature/balanceCtx' into feature/cartCtx

... ... @@ -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);
};
... ...
... ... @@ -5,9 +5,12 @@
*/
'use strict';
const api = global.yoho.API;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
const getEasyPaymentAsync = (uid, goods, activity) => {
getEasyPaymentAsync(uid, goods, activity) {
let param = {
method: 'app.Shopping.easyPayment',
uid: uid,
... ... @@ -21,11 +24,10 @@ const getEasyPaymentAsync = (uid, goods, activity) => {
param.activity_id = activity;
}
return api.get('', param, {code: 200});
};
return this.get({data: param});
}
/**
/**
* 订单计算API
* @param uid [number] uid
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
... ... @@ -36,9 +38,8 @@ const getEasyPaymentAsync = (uid, goods, activity) => {
* @param couponCode [string] 优惠券码
* @param promotionCode [string] 优惠码
* @param productSkuList [string] 限购商品
*/
const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other) => {
getEasypayComputeAsync(uid, cartType, paymentType, deliveryWay, other) {
let param = {
method: 'app.Shopping.easyCompute',
uid: uid,
... ... @@ -84,13 +85,12 @@ const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other)
});
}
}
}
return api.get('', param);
};
return this.get({data: param});
}
/**
/**
* 订单提交API
* @param uid [number] uid
* @param cartType [String] 购物车类型,ordinary表示普通, advance表示预售
... ... @@ -109,7 +109,7 @@ const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other)
* @param couponCode [string] 优惠券码
* @param printPrice [string] 是否打印价格
*/
const easypayOrderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, paymentType, paymentId, printPrice, other, remoteIp) => { // eslint-disable-line
easypayOrderSubmitAsync(uid, cartType, addressId, deliveryTime, deliveryWay, paymentType, paymentId, printPrice, other, remoteIp) { // eslint-disable-line
let param = {
method: 'app.Shopping.easySubmit',
uid: uid,
... ... @@ -178,13 +178,10 @@ const easypayOrderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliver
});
}
return api.get('', param, {
headers: {'X-Forwarded-For': remoteIp || ''}
});
};
module.exports = {
getEasyPaymentAsync,
getEasypayComputeAsync,
easypayOrderSubmitAsync
return this.get({data: param, param: {
headers: {
'X-Forwarded-For': remoteIp || ''
}
}});
}
};
... ...