|
|
@@ -1,39 +0,0 @@
|
1
|
|
-# -*- coding: utf-8 -*-
|
2
|
|
-
|
3
|
|
-import logging
|
4
|
|
-
|
5
|
|
-from django.db.models import Sum
|
6
|
|
-from django_six import CompatibilityBaseCommand, close_old_connections
|
7
|
|
-from TimeConvert import TimeConvert as tc
|
8
|
|
-
|
9
|
|
-from integral.models import SaleclerkSubmitLogInfo
|
10
|
|
-from mch.models import BrandInfo, DistributorInfo, ModelInfo, SaleclerkInfo
|
11
|
|
-from sales.models import (SalesResponsibilityInfo, SalesResponsibilityInfoModelsSaleStatisticInfo,
|
12
|
|
- SuperSalesResponsibilityInfoModelsSaleStatisticInfo)
|
13
|
|
-
|
14
|
|
-
|
15
|
|
-logger = logging.getLogger('console')
|
16
|
|
-
|
17
|
|
-
|
18
|
|
-class Command(CompatibilityBaseCommand):
|
19
|
|
- def handle(self, *args, **options):
|
20
|
|
-
|
21
|
|
- logger.info('Fix sale is dealing')
|
22
|
|
-
|
23
|
|
- close_old_connections()
|
24
|
|
-
|
25
|
|
- pks = range(0, 1200000, 10000)
|
26
|
|
- pkslen = len(pks)
|
27
|
|
- for idx in range(1, pkslen):
|
28
|
|
- start, end = pks[idx - 1], pks[idx]
|
29
|
|
- print('Start Idx: ', start)
|
30
|
|
- print('End Idx: ', end)
|
31
|
|
- sales = SalesResponsibilityInfoModelsSaleStatisticInfo.objects.filter(pk__gt=start, pk__lte=end)
|
32
|
|
- for sale in sales:
|
33
|
|
- ymd = str(sale.ymd)
|
34
|
|
- print('Old ymd: ', ymd)
|
35
|
|
- sale.ymd = tc.local_string(tc.local_datetime(tc.string_to_local_datetime(ymd, '%Y%m%d'), days=-1), format='%Y%m%d')
|
36
|
|
- print('New ymd: ', sale.ymd)
|
37
|
|
- sale.save()
|
38
|
|
-
|
39
|
|
- close_old_connections()
|