Merge branch 'bugfix' into dev
This commit is contained in:
commit
6d1149d6ee
@ -8,8 +8,15 @@ import { PublicShared } from "../../shared/public/public";
|
|||||||
import { HongDianChange } from "../hongdian/fun";
|
import { HongDianChange } from "../hongdian/fun";
|
||||||
|
|
||||||
const maxScore = 269; // 积分上限
|
const maxScore = 269; // 积分上限
|
||||||
|
const lockPrefix = 'lock:DldFight:';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqDldFight, ResDldFight>) {
|
export default async function (call: ApiCall<ReqDldFight, ResDldFight>) {
|
||||||
|
const lockKey = lockPrefix + call.uid;
|
||||||
|
const gotLock = await G.ioredis.setnx(lockKey, 1);
|
||||||
|
if (!gotLock) {
|
||||||
|
return call.errorCode(-101); // -101 并发请求, 告知客户端稍后再试 request_too_fast
|
||||||
|
}
|
||||||
|
await G.ioredis.pexpire(lockKey, 500); // 设置 ttl 避免死锁. 策划要求: 500ms
|
||||||
let status = await WangZheRongYaofun.getWangZheStatus();
|
let status = await WangZheRongYaofun.getWangZheStatus();
|
||||||
if (status.status != 3) {
|
if (status.status != 3) {
|
||||||
// 未到大乱斗时间
|
// 未到大乱斗时间
|
||||||
@ -75,7 +82,7 @@ export default async function (call: ApiCall<ReqDldFight, ResDldFight>) {
|
|||||||
_mydata.jifen = _myFight.jifen;
|
_mydata.jifen = _myFight.jifen;
|
||||||
|
|
||||||
HongDianChange.sendChangeKey(call.uid, ['wzryhd']);
|
HongDianChange.sendChangeKey(call.uid, ['wzryhd']);
|
||||||
|
await G.ioredis.del(lockKey);
|
||||||
call.succ({
|
call.succ({
|
||||||
mydata: _mydata,
|
mydata: _mydata,
|
||||||
result: result,
|
result: result,
|
||||||
|
Loading…
Reference in New Issue
Block a user