mount_withdraw_apps.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. import os
  4. import sys
  5. PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
  6. sys.path.insert(0, PROJECT_ROOT)
  7. from script.base import init_env, get_logger
  8. logger = get_logger(__name__)
  9. init_env(interactive = True)
  10. from apps.web.core.models import AliApp, WithdrawEntity, WechatPayApp
  11. from apps.web.agent.models import Agent
  12. agentId = '6417d4456f29257125ebf705'
  13. alipay_withdraw_app_id = '2021003183632080'
  14. new_alipay_pay_app_id = '' # 新支付宝支付APP
  15. new_wechat_pay_mchid = '' # 新微信支付APP
  16. agent = Agent.objects(id = agentId).first()
  17. print agent.username, agent.nickname, agent.productName, agent.withdraw_source_key()
  18. if new_alipay_pay_app_id:
  19. agent.payAppAli = AliApp.objects(appid = new_alipay_pay_app_id).first()
  20. agent.save()
  21. if new_wechat_pay_mchid:
  22. old_source_key = agent.withdraw_source_key()
  23. if not agent.withdrawApps or old_source_key not in agent.withdrawApps:
  24. entity = WithdrawEntity() # type: WithdrawEntity
  25. entity.wechatWithdrawApp = agent.payAppWechat.fetch()
  26. agent.withdrawApps = {
  27. old_source_key: entity
  28. }
  29. agent.save()
  30. agent.payAppWechat = WechatPayApp.objects(mchid = new_wechat_pay_mchid).first()
  31. new_source_key = agent.withdraw_source_key()
  32. entity = WithdrawEntity() # type: WithdrawEntity
  33. entity.alipayWithdrawApp = agent.payAppAli.fetch()
  34. entity.wechatWithdrawApp = agent.payAppWechat.fetch()
  35. agent.withdrawApps = {
  36. new_source_key: entity
  37. }
  38. agent.save()
  39. else:
  40. entity = WithdrawEntity() # type: WithdrawEntity
  41. entity.alipayWithdrawApp = AliApp.objects(appid = alipay_withdraw_app_id).first()
  42. entity.wechatWithdrawApp = agent.payAppWechat.fetch()
  43. agent.withdrawApps = {
  44. agent.withdraw_source_key(): entity
  45. }
  46. agent.save()