@@ -7,7 +7,7 @@ from jsonfield import JSONField |
||
7 | 7 |
from TimeConvert import TimeConvert as tc |
8 | 8 |
|
9 | 9 |
from kodo.basemodels import LensmanTypeBoolMixin |
10 |
-from mch.models import SaleclerkInfo, MaintenancemanInfo |
|
10 |
+from mch.models import MaintenancemanInfo, SaleclerkInfo |
|
11 | 11 |
from sales.models import SalesResponsibilityInfo |
12 | 12 |
|
13 | 13 |
|
@@ -475,7 +475,7 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin): |
||
475 | 475 |
'shots_num': self.shots_num, |
476 | 476 |
'level': self.level, |
477 | 477 |
} |
478 |
- |
|
478 |
+ |
|
479 | 479 |
def brand_qydata(self, brand_id=None): |
480 | 480 |
if self.phone: |
481 | 481 |
try: |
@@ -485,12 +485,12 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin): |
||
485 | 485 |
saleclerk_info = saleclerk.data if saleclerk and saleclerk.is_auth else {} |
486 | 486 |
else: |
487 | 487 |
saleclerk_info = {} |
488 |
- |
|
488 |
+ |
|
489 | 489 |
try: |
490 | 490 |
maintenance = MaintenancemanInfo.objects.get(brand_id=brand_id, user_id=self.user_id, status=True) |
491 |
- except: |
|
491 |
+ except MaintenancemanInfo.DoesNotExist: |
|
492 | 492 |
maintenance = {} |
493 |
- |
|
493 |
+ |
|
494 | 494 |
maintenance_info = maintenance.data if maintenance and self.is_maintenance else {} |
495 | 495 |
return { |
496 | 496 |
'has_unionid': bool(self.unionid), |
@@ -2,27 +2,22 @@ |
||
2 | 2 |
|
3 | 3 |
from __future__ import division |
4 | 4 |
|
5 |
-import json |
|
6 | 5 |
from collections import defaultdict |
7 | 6 |
from datetime import datetime |
8 |
-from itertools import chain, groupby |
|
9 | 7 |
|
10 | 8 |
from django.conf import settings |
11 | 9 |
from django.db import transaction |
12 |
-from django.db.models import Count, Sum, Q |
|
10 |
+from django.db.models import Count, Q, Sum |
|
13 | 11 |
from django_logit import logit |
14 | 12 |
from django_response import response |
15 | 13 |
from paginator import pagination |
16 | 14 |
from TimeConvert import TimeConvert as tc |
17 |
-from django.utils.timezone import utc |
|
18 | 15 |
|
19 | 16 |
from account.models import UserInfo |
20 |
-from integral.models import SaleclerkSubmitLogInfo |
|
21 |
-from logs.models import MchInfoEncryptLogInfo |
|
22 | 17 |
from coupon.models import UserCouponInfo |
23 |
-from mch.models import AdministratorInfo, ConsumeInfoSubmitLogInfo, ModelInfo, SaleclerkInfo |
|
24 |
-from statistic.models import (ConsumeModelSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo, |
|
25 |
- ModelSaleStatisticInfo) |
|
18 |
+from integral.models import SaleclerkSubmitLogInfo |
|
19 |
+from mch.models import AdministratorInfo, ConsumeInfoSubmitLogInfo |
|
20 |
+from statistic.models import ConsumeModelSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo |
|
26 | 21 |
from utils.error.errno_utils import (AdministratorStatusCode, ProductBrandStatusCode, ProductCouponStatusCode, |
27 | 22 |
ProductMachineStatusCode, UserStatusCode) |
28 | 23 |
|
@@ -97,7 +92,7 @@ def usecoupon(request): |
||
97 | 92 |
model_id=model_id, |
98 | 93 |
serialNo=sn, |
99 | 94 |
submit_during_activity=True, |
100 |
- has_used=False, |
|
95 |
+ has_used=False, |
|
101 | 96 |
status=True |
102 | 97 |
).first() |
103 | 98 |
if not log: |
@@ -168,6 +163,7 @@ def query_usercoupons(request): |
||
168 | 163 |
'coupons': coupons, |
169 | 164 |
}) |
170 | 165 |
|
166 |
+ |
|
171 | 167 |
@logit |
172 | 168 |
def query_usergoods(request): |
173 | 169 |
brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
@@ -224,22 +220,22 @@ def query_userinfo(request): |
||
224 | 220 |
|
225 | 221 |
if level: |
226 | 222 |
userinfos = userinfos.filter(level=level) |
227 |
- |
|
223 |
+ |
|
228 | 224 |
if code_version: |
229 | 225 |
userinfos = userinfos.filter(code_version=code_version) |
230 |
- |
|
226 |
+ |
|
231 | 227 |
if subscribe: |
232 | 228 |
userinfos = userinfos.filter(subscribe=subscribe) |
233 |
- |
|
229 |
+ |
|
234 | 230 |
if has_membercard: |
235 | 231 |
userinfos = userinfos.filter(has_membercard=has_membercard) |
236 |
- |
|
232 |
+ |
|
237 | 233 |
if is_member: |
238 | 234 |
userinfos = userinfos.filter(level__gte=1) |
239 |
- |
|
235 |
+ |
|
240 | 236 |
if sex: |
241 | 237 |
userinfos = userinfos.filter(sex=sex) |
242 |
- |
|
238 |
+ |
|
243 | 239 |
if start_time and end_time: |
244 | 240 |
ftime = datetime.strptime(start_time + ' 00:00:00', '%Y%m%d %H:%M:%S') |
245 | 241 |
ttime = datetime.strptime(end_time + ' 23:59:59', '%Y%m%d %H:%M:%S') |
@@ -626,6 +622,7 @@ def statistic_consumer(request): |
||
626 | 622 |
'province_logs': province_logs, |
627 | 623 |
}) |
628 | 624 |
|
625 |
+ |
|
629 | 626 |
def statistic_member(request): |
630 | 627 |
brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
631 | 628 |
admin_id = request.POST.get('admin_id', '') |
@@ -647,7 +644,7 @@ def statistic_member(request): |
||
647 | 644 |
|
648 | 645 |
for user in users: |
649 | 646 |
userinfos |= UserInfo.objects.filter(user_id=user.get('user_id', '')) |
650 |
- |
|
647 |
+ |
|
651 | 648 |
# 会员级别 |
652 | 649 |
level_logs = list(userinfos.values('level').annotate(num=Count('user_id'))) |
653 | 650 |
|
@@ -671,6 +668,7 @@ def statistic_member(request): |
||
671 | 668 |
'province_logs': province_logs, |
672 | 669 |
}) |
673 | 670 |
|
671 |
+ |
|
674 | 672 |
def record_consumer(request): |
675 | 673 |
brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
676 | 674 |
page = request.POST.get('page', 1) |
@@ -689,15 +687,15 @@ def record_consumer(request): |
||
689 | 687 |
administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True) |
690 | 688 |
except AdministratorInfo.DoesNotExist: |
691 | 689 |
return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND) |
692 |
- |
|
690 |
+ |
|
693 | 691 |
logs = ConsumeInfoSubmitLogInfo.objects.filter(Q(status=True) & Q(test_user=False) & (Q(model_name__icontains=query) | Q(phone__icontains=query) | Q(serialNo__icontains=query))).order_by('-created_at') |
694 | 692 |
|
695 | 693 |
if dupload: |
696 | 694 |
logs = logs.filter(dupload=dupload) |
697 |
- |
|
695 |
+ |
|
698 | 696 |
if code_version: |
699 | 697 |
logs = logs.filter(code_version=code_version) |
700 |
- |
|
698 |
+ |
|
701 | 699 |
if start_time and end_time: |
702 | 700 |
logs = logs.filter(ymd__gte=start_time, ymd__lte=end_time) |
703 | 701 |
|
@@ -711,6 +709,7 @@ def record_consumer(request): |
||
711 | 709 |
'left': left |
712 | 710 |
}) |
713 | 711 |
|
712 |
+ |
|
714 | 713 |
def record_sale(request): |
715 | 714 |
brand_id = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_ID) |
716 | 715 |
admin_id = request.POST.get('admin_id', '') |
@@ -731,15 +730,15 @@ def record_sale(request): |
||
731 | 730 |
administrator = AdministratorInfo.objects.get(admin_id=admin_id, user_status=AdministratorInfo.ACTIVATED, status=True) |
732 | 731 |
except AdministratorInfo.DoesNotExist: |
733 | 732 |
return response(AdministratorStatusCode.ADMINISTRATOR_NOT_FOUND) |
734 |
- |
|
735 |
- logs = SaleclerkSubmitLogInfo.objects.filter(Q(status=True) & Q(test_user=False) & Q(test_sn=False) & (Q(model_name__icontains=query) | Q(clerk_name__icontains=query) | Q(distributor_name__icontains=query)| Q(code__icontains=query))).order_by('-created_at') |
|
733 |
+ |
|
734 |
+ logs = SaleclerkSubmitLogInfo.objects.filter(Q(status=True) & Q(test_user=False) & Q(test_sn=False) & (Q(model_name__icontains=query) | Q(clerk_name__icontains=query) | Q(distributor_name__icontains=query) | Q(code__icontains=query))).order_by('-created_at') |
|
736 | 735 |
|
737 | 736 |
if dupload: |
738 | 737 |
logs = logs.filter(dupload=dupload) |
739 |
- |
|
738 |
+ |
|
740 | 739 |
if code_version: |
741 | 740 |
logs = logs.filter(code_version=code_version) |
742 |
- |
|
741 |
+ |
|
743 | 742 |
if has_scan: |
744 | 743 |
logs = logs.filter(has_scan=has_scan) |
745 | 744 |
|
@@ -748,7 +747,6 @@ def record_sale(request): |
||
748 | 747 |
|
749 | 748 |
if is_online_sale: |
750 | 749 |
logs = logs.filter(remark=('扫描条形码' if is_online_sale == '1' else '')) |
751 |
- |
|
752 | 750 |
|
753 | 751 |
count = logs.count() |
754 | 752 |
logs, left = pagination(logs, page, num) |
@@ -294,28 +294,33 @@ def consumer_info_api(request): |
||
294 | 294 |
for act in activities: |
295 | 295 |
try: |
296 | 296 |
coupon = CouponInfo.objects.get(coupon_id=act['coupon_id']) |
297 |
+ except CouponInfo.DoesNotExist: |
|
298 |
+ continue |
|
299 |
+ |
|
300 |
+ try: |
|
297 | 301 |
activity = ActivityInfo.objects.get(activity_id=act['activity_id']) |
298 |
- UserCouponInfo.objects.create( |
|
299 |
- brand_id=coupon.brand_id, |
|
300 |
- brand_name=coupon.brand_name, |
|
301 |
- coupon_id=coupon.coupon_id, |
|
302 |
- user_id=user_id, |
|
303 |
- coupon_title=coupon.coupon_title, |
|
304 |
- coupon_detail=coupon.coupon_detail, |
|
305 |
- coupon_value=coupon.coupon_value, |
|
306 |
- coupon_image=coupon.coupon_image, |
|
307 |
- active_at=tc.utc_datetime(), |
|
308 |
- expire_at=coupon.final_expire_at, |
|
309 |
- is_coupon_admin_writeoff=coupon.is_coupon_admin_writeoff, |
|
310 |
- coupon_valid_period=coupon.coupon_valid_period, |
|
311 |
- coupon_limit_model_ids=coupon.coupon_limit_model_ids, |
|
312 |
- coupon_from='PROMOTION', |
|
313 |
- activity_id=activity.activity_id, |
|
314 |
- activity_name=activity.activity_name, |
|
315 |
- ) |
|
316 |
- except: |
|
302 |
+ except ActivityInfo.DoesNotExist: |
|
317 | 303 |
continue |
318 | 304 |
|
305 |
+ UserCouponInfo.objects.create( |
|
306 |
+ brand_id=coupon.brand_id, |
|
307 |
+ brand_name=coupon.brand_name, |
|
308 |
+ coupon_id=coupon.coupon_id, |
|
309 |
+ user_id=user_id, |
|
310 |
+ coupon_title=coupon.coupon_title, |
|
311 |
+ coupon_detail=coupon.coupon_detail, |
|
312 |
+ coupon_value=coupon.coupon_value, |
|
313 |
+ coupon_image=coupon.coupon_image, |
|
314 |
+ active_at=tc.utc_datetime(), |
|
315 |
+ expire_at=coupon.final_expire_at, |
|
316 |
+ is_coupon_admin_writeoff=coupon.is_coupon_admin_writeoff, |
|
317 |
+ coupon_valid_period=coupon.coupon_valid_period, |
|
318 |
+ coupon_limit_model_ids=coupon.coupon_limit_model_ids, |
|
319 |
+ coupon_from='PROMOTION', |
|
320 |
+ activity_id=activity.activity_id, |
|
321 |
+ activity_name=activity.activity_name, |
|
322 |
+ ) |
|
323 |
+ |
|
319 | 324 |
# 更新销售员提交的表 |
320 | 325 |
SaleclerkSubmitLogInfo.objects.filter(code=serialNo, model_pk=model.pk, status=True).update(has_scan=True) |
321 | 326 |
|
@@ -13,7 +13,8 @@ from group import (groupuser_views, lensman_views, tourguidegroup_views, tourgui |
||
13 | 13 |
tourguidegroupuser_views) |
14 | 14 |
from group import views as group_views |
15 | 15 |
from message import views as message_views |
16 |
-from miniapp import views as mini_views, qy_views |
|
16 |
+from miniapp import qy_views |
|
17 |
+from miniapp import views as mini_views |
|
17 | 18 |
from operation import views as op_views |
18 | 19 |
from page import oauth_views, sale_views, screen_views |
19 | 20 |
from pay import views as pay_views |
@@ -187,7 +188,7 @@ urlpatterns += [ |
||
187 | 188 |
|
188 | 189 |
url(r'^qy/login$', qy_views.qy_login_api, name='qy_login_api'), # 小程序登录 |
189 | 190 |
|
190 |
- url(r'^qy/query/userinfo$', qy_views.query_userinfo, name='query_userinfo'), # 查询用户等级及维修劵 |
|
191 |
+ url(r'^qy/query/userinfo$', qy_views.query_userinfo, name='query_userinfo'), # 查询用户等级及维修劵 |
|
191 | 192 |
] |
192 | 193 |
|
193 | 194 |
urlpatterns += [ |
@@ -6,9 +6,9 @@ import os |
||
6 | 6 |
from django_six import CompatibilityBaseCommand, close_old_connections |
7 | 7 |
|
8 | 8 |
from integral.models import SaleclerkSubmitLogInfo |
9 |
+from utils.qiniucdn import upload_file_path |
|
9 | 10 |
from utils.redis.connect import r |
10 | 11 |
from utils.redis.rkeys import QINIU_UPLOAD_LIST |
11 |
-from utils.qiniucdn import upload_file_path |
|
12 | 12 |
|
13 | 13 |
|
14 | 14 |
logger = logging.getLogger('console') |
@@ -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 |
|
11 | 12 |
|
12 | 13 |
from account.models import UserInfo |
13 | 14 |
from mch.models import BrandInfo |
14 | 15 |
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 |
|
@@ -118,7 +118,7 @@ class UserCouponInfo(BaseModelMixin): |
||
118 | 118 |
if not self.expire_at: |
119 | 119 |
return False |
120 | 120 |
return tc.utc_datetime() > self.expire_at |
121 |
- |
|
121 |
+ |
|
122 | 122 |
@property |
123 | 123 |
def coupon_source(self): |
124 | 124 |
if self.coupon_from == 'INTEGRAL_MALL': |
@@ -151,7 +151,7 @@ class UserCouponInfo(BaseModelMixin): |
||
151 | 151 |
'admin_id': self.admin_id, |
152 | 152 |
'used_at': self.used_at |
153 | 153 |
} |
154 |
- |
|
154 |
+ |
|
155 | 155 |
@property |
156 | 156 |
def admindata(self): |
157 | 157 |
return { |
@@ -2,7 +2,7 @@ |
||
2 | 2 |
|
3 | 3 |
from django.db import models |
4 | 4 |
from django.utils.translation import ugettext_lazy as _ |
5 |
-from django_models_ext import BaseModelMixin, upload_path, upload_file_path, upload_file_url |
|
5 |
+from django_models_ext import BaseModelMixin, upload_file_path, upload_file_url, upload_path |
|
6 | 6 |
from TimeConvert import TimeConvert as tc |
7 | 7 |
|
8 | 8 |
from mch.models import ModelInfo |
@@ -129,7 +129,7 @@ class SaleclerkSubmitLogInfo(BaseModelMixin): |
||
129 | 129 |
|
130 | 130 |
def __unicode__(self): |
131 | 131 |
return unicode(self.pk) |
132 |
- |
|
132 |
+ |
|
133 | 133 |
@property |
134 | 134 |
def image_path(self): |
135 | 135 |
return upload_file_path(self.image) |
@@ -137,7 +137,7 @@ class SaleclerkSubmitLogInfo(BaseModelMixin): |
||
137 | 137 |
@property |
138 | 138 |
def image_url(self): |
139 | 139 |
return qiniu_file_url(self.image.name, bucket='tamron') if self.is_upload_qiniu else upload_file_url(self.image) |
140 |
- |
|
140 |
+ |
|
141 | 141 |
@property |
142 | 142 |
def code_image_path(self): |
143 | 143 |
return upload_file_path(self.code_image) |
@@ -164,4 +164,4 @@ class SaleclerkSubmitLogInfo(BaseModelMixin): |
||
164 | 164 |
'image': self.image_url, |
165 | 165 |
'code_image': self.code_image_url, |
166 | 166 |
'created_at': tc.local_string(utc_dt=self.created_at, format='%Y-%m-%d'), |
167 |
- } |
|
167 |
+ } |
@@ -9,8 +9,8 @@ from django_models_ext import ProvinceShortModelMixin |
||
9 | 9 |
from pysnippets.strsnippets import strip |
10 | 10 |
|
11 | 11 |
from mch.models import (ActivityInfo, AdministratorInfo, BrandInfo, CameraModelInfo, ConsumeInfoSubmitLogInfo, |
12 |
- DistributorInfo, LatestAppInfo, LatestAppScreenInfo, ModelCameraBodyInfo, ModelInfo, |
|
13 |
- OperatorInfo, SaleclerkInfo, MaintenancemanInfo) |
|
12 |
+ DistributorInfo, LatestAppInfo, LatestAppScreenInfo, MaintenancemanInfo, ModelCameraBodyInfo, |
|
13 |
+ ModelInfo, OperatorInfo, SaleclerkInfo) |
|
14 | 14 |
from utils.redis.rshot import update_member_shot_data |
15 | 15 |
|
16 | 16 |
|
@@ -161,6 +161,7 @@ class SaleclerkInfoAdmin(AdvancedExportExcelModelAdmin, AdvancedActionsModelAdmi |
||
161 | 161 |
search_fields = ('brand_id', 'brand_name', 'distributor_id', 'distributor_name', 'clerk_id', 'clerk_name', 'clerk_phone', 'unionid', 'openid') |
162 | 162 |
actions_exclude = ('delete_selected', ) |
163 | 163 |
|
164 |
+ |
|
164 | 165 |
class MaintenancemanInfoAdmin(AdvancedExportExcelModelAdmin, AdvancedActionsModelAdmin, admin.ModelAdmin): |
165 | 166 |
list_display = ('brand_name', 'wx_userid', 'maintenance_id', 'maintenance_name', 'maintenance_phone', 'status', 'created_at', 'updated_at') |
166 | 167 |
search_fields = ('maintenance_id', 'maintenance_name', 'maintenance_phone') |
@@ -252,4 +253,4 @@ admin.site.register(LatestAppInfo, LatestAppInfoAdmin) |
||
252 | 253 |
admin.site.register(LatestAppScreenInfo, LatestAppScreenInfoAdmin) |
253 | 254 |
admin.site.register(ConsumeInfoSubmitLogInfo, ConsumeInfoSubmitLogInfoAdmin) |
254 | 255 |
admin.site.register(ActivityInfo, ActivityInfoAdmin) |
255 |
-admin.site.register(MaintenancemanInfo, MaintenancemanInfoAdmin) |
|
256 |
+admin.site.register(MaintenancemanInfo, MaintenancemanInfoAdmin) |
@@ -478,6 +478,7 @@ class SaleclerkInfo(BaseModelMixin, SexModelMixin): |
||
478 | 478 |
|
479 | 479 |
data = admindata |
480 | 480 |
|
481 |
+ |
|
481 | 482 |
class MaintenancemanInfo(BaseModelMixin, SexModelMixin): |
482 | 483 |
brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
483 | 484 |
brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称') |
@@ -503,12 +504,13 @@ class MaintenancemanInfo(BaseModelMixin, SexModelMixin): |
||
503 | 504 |
|
504 | 505 |
@property |
505 | 506 |
def data(self): |
506 |
- return { |
|
507 |
+ return { |
|
507 | 508 |
'maintenance_id': self.maintenance_id, |
508 | 509 |
'maintenance_name': self.maintenance_name, |
509 | 510 |
'maintenance_phone': self.maintenance_phone, |
510 | 511 |
} |
511 | 512 |
|
513 |
+ |
|
512 | 514 |
class BrandModelDistributorPriceInfo(BaseModelMixin): |
513 | 515 |
brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
514 | 516 |
brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称') |
@@ -729,7 +731,7 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin): |
||
729 | 731 |
'code_version': self.code_version, |
730 | 732 |
'created_at': tc.local_string(utc_dt=self.created_at, format='%Y-%m-%d'), |
731 | 733 |
} |
732 |
- |
|
734 |
+ |
|
733 | 735 |
@property |
734 | 736 |
def admindata(self): |
735 | 737 |
return { |
@@ -219,7 +219,7 @@ class RightInfo(BaseModelMixin): |
||
219 | 219 |
'left_num': 3, |
220 | 220 |
'left_tip': 3, |
221 | 221 |
} |
222 |
- |
|
222 |
+ |
|
223 | 223 |
def maintaindata(self, level): |
224 | 224 |
right_detail = '' |
225 | 225 |
if level == 1: |
@@ -232,7 +232,7 @@ class RightInfo(BaseModelMixin): |
||
232 | 232 |
right_detail = self.level4 if self.level4 else '' |
233 | 233 |
elif level == 5: |
234 | 234 |
right_detail = self.level5 if self.level5 else '' |
235 |
- |
|
235 |
+ |
|
236 | 236 |
return right_detail |
237 | 237 |
|
238 | 238 |
|
@@ -1,9 +1,9 @@ |
||
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
-import logging |
|
4 |
-import requests |
|
5 | 3 |
import json |
4 |
+import logging |
|
6 | 5 |
|
6 |
+import requests |
|
7 | 7 |
from django.conf import settings |
8 | 8 |
from django.db import transaction |
9 | 9 |
from django_curtail_uuid import CurtailUUID |
@@ -16,14 +16,15 @@ from pywe_storage import RedisStorage |
||
16 | 16 |
from TimeConvert import TimeConvert as tc |
17 | 17 |
|
18 | 18 |
from account.models import UserInfo |
19 |
-from mch.models import SaleclerkInfo, DistributorInfo, MaintenancemanInfo |
|
20 |
-from statistic.models import RegisterStatisticInfo |
|
21 |
-from member.models import RightInfo |
|
22 | 19 |
from coupon.models import UserCouponInfo |
20 |
+from mch.models import DistributorInfo, MaintenancemanInfo, SaleclerkInfo |
|
21 |
+from member.models import RightInfo |
|
22 |
+from statistic.models import RegisterStatisticInfo |
|
23 | 23 |
from utils.error.errno_utils import ProductBrandStatusCode, ProductDistributorStatusCode, UserStatusCode |
24 | 24 |
from utils.redis.connect import r |
25 | 25 |
from utils.redis.rprofile import set_profile_info |
26 | 26 |
|
27 |
+ |
|
27 | 28 |
WECHAT = settings.WECHAT |
28 | 29 |
logger = logging.getLogger('logit') |
29 | 30 |
|
@@ -48,11 +49,11 @@ def qy_login_api(request): |
||
48 | 49 |
|
49 | 50 |
token = access_token(appid=appid, secret=secret, storage=RedisStorage(r)) |
50 | 51 |
|
51 |
- userinfo = requests.post(url='https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token='+token+'&userid='+userid).text |
|
52 |
+ userinfo = requests.post(url='https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=' + token + '&userid=' + userid).text |
|
52 | 53 |
userinfo = json.loads(userinfo) |
53 | 54 |
|
54 | 55 |
mobile = userinfo.get('mobile', '') |
55 |
- |
|
56 |
+ |
|
56 | 57 |
# Get or Create User |
57 | 58 |
user, created = UserInfo.objects.select_for_update().get_or_create(appid=appid, userid=userid) |
58 | 59 |
|
@@ -83,14 +84,14 @@ def qy_login_api(request): |
||
83 | 84 |
if 122 in userinfo.get('department', []): |
84 | 85 |
maintenance, created = MaintenancemanInfo.objects.get_or_create(brand_id=brand_id, maintenance_phone=mobile, status=True) |
85 | 86 |
user.is_maintenance = True |
86 |
- |
|
87 |
+ |
|
87 | 88 |
if created: |
88 | 89 |
maintenance.maintenance_name = userinfo.get('name', '') |
89 | 90 |
maintenance.maintenance_sex = userinfo.get('gender', 0) |
90 | 91 |
maintenance.maintenance_phone = mobile |
91 | 92 |
maintenance.user_id = user.user_id |
92 | 93 |
maintenance.wx_userid = userid |
93 |
- maintenance.save() |
|
94 |
+ maintenance.save() |
|
94 | 95 |
else: |
95 | 96 |
user.is_maintenance = False |
96 | 97 |
# 销售员登录 |
@@ -99,9 +100,9 @@ def qy_login_api(request): |
||
99 | 100 |
if created: |
100 | 101 |
try: |
101 | 102 |
distributor = DistributorInfo.objects.get(department_id__in=userinfo.get('department', [])) |
102 |
- except: |
|
103 |
+ except DistributorInfo.DoesNotExist: |
|
103 | 104 |
return response(ProductDistributorStatusCode.DISTRIBUTOR_NOT_FOUND) |
104 |
- |
|
105 |
+ |
|
105 | 106 |
saleclerk.brand_id = brand_id |
106 | 107 |
saleclerk.distributor_id = distributor.distributor_id |
107 | 108 |
saleclerk.distributor_name = distributor.distributor_name |
@@ -113,7 +114,7 @@ def qy_login_api(request): |
||
113 | 114 |
saleclerk.user_status = SaleclerkInfo.ACTIVATED |
114 | 115 |
saleclerk.is_auth = True |
115 | 116 |
saleclerk.save() |
116 |
- |
|
117 |
+ |
|
117 | 118 |
user.save() |
118 | 119 |
|
119 | 120 |
return response(200, 'Mini App Login Success', u'微信小程序登录成功', user.brand_qydata(brand_id=brand_id)) |
@@ -128,9 +129,9 @@ def query_userinfo(request): |
||
128 | 129 |
|
129 | 130 |
try: |
130 | 131 |
user = UserInfo.objects.get(memberusercardcode=memebercardcode, status=True) |
131 |
- except: |
|
132 |
+ except UserInfo.DoesNotExist: |
|
132 | 133 |
return response(UserStatusCode.USER_NOT_FOUND) |
133 |
- |
|
134 |
+ |
|
134 | 135 |
# 维修人工费 |
135 | 136 |
right = RightInfo.objects.get(right_id='X457xEV8KVxHQiTvhA7Dtf') |
136 | 137 |
coupons = UserCouponInfo.objects.filter(user_id=user.user_id, has_used=False, status=True) |
@@ -14,8 +14,8 @@ from pywe_storage import RedisStorage |
||
14 | 14 |
from TimeConvert import TimeConvert as tc |
15 | 15 |
|
16 | 16 |
from account.models import UserInfo |
17 |
-from statistic.models import RegisterStatisticInfo |
|
18 | 17 |
from mch.models import SaleclerkInfo |
18 |
+from statistic.models import RegisterStatisticInfo |
|
19 | 19 |
from utils.error.errno_utils import ProductBrandStatusCode, UserStatusCode |
20 | 20 |
from utils.redis.connect import r |
21 | 21 |
from utils.redis.rprofile import set_profile_info |
@@ -158,9 +158,10 @@ def mini_login_api(request): |
||
158 | 158 |
# 同步销售员手机号 |
159 | 159 |
try: |
160 | 160 |
saleclerk = SaleclerkInfo.objects.get(unionid=unionid, is_auth=True, status=True) |
161 |
+ except SaleclerkInfo.DoesNotExist: |
|
162 |
+ saleclerk = None |
|
163 |
+ if saleclerk: |
|
161 | 164 |
user.phone = saleclerk.clerk_phone |
162 |
- except: |
|
163 |
- pass |
|
164 | 165 |
user.unionid = unionid |
165 | 166 |
user.user_status = UserInfo.ACTIVATED |
166 | 167 |
user.signup_ip = client_ip(request) |
@@ -17,10 +17,11 @@ from account.models import UserInfo |
||
17 | 17 |
from coupon.models import UserCouponInfo |
18 | 18 |
from integral.models import SaleclerkIntegralIncomeExpensesInfo, SaleclerkSubmitLogInfo |
19 | 19 |
from logs.models import MchInfoEncryptLogInfo |
20 |
-from mch.models import BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo, SaleclerkInfo, MaintenancemanInfo |
|
20 |
+from mch.models import (BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, MaintenancemanInfo, ModelInfo, |
|
21 |
+ SaleclerkInfo) |
|
22 |
+from member.models import RightInfo |
|
21 | 23 |
from statistic.models import (DistributorSaleStatisticInfo, ModelSaleStatisticInfo, ProvinceSaleStatisticInfo, |
22 | 24 |
SaleclerkSaleStatisticInfo, SaleStatisticInfo) |
23 |
-from member.models import RightInfo |
|
24 | 25 |
from utils.error.errno_utils import (CouponStatusCode, ProductBrandStatusCode, ProductDistributorStatusCode, |
25 | 26 |
ProductMachineStatusCode, ProductModelStatusCode, SaleclerkStatusCode) |
26 | 27 |
|
@@ -454,19 +455,26 @@ def clerk_query_coupon(request): |
||
454 | 455 |
user_coupon = UserCouponInfo.objects.get(user_coupon_id=user_coupon_id) |
455 | 456 |
except UserCouponInfo.DoesNotExist: |
456 | 457 |
return response(CouponStatusCode.COUPON_NOT_FOUND) |
457 |
- |
|
458 |
+ |
|
458 | 459 |
right_detail = '' |
459 | 460 |
if is_maintenance: |
460 | 461 |
try: |
461 |
- maintenance = MaintenancemanInfo.objects.get(brand_id=brand.brand_id, user_id=user.user_id, status=True) |
|
462 |
- |
|
463 |
- # 维修人工费 |
|
462 |
+ maintenance = MaintenancemanInfo.objects.get(brand_id=brand.brand_id, user_id=user.user_id, status=True) |
|
463 |
+ except MaintenancemanInfo.DoesNotExist: |
|
464 |
+ return response(400001, 'MaintenancemanInfo Not Found', u'维修员不存在') |
|
465 |
+ |
|
466 |
+ # 维修人工费 |
|
467 |
+ try: |
|
464 | 468 |
right = RightInfo.objects.get(right_id='X457xEV8KVxHQiTvhA7Dtf') |
465 |
- member = UserInfo.objects.get(user_id=user_coupon.user_id) |
|
469 |
+ except RightInfo.DoesNotExist: |
|
470 |
+ return response(400001, 'MaintenancemanInfo Not Found', u'维修员不存在') |
|
466 | 471 |
|
467 |
- right_detail = right.maintaindata(level=member.level) |
|
468 |
- except: |
|
472 |
+ try: |
|
473 |
+ member = UserInfo.objects.get(user_id=user_coupon.user_id) |
|
474 |
+ except UserInfo.DoesNotExist: |
|
469 | 475 |
return response(400001, 'MaintenancemanInfo Not Found', u'维修员不存在') |
476 |
+ |
|
477 |
+ right_detail = right.maintaindata(level=member.level) |
|
470 | 478 |
else: |
471 | 479 |
try: |
472 | 480 |
clerk = SaleclerkInfo.objects.get(brand_id=brand.brand_id, clerk_phone=user.phone, status=True) |
@@ -503,40 +511,43 @@ def clerk_writeoff_coupon(request): |
||
503 | 511 |
brand = BrandInfo.objects.get(brand_id=brandID) |
504 | 512 |
except BrandInfo.DoesNotExist: |
505 | 513 |
return response(ProductBrandStatusCode.BRAND_NOT_FOUND) |
506 |
- |
|
514 |
+ |
|
507 | 515 |
try: |
508 | 516 |
user_coupon = UserCouponInfo.objects.get(user_coupon_id=user_coupon_id) |
509 |
- if user_coupon.has_used: |
|
510 |
- return response(CouponStatusCode.COUPON_HAS_USED) |
|
511 |
- elif user_coupon.is_coupon_admin_writeoff and not is_maintenance: |
|
512 |
- return response(CouponStatusCode.COUPON_PERMISSION_DENIED) |
|
513 |
- elif user_coupon.has_expired: |
|
514 |
- return response(CouponStatusCode.COUPON_EXPIRED) |
|
515 | 517 |
except UserCouponInfo.DoesNotExist: |
516 | 518 |
return response(CouponStatusCode.COUPON_NOT_FOUND) |
517 |
- |
|
519 |
+ |
|
520 |
+ if user_coupon.has_used: |
|
521 |
+ return response(CouponStatusCode.COUPON_HAS_USED) |
|
522 |
+ elif user_coupon.is_coupon_admin_writeoff and not is_maintenance: |
|
523 |
+ return response(CouponStatusCode.COUPON_PERMISSION_DENIED) |
|
524 |
+ elif user_coupon.has_expired: |
|
525 |
+ return response(CouponStatusCode.COUPON_EXPIRED) |
|
526 |
+ |
|
518 | 527 |
user_coupon.has_used = True |
519 | 528 |
user_coupon.used_at = tc.utc_datetime() |
520 | 529 |
|
521 | 530 |
if is_maintenance: |
522 | 531 |
try: |
523 |
- maintenance = MaintenancemanInfo.objects.get(brand_id=brand.brand_id, user_id=user.user_id, status=True) |
|
524 |
- user_coupon.admin_id = maintenance.maintenance_id |
|
525 |
- user_coupon.admin_name = maintenance.maintenance_name |
|
526 |
- user_coupon.save() |
|
527 |
- except: |
|
532 |
+ maintenance = MaintenancemanInfo.objects.get(brand_id=brand.brand_id, user_id=user.user_id, status=True) |
|
533 |
+ except MaintenancemanInfo.DoesNotExist: |
|
528 | 534 |
return response(400001, 'MaintenancemanInfo Not Found', u'维修员不存在') |
535 |
+ |
|
536 |
+ user_coupon.admin_id = maintenance.maintenance_id |
|
537 |
+ user_coupon.admin_name = maintenance.maintenance_name |
|
538 |
+ user_coupon.save() |
|
529 | 539 |
else: |
530 | 540 |
try: |
531 | 541 |
clerk = SaleclerkInfo.objects.get(brand_id=brand.brand_id, clerk_phone=user.phone, status=True) |
532 |
- user_coupon.clerk_id = clerk.clerk_id |
|
533 |
- user_coupon.clerk_name = clerk.clerk_name |
|
534 |
- user_coupon.distributor_id = clerk.distributor_id |
|
535 |
- user_coupon.distributor_name = clerk.distributor_name |
|
536 |
- user_coupon.save() |
|
537 | 542 |
except SaleclerkInfo.DoesNotExist: |
538 | 543 |
return response(SaleclerkStatusCode.CLERK_NOT_FOUND) |
539 | 544 |
|
545 |
+ user_coupon.clerk_id = clerk.clerk_id |
|
546 |
+ user_coupon.clerk_name = clerk.clerk_name |
|
547 |
+ user_coupon.distributor_id = clerk.distributor_id |
|
548 |
+ user_coupon.distributor_name = clerk.distributor_name |
|
549 |
+ user_coupon.save() |
|
550 |
+ |
|
540 | 551 |
return response(200, 'Write Off Coupon Success', u'劵核销成功') |
541 | 552 |
|
542 | 553 |
|
@@ -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 |
- |
|
7 | 6 |
from pywe_user import get_all_users |
7 |
+ |
|
8 | 8 |
from utils.redis.rkeys import SUBSCRIBE_USERINFO_LIST |
9 | 9 |
|
10 | 10 |
|