|
@@ -25,7 +25,14 @@ class MatchSignService extends CrudService {
|
|
|
return body;
|
|
|
}
|
|
|
async beforeUpdate(filter, update) {
|
|
|
- // 比赛结束后不能退款
|
|
|
+ // 比赛结束后不能退款, match 0,1,2往后的状态不能退赛
|
|
|
+ const { pay_status } = update;
|
|
|
+ if (pay_status !== '-2') return { filter, update };
|
|
|
+ const { id } = filter;
|
|
|
+ const data = await this.model.findById(id);
|
|
|
+ const { match_id } = data;
|
|
|
+ const num = await this.matchModel.count({ _id: match_id, status: { $nin: [ '0', '1', '2' ] } });
|
|
|
+ if (num > 0) throw new BusinessError(ErrorCode.DATA_INVALID, '赛事已经处于准备开赛或开赛中,不能退赛');
|
|
|
return { filter, update };
|
|
|
}
|
|
|
|