@@ -483,7 +483,7 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin): |
||
483 | 483 |
'subscribe': self.subscribe, |
484 | 484 |
'membercardid': self.membercardid, |
485 | 485 |
'memberusercardcode': self.memberusercardcode, |
486 |
- 'created_at': tc.local_string(self.created_at, format='%Y-%m-%d'), |
|
486 |
+ 'created_at': tc.local_string(utc_dt=self.created_at, format='%Y-%m-%d'), |
|
487 | 487 |
|
488 | 488 |
# 会员信息 |
489 | 489 |
'integral': self.integral, |
@@ -2,28 +2,28 @@ |
||
2 | 2 |
|
3 | 3 |
from __future__ import division |
4 | 4 |
|
5 |
+import json |
|
6 |
+from collections import defaultdict |
|
7 |
+from datetime import datetime |
|
8 |
+from itertools import chain, groupby |
|
9 |
+ |
|
5 | 10 |
from django.conf import settings |
6 | 11 |
from django.db import transaction |
12 |
+from django.db.models import Count, Sum |
|
7 | 13 |
from django_logit import logit |
8 | 14 |
from django_response import response |
9 | 15 |
from paginator import pagination |
10 | 16 |
from TimeConvert import TimeConvert as tc |
11 |
-from django.db.models import Sum, Count |
|
12 |
-from datetime import datetime |
|
13 | 17 |
|
14 |
-from mch.models import AdministratorInfo, ConsumeInfoSubmitLogInfo, SaleclerkInfo, ModelInfo |
|
15 |
-from statistic.models import ConsumeModelSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo, ModelSaleStatisticInfo |
|
18 |
+from account.models import UserInfo |
|
16 | 19 |
from integral.models import SaleclerkSubmitLogInfo |
17 | 20 |
from logs.models import MchInfoEncryptLogInfo |
18 |
-from account.models import UserInfo |
|
21 |
+from mch.models import AdministratorInfo, ConsumeInfoSubmitLogInfo, ModelInfo, SaleclerkInfo |
|
22 |
+from statistic.models import (ConsumeModelSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo, |
|
23 |
+ ModelSaleStatisticInfo) |
|
19 | 24 |
from utils.error.errno_utils import (AdministratorStatusCode, ProductBrandStatusCode, ProductCouponStatusCode, |
20 | 25 |
ProductMachineStatusCode, UserStatusCode) |
21 | 26 |
|
22 |
-from collections import defaultdict |
|
23 |
-import json |
|
24 |
-from itertools import groupby,chain |
|
25 |
- |
|
26 |
- |
|
27 | 27 |
|
28 | 28 |
WECHAT = settings.WECHAT |
29 | 29 |
|
@@ -349,11 +349,11 @@ def statistic_distributor(request): |
||
349 | 349 |
if i2 < len(daily_code1_logs) and daily_logs[i]['ymd'] == daily_code1_logs[i2]['ymd']: |
350 | 350 |
daily_logs[i]['code1'] = daily_code1_logs[i2]['num'] |
351 | 351 |
i2 += 1 |
352 |
- |
|
352 |
+ |
|
353 | 353 |
if i3 < len(daily_code2_logs) and daily_logs[i]['ymd'] == daily_code2_logs[i3]['ymd']: |
354 | 354 |
daily_logs[i]['code2'] = daily_code2_logs[i3]['num'] |
355 | 355 |
i3 += 1 |
356 |
- |
|
356 |
+ |
|
357 | 357 |
if i4 < len(daily_code2_hasScan_logs) and daily_logs[i]['ymd'] == daily_code2_hasScan_logs[i4]['ymd']: |
358 | 358 |
daily_logs[i]['has_code2_scan_num'] = daily_code2_hasScan_logs[i4]['num'] |
359 | 359 |
i4 += 1 |
@@ -380,15 +380,15 @@ def statistic_distributor(request): |
||
380 | 380 |
if i2 < len(model_code1_logs) and model_logs[i]['model_uni_name'] == model_code1_logs[i2]['model_uni_name']: |
381 | 381 |
model_logs[i]['code1'] = model_code1_logs[i2]['num'] |
382 | 382 |
i2 += 1 |
383 |
- |
|
383 |
+ |
|
384 | 384 |
if i3 < len(model_code2_logs) and model_logs[i]['model_uni_name'] == model_code2_logs[i3]['model_uni_name']: |
385 | 385 |
model_logs[i]['code2'] = model_code2_logs[i3]['num'] |
386 | 386 |
i3 += 1 |
387 |
- |
|
387 |
+ |
|
388 | 388 |
if i4 < len(model_code2_hasScan_logs) and model_logs[i]['model_uni_name'] == model_code2_hasScan_logs[i4]['model_uni_name']: |
389 | 389 |
model_logs[i]['has_code2_scan_num'] = model_code2_hasScan_logs[i4]['num'] |
390 | 390 |
i4 += 1 |
391 |
- |
|
391 |
+ |
|
392 | 392 |
model_logs.sort(key=lambda k: (-k['num'])) |
393 | 393 |
|
394 | 394 |
distributor_logs = list(logs.values('distributor_name').annotate(num=Count('pk')).order_by('distributor_name')) |
@@ -413,11 +413,11 @@ def statistic_distributor(request): |
||
413 | 413 |
if i2 < len(distributor_code1_logs) and distributor_logs[i]['distributor_name'] == distributor_code1_logs[i2]['distributor_name']: |
414 | 414 |
distributor_logs[i]['code1'] = distributor_code1_logs[i2]['num'] |
415 | 415 |
i2 += 1 |
416 |
- |
|
416 |
+ |
|
417 | 417 |
if i3 < len(distributor_code2_logs) and distributor_logs[i]['distributor_name'] == distributor_code2_logs[i3]['distributor_name']: |
418 | 418 |
distributor_logs[i]['code2'] = distributor_code2_logs[i3]['num'] |
419 | 419 |
i3 += 1 |
420 |
- |
|
420 |
+ |
|
421 | 421 |
if i4 < len(distributor_code2_hasScan_logs) and distributor_logs[i]['distributor_name'] == distributor_code2_hasScan_logs[i4]['distributor_name']: |
422 | 422 |
distributor_logs[i]['has_code2_scan_num'] = distributor_code2_hasScan_logs[i4]['num'] |
423 | 423 |
i4 += 1 |
@@ -430,6 +430,7 @@ def statistic_distributor(request): |
||
430 | 430 |
'distributor_logs': distributor_logs |
431 | 431 |
}) |
432 | 432 |
|
433 |
+ |
|
433 | 434 |
def dashboard(request): |
434 | 435 |
brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
435 | 436 |
admin_id = request.POST.get('admin_id', '') |
@@ -444,7 +445,7 @@ def dashboard(request): |
||
444 | 445 |
except AdministratorInfo.DoesNotExist: |
445 | 446 |
return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND) |
446 | 447 |
|
447 |
- #销售员统计 |
|
448 |
+ # 销售员统计 |
|
448 | 449 |
sale_logs = SaleclerkSubmitLogInfo.objects.filter(ymd__gte=start_time, ymd__lte=end_time, test_user=False, dupload=False, test_sn=False, status=True) |
449 | 450 |
|
450 | 451 |
sale_count = sale_logs.count() |
@@ -455,7 +456,7 @@ def dashboard(request): |
||
455 | 456 |
|
456 | 457 |
sale_distributor_logs = list(sale_logs.values('distributor_name').annotate(num=Count('pk')).order_by('-num'))[:10] |
457 | 458 |
|
458 |
- #消费者统计 |
|
459 |
+ # 消费者统计 |
|
459 | 460 |
logs = ConsumeInfoSubmitLogInfo.objects.filter(ymd__gte=start_time, ymd__lte=end_time, test_user=False, dupload=False, status=True) |
460 | 461 |
|
461 | 462 |
consumer_count = logs.count() |
@@ -477,6 +478,7 @@ def dashboard(request): |
||
477 | 478 |
'consumer_count': consumer_count, |
478 | 479 |
}) |
479 | 480 |
|
481 |
+ |
|
480 | 482 |
def statistic_consumer(request): |
481 | 483 |
brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
482 | 484 |
admin_id = request.POST.get('admin_id', '') |
@@ -490,8 +492,8 @@ def statistic_consumer(request): |
||
490 | 492 |
administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True) |
491 | 493 |
except AdministratorInfo.DoesNotExist: |
492 | 494 |
return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND) |
493 |
- |
|
494 |
- #消费者统计 |
|
495 |
+ |
|
496 |
+ # 消费者统计 |
|
495 | 497 |
logs = ConsumeInfoSubmitLogInfo.objects.filter(ymd__gte=start_time, ymd__lte=end_time, test_user=False, dupload=False, status=True) |
496 | 498 |
|
497 | 499 |
daily_logs = list(logs.values('ymd').annotate(num=Count('pk')).order_by('ymd')) |
@@ -506,7 +508,7 @@ def statistic_consumer(request): |
||
506 | 508 |
if j < len(daily_code1_logs) and daily_logs[i]['ymd'] == daily_code1_logs[j]['ymd']: |
507 | 509 |
daily_logs[i]['code1'] = daily_code1_logs[j]['num'] |
508 | 510 |
j += 1 |
509 |
- |
|
511 |
+ |
|
510 | 512 |
if k < len(daily_code2_logs) and daily_logs[i]['ymd'] == daily_code2_logs[k]['ymd']: |
511 | 513 |
daily_logs[i]['code2'] = daily_code2_logs[k]['num'] |
512 | 514 |
k += 1 |
@@ -523,11 +525,11 @@ def statistic_consumer(request): |
||
523 | 525 |
if j < len(model_code1_logs) and model_logs[i]['model_uni_name'] == model_code1_logs[j]['model_uni_name']: |
524 | 526 |
model_logs[i]['code1'] = model_code1_logs[j]['num'] |
525 | 527 |
j += 1 |
526 |
- |
|
528 |
+ |
|
527 | 529 |
if k < len(model_code2_logs) and model_logs[i]['model_uni_name'] == model_code2_logs[k]['model_uni_name']: |
528 | 530 |
model_logs[i]['code2'] = model_code2_logs[k]['num'] |
529 | 531 |
k += 1 |
530 |
- |
|
532 |
+ |
|
531 | 533 |
model_logs.sort(key=lambda k: (-k['num'])) |
532 | 534 |
|
533 | 535 |
province_logs = list(logs.values('province').annotate(num=Count('pk')).order_by('province')) |
@@ -542,15 +544,15 @@ def statistic_consumer(request): |
||
542 | 544 |
if j < len(province_code1_logs) and province_logs[i]['province'] == province_code1_logs[j]['province']: |
543 | 545 |
province_logs[i]['code1'] = province_code1_logs[j]['num'] |
544 | 546 |
j += 1 |
545 |
- |
|
547 |
+ |
|
546 | 548 |
if k < len(province_code2_logs) and province_logs[i]['province'] == province_code2_logs[k]['province']: |
547 | 549 |
province_logs[i]['code2'] = province_code2_logs[k]['num'] |
548 | 550 |
k += 1 |
549 |
- |
|
551 |
+ |
|
550 | 552 |
province_logs.sort(key=lambda k: (-k['num'])) |
551 | 553 |
|
552 | 554 |
return response(200, 'Get Consumer Statistic Success', u'获取消费者统计成功', data={ |
553 | 555 |
'daily_logs': daily_logs, |
554 | 556 |
'model_logs': model_logs, |
555 | 557 |
'province_logs': province_logs, |
556 |
- }) |
|
558 |
+ }) |
@@ -145,7 +145,7 @@ def decrypt(request, v='v2'): |
||
145 | 145 |
mdli.decrypt_count += 1 |
146 | 146 |
mdli.save() |
147 | 147 |
|
148 |
- #弃用老版本的劵形式,和会员系统统一 |
|
148 |
+ # 弃用老版本的劵形式,和会员系统统一 |
|
149 | 149 |
if v == 'v1': |
150 | 150 |
has_unexpired_activity = False |
151 | 151 |
coupon_infos = {} |
@@ -2,6 +2,8 @@ |
||
2 | 2 |
|
3 | 3 |
from __future__ import division |
4 | 4 |
|
5 |
+import json |
|
6 |
+ |
|
5 | 7 |
from django.conf import settings |
6 | 8 |
from django.contrib.auth.hashers import check_password |
7 | 9 |
from django.db import transaction |
@@ -10,19 +12,18 @@ from django_response import response |
||
10 | 12 |
from pywe_miniapp import get_phone_number |
11 | 13 |
from pywe_storage import RedisStorage |
12 | 14 |
from TimeConvert import TimeConvert as tc |
13 |
-import json |
|
14 | 15 |
|
15 |
-from logs.models import MchInfoEncryptLogInfo |
|
16 | 16 |
from account.models import UserInfo |
17 |
+from coupon.models import CouponInfo, UserCouponInfo |
|
17 | 18 |
from integral.models import SaleclerkSubmitLogInfo |
19 |
+from logs.models import MchInfoEncryptLogInfo |
|
18 | 20 |
from mch.models import (ActivityInfo, AdministratorInfo, BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, |
19 | 21 |
LatestAppInfo, LatestAppScreenInfo, ModelInfo, OperatorInfo) |
20 |
-from coupon.models import CouponInfo, UserCouponInfo |
|
21 | 22 |
from statistic.models import ConsumeModelSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo |
22 | 23 |
from utils.error.errno_utils import (AdministratorStatusCode, OperatorStatusCode, ProductBrandStatusCode, |
23 | 24 |
ProductModelStatusCode, UserStatusCode) |
24 | 25 |
from utils.redis.connect import r |
25 |
-from utils.redis.rkeys import MEMBER_SEND_COUPON_LIST, MINI_PROGRAM_GIS_LIST, MEMBER_UPGRADE_INFO |
|
26 |
+from utils.redis.rkeys import MEMBER_SEND_COUPON_LIST, MEMBER_UPGRADE_INFO, MINI_PROGRAM_GIS_LIST |
|
26 | 27 |
|
27 | 28 |
|
28 | 29 |
WECHAT = settings.WECHAT |
@@ -264,7 +265,7 @@ def consumer_info_api(request): |
||
264 | 265 |
|
265 | 266 |
if encrypt_logs: |
266 | 267 |
code_version = encrypt_logs[0].version |
267 |
- |
|
268 |
+ |
|
268 | 269 |
user.code_version = code_version |
269 | 270 |
user.save() |
270 | 271 |
|
@@ -313,7 +314,7 @@ def consumer_info_api(request): |
||
313 | 314 |
) |
314 | 315 |
except: |
315 | 316 |
continue |
316 |
- |
|
317 |
+ |
|
317 | 318 |
# 更新销售员提交的表 |
318 | 319 |
logs = SaleclerkSubmitLogInfo.objects.filter(code=serialNo, model_pk=model.pk) |
319 | 320 |
for log in logs: |
@@ -14,8 +14,8 @@ from account.models import UserInfo |
||
14 | 14 |
from coupon.models import UserCouponInfo |
15 | 15 |
from member.models import (GoodsInfo, GoodsOrderInfo, MemberActivityInfo, MemberActivitySigninInfo, |
16 | 16 |
MemberActivitySignupInfo, RightInfo) |
17 |
-from utils.error.errno_utils import (MemberActivityStatusCode, MemberCouponStatusCode, MemberGoodStatusCode, MemberRightStatusCode, |
|
18 |
- UserStatusCode) |
|
17 |
+from utils.error.errno_utils import (MemberActivityStatusCode, MemberCouponStatusCode, MemberGoodStatusCode, |
|
18 |
+ MemberRightStatusCode, UserStatusCode) |
|
19 | 19 |
from utils.redis.connect import r |
20 | 20 |
from utils.redis.rkeys import MEMBER_SEND_COUPON_LIST, MEMBER_UPGRADE_INFO |
21 | 21 |
from utils.redis.rshot import get_member_shot_data |
@@ -10,7 +10,7 @@ from django_response import response |
||
10 | 10 |
from paginator import pagination |
11 | 11 |
|
12 | 12 |
from account.models import UserInfo |
13 |
-from mch.models import AdministratorInfo, ModelInfo, ModelCameraBodyInfo |
|
13 |
+from mch.models import AdministratorInfo, ModelCameraBodyInfo, ModelInfo |
|
14 | 14 |
from utils.error.errno_utils import AdministratorStatusCode, ProductModelStatusCode, UserStatusCode |
15 | 15 |
|
16 | 16 |
|
@@ -159,6 +159,7 @@ def model_list(request): |
||
159 | 159 |
'left': left, |
160 | 160 |
}) |
161 | 161 |
|
162 |
+ |
|
162 | 163 |
@logit |
163 | 164 |
def model_name_list(request): |
164 | 165 |
brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
@@ -175,7 +176,7 @@ def model_name_list(request): |
||
175 | 176 |
models = list(models) |
176 | 177 |
|
177 | 178 |
return response(200, 'Get Model Name List Success', u'获取型号列表成功', { |
178 |
- 'models': sorted(set(models),key=models.index) |
|
179 |
+ 'models': sorted(set(models), key=models.index) |
|
179 | 180 |
}) |
180 | 181 |
|
181 | 182 |
|
@@ -5,8 +5,8 @@ from django_file_upload import views as file_views |
||
5 | 5 |
|
6 | 6 |
from account import tourguide_views |
7 | 7 |
from account import views as account_views |
8 |
-from api import (admin_views, clerk_views, distributor_views, encrypt_views, mch_views, member_views, model_views, |
|
9 |
- operator_views, refresh_views, sr_views, staff_views, log_views) |
|
8 |
+from api import (admin_views, clerk_views, distributor_views, encrypt_views, log_views, mch_views, member_views, |
|
9 |
+ model_views, operator_views, refresh_views, sr_views, staff_views) |
|
10 | 10 |
from box import views as box_views |
11 | 11 |
from geo import views as geo_views |
12 | 12 |
from group import (groupuser_views, lensman_views, tourguidegroup_views, tourguidegroupadmin_views, |
@@ -230,8 +230,8 @@ urlpatterns += [ |
||
230 | 230 |
url(r'^clerk/integral/list$', sale_views.clerk_integral_list_api, name='clerk_integral_list_api'), # 店员销售积分列表 |
231 | 231 |
url(r'^clerk/model/list$', sale_views.clerk_model_list_api, name='clerk_model_list_api'), |
232 | 232 |
url(r'^clerk/checkout/serialNo$', sale_views.clerk_checkout_serialNo_api, name='clerk_checkout_serialNo_api'), # 校验序列号 |
233 |
- url(r'^clerk/query/coupon$', sale_views.clerk_query_coupon, name='clerk_query_coupon'), |
|
234 |
- url(r'^clerk/writeoff/coupon$', sale_views.clerk_writeoff_coupon, name='clerk_writeoff_coupon'), |
|
233 |
+ url(r'^clerk/query/coupon$', sale_views.clerk_query_coupon, name='clerk_query_coupon'), |
|
234 |
+ url(r'^clerk/writeoff/coupon$', sale_views.clerk_writeoff_coupon, name='clerk_writeoff_coupon'), |
|
235 | 235 |
] |
236 | 236 |
|
237 | 237 |
urlpatterns += [ |
@@ -9,9 +9,9 @@ from django.db import transaction |
||
9 | 9 |
from django_models_ext import ProvinceModelMixin, ProvinceShortModelMixin |
10 | 10 |
from django_six import CompatibilityBaseCommand, close_old_connections |
11 | 11 |
|
12 |
-from statistic.models import ConsumeProvinceSaleStatisticInfo |
|
13 | 12 |
from account.models import UserInfo |
14 | 13 |
from mch.models import ConsumeInfoSubmitLogInfo |
14 |
+from statistic.models import ConsumeProvinceSaleStatisticInfo |
|
15 | 15 |
from utils.redis.connect import r |
16 | 16 |
from utils.redis.rkeys import MINI_PROGRAM_GIS_LIST |
17 | 17 |
|
@@ -89,7 +89,6 @@ class Command(CompatibilityBaseCommand): |
||
89 | 89 |
log.phone = userinfo.phone |
90 | 90 |
log.save() |
91 | 91 |
|
92 |
- |
|
93 | 92 |
try: |
94 | 93 |
phoneinfo = requests.get(settings.PHONE_2_ADMINISTRATIVE_DIVISION.format(phone)) |
95 | 94 |
except Exception as e: |
@@ -100,7 +99,7 @@ class Command(CompatibilityBaseCommand): |
||
100 | 99 |
except Exception as e: |
101 | 100 |
logger.info(e.message) |
102 | 101 |
continue |
103 |
- |
|
102 |
+ |
|
104 | 103 |
logs = ConsumeInfoSubmitLogInfo.objects.filter(user_id=userinfo.user_id) |
105 | 104 |
for log in logs: |
106 | 105 |
log.province = log.province if log.lat and log.lon else province_name |
@@ -8,11 +8,11 @@ from django_redis_connector import connector |
||
8 | 8 |
from django_six import CompatibilityBaseCommand, close_old_connections |
9 | 9 |
from django_we.models import SubscribeUserInfo |
10 | 10 |
from pywe_storage import RedisStorage |
11 |
-from pywe_user import get_user_info |
|
12 | 11 |
|
13 | 12 |
from account.models import UserInfo |
14 | 13 |
from mch.models import BrandInfo |
15 | 14 |
from pre.custom_message import sendcustomwxamessage |
15 |
+from pywe_user import get_user_info |
|
16 | 16 |
from utils.redis.rkeys import SUBSCRIBE_USERINFO_LIST |
17 | 17 |
|
18 | 18 |
|
@@ -51,7 +51,6 @@ class CouponInfo(BaseModelMixin): |
||
51 | 51 |
def coupon_image_url(self): |
52 | 52 |
return upload_file_url(self.coupon_image) |
53 | 53 |
|
54 |
- |
|
55 | 54 |
@property |
56 | 55 |
def final_expire_at(self): |
57 | 56 |
if self.coupon_expire_type == CouponInfo.FIXED_EXPIRED_TIME: |
@@ -131,8 +130,8 @@ class UserCouponInfo(BaseModelMixin): |
||
131 | 130 |
'coupon_value': self.coupon_value, |
132 | 131 |
'coupon_image_url': self.coupon_image_url, |
133 | 132 |
'is_coupon_admin_writeoff': self.is_coupon_admin_writeoff, |
134 |
- 'active_at': tc.local_string(self.active_at, format='%Y%m%d'), |
|
135 |
- 'expire_at': tc.local_string(self.expire_at, format='%Y-%m-%d'), |
|
133 |
+ 'active_at': tc.local_string(utc_dt=self.active_at, format='%Y%m%d'), |
|
134 |
+ 'expire_at': tc.local_string(utc_dt=self.expire_at, format='%Y-%m-%d'), |
|
136 | 135 |
'coupon_valid_period': self.coupon_valid_period, |
137 | 136 |
'coupon_limit_model_ids': self.coupon_limit_model_ids, |
138 | 137 |
'has_actived': self.has_actived, |
@@ -1,6 +1,5 @@ |
||
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
-from daterange_filter.filter import DateRangeFilter |
|
4 | 3 |
from django.contrib import admin |
5 | 4 |
from django_admin import AdvancedExportExcelModelAdmin, ReadOnlyModelAdmin |
6 | 5 |
|
@@ -21,6 +20,5 @@ class SaleclerkSubmitLogInfoAdmin(AdvancedExportExcelModelAdmin, ReadOnlyModelAd |
||
21 | 20 |
search_fields = ('code', 'trackingNo', 'distributor_name', 'clerk_name', 'model_name', 'model_uni_name') |
22 | 21 |
|
23 | 22 |
|
24 |
- |
|
25 | 23 |
admin.site.register(SaleclerkIntegralIncomeExpensesInfo, SaleclerkIntegralIncomeExpensesInfoAdmin) |
26 | 24 |
admin.site.register(SaleclerkSubmitLogInfo, SaleclerkSubmitLogInfoAdmin) |
@@ -86,7 +86,6 @@ MIDDLEWARE = ( |
||
86 | 86 |
'django.middleware.common.CommonMiddleware', |
87 | 87 |
# 'django.middleware.csrf.CsrfViewMiddleware', |
88 | 88 |
'django.contrib.auth.middleware.AuthenticationMiddleware', |
89 |
- 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
|
90 | 89 |
'django.contrib.messages.middleware.MessageMiddleware', |
91 | 90 |
'django.middleware.clickjacking.XFrameOptionsMiddleware', |
92 | 91 |
'django.middleware.security.SecurityMiddleware', |
@@ -18,8 +18,8 @@ class MchInfoEncryptLogInfo(BaseModelMixin): |
||
18 | 18 |
|
19 | 19 |
sn = models.CharField(_(u'sn'), max_length=32, blank=True, null=True, help_text=u'序列号', db_index=True) |
20 | 20 |
|
21 |
- #二维码版本 |
|
22 |
- version=models.IntegerField(_(u'version'), default=2, help_text=u'二维码版本', db_index=True) |
|
21 |
+ # 二维码版本 |
|
22 |
+ version = models.IntegerField(_(u'version'), default=2, help_text=u'二维码版本', db_index=True) |
|
23 | 23 |
|
24 | 24 |
# 一物一码 |
25 | 25 |
application_id = models.IntegerField(_(u'application_id'), default=0, help_text=u'申请单号', db_index=True) |
@@ -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. |
@@ -3,4 +3,5 @@ from __future__ import unicode_literals |
||
3 | 3 |
|
4 | 4 |
from django.shortcuts import render |
5 | 5 |
|
6 |
+ |
|
6 | 7 |
# Create your views here. |
@@ -8,8 +8,9 @@ from django_admin import AdvancedActionsModelAdmin, AdvancedExportExcelModelAdmi |
||
8 | 8 |
from django_models_ext import ProvinceShortModelMixin |
9 | 9 |
from pysnippets.strsnippets import strip |
10 | 10 |
|
11 |
-from mch.models import (ActivityInfo, AdministratorInfo, BrandInfo, CameraModelInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, |
|
12 |
- LatestAppInfo, LatestAppScreenInfo, ModelInfo, ModelCameraBodyInfo, OperatorInfo, SaleclerkInfo) |
|
11 |
+from mch.models import (ActivityInfo, AdministratorInfo, BrandInfo, CameraModelInfo, ConsumeInfoSubmitLogInfo, |
|
12 |
+ DistributorInfo, LatestAppInfo, LatestAppScreenInfo, ModelCameraBodyInfo, ModelInfo, |
|
13 |
+ OperatorInfo, SaleclerkInfo) |
|
13 | 14 |
from utils.redis.rshot import update_member_shot_data |
14 | 15 |
|
15 | 16 |
|
@@ -337,7 +337,7 @@ class ModelCameraBodyInfo(BaseModelMixin): |
||
337 | 337 |
def final_camera_market_time(self): |
338 | 338 |
if not self.camera_market_time: |
339 | 339 |
return '' |
340 |
- return tc.local_string(self.camera_market_time, format='%Y-%m-%d') |
|
340 |
+ return tc.local_string(utc_dt=self.camera_market_time, format='%Y-%m-%d') |
|
341 | 341 |
|
342 | 342 |
@property |
343 | 343 |
def data(self): |
@@ -693,7 +693,7 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin): |
||
693 | 693 |
'serialNo': self.serialNo, |
694 | 694 |
'integral': model_info.shot_member_integral, |
695 | 695 |
'dupload': self.dupload, |
696 |
- 'created_at': tc.local_string(self.created_at, format='%Y-%m-%d'), |
|
696 |
+ 'created_at': tc.local_string(utc_dt=self.created_at, format='%Y-%m-%d'), |
|
697 | 697 |
} |
698 | 698 |
|
699 | 699 |
|
@@ -737,10 +737,7 @@ class ActivityInfo(BaseModelMixin): |
||
737 | 737 |
final_expire_at = self.final_expire_at(created_at=created_at) |
738 | 738 |
if not final_expire_at: |
739 | 739 |
return '' |
740 |
- y = tc.local_string(final_expire_at, format='%Y') |
|
741 |
- m = tc.local_string(final_expire_at, format='%m') |
|
742 |
- d = tc.local_string(final_expire_at, format='%d') |
|
743 |
- return u'{}年{}月{}日'.format(y, m, d) |
|
740 |
+ return tc.local_string(utc_dt=final_expire_at, format=u'%Y年%m月%d日', isuc=True) |
|
744 | 741 |
|
745 | 742 |
def has_unexpired_activity(self, model_name): |
746 | 743 |
return ((self.model_uni_names and model_name in self.model_uni_names) or not self.model_uni_names) and (self.start_at <= tc.utc_datetime() < self.end_at) |
@@ -751,7 +748,6 @@ class ActivityInfo(BaseModelMixin): |
||
751 | 748 |
'coupon_value': self.coupon_value, |
752 | 749 |
'coupon_has_expired': tc.utc_datetime() >= self.final_expire_at(created_at=created_at), |
753 | 750 |
} |
754 |
- |
|
755 | 751 |
|
756 | 752 |
def coupon_info2(self, created_at=None): |
757 | 753 |
return self.coupon_info(created_at=created_at), |
@@ -759,17 +755,17 @@ class ActivityInfo(BaseModelMixin): |
||
759 | 755 |
@property |
760 | 756 |
def coupon_info3(self): |
761 | 757 |
try: |
762 |
- coupon_info = CouponInfo.objects.get(coupon_id=self.coupon_id) |
|
763 |
- return { |
|
764 |
- 'coupon_image': coupon_info.coupon_image_url, |
|
765 |
- 'coupon_expire_at': coupon_info.coupon_expire_at, |
|
766 |
- 'coupon_value': coupon_info.coupon_value, |
|
767 |
- 'coupon_title': coupon_info.coupon_title, |
|
768 |
- 'coupon_valid_period': coupon_info.coupon_valid_period, |
|
769 |
- 'coupon_id': coupon_info.coupon_id, |
|
770 |
- 'activity_id': self.activity_id, |
|
771 |
- 'activity_name': self.activity_name, |
|
772 |
- } |
|
773 |
- except: |
|
774 |
- return {} |
|
775 |
- |
|
758 |
+ coupon = CouponInfo.objects.get(coupon_id=self.coupon_id) |
|
759 |
+ except CouponInfo.DoesNotExist: |
|
760 |
+ coupon = None |
|
761 |
+ |
|
762 |
+ return { |
|
763 |
+ 'coupon_image': coupon.coupon_image_url, |
|
764 |
+ 'coupon_expire_at': coupon.coupon_expire_at, |
|
765 |
+ 'coupon_value': coupon.coupon_value, |
|
766 |
+ 'coupon_title': coupon.coupon_title, |
|
767 |
+ 'coupon_valid_period': coupon.coupon_valid_period, |
|
768 |
+ 'coupon_id': coupon.coupon_id, |
|
769 |
+ 'activity_id': self.activity_id, |
|
770 |
+ 'activity_name': self.activity_name, |
|
771 |
+ } if coupon else {} |
@@ -330,7 +330,7 @@ class MemberActivityInfo(BaseModelMixin): |
||
330 | 330 |
'activity_id': self.activity_id, |
331 | 331 |
'title': self.title, |
332 | 332 |
'subtitle': self.subtitle, |
333 |
- 'date': tc.local_string(self.date, format='%Y-%m-%d'), |
|
333 |
+ 'date': tc.local_string(utc_dt=self.date, format='%Y-%m-%d'), |
|
334 | 334 |
'city': self.city, |
335 | 335 |
'location': self.location, |
336 | 336 |
'lat': self.lat, |
@@ -350,7 +350,7 @@ class MemberActivityInfo(BaseModelMixin): |
||
350 | 350 |
'activity_id': self.activity_id, |
351 | 351 |
'title': self.title, |
352 | 352 |
'subtitle': self.subtitle, |
353 |
- 'date': tc.local_string(self.date, format='%Y-%m-%d'), |
|
353 |
+ 'date': tc.local_string(utc_dt=self.date, format='%Y-%m-%d'), |
|
354 | 354 |
'city': self.city, |
355 | 355 |
'location': self.location, |
356 | 356 |
'lat': self.lat, |
@@ -2,6 +2,10 @@ |
||
2 | 2 |
|
3 | 3 |
from __future__ import division |
4 | 4 |
|
5 |
+import os |
|
6 |
+import string |
|
7 |
+import sys |
|
8 |
+ |
|
5 | 9 |
from django.conf import settings |
6 | 10 |
from django.db import transaction |
7 | 11 |
from django_logit import logit |
@@ -10,16 +14,14 @@ from paginator import pagination |
||
10 | 14 |
from TimeConvert import TimeConvert as tc |
11 | 15 |
|
12 | 16 |
from account.models import UserInfo |
17 |
+from coupon.models import UserCouponInfo |
|
13 | 18 |
from integral.models import SaleclerkIntegralIncomeExpensesInfo, SaleclerkSubmitLogInfo |
14 | 19 |
from logs.models import MchInfoEncryptLogInfo |
15 |
-from coupon.models import UserCouponInfo |
|
16 | 20 |
from mch.models import BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo, SaleclerkInfo |
17 | 21 |
from statistic.models import (DistributorSaleStatisticInfo, ModelSaleStatisticInfo, ProvinceSaleStatisticInfo, |
18 | 22 |
SaleclerkSaleStatisticInfo, SaleStatisticInfo) |
19 |
-from utils.error.errno_utils import (ProductBrandStatusCode, ProductDistributorStatusCode, ProductMachineStatusCode, |
|
20 |
- ProductModelStatusCode, SaleclerkStatusCode, CouponStatusCode) |
|
21 |
-import os,sys,string |
|
22 |
- |
|
23 |
+from utils.error.errno_utils import (CouponStatusCode, ProductBrandStatusCode, ProductDistributorStatusCode, |
|
24 |
+ ProductMachineStatusCode, ProductModelStatusCode, SaleclerkStatusCode) |
|
23 | 25 |
|
24 | 26 |
|
25 | 27 |
@logit |
@@ -99,7 +101,7 @@ def clerk_sale_submit_api(request): |
||
99 | 101 |
# 是否被消费者扫过 |
100 | 102 |
has_scan = ConsumeInfoSubmitLogInfo.objects.filter(model_id=model.model_id, serialNo=serialNo).exists() |
101 | 103 |
|
102 |
- #是否是新二维码,即统览码2 |
|
104 |
+ # 是否是新二维码,即统览码2 |
|
103 | 105 |
if not code_version: |
104 | 106 |
code_version = 1 |
105 | 107 |
code = filter(lambda ch: ch in '0123456789', serialNo) |
@@ -458,6 +460,7 @@ def clerk_query_coupon(request): |
||
458 | 460 |
'user_coupon': user_coupon.data |
459 | 461 |
}) |
460 | 462 |
|
463 |
+ |
|
461 | 464 |
@logit |
462 | 465 |
def clerk_writeoff_coupon(request): |
463 | 466 |
brandID = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_PK) |
@@ -490,7 +493,7 @@ def clerk_writeoff_coupon(request): |
||
490 | 493 |
try: |
491 | 494 |
user_coupon = UserCouponInfo.objects.get(user_coupon_id=user_coupon_id) |
492 | 495 |
if user_coupon.has_used: |
493 |
- return response(CouponStatusCode.COUPON_HAS_USED) |
|
496 |
+ return response(CouponStatusCode.COUPON_HAS_USED) |
|
494 | 497 |
elif user_coupon.is_coupon_admin_writeoff: |
495 | 498 |
return response(CouponStatusCode.COUPON_PERMISSION_DENIED) |
496 | 499 |
elif not user_coupon.has_expired: |
@@ -502,12 +505,13 @@ def clerk_writeoff_coupon(request): |
||
502 | 505 |
user_coupon.used_at = tc.utc_datetime() |
503 | 506 |
user_coupon.save() |
504 | 507 |
else: |
505 |
- return response(CouponStatusCode.COUPON_EXPIRED) |
|
508 |
+ return response(CouponStatusCode.COUPON_EXPIRED) |
|
506 | 509 |
except UserCouponInfo.DoesNotExist: |
507 | 510 |
return response(CouponStatusCode.COUPON_NOT_FOUND) |
508 | 511 |
|
509 | 512 |
return response(200, 'Write Off Coupon Success', u'劵核销成功') |
510 | 513 |
|
514 |
+ |
|
511 | 515 |
@logit |
512 | 516 |
def clerk_checkout_serialNo_api(request): |
513 | 517 |
brandID = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_PK) |
@@ -128,7 +128,7 @@ def pre_new_models(fpath='./pre/static/models_20180816.xls'): |
||
128 | 128 |
nrows = sheet.nrows |
129 | 129 |
for idx in range(1, nrows): |
130 | 130 |
rvals = sheet.row_values(idx) |
131 |
- print rvals |
|
131 |
+ print(rvals) |
|
132 | 132 |
|
133 | 133 |
jancode = strip(rvals[0]) |
134 | 134 |
if not jancode: |
@@ -159,18 +159,18 @@ def pre_adaptive_cameras(fpath=u'./pre/static/腾龙镜头适用机型V1.xlsx'): |
||
159 | 159 |
for sheet in sheets: |
160 | 160 |
model_name = sheet.name |
161 | 161 |
model_full_name = sheet.row_values(2)[0] |
162 |
- print model_name, model_full_name |
|
162 |
+ print(model_name, model_full_name) |
|
163 | 163 |
nrows = sheet.nrows |
164 | 164 |
for idx in range(4, nrows): |
165 | 165 |
rvals = sheet.row_values(idx) |
166 |
- print rvals |
|
166 |
+ print(rvals) |
|
167 | 167 |
for val in rvals: |
168 | 168 |
val = strip(val) |
169 | 169 |
if not val: |
170 | 170 |
continue |
171 | 171 |
if u'卡口' in val: |
172 | 172 |
continue |
173 |
- print val |
|
173 |
+ print(val) |
|
174 | 174 |
ModelCameraBodyInfo.objects.get_or_create( |
175 | 175 |
brand_id=settings.KODO_DEFAULT_BRAND_ID, |
176 | 176 |
brand_name=settings.KODO_DEFAULT_BRAND_NAME, |
@@ -249,7 +249,7 @@ def refreshs(): |
||
249 | 249 |
logs = ConsumeInfoSubmitLogInfo.objects.filter(verifyResult=1, dupload=False, test_user=False) |
250 | 250 |
|
251 | 251 |
for log in logs: |
252 |
- ymd = tc.local_string(tc.to_local_datetime(log.created_at), format='%Y%m%d') |
|
252 |
+ ymd = tc.local_string(utc_dt=log.created_at, format='%Y%m%d') |
|
253 | 253 |
|
254 | 254 |
try: |
255 | 255 |
mdl = ModelInfo.objects.get(model_id=log.model_id) |
@@ -329,7 +329,7 @@ def refreshs(): |
||
329 | 329 |
'lat': log.lat, |
330 | 330 |
'lon': log.lon, |
331 | 331 |
'phone': log.phone, |
332 |
- 'ymd': tc.local_string(tc.to_local_datetime(log.created_at), format='%Y%m%d'), |
|
332 |
+ 'ymd': tc.local_string(utc_dt=log.created_at, format='%Y%m%d'), |
|
333 | 333 |
'model_id': log.model_id, |
334 | 334 |
'serialNo': log.serialNo |
335 | 335 |
}) |
@@ -345,7 +345,7 @@ def refreshs2(): |
||
345 | 345 |
logs = SaleclerkSubmitLogInfo.objects.filter(dupload=False, test_user=False, test_sn=False, status=True) |
346 | 346 |
|
347 | 347 |
for log in logs: |
348 |
- ymd = tc.local_string(tc.to_local_datetime(log.created_at), format='%Y%m%d') |
|
348 |
+ ymd = tc.local_string(utc_dt=log.created_at, format='%Y%m%d') |
|
349 | 349 |
|
350 | 350 |
try: |
351 | 351 |
brand = BrandInfo.objects.get(pk=log.brand_pk) |
@@ -1,4 +1,4 @@ |
||
1 |
-CodeConvert==2.0.5 |
|
1 |
+CodeConvert==3.0.2 |
|
2 | 2 |
Pillow==5.0.0 |
3 | 3 |
StatusCode==1.0.0 |
4 | 4 |
TimeConvert==1.5.1 |
@@ -7,7 +7,7 @@ isoweek==1.3.3 |
||
7 | 7 |
jsonfield==2.0.2 |
8 | 8 |
mock==2.0.0 |
9 | 9 |
monetary==1.0.3 |
10 |
-mysqlclient==1.4.5 |
|
10 |
+mysqlclient==1.4.6 |
|
11 | 11 |
pysnippets==1.1.2 |
12 | 12 |
qiniu==7.2.6 |
13 | 13 |
requests==2.21.0 |
@@ -1,3 +1,3 @@ |
||
1 | 1 |
ipdb==0.11 |
2 | 2 |
ipython==5.8.0 |
3 |
-uwsgi==2.0.17 |
|
3 |
+uwsgi==2.0.18 |
@@ -1,9 +1,9 @@ |
||
1 |
-Django==1.11.26 |
|
1 |
+Django==1.11.29 |
|
2 | 2 |
django-admin==2.0.1 |
3 | 3 |
django-cors-headers==3.0.2 |
4 | 4 |
django-curtail-uuid==1.0.4 |
5 | 5 |
django-daterange-filter==1.3.0 |
6 |
-django-detect==1.0.17 |
|
6 |
+django-detect==1.0.18 |
|
7 | 7 |
django-file-md5==1.0.3 |
8 | 8 |
django-file-upload==1.1.1 |
9 | 9 |
django-ip==1.0.2 |
@@ -8,7 +8,7 @@ pywe-custom-message==1.0.1 |
||
8 | 8 |
pywe-miniapp==1.1.5 |
9 | 9 |
pywe-oauth==1.1.1 |
10 | 10 |
pywe-pay==1.0.13 |
11 |
-pywe-pay-notify==1.0.4 |
|
11 |
+pywe-pay-notify==1.0.5 |
|
12 | 12 |
pywe-response==1.0.1 |
13 | 13 |
pywe-sign==1.1.0 |
14 | 14 |
pywe-wxa-cv==1.0.0 |
@@ -3,8 +3,8 @@ |
||
3 | 3 |
from django.conf import settings |
4 | 4 |
from django_redis_connector import connector |
5 | 5 |
from pywe_storage import RedisStorage |
6 |
-from pywe_user import get_all_users |
|
7 | 6 |
|
7 |
+from pywe_user import get_all_users |
|
8 | 8 |
from utils.redis.rkeys import SUBSCRIBE_USERINFO_LIST |
9 | 9 |
|
10 | 10 |
|
@@ -15,7 +15,7 @@ WECHAT = settings.WECHAT |
||
15 | 15 |
|
16 | 16 |
|
17 | 17 |
def fetch_users_func(authorizer_appid, infos): |
18 |
- print authorizer_appid, infos |
|
18 |
+ print(authorizer_appid, infos) |
|
19 | 19 |
openids = infos.get('data', {}).get('openid', []) |
20 | 20 |
for openid in openids: |
21 | 21 |
r1.rpushjson(SUBSCRIBE_USERINFO_LIST % authorizer_appid, { |
@@ -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. |
@@ -3,4 +3,5 @@ from __future__ import unicode_literals |
||
3 | 3 |
|
4 | 4 |
from django.shortcuts import render |
5 | 5 |
|
6 |
+ |
|
6 | 7 |
# Create your views here. |
@@ -256,6 +256,7 @@ class PermissionStatusCode(BaseStatusCode): |
||
256 | 256 |
""" 4099xx 权限相关错误码 """ |
257 | 257 |
PERMISSION_DENIED = StatusCodeField(409900, 'Permission Denied', description=u'权限不足') |
258 | 258 |
|
259 |
+ |
|
259 | 260 |
class CouponStatusCode(BaseStatusCode): |
260 | 261 |
""" 4050xx 优惠劵相关错误码 """ |
261 | 262 |
COUPON_NOT_FOUND = StatusCodeField(405001, 'Coupon Not Found', description=u'劵不存在') |
@@ -9,7 +9,7 @@ from utils.redis.rkeys import TODAY_INCOME, TOTAL_INCOME, WEEK_INCOME, WEEK_SOLD |
||
9 | 9 |
|
10 | 10 |
def set_brief_info(uid, ptype, fee, dt=None): |
11 | 11 |
""" 更新简报信息 """ |
12 |
- ymd, week = (tc.local_string(tc.to_local_datetime(dt), format='%Y%m%d'), Week.withdate(dt)) if dt else (tc.local_string(format='%Y%m%d'), Week.thisweek().isoformat()) |
|
12 |
+ ymd, week = (tc.local_string(utc_dt=dt, format='%Y%m%d'), Week.withdate(dt)) if dt else (tc.local_string(format='%Y%m%d'), Week.thisweek().isoformat()) |
|
13 | 13 |
|
14 | 14 |
# 总收入 |
15 | 15 |
r.incr(TOTAL_INCOME % (uid, ptype), fee) |
@@ -41,7 +41,7 @@ def zbar(path): |
||
41 | 41 |
def test_zbar(): |
42 | 42 |
# In[4]: test_zbar() |
43 | 43 |
# [u'189415'] |
44 |
- print zbar(settings.TESTING_ZBAR) |
|
44 |
+ print(zbar(settings.TESTING_ZBAR)) |
|
45 | 45 |
|
46 | 46 |
|
47 | 47 |
if __name__ == '__main__': |
@@ -28,4 +28,4 @@ def zbar2(path): |
||
28 | 28 |
def test_zbar2(): |
29 | 29 |
# In[5]: test_zbar() |
30 | 30 |
# [u'189415'] |
31 |
- print zbar2(settings.TESTING_ZBAR) |
|
31 |
+ print(zbar2(settings.TESTING_ZBAR)) |