+ ('user_id', models.CharField(blank=True, db_index=True, help_text='\u7528\u6237\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='user_id')),
+ ('log_id', shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='\u65e5\u5fd7\u552f\u4e00\u6807\u8bc6', max_length=22)),
+ ('is_search_model', models.IntegerField(db_index=True, default=0, help_text='\u641c\u7d22\u955c\u5934\u578b\u53f7', verbose_name='is_search_model')),
+ ('is_search_camera', models.IntegerField(db_index=True, default=0, help_text='\u641c\u7d22\u76f8\u673a\u578b\u53f7', verbose_name='is_search_model')),
+ ('is_search_model_camera', models.IntegerField(db_index=True, default=0, help_text='\u641c\u7d22\u76f8\u673a\u578b\u53f7\u548c\u955c\u5934\u578b\u53f7', verbose_name='is_search_model')),
+ ('is_search_camera_after_model', models.IntegerField(db_index=True, default=0, help_text='\u9009\u62e9\u955c\u5934\u540e\u641c\u7d22\u76f8\u673a\u578b\u53f7', verbose_name='is_search_camera_after_model')),
+ ],
+ options={
+ 'verbose_name': 'mchsearchmodelandcameraloginfo',
+ 'verbose_name_plural': 'mchsearchmodelandcameraloginfo',
+ },
+ ),
+ ]
@@ -0,0 +1,20 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.26 on 2020-02-27 17:08 |
|
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 |
+ ('logs', '0008_mchsearchmodelandcameraloginfo'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AddField( |
|
16 |
+ model_name='mchsearchmodelandcameraloginfo', |
|
17 |
+ name='is_selected_model', |
|
18 |
+ field=models.IntegerField(db_index=True, default=0, help_text='\u641c\u7d22\u76f8\u673a\u578b\u53f7', verbose_name='is_selected_model'), |
|
19 |
+ ), |
|
20 |
+ ] |
@@ -72,6 +72,7 @@ class MchLogInfo(BaseModelMixin): |
||
72 | 72 |
def __unicode__(self): |
73 | 73 |
return unicode(self.pk) |
74 | 74 |
|
75 |
+ |
|
75 | 76 |
class MchSearchModelAndCameraLogInfo(BaseModelMixin): |
76 | 77 |
user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True) |
77 | 78 |
|
@@ -88,4 +89,4 @@ class MchSearchModelAndCameraLogInfo(BaseModelMixin): |
||
88 | 89 |
verbose_name_plural = _(u'mchsearchmodelandcameraloginfo') |
89 | 90 |
|
90 | 91 |
def __unicode__(self): |
91 |
- return unicode(self.pk) |
|
92 |
+ return unicode(self.pk) |
@@ -0,0 +1,20 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.26 on 2020-02-23 08:32 |
|
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 |
+ ('mch', '0043_modelcamerabodyinfo'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AddField( |
|
16 |
+ model_name='modelcamerabodyinfo', |
|
17 |
+ name='camera_brand_name', |
|
18 |
+ field=models.CharField(blank=True, help_text='\u673a\u8eab\u54c1\u724c', max_length=255, null=True, verbose_name='camera_brand_name'), |
|
19 |
+ ), |
|
20 |
+ ] |
@@ -635,7 +635,7 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin): |
||
635 | 635 |
model_info = ModelInfo.objects.get(model_id=self.model_id) |
636 | 636 |
except ModelInfo.DoesNotExist: |
637 | 637 |
model_info = {} |
638 |
- |
|
638 |
+ |
|
639 | 639 |
return { |
640 | 640 |
'model_name': self.model_name, |
641 | 641 |
'serialNo': self.serialNo, |
@@ -644,6 +644,7 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin): |
||
644 | 644 |
'created_at': tc.local_string(self.created_at, format='%Y-%m-%d'), |
645 | 645 |
} |
646 | 646 |
|
647 |
+ |
|
647 | 648 |
class ActivityInfo(BaseModelMixin): |
648 | 649 |
FIXED_EXPIRED_TIME = 0 |
649 | 650 |
CHANGED_EXPIRED_TIME = 1 |
@@ -91,7 +91,7 @@ class GoodsInfo(BaseModelMixin): |
||
91 | 91 |
'able': True, |
92 | 92 |
'value': self.value, |
93 | 93 |
} |
94 |
- |
|
94 |
+ |
|
95 | 95 |
def details(self, user_id): |
96 | 96 |
detail = self.data(user_id) |
97 | 97 |
detail['desc'] = self.desc |
@@ -97,9 +97,7 @@ def clerk_sale_submit_api(request): |
||
97 | 97 |
ymd = tc.local_string(format='%Y%m%d') |
98 | 98 |
|
99 | 99 |
# 是否被消费者扫过 |
100 |
- has_scan = ConsumeInfoSubmitLogInfo.objects.filter( |
|
101 |
- model_id=model.model_id, |
|
102 |
- serialNo=serialNo).exists() |
|
100 |
+ has_scan = ConsumeInfoSubmitLogInfo.objects.filter(model_id=model.model_id, serialNo=serialNo).exists() |
|
103 | 101 |
|
104 | 102 |
# 店员提交记录 |
105 | 103 |
ssli = SaleclerkSubmitLogInfo.objects.create( |
@@ -239,7 +237,6 @@ def clerk_sale_submit_api(request): |
||
239 | 237 |
mssi.num = len(mssi.saleclerks) |
240 | 238 |
mssi.save() |
241 | 239 |
|
242 |
- |
|
243 | 240 |
# 经销商销量统计 |
244 | 241 |
dssi, _ = DistributorSaleStatisticInfo.objects.select_for_update().get_or_create( |
245 | 242 |
brand_id=brand.brand_id, |
@@ -287,15 +284,6 @@ def clerk_sale_submit_api(request): |
||
287 | 284 |
pssi.num += 1 |
288 | 285 |
pssi.save() |
289 | 286 |
|
290 |
- # pssi2, _ = ProvinceSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
291 |
- # brand_id=brand.brand_id, |
|
292 |
- # province_code=distributor.distributor_province_code, |
|
293 |
- # ymd=0, |
|
294 |
- # ) |
|
295 |
- # pssi2.province_name = distributor.distributor_province_name |
|
296 |
- # pssi2.num += 1 |
|
297 |
- # pssi2.save() |
|
298 |
- |
|
299 | 287 |
# 日销售员销量统计 |
300 | 288 |
sssi, _ = SaleclerkSaleStatisticInfo.objects.select_for_update().get_or_create( |
301 | 289 |
brand_id=brand.brand_id, |
@@ -451,9 +439,8 @@ def clerk_checkout_serialNo_api(request): |
||
451 | 439 |
except SaleclerkInfo.DoesNotExist: |
452 | 440 |
return response(SaleclerkStatusCode.CLERK_NOT_FOUND) |
453 | 441 |
|
454 |
- |
|
455 | 442 |
log = MchInfoEncryptLogInfo.objects.filter(model_pk=model_pk, sn=serialNo) |
456 |
- |
|
443 |
+ |
|
457 | 444 |
if not log: |
458 | 445 |
return response(ProductMachineStatusCode.SN_NOT_FOUND) |
459 | 446 |
|
@@ -37,5 +37,3 @@ def marketcodedownload(application_id, code_start, code_end, isv_application_id= |
||
37 | 37 |
code_index=code_index, |
38 | 38 |
code_url=code_url |
39 | 39 |
) |
40 |
- |
|
41 |
- |
@@ -4,14 +4,17 @@ from __future__ import division |
||
4 | 4 |
|
5 | 5 |
import xlrd |
6 | 6 |
from django.conf import settings |
7 |
+from django.db import transaction |
|
7 | 8 |
from pysnippets.strsnippets import strip |
8 | 9 |
from TimeConvert import TimeConvert as tc |
9 | 10 |
|
10 |
-from mch.models import BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo, ModelCameraBodyInfo |
|
11 |
+from integral.models import SaleclerkSubmitLogInfo |
|
12 |
+from mch.models import (BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelCameraBodyInfo, ModelInfo, |
|
13 |
+ SaleclerkInfo) |
|
11 | 14 |
from statistic.models import (ConsumeDistributorSaleStatisticInfo, ConsumeModelSaleStatisticInfo, |
12 | 15 |
ConsumeProvinceSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo, |
13 | 16 |
DistributorSaleStatisticInfo, ModelSaleStatisticInfo, ProvinceSaleStatisticInfo, |
14 |
- SaleStatisticInfo) |
|
17 |
+ SaleclerkSaleStatisticInfo, SaleStatisticInfo) |
|
15 | 18 |
from utils.redis.connect import r |
16 | 19 |
from utils.redis.rkeys import MINI_PROGRAM_GIS_LIST |
17 | 20 |
|
@@ -253,77 +256,246 @@ def refreshs(): |
||
253 | 256 |
except ModelInfo.DoesNotExist: |
254 | 257 |
continue |
255 | 258 |
|
256 |
- cusi, _ = ConsumeUserStatisticInfo.objects.get_or_create( |
|
257 |
- brand_id=mdl.brand_id, |
|
258 |
- ymd=ymd, |
|
259 |
- ) |
|
260 |
- cusi.users = list(set(cusi.users + [log.user_id])) |
|
261 |
- cusi.num = len(cusi.users) |
|
262 |
- cusi.save() |
|
263 |
- cusi, _ = ConsumeUserStatisticInfo.objects.get_or_create( |
|
264 |
- brand_id=mdl.brand_id, |
|
265 |
- ymd=ymd[:6], |
|
266 |
- ) |
|
267 |
- cusi.users = list(set(cusi.users + [log.user_id])) |
|
268 |
- cusi.num = len(cusi.users) |
|
269 |
- cusi.save() |
|
270 |
- cusi, _ = ConsumeUserStatisticInfo.objects.get_or_create( |
|
271 |
- brand_id=mdl.brand_id, |
|
272 |
- ymd=ymd[:4], |
|
273 |
- ) |
|
274 |
- cusi.users = list(set(cusi.users + [log.user_id])) |
|
275 |
- cusi.num = len(cusi.users) |
|
276 |
- cusi.save() |
|
277 |
- |
|
278 |
- cssi, _ = ConsumeSaleStatisticInfo.objects.get_or_create( |
|
279 |
- brand_id=mdl.brand_id, |
|
280 |
- ymd=ymd, |
|
281 |
- ) |
|
282 |
- cssi.num += 1 |
|
283 |
- cssi.save() |
|
284 |
- cssi, _ = ConsumeSaleStatisticInfo.objects.get_or_create( |
|
285 |
- brand_id=mdl.brand_id, |
|
286 |
- ymd=ymd[:6], |
|
287 |
- ) |
|
288 |
- cssi.num += 1 |
|
289 |
- cssi.save() |
|
290 |
- cssi, _ = ConsumeSaleStatisticInfo.objects.get_or_create( |
|
291 |
- brand_id=mdl.brand_id, |
|
292 |
- ymd=ymd[:4], |
|
293 |
- ) |
|
294 |
- cssi.num += 1 |
|
295 |
- cssi.save() |
|
296 |
- |
|
297 |
- # 日型号销量统计 |
|
298 |
- cmssi, _ = ConsumeModelSaleStatisticInfo.objects.get_or_create( |
|
299 |
- brand_id=mdl.brand_id, |
|
300 |
- model_name=mdl.model_uni_name, |
|
301 |
- ymd=ymd, |
|
302 |
- ) |
|
303 |
- cmssi.num += 1 |
|
304 |
- cmssi.save() |
|
305 |
- # 月型号销量统计 |
|
306 |
- cmssi, _ = ConsumeModelSaleStatisticInfo.objects.get_or_create( |
|
307 |
- brand_id=mdl.brand_id, |
|
308 |
- model_name=mdl.model_uni_name, |
|
309 |
- ymd=ymd[:6], |
|
310 |
- ) |
|
311 |
- cmssi.num += 1 |
|
312 |
- cmssi.save() |
|
313 |
- # 年型号销量统计 |
|
314 |
- cmssi, _ = ConsumeModelSaleStatisticInfo.objects.get_or_create( |
|
315 |
- brand_id=mdl.brand_id, |
|
316 |
- model_name=mdl.model_uni_name, |
|
317 |
- ymd=ymd[:4], |
|
318 |
- ) |
|
319 |
- cmssi.num += 1 |
|
320 |
- cmssi.save() |
|
321 |
- |
|
322 |
- r.rpushjson(MINI_PROGRAM_GIS_LIST, { |
|
323 |
- 'brand_id': log.brand_id, |
|
324 |
- 'user_id': log.user_id, |
|
325 |
- 'lat': log.lat, |
|
326 |
- 'lon': log.lon, |
|
327 |
- 'phone': log.phone, |
|
328 |
- 'ymd': tc.local_string(tc.to_local_datetime(log.created_at), format='%Y%m%d'), |
|
329 |
- }) |
|
259 |
+ with transaction.atomic(): |
|
260 |
+ cusi, _ = ConsumeUserStatisticInfo.objects.select_for_update().get_or_create( |
|
261 |
+ brand_id=mdl.brand_id, |
|
262 |
+ ymd=ymd, |
|
263 |
+ ) |
|
264 |
+ cusi.users = list(set(cusi.users + [log.user_id])) |
|
265 |
+ cusi.num = len(cusi.users) |
|
266 |
+ cusi.save() |
|
267 |
+ cusi, _ = ConsumeUserStatisticInfo.objects.select_for_update().get_or_create( |
|
268 |
+ brand_id=mdl.brand_id, |
|
269 |
+ ymd=ymd[:6], |
|
270 |
+ ) |
|
271 |
+ cusi.users = list(set(cusi.users + [log.user_id])) |
|
272 |
+ cusi.num = len(cusi.users) |
|
273 |
+ cusi.save() |
|
274 |
+ cusi, _ = ConsumeUserStatisticInfo.objects.select_for_update().get_or_create( |
|
275 |
+ brand_id=mdl.brand_id, |
|
276 |
+ ymd=ymd[:4], |
|
277 |
+ ) |
|
278 |
+ cusi.users = list(set(cusi.users + [log.user_id])) |
|
279 |
+ cusi.num = len(cusi.users) |
|
280 |
+ cusi.save() |
|
281 |
+ |
|
282 |
+ cssi, _ = ConsumeSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
283 |
+ brand_id=mdl.brand_id, |
|
284 |
+ ymd=ymd, |
|
285 |
+ ) |
|
286 |
+ cssi.num += 1 |
|
287 |
+ cssi.save() |
|
288 |
+ cssi, _ = ConsumeSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
289 |
+ brand_id=mdl.brand_id, |
|
290 |
+ ymd=ymd[:6], |
|
291 |
+ ) |
|
292 |
+ cssi.num += 1 |
|
293 |
+ cssi.save() |
|
294 |
+ cssi, _ = ConsumeSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
295 |
+ brand_id=mdl.brand_id, |
|
296 |
+ ymd=ymd[:4], |
|
297 |
+ ) |
|
298 |
+ cssi.num += 1 |
|
299 |
+ cssi.save() |
|
300 |
+ |
|
301 |
+ # 日型号销量统计 |
|
302 |
+ cmssi, _ = ConsumeModelSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
303 |
+ brand_id=mdl.brand_id, |
|
304 |
+ model_name=mdl.model_uni_name, |
|
305 |
+ ymd=ymd, |
|
306 |
+ ) |
|
307 |
+ cmssi.num += 1 |
|
308 |
+ cmssi.save() |
|
309 |
+ # 月型号销量统计 |
|
310 |
+ cmssi, _ = ConsumeModelSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
311 |
+ brand_id=mdl.brand_id, |
|
312 |
+ model_name=mdl.model_uni_name, |
|
313 |
+ ymd=ymd[:6], |
|
314 |
+ ) |
|
315 |
+ cmssi.num += 1 |
|
316 |
+ cmssi.save() |
|
317 |
+ # 年型号销量统计 |
|
318 |
+ cmssi, _ = ConsumeModelSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
319 |
+ brand_id=mdl.brand_id, |
|
320 |
+ model_name=mdl.model_uni_name, |
|
321 |
+ ymd=ymd[:4], |
|
322 |
+ ) |
|
323 |
+ cmssi.num += 1 |
|
324 |
+ cmssi.save() |
|
325 |
+ |
|
326 |
+ r.rpushjson(MINI_PROGRAM_GIS_LIST, { |
|
327 |
+ 'brand_id': log.brand_id, |
|
328 |
+ 'user_id': log.user_id, |
|
329 |
+ 'lat': log.lat, |
|
330 |
+ 'lon': log.lon, |
|
331 |
+ 'phone': log.phone, |
|
332 |
+ 'ymd': tc.local_string(tc.to_local_datetime(log.created_at), format='%Y%m%d'), |
|
333 |
+ }) |
|
334 |
+ |
|
335 |
+ |
|
336 |
+def refreshs2(): |
|
337 |
+ SaleStatisticInfo.objects.all().delete() |
|
338 |
+ ModelSaleStatisticInfo.objects.all().delete() |
|
339 |
+ DistributorSaleStatisticInfo.objects.all().delete() |
|
340 |
+ ProvinceSaleStatisticInfo.objects.all().delete() |
|
341 |
+ SaleclerkSaleStatisticInfo.objects.all().delete() |
|
342 |
+ |
|
343 |
+ logs = SaleclerkSubmitLogInfo.objects.filter(dupload=False, test_user=False, test_sn=False, status=True) |
|
344 |
+ |
|
345 |
+ for log in logs: |
|
346 |
+ ymd = tc.local_string(tc.to_local_datetime(log.created_at), format='%Y%m%d') |
|
347 |
+ |
|
348 |
+ try: |
|
349 |
+ brand = BrandInfo.objects.get(pk=log.brand_pk) |
|
350 |
+ except BrandInfo.DoesNotExist: |
|
351 |
+ continue |
|
352 |
+ |
|
353 |
+ try: |
|
354 |
+ model = ModelInfo.objects.get(pk=log.model_pk) |
|
355 |
+ except ModelInfo.DoesNotExist: |
|
356 |
+ continue |
|
357 |
+ |
|
358 |
+ try: |
|
359 |
+ clerk = SaleclerkInfo.objects.get(clerk_id=log.clerk_id, status=True) |
|
360 |
+ except SaleclerkInfo.DoesNotExist: |
|
361 |
+ continue |
|
362 |
+ |
|
363 |
+ try: |
|
364 |
+ distributor = DistributorInfo.objects.get(distributor_id=clerk.distributor_id) |
|
365 |
+ except DistributorInfo.DoesNotExist: |
|
366 |
+ continue |
|
367 |
+ |
|
368 |
+ with transaction.atomic(): |
|
369 |
+ # 日销量统计 |
|
370 |
+ ssi, _ = SaleStatisticInfo.objects.select_for_update().get_or_create( |
|
371 |
+ brand_id=brand.brand_id, |
|
372 |
+ ymd=ymd, |
|
373 |
+ ) |
|
374 |
+ ssi.num += 1 |
|
375 |
+ ssi.save() |
|
376 |
+ # 月销量统计 |
|
377 |
+ ssi, _ = SaleStatisticInfo.objects.select_for_update().get_or_create( |
|
378 |
+ brand_id=brand.brand_id, |
|
379 |
+ ymd=ymd[:6], |
|
380 |
+ ) |
|
381 |
+ ssi.num += 1 |
|
382 |
+ ssi.save() |
|
383 |
+ # 年销量统计 |
|
384 |
+ ssi, _ = SaleStatisticInfo.objects.select_for_update().get_or_create( |
|
385 |
+ brand_id=brand.brand_id, |
|
386 |
+ ymd=ymd[:4], |
|
387 |
+ ) |
|
388 |
+ ssi.num += 1 |
|
389 |
+ ssi.save() |
|
390 |
+ |
|
391 |
+ # 型号销量统计 |
|
392 |
+ mssi, _ = ModelSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
393 |
+ brand_id=brand.brand_id, |
|
394 |
+ model_name=model.model_uni_name, |
|
395 |
+ ymd=ymd, |
|
396 |
+ ) |
|
397 |
+ mssi.saleclerks += [clerk.clerk_id] |
|
398 |
+ mssi.num = len(mssi.saleclerks) |
|
399 |
+ mssi.save() |
|
400 |
+ |
|
401 |
+ mssi, _ = ModelSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
402 |
+ brand_id=brand.brand_id, |
|
403 |
+ model_name=model.model_uni_name, |
|
404 |
+ ymd=ymd[:6], |
|
405 |
+ ) |
|
406 |
+ mssi.saleclerks += [clerk.clerk_id] |
|
407 |
+ mssi.num = len(mssi.saleclerks) |
|
408 |
+ mssi.save() |
|
409 |
+ |
|
410 |
+ mssi, _ = ModelSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
411 |
+ brand_id=brand.brand_id, |
|
412 |
+ model_name=model.model_uni_name, |
|
413 |
+ ymd=ymd[:4], |
|
414 |
+ ) |
|
415 |
+ mssi.saleclerks += [clerk.clerk_id] |
|
416 |
+ mssi.num = len(mssi.saleclerks) |
|
417 |
+ mssi.save() |
|
418 |
+ |
|
419 |
+ # 经销商销量统计 |
|
420 |
+ dssi, _ = DistributorSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
421 |
+ brand_id=brand.brand_id, |
|
422 |
+ distributor_id=distributor.distributor_id, |
|
423 |
+ ymd=ymd, |
|
424 |
+ ) |
|
425 |
+ dssi.distributor_name = distributor.distributor_name |
|
426 |
+ dssi.num += 1 |
|
427 |
+ dssi.save() |
|
428 |
+ |
|
429 |
+ dssi2, _ = DistributorSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
430 |
+ brand_id=brand.brand_id, |
|
431 |
+ distributor_id=distributor.distributor_id, |
|
432 |
+ ymd=0, |
|
433 |
+ ) |
|
434 |
+ dssi2.distributor_name = distributor.distributor_name |
|
435 |
+ dssi2.num += 1 |
|
436 |
+ dssi2.save() |
|
437 |
+ |
|
438 |
+ # 日省份销量统计 |
|
439 |
+ pssi, _ = ProvinceSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
440 |
+ brand_id=brand.brand_id, |
|
441 |
+ province_code=distributor.distributor_province_code, |
|
442 |
+ ymd=ymd, |
|
443 |
+ ) |
|
444 |
+ pssi.province_name = distributor.distributor_province_name |
|
445 |
+ pssi.num += 1 |
|
446 |
+ pssi.save() |
|
447 |
+ # 月省份销量统计 |
|
448 |
+ pssi, _ = ProvinceSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
449 |
+ brand_id=brand.brand_id, |
|
450 |
+ province_code=distributor.distributor_province_code, |
|
451 |
+ ymd=ymd[:6], |
|
452 |
+ ) |
|
453 |
+ pssi.province_name = distributor.distributor_province_name |
|
454 |
+ pssi.num += 1 |
|
455 |
+ pssi.save() |
|
456 |
+ # 年省份销量统计 |
|
457 |
+ pssi, _ = ProvinceSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
458 |
+ brand_id=brand.brand_id, |
|
459 |
+ province_code=distributor.distributor_province_code, |
|
460 |
+ ymd=ymd[:4], |
|
461 |
+ ) |
|
462 |
+ pssi.province_name = distributor.distributor_province_name |
|
463 |
+ pssi.num += 1 |
|
464 |
+ pssi.save() |
|
465 |
+ |
|
466 |
+ # 日销售员销量统计 |
|
467 |
+ sssi, _ = SaleclerkSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
468 |
+ brand_id=brand.brand_id, |
|
469 |
+ clerk_id=clerk.clerk_id, |
|
470 |
+ ymd=ymd, |
|
471 |
+ ) |
|
472 |
+ sssi.distributor_id = distributor.distributor_id |
|
473 |
+ sssi.distributor_name = distributor.distributor_name |
|
474 |
+ sssi.distributor_short_name = distributor.distributor_short_name |
|
475 |
+ sssi.clerk_name = clerk.clerk_name |
|
476 |
+ sssi.num += 1 |
|
477 |
+ sssi.save() |
|
478 |
+ # 月销售员销量统计 |
|
479 |
+ sssi, _ = SaleclerkSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
480 |
+ brand_id=brand.brand_id, |
|
481 |
+ clerk_id=clerk.clerk_id, |
|
482 |
+ ymd=ymd[:6], |
|
483 |
+ ) |
|
484 |
+ sssi.distributor_id = distributor.distributor_id |
|
485 |
+ sssi.distributor_name = distributor.distributor_name |
|
486 |
+ sssi.distributor_short_name = distributor.distributor_short_name |
|
487 |
+ sssi.clerk_name = clerk.clerk_name |
|
488 |
+ sssi.num += 1 |
|
489 |
+ sssi.save() |
|
490 |
+ # 年销售员销量统计 |
|
491 |
+ sssi, _ = SaleclerkSaleStatisticInfo.objects.select_for_update().get_or_create( |
|
492 |
+ brand_id=brand.brand_id, |
|
493 |
+ clerk_id=clerk.clerk_id, |
|
494 |
+ ymd=ymd[:4], |
|
495 |
+ ) |
|
496 |
+ sssi.distributor_id = distributor.distributor_id |
|
497 |
+ sssi.distributor_name = distributor.distributor_name |
|
498 |
+ sssi.distributor_short_name = distributor.distributor_short_name |
|
499 |
+ sssi.clerk_name = clerk.clerk_name |
|
500 |
+ sssi.num += 1 |
|
501 |
+ sssi.save() |
@@ -3,4 +3,5 @@ from __future__ import unicode_literals |
||
3 | 3 |
|
4 | 4 |
from django.contrib import admin |
5 | 5 |
|
6 |
+ |
|
6 | 7 |
# Register your models here. |
@@ -3,4 +3,5 @@ from __future__ import unicode_literals |
||
3 | 3 |
|
4 | 4 |
from django.db import models |
5 | 5 |
|
6 |
+ |
|
6 | 7 |
# Create your models here. |
@@ -3,4 +3,5 @@ from __future__ import unicode_literals |
||
3 | 3 |
|
4 | 4 |
from django.test import TestCase |
5 | 5 |
|
6 |
+ |
|
6 | 7 |
# Create your tests here. |
@@ -0,0 +1,12 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+from django.contrib import admin |
|
4 |
+ |
|
5 |
+from staff.models import StaffDeleteClerkSaleSubmitLogInfo |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class StaffDeleteClerkSaleSubmitLogInfoAdmin(admin.ModelAdmin): |
|
9 |
+ list_display = ('username', 'code', 'status', 'created_at', 'updated_at') |
|
10 |
+ |
|
11 |
+ |
|
12 |
+admin.site.register(StaffDeleteClerkSaleSubmitLogInfo, StaffDeleteClerkSaleSubmitLogInfoAdmin) |
@@ -0,0 +1,8 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+from __future__ import unicode_literals |
|
3 |
+ |
|
4 |
+from django.apps import AppConfig |
|
5 |
+ |
|
6 |
+ |
|
7 |
+class StaffConfig(AppConfig): |
|
8 |
+ name = 'staff' |
@@ -0,0 +1,31 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.28 on 2020-03-01 13:19 |
|
3 |
+from __future__ import unicode_literals |
|
4 |
+ |
|
5 |
+from django.db import migrations, models |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class Migration(migrations.Migration): |
|
9 |
+ |
|
10 |
+ initial = True |
|
11 |
+ |
|
12 |
+ dependencies = [ |
|
13 |
+ ] |
|
14 |
+ |
|
15 |
+ operations = [ |
|
16 |
+ migrations.CreateModel( |
|
17 |
+ name='StaffDeleteClerkSaleSubmitLogInfo', |
|
18 |
+ fields=[ |
|
19 |
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|
20 |
+ ('status', models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status')), |
|
21 |
+ ('created_at', models.DateTimeField(auto_now_add=True, help_text='Create Time', verbose_name='created_at')), |
|
22 |
+ ('updated_at', models.DateTimeField(auto_now=True, help_text='Update Time', verbose_name='updated_at')), |
|
23 |
+ ('username', models.CharField(blank=True, db_index=True, help_text='\u7528\u6237\u540d', max_length=32, null=True, verbose_name='username')), |
|
24 |
+ ('code', models.CharField(blank=True, db_index=True, help_text='\u673a\u8eab\u7801', max_length=32, null=True, verbose_name='code')), |
|
25 |
+ ], |
|
26 |
+ options={ |
|
27 |
+ 'verbose_name': 'staffdeleteclerksalesubmitloginfo', |
|
28 |
+ 'verbose_name_plural': 'staffdeleteclerksalesubmitloginfo', |
|
29 |
+ }, |
|
30 |
+ ), |
|
31 |
+ ] |
@@ -0,0 +1,17 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+from django.db import models |
|
4 |
+from django.utils.translation import ugettext_lazy as _ |
|
5 |
+from django_models_ext import BaseModelMixin |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class StaffDeleteClerkSaleSubmitLogInfo(BaseModelMixin): |
|
9 |
+ username = models.CharField(_(u'username'), max_length=32, blank=True, null=True, help_text=u'用户名', db_index=True) |
|
10 |
+ code = models.CharField(_(u'code'), max_length=32, blank=True, null=True, help_text=u'机身码', db_index=True) |
|
11 |
+ |
|
12 |
+ class Meta: |
|
13 |
+ verbose_name = _(u'staffdeleteclerksalesubmitloginfo') |
|
14 |
+ verbose_name_plural = _(u'staffdeleteclerksalesubmitloginfo') |
|
15 |
+ |
|
16 |
+ def __unicode__(self): |
|
17 |
+ return unicode(self.pk) |
@@ -0,0 +1,6 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+from __future__ import unicode_literals |
|
3 |
+ |
|
4 |
+from django.test import TestCase |
|
5 |
+ |
|
6 |
+# Create your tests here. |
@@ -0,0 +1,6 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+from __future__ import unicode_literals |
|
3 |
+ |
|
4 |
+from django.shortcuts import render |
|
5 |
+ |
|
6 |
+# Create your views here. |