|
|
@ -1,7 +1,9 @@
|
|
|
|
import { makeAutoObservable, runInAction } from 'mobx';
|
|
|
|
import { makeAutoObservable, runInAction } from 'mobx';
|
|
|
|
import { fetchJSON } from '../utils/request';
|
|
|
|
import { fetchJSON } from '../utils/request';
|
|
|
|
import { objectMapper } from '../utils/commons';
|
|
|
|
import { objectMapper, pick, price_to_number, } from '../utils/commons';
|
|
|
|
import { pivotBy } from './../libs/ht';
|
|
|
|
import { pivotBy } from './../libs/ht';
|
|
|
|
|
|
|
|
import moment from "moment";
|
|
|
|
|
|
|
|
import { DATE_FORMAT } from './../config';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 用于透视的数据
|
|
|
|
* 用于透视的数据
|
|
|
@ -27,6 +29,17 @@ const getOrderCountByType = async (param) => {
|
|
|
|
const json = await fetchJSON(url, paramBody);
|
|
|
|
const json = await fetchJSON(url, paramBody);
|
|
|
|
return json.errcode === 0 ? json : {};
|
|
|
|
return json.errcode === 0 ? json : {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const getAgentGroupInfoALL = async (param) => {
|
|
|
|
|
|
|
|
const paramBody = objectMapper(param, {
|
|
|
|
|
|
|
|
DateType: 'DateType',
|
|
|
|
|
|
|
|
DepartmentList: 'DepList', // { key: 'DepartmentList', transform: (v) => v.join(',') },
|
|
|
|
|
|
|
|
Date1: 'OldDate1',
|
|
|
|
|
|
|
|
Date2: 'OldDate2',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const url = '/service-web/QueryData/GetAgentGroupInfoALL';
|
|
|
|
|
|
|
|
const json = await fetchJSON(url, paramBody);
|
|
|
|
|
|
|
|
return json.errcode === 0 ? json : {};
|
|
|
|
|
|
|
|
};
|
|
|
|
const GHproductTypeListSetting = {
|
|
|
|
const GHproductTypeListSetting = {
|
|
|
|
ja: ['日本', '东亚跨国'],
|
|
|
|
ja: ['日本', '东亚跨国'],
|
|
|
|
se: ['东南亚跨国', '泰国', '越南', '印度尼西亚', '水灯节'],
|
|
|
|
se: ['东南亚跨国', '泰国', '越南', '印度尼西亚', '水灯节'],
|
|
|
@ -89,6 +102,29 @@ const dataGHOther = (rawData, yearData) => {
|
|
|
|
return { ...rowItem(filterData), rowYear };
|
|
|
|
return { ...rowItem(filterData), rowYear };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dataSales = (tKey, rawData, yearData) => {
|
|
|
|
|
|
|
|
const productTypeList = GHproductTypeListSetting[tKey];
|
|
|
|
|
|
|
|
const filterData = rawData.filter((ele) => productTypeList.some((item) => ele.OrderType.toLocaleLowerCase().indexOf(item) !== -1));
|
|
|
|
|
|
|
|
const filterDataYear = yearData.filter((ele) => productTypeList.some((item) => ele.OrderType.toLocaleLowerCase().indexOf(item) !== -1));
|
|
|
|
|
|
|
|
const rowYearData = ['YJLY', 'CJCount'].reduce((r, key) => ({ ...r, [key]: filterDataYear.reduce((a, c) => a + price_to_number(c[key]), 0) }), {});
|
|
|
|
|
|
|
|
const rowYear = { YJLY: price_to_number(rowYearData.YJLY), CJCount: rowYearData.CJCount };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const cols = ['YJLY', 'CJCount'].reduce((r, key) => ({ ...r, [key]: filterData.reduce((a, c) => a + price_to_number(c[key]), 0) }), {});
|
|
|
|
|
|
|
|
// console.log(tKey, filterData, filterDataYear);
|
|
|
|
|
|
|
|
return { ...cols, rowYear };
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const dataSalesGHOther = (rawData, yearData) => {
|
|
|
|
|
|
|
|
const exceptProduct = Object.values(GHproductTypeListSetting).reduce((r, c) => r.concat(c), []);
|
|
|
|
|
|
|
|
const filterData = rawData.filter((ele) => exceptProduct.every((item) => ele.OrderType.toLocaleLowerCase().indexOf(item) === -1));
|
|
|
|
|
|
|
|
const filterDataYear = yearData.filter((ele) => exceptProduct.every((item) => ele.OrderType.toLocaleLowerCase().indexOf(item) === -1));
|
|
|
|
|
|
|
|
const rowYearData = ['YJLY', 'CJCount'].reduce((r, key) => ({ ...r, [key]: filterDataYear.reduce((a, c) => a + price_to_number(c[key]), 0) }), {});
|
|
|
|
|
|
|
|
const rowYear = { YJLY: price_to_number(rowYearData.YJLY), CJCount: rowYearData.CJCount };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const cols = ['YJLY', 'CJCount'].reduce((r, key) => ({ ...r, [key]: filterData.reduce((a, c) => a + price_to_number(c[key]), 0) }), {});
|
|
|
|
|
|
|
|
// console.log('Oo', filterData, filterDataYear);
|
|
|
|
|
|
|
|
return { ...cols, rowYear };
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class MeetingData {
|
|
|
|
class MeetingData {
|
|
|
|
constructor(rootStore) {
|
|
|
|
constructor(rootStore) {
|
|
|
|
this.rootStore = rootStore;
|
|
|
|
this.rootStore = rootStore;
|
|
|
@ -104,22 +140,27 @@ class MeetingData {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GHTableData = [];
|
|
|
|
GHTableData = [];
|
|
|
|
GHLoading = false;
|
|
|
|
GHTableLoading = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
dataGH = async (param) => {
|
|
|
|
* 获取市场订单数据
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
dataGHOrder = async (param) => {
|
|
|
|
// console.log('dataGH', param);
|
|
|
|
// console.log('dataGH', param);
|
|
|
|
this.GHLoading = true;
|
|
|
|
this.GHTableLoading = true;
|
|
|
|
|
|
|
|
const defaultParam = { DateType: 'applyDate' };
|
|
|
|
// 本周
|
|
|
|
// 本周
|
|
|
|
const CHData = await getDetailData({ ...param, 'DepartmentList': '1', 'WebCode': 'All' });
|
|
|
|
const CHData = await getDetailData({ ...param, ...defaultParam, 'DepartmentList': '1', 'WebCode': 'All' });
|
|
|
|
const exceptCHData = await getDetailData({ ...param, 'DepartmentList': '28,33', 'WebCode': 'All' });
|
|
|
|
const exceptCHData = await getDetailData({ ...param, ...defaultParam, 'DepartmentList': '28,33', 'WebCode': 'All' });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const yearStart = moment().startOf("year").format(DATE_FORMAT);
|
|
|
|
/** 截至今年 - 行 */
|
|
|
|
/** 截至今年 - 行 */
|
|
|
|
const { ordercountTotal1: CHDataYear } = await getOrderCountByType({ ...param, Date1: '2024-01-01', 'DepartmentList': '1', 'WebCode': 'All', OrderType: 'LineClass' });
|
|
|
|
const { ordercountTotal1: CHDataYear } = await getOrderCountByType({ ...param, ...defaultParam, Date1: yearStart, 'DepartmentList': '1', 'WebCode': 'All', OrderType: 'LineClass' });
|
|
|
|
const { ordercount1: exceptCHDataYear } = await getOrderCountByType({ ...param, Date1: '2024-01-01', 'DepartmentList': '28,33', 'WebCode': 'All', OrderType: 'Product' });
|
|
|
|
const { ordercount1: exceptCHDataYear } = await getOrderCountByType({ ...param, ...defaultParam, Date1: yearStart, 'DepartmentList': '28,33', 'WebCode': 'All', OrderType: 'Product' });
|
|
|
|
/** 截至今年 - 列 */
|
|
|
|
/** 截至今年 - 列 */
|
|
|
|
const { ordercount1: ColLineClassDataYear } = await getOrderCountByType({ ...param, Date1: '2024-01-01', 'DepartmentList': '1,2,28,7,33', 'WebCode': 'All', OrderType: 'LineClass' });
|
|
|
|
const { ordercount1: ColLineClassDataYear } = await getOrderCountByType({ ...param, ...defaultParam, Date1: yearStart, 'DepartmentList': '1,2,28,7,33', 'WebCode': 'All', OrderType: 'LineClass' });
|
|
|
|
const { ordercountTotal1: ColToBDataYear } = await getOrderCountByType({ ...param, Date1: '2024-01-01', 'DepartmentList': '1,2,28,7,33', 'WebCode': 'GHTOBHW,GHTOBZG', OrderType: 'LineClass' });
|
|
|
|
const { ordercountTotal1: ColToBDataYear } = await getOrderCountByType({ ...param, ...defaultParam, Date1: yearStart, 'DepartmentList': '1,2,28,7,33', 'WebCode': 'GHTOBHW,GHTOBZG', OrderType: 'LineClass' });
|
|
|
|
// 老客户
|
|
|
|
// 老客户
|
|
|
|
const yearDetail = await getDetailData({ ...param, Date1: '2024-01-01', 'DepartmentList': '1,2,28,7,33', 'WebCode': 'All' });
|
|
|
|
const yearDetail = await getDetailData({ ...param, ...defaultParam, Date1: yearStart, 'DepartmentList': '1,2,28,7,33', 'WebCode': 'All' });
|
|
|
|
const { isOld1: isOld1Year } = rowItem(yearDetail);
|
|
|
|
const { isOld1: isOld1Year } = rowItem(yearDetail);
|
|
|
|
|
|
|
|
|
|
|
|
const colYearRow = {
|
|
|
|
const colYearRow = {
|
|
|
@ -145,10 +186,80 @@ class MeetingData {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
rows.push({ key: 'columnSum', label: '合计', ...columnsSum });
|
|
|
|
rows.push({ key: 'columnSum', label: '合计', ...columnsSum });
|
|
|
|
rows.push({ key: 'colYearRow', label: '截至', ...colYearRow });
|
|
|
|
rows.push({ key: 'colYearRow', label: '截至', ...colYearRow });
|
|
|
|
// console.log(rows);
|
|
|
|
|
|
|
|
runInAction(() => {
|
|
|
|
runInAction(() => {
|
|
|
|
this.GHTableData = rows;
|
|
|
|
this.GHTableData = rows;
|
|
|
|
this.GHLoading = false;
|
|
|
|
this.GHTableLoading = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GHSalesTableData = [];
|
|
|
|
|
|
|
|
GHSalesLoading = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取GH销售数据
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
dataGHSales = async (param) => {
|
|
|
|
|
|
|
|
this.GHSalesLoading = true;
|
|
|
|
|
|
|
|
const salesParam = { ...param, DateType: 'confirmDate' };
|
|
|
|
|
|
|
|
// console.log(param);
|
|
|
|
|
|
|
|
const { ordercountTotal1: CHSalesDataWeek } = await getOrderCountByType({ ...salesParam, 'DepartmentList': '1', 'WebCode': 'All', OrderType: 'LineClass' });
|
|
|
|
|
|
|
|
const { ordercount1: exceptCHSalesDataWeek } = await getOrderCountByType({ ...salesParam, 'DepartmentList': '28,33', 'WebCode': 'All', OrderType: 'Product' });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const yearStart = moment().startOf("year").format(DATE_FORMAT);
|
|
|
|
|
|
|
|
const yearEnd = moment().endOf("year").format(DATE_FORMAT);
|
|
|
|
|
|
|
|
/** 截至今年 - 成交 */
|
|
|
|
|
|
|
|
const { ordercountTotal1: CHDataYear } = await getOrderCountByType({ ...salesParam, Date1: yearStart,Date2:yearEnd, 'DepartmentList': '1', 'WebCode': 'All', OrderType: 'LineClass' });
|
|
|
|
|
|
|
|
const { ordercount1: ColLineClassDataYear } = await getOrderCountByType({ ...salesParam, Date1: yearStart,Date2:yearEnd, 'DepartmentList': '28,33', WebCode: 'All', OrderType: 'Product' });
|
|
|
|
|
|
|
|
/** 截至今年 - 走团 */
|
|
|
|
|
|
|
|
const { ordercountTotal1: CHStartDataYear } = await getOrderCountByType({ ...salesParam, Date1: yearStart,Date2:yearEnd, DepartmentList: '1', 'WebCode': 'All', OrderType: 'LineClass', DateType: 'startDate' });
|
|
|
|
|
|
|
|
const { ordercount1: GHStartDataYear } = await getOrderCountByType({ ...salesParam, Date1: yearStart,Date2:yearEnd, DepartmentList: '28,33', WebCode: 'All', OrderType: 'Product', DateType: 'startDate' });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rows = [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
key: 'ch',
|
|
|
|
|
|
|
|
label: '中国',
|
|
|
|
|
|
|
|
YJLY: price_to_number(CHSalesDataWeek.YJLY),
|
|
|
|
|
|
|
|
CJCount: (CHSalesDataWeek.CJCount),
|
|
|
|
|
|
|
|
rowYear: { YJLY: price_to_number(CHDataYear.YJLY), CJCount: CHDataYear.CJCount, StartProfit: price_to_number(CHStartDataYear.YJLY) },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{ key: 'ja', label: '日本+', ...dataSales('ja', exceptCHSalesDataWeek, ColLineClassDataYear) },
|
|
|
|
|
|
|
|
{ key: 'se', label: '东南亚+', ...dataSales('se', exceptCHSalesDataWeek, ColLineClassDataYear) },
|
|
|
|
|
|
|
|
{ key: 'in', label: '印度+', ...dataSales('in', exceptCHSalesDataWeek, ColLineClassDataYear) },
|
|
|
|
|
|
|
|
{ key: 'other', label: '其他GH', ...dataSalesGHOther(exceptCHSalesDataWeek, ColLineClassDataYear) },
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
const columnsSum = ['CJCount', 'YJLY'].reduce((r, col) => ({ ...r, [col]: rows.reduce((rr, row) => rr + row[col], 0) }), {});
|
|
|
|
|
|
|
|
const allYearData = rows.map(row => row.rowYear);
|
|
|
|
|
|
|
|
const rowYear = ['CJCount', 'YJLY'].reduce((r, col) => ({ ...r, [col]: allYearData.reduce((rr, row) => rr + row[col], 0) }), {});
|
|
|
|
|
|
|
|
rows.push({ key: 'columnSum', label: '合计', ...columnsSum, rowYear });
|
|
|
|
|
|
|
|
// console.log(rows, rowYear);
|
|
|
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
|
|
|
this.GHSalesTableData = rows;
|
|
|
|
|
|
|
|
this.GHSalesLoading = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GHServiceTableData = [];
|
|
|
|
|
|
|
|
GHServiceLoading = false;
|
|
|
|
|
|
|
|
dataGHService = async (param) => {
|
|
|
|
|
|
|
|
this.GHServiceLoading = true;
|
|
|
|
|
|
|
|
const serviceParam = { ...param, DateType: 'startDate' };
|
|
|
|
|
|
|
|
const { total1: CHDataWeek } = await getAgentGroupInfoALL({ ...serviceParam, 'DepartmentList': '1', });
|
|
|
|
|
|
|
|
const yearStart = moment().startOf("year").format(DATE_FORMAT);
|
|
|
|
|
|
|
|
const { total1: CHDataYear } = await getAgentGroupInfoALL({ ...serviceParam, Date1: yearStart, 'DepartmentList': '1', });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const { total1: yearData } = await getAgentGroupInfoALL({ ...serviceParam, 'DepartmentList': '28,33', Country: 'foreign' });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rows = [
|
|
|
|
|
|
|
|
{ key: 'ch', label: '中国', ...pick(CHDataWeek, ['GroupCount', 'GoodCount']), rowYear: { GroupCount: CHDataYear.GroupCount, GoodCount: CHDataYear.GoodCount } },
|
|
|
|
|
|
|
|
// { key: 'ja', label: '日本+', ...dataJA(exceptCHData, exceptCHDataYear) },
|
|
|
|
|
|
|
|
// { key: 'se', label: '东南亚+', ...dataSE(exceptCHData, exceptCHDataYear) },
|
|
|
|
|
|
|
|
// { key: 'in', label: '印度+', ...dataIN(exceptCHData, exceptCHDataYear) },
|
|
|
|
|
|
|
|
// { key: 'other', label: '其他GH', ...dataGHOther(exceptCHData, exceptCHDataYear) },
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
// console.log(rows);
|
|
|
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
|
|
|
this.GHServiceTableData = rows;
|
|
|
|
|
|
|
|
this.GHServiceLoading = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|