|
|
@@ -7,7 +7,7 @@ from django_six import CompatibilityBaseCommand, close_old_connections
|
7
|
7
|
from TimeConvert import TimeConvert as tc
|
8
|
8
|
|
9
|
9
|
from integral.models import SaleclerkSubmitLogInfo
|
10
|
|
-from mch.models import BrandInfo, DistributorInfo, ModelInfo
|
|
10
|
+from mch.models import BrandInfo, DistributorInfo, ModelInfo, SaleclerkInfo
|
11
|
11
|
from sales.models import SalesResponsibilityInfo, SalesResponsibilityInfoModelsSaleStatisticInfo, SuperSalesResponsibilityInfoModelsSaleStatisticInfo
|
12
|
12
|
|
13
|
13
|
|
|
|
@@ -37,13 +37,20 @@ class Command(CompatibilityBaseCommand):
|
37
|
37
|
|
38
|
38
|
distributors = DistributorInfo.objects.filter(brand_id=b.brand_id, status=True)
|
39
|
39
|
models = ModelInfo.objects.filter(brand_id=b.brand_id, status=True)
|
40
|
|
- for d in distributors:
|
41
|
|
- for m in models:
|
42
|
|
- logs = SaleclerkSubmitLogInfo.objects.filter(distributor_pk=d.pk, model_pk=m.pk, dupload=False, test_sn=False, status=True)
|
43
|
|
- # today_num = logs.filter(ymd=day).count()
|
44
|
|
- yesterday_num = logs.filter(ymd=lastday).count()
|
45
|
|
- current_month = logs.filter(ym=month).count()
|
46
|
|
- last_month = logs.filter(ym=lastmonth).count()
|
|
40
|
+ for m in models:
|
|
41
|
+ logs = SaleclerkSubmitLogInfo.objects.filter(model_pk=m.pk, dupload=False, test_sn=False, ym__gte=lastmonth, status=True)
|
|
42
|
+ for d in distributors:
|
|
43
|
+ yesterday_num = 0
|
|
44
|
+ current_month = 0
|
|
45
|
+ last_month = 0
|
|
46
|
+ if logs.count() != 0:
|
|
47
|
+ saleclerks = SaleclerkInfo.objects.filter(brand_id=b.brand_id, distributor_id=d.distributor_id, status=True)
|
|
48
|
+ for saleclerk in saleclerks:
|
|
49
|
+ log = logs.filter(clerk_id=saleclerk.clerk_id)
|
|
50
|
+ yesterday_num += log.filter(ymd=lastday).count()
|
|
51
|
+ current_month += log.filter(ym=month).count()
|
|
52
|
+ last_month += log.filter(ym=lastmonth).count()
|
|
53
|
+
|
47
|
54
|
if m.is_important or (yesterday_num or current_month or last_month):
|
48
|
55
|
SalesResponsibilityInfoModelsSaleStatisticInfo.objects.create(
|
49
|
56
|
brand_id=b.brand_id,
|
|
|
@@ -61,7 +68,6 @@ class Command(CompatibilityBaseCommand):
|
61
|
68
|
|
62
|
69
|
srs = SalesResponsibilityInfo.objects.filter(brand_id=b.brand_id, status=True)
|
63
|
70
|
for s in srs:
|
64
|
|
- print s
|
65
|
71
|
if s.is_super:
|
66
|
72
|
continue
|
67
|
73
|
sums = SalesResponsibilityInfoModelsSaleStatisticInfo.objects.filter(
|