magazine.js 1019 Bytes
'use strict';
const magazineModel = require('../models/magazine'); // 头部model
const headerModel = require('../../../doraemon/models/header'); // 头部model

const confirm = (req, res, next) => {
    req.ctx(magazineModel).getMagazinePayment(req.user.uid, req.query).then(result => {
        res.render('magazine-confirm', {
            pageHeader: headerModel.setNav({
                navTitle: '支付订单',
                navBtn: false
            }),
            page: 'magazine-confirm',
            localCss: true,
            result: Object.assign({
                sku: req.query.sku
            }, result)
        });
    }).catch(next);
};

const compute = (req, res, next) => {
    req.ctx(magazineModel).computeMagazineOrder(req.user.uid, req.body)
    .then(res.json)
    .catch(next);
};

const submit = (req, res, next) => {
    req.ctx(magazineModel).submitMagazineOrder(req.user.uid, req.body)
    .then(res.json)
    .catch(next);
};

module.exports = {
    confirm,
    compute,
    submit
};