# -*- coding: utf-8 -*- #!/usr/bin/env python """ 支付宝自主收款和微信自主收款并无关联 """ import os import sys from bson.objectid import ObjectId #: current_dir - 2 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.agent.models import Agent agentCollection = Agent.get_collection() agents = agentCollection.find({'customizedCashflowAllowable': True}) if not agents: print 'no agents to operate on' for a in agents: if a.get('appid'): print 'writing wechat cashflow allowable to agent(%s)' % (str(a['_id'],)) updated0 = agentCollection.update({'_id': ObjectId(a['_id'])}, {'$set': {'customizedWechatCashflowAllowable':True}}) assert updated0, 'customizeWechatCashflowAllowable update error, agent=%s' % (str(a.id),) if a.get('alipay_appid'): print 'writing alipay cashflow allowable to agent(%s)' % (str(a['_id'],)) updated1 = agentCollection.update({'_id': ObjectId(a['_id'])}, {'$set':{'customizedAlipayCashflowAllowable': True}}) assert updated1, 'customizeAlipayCashflowAllowable update error agent=%s' % (str(a.id),) print 'start deleting customizedCashflowAllowable field' agentCollection.update({}, {'$unset': {'customizedCashflowAllowable': ''}}, multi=True) print 'finished'