ticket-api.js 1.03 KB
/**
 * Created by TaoHuang on 2017/6/22.
 */

const api = global.yoho.API;

/**
 * 电子票下单
 * @param uid 用户id
 * @param sku 商品sku
 * @param count 购买数量 1-4
 * @param mobile 手机号码
 * @param yohoCoin 有货币
 */
function submit(uid, sku, count, mobile, yohoCoin) {
    let params = {
        method: 'app.shopping.submitTicket',
        uid,
        product_sku: sku,
        buy_number: count,
        mobile: mobile
    };

    if (yohoCoin) {
        params.use_yoho_coin = yohoCoin / 100;
    }

    return api.get('', params);
}

/**
 * 电子票添加和查询
 * @param uid 用户 id
 * @param sku 商品sku
 * @param count 购买数量 1-4
 * @param yohoCoin 有货币
 */
function add(uid, sku, count, yohoCoin) {
    let params = {
        method: 'app.shopping.ticket',
        uid,
        product_sku: sku,
        buy_number: count
    };

    if (yohoCoin) {
        params.use_yoho_coin = yohoCoin / 100;
    }
    console.log(params);
    return api.get('', params);
}

module.exports = {
    submit,
    add
};