From a758f13d7d9e5058b26b78b99851e7270e6e3b6b Mon Sep 17 00:00:00 2001 From: ljw <1910244583@qq.com> Date: Wed, 31 May 2023 21:36:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloudfunctions/fe-team-leaveTeam/index.js | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js index da3b08a..f219a09 100644 --- a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js @@ -49,37 +49,39 @@ exports.main = async (event, context) => { const res = await collection.doc(event.userId).update({ team_id: "" }) - if (res.updated === 1 && res1.affectedDocs != 1) { + if (res.updated === 1) { const activity = db.collection('mustgo-team-activity') let res2 = await activity.where({ team_id: teamid }).get() - var arr = new Array; - arr = res2.data + const registration = db.collection('mustgo-registration') + let res3 = await registration.where({ + owner_id: event.userId + }).get() + var arr = new Array; + arr = res3.data for (var i = 0; i < arr.length; i++) { - const res = await activitycollection.doc(arr[i]["_id"]).update({ - enrollment: arr[i]["enrollment"]-1 + + let res4 = await activity.where({ + _id:arr[i]["team_activity_id"] + }).get() + + const res = await activitycollection.doc(arr[i]["team_activity_id"]).update({ + enrollment: res4.data[0]["enrollment"] - 1 }) - const tmp = await registration.where({ - team_activity_id: arr[i]["_id"] + const restep = await registration.where({ + _id:arr[i]["_id"] }).remove() } - return { "code": 200, "message": "退出小队成功", "data": {} } - } else { - return { - "code": 200, - "message": "退出小队成功", - "data": {} - } - } + } } return { "code": 400, -- GitLab