Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yuyixcx
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
yuyixcx
Commits
33f487e6
Commit
33f487e6
authored
Jan 01, 2026
by
chenjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
cf36e6b3
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
994 additions
and
132 deletions
+994
-132
serverConfig.xml
serverConfig.xml
+2
-1
enterpriseInfo.ts
src/biz/enterpriseInfo.ts
+493
-115
finance.ts
src/biz/finance.ts
+11
-2
massageNotice.ts
src/biz/massageNotice.ts
+391
-0
dbEnum.ts
src/config/enum/dbEnum.ts
+5
-0
enum.ts
src/config/enum/enum.ts
+28
-1
errorEnum.ts
src/config/enum/errorEnum.ts
+2
-0
enterpriseInfo.ts
src/routers/enterpriseInfo.ts
+5
-5
files.ts
src/routers/files.ts
+1
-1
finance.ts
src/routers/finance.ts
+1
-1
gaoxin.ts
src/routers/gaoxin.ts
+1
-1
notification.ts
src/routers/notification.ts
+44
-0
public.ts
src/routers/public.ts
+1
-1
qualification.ts
src/routers/qualification.ts
+1
-1
router.ts
src/routers/router.ts
+4
-0
teams.ts
src/routers/teams.ts
+1
-1
system.ts
src/tools/system.ts
+3
-2
No files found.
serverConfig.xml
View file @
33f487e6
<config>
<port>
9099
</port>
<sign>
xxx90909082fsdahfjosadjfpoiwausjorip2hjklrhn1ioud0u124rx0qwejfokasjfolksaujfoas
</sign>
<dbServer>
http://192.168.0.71:
9096
</dbServer>
<dbServer>
http://192.168.0.71:
40012
</dbServer>
</config>
\ No newline at end of file
src/biz/enterpriseInfo.ts
View file @
33f487e6
...
...
@@ -2,7 +2,7 @@
* 企业信息汇总
* */
import
{
EnterpriseFaRenInfoUpdateConfig
,
EnterpriseInfomationUpdateConfig
,
enterpriseLeaseUpdateConfig
,
EnterpriseServiceUpdateConfig
}
from
"../config/eccParam/enterprise"
;
import
{
EnterpriseFaRenInfoUpdateConfig
,
EnterpriseInfomationUpdateConfig
,
enterpriseLeaseUpdateConfig
,
Enterprise
ManageInfoAddConfig
,
EnterpriseManageInfoUpdateConfig
,
Enterprise
ServiceUpdateConfig
}
from
"../config/eccParam/enterprise"
;
import
{
OPERATIONALDATATYPE
,
TABLEID
,
TABLENAME
}
from
"../config/enum/dbEnum"
;
import
*
as
enumConfig
from
"../config/enum/enum"
;
import
{
EnterpriseBaseResConfig
,
EnterpriseFaRenInfoResConfig
,
EnterpriseInfomationResConfig
,
EnterpriseLeaseInfoResConfig
,
EnterpriseQualificationInfoResConfig
}
from
"../config/splitResult/enterprise"
;
...
...
@@ -12,64 +12,206 @@ import { checkChange, extractData } from "../util/piecemeal";
import
{
changeEnumValue
,
eccEnumValue
}
from
"../util/verificationEnum"
;
import
{
eccFormParam
}
from
"../util/verificationParam"
;
import
{
ERRORENUM
}
from
"../config/enum/errorEnum"
;
import
{
getAddresList
,
getDeclarationTime
,
getLastDeclarationTime
,
getMySqlMs
,
getToken
,
randomId
}
from
"../tools/system"
;
import
{
getAddresList
,
getDeclarationTime
,
getLastDeclarationTime
,
getMySqlMs
,
get
PwdMd5
,
get
Token
,
randomId
}
from
"../tools/system"
;
import
moment
=
require
(
"moment"
);
import
{
sendVerificationCode
}
from
"./mail"
;
//==登录登出
//企业用户表没有存uscc字段,先查询到企业eId,然后到用户表查询密码判断是否登录成功
export
async
function
enterpriseLogin
(
phone
:
string
,
pwd
:
string
)
{
let
filesList
=
[
"userName"
,
"eId"
,
"pwd"
,
"uId"
,
"phone"
];
/**
* 使用加密后的密码判断登录
* @param phone
* @param pwd
* @returns
*/
export
async
function
enterpriseLogin
(
phone
:
string
,
pwd
:
string
)
{
let
filesList
=
[
"userName"
,
"eId"
,
"pwd"
,
"uId"
,
"phone"
,
"uscc"
];
let
userDbData
=
await
selectData
(
OPERATIONALDATATYPE
.
查询多个
,
TABLENAME
.
企业用户表
,
{
phone
},
filesList
);
if
(
!
userDbData
.
length
)
throw
new
BizError
(
ERRORENUM
.
账号或密码错误
);
let
eId
=
userDbData
[
0
].
eId
;
let
enterpriseUserInfo
=
userDbData
[
0
];
// if (userDbData.length > 1) {
// if (phone == "13601665163") {
// eId = userDbData[1].eId;
// enterpriseUserInfo = userDbData[1];
// }
// }
let
eId
=
""
;
let
enterpriseUserInfo
;
if
(
userDbData
.
length
>
1
)
{
let
includePhoneConf
=
{};
// includePhoneConf[TABLENAME.企业孵化信息] = {colum:["state", "startTime", "endTime"], where:{state:{"%ne%":enumConfig.FUHUASTATE.迁出}} };
includePhoneConf
[
TABLENAME
.
企业孵化信息
]
=
{
colum
:[
"state"
,
"startTime"
,
"endTime"
],
where
:{}
};
includePhoneConf
[
TABLENAME
.
企业用户表
]
=
{
colum
:
filesList
,
where
:{
phone
}};
let
userEnterpriseData
=
await
selectManyTableData
(
OPERATIONALDATATYPE
.
多表单个
,
TABLENAME
.
企业基础信息表
,
{
state
:
enumConfig
.
CHANGESTATE
.
已通过
},
[
"enterpriseName"
],
includePhoneConf
);
eId
=
userEnterpriseData
.
enterprise_users
[
0
].
eId
;
enterpriseUserInfo
=
userEnterpriseData
.
enterprise_users
[
0
];
}
else
{
eId
=
userDbData
[
0
].
eId
;
enterpriseUserInfo
=
userDbData
[
0
];
}
console
.
log
(
eId
);
if
(
!
eId
)
throw
new
BizError
(
ERRORENUM
.
账号或密码错误
);
let
includeConf
=
{};
includeConf
[
TABLENAME
.
企业孵化信息
]
=
{
colum
:[
"state"
,
"startTime"
,
"endTime"
],
where
:{
state
:{
"%ne%"
:
enumConfig
.
FUHUASTATE
.
迁出
}}
};
let
enterpriseInfo
=
await
selectManyTableData
(
OPERATIONALDATATYPE
.
多表单个
,
TABLENAME
.
企业基础信息表
,
{
state
:
enumConfig
.
CHANGESTATE
.
已通过
,
eId
},
[
"enterpriseName"
],
includeConf
);
// includeConf[TABLENAME.企业孵化信息] = {colum:["state", "startTime", "endTime"], where:{state:{"%ne%":enumConfig.FUHUASTATE.迁出}} };
// includeConf[TABLENAME.企业用户表] = {colum:filesList, where:{phone} };
// let enterpriseInfo = await selectManyTableData(OPERATIONALDATATYPE.多表单个, TABLENAME.企业基础信息表, {state:enumConfig.CHANGESTATE.已通过}, ["enterpriseName"], includeConf
);
let
enterpriseInfo
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业基础信息表
,
{
state
:
enumConfig
.
CHANGESTATE
.
已通过
,
eId
},
[
"enterpriseName"
]
);
if
(
!
enterpriseInfo
||
!
enterpriseInfo
.
enterpriseName
)
{
throw
new
BizError
(
ERRORENUM
.
账号或密码错误
);
}
// let {enterprise_users} = enterpriseInfo;
// let enterpriseUserInfo = enterprise_users[0];
if
(
!
enterpriseUserInfo
||
!
enterpriseUserInfo
.
phone
)
{
throw
new
BizError
(
ERRORENUM
.
账号或密码错误
);
}
if
(
enterpriseUserInfo
.
pwd
!=
pwd
)
{
//使用uId作为盐值进行加密
const
encryptedInputPwd
=
getPwdMd5
(
enterpriseUserInfo
.
uId
,
pwd
);
if
(
enterpriseUserInfo
.
pwd
!==
encryptedInputPwd
)
{
throw
new
BizError
(
ERRORENUM
.
账号或密码错误
);
}
// if (enterpriseUserInfo.pwd !== pwd) {
// throw new BizError(ERRORENUM.账号或密码错误);
// }
let
updateUserInfo
=
{
token
:
getToken
(
enterprise
Info
.
uId
),
tokenMs
:
getMySqlMs
()
token
:
getToken
(
enterpriseUser
Info
.
uId
),
tokenMs
:
getMySqlMs
()
};
await
operationalData
(
OPERATIONALDATATYPE
.
修改
,
TABLENAME
.
企业用户表
,
updateUserInfo
,
{
uId
:
enterpriseUserInfo
.
uId
});
await
operationalData
(
OPERATIONALDATATYPE
.
修改
,
TABLENAME
.
企业用户表
,
updateUserInfo
,
{
uId
:
enterpriseUserInfo
.
uId
}
);
let
userInfo
=
{
userId
:
enterpriseUserInfo
.
uId
,
userName
:
enterpriseUserInfo
.
userName
,
phone
:
enterpriseUserInfo
.
phone
,
token
:
updateUserInfo
.
token
,
userId
:
enterpriseUserInfo
.
uId
,
userName
:
enterpriseUserInfo
.
userName
,
phone
:
enterpriseUserInfo
.
phone
,
token
:
updateUserInfo
.
token
,
};
return
{
dataInfo
:
userInfo
};
return
{
dataInfo
:
userInfo
};
}
//企业用户表没有存uscc字段,先查询到企业eId,然后到用户表查询密码判断是否登录成功
// export async function enterpriseLogin(phone:string, pwd:string) {
// let filesList = ["userName", "eId", "pwd", "uId", "phone"];
// let userDbData = await selectData(OPERATIONALDATATYPE.查询多个, TABLENAME.企业用户表, { phone }, filesList);
// if (!userDbData.length) throw new BizError(ERRORENUM.账号或密码错误);
// let userEnterpriseData = await selectData(OPERATIONALDATATYPE.查询多个, TABLENAME.企业用户表, { phone }, filesList);
// let eId = "";
// let enterpriseUserInfo;
// if (userDbData.length > 1) {
// let includePhoneConf = {};
// includePhoneConf[TABLENAME.企业孵化信息] = {colum:["state", "startTime", "endTime"], where:{state:{"%ne%":enumConfig.FUHUASTATE.迁出}} };
// includePhoneConf[TABLENAME.企业用户表] = {colum:filesList, where:{phone}};
// userEnterpriseData = await selectManyTableData(OPERATIONALDATATYPE.多表单个, TABLENAME.企业基础信息表, {state:enumConfig.CHANGESTATE.已通过}, ["enterpriseName"], includePhoneConf);
// eId = userEnterpriseData.enterprise_users[0].eId;
// enterpriseUserInfo = userEnterpriseData.enterprise_users[0];
// } else {
// eId = userEnterpriseData[0].eId;
// enterpriseUserInfo = userEnterpriseData[0];
// }
// if (!eId) throw new BizError(ERRORENUM.账号或密码错误);
// let includeConf = {};
// includeConf[TABLENAME.企业孵化信息] = {colum:["state", "startTime", "endTime"], where:{state:{"%ne%":enumConfig.FUHUASTATE.迁出}} };
// let enterpriseInfo = await selectManyTableData(OPERATIONALDATATYPE.多表单个, TABLENAME.企业基础信息表, {state:enumConfig.CHANGESTATE.已通过, eId}, ["enterpriseName"], includeConf);
// // includeConf[TABLENAME.企业孵化信息] = {colum:["state", "startTime", "endTime"], where:{state:{"%ne%":enumConfig.FUHUASTATE.迁出}} };
// // includeConf[TABLENAME.企业用户表] = {colum:filesList, where:{phone} };
// // let enterpriseInfo = await selectManyTableData(OPERATIONALDATATYPE.多表单个, TABLENAME.企业基础信息表, {state:enumConfig.CHANGESTATE.已通过}, ["enterpriseName"], includeConf);
// if (!enterpriseInfo || !enterpriseInfo.enterpriseName) {
// throw new BizError(ERRORENUM.账号或密码错误);
// }
// // let {enterprise_users} = enterpriseInfo;
// // let enterpriseUserInfo = enterprise_users[0];
// if (!enterpriseUserInfo || !enterpriseUserInfo.phone) {
// throw new BizError(ERRORENUM.账号或密码错误);
// }
// if (enterpriseUserInfo.pwd != pwd) {
// throw new BizError(ERRORENUM.账号或密码错误);
// }
// let updateUserInfo = {
// token : getToken(enterpriseInfo.uId),
// tokenMs : getMySqlMs()
// };
// await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.企业用户表, updateUserInfo, {uId:enterpriseUserInfo.uId});
// let userInfo = {
// userId:enterpriseUserInfo.uId,
// userName:enterpriseUserInfo.userName,
// phone:enterpriseUserInfo.phone,
// token:updateUserInfo.token,
// };
// return {dataInfo:userInfo};
// }
// export async function enterpriseLogin(phone:string, pwd:string) {
// let filesList = ["userName", "eId", "pwd", "uId", "phone"];
// let userDbData = await selectData(OPERATIONALDATATYPE.查询多个, TABLENAME.企业用户表, { phone }, filesList);
// if (!userDbData.length) throw new BizError(ERRORENUM.账号或密码错误);
// let eId = userDbData[0].eId;
// let enterpriseUserInfo = userDbData[0];
// // if (userDbData.length > 1) {
// // if (phone == "13601665163") {
// // eId = userDbData[1].eId;
// // enterpriseUserInfo = userDbData[1];
// // }
// // }
// if (!eId) throw new BizError(ERRORENUM.账号或密码错误);
// let includeConf = {};
// includeConf[TABLENAME.企业孵化信息] = {colum:["state", "startTime", "endTime"], where:{state:{"%ne%":enumConfig.FUHUASTATE.迁出}} };
// let enterpriseInfo = await selectManyTableData(OPERATIONALDATATYPE.多表单个, TABLENAME.企业基础信息表, {state:enumConfig.CHANGESTATE.已通过, eId}, ["enterpriseName"], includeConf);
// // includeConf[TABLENAME.企业孵化信息] = {colum:["state", "startTime", "endTime"], where:{state:{"%ne%":enumConfig.FUHUASTATE.迁出}} };
// // includeConf[TABLENAME.企业用户表] = {colum:filesList, where:{phone} };
// // let enterpriseInfo = await selectManyTableData(OPERATIONALDATATYPE.多表单个, TABLENAME.企业基础信息表, {state:enumConfig.CHANGESTATE.已通过}, ["enterpriseName"], includeConf);
// if (!enterpriseInfo || !enterpriseInfo.enterpriseName) {
// throw new BizError(ERRORENUM.账号或密码错误);
// }
// // let {enterprise_users} = enterpriseInfo;
// // let enterpriseUserInfo = enterprise_users[0];
// if (!enterpriseUserInfo || !enterpriseUserInfo.phone) {
// throw new BizError(ERRORENUM.账号或密码错误);
// }
// if (enterpriseUserInfo.pwd != pwd) {
// throw new BizError(ERRORENUM.账号或密码错误);
// }
// let updateUserInfo = {
// token : getToken(enterpriseInfo.uId),
// tokenMs : getMySqlMs()
// };
// await operationalData(OPERATIONALDATATYPE.修改, TABLENAME.企业用户表, updateUserInfo, {uId:enterpriseUserInfo.uId});
// let userInfo = {
// userId:enterpriseUserInfo.uId,
// userName:enterpriseUserInfo.userName,
// phone:enterpriseUserInfo.phone,
// token:updateUserInfo.token,
// };
// return {dataInfo:userInfo};
// }
/**
* 修改密码
* @param uId
...
...
@@ -85,7 +227,7 @@ export async function changePassword(uId:string, pwd:string, newPwd:string, conf
/**验证当前密码 */
if
(
pwd
!=
enterpriseInfo
.
pwd
)
throw
new
BizError
(
ERRORENUM
.
原密码错误
);
//
if (newPwd != confirmPwd) throw new BizError(ERRORENUM.密码不一致);
if
(
newPwd
!=
confirmPwd
)
throw
new
BizError
(
ERRORENUM
.
密码不一致
);
if
(
newPwd
.
search
(
/^
[
A-Za-z0-9
]{6,18}
$/
)
<
0
)
throw
new
BizError
(
ERRORENUM
.
密码只能由
6
至
18
位字符和数字组成
);
await
operationalData
(
OPERATIONALDATATYPE
.
修改
,
TABLENAME
.
企业用户表
,
{
pwd
:
newPwd
},
{
uId
});
...
...
@@ -277,7 +419,7 @@ export async function homePage(eId:string) {
chongYeRenYuan
,
zhengCeList
:
zhengCeList
,
manage
:{
lastYear
:{
BI
:
"未填报"
,
TXP
:
"未填报"
,
RD
:
"未填报"
},
//
lastYear:{BI:"未填报", TXP:"未填报", RD:"未填报"},
thisYear
:{
BI
:
"未填报"
,
TXP
:
"未填报"
,
RD
:
"未填报"
}
}
}
...
...
@@ -285,91 +427,344 @@ export async function homePage(eId:string) {
let
thisYear
=
new
Date
().
getFullYear
();
let
jysjFile
=
[
"BI"
,
"TXP"
,
"RD"
,
"mId"
,
"annual"
,
"quarter"
];
let
thisQuarter
=
getDeclarationTime
();
let
thisYearjJysjInfo
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业经营信息
,
{
eId
,
isSubmit
:
1
,
annual
:
thisQuarter
.
declarationYear
,
quarter
:
thisQuarter
.
declarationQuarter
},
jysjFile
);
// 修改为获取本年度的数据,不再按季度查询
let
thisYearStartTime
=
getMySqlMs
(
`
${
thisYear
}
-01-01 00:00:00`
);
let
thisYearJysjList
=
await
selectData
(
OPERATIONALDATATYPE
.
查询多个
,
TABLENAME
.
企业经营信息
,
{
eId
,
isSubmit
:
1
,
annual
:
thisYearStartTime
},
jysjFile
);
if
(
thisYearJysjList
&&
thisYearJysjList
.
length
>
0
)
{
// 汇总本年度的数据
let
totalBI
=
0
;
let
totalTXP
=
0
;
let
totalRD
=
0
;
let
count
=
0
;
thisYearJysjList
.
forEach
(
item
=>
{
if
(
!
isNaN
(
parseFloat
(
item
.
BI
)))
{
totalBI
+=
parseFloat
(
item
.
BI
);
}
if
(
!
isNaN
(
parseFloat
(
item
.
TXP
)))
{
totalTXP
+=
parseFloat
(
item
.
TXP
);
}
if
(
!
isNaN
(
parseFloat
(
item
.
RD
)))
{
totalRD
+=
parseFloat
(
item
.
RD
);
}
count
++
;
});
if
(
thisYearjJysjInfo
&&
thisYearjJysjInfo
.
mId
)
{
dataInfo
.
manage
.
thisYear
.
BI
=
!
isNaN
(
thisYearjJysjInfo
.
BI
)
?
thisYearjJysjInfo
.
BI
:
"未填报"
;
dataInfo
.
manage
.
thisYear
.
TXP
=
!
isNaN
(
thisYearjJysjInfo
.
TXP
)
?
thisYearjJysjInfo
.
TXP
:
"未填报"
;
dataInfo
.
manage
.
thisYear
.
RD
=
!
isNaN
(
thisYearjJysjInfo
.
RD
)
?
thisYearjJysjInfo
.
RD
:
"未填报"
;
// 计算平均值或总和,根据业务需求选择
// 如果是要显示累计值,直接使用总和
dataInfo
.
manage
.
thisYear
.
BI
=
count
>
0
?
totalBI
.
toFixed
(
2
)
:
"未填报"
;
dataInfo
.
manage
.
thisYear
.
TXP
=
count
>
0
?
totalTXP
.
toFixed
(
2
)
:
"未填报"
;
dataInfo
.
manage
.
thisYear
.
RD
=
count
>
0
?
totalRD
.
toFixed
(
2
)
:
"未填报"
;
// 或者如果要显示平均值:
// dataInfo.manage.thisYear.BI = count > 0 ? (totalBI / count).toFixed(2) : "未填报";
// dataInfo.manage.thisYear.TXP = count > 0 ? (totalTXP / count).toFixed(2) : "未填报";
// dataInfo.manage.thisYear.RD = count > 0 ? (totalRD / count).toFixed(2) : "未填报";
}
let
laseQuarter
=
getLastDeclarationTime
();
let
lastYearjJysjInfo
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业经营信息
,
{
eId
,
isSubmit
:
1
,
annual
:
laseQuarter
.
declarationYear
,
quarter
:
laseQuarter
.
declarationQuarter
},
jysjFile
);
// let lastYearjJysjInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.企业经营信息, { eId, state:1, annual:getMySqlMs(`${thisYear-1}-01-01 00:00:00`)}, jysjFile);
if
(
lastYearjJysjInfo
&&
lastYearjJysjInfo
.
mId
)
{
dataInfo
.
manage
.
lastYear
.
BI
=
!
isNaN
(
lastYearjJysjInfo
.
BI
)
?
lastYearjJysjInfo
.
BI
:
"未填报"
;
dataInfo
.
manage
.
lastYear
.
TXP
=
!
isNaN
(
lastYearjJysjInfo
.
TXP
)
?
lastYearjJysjInfo
.
TXP
:
"未填报"
;
dataInfo
.
manage
.
lastYear
.
RD
=
!
isNaN
(
lastYearjJysjInfo
.
RD
)
?
lastYearjJysjInfo
.
RD
:
"未填报"
;
}
// let thisQuarter = getDeclarationTime();
// let thisYearjJysjInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.企业经营信息, { eId, isSubmit:1, annual:thisQuarter.declarationYear, quarter:thisQuarter.declarationQuarter }, jysjFile);
// if (thisYearjJysjInfo && thisYearjJysjInfo.mId) {
// dataInfo.manage.thisYear.BI = !isNaN(thisYearjJysjInfo.BI) ? thisYearjJysjInfo.BI : "未填报";
// dataInfo.manage.thisYear.TXP = !isNaN(thisYearjJysjInfo.TXP) ? thisYearjJysjInfo.TXP : "未填报";
// dataInfo.manage.thisYear.RD = !isNaN(thisYearjJysjInfo.RD) ? thisYearjJysjInfo.RD : "未填报";
// }
// let laseQuarter = getLastDeclarationTime();
// let lastYearjJysjInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.企业经营信息, { eId, isSubmit:1, annual:laseQuarter.declarationYear, quarter:laseQuarter.declarationQuarter }, jysjFile);
// // let lastYearjJysjInfo = await selectData(OPERATIONALDATATYPE.查询单个, TABLENAME.企业经营信息, { eId, state:1, annual:getMySqlMs(`${thisYear-1}-01-01 00:00:00`)}, jysjFile);
// if (lastYearjJysjInfo && lastYearjJysjInfo.mId) {
// dataInfo.manage.lastYear.BI = !isNaN(lastYearjJysjInfo.BI) ? lastYearjJysjInfo.BI : "未填报";
// dataInfo.manage.lastYear.TXP = !isNaN(lastYearjJysjInfo.TXP) ? lastYearjJysjInfo.TXP : "未填报";
// dataInfo.manage.lastYear.RD = !isNaN(lastYearjJysjInfo.RD) ? lastYearjJysjInfo.RD : "未填报";
// }
return
{
dataInfo
}
}
export
async
function
taskList
(
eId
:
string
,
annual
,
state
)
{
let
quarterConf
=
[
"第一季度"
,
"第二季度"
,
"第三季度"
,
"第四季度"
];
let
year
=
annual
.
slice
(
0
,
4
);
let
annualquarter
=
annual
.
slice
(
4
)
let
quarter
=
0
;
quarterConf
.
forEach
(
(
item
,
index
)
=>
{
if
(
annualquarter
==
item
)
{
quarter
=
index
+
1
;
/**
* 检查当前时间是否在填报时间内
* @param year 年份
* @param quarter 季度
* @returns 是否在填报时间内
*/
function
isInDeclarationPeriod
(
year
:
number
,
quarter
:
number
):
boolean
{
const
timeRange
=
getQuarterTaskTimeRange
(
year
,
quarter
);
const
currentTime
=
moment
();
const
startTime
=
moment
(
timeRange
.
startTime
);
const
endTime
=
moment
(
timeRange
.
endTime
).
endOf
(
'day'
);
// 包含当天的最后一刻
return
currentTime
.
isBetween
(
startTime
,
endTime
,
null
,
'[]'
);
// [] 表示包含边界
}
/**
* 获取季度任务的开始和结束时间(填报期为一个月)
* @param year 年份
* @param quarter 季度 (1-4)
* @returns 包含开始时间和结束时间的对象
*/
function
getQuarterTaskTimeRange
(
year
:
number
,
quarter
:
number
)
{
let
startTime
:
moment
.
Moment
;
let
endTime
:
moment
.
Moment
;
switch
(
quarter
)
{
case
1
:
// 第一季度任务在第二季度第一天开始填报,填报一个月
startTime
=
moment
(
`
${
year
}
-04-01`
);
// 第二季度第一天
endTime
=
moment
(
`
${
year
}
-04-01`
).
add
(
1
,
'month'
).
subtract
(
1
,
'day'
);
// 第二季度第一个月最后一天
break
;
case
2
:
// 第二季度任务在第三季度第一天开始填报,填报一个月
startTime
=
moment
(
`
${
year
}
-07-01`
);
// 第三季度第一天
endTime
=
moment
(
`
${
year
}
-07-01`
).
add
(
1
,
'month'
).
subtract
(
1
,
'day'
);
// 第三季度第一个月最后一天
break
;
case
3
:
// 第三季度任务在第四季度第一天开始填报,填报一个月
startTime
=
moment
(
`
${
year
}
-10-01`
);
// 第四季度第一天
endTime
=
moment
(
`
${
year
}
-10-01`
).
add
(
1
,
'month'
).
subtract
(
1
,
'day'
);
// 第四季度第一个月最后一天
break
;
case
4
:
// 第四季度任务在明年第一季度第一天开始填报,填报一个月
startTime
=
moment
(
`
${
year
+
1
}
-01-01`
);
// 明年第一季度第一天
endTime
=
moment
(
`
${
year
+
1
}
-01-01`
).
add
(
1
,
'month'
).
subtract
(
1
,
'day'
);
// 明年第一季度第一个月最后一天
break
;
default
:
startTime
=
moment
();
endTime
=
moment
();
}
return
{
startTime
:
startTime
.
format
(
"YYYY-MM-DD"
),
endTime
:
endTime
.
format
(
"YYYY-MM-DD"
)
};
}
/**
* 获取填报状态
* @param year 年份
* @param quarter 季度
* @param isSubmitted 是否已提交
* @returns 填报状态
*/
function
getDeclarationStatus
(
year
:
number
,
quarter
:
number
,
isSubmitted
:
boolean
):
string
{
if
(
isSubmitted
)
{
return
"已填报"
;
}
const
timeRange
=
getQuarterTaskTimeRange
(
year
,
quarter
);
const
currentTime
=
moment
();
const
startTime
=
moment
(
timeRange
.
startTime
);
const
endTime
=
moment
(
timeRange
.
endTime
).
endOf
(
'day'
);
if
(
currentTime
.
isBefore
(
startTime
))
{
return
"未开始"
;
}
else
if
(
currentTime
.
isAfter
(
endTime
))
{
return
"已结束"
;
}
else
{
const
daysLeft
=
endTime
.
diff
(
currentTime
,
'days'
);
if
(
daysLeft
<=
15
)
{
return
`距离结束
${
daysLeft
}
天`
;
}
else
{
return
"填报中"
;
}
})
}
}
let
dataList
:
any
[]
=
[];
let
jysjFile
=
[
"BI"
,
"TXP"
,
"RD"
,
"mId"
,
"state"
,
"isSubmit"
];
let
selectParam
:
any
=
{
eId
,
annual
:
getMySqlMs
(
`
${
year
}
-01-01 00:00:00`
),
quarter
};
if
(
state
==
1
)
selectParam
.
isSubmit
=
0
;
else
selectParam
.
isSubmit
=
1
;
let
lastYearjJysjInfo
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业经营信息
,
{
eId
,
annual
:
getMySqlMs
(
`
${
year
}
-01-01 00:00:00`
),
quarter
},
jysjFile
);
if
(
!
lastYearjJysjInfo
||
!
lastYearjJysjInfo
.
mId
)
{
//创建新的填报任务
let
itemInfo
=
{
eId
,
mId
:
randomId
(
TABLEID
.
企业经营信息
),
annual
:
getMySqlMs
(
`
${
year
}
-01-01 00:00:00`
),
quarter
,
BI
:
0
,
TXP
:
0
,
RD
:
0
,
createTime
:
getMySqlMs
(),
state
:
1
,
isSubmit
:
0
,
isUpdate
:
0
}
await
operationalData
(
OPERATIONALDATATYPE
.
增加
,
TABLENAME
.
企业经营信息
,
itemInfo
,
{});
}
/**
* 检查是否可以提交
* @param year 年份
* @param quarter 季度
* @param isSubmitted 是否已提交
* @returns 是否可以提交
*/
function
canSubmitTask
(
year
:
number
,
quarter
:
number
,
isSubmitted
:
boolean
):
boolean
{
if
(
isSubmitted
)
{
return
false
;
}
const
timeRange
=
getQuarterTaskTimeRange
(
year
,
quarter
);
const
currentTime
=
moment
();
const
startTime
=
moment
(
timeRange
.
startTime
);
const
endTime
=
moment
(
timeRange
.
endTime
).
endOf
(
'day'
);
return
currentTime
.
isBetween
(
startTime
,
endTime
,
null
,
'[]'
);
}
let
manageList
=
await
selectData
(
OPERATIONALDATATYPE
.
查询多个
,
TABLENAME
.
企业经营信息
,
selectParam
,
jysjFile
);
/**
* 任务列表
* @param eId 企业ID
* @param annual 年份
* @returns
*/
export
async
function
taskList
(
eId
:
string
,
annual
:
string
)
{
const
year
=
parseInt
(
annual
);
const
quarterConf
=
[
"第一季度"
,
"第二季度"
,
"第三季度"
,
"第四季度"
];
let
dataList
:
any
[]
=
[];
// 查询该年度所有季度的任务
let
jysjFile
=
[
"BI"
,
"TXP"
,
"RD"
,
"mId"
,
"state"
,
"isSubmit"
,
"annual"
,
"quarter"
];
let
selectParam
=
{
eId
,
annual
:
getMySqlMs
(
`
${
year
}
-01-01 00:00:00`
)
};
let
manageList
=
await
selectData
(
OPERATIONALDATATYPE
.
查询多个
,
TABLENAME
.
企业经营信息
,
selectParam
,
jysjFile
);
// 按年度和季度倒序排列
manageList
.
sort
((
a
,
b
)
=>
{
if
(
a
.
annual
===
b
.
annual
)
{
return
b
.
quarter
-
a
.
quarter
;
// 为每个季度创建或获取任务信息
for
(
let
quarter
=
1
;
quarter
<=
4
;
quarter
++
)
{
const
quarterName
=
quarterConf
[
quarter
-
1
];
// 查找是否已存在该季度的任务
let
existingTask
=
manageList
.
find
(
task
=>
task
.
quarter
===
quarter
);
if
(
!
existingTask
)
{
// 创建新的填报任务
let
itemInfo
=
{
eId
,
mId
:
randomId
(
TABLEID
.
企业经营信息
),
annual
:
getMySqlMs
(
`
${
year
}
-01-01 00:00:00`
),
quarter
,
BI
:
0
,
TXP
:
0
,
RD
:
0
,
createTime
:
getMySqlMs
(),
state
:
1
,
isSubmit
:
0
,
isUpdate
:
0
};
await
operationalData
(
OPERATIONALDATATYPE
.
增加
,
TABLENAME
.
企业经营信息
,
itemInfo
,
{});
// 重新查询新创建的任务
const
newTask
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业经营信息
,
{
eId
,
annual
:
getMySqlMs
(
`
${
year
}
-01-01 00:00:00`
),
quarter
},
jysjFile
);
existingTask
=
newTask
;
}
return
new
Date
(
b
.
annual
).
valueOf
()
-
new
Date
(
a
.
annual
).
valueOf
();
});
manageList
.
forEach
(
info
=>
{
const
timeRange
=
getQuarterTaskTimeRange
(
year
,
quarter
);
const
isSubmitted
=
existingTask
.
isSubmit
===
1
;
const
declarationStatus
=
getDeclarationStatus
(
year
,
quarter
,
isSubmitted
);
const
canSubmit
=
canSubmitTask
(
year
,
quarter
,
isSubmitted
);
dataList
.
push
({
mId
:
info
.
mId
,
annual
:
moment
(
info
.
annual
).
format
(
"YYYY"
),
quarter
:
info
.
quarter
,
//新增季度
state
:
info
.
isSubmit
,
remaining
:
!
info
.
isSubmit
?
100
:
0
,
isSubmit
:
info
.
isSubmit
==
1
mId
:
existingTask
.
mId
,
// 任务ID
annual
:
moment
(
existingTask
.
annual
).
format
(
"YYYY"
),
// 年份
quarter
:
quarter
,
// 季度
quarterName
:
quarterName
,
// 季度名称
state
:
existingTask
.
isSubmit
,
// 任务状态
isSubmit
:
isSubmitted
,
// 是否已提交
declarationStatus
:
declarationStatus
,
// 填报状态
canSubmit
:
canSubmit
,
// 是否可以提交
declarationPeriod
:
`
${
timeRange
.
startTime
}
至
${
timeRange
.
endTime
}
`
,
// 填报期限
deadline
:
timeRange
.
endTime
,
// 截止日期
// 经营数据字段
BI
:
existingTask
.
BI
,
// 营收(万元)
TXP
:
existingTask
.
TXP
,
// 纳税(万元)
RD
:
existingTask
.
RD
// 研发投入(万元)
});
});
}
// 按季度顺序排序
dataList
.
sort
((
a
,
b
)
=>
a
.
quarter
-
b
.
quarter
);
return
{
dataList
};
}
/**
* 经营信息提交(增加时间校验)
* @param eId
* @param mId
*/
export
async
function
submitTask
(
eId
:
string
,
mId
:
string
,
param
)
{
const
FuncName
=
"企业提交企业营收记录"
eccFormParam
(
FuncName
,
EnterpriseManageInfoUpdateConfig
,
param
);
let
filesList
=
[
"mId"
,
"isSubmit"
,
"annual"
,
"quarter"
];
let
resInfo
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业经营信息
,
{
eId
,
mId
},
filesList
);
if
(
!
resInfo
||
!
resInfo
.
mId
)
{
throw
new
BizError
(
ERRORENUM
.
数据不存在
);
}
if
(
resInfo
.
isSubmit
==
1
)
throw
new
BizError
(
ERRORENUM
.
不可重复提交
);
// 检查是否在填报时间内
const
year
=
moment
(
resInfo
.
annual
).
year
();
const
canSubmit
=
canSubmitTask
(
year
,
resInfo
.
quarter
,
false
);
if
(
!
canSubmit
)
{
const
timeRange
=
getQuarterTaskTimeRange
(
year
,
resInfo
.
quarter
);
const
status
=
getDeclarationStatus
(
year
,
resInfo
.
quarter
,
false
);
throw
new
BizError
(
ERRORENUM
.
当前不在填报时间内
,
`状态:
${
status
}
`
);
}
let
addInfo
=
{
BI
:
param
.
BI
,
TXP
:
param
.
TXP
,
RD
:
param
.
RD
,
isSubmit
:
1
};
await
operationalData
(
OPERATIONALDATATYPE
.
修改
,
TABLENAME
.
企业经营信息
,
addInfo
,
{
eId
,
mId
});
return
{
isSuccess
:
true
};
}
/**
* 获取当前可填报的任务列表
* @param eId 企业ID
*/
export
async
function
getCurrentDeclarableTasks
(
eId
:
string
)
{
const
currentYear
=
moment
().
year
();
const
dataList
=
[];
// 检查最近4个季度的任务
for
(
let
year
=
currentYear
-
1
;
year
<=
currentYear
+
1
;
year
++
)
{
for
(
let
quarter
=
1
;
quarter
<=
4
;
quarter
++
)
{
const
isInPeriod
=
isInDeclarationPeriod
(
year
,
quarter
);
if
(
isInPeriod
)
{
const
timeRange
=
getQuarterTaskTimeRange
(
year
,
quarter
);
const
quarterConf
=
[
"第一季度"
,
"第二季度"
,
"第三季度"
,
"第四季度"
];
// 检查该任务是否已存在
const
existingTask
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业经营信息
,
{
eId
,
annual
:
getMySqlMs
(
`
${
year
}
-01-01 00:00:00`
),
quarter
},
[
"mId"
,
"isSubmit"
]
);
dataList
.
push
({
year
,
quarter
,
quarterName
:
quarterConf
[
quarter
-
1
],
declarationPeriod
:
`
${
timeRange
.
startTime
}
至
${
timeRange
.
endTime
}
`
,
canDeclare
:
true
,
hasTask
:
!!
existingTask
?.
mId
,
isSubmitted
:
existingTask
?.
isSubmit
===
1
,
mId
:
existingTask
?.
mId
});
}
}
}
return
{
dataList
};
}
...
...
@@ -396,23 +791,6 @@ export async function enterpriseBaseInfo(eId) {
return
{
dataInfo
};
}
/**
* 经营信息提交
* @param uscc
*/
export
async
function
submitTask
(
eId
:
string
,
mId
:
string
)
{
let
filesList
=
[
"mId"
,
"isSubmit"
];
let
resInfo
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业经营信息
,
{
eId
,
mId
},
filesList
);
if
(
!
resInfo
||
!
resInfo
.
mId
)
{
throw
new
BizError
(
ERRORENUM
.
数据不存在
);
}
if
(
resInfo
.
isSubmit
==
1
)
throw
new
BizError
(
ERRORENUM
.
不可重复提交
)
await
operationalData
(
OPERATIONALDATATYPE
.
修改
,
TABLENAME
.
企业经营信息
,
{
isSubmit
:
1
},
{
eId
,
mId
});
return
{
isSuccess
:
true
};
}
/**
* 获取企业-我的信息
...
...
src/biz/finance.ts
View file @
33f487e6
...
...
@@ -149,8 +149,8 @@ export async function enterpriseManageInfo(eId, mId) {
let
dataInfo
=
{
mId
:
resInfo
.
mId
,
annual
:
moment
(
resInfo
.
annual
).
format
(
"YYYY"
),
quarter
:
changeEnumValue
(
enumConfig
.
QUARTER
,
resInfo
.
quarter
),
//
新增
季度
annual
:
moment
(
resInfo
.
annual
).
format
(
"YYYY"
),
//年度
quarter
:
changeEnumValue
(
enumConfig
.
QUARTER
,
resInfo
.
quarter
),
//季度
BI
:
parseFloat
(
resInfo
.
BI
),
TXP
:
parseFloat
(
resInfo
.
TXP
),
RD
:
parseFloat
(
resInfo
.
RD
)
...
...
@@ -165,6 +165,7 @@ export async function enterpriseManageInfo(eId, mId) {
*/
// 季度配置数组
let
quarterConf
=
[
"第一季度"
,
"第二季度"
,
"第三季度"
,
"第四季度"
];
/**
* 辅助函数:将年度和季度字符串转换为年份和季度序号
* @param annual "2025第一季度"
...
...
@@ -182,6 +183,14 @@ function getYearAndQuarter(annual: string) {
return
{
year
,
quarter
};
}
/**
* 营收数据添加
* @param eId
* @param mId
* @param param
* @returns
*/
export
async
function
updateEnterpriseManageInfo
(
eId
,
mId
,
param
)
{
const
FuncName
=
"企业修改企业营收记录"
eccFormParam
(
FuncName
,
EnterpriseManageInfoUpdateConfig
,
param
);
...
...
src/biz/massageNotice.ts
0 → 100644
View file @
33f487e6
/**
* 企业消息通知
*/
import
moment
=
require
(
"moment"
);
import
{
OPERATIONALDATATYPE
,
TABLEID
,
TABLENAME
}
from
"../config/enum/dbEnum"
;
import
{
operationalData
,
selectData
}
from
"../data/operationalData"
;
import
{
getMySqlMs
,
randomId
}
from
"../tools/system"
;
import
{
BizError
}
from
"../util/bizError"
;
import
{
ERRORENUM
}
from
"../config/enum/errorEnum"
;
import
{
MSGTYPE
}
from
"../config/enum/enum"
;
/**
* 获取企业通知列表
*/
export
async
function
getNotificationList
(
eId
:
string
)
{
// 查询消息表,获取所有给该企业或所有企业的消息
const
messageFields
=
[
"msgId"
,
"msgType"
,
"msgTitle"
,
"createTime"
,
"effectiveTime"
,
"msgContent"
,
"eId"
,
"isPop"
];
// 查询条件:eId包含该企业或eId为空数组(发给所有企业)
const
selectParam
=
{
"%or%"
:
[
{
eId
:
{
"%like%"
:
eId
}
},
// 包含该企业ID
{
eId
:
'[]'
}
// 发给所有企业
]
};
let
messageList
=
await
selectData
(
OPERATIONALDATATYPE
.
查询多个
,
TABLENAME
.
企业消息通知表
,
selectParam
,
messageFields
);
// 过滤过期消息
const
currentTime
=
getMySqlMs
();
messageList
=
messageList
.
filter
(
message
=>
!
message
.
effectiveTime
||
message
.
effectiveTime
>
currentTime
);
// 按创建时间排序
messageList
.
sort
((
a
,
b
)
=>
new
Date
(
b
.
createTime
).
valueOf
()
-
new
Date
(
a
.
createTime
).
valueOf
()
);
// 获取已读状态
const
readStatusFields
=
[
"readId"
,
"msgId"
,
"eId"
,
"readTime"
,
"isRead"
];
const
readStatusList
=
await
selectData
(
OPERATIONALDATATYPE
.
查询多个
,
TABLENAME
.
企业消息已读状态表
,
{
eId
:
eId
},
readStatusFields
);
// 创建已读状态映射
const
readStatusMap
=
new
Map
();
readStatusList
.
forEach
(
status
=>
{
readStatusMap
.
set
(
status
.
msgId
,
status
);
});
// 存储需要创建的未读记录
const
unreadRecordsToCreate
=
[];
// 构建返回数据
const
dataList
=
messageList
.
map
(
message
=>
{
// 解析企业ID数组
let
eIdArray
:
string
[]
=
[];
if
(
message
.
eId
)
{
try
{
eIdArray
=
JSON
.
parse
(
message
.
eId
);
}
catch
(
error
)
{
console
.
error
(
'解析 eId 失败:'
,
error
);
}
}
// 获取已读状态
const
readStatus
=
readStatusMap
.
get
(
message
.
msgId
);
let
isRead
=
false
;
let
readTime
=
null
;
let
readId
=
null
;
if
(
readStatus
)
{
// 如果已有记录,使用现有状态
isRead
=
readStatus
.
isRead
===
1
;
readTime
=
readStatus
.
readTime
;
readId
=
readStatus
.
readId
;
}
else
{
// 如果没有记录,标记为未读,并准备创建记录
isRead
=
false
;
readTime
=
null
;
readId
=
null
;
// 尚未创建,没有readId
// 收集需要创建的未读记录
unreadRecordsToCreate
.
push
({
msgId
:
message
.
msgId
,
readId
:
randomId
(
TABLEID
.
企业消息已读状态表
),
eId
:
eId
,
readTime
:
null
,
isRead
:
0
,
// 0表示未读
createTime
:
getMySqlMs
()
// 添加创建时间
});
}
return
{
msgId
:
message
.
msgId
,
readId
:
readId
,
msgType
:
message
.
msgType
,
msgTitle
:
message
.
msgTitle
,
msgContent
:
message
.
msgContent
,
eId
:
eIdArray
,
isPop
:
message
.
isPop
===
1
,
isRead
:
isRead
,
effectiveTime
:
message
.
effectiveTime
?
moment
(
message
.
effectiveTime
).
format
(
"YYYY-MM-DD HH:mm:ss"
)
:
null
,
readTime
:
readTime
?
moment
(
readTime
).
format
(
"YYYY-MM-DD HH:mm:ss"
)
:
null
,
createTime
:
moment
(
message
.
createTime
).
format
(
"YYYY-MM-DD HH:mm:ss"
)
};
});
// 批量创建未读记录(如果有需要创建的)
if
(
unreadRecordsToCreate
.
length
>
0
)
{
try
{
// 这里需要实现批量插入数据的函数
await
createUnreadRecords
(
unreadRecordsToCreate
);
}
catch
(
error
)
{
console
.
error
(
'创建未读记录失败:'
,
error
);
// 这里可以根据需要决定是否抛出错误
}
}
return
{
dataList
};
}
/**
* 批量创建未读记录
*/
async
function
createUnreadRecords
(
records
:
any
[])
{
// 批量插入未读记录
for
(
const
record
of
records
)
{
await
operationalData
(
OPERATIONALDATATYPE
.
增加
,
TABLENAME
.
企业消息已读状态表
,
record
,
{}
);
}
}
/**
* 标记通知为已读
*/
export
async
function
markNotificationAsRead
(
eId
:
string
,
msgId
:
string
,
readId
:
string
)
{
// 先检查消息是否存在且对该企业可见
const
message
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业消息通知表
,
{
msgId
:
msgId
,
readId
:
readId
,
"%or%"
:
[
{
eId
:
{
"%like%"
:
`%"
${
eId
}
"%`
}
},
{
eId
:
'[]'
}
]
},
[
"msgId"
]
);
if
(
!
message
)
{
throw
new
BizError
(
ERRORENUM
.
数据不存在
);
}
// 检查是否已存在已读记录
const
existingRead
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业消息已读状态表
,
{
msgId
:
msgId
,
readId
:
readId
,
eId
:
eId
},
[
"readId"
]
);
if
(
Object
.
keys
(
existingRead
).
length
)
{
// 更新已存在记录
const
updateData
=
{
isRead
:
1
,
// isRead: 0,
readTime
:
getMySqlMs
()
};
await
operationalData
(
OPERATIONALDATATYPE
.
修改
,
TABLENAME
.
企业消息已读状态表
,
updateData
,
{
readId
:
existingRead
.
readId
}
);
}
else
{
// 创建新的已读记录
const
readData
=
{
readId
:
randomId
(
TABLEID
.
企业消息已读状态表
),
msgId
:
msgId
,
eId
:
eId
,
isRead
:
1
,
// isRead: 0,
readTime
:
getMySqlMs
()
};
await
operationalData
(
OPERATIONALDATATYPE
.
增加
,
TABLENAME
.
企业消息已读状态表
,
readData
,
{}
);
}
return
{
isSuccess
:
true
};
}
/**
* 批量标记通知为已读
*/
export
async
function
markNotificationsAsRead
(
eId
:
string
,
msgIds
:
string
[],
readId
:
string
)
{
for
(
const
msgId
of
msgIds
)
{
await
markNotificationAsRead
(
eId
,
msgId
,
readId
);
}
return
{
isSuccess
:
true
};
}
/**
* 获取弹窗消息
*/
// export async function getPopupNotifications(eId: string) {
// // 先获取所有消息
// const result = await getNotificationList(eId);
// // 过滤出弹窗消息且未读的
// const popupMessages = result.dataList.filter(message =>
// message.isPop && !message.isRead
// );
// return { dataList: popupMessages };
// }
/**
* 获取弹窗消息
*/
export
async
function
getPopupNotifications
(
eId
:
string
)
{
// 先获取所有消息
const
result
=
await
getNotificationList
(
eId
);
// 过滤出弹窗消息
const
popupMessages
=
result
.
dataList
.
filter
(
message
=>
message
.
isPop
);
// 特殊处理季度填报提醒消息
const
processedMessages
=
await
Promise
.
all
(
popupMessages
.
map
(
async
(
message
)
=>
{
// 如果是季度填报提醒类型
if
(
message
.
msgType
===
MSGTYPE
.
季度填报提醒
)
{
// 获取上季度的时间
const
lastQuarter
=
getLastQuarter
();
// 替换模板变量
const
year
=
lastQuarter
.
year
;
const
quarter
=
lastQuarter
.
quarter
;
// const quarterNames = ["第一季度", "第二季度", "第三季度", "第四季度"];
const
quarterNames
=
[
"一"
,
"二"
,
"三"
,
"四"
];
// 替换标题和内容中的模板变量
let
processedTitle
=
message
.
msgTitle
;
let
processedContent
=
message
.
msgContent
;
if
(
processedTitle
.
includes
(
"${year}"
)
||
processedTitle
.
includes
(
"${quarter}"
))
{
processedTitle
=
processedTitle
.
replace
(
/
\$
{year}/g
,
year
.
toString
())
.
replace
(
/
\$
{quarter}/g
,
quarter
.
toString
());
}
if
(
processedContent
.
includes
(
"${year}"
)
||
processedContent
.
includes
(
"${quarter}"
))
{
processedContent
=
processedContent
.
replace
(
/
\$
{year}/g
,
year
.
toString
())
.
replace
(
/
\$
{quarter}/g
,
quarterNames
[
quarter
-
1
]);
}
// 检查是否是每季度1号
const
today
=
moment
();
const
isFirstDayOfMonth
=
today
.
date
()
===
1
;
if
(
isFirstDayOfMonth
)
{
// 重置该消息对该企业的已读状态为未读
await
resetNotificationReadStatus
(
eId
,
message
.
msgId
);
// 返回处理后的消息,标记为未读
return
{
...
message
,
msgTitle
:
processedTitle
,
msgContent
:
processedContent
,
isRead
:
false
// 强制设置为未读
};
}
// 如果不是1号,返回处理后的消息(保持原有已读状态)
return
{
...
message
,
msgTitle
:
processedTitle
,
msgContent
:
processedContent
};
}
// 其他类型的消息保持不变
return
message
;
})
);
// 过滤出未读的消息(包括被重置为未读的季度填报提醒)
const
unreadPopupMessages
=
processedMessages
.
filter
(
message
=>
!
message
.
isRead
);
return
{
dataList
:
unreadPopupMessages
};
}
/**
* 获取上一个季度
*/
function
getLastQuarter
():
{
year
:
number
;
quarter
:
number
}
{
const
currentTime
=
moment
();
const
currentYear
=
currentTime
.
year
();
const
currentMonth
=
currentTime
.
month
()
+
1
;
let
lastQuarter
=
0
;
let
lastQuarterYear
=
currentYear
;
if
(
currentMonth
>=
1
&&
currentMonth
<=
3
)
{
lastQuarter
=
4
;
lastQuarterYear
=
currentYear
-
1
;
}
else
if
(
currentMonth
>=
4
&&
currentMonth
<=
6
)
{
lastQuarter
=
1
;
}
else
if
(
currentMonth
>=
7
&&
currentMonth
<=
9
)
{
lastQuarter
=
2
;
}
else
{
lastQuarter
=
3
;
}
return
{
year
:
lastQuarterYear
,
quarter
:
lastQuarter
};
}
/**
* 重置消息的已读状态为未读
*/
async
function
resetNotificationReadStatus
(
eId
:
string
,
msgId
:
string
)
{
// 检查是否已存在已读记录
const
existingRead
=
await
selectData
(
OPERATIONALDATATYPE
.
查询单个
,
TABLENAME
.
企业消息已读状态表
,
{
msgId
:
msgId
,
eId
:
eId
},
[
"readId"
]
);
if
(
existingRead
)
{
// 更新已存在记录为未读
const
updateData
=
{
isRead
:
0
,
readTime
:
null
};
await
operationalData
(
OPERATIONALDATATYPE
.
修改
,
TABLENAME
.
企业消息已读状态表
,
updateData
,
{
readId
:
existingRead
.
readId
}
);
}
else
{
// 如果没有已读记录,创建一条未读记录(可选)
// 通常不需要,因为默认就是未读状态
}
return
{
isSuccess
:
true
};
}
src/config/enum/dbEnum.ts
View file @
33f487e6
...
...
@@ -48,6 +48,8 @@ export enum TABLENAME {
租房补贴企业自评
=
"zufang_answer"
,
租房补贴答题记录
=
"zufang_answerrecord"
,
租房补贴答题记录明细
=
"zufang_answerdetail"
,
企业消息通知表
=
"message_notice"
,
企业消息已读状态表
=
"message_reads"
,
}
...
...
@@ -82,4 +84,6 @@ export enum TABLEID {
租房补贴企业自评
=
"zaId"
,
租房补贴答题记录
=
"zarId"
,
租房补贴答题记录明细
=
"zadId"
,
企业消息通知表
=
"msg"
,
企业消息已读状态表
=
"read"
,
}
\ No newline at end of file
src/config/enum/enum.ts
View file @
33f487e6
...
...
@@ -80,7 +80,8 @@ export enum EMIGRATIONTYPE {
毕业迁出
=
1
,
毕业未迁出
,
//新加状态
到期退租
,
违约退租
违约退租
,
到期未迁出
}
...
...
@@ -257,6 +258,32 @@ export enum BUILDING {
}
// 企业服务状态枚举
export
enum
MSGTYPE
{
// 季度填报相关
季度填报提醒
=
1
,
填报截止提醒
=
2
,
// 政策相关
政策发布
=
3
,
政策更新
=
4
,
// 服务相关
服务反馈
=
5
,
服务进度
=
6
,
// 系统相关
系统维护
=
7
,
系统更新
=
8
,
// 园区通知
园区公告
=
9
,
活动通知
=
10
};
/**
* 知识产权类型其他 前端用
*/
...
...
src/config/enum/errorEnum.ts
View file @
33f487e6
...
...
@@ -35,6 +35,8 @@ export enum ERRORENUM {
密码不一致
,
密码只能由
6
至
18
位字符和数字组成
,
原密码错误
,
当前无法提交
,
当前不在填报时间内
,
}
export
enum
ERRORCODEENUM
{
...
...
src/routers/enterpriseInfo.ts
View file @
33f487e6
...
...
@@ -2,7 +2,7 @@
* 小程序端 企业入口 用户基础功能路由
*/
import
*
as
asyncHandler
from
'express-async-handler'
;
import
asyncHandler
=
require
(
'express-async-handler'
)
;
import
*
as
enterpriseInfoBiz
from
'../biz/enterpriseInfo'
;
import
{
checkUser
}
from
'../middleware/user'
;
...
...
@@ -325,8 +325,8 @@ async function baseInfo(req, res) {
async
function
homePageTaskSubmit
(
req
,
res
)
{
const
UserInfo
=
req
.
userInfo
;
let
{
mId
}
=
req
.
body
;
let
result
=
await
enterpriseInfoBiz
.
submitTask
(
UserInfo
.
eId
,
mId
);
let
{
mId
,
param
}
=
req
.
body
;
let
result
=
await
enterpriseInfoBiz
.
submitTask
(
UserInfo
.
eId
,
mId
,
param
);
res
.
success
(
result
);
}
...
...
@@ -374,8 +374,8 @@ async function homePageTop(req, res) {
*/
async
function
homePageTask
(
req
,
res
)
{
const
UserInfo
=
req
.
userInfo
;
let
{
state
,
annual
}
=
req
.
body
let
result
=
await
enterpriseInfoBiz
.
taskList
(
UserInfo
.
eId
,
annual
,
state
);
let
{
annual
}
=
req
.
body
let
result
=
await
enterpriseInfoBiz
.
taskList
(
UserInfo
.
eId
,
annual
);
res
.
success
(
result
);
}
...
...
src/routers/files.ts
View file @
33f487e6
...
...
@@ -2,7 +2,7 @@
* 文件管理 路由
*/
import
*
as
asyncHandler
from
'express-async-handler'
;
import
asyncHandler
=
require
(
'express-async-handler'
)
;
import
*
as
fileBiz
from
'../biz/file'
;
import
{
checkUser
}
from
'../middleware/user'
;
import
{
parseFormParam
}
from
'../middleware/fromParam'
;
...
...
src/routers/finance.ts
View file @
33f487e6
...
...
@@ -2,7 +2,7 @@
* 企业融资
*/
import
*
as
asyncHandler
from
'express-async-handler'
;
import
asyncHandler
=
require
(
'express-async-handler'
)
;
import
*
as
financeBiz
from
'../biz/finance'
;
import
{
checkUser
}
from
'../middleware/user'
;
...
...
src/routers/gaoxin.ts
View file @
33f487e6
...
...
@@ -2,7 +2,7 @@
* 高新企业创新能力评价答题
*/
import
*
as
asyncHandler
from
'express-async-handler'
;
import
asyncHandler
=
require
(
'express-async-handler'
)
;
import
*
as
gaoxinBiz
from
'../biz/answer'
;
import
{
checkUser
}
from
'../middleware/user'
;
...
...
src/routers/notification.ts
0 → 100644
View file @
33f487e6
/**
* 企业消息通知
*/
import
asyncHandler
=
require
(
'express-async-handler'
);
import
*
as
massageNoticeBiz
from
'../biz/massageNotice'
;
import
{
checkUser
}
from
'../middleware/user'
;
export
function
setRouter
(
httpServer
)
{
httpServer
.
post
(
'/xcx/enterprise/massagnotice/list'
,
checkUser
,
asyncHandler
(
notificationList
));
httpServer
.
post
(
'/xcx/enterprise/massagnotice/markasread'
,
checkUser
,
asyncHandler
(
markAsRead
));
}
/**
* 获取登录用户的企业消息通知列表
* @param req
* @param res
*/
async
function
notificationList
(
req
,
res
)
{
const
UserInfo
=
req
.
userInfo
;
let
result
=
await
massageNoticeBiz
.
getPopupNotifications
(
UserInfo
.
eId
);
res
.
success
(
result
);
}
/**
* 标记通知为已读
* @param req
* @param res
*/
async
function
markAsRead
(
req
,
res
)
{
let
{
msgId
,
readId
}
=
req
.
body
;
const
UserInfo
=
req
.
userInfo
;
let
result
=
await
massageNoticeBiz
.
markNotificationAsRead
(
UserInfo
.
eId
,
msgId
,
readId
);
res
.
success
(
result
);
}
src/routers/public.ts
View file @
33f487e6
/**
* 公共资源路由
*/
import
*
as
asyncHandler
from
'express-async-handler'
;
import
asyncHandler
=
require
(
'express-async-handler'
)
;
import
*
as
enumConfig
from
'../config/enum/enum'
;
const
config
=
{
...
...
src/routers/qualification.ts
View file @
33f487e6
...
...
@@ -2,7 +2,7 @@
* 资质
*/
import
*
as
asyncHandler
from
'express-async-handler'
;
import
asyncHandler
=
require
(
'express-async-handler'
)
;
import
*
as
qualificationBiz
from
'../biz/qualification'
;
import
{
checkUser
}
from
'../middleware/user'
;
...
...
src/routers/router.ts
View file @
33f487e6
...
...
@@ -9,6 +9,7 @@ import * as qualificationRouters from './qualification';
import
*
as
financeRouters
from
'./finance'
;
import
*
as
gaoxinRouters
from
'./gaoxin'
;
import
*
as
filesInfoRouters
from
'./files'
;
import
*
as
notificationRouters
from
'./notification'
;
export
function
setRouter
(
httpServer
){
/**下拉框等公用 路由 */
...
...
@@ -22,4 +23,6 @@ export function setRouter(httpServer){
gaoxinRouters
.
setRouter
(
httpServer
);
filesInfoRouters
.
setRouter
(
httpServer
);
notificationRouters
.
setRouter
(
httpServer
);
}
\ No newline at end of file
src/routers/teams.ts
View file @
33f487e6
...
...
@@ -2,7 +2,7 @@
* 企业团队
*/
import
*
as
asyncHandler
from
'express-async-handler'
;
import
asyncHandler
=
require
(
'express-async-handler'
)
;
import
*
as
teamsBiz
from
'../biz/teams'
;
import
{
checkUser
}
from
'../middleware/user'
;
...
...
src/tools/system.ts
View file @
33f487e6
...
...
@@ -92,8 +92,9 @@ export function getLastDeclarationTime() {
*/
export
function
getDeclarationTime
()
{
let
thisYear
=
new
Date
().
getFullYear
();
let
thisQuarter
=
moment
().
quarter
();
//当月填报季度
return
{
declarationYear
:
getMySqlMs
(
`
${
thisYear
}
-01-01 00:00:00`
),
declarationQuarter
:
thisQuarter
};
return
{
declarationYear
:
getMySqlMs
(
`
${
thisYear
}
-01-01 00:00:00`
)};
// let thisQuarter = moment().quarter();//当月填报季度
// return {declarationYear:getMySqlMs(`${thisYear}-01-01 00:00:00`), declarationQuarter:thisQuarter};
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment