@@ -0,0 +1,41 @@ |
||
| 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 |
+ sales = SalesResponsibilityInfoModelsSaleStatisticInfo.objects.all() |
|
| 26 |
+ for sale in sales: |
|
| 27 |
+ ymd = str(sale.ymd) |
|
| 28 |
+ print('Old ymd: ', ymd)
|
|
| 29 |
+ sale.ymd = tc.local_string(tc.local_datetime(tc.string_to_local_datetime(ymd, '%Y%m%d'), days=-1), format='%Y%m%d') |
|
| 30 |
+ print('New ymd: ', sale.ymd)
|
|
| 31 |
+ sale.save() |
|
| 32 |
+ |
|
| 33 |
+ sales = SuperSalesResponsibilityInfoModelsSaleStatisticInfo.objects.all() |
|
| 34 |
+ for sale in sales: |
|
| 35 |
+ ymd = str(sale.ymd) |
|
| 36 |
+ print('Old ymd: ', ymd)
|
|
| 37 |
+ sale.ymd = tc.local_string(tc.local_datetime(tc.string_to_local_datetime(ymd, '%Y%m%d'), days=-1), format='%Y%m%d') |
|
| 38 |
+ print('New ymd: ', sale.ymd)
|
|
| 39 |
+ sale.save() |
|
| 40 |
+ |
|
| 41 |
+ close_old_connections() |