提交 7f5438ac 编写于 作者: L ljw

修改

上级 a758f13d
...@@ -3,7 +3,7 @@ exports.main = async (event, context) => { ...@@ -3,7 +3,7 @@ exports.main = async (event, context) => {
const db = uniCloud.database() const db = uniCloud.database()
const collection = db.collection('mustgo-user') const collection = db.collection('mustgo-user')
const activitycollection = db.collection('mustgo-team-activity') const activitycollection = db.collection('mustgo-team-activity')
const registration = db.collection('mustgo-registration')
let res1 = await collection.where({ let res1 = await collection.where({
_id: event.userId _id: event.userId
...@@ -40,9 +40,13 @@ exports.main = async (event, context) => { ...@@ -40,9 +40,13 @@ exports.main = async (event, context) => {
if (tmp.affectedDocs == 1) { if (tmp.affectedDocs == 1) {
const collection1 = db.collection('mustgo-team') const collection1 = db.collection('mustgo-team')
const res1 = await collection1.doc(teamid).remove() const res1 = await collection1.doc(teamid).remove()
const tmp2 = await activitycollection.where({ const tmp2 = await activitycollection.where({
team_id:teamid team_id: teamid
}).remove()
const tmp3 = await registration.where({
owner_id: event.userId
}).remove() }).remove()
} }
...@@ -55,33 +59,35 @@ exports.main = async (event, context) => { ...@@ -55,33 +59,35 @@ exports.main = async (event, context) => {
let res2 = await activity.where({ let res2 = await activity.where({
team_id: teamid team_id: teamid
}).get() }).get()
const registration = db.collection('mustgo-registration')
let res3 = await registration.where({ let res3 = await registration.where({
owner_id: event.userId owner_id: event.userId
}).get() }).get()
var arr = new Array; var arr = new Array;
arr = res3.data arr = res3.data
// return arr
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
let res4 = await activity.where({ let res4 = await activity.where({
_id:arr[i]["team_activity_id"] _id: arr[i]["team_activity_id"]
}).get() }).get()
// return res4
const res = await activitycollection.doc(arr[i]["team_activity_id"]).update({ const res = await activitycollection.doc(arr[i]["team_activity_id"]).update({
enrollment: res4.data[0]["enrollment"] - 1 enrollment: res4.data[0]["enrollment"] - 1
}) })
const restep = await registration.where({ // const restep = await registration.where({
_id:arr[i]["_id"] // _id:arr[i]["_id"]
}).remove() // }).remove()
const resreg = await registration.doc(arr[i]["_id"]).remove()
} }
return { return {
"code": 200, "code": 200,
"message": "退出小队成功", "message": "退出小队成功",
"data": {} "data": {}
} }
} }
} }
return { return {
"code": 400, "code": 400,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册