From 7f5438acb91bd07b669708d8a98f04e025c3fd9e Mon Sep 17 00:00:00 2001 From: ljw <1910244583@qq.com> Date: Wed, 31 May 2023 23:00:50 +0800 Subject: [PATCH] =?UTF-8?q?=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, 19 insertions(+), 13 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 f219a09..f886734 100644 --- a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-team-leaveTeam/index.js @@ -3,7 +3,7 @@ exports.main = async (event, context) => { const db = uniCloud.database() const collection = db.collection('mustgo-user') const activitycollection = db.collection('mustgo-team-activity') - + const registration = db.collection('mustgo-registration') let res1 = await collection.where({ _id: event.userId @@ -40,9 +40,13 @@ exports.main = async (event, context) => { if (tmp.affectedDocs == 1) { const collection1 = db.collection('mustgo-team') const res1 = await collection1.doc(teamid).remove() - + const tmp2 = await activitycollection.where({ - team_id:teamid + team_id: teamid + }).remove() + + const tmp3 = await registration.where({ + owner_id: event.userId }).remove() } @@ -55,33 +59,35 @@ exports.main = async (event, context) => { let res2 = await activity.where({ team_id: teamid }).get() - - const registration = db.collection('mustgo-registration') + + let res3 = await registration.where({ owner_id: event.userId }).get() var arr = new Array; arr = res3.data + // return arr for (var i = 0; i < arr.length; i++) { - + let res4 = await activity.where({ - _id:arr[i]["team_activity_id"] + _id: arr[i]["team_activity_id"] }).get() - + // return res4 const res = await activitycollection.doc(arr[i]["team_activity_id"]).update({ enrollment: res4.data[0]["enrollment"] - 1 }) - - const restep = await registration.where({ - _id:arr[i]["_id"] - }).remove() + + // const restep = await registration.where({ + // _id:arr[i]["_id"] + // }).remove() + const resreg = await registration.doc(arr[i]["_id"]).remove() } return { "code": 200, "message": "退出小队成功", "data": {} } - } + } } return { "code": 400, -- GitLab