|
|
@@ -16,7 +16,7 @@ from TimeConvert import TimeConvert as tc
|
16
|
16
|
from account.models import UserInfo
|
17
|
17
|
from coupon.models import UserCouponInfo
|
18
|
18
|
from integral.models import SaleclerkSubmitLogInfo
|
19
|
|
-from mch.models import AdministratorInfo, ConsumeInfoSubmitLogInfo
|
|
19
|
+from mch.models import AdministratorInfo, ConsumeInfoSubmitLogInfo, ModelInfo, DistributorInfo
|
20
|
20
|
from statistic.models import ConsumeModelSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo
|
21
|
21
|
from utils.error.errno_utils import (AdministratorStatusCode, ProductBrandStatusCode, ProductCouponStatusCode,
|
22
|
22
|
ProductMachineStatusCode, UserStatusCode)
|
|
|
@@ -390,22 +390,21 @@ def statistic_distributor(request):
|
390
|
390
|
except AdministratorInfo.DoesNotExist:
|
391
|
391
|
return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND)
|
392
|
392
|
|
393
|
|
- daily_sql = 'select id, ymd, Count(*) AS num, Count(code_version=1 or NULL) AS code1 , Count(code_version=2 or NULL) AS code2, Count((code_version=1 AND has_scan=True) or NULL) AS has_code1_scan_num, Count((code_version=2 AND has_scan=True) or NULL) AS has_code2_scan_num FROM integral_saleclerksubmitloginfo where ymd >= %s AND ymd <= %s AND test_user=False AND dupload=False AND test_sn=False AND status=True %s %s GROUP BY ymd;' % (start_time, end_time, ('AND model_uni_name = %s' ,(model_name)) if model_name else '', ('AND distributor_name = %s' ,(distributor_name)) if distributor_name else '')
|
|
393
|
+ daily_sql = 'select id, Count(*) AS num, Count(code_version=1 or NULL) AS code1 , Count(code_version=2 or NULL) AS code2, Count((code_version=1 AND has_scan=True) or NULL) AS has_code1_scan_num, Count((code_version=2 AND has_scan=True) or NULL) AS has_code2_scan_num FROM integral_saleclerksubmitloginfo where ymd >= %s AND ymd <= %s AND test_user=False AND dupload=False AND test_sn=False AND status=True %s %s GROUP BY ymd;' % (start_time, end_time, ('AND model_uni_name="%s"' % (model_name)) if model_name else '', ('AND distributor_name="%s"' % (distributor_name)) if distributor_name else '')
|
394
|
394
|
daily_logs = SaleclerkSubmitLogInfo.objects.raw(daily_sql)
|
395
|
|
- print(daily_logs)
|
396
|
395
|
|
397
|
396
|
daily_logs = [{'ymd': log.ymd, 'num': log.num, 'code1': log.code1, 'code2': log.code2, 'has_code1_scan_num': log.has_code1_scan_num, 'has_code2_scan_num': log.has_code2_scan_num} for log in daily_logs]
|
398
|
397
|
|
399
|
398
|
model_logs = []
|
400
|
399
|
if model_name == '':
|
401
|
|
- model_sql = 'select id, model_uni_name, Count(*) AS num, Count(code_version=1 or NULL) AS code1 , Count(code_version=2 or NULL) AS code2, Count((code_version=1 AND has_scan=True) or NULL) AS has_code1_scan_num, Count((code_version=2 AND has_scan=True) or NULL) AS has_code2_scan_num FROM integral_saleclerksubmitloginfo where ymd >= %s AND ymd <= %s AND test_user=False AND dupload=False AND test_sn=False AND status=True %s GROUP BY model_uni_name;' % (start_time, end_time, ('AND distributor_name = %s' ,(distributor_name)) if distributor_name else '')
|
|
400
|
+ model_sql = 'select id, model_uni_name, Count(*) AS num, Count(code_version=1 or NULL) AS code1 , Count(code_version=2 or NULL) AS code2, Count((code_version=1 AND has_scan=True) or NULL) AS has_code1_scan_num, Count((code_version=2 AND has_scan=True) or NULL) AS has_code2_scan_num FROM integral_saleclerksubmitloginfo where ymd >= %s AND ymd <= %s AND test_user=False AND dupload=False AND test_sn=False AND status=True %s GROUP BY model_uni_name;' % (start_time, end_time, ('AND distributor_name="%s"' % (distributor_name)) if distributor_name else '')
|
402
|
401
|
|
403
|
402
|
model_logs = SaleclerkSubmitLogInfo.objects.raw(model_sql)
|
404
|
403
|
model_logs = [{'model_uni_name': log.model_uni_name, 'num': log.num, 'code1': log.code1, 'code2': log.code2, 'has_code1_scan_num': log.has_code1_scan_num, 'has_code2_scan_num': log.has_code2_scan_num} for log in model_logs]
|
405
|
404
|
|
406
|
405
|
distributor_logs = []
|
407
|
406
|
if distributor_name == '':
|
408
|
|
- distributor_sql = 'select id, distributor_name, Count(*) AS num, Count(code_version=1 or NULL) AS code1 , Count(code_version=2 or NULL) AS code2, Count((code_version=1 AND has_scan=True) or NULL) AS has_code1_scan_num, Count((code_version=2 AND has_scan=True) or NULL) AS has_code2_scan_num FROM integral_saleclerksubmitloginfo where ymd >= %s AND ymd <= %s AND test_user=False AND dupload=False AND test_sn=False AND status=True %s GROUP BY distributor_name;' % (start_time, end_time, ('AND model_uni_name = %s' ,(model_name)) if model_name else '')
|
|
407
|
+ distributor_sql = 'select id, distributor_name, Count(*) AS num, Count(code_version=1 or NULL) AS code1 , Count(code_version=2 or NULL) AS code2, Count((code_version=1 AND has_scan=True) or NULL) AS has_code1_scan_num, Count((code_version=2 AND has_scan=True) or NULL) AS has_code2_scan_num FROM integral_saleclerksubmitloginfo where ymd >= %s AND ymd <= %s AND test_user=False AND dupload=False AND test_sn=False AND status=True %s GROUP BY distributor_name;' % (start_time, end_time, ('AND model_uni_name="%s"' % (model_name)) if model_name else '')
|
409
|
408
|
|
410
|
409
|
distributor_logs = SaleclerkSubmitLogInfo.objects.raw(distributor_sql)
|
411
|
410
|
distributor_logs = [{'distributor_name': log.distributor_name, 'num': log.num, 'code1': log.code1, 'code2': log.code2, 'has_code1_scan_num': log.has_code1_scan_num, 'has_code2_scan_num': log.has_code2_scan_num} for log in distributor_logs]
|
|
|
@@ -774,3 +773,41 @@ def record_sale(request):
|
774
|
773
|
'count': count,
|
775
|
774
|
'left': left
|
776
|
775
|
})
|
|
776
|
+
|
|
777
|
+def model_list(request):
|
|
778
|
+ brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
|
|
779
|
+ admin_id = request.POST.get('admin_id', '')
|
|
780
|
+
|
|
781
|
+ if brand_id != settings.KODO_DEFAULT_BRAND_ID:
|
|
782
|
+ return response(ProductBrandStatusCode.BRAND_NOT_MATCH)
|
|
783
|
+
|
|
784
|
+ try:
|
|
785
|
+ administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True)
|
|
786
|
+ except AdministratorInfo.DoesNotExist:
|
|
787
|
+ return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND)
|
|
788
|
+
|
|
789
|
+ infos = list(ModelInfo.objects.filter(status=True).values_list('model_uni_name', flat=True).distinct().order_by('model_uni_name'))
|
|
790
|
+
|
|
791
|
+ return response(200, 'Get Model List Success', u'获取型号列表成功', data={
|
|
792
|
+ 'models': infos
|
|
793
|
+ })
|
|
794
|
+
|
|
795
|
+def distributor_list(request):
|
|
796
|
+ brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID)
|
|
797
|
+ admin_id = request.POST.get('admin_id', '')
|
|
798
|
+
|
|
799
|
+ if brand_id != settings.KODO_DEFAULT_BRAND_ID:
|
|
800
|
+ return response(ProductBrandStatusCode.BRAND_NOT_MATCH)
|
|
801
|
+
|
|
802
|
+ try:
|
|
803
|
+ administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True)
|
|
804
|
+ except AdministratorInfo.DoesNotExist:
|
|
805
|
+ return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND)
|
|
806
|
+
|
|
807
|
+ infos = list(DistributorInfo.objects.filter(status=True).values_list('distributor_name', flat=True).distinct().order_by('distributor_name'))
|
|
808
|
+
|
|
809
|
+ return response(200, 'Get Model List Success', u'获取型号列表成功', data={
|
|
810
|
+ 'distributors': infos
|
|
811
|
+ })
|
|
812
|
+
|
|
813
|
+
|