calc_redpack.py 1023 B

123456789101112131415161718192021222324252627282930313233343536
  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 apilib.monetary import RMB
  12. from apps.web.core.db import copy_document_classes
  13. from apps.web.user.models import RechargeRecord
  14. end = datetime.datetime(2089, 1, 1, 0, 0, 0)
  15. check_date = datetime.datetime(2022, 6, 1, 0, 0, 0)
  16. if __name__ == '__main__':
  17. ownerId = sys.argv[1]
  18. online = RechargeRecord.objects(ownerId = ownerId, via = 'redpack').sum('money')
  19. print online
  20. his_model_cls = copy_document_classes(RechargeRecord, '{}_his'.format(RechargeRecord.__name__),
  21. 'default_his')
  22. history = his_model_cls.objects(ownerId = ownerId, via = 'redpack').sum('money')
  23. print history
  24. print RMB(online) + RMB(history)