|
@@ -9,6 +9,7 @@ class CashOutService extends CrudService {
|
|
|
constructor(ctx) {
|
|
|
super(ctx, 'cashout');
|
|
|
this.model = this.ctx.model.User.CashOut;
|
|
|
+ this.cashBackModel = this.ctx.model.User.CashBack;
|
|
|
}
|
|
|
|
|
|
async beforeCreate(data) {
|
|
@@ -18,6 +19,16 @@ class CashOutService extends CrudService {
|
|
|
if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '您有未处理提现申请,请联系管理员先处理之前的申请');
|
|
|
return data;
|
|
|
}
|
|
|
+
|
|
|
+ async afterUpdate(filter, body, data) {
|
|
|
+ const { status } = body;
|
|
|
+ if (status === '1') {
|
|
|
+ const { customer: inviter } = data;
|
|
|
+ const obj = { inviter, time: moment().format('YYYY-MM-DD HH:mm:ss'), status: '-1', source: '-1', source_id: data._id };
|
|
|
+ await this.cashBackModel.create(obj);
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = CashOutService;
|