invoice.js
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
const ordersService = require('../models/orders-service');
const invoiceModel = require('../models/invoice');
const index = (req, res, next) => {
let page = parseInt(req.query.page, 10) || 1;
let limit = parseInt(req.query.limit, 10) || 10;
return req.ctx(ordersService).index(req.user.uid, page, limit, 8).then(result => {
res.render('invoice', {
meOrders: result
});
}).catch(next);
};
const detail = (req, res, next) => {
return req.ctx(invoiceModel).getInvoiceDetail(req.query.orderCode, req.user.uid).then(result => {
res.send(result);
}).catch(next);
};
const supply = (req, res, next) => {
let params = req.body;
// 5.8.1 发票优化需求
// 只接受电子发票(1 纸质 2 电子),发票内容为明细(id 12:明细)
Object.assign(params, {
invoicesType: 2,
contentId: 12
});
return req.ctx(invoiceModel).submitInvoiceSupply(params, req.user.uid).then(result => {
res.send(result);
}).catch(next);
};
module.exports = {
index,
detail,
supply
};