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 f219a09230560765786e7d7b04f20bdf6879f7a1..f886734b9212b83bc54c20e04ddf3a88639c8907 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,