cash.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. const BaseService = require('./base.js');
  3. // 提现记录服务类
  4. class CashService extends BaseService {
  5. // 使用模型
  6. get useModel() {
  7. const that = this;
  8. return that.app.model.UsersCashLogs;
  9. }
  10. /**
  11. * 添加提现记录
  12. * @return {Promise<void>}
  13. */
  14. async addCashLog(data, transaction) {
  15. const that = this;
  16. const orderBean = await that.app.comoBean.instance(data, { transaction });
  17. await that.service.base.create(orderBean, that.useModel, '提现记录创建失败');
  18. }
  19. /**
  20. * 查询状态正在提现中的记录
  21. * @return {Promise<void>}
  22. */
  23. async getCommissionCashingLog() {
  24. const that = this;
  25. const seq = that.app.Sequelize;
  26. const result = await that.useModel.findAll({
  27. where: { type: { [seq.Op.eq]: 2 }, partner_id: -1 },
  28. });
  29. const cashingRes = JSON.parse(JSON.stringify(result));
  30. return cashingRes;
  31. }
  32. async getCoinsCashingLog() {
  33. const that = this;
  34. const seq = that.app.Sequelize;
  35. const result = await that.useModel.findAll({
  36. where: { type: { [seq.Op.eq]: 2 }, partner_id: { [seq.Op.gt]: 0 } },
  37. });
  38. const cashingRes = JSON.parse(JSON.stringify(result));
  39. return cashingRes;
  40. }
  41. }
  42. module.exports = CashService;