find_refund_order.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. import datetime
  4. import os
  5. import sys
  6. PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
  7. sys.path.insert(0, PROJECT_ROOT)
  8. from script.base import init_env
  9. os.environ["DJANGO_SETTINGS_MODULE"] = "configs.production"
  10. init_env(False)
  11. from apps.web.dealer.models import Dealer
  12. from apilib.monetary import RMB
  13. # from apps.web.user.models import RechargeRecord, RefundMoneyRecord
  14. #
  15. # for item in RechargeRecord.objects(ownerId = '613706d4003048141c44563b').all():
  16. # refund_order = RefundMoneyRecord.objects(rechargeObjId = item.id).first()
  17. # if refund_order:
  18. # print str(item.id), str(refund_order.id)
  19. skip = 0
  20. limit = 2000
  21. while True:
  22. query = Dealer.objects().only('id', 'deviceBalance').skip(skip).limit(limit)
  23. if len(query) <= 0:
  24. break
  25. for dealer in query:
  26. if not dealer.deviceBalance:
  27. continue
  28. for source_key, balance in dealer.deviceBalance.iteritems():
  29. if balance.balance < RMB(0):
  30. print '{}'.format(str(dealer.id))
  31. break
  32. skip = skip + limit
  33. from apps.web.dealer.proxy import DealerIncomeProxy
  34. # for proxy in DealerIncomeProxy.objects(partition__id = '613706d4003048141c44563b').all():
  35. # if len(proxy.dealerIds) != 1 or str(proxy.dealerIds[0]) != '613706d4003048141c44563b':
  36. # print str(proxy.id)
  37. # from apps.web.common.proxy import ClientDealerIncomeModelProxy
  38. #
  39. # proxyModel = ClientDealerIncomeModelProxy(st = datetime.datetime(2017, 1, 1, 0, 0, 0),
  40. # et = datetime.datetime(2022, 3, 1, 0, 0, 0))
  41. # for proxy in proxyModel.all(**{'partition__id': '613706d4003048141c44563b'}):
  42. # if len(proxy.dealerIds) != 1 or str(proxy.dealerIds[0]) != '613706d4003048141c44563b':
  43. # print str(proxy.id)