修改达到人数事没有更新is_full字段的bug
Showing
1 changed file
with
20 additions
and
11 deletions
@@ -387,11 +387,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -387,11 +387,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
387 | let productInfo = _.get(info, '[0][0]'); | 387 | let productInfo = _.get(info, '[0][0]'); |
388 | let joinNum = _.get(info, '[1].join_num', 0); | 388 | let joinNum = _.get(info, '[1].join_num', 0); |
389 | 389 | ||
390 | - // 参与人数满时更新活动状态 | ||
391 | - if (+info.is_full === 0 && joinNum >= info.limit) { | ||
392 | - mysqlCli.update(`update ${TABLE_ACT_PRIZE_PRODUCT} set is_full = 1 | ||
393 | - where id = :actPrizeId and is_full = 0 limit 1`, {actPrizeId}); | ||
394 | - } | 390 | + |
395 | 391 | ||
396 | let status = getActivityStatus(productInfo, joinNum); | 392 | let status = getActivityStatus(productInfo, joinNum); |
397 | 393 | ||
@@ -407,12 +403,25 @@ module.exports = class extends global.yoho.BaseModel { | @@ -407,12 +403,25 @@ module.exports = class extends global.yoho.BaseModel { | ||
407 | this.sendPrizeCode(extra.shareUid, actPrizeId, {isShareTake: true}); | 403 | this.sendPrizeCode(extra.shareUid, actPrizeId, {isShareTake: true}); |
408 | } | 404 | } |
409 | 405 | ||
410 | - return this.sendPrizeCode(uid, actPrizeId, Object.assign(extra, { | ||
411 | - isShareTake: false, | ||
412 | - actName: productInfo.name, | ||
413 | - actStartTime: productInfo.start_time, | ||
414 | - actEndTime: productInfo.end_time | ||
415 | - })); | 406 | + return new Promise((resolve, reject) => { |
407 | + this.sendPrizeCode(uid, actPrizeId, Object.assign(extra, { | ||
408 | + isShareTake: false, | ||
409 | + actName: productInfo.name, | ||
410 | + actStartTime: productInfo.start_time, | ||
411 | + actEndTime: productInfo.end_time | ||
412 | + })).then(response => { | ||
413 | + // 参与人数满时更新活动状态 | ||
414 | + if (+response.code === 200 && (+productInfo.is_full === 0) && (joinNum + 1) >= productInfo.limit) { | ||
415 | + mysqlCli.update(`update ${TABLE_ACT_PRIZE_PRODUCT} set is_full = 1 | ||
416 | + where id = :actPrizeId and is_full = 0 limit 1`, {actPrizeId}); | ||
417 | + } | ||
418 | + resolve(response); | ||
419 | + }) | ||
420 | + .catch(error => { | ||
421 | + reject(error); | ||
422 | + }); | ||
423 | + }); | ||
424 | + | ||
416 | } | 425 | } |
417 | 426 | ||
418 | /** | 427 | /** |
-
Please register or login to post a comment