upgrade_Agent.20180813.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. """
  4. """
  5. import os
  6. import sys
  7. from django.conf import settings
  8. from apps.web.core.models import _AliPaymentApp
  9. PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
  10. sys.path.insert(0, PROJECT_ROOT)
  11. from script.base import init_env
  12. init_env(interactive = True)
  13. from apps.web.agent.models import Agent
  14. for agent in Agent.objects.all():
  15. if not agent.is_primary:
  16. continue
  17. my_agent = Agent.objects(id = str('6417d4456f29257125ebf705')).get()
  18. import copy
  19. if not agent.wechatLoginAuthApp or not agent.wechatLoginAuthApp.appid:
  20. agent.wechatLoginAuthApp = copy.deepcopy(my_agent.wechatLoginAuthApp)
  21. if not agent.wechatPayApp or not agent.wechatPayApp.appid:
  22. agent.wechatPayApp = copy.deepcopy(my_agent.wechatPayApp)
  23. agent.customizedWechatCashflowAllowable = my_agent.customizedWechatCashflowAllowable
  24. if not agent.wechatUserManagerialApp or not agent.wechatUserManagerialApp.appid:
  25. agent.wechatUserManagerialApp = copy.deepcopy(my_agent.wechatUserManagerialApp)
  26. agent.customizedUserGzhAllowable = my_agent.customizedUserGzhAllowable
  27. if not agent.wechatDealerManagerialApp or not agent.wechatDealerManagerialApp.appid:
  28. agent.wechatDealerManagerialApp = copy.deepcopy(my_agent.wechatDealerManagerialApp)
  29. agent.customizedDealerGzhAllowable = my_agent.customizedDealerGzhAllowable
  30. if not agent.aliPayApp or not agent.aliPayApp.appid:
  31. if agent.customizedWechatCashflowAllowable:
  32. if agent.customizedAlipayCashflowAllowable:
  33. agent.aliPayApp = _AliPaymentApp(appid = agent.alipay_appid,
  34. public_key_path = agent.alipay_public_key_path,
  35. app_private_key_path = agent.app_private_key_path,
  36. shadow = False)
  37. else:
  38. if agent.customizedAlipayCashflowAllowable:
  39. agent.aliPayApp = _AliPaymentApp(appid = agent.alipay_appid,
  40. public_key_path = agent.alipay_public_key_path,
  41. app_private_key_path = agent.app_private_key_path,
  42. shadow = False)
  43. else:
  44. agent.aliPayApp = copy.deepcopy(my_agent.aliPayApp)
  45. agent.customizedAlipayCashflowAllowable = my_agent.customizedAlipayCashflowAllowable
  46. if not agent.productName:
  47. agent.productName = my_agent.productName
  48. if not agent.productLogo:
  49. agent.productLogo = my_agent.productLogo
  50. agent.save()