Commit 299795fb authored by gongguan's avatar gongguan

提交分数接口增加防并发

parent 4f67af43
......@@ -50,6 +50,20 @@ export default class GameService extends UserService {
userInfo: IUserInfo,
joinInfo: IJoinRecord
) {
const gameResult = await this.joindao.update(
{
_id: id,
$where: `this.status === 1`
},
{
$set: {
status: 2
}
}
)
if (gameResult !== 1) { // 该局游戏实际已结束,有并发
return { data: 1 }
}
const { duration } = await this.updateJoinRecord(id, score, userInfo, joinInfo)
const { maxScore, totalScore } = await this.updateUserScore(score, userInfo)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment