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

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    /**
     * 电子票下单
     * @param uid 用户id
     * @param sku 商品sku
     * @param count 购买数量 1-4
     * @param mobile 手机号码
     * @param yohoCoin 有货币
     */
    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 this.get({data: params});
    }

    /**
     * 电子票添加和查询
     * @param uid 用户 id
     * @param sku 商品sku
     * @param count 购买数量 1-4
     * @param yohoCoin 有货币
     */
    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;
        }

        return this.get({data: params});
    }
};