|
@@ -16,6 +16,7 @@ class WxpayService extends CrudService {
|
|
|
this.redis = this.app.redis;
|
|
|
this.model = this.ctx.model.Card;
|
|
|
this.cashModel = this.ctx.model.Cash;
|
|
|
+ this.cashError = this.ctx.model.CashError;
|
|
|
}
|
|
|
|
|
|
async toAuth({ code, id }) {
|
|
@@ -74,15 +75,22 @@ class WxpayService extends CrudService {
|
|
|
|
|
|
const { return_code, return_msg, result_code, err_code, err_code_des } = result;
|
|
|
|
|
|
- if (return_code !== 'SUCCESS') throw new BusinessError(ErrorCode.SERVICE_FAULT, `${return_code}:${return_msg}`);
|
|
|
+ if (return_code !== 'SUCCESS') {
|
|
|
+ this.cashError.create({ word: `${return_code}:${return_msg}` });
|
|
|
+ throw new BusinessError(ErrorCode.SERVICE_FAULT, `${return_code}:${return_msg}`);
|
|
|
+ }
|
|
|
|
|
|
- if (result_code === 'FAIL') throw new BusinessError(ErrorCode.SERVICE_FAULT, `${err_code}:${err_code_des}`);
|
|
|
+ if (result_code === 'FAIL') {
|
|
|
+ this.cashError.create({ word: `${err_code}:${err_code_des}` });
|
|
|
+ throw new BusinessError(ErrorCode.SERVICE_FAULT, `${err_code}:${err_code_des}`);
|
|
|
+ }
|
|
|
|
|
|
const cashRecord = { name: user.name, mobile: user.mobile, b_point: opoints, i_point: points, e_point: pres };
|
|
|
try {
|
|
|
await this.cashModel.create(cashRecord);
|
|
|
} catch (error) {
|
|
|
const word = '添加提现记录失败!但钱已转出.';
|
|
|
+ this.cashError.create({ word });
|
|
|
throw new BusinessError(ErrorCode.SERVICE_FAULT, word);
|
|
|
}
|
|
|
user.points = pres;
|
|
@@ -90,6 +98,7 @@ class WxpayService extends CrudService {
|
|
|
await user.save();
|
|
|
} catch (error) {
|
|
|
const word = '用户减掉已转出积分失败!钱已转出;提现记录已添加';
|
|
|
+ this.cashError.create({ word });
|
|
|
throw new BusinessError(ErrorCode.SERVICE_FAULT, word);
|
|
|
}
|
|
|
let newUser = await this.model.findById(id);
|