Authored by 陈轩

save

'use strict';
const _ = require('lodash');
const helpers = global.yoho.helpers;
const cartModel = require('../models/cart');
exports.orderEnsure = (req, res, next) => {
let uid = req.user.uid;
let returnUrl = helpers.urlFormat('/cart/index/new');
let cartType = req.query.cartType;
let orderInfo;
try {
orderInfo = JSON.parse(req.cookies['order-info']);
} catch (e) {
orderInfo = {};
}
// 如果传递了code, skn, sku, buy_number 就代表限购商品
let limitProductCode = req.query.limitproductcode || '';
let sku = req.query.sku || '';
let skn = req.query.skn || '';
let buyNumber = req.query.buy_number || 1;
if (limitProductCode) {
returnUrl = req.get('Referer') || returnUrl;
}
cartModel.cartPay(uid, cartType, orderInfo, limitProductCode)
res.send('todo: orderEnsure');
};
... ...
'use strict';
const api = global.yoho.api;
/**
* 购物车结算
*
* @param int uid 用户ID
* @param string cartType 购物车类型,ordinary表示普通购物车
* @param int isUseYohoCoin 是否使用有货币,0不使用, 1使用
* @param string skuList 购买限购商品时需要传递的参数
* @return array 接口返回的数据
*/
exports.cartPay = (uid, cartType, isUseYohoCoin, skuList) => {
let param = {
method: 'app.Shopping.payment',
enable_red_envelopes: 0, // h5不返回红包
cart_type: cartType,
yoho_coin_mode: isUseYohoCoin,
uid: uid
};
if (skuList) {
param.product_sku_list = skuList;
}
return api.get('', param);
};
... ...