|
|
@@ -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,27 +37,33 @@ 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:
|
|
40
|
+ for log in logs:
|
41
|
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()
|
47
|
|
- if m.is_important or (yesterday_num or current_month or last_month):
|
48
|
|
- SalesResponsibilityInfoModelsSaleStatisticInfo.objects.create(
|
49
|
|
- brand_id=b.brand_id,
|
50
|
|
- sr_id=d.sr_id,
|
51
|
|
- distributor_id=d.distributor_id,
|
52
|
|
- distributor_name=d.distributor_name,
|
53
|
|
- model_id=m.model_id,
|
54
|
|
- model_name=m.model_name,
|
55
|
|
- is_important=m.is_important,
|
56
|
|
- ymd=day,
|
57
|
|
- yesterday_num=yesterday_num,
|
58
|
|
- current_month=current_month,
|
59
|
|
- last_month=last_month,
|
60
|
|
- )
|
|
42
|
+ logs = SaleclerkSubmitLogInfo.objects.filter(model_pk=m.pk, dupload=False, test_sn=False, status=True)
|
|
43
|
+ for d in distributors:
|
|
44
|
+ saleclerks = SaleclerkInfo.objects.filter(brand_id=b.brand_id, distributor_id=d.distributor_id, status=True)
|
|
45
|
+ yesterday_num = 0
|
|
46
|
+ current_month = 0
|
|
47
|
+ last_month = 0
|
|
48
|
+ for saleclerk in saleclerks:
|
|
49
|
+ log = logs.filter(clerk_id=saleclerk.clerk_id)
|
|
50
|
+ yesterday_num += logs.filter(ymd=lastday).count()
|
|
51
|
+ current_month += logs.filter(ym=month).count()
|
|
52
|
+ last_month += logs.filter(ym=lastmonth).count()
|
|
53
|
+ if m.is_important or (yesterday_num or current_month or last_month):
|
|
54
|
+ SalesResponsibilityInfoModelsSaleStatisticInfo.objects.create(
|
|
55
|
+ brand_id=b.brand_id,
|
|
56
|
+ sr_id=d.sr_id,
|
|
57
|
+ distributor_id=d.distributor_id,
|
|
58
|
+ distributor_name=d.distributor_name,
|
|
59
|
+ model_id=m.model_id,
|
|
60
|
+ model_name=m.model_name,
|
|
61
|
+ is_important=m.is_important,
|
|
62
|
+ ymd=day,
|
|
63
|
+ yesterday_num=yesterday_num,
|
|
64
|
+ current_month=current_month,
|
|
65
|
+ last_month=last_month,
|
|
66
|
+ )
|
61
|
67
|
|
62
|
68
|
srs = SalesResponsibilityInfo.objects.filter(brand_id=b.brand_id, status=True)
|
63
|
69
|
for s in srs:
|