|
|
@ -165,7 +165,8 @@ const todoTypes = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 顾问的邮箱目录
|
|
|
|
* 顾问的邮箱目录
|
|
|
|
* @param {object} { opi_sn, year, by_start_date, by_success, important, if_want_book, if_thinking }
|
|
|
|
* @param {object} params { opi_sn, year, by_start_date, by_success, important, if_want_book, if_thinking }
|
|
|
|
|
|
|
|
* @param {boolean} retOrder 是否直接返回订单列表 -- 忽略
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export const getEmailDirAction = async (params = { opi_sn: '' }, retOrder=false) => {
|
|
|
|
export const getEmailDirAction = async (params = { opi_sn: '' }, retOrder=false) => {
|
|
|
|
const defaultParams = { opi_sn: 0, year: dayjs().year(), by_start_date: -1, by_success: -1, important: -1, if_want_book: -1, if_thinking: -1 }
|
|
|
|
const defaultParams = { opi_sn: 0, year: dayjs().year(), by_start_date: -1, by_success: -1, important: -1, if_want_book: -1, if_thinking: -1 }
|
|
|
@ -177,6 +178,35 @@ export const getEmailDirAction = async (params = { opi_sn: '' }, retOrder=false)
|
|
|
|
const orderList = groupBy(result, row => `${row.IsTrue}`)?.['0'] || [];
|
|
|
|
const orderList = groupBy(result, row => `${row.IsTrue}`)?.['0'] || [];
|
|
|
|
return retOrder !== false ? orderList : { [`${params.opi_sn}`]: retTree }
|
|
|
|
return retOrder !== false ? orderList : { [`${params.opi_sn}`]: retTree }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getMailboxCountAction = async (params = { opi_sn: '' }, update = false) => {
|
|
|
|
|
|
|
|
const defaultParams = {
|
|
|
|
|
|
|
|
opi_sn: 0,
|
|
|
|
|
|
|
|
// date1: dayjs().subtract(1, 'year').startOf('year').format(DATE_FORMAT),
|
|
|
|
|
|
|
|
date1: dayjs().subtract(180, 'days').format(DATE_FORMAT),
|
|
|
|
|
|
|
|
date2: dayjs().format(DATEEND_FORMAT)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST_V3}/dir_count`, {...defaultParams, ...params})
|
|
|
|
|
|
|
|
const ret = errcode !== 0 ? { [`${params.opi_sn}`]: {} } : { [`${params.opi_sn}`]: result }
|
|
|
|
|
|
|
|
// 更新数量
|
|
|
|
|
|
|
|
if (update !== false) {
|
|
|
|
|
|
|
|
const readCacheDir = await readIndexDB(Number(params.opi_sn), 'dirs', 'mailbox');
|
|
|
|
|
|
|
|
const mailboxDir = isEmpty(readCacheDir) ? [] : readCacheDir.tree.filter(node => node._raw.IsTrue === 1);
|
|
|
|
|
|
|
|
const _MapDir = new Map(mailboxDir.map((obj) => [obj.key, obj]))
|
|
|
|
|
|
|
|
Object.keys(result).map(dirKey => {
|
|
|
|
|
|
|
|
_MapDir.set(Number(dirKey), {..._MapDir.get(Number(dirKey)), count: result[dirKey]});
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log(_MapDir, '_MapDir')
|
|
|
|
|
|
|
|
const _newToUpdate = Array.from(_MapDir.values());
|
|
|
|
|
|
|
|
const _MapRoot = new Map((readCacheDir?.tree || []).map((obj) => [obj.key, obj]))
|
|
|
|
|
|
|
|
_newToUpdate.forEach((row) => {
|
|
|
|
|
|
|
|
_MapRoot.set(row.key, row)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
const _newRoot = Array.from(_MapRoot.values())
|
|
|
|
|
|
|
|
writeIndexDB([{ key: Number(params.opi_sn), tree: _newRoot }], 'dirs', 'mailbox')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
};
|
|
|
|
export const getTodoOrdersAction = async (params) => {
|
|
|
|
export const getTodoOrdersAction = async (params) => {
|
|
|
|
const opi_arr = params.opisn.split(',')
|
|
|
|
const opi_arr = params.opisn.split(',')
|
|
|
|
const defaultStickyTree = opi_arr.reduce(
|
|
|
|
const defaultStickyTree = opi_arr.reduce(
|
|
|
@ -211,7 +241,7 @@ export const getTodoOrdersAction = async (params) => {
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/getwlorder`, params)
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/getwlorder`, params)
|
|
|
|
// 取后一个状态, 因此翻转两次
|
|
|
|
// 订单重复时, 取后一个状态, 因此翻转两次
|
|
|
|
const _result_unique = uniqWith(result.reverse(), (a, b) => a.COLI_SN === b.COLI_SN).reverse();
|
|
|
|
const _result_unique = uniqWith(result.reverse(), (a, b) => a.COLI_SN === b.COLI_SN).reverse();
|
|
|
|
const orderList = errcode === 0 ? _result_unique : []
|
|
|
|
const orderList = errcode === 0 ? _result_unique : []
|
|
|
|
const byOPI = groupBy(orderList, 'OPI_SN')
|
|
|
|
const byOPI = groupBy(orderList, 'OPI_SN')
|
|
|
@ -286,7 +316,9 @@ export const getRootMailboxDirAction = async ({ opi_sn = 0, userIdStr = '' } = {
|
|
|
|
getTodoOrdersAction({ opisn: userIdStr || String(opi_sn), otype: 'today' }),
|
|
|
|
getTodoOrdersAction({ opisn: userIdStr || String(opi_sn), otype: 'today' }),
|
|
|
|
...(userIdStr.split(',').map(_opi => getEmailDirAction({ opi_sn: _opi }))),
|
|
|
|
...(userIdStr.split(',').map(_opi => getEmailDirAction({ opi_sn: _opi }))),
|
|
|
|
])
|
|
|
|
])
|
|
|
|
const mailboxDirByOPI = mailboxDir.reduce((a, c) => ({...a, ...c}), {});
|
|
|
|
const mailBoxCount = await Promise.all(userIdStr.split(',').map(_opi => getMailboxCountAction({ opi_sn: _opi })));
|
|
|
|
|
|
|
|
const mailboxDirCountByOPI = mailBoxCount.reduce((a, c) => ({ ...a, ...c, }), {})
|
|
|
|
|
|
|
|
const mailboxDirByOPI = mailboxDir.reduce((a, c) => ({ ...a, ...(Object.keys(c).reduce((a, opi) => ({...a, [opi]: c[`${opi}`].map((dir) => ({ ...dir, count: mailboxDirCountByOPI[opi][`${dir.key}`] })) }), {} )) }), {})
|
|
|
|
const rootTree = Object.keys(stickyTree).map((opi) => ({ key: Number(opi), tree: [...stickyTree[opi], ...(mailboxDirByOPI?.[opi] || [])] }))
|
|
|
|
const rootTree = Object.keys(stickyTree).map((opi) => ({ key: Number(opi), tree: [...stickyTree[opi], ...(mailboxDirByOPI?.[opi] || [])] }))
|
|
|
|
writeIndexDB(rootTree, 'dirs', 'mailbox')
|
|
|
|
writeIndexDB(rootTree, 'dirs', 'mailbox')
|
|
|
|
const _mapped = groupBy(rootTree, 'key')
|
|
|
|
const _mapped = groupBy(rootTree, 'key')
|
|
|
@ -304,7 +336,8 @@ export const queryEmailListAction = async ({ opi_sn = '', pagesize = 10, last_id
|
|
|
|
vkey: 0,
|
|
|
|
vkey: 0,
|
|
|
|
vparent: 0,
|
|
|
|
vparent: 0,
|
|
|
|
order_source_type: 0,
|
|
|
|
order_source_type: 0,
|
|
|
|
mai_senddate1: dayjs().subtract(1, 'year').startOf('year').format(DATE_FORMAT),
|
|
|
|
// mai_senddate1: dayjs().subtract(1, 'year').startOf('year').format(DATE_FORMAT),
|
|
|
|
|
|
|
|
mai_senddate1: dayjs().subtract(180, 'days').format(DATE_FORMAT),
|
|
|
|
mai_senddate2: dayjs().format(DATEEND_FORMAT),
|
|
|
|
mai_senddate2: dayjs().format(DATEEND_FORMAT),
|
|
|
|
...omitEmpty({
|
|
|
|
...omitEmpty({
|
|
|
|
...node,
|
|
|
|
...node,
|
|
|
|