|
@@ -7,7 +7,7 @@ from django.db.models import Q
|
|
|
from rest_framework import serializers
|
|
|
from rest_framework_jwt.settings import api_settings
|
|
|
|
|
|
-from apps.WechatApplet.models import WechatApplet
|
|
|
+from apps.tenant.models import Tenant
|
|
|
from apps.wxapp.models import CustomerWechat
|
|
|
from apps.log.models import BizLog
|
|
|
from apps.wxapp import customer_log
|
|
@@ -39,12 +39,15 @@ class WechatLoginSerializer(serializers.Serializer):
|
|
|
|
|
|
payload = jwt_payload_handler(user)
|
|
|
customer_log(customer_wechat.customer, BizLog.INSERT, u'用户微信登录,username=%s' % user.username)
|
|
|
+ tenant_id = customer_wechat.customer.tenant and customer_wechat.customer.tenant.id or ''
|
|
|
+ is_validity = Tenant.check_validity(tenant_id)
|
|
|
return {
|
|
|
'bind': 1,
|
|
|
'user_id': user.id,
|
|
|
'token': jwt_encode_handler(payload),
|
|
|
'openid': customer_wechat.openid,
|
|
|
- 'tenant_id': customer_wechat.customer.tenant and customer_wechat.customer.tenant.id or '',
|
|
|
+ 'tenant_id': tenant_id,
|
|
|
+ 'is_validity': is_validity,
|
|
|
'nick_name': settings.WEAPP['nick_name'],
|
|
|
'name': customer_wechat.customer.name or '',
|
|
|
'tel': customer_wechat.customer.tel or '',
|
|
@@ -71,12 +74,15 @@ class WechatBindSerializer(serializers.Serializer):
|
|
|
user = customer.user
|
|
|
payload = jwt_payload_handler(user)
|
|
|
customer_log(customer, BizLog.INSERT, u'用户微信登录,username=%s' % user.username)
|
|
|
+ tenant_id = customer.tenant and customer.tenant.id or ''
|
|
|
+ is_validity = Tenant.check_validity(tenant_id)
|
|
|
return {
|
|
|
'token': jwt_encode_handler(payload),
|
|
|
'user_id': user.id,
|
|
|
'name': customer.name or '',
|
|
|
'tel': customer.tel or '',
|
|
|
'face': customer.face,
|
|
|
+ 'is_validity': is_validity,
|
|
|
'user_type': customer.type, # 用户类别,1为平台管理员,2为管理者,3检修人,4报修人
|
|
|
'forbid_baoxiu': 'true' and customer.status == Employee.DISABLE or 'false', # 是否禁用报修,
|
|
|
'tenant_id': customer.tenant and customer.tenant.id or '',
|