123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- # -*- coding: utf-8 -*-
- # !/usr/bin/env python
- import os
- import sys
- PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
- sys.path.insert(0, PROJECT_ROOT)
- from script.base import init_env, get_logger
- logger = get_logger(__name__)
- init_env(interactive = True)
- from apps.web.core.models import AliApp, WithdrawEntity, WechatPayApp
- from apps.web.agent.models import Agent
- agentId = '6417d4456f29257125ebf705'
- alipay_withdraw_app_id = '2021003183632080'
- new_alipay_pay_app_id = '' # 新支付宝支付APP
- new_wechat_pay_mchid = '' # 新微信支付APP
- agent = Agent.objects(id = agentId).first()
- print agent.username, agent.nickname, agent.productName, agent.withdraw_source_key()
- if new_alipay_pay_app_id:
- agent.payAppAli = AliApp.objects(appid = new_alipay_pay_app_id).first()
- agent.save()
- if new_wechat_pay_mchid:
- old_source_key = agent.withdraw_source_key()
- if not agent.withdrawApps or old_source_key not in agent.withdrawApps:
- entity = WithdrawEntity() # type: WithdrawEntity
- entity.wechatWithdrawApp = agent.payAppWechat.fetch()
- agent.withdrawApps = {
- old_source_key: entity
- }
- agent.save()
- agent.payAppWechat = WechatPayApp.objects(mchid = new_wechat_pay_mchid).first()
- new_source_key = agent.withdraw_source_key()
- entity = WithdrawEntity() # type: WithdrawEntity
- entity.alipayWithdrawApp = agent.payAppAli.fetch()
- entity.wechatWithdrawApp = agent.payAppWechat.fetch()
- agent.withdrawApps = {
- new_source_key: entity
- }
- agent.save()
- else:
- entity = WithdrawEntity() # type: WithdrawEntity
- entity.alipayWithdrawApp = AliApp.objects(appid = alipay_withdraw_app_id).first()
- entity.wechatWithdrawApp = agent.payAppWechat.fetch()
- agent.withdrawApps = {
- agent.withdraw_source_key(): entity
- }
- agent.save()
|