seckill.js 1.2 KB
'use strict';

const API = global.yoho.API;
const paymentProcess = require(global.utils + '/payment-process');

/**
 *  获取 获取秒杀信息接口
 *  doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E5%95%86%E5%93%81%E5%88%97%E8%A1%A8/seckill.md
 */
exports.skillData = product_skn => {
    let queryData = {
        method: 'app.seckill.data',
        product_skn
    };

    return API.post('', queryData);
};


exports.payment = (options, orderInfo) => {
    let queryData = Object.assign({
        method: 'app.Seckill.payment',
    }, options);

    return API.post('', queryData)
        .then(result => {
            // TODO 数据处理
            if (result.code === 200 && result.data) {
                result.data = paymentProcess.tranformPayment(result.data, orderInfo);
            }
            return result;
        });
};


exports.compute = options => {
    let url = '';
    let queryData = Object.assign({
        method: 'app.Seckill.compute',
    }, options);

    return API.post(url, queryData);
};


exports.submit = options => {
    let url = '';
    let queryData = Object.assign({
        method: 'app.Seckill.submit'
    }, options);

    return API.post(url, queryData);
};