@@ -0,0 +1,29 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.20 on 2019-04-14 18:25 |
|
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 |
+ ('account', '0035_auto_20181006_1142'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AddField( |
|
16 |
+ model_name='userinfo', |
|
17 |
+ name='brand_id', |
|
18 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u54c1\u724c\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='brand_id'), |
|
19 |
+ ), |
|
20 |
+ migrations.AlterField( |
|
21 |
+ model_name='userinfo', |
|
22 |
+ name='unionid', |
|
23 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u5fae\u4fe1 Unionid', max_length=32, null=True, verbose_name='unionid'), |
|
24 |
+ ), |
|
25 |
+ migrations.AlterUniqueTogether( |
|
26 |
+ name='userinfo', |
|
27 |
+ unique_together=set([('brand_id', 'unionid')]), |
|
28 |
+ ), |
|
29 |
+ ] |
@@ -289,6 +289,8 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin): |
||
289 | 289 |
(FEMALE, u'女'), |
290 | 290 |
) |
291 | 291 |
|
292 |
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
|
293 |
+ |
|
292 | 294 |
user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True, unique=True) |
293 | 295 |
|
294 | 296 |
user_from = models.IntegerField(_(u'user_from'), choices=USER_FROM, default=APP_USER, help_text=u'用户来源') |
@@ -297,7 +299,7 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin): |
||
297 | 299 |
username = models.CharField(_(u'username'), max_length=255, blank=True, null=True, help_text=u'用户用户名', db_index=True, unique=True) |
298 | 300 |
password = models.CharField(_(u'password'), max_length=255, blank=True, null=True, help_text=u'用户密码') |
299 | 301 |
# 微信授权用户 |
300 |
- unionid = models.CharField(_(u'unionid'), max_length=32, blank=True, null=True, help_text=u'微信 Unionid', db_index=True, unique=True) |
|
302 |
+ unionid = models.CharField(_(u'unionid'), max_length=32, blank=True, null=True, help_text=u'微信 Unionid', db_index=True) |
|
301 | 303 |
openid = models.CharField(_(u'openid'), max_length=32, blank=True, null=True, help_text=u'微信 Openid,拍爱用户端', db_index=True, unique=True) |
302 | 304 |
openid_lensman = models.CharField(_(u'openid_lensman'), max_length=32, blank=True, null=True, help_text=u'微信 Openid,拍爱摄影师端', db_index=True, unique=True) |
303 | 305 |
openid_tourguide = models.CharField(_(u'openid_tourguide'), max_length=32, blank=True, null=True, help_text=u'微信 Openid,拍爱导游端', db_index=True, unique=True) |
@@ -344,6 +346,10 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin): |
||
344 | 346 |
verbose_name = _(u'userinfo') |
345 | 347 |
verbose_name_plural = _(u'userinfo') |
346 | 348 |
|
349 |
+ unique_together = ( |
|
350 |
+ ('brand_id', 'unionid') |
|
351 |
+ ) |
|
352 |
+ |
|
347 | 353 |
def __unicode__(self): |
348 | 354 |
return unicode(self.pk) |
349 | 355 |
|
@@ -50,7 +50,7 @@ def get_userinfo_api(request): |
||
50 | 50 |
userinfo = get_userinfo(appid=appid, secret=secret, code=code, session_key=session_key, encryptedData=encryptedData, iv=iv) |
51 | 51 |
|
52 | 52 |
# Get or Create User |
53 |
- user, created = UserInfo.objects.select_for_update().get_or_create(unionid=userinfo.get('unionId', '')) |
|
53 |
+ user, created = UserInfo.objects.select_for_update().get_or_create(brand_id=brand_id, unionid=userinfo.get('unionId', '')) |
|
54 | 54 |
|
55 | 55 |
# Set User_id |
56 | 56 |
if created: |
@@ -124,7 +124,7 @@ def mini_login_api(request): |
||
124 | 124 |
openid = session_info.get('openid', '') |
125 | 125 |
|
126 | 126 |
# Get or Create User |
127 |
- user, created = UserInfo.objects.select_for_update().get_or_create(openid_miniapp=openid) |
|
127 |
+ user, created = UserInfo.objects.select_for_update().get_or_create(brand_id=brand_id, openid_miniapp=openid) |
|
128 | 128 |
|
129 | 129 |
# Set User_id |
130 | 130 |
if created: |