@@ -228,4 +228,5 @@ urlpatterns += [ |
||
228 | 228 |
|
229 | 229 |
urlpatterns += [ |
230 | 230 |
url(r'^tj$', tj_views.tj_data, name='tj_data'), # 统计数据 |
231 |
+ url(r'^tj/generate$', tj_views.tj_generate, name='tj_generate'), # 统计数据生成 |
|
231 | 232 |
] |
@@ -1,6 +1,7 @@ |
||
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 | 3 |
from django.conf import settings |
4 |
+from django.db import transaction |
|
4 | 5 |
from django_logit import logit |
5 | 6 |
from django_response import response |
6 | 7 |
from TimeConvert import TimeConvert as tc |
@@ -55,3 +56,19 @@ def tj_data(request): |
||
55 | 56 |
'distributor_sales': distributor_sales, # 经销商销量统计 & 经销商榜 |
56 | 57 |
'province_sales': province_sales, # 各地区实时销量 |
57 | 58 |
}) |
59 |
+ |
|
60 |
+ |
|
61 |
+@logit |
|
62 |
+@transaction.atomic |
|
63 |
+def tj_generate(request): |
|
64 |
+ ymd = int(tc.local_string(format='%Y%m%d')) |
|
65 |
+ |
|
66 |
+ RegisterStatisticInfo.objects.select_for_update().get_or_create( |
|
67 |
+ ymd=ymd, |
|
68 |
+ ) |
|
69 |
+ |
|
70 |
+ SaleStatisticInfo.objects.select_for_update().get_or_create( |
|
71 |
+ ymd=ymd, |
|
72 |
+ ) |
|
73 |
+ |
|
74 |
+ return response() |