|
|
@@ -21,6 +21,7 @@ module.exports={
|
|
|
projectType: projectType,
|
|
|
getPosterityProjects: getPosterityProjects,
|
|
|
isShare: isShare,
|
|
|
+ isFirst: isFirst,
|
|
|
getShareInfo: getShareInfo,
|
|
|
prepareInitialData: prepareInitialData,
|
|
|
changeFile:changeFile
|
|
|
@@ -925,17 +926,32 @@ async function isShare(userId, project){
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+//用户是否第一次进入费用定额
|
|
|
+async function isFirst(userId, compilationId) {
|
|
|
+ let userData = await userModel.findOne({_id: mongoose.Types.ObjectId(userId)}, '-_id used_list');
|
|
|
+ let isFirst = false;
|
|
|
+ if (userData) {
|
|
|
+ isFirst = !_.find(userData.used_list, function (o) {
|
|
|
+ return o.compilationId === compilationId;
|
|
|
+ });;
|
|
|
+ }
|
|
|
+ return isFirst;
|
|
|
+}
|
|
|
+
|
|
|
//用户第一次进入费用定额的数据准备
|
|
|
async function prepareInitialData(userId, compilation, example) {
|
|
|
- let prepareTask = [
|
|
|
- updateUsedList(userId, compilation),
|
|
|
- copyCompleRationSection(userId, compilation),
|
|
|
- copyCompleGljSection(userId, compilation)
|
|
|
- ];
|
|
|
- if (example && example.length > 0) {
|
|
|
- prepareTask.push(copyExample(userId, compilation, example));
|
|
|
+ let first = await isFirst(userId, compilation);
|
|
|
+ if (first) {
|
|
|
+ await updateUsedList(userId, compilation);
|
|
|
+ let prepareTask = [
|
|
|
+ copyCompleRationSection(userId, compilation),
|
|
|
+ copyCompleGljSection(userId, compilation)
|
|
|
+ ];
|
|
|
+ if (example && example.length > 0) {
|
|
|
+ prepareTask.push(copyExample(userId, compilation, example));
|
|
|
+ }
|
|
|
+ await Promise.all(prepareTask);
|
|
|
}
|
|
|
- await Promise.all(prepareTask);
|
|
|
}
|
|
|
|
|
|
async function updateUsedList(userId, compilation) {
|