Exemple #1
0
 def handle(self, start, end, *args, **options):
     print "__jk terminal"
     if not token:
         print "no token!!"
         return
     date_list = []
     if not start or not end:
         end_date = datetime.now()
         for i in range(3):
             adate = end_date - timedelta(i)
             date_list.append(adate)
     else:
         start_date = utils.string_to_datetime(start)
         end_date = utils.string_to_datetime(end)
         date_list.append(start_date)
         n = 1
         while True:
             day_date = start_date + timedelta(n)
             date_list.append(day_date)
             n += 1
             if day_date >= end_date:
                 break
     cookies = get_cookies(token)
     for adate in date_list:
         adate_str = utils.datetime_to_string(adate, format_str="%Y-%m-%d")
         terminal_data = get_trade_data(cookies, adate_str)
         write_to_db_trade(terminal_data)
     print "ok"
Exemple #2
0
 def handle(self, start, end, *args, **options):
     now = datetime.now()
     if end is None:
         end_datetime = now
     else:
         end_datetime = utils.string_to_datetime(end, format_str="%Y-%m-%d")
     if start is None:
         start_datetime = end_datetime - timedelta(3)
     else:
         start_datetime = utils.string_to_datetime(start,
                                                   format_str="%Y-%m-%d")
     start_date = start_datetime.date()
     end_date = end_datetime.date()
     print "__sync jk child user rmb", start_date, end_date
     print now
     default_user = get_user_by_username("13300000000")
     # SYFTrade
     used_trans_ids = set(
         models.JKChildProfit.objects.values_list("trans_id", flat=True))
     objs = models.JKProfit.objects.all()
     for obj in objs:
         if obj.trans_id in used_trans_ids:
             continue
         adatetime = utils.string_to_datetime(obj.trade_date[:10],
                                              format_str="%Y-%m-%d")
         adate = adatetime.date()
         if start_date <= adate <= end_date:
             process_jk_child_rmb(obj, default_user)
     print "ok"
Exemple #3
0
 def handle(self, start, end, *args, **options):
     now = datetime.now()
     if end is None:
         end_datetime = now
     else:
         end_datetime = utils.string_to_datetime(end, format_str="%Y-%m-%d")
     if start is None:
         start_datetime = end_datetime - timedelta(3)
     else:
         start_datetime = utils.string_to_datetime(start,
                                                   format_str="%Y-%m-%d")
     start_date = start_datetime.date()
     end_date = end_datetime.date()
     print "__sync jk user rmb", start_date, end_date
     print now
     default_user = get_user_by_username("13300000000")
     # SYFTrade
     used_trans_ids = set(
         models.JKProfit.objects.values_list("trans_id", flat=True))
     objs = models.JKTrade.objects.filter(card_type=u"贷记").filter(
         return_code="00")
     # if obj.trade_card_type == u"贷记卡" and obj.return_code == "00" and obj.trade_rmb != "299.0":
     for obj in objs:
         if obj.trans_id in used_trans_ids:
             continue
         if obj.product.strip() == "" and obj.trade_category.strip(
         ) == "" and obj.trade_rmb != "220.0" and obj.trade_rmb != "300.0":
             adatetime = utils.string_to_datetime(obj.trade_date[:10],
                                                  format_str="%Y-%m-%d")
             adate = adatetime.date()
             if start_date <= adate <= end_date:
                 process_jk_rmb(obj, default_user)
     print "ok"
Exemple #4
0
 def handle(self, start, end, table, *args, **options):
     is_none = False
     if start is None or end is None:
         is_none = True
         end_date = datetime.now()
         if table == "terminal_update":
             end_date = end_date - timedelta(3)
             start_date = end_date - timedelta(30)
         else:
             start_date = end_date - timedelta(3)
         start = utils.datetime_to_string(start_date, format_str="%Y-%m-%d")
         end = utils.datetime_to_string(end_date, format_str="%Y-%m-%d")
     print "__sync slkl", start, end, table
     print datetime.now()
     if not URL:
         print "token:", URL
         return
     cookies = get_cookies()
     start1 = "".join(start.split("-"))
     end1 = "".join(end.split("-"))
     # D0
     if table in ("d0", "all"):
         d0_data = get_d0_data(cookies, start1, end1)
         write_to_db_d0(d0_data)
     # D1
     if table in ("d1", "all"):
         start_date = utils.string_to_datetime(start1)
         end_date = utils.string_to_datetime(end1)
         diff = end_date - start_date
         if is_none:
             s = -3
         else:
             s = 0
         for i in range(s, diff.days + 1)[::-1]:
             adate = start_date + timedelta(i)
             adate_str = utils.datetime_to_string(adate)
             d1_data = get_d1_data(cookies, adate_str)
             write_to_db_d1(d1_data)
     # 终端
     if table in ("terminal", "terminal_update", "all"):
         terminal_data = get_terminal_data(cookies, start, end)
         write_to_db_terminal(terminal_data)
Exemple #5
0
 def handle(self, start, end, table, *args, **options):
     if end is None:
         end_datetime = datetime.now() - timedelta(4)
     else:
         end_datetime = utils.string_to_datetime(end, format_str="%Y-%m-%d")
     if start is None:
         start_datetime = end_datetime - timedelta(3)
     else:
         start_datetime = utils.string_to_datetime(start, format_str="%Y-%m-%d")
     start_date = start_datetime.date()
     end_date = end_datetime.date()
     # start = utils.datetime_to_string(start_date, format_str="%Y-%m-%d")
     # end = utils.datetime_to_string(end_date, format_str="%Y-%m-%d")
     print "__sync user rmb", start_date, end_date, table
     print datetime.now()
     default_user = get_user_by_username("13300000000")
     # D0
     if table in ("d0", "all"):
         used_trans_ids = set(models.ProfitD0.objects.values_list("trans_id", flat=True))
         objs = models.LKLD0.objects.filter(fee_rmb="2").filter(trans_type=u"正交易").filter(trans_status=u"成功")
         for obj in objs:
             if obj.trans_id in used_trans_ids:
                 continue
             adatetime = utils.string_to_datetime(obj.draw_date, format_str="%Y%m%d %H:%M:%S")
             adate = adatetime.date()
             if start_date <= adate <= end_date:
                 process_d0_rmb(obj, default_user)
     # D1
     if table in ("d1", "all"):
         used_trans_ids = set(models.ProfitD1.objects.values_list("trans_id", flat=True))
         objs = models.LKLD1.objects.filter(card_type=u"贷记卡")
         for obj in objs:
             if obj.trans_id in used_trans_ids:
                 continue
             adatetime = utils.string_to_datetime(obj.pay_date, format_str="%Y-%m-%d %H:%M:%S.0")
             adate = adatetime.date()
             if start_date <= adate <= end_date:
                 process_d1_rmb(obj, default_user)