|
|
@ -72,15 +72,20 @@ const chunkBy = (use_year, dataList = [], by = []) => {
|
|
|
|
uniqWith(groupSize, (a, b) => a[0] === b[0] && a[1] === b[1]),
|
|
|
|
uniqWith(groupSize, (a, b) => a[0] === b[0] && a[1] === b[1]),
|
|
|
|
(c) => c[0]
|
|
|
|
(c) => c[0]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
// 按max最大值 cut分组
|
|
|
|
const sizeSets = Object.keys(allSizeCut).map((s1) => [Number(s1), Math.max(...allSizeCut[s1].map((c) => c[1]))]);
|
|
|
|
const sizeSets = Object.keys(allSizeCut).map((s1) => [Number(s1), Math.max(...allSizeCut[s1].map((c) => c[1]))]);
|
|
|
|
const sizeSetsByMax = uniqWith(sizeSets, (a, b) => a[1] === b[1]);
|
|
|
|
const sizeSetsByMax = uniqWith(sizeSets, (a, b) => a[1] === b[1]);
|
|
|
|
// const sizeSetsByMax = [[1,4], [5,6], [7, 9], [10, Infinity]]; // test: 固定车辆座次
|
|
|
|
// // const sizeSetsByMax = [[1,4], [5,6], [7, 9], [10, Infinity]]; // test: 固定车辆座次
|
|
|
|
|
|
|
|
// 按max最小值 cut分组
|
|
|
|
|
|
|
|
// const sizeSets = Object.keys(allSizeCut).map((s1) => [Number(s1), Math.min(...allSizeCut[s1].map((c) => c[1]))]);
|
|
|
|
|
|
|
|
// const sizeSetsByMax = uniqWith(sizeSets, (a, b) => a[1] === b[1]);
|
|
|
|
|
|
|
|
|
|
|
|
const dataRoll = dataList.map((rowp, ii) => {
|
|
|
|
const dataRoll = dataList.map((rowp, ii) => {
|
|
|
|
const quotation = rowp.quotation.map((quoteItem) => {
|
|
|
|
const quotation = rowp.quotation.map((quoteItem) => {
|
|
|
|
const matchRange = cloneDeep(sizeSetsByMax)
|
|
|
|
const matchRange = cloneDeep(sizeSetsByMax)
|
|
|
|
.reverse()
|
|
|
|
.reverse()
|
|
|
|
.find((ss) => quoteItem.group_size_min >= ss[0] && quoteItem.group_size_max <= ss[1]);
|
|
|
|
.find((ss) => quoteItem.group_size_min >= ss[0] && quoteItem.group_size_max <= ss[1]);
|
|
|
|
|
|
|
|
const inSet = matchRange;
|
|
|
|
// const matchMax =
|
|
|
|
// const matchMax =
|
|
|
|
// matchRange ||
|
|
|
|
// matchRange ||
|
|
|
|
// cloneDeep(sizeSetsByMax)
|
|
|
|
// cloneDeep(sizeSetsByMax)
|
|
|
@ -92,7 +97,6 @@ const chunkBy = (use_year, dataList = [], by = []) => {
|
|
|
|
// // .reverse()
|
|
|
|
// // .reverse()
|
|
|
|
// .find((ss) => quoteItem.group_size_min >= ss[0]);
|
|
|
|
// .find((ss) => quoteItem.group_size_min >= ss[0]);
|
|
|
|
// const inSet = matchMin;
|
|
|
|
// const inSet = matchMin;
|
|
|
|
const inSet = matchRange;
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
...quoteItem,
|
|
|
|
...quoteItem,
|
|
|
|
quote_season: isFullYearOrLonger(use_year, quoteItem.use_dates_start, quoteItem.use_dates_end) ? 'SS' : 'PS',
|
|
|
|
quote_season: isFullYearOrLonger(use_year, quoteItem.use_dates_start, quoteItem.use_dates_end) ? 'SS' : 'PS',
|
|
|
@ -120,9 +124,10 @@ const chunkBy = (use_year, dataList = [], by = []) => {
|
|
|
|
return { ...rowp, quote_chunk: thisChunk };
|
|
|
|
return { ...rowp, quote_chunk: thisChunk };
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const allquotation = chunk.reduce((a, c) => a.concat(c.quotation), []);
|
|
|
|
const allquotation = chunk.reduce((a, c) => a.concat(c.quotation), []);
|
|
|
|
|
|
|
|
// 取出两季相应的时效区间
|
|
|
|
const SSRange = unique((allquotation || []).filter((q) => q.quote_season === 'SS').map((qr) => `${qr.use_dates_start}~${qr.use_dates_end}`));
|
|
|
|
const SSRange = unique((allquotation || []).filter((q) => q.quote_season === 'SS').map((qr) => `${qr.use_dates_start}~${qr.use_dates_end}`));
|
|
|
|
const PSRange = unique((allquotation || []).filter((q) => q.quote_season === 'PS').map((qr) => `${qr.use_dates_start}~${qr.use_dates_end}`));
|
|
|
|
const PSRange = unique((allquotation || []).filter((q) => q.quote_season === 'PS').map((qr) => `${qr.use_dates_start}~${qr.use_dates_end}`));
|
|
|
|
// console.log(chunk, dataSource, sizeSets, sizeSetsByMax);
|
|
|
|
// console.log('chunk', chunk, dataSource, sizeSets, sizeSetsByMax);
|
|
|
|
return { chunk, dataSource, sizeSets: sizeSetsByMax, SSRange, PSRange };
|
|
|
|
return { chunk, dataSource, sizeSets: sizeSetsByMax, SSRange, PSRange };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -153,6 +158,7 @@ export default class AgencyContract {
|
|
|
|
const yearStart = dayjs(`${use_year}-01-01`).format('YYYY.MM.DD');
|
|
|
|
const yearStart = dayjs(`${use_year}-01-01`).format('YYYY.MM.DD');
|
|
|
|
const yearEnd = dayjs(`${use_year}-12-31`).format('YYYY.MM.DD');
|
|
|
|
const yearEnd = dayjs(`${use_year}-12-31`).format('YYYY.MM.DD');
|
|
|
|
// console.log(agencyExtras);
|
|
|
|
// console.log(agencyExtras);
|
|
|
|
|
|
|
|
console.log('*********************************************************************************************');
|
|
|
|
|
|
|
|
|
|
|
|
const document = new Document({
|
|
|
|
const document = new Document({
|
|
|
|
creator: 'China Highlights',
|
|
|
|
creator: 'China Highlights',
|
|
|
@ -317,26 +323,21 @@ export default class AgencyContract {
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
// new Paragraph({
|
|
|
|
|
|
|
|
// text: h1,
|
|
|
|
|
|
|
|
// heading: HeadingLevel.HEADING_1,
|
|
|
|
|
|
|
|
// alignment: 'center',
|
|
|
|
|
|
|
|
// }),
|
|
|
|
|
|
|
|
this.createTitle(h1),
|
|
|
|
this.createTitle(h1),
|
|
|
|
this.createSubHeading(`价格有效期: ${yearStart}-${yearEnd}`, { alignment: AlignmentType.CENTER }),
|
|
|
|
this.createSubHeading(`价格有效期: ${yearStart}-${yearEnd}`, { alignment: AlignmentType.CENTER }),
|
|
|
|
|
|
|
|
|
|
|
|
...(isEmpty(agencyProducts['6'])
|
|
|
|
...(isEmpty(agencyProducts['6'])
|
|
|
|
? []
|
|
|
|
? []
|
|
|
|
: [this.createSubHeading(`综费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_6(use_year, agencyProducts['6'])]),
|
|
|
|
: [this.createSubHeading(`综费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_6Q(use_year, agencyProducts['6'])]),
|
|
|
|
...(isEmpty(agencyProducts['B'])
|
|
|
|
...(isEmpty(agencyProducts['B'])
|
|
|
|
? []
|
|
|
|
? []
|
|
|
|
: [this.createSubHeading(`超公里`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_B(use_year, agencyProducts['B'])]),
|
|
|
|
: [this.createSubHeading(`超公里`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_B(use_year, agencyProducts['B'])]),
|
|
|
|
...(isEmpty(agencyProducts['J'])
|
|
|
|
...(isEmpty(agencyProducts['J'])
|
|
|
|
? []
|
|
|
|
? []
|
|
|
|
: [this.createSubHeading(`车费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_J(use_year, agencyProducts['J'])]),
|
|
|
|
: [this.createSubHeading(`车费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_JD(use_year, agencyProducts['J'])]),
|
|
|
|
...(isEmpty(agencyProducts['Q'])
|
|
|
|
...(isEmpty(agencyProducts['Q'])
|
|
|
|
? []
|
|
|
|
? []
|
|
|
|
: [this.createSubHeading(`导游`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_6(use_year, agencyProducts['Q'])]),
|
|
|
|
: [this.createSubHeading(`导游`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_6Q(use_year, agencyProducts['Q'])]),
|
|
|
|
// this.createTable_Q(use_year, agencyProducts['Q']),
|
|
|
|
// this.createTable_Q(use_year, agencyProducts['Q']),
|
|
|
|
...(isEmpty(agencyProducts['7'])
|
|
|
|
...(isEmpty(agencyProducts['7'])
|
|
|
|
? []
|
|
|
|
? []
|
|
|
@ -346,7 +347,7 @@ export default class AgencyContract {
|
|
|
|
: [this.createSubHeading(`餐费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_R(use_year, agencyProducts['R'], agencyExtras)]),
|
|
|
|
: [this.createSubHeading(`餐费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_R(use_year, agencyProducts['R'], agencyExtras)]),
|
|
|
|
...(isEmpty(agencyProducts['D'])
|
|
|
|
...(isEmpty(agencyProducts['D'])
|
|
|
|
? []
|
|
|
|
? []
|
|
|
|
: [this.createSubHeading(`包价线路`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_J(use_year, agencyProducts['D'])]),
|
|
|
|
: [this.createSubHeading(`包价线路`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_JD(use_year, agencyProducts['D'])]),
|
|
|
|
this.createSubHeading(`公司银行账户`, { numbering: { reference: 'products-type', level: 0 } }),
|
|
|
|
this.createSubHeading(`公司银行账户`, { numbering: { reference: 'products-type', level: 0 } }),
|
|
|
|
this.createInfo_Bank(),
|
|
|
|
this.createInfo_Bank(),
|
|
|
|
this.createSubHeading(`联系资料`, { numbering: { reference: 'products-type', level: 0 } }),
|
|
|
|
this.createSubHeading(`联系资料`, { numbering: { reference: 'products-type', level: 0 } }),
|
|
|
@ -363,8 +364,9 @@ export default class AgencyContract {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 综费
|
|
|
|
* 综费
|
|
|
|
|
|
|
|
* 导游
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
createTable_6(use_year, dataList, style = {}) {
|
|
|
|
createTable_6Q(use_year, dataList, style = {}) {
|
|
|
|
const { chunk, SSRange, PSRange } = chunkBy(use_year, dataList, ['quote_season']);
|
|
|
|
const { chunk, SSRange, PSRange } = chunkBy(use_year, dataList, ['quote_season']);
|
|
|
|
|
|
|
|
|
|
|
|
return new Table({
|
|
|
|
return new Table({
|
|
|
@ -429,9 +431,11 @@ export default class AgencyContract {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 车费
|
|
|
|
* 车费
|
|
|
|
|
|
|
|
* 包价线路
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
createTable_J(use_year, dataList) {
|
|
|
|
createTable_JD(use_year, dataList) {
|
|
|
|
const { chunk, dataSource, sizeSets, SSRange, PSRange } = chunkBy(use_year, dataList, ['quote_season', 'quote_size']);
|
|
|
|
const { chunk, dataSource, sizeSets, SSRange, PSRange } = chunkBy(use_year, dataList, ['quote_season', 'quote_size']);
|
|
|
|
|
|
|
|
// console.log(chunk, dataSource, sizeSets);
|
|
|
|
|
|
|
|
|
|
|
|
return new Table({
|
|
|
|
return new Table({
|
|
|
|
borders: tableBorderNone,
|
|
|
|
borders: tableBorderNone,
|
|
|
|