162
+        if len(ymd) == 8:
163
+            # 月型号销量统计
164
+            mssi, _ = ConsumeModelSaleStatisticInfo.objects.select_for_update().get_or_create(
165
+                brand_id=o.brand_id,
166
+                model_id=o.model_id,
167
+                ymd=ymd[6],
168
+            )
169
+            mssi.model_name = o.model_name
170
+            mssi.num += 1
171
+            mssi.save()
172
+            # 年型号销量统计
173
+            mssi, _ = ConsumeModelSaleStatisticInfo.objects.select_for_update().get_or_create(
174
+                brand_id=o.brand_id,
175
+                model_id=o.model_id,
176
+                ymd=ymd[4],
177
+            )
178
+            mssi.model_name = o.model_name
179
+            mssi.num += 1
180
+            mssi.save()
181
+
182
+    for o in SaleStatisticInfo.objects.all():
183
+        ymd = str(o.ymd)
184
+        if len(ymd) == 8:
185
+            # 月销量统计
186
+            ssi, _ = SaleStatisticInfo.objects.select_for_update().get_or_create(
187
+                brand_id=o.brand_id,
188
+                ymd=ymd[6],
189
+            )
190
+            ssi.num += 1
191
+            ssi.save()
192
+            # 年销量统计
193
+            ssi, _ = SaleStatisticInfo.objects.select_for_update().get_or_create(
194
+                brand_id=o.brand_id,
195
+                ymd=ymd[4],
196
+            )
197
+            ssi.num += 1
198
+            ssi.save()

+ 1 - 1
requirements_dj.txt

@@ -1,4 +1,4 @@
1
-Django==1.11.15
1
+Django==1.11.16
2 2
 django-admin==1.3.2
3 3
 django-cors-headers==2.4.0
4 4
 django-curtail-uuid==1.0.4

+ 5 - 5
statistic/views.py

@@ -205,7 +205,7 @@ def __tj_generate(ymd=None):
205 205
 
206 206
 
207 207
 def ymdtj(brand_id, ymd, lastymd):
208
-    # 周期内扫描用户人数
208
+    # [消费者维度] 周期内扫描用户人数
209 209
     try:
210 210
         scan_user_count = ConsumeSaleStatisticInfo.objects.get(brand_id=brand_id, ymd=ymd).num
211 211
     except ConsumeSaleStatisticInfo.DoesNotExist:
@@ -219,7 +219,7 @@ def ymdtj(brand_id, ymd, lastymd):
219 219
     # 与上个统计周期数据的用户人数比例
220 220
     user_count_increase_pct = '%.2f' % (scan_user_count * 100.0 / last_scan_user_count) if last_scan_user_count != 0 else 0
221 221
 
222
-    # 周期内镜头销售支数
222
+    # [经销商维度] 周期内镜头销售支数
223 223
     try:
224 224
         sell_volume_count = SaleStatisticInfo.objects.get(brand_id=brand_id, ymd=ymd).num
225 225
     except SaleStatisticInfo.DoesNotExist:
@@ -233,15 +233,15 @@ def ymdtj(brand_id, ymd, lastymd):
233 233
     # 与上个统计周期数据的销售支数比例
234 234
     volume_count_increase_pct = '%.2f' % (sell_volume_count * 100.0 / last_sell_volume_count) if last_sell_volume_count != 0 else 0
235 235
 
236
-    # 统计周期内型号扫描排行数据,请按顺序返回
236
+    # [消费者维度] 统计周期内型号扫描排行数据,请按顺序返回
237 237
     models = ConsumeModelSaleStatisticInfo.objects.filter(brand_id=brand_id, ymd=ymd, status=True).order_by('-num')[:20]
238 238
     models = [m.data for m in models]
239 239
 
240
-    # 统计周期内销售员排行数据,请按顺序返回
240
+    # [经销商维度] 统计周期内销售员排行数据,请按顺序返回
241 241
     salesmen = SaleclerkSaleStatisticInfo.objects.filter(brand_id=brand_id, ymd=ymd, status=True).order_by('-num')[:20]
242 242
     salesmen = [s.data for s in salesmen]
243 243
 
244
-    # 统计周期内省份销量排行数据,请按顺序返回
244
+    # [经销商维度] 统计周期内省份销量排行数据,请按顺序返回
245 245
     provinces = ProvinceSaleStatisticInfo.objects.filter(brand_id=brand_id, ymd=ymd, status=True)
246 246
     provinces = [p.data for p in provinces]
247 247
 

Kodo/kodo - Gogs: Go Git Service

1 コミット (0ccf5ce96b345022620dfd9c513bfbebab9e88f6)

作者 SHA1 メッセージ 日付
  Brightcells a078341431 Preauth page 7 年 前