12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- # -*- 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
- init_env(interactive=True)
- logger = get_logger(__name__)
- from bson.objectid import ObjectId
- from apps.web.user.models import CardRechargeOrder, RechargeRecord
- from apps.web.dealer.models import Dealer
- from apps.web.agent.models import Agent
- from apps.web.dealer.proxy import DealerIncomeProxy
- agentIds = [str(_.id) for _ in Agent.objects(customizedWechatCashflowAllowable=False, customizedAlipayCashflowAllowable=False)]
- cardOrders = CardRechargeOrder.objects(__raw__={'status':'finishedPay','rechargeNo':{'$ne': None}})
- tempCardOrders = [str(_.id) for _ in cardOrders]
- trueCardOrders = []
- for _ in cardOrders:
- r = RechargeRecord.objects(id=str(_.rechargeNo)).first()
- if r is None or r.ownerId == '' or r.ownerId is None:
- logger.error('invalid rechargeNo=%s' % _.rechargeNo)
- continue
- p = DealerIncomeProxy.objects(ref_id=ObjectId(r.id)).first()
- # 如果有分账就不记录
- if p is not None:
- continue
- d = Dealer.objects(id=r.ownerId).first()
- if d is None:
- logger.error('undefined Dealer=%s' % r.ownerId)
- continue
- # 如果有资金池就不记录
- if d.agentId not in agentIds:
- continue
- else:
- trueCardOrders.append(str(_.id))
- print(len(trueCardOrders), len(tempCardOrders))
- total = 0
- for _ in trueCardOrders:
- c = CardRechargeOrder.objects(id=_).first()
- total += int(c.money)
- print(total)
|