redenvelopes-model.js 877 Bytes
'use strict';
const Promise = require('bluebird');
const co = Promise.coroutine;
const _ = require('lodash');
const redenvelopesData = require('./redenvelopes-api.js');

const redenvelopesList = uid=>{
    return co(function*() {
        let result = {};
        let data = yield redenvelopesData.getRedenvelopesTotal(uid);

        if (_.get(data, 'code') === 200 && _.get(data, 'data.redpacket_num')) {
            result.money = _.get(data, 'data.redpacket_num');
            result.termOfValidity = _.get(data, 'data.useable_time');
        }
        result.useRemark = '1.红包活动,全场通用(预售商品除外);<br>' +
            '2.结算时折抵现金使用,可以和优惠券叠加使用;<br>' +
            '3.限有效期内使用,过期清零';
        return {redEnvelopes: [result]};
    })();
};

module.exports = {
    redenvelopesList
};