Field(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d')
|
13
|
14
|
num = models.IntegerField(_(u'num'), default=0, help_text=u'数量')
|
|
14
|
15
|
|
|
|
|
@@ -27,7 +28,11 @@ class RegisterStatisticInfo(BaseModelMixin):
|
|
27
|
28
|
}
|
|
28
|
29
|
|
|
29
|
30
|
|
|
|
31
|
+# 经销商维度
|
|
|
32
|
+
|
|
|
33
|
+
|
|
30
|
34
|
class SaleStatisticInfo(BaseModelMixin):
|
|
|
35
|
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
|
|
31
|
36
|
ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d')
|
|
32
|
37
|
num = models.IntegerField(_(u'num'), default=0, help_text=u'数量')
|
|
33
|
38
|
|
|
|
|
@@ -47,6 +52,7 @@ class SaleStatisticInfo(BaseModelMixin):
|
|
47
|
52
|
|
|
48
|
53
|
|
|
49
|
54
|
class ModelSaleStatisticInfo(BaseModelMixin):
|
|
|
55
|
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
|
|
50
|
56
|
model_id = models.CharField(_(u'model_id'), max_length=32, help_text=u'型号唯一标识', db_index=True)
|
|
51
|
57
|
model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称')
|
|
52
|
58
|
ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部
|
|
|
|
@@ -70,6 +76,7 @@ class ModelSaleStatisticInfo(BaseModelMixin):
|
|
70
|
76
|
|
|
71
|
77
|
|
|
72
|
78
|
class DistributorSaleStatisticInfo(BaseModelMixin):
|
|
|
79
|
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
|
|
73
|
80
|
distributor_id = models.CharField(_(u'distributor_id'), max_length=32, help_text=u'经销商唯一标识', db_index=True)
|
|
74
|
81
|
distributor_name = models.CharField(_(u'distributor_name'), max_length=255, blank=True, null=True, help_text=u'经销商名称')
|
|
75
|
82
|
ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部
|
|
|
|
@@ -93,6 +100,104 @@ class DistributorSaleStatisticInfo(BaseModelMixin):
|
|
93
|
100
|
|
|
94
|
101
|
|
|
95
|
102
|
class ProvinceSaleStatisticInfo(BaseModelMixin):
|
|
|
103
|
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
|
|
|
104
|
+ province_code = models.CharField(_(u'province_code'), max_length=6, help_text=u'省份编码', db_index=True)
|
|
|
105
|
+ province_name = models.CharField(_(u'province_name'), max_length=3, blank=True, null=True, help_text=u'省份名称')
|
|
|
106
|
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部
|
|
|
107
|
+ num = models.IntegerField(_(u'num'), default=0, help_text=u'数量')
|
|
|
108
|
+
|
|
|
109
|
+ position = models.IntegerField(_(u'position'), default=1, help_text=u'排序')
|
|
|
110
|
+
|
|
|
111
|
+ class Meta:
|
|
|
112
|
+ verbose_name = _(u'省份销量统计')
|
|
|
113
|
+ verbose_name_plural = _(u'省份销量统计')
|
|
|
114
|
+
|
|
|
115
|
+ def __unicode__(self):
|
|
|
116
|
+ return unicode(self.pk)
|
|
|
117
|
+
|
|
|
118
|
+ @property
|
|
|
119
|
+ def data(self):
|
|
|
120
|
+ return {
|
|
|
121
|
+ 'province_code': self.province_code,
|
|
|
122
|
+ 'province_name': self.province_name,
|
|
|
123
|
+ 'ymd': self.ymd,
|
|
|
124
|
+ 'num': randnum() if settings.DEBUG_DATA_FLAG else self.num,
|
|
|
125
|
+ }
|
|
|
126
|
+
|
|
|
127
|
+
|
|
|
128
|
+# 消费者维度
|
|
|
129
|
+
|
|
|
130
|
+
|
|
|
131
|
+class ConsumeSaleStatisticInfo(BaseModelMixin):
|
|
|
132
|
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
|
|
|
133
|
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d')
|
|
|
134
|
+ num = models.IntegerField(_(u'num'), default=0, help_text=u'数量')
|
|
|
135
|
+
|
|
|
136
|
+ class Meta:
|
|
|
137
|
+ verbose_name = _(u'销量统计')
|
|
|
138
|
+ verbose_name_plural = _(u'销量统计')
|
|
|
139
|
+
|
|
|
140
|
+ def __unicode__(self):
|
|
|
141
|
+ return unicode(self.pk)
|
|
|
142
|
+
|
|
|
143
|
+ @property
|
|
|
144
|
+ def data(self):
|
|
|
145
|
+ return {
|
|
|
146
|
+ 'ymd': self.ymd,
|
|
|
147
|
+ 'num': randnum() if settings.DEBUG_DATA_FLAG else self.num,
|
|
|
148
|
+ }
|
|
|
149
|
+
|
|
|
150
|
+
|
|
|
151
|
+class ConsumeModelSaleStatisticInfo(BaseModelMixin):
|
|
|
152
|
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
|
|
|
153
|
+ model_id = models.CharField(_(u'model_id'), max_length=32, help_text=u'型号唯一标识', db_index=True)
|
|
|
154
|
+ model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称')
|
|
|
155
|
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部
|
|
|
156
|
+ num = models.IntegerField(_(u'num'), default=0, help_text=u'数量')
|
|
|
157
|
+
|
|
|
158
|
+ class Meta:
|
|
|
159
|
+ verbose_name = _(u'型号销量统计')
|
|
|
160
|
+ verbose_name_plural = _(u'型号销量统计')
|
|
|
161
|
+
|
|
|
162
|
+ def __unicode__(self):
|
|
|
163
|
+ return unicode(self.pk)
|
|
|
164
|
+
|
|
|
165
|
+ @property
|
|
|
166
|
+ def data(self):
|
|
|
167
|
+ return {
|
|
|
168
|
+ 'model_id': self.model_id,
|
|
|
169
|
+ 'model_name': self.model_name,
|
|
|
170
|
+ 'ymd': self.ymd,
|
|
|
171
|
+ 'num': randnum() if settings.DEBUG_DATA_FLAG else self.num,
|
|
|
172
|
+ }
|
|
|
173
|
+
|
|
|
174
|
+
|
|
|
175
|
+class ConsumeDistributorSaleStatisticInfo(BaseModelMixin):
|
|
|
176
|
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
|
|
|
177
|
+ distributor_id = models.CharField(_(u'distributor_id'), max_length=32, help_text=u'经销商唯一标识', db_index=True)
|
|
|
178
|
+ distributor_name = models.CharField(_(u'distributor_name'), max_length=255, blank=True, null=True, help_text=u'经销商名称')
|
|
|
179
|
+ ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部
|
|
|
180
|
+ num = models.IntegerField(_(u'num'), default=0, help_text=u'数量')
|
|
|
181
|
+
|
|
|
182
|
+ class Meta:
|
|
|
183
|
+ verbose_name = _(u'经销商销量统计')
|
|
|
184
|
+ verbose_name_plural = _(u'经销商销量统计')
|
|
|
185
|
+
|
|
|
186
|
+ def __unicode__(self):
|
|
|
187
|
+ return unicode(self.pk)
|
|
|
188
|
+
|
|
|
189
|
+ @property
|
|
|
190
|
+ def data(self):
|
|
|
191
|
+ return {
|
|
|
192
|
+ 'distributor_id': self.distributor_id,
|
|
|
193
|
+ 'distributor_name': self.distributor_name,
|
|
|
194
|
+ 'ymd': self.ymd,
|
|
|
195
|
+ 'num': randnum() if settings.DEBUG_DATA_FLAG else self.num,
|
|
|
196
|
+ }
|
|
|
197
|
+
|
|
|
198
|
+
|
|
|
199
|
+class ConsumeProvinceSaleStatisticInfo(BaseModelMixin):
|
|
|
200
|
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
|
|
96
|
201
|
province_code = models.CharField(_(u'province_code'), max_length=6, help_text=u'省份编码', db_index=True)
|
|
97
|
202
|
province_name = models.CharField(_(u'province_name'), max_length=3, blank=True, null=True, help_text=u'省份名称')
|
|
98
|
203
|
ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d'), 0 为全部
|
|
|
|
@@ -12,7 +12,56 @@ from utils.rdm_utils import randnum
|
|
12
|
12
|
|
|
13
|
13
|
|
|
14
|
14
|
@logit
|
|
15
|
|
-def tj_data(request):
|
|
|
15
|
+def tj_distributor(request):
|
|
|
16
|
+ ymd = int(tc.local_string(format='%Y%m%d'))
|
|
|
17
|
+
|
|
|
18
|
+ # 注册用户统计 & 今日注册用户
|
|
|
19
|
+ try:
|
|
|
20
|
+ register_num = RegisterStatisticInfo.objects.get(ymd=ymd).num
|
|
|
21
|
+ except RegisterStatisticInfo.DoesNotExist:
|
|
|
22
|
+ register_num = 0
|
|
|
23
|
+
|
|
|
24
|
+ # # 注册用户数趋势
|
|
|
25
|
+ # register_trends = RegisterStatisticInfo.objects.filter(status=True).order_by('-ymd')
|
|
|
26
|
+ # register_trends = [r.data for r in register_trends]
|
|
|
27
|
+
|
|
|
28
|
+ # 销量统计 & 今日销量
|
|
|
29
|
+ try:
|
|
|
30
|
+ sale_num = SaleStatisticInfo.objects.get(ymd=ymd).num
|
|
|
31
|
+ except SaleStatisticInfo.DoesNotExist:
|
|
|
32
|
+ sale_num = 0
|
|
|
33
|
+
|
|
|
34
|
+ # # 商品销量趋势
|
|
|
35
|
+ # sale_trends = SaleStatisticInfo.objects.filter(status=True).order_by('-ymd')
|
|
|
36
|
+ # sale_trends = [s.data for s in sale_trends]
|
|
|
37
|
+
|
|
|
38
|
+ # 型号销量统计 & 热销商品榜
|
|
|
39
|
+ model_sales = ModelSaleStatisticInfo.objects.filter(ymd=0, status=True).order_by('-num')
|
|
|
40
|
+ model_sales = [m.data for m in model_sales]
|
|
|
41
|
+
|
|
|
42
|
+ # 经销商销量统计 & 经销商榜
|
|
|
43
|
+ distributor_sales = DistributorSaleStatisticInfo.objects.filter(ymd=0, status=True).order_by('-num')
|
|
|
44
|
+ distributor_sales = [d.data for d in distributor_sales]
|
|
|
45
|
+
|
|
|
46
|
+ # 各地区实时销量
|
|
|
47
|
+ province_sales = ProvinceSaleStatisticInfo.objects.filter(ymd=0, status=True).order_by('position')
|
|
|
48
|
+ province_sales = [p.data for p in province_sales]
|
|
|
49
|
+
|
|
|
50
|
+ # TOADD: ROI
|
|
|
51
|
+
|
|
|
52
|
+ return response(200, 'Get TJ Data Success', u'获取统计数据成功', {
|
|
|
53
|
+ 'register_num': randnum() if settings.DEBUG_DATA_FLAG else register_num, # 注册用户统计 & 今日注册用户
|
|
|
54
|
+ # 'register_trends': register_trends, # 注册用户数趋势
|
|
|
55
|
+ 'sale_num': randnum() if settings.DEBUG_DATA_FLAG else sale_num, # 销量统计 & 今日销量
|
|
|
56
|
+ # 'sale_trends': sale_trends, # 商品销量趋势
|
|
|
57
|
+ 'model_sales': model_sales, # 型号销量统计 & 热销商品榜
|
|
|
58
|
+ 'distributor_sales': distributor_sales, # 经销商销量统计 & 经销商榜
|
|
|
59
|
+ 'province_sales': province_sales, # 各地区实时销量
|
|
|
60
|
+ })
|
|
|
61
|
+
|
|
|
62
|
+
|
|
|
63
|
+@logit
|
|
|
64
|
+def tj_consumer(request):
|
|
16
|
65
|
ymd = int(tc.local_string(format='%Y%m%d'))
|
|
17
|
66
|
|
|
18
|
67
|
# 注册用户统计 & 今日注册用户
|
|
|
|
@@ -20,14 +20,19 @@ class SaleclerkStatusCode(BaseStatusCode):
|
|
20
|
20
|
DUPLICATE_SUBMIT = StatusCodeField(500199, 'Duplicate Submit', description=u'重复提交')
|
|
21
|
21
|
|
|
22
|
22
|
|
|
|
23
|
+class ProductBrandStatusCode(BaseStatusCode):
|
|
|
24
|
+ """ 品牌相关错误码 5010xx """
|
|
|
25
|
+ BRAND_NOT_FOUND = StatusCodeField(501001, 'Brand Not Found', description=u'品牌不存在')
|
|
|
26
|
+
|
|
|
27
|
+
|
|
23
|
28
|
class ProductModelStatusCode(BaseStatusCode):
|
|
24
|
|
- """ 型号相关错误码 5010xx """
|
|
25
|
|
- MODEL_NOT_FOUND = StatusCodeField(501001, 'Model Not Found', description=u'型号不存在')
|
|
|
29
|
+ """ 型号相关错误码 5011xx """
|
|
|
30
|
+ MODEL_NOT_FOUND = StatusCodeField(501101, 'Model Not Found', description=u'型号不存在')
|
|
26
|
31
|
|
|
27
|
32
|
|
|
28
|
33
|
class ProductDistributorStatusCode(BaseStatusCode):
|
|
29
|
34
|
""" 经销商相关错误码 5011xx """
|
|
30
|
|
- DISTRIBUTOR_NOT_FOUND = StatusCodeField(501101, 'Distributor Not Found', description=u'经销商不存在')
|
|
|
35
|
+ DISTRIBUTOR_NOT_FOUND = StatusCodeField(501201, 'Distributor Not Found', description=u'经销商不存在')
|
|
31
|
36
|
|
|
32
|
37
|
|
|
33
|
38
|
class ProductStatusCode(BaseStatusCode):
|