withdraw.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. from typing import TYPE_CHECKING
  4. from apps.web.common.models import WithdrawRecord
  5. from apps.web.common.transaction.withdraw import WithdrawService, WithdrawRetryService
  6. from apps.web.common.transaction import WithdrawStatus, WithdrawHandler
  7. from apps.web.core.exceptions import ServiceException
  8. if TYPE_CHECKING:
  9. pass
  10. def check_record_when_revoke_or_approve(withdraw_record, agent_id):
  11. # type: (WithdrawRecord, str)->None
  12. if withdraw_record is None:
  13. raise ServiceException({'result': 0, 'description': u'提现申请不存在', 'payload': {}})
  14. if withdraw_record.manual:
  15. if withdraw_record.status != WithdrawStatus.PROCESSING:
  16. raise ServiceException({'result': 0, 'description': u'订单状态错误,请刷新', 'payload': {}})
  17. else:
  18. if withdraw_record.status != WithdrawStatus.FAILED:
  19. raise ServiceException({'result': 0, 'description': u'订单状态错误,请刷新', 'payload': {}})
  20. if withdraw_record.payAgentId != agent_id:
  21. raise ServiceException({'result': 0, 'description': u'不是有效的提现申请(1001)', 'payload': {}})
  22. class AgentWithdrawHandler(WithdrawHandler):
  23. pass
  24. class AgentWithdrawService(WithdrawService):
  25. pass
  26. class AgentWithdrawRetryService(WithdrawRetryService):
  27. pass