@@ -52,7 +52,7 @@ def get_userinfo_api(request): |
||
52 | 52 |
user.user_id = CurtailUUID.uuid(UserInfo, 'user_id') |
53 | 53 |
# 注册用户统计 |
54 | 54 |
rsi, _ = RegisterStatisticInfo.objects.select_for_update().get_or_create( |
55 |
- ymd=tc.local_string(format='%Y%m%d'), |
|
55 |
+ ymd=int(tc.local_string(format='%Y%m%d')), |
|
56 | 56 |
) |
57 | 57 |
rsi.num += 1 |
58 | 58 |
rsi.save() |
@@ -132,7 +132,7 @@ def clerk_sale_submit_api(request): |
||
132 | 132 |
) |
133 | 133 |
|
134 | 134 |
if not sci: |
135 |
- ymd = tc.local_string(format='%Y%m%d') |
|
135 |
+ ymd = int(tc.local_string(format='%Y%m%d')) |
|
136 | 136 |
|
137 | 137 |
# 销量统计 |
138 | 138 |
ssi, _ = SaleStatisticInfo.objects.select_for_update().get_or_create( |
@@ -152,7 +152,7 @@ def clerk_sale_submit_api(request): |
||
152 | 152 |
|
153 | 153 |
mssi2, _ = ModelSaleStatisticInfo.objects.select_for_update().get_or_create( |
154 | 154 |
model_id=modelID, |
155 |
- ymd='0', |
|
155 |
+ ymd=0, |
|
156 | 156 |
) |
157 | 157 |
mssi2.model_name = model.model_name |
158 | 158 |
mssi2.num += 1 |
@@ -169,7 +169,7 @@ def clerk_sale_submit_api(request): |
||
169 | 169 |
|
170 | 170 |
dssi2, _ = DistributorSaleStatisticInfo.objects.select_for_update().get_or_create( |
171 | 171 |
distributor_id=distributorID, |
172 |
- ymd='0', |
|
172 |
+ ymd=0, |
|
173 | 173 |
) |
174 | 174 |
dssi2.distributor_name = distributor.distributor_name |
175 | 175 |
dssi2.num += 1 |
@@ -46,7 +46,7 @@ PROVINCE_LIST = { |
||
46 | 46 |
|
47 | 47 |
def pre_provinces(): |
48 | 48 |
for pcode, pname in PROVINCE_LIST.items(): |
49 |
- pssi, created = ProvinceSaleStatisticInfo.objects.get_or_create(province_code=pcode, ymd='0') |
|
49 |
+ pssi, created = ProvinceSaleStatisticInfo.objects.get_or_create(province_code=pcode, ymd=0) |
|
50 | 50 |
pssi.province_name = pname |
51 | 51 |
pssi.save() |
52 | 52 |
|
@@ -54,7 +54,7 @@ def pre_provinces(): |
||
54 | 54 |
def pre_models(): |
55 | 55 |
models = ModelInfo.objects.filter(status=True) |
56 | 56 |
for mdl in models: |
57 |
- mssi, created = ModelSaleStatisticInfo.objects.get_or_create(model_id=mdl.model_id, ymd='0') |
|
57 |
+ mssi, created = ModelSaleStatisticInfo.objects.get_or_create(model_id=mdl.model_id, ymd=0) |
|
58 | 58 |
mssi.model_name = mdl.model_name |
59 | 59 |
mssi.save() |
60 | 60 |
|
@@ -62,6 +62,6 @@ def pre_models(): |
||
62 | 62 |
def pre_distributors(): |
63 | 63 |
distributors = DistributorInfo.objects.filter(status=True) |
64 | 64 |
for dtbt in distributors: |
65 |
- dssi, created = DistributorSaleStatisticInfo.objects.get_or_create(distributor_id=dtbt.distributor_id, ymd='0') |
|
65 |
+ dssi, created = DistributorSaleStatisticInfo.objects.get_or_create(distributor_id=dtbt.distributor_id, ymd=0) |
|
66 | 66 |
dssi.distributor_name = dtbt.distributor_name |
67 | 67 |
dssi.save() |
@@ -0,0 +1,40 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.11 on 2018-04-26 01:52 |
|
3 |
+from __future__ import unicode_literals |
|
4 |
+ |
|
5 |
+from django.db import migrations, models |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class Migration(migrations.Migration): |
|
9 |
+ |
|
10 |
+ dependencies = [ |
|
11 |
+ ('statistic', '0003_provincesalestatisticinfo_position'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AlterField( |
|
16 |
+ model_name='distributorsalestatisticinfo', |
|
17 |
+ name='ymd', |
|
18 |
+ field=models.IntegerField(db_index=True, default=0, help_text='\u5e74\u6708\u65e5', verbose_name='ymd'), |
|
19 |
+ ), |
|
20 |
+ migrations.AlterField( |
|
21 |
+ model_name='modelsalestatisticinfo', |
|
22 |
+ name='ymd', |
|
23 |
+ field=models.IntegerField(db_index=True, default=0, help_text='\u5e74\u6708\u65e5', verbose_name='ymd'), |
|
24 |
+ ), |
|
25 |
+ migrations.AlterField( |
|
26 |
+ model_name='provincesalestatisticinfo', |
|
27 |
+ name='ymd', |
|
28 |
+ field=models.IntegerField(db_index=True, default=0, help_text='\u5e74\u6708\u65e5', verbose_name='ymd'), |
|
29 |
+ ), |
|
30 |
+ migrations.AlterField( |
|
31 |
+ model_name='registerstatisticinfo', |
|
32 |
+ name='ymd', |
|
33 |
+ field=models.IntegerField(db_index=True, default=0, help_text='\u5e74\u6708\u65e5', verbose_name='ymd'), |
|
34 |
+ ), |
|
35 |
+ migrations.AlterField( |
|
36 |
+ model_name='salestatisticinfo', |
|
37 |
+ name='ymd', |
|
38 |
+ field=models.IntegerField(db_index=True, default=0, help_text='\u5e74\u6708\u65e5', verbose_name='ymd'), |
|
39 |
+ ), |
|
40 |
+ ] |
@@ -9,7 +9,7 @@ from utils.rdm_utils import randnum |
||
9 | 9 |
|
10 | 10 |
|
11 | 11 |
class RegisterStatisticInfo(BaseModelMixin): |
12 |
- ymd = models.CharField(_(u'ymd'), max_length=8, blank=True, null=True, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d') |
|
12 |
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d') |
|
13 | 13 |
num = models.IntegerField(_(u'num'), default=0, help_text=u'数量') |
14 | 14 |
|
15 | 15 |
class Meta: |
@@ -28,7 +28,7 @@ class RegisterStatisticInfo(BaseModelMixin): |
||
28 | 28 |
|
29 | 29 |
|
30 | 30 |
class SaleStatisticInfo(BaseModelMixin): |
31 |
- ymd = models.CharField(_(u'ymd'), max_length=8, blank=True, null=True, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d') |
|
31 |
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d') |
|
32 | 32 |
num = models.IntegerField(_(u'num'), default=0, help_text=u'数量') |
33 | 33 |
|
34 | 34 |
class Meta: |
@@ -49,7 +49,7 @@ class SaleStatisticInfo(BaseModelMixin): |
||
49 | 49 |
class ModelSaleStatisticInfo(BaseModelMixin): |
50 | 50 |
model_id = models.CharField(_(u'model_id'), max_length=32, help_text=u'型号唯一标识', db_index=True) |
51 | 51 |
model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称') |
52 |
- ymd = models.CharField(_(u'ymd'), max_length=8, blank=True, null=True, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部 |
|
52 |
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部 |
|
53 | 53 |
num = models.IntegerField(_(u'num'), default=0, help_text=u'数量') |
54 | 54 |
|
55 | 55 |
class Meta: |
@@ -72,7 +72,7 @@ class ModelSaleStatisticInfo(BaseModelMixin): |
||
72 | 72 |
class DistributorSaleStatisticInfo(BaseModelMixin): |
73 | 73 |
distributor_id = models.CharField(_(u'distributor_id'), max_length=32, help_text=u'经销商唯一标识', db_index=True) |
74 | 74 |
distributor_name = models.CharField(_(u'distributor_name'), max_length=255, blank=True, null=True, help_text=u'经销商名称') |
75 |
- ymd = models.CharField(_(u'ymd'), max_length=8, blank=True, null=True, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部 |
|
75 |
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部 |
|
76 | 76 |
num = models.IntegerField(_(u'num'), default=0, help_text=u'数量') |
77 | 77 |
|
78 | 78 |
class Meta: |
@@ -95,7 +95,7 @@ class DistributorSaleStatisticInfo(BaseModelMixin): |
||
95 | 95 |
class ProvinceSaleStatisticInfo(BaseModelMixin): |
96 | 96 |
province_code = models.CharField(_(u'province_code'), max_length=32, help_text=u'省份编码', db_index=True) |
97 | 97 |
province_name = models.CharField(_(u'province_name'), max_length=32, blank=True, null=True, help_text=u'省份名称') |
98 |
- ymd = models.CharField(_(u'ymd'), max_length=8, blank=True, null=True, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部 |
|
98 |
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部 |
|
99 | 99 |
num = models.IntegerField(_(u'num'), default=0, help_text=u'数量') |
100 | 100 |
|
101 | 101 |
position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') |
@@ -12,7 +12,7 @@ from utils.rdm_utils import randnum |
||
12 | 12 |
|
13 | 13 |
@logit |
14 | 14 |
def tj_data(request): |
15 |
- ymd = tc.local_string(format='%Y%m%d') |
|
15 |
+ ymd = int(tc.local_string(format='%Y%m%d')) |
|
16 | 16 |
|
17 | 17 |
# 注册用户统计 & 今日注册用户 |
18 | 18 |
try: |
@@ -21,7 +21,7 @@ def tj_data(request): |
||
21 | 21 |
register_num = 0 |
22 | 22 |
|
23 | 23 |
# 注册用户数趋势 |
24 |
- register_trends = RegisterStatisticInfo.objects.filter(status=True).order_by('-pk')[:30] |
|
24 |
+ register_trends = RegisterStatisticInfo.objects.filter(status=True).order_by('-ymd')[:30] |
|
25 | 25 |
register_trends = [r.data for r in register_trends] |
26 | 26 |
|
27 | 27 |
# 销量统计 & 今日销量 |
@@ -31,19 +31,19 @@ def tj_data(request): |
||
31 | 31 |
sale_num = 0 |
32 | 32 |
|
33 | 33 |
# 商品销量趋势 |
34 |
- sale_trends = SaleStatisticInfo.objects.filter(status=True).order_by('-pk')[:30] |
|
34 |
+ sale_trends = SaleStatisticInfo.objects.filter(status=True).order_by('-ymd')[:30] |
|
35 | 35 |
sale_trends = [s.data for s in sale_trends] |
36 | 36 |
|
37 | 37 |
# 型号销量统计 & 热销商品榜 |
38 |
- model_sales = ModelSaleStatisticInfo.objects.filter(ymd='0', status=True).order_by('-num')[:3] |
|
38 |
+ model_sales = ModelSaleStatisticInfo.objects.filter(ymd=0, status=True).order_by('-num')[:3] |
|
39 | 39 |
model_sales = [m.data for m in model_sales] |
40 | 40 |
|
41 | 41 |
# 经销商销量统计 & 经销商榜 |
42 |
- distributor_sales = DistributorSaleStatisticInfo.objects.filter(ymd='0', status=True).order_by('-num')[:3] |
|
42 |
+ distributor_sales = DistributorSaleStatisticInfo.objects.filter(ymd=0, status=True).order_by('-num')[:3] |
|
43 | 43 |
distributor_sales = [d.data for d in distributor_sales] |
44 | 44 |
|
45 | 45 |
# 各地区实时销量 |
46 |
- province_sales = ProvinceSaleStatisticInfo.objects.filter(ymd='0', status=True).order_by('position') |
|
46 |
+ province_sales = ProvinceSaleStatisticInfo.objects.filter(ymd=0, status=True).order_by('position') |
|
47 | 47 |
province_sales = [p.data for p in province_sales] |
48 | 48 |
|
49 | 49 |
return response(200, 'Get TJ Data Success', u'获取统计数据成功', { |