@@ -1153,34 +1153,29 @@ def member_activity_contribute_welfare_unlock(request, administrator): |
||
1153 | 1153 |
except MemberActivityContributionWelfareInfo.DoesNotExist: |
1154 | 1154 |
return response(MemberActivityContributionWelfareStatusCode.ACTIVITY_CONTRIBUTION_WELFARE_NOT_FOUND) |
1155 | 1155 |
|
1156 |
- try: |
|
1157 |
- unlocking_info, _ = MemberActivityContributionWelfareUnlockingInfo.objects.create( |
|
1158 |
- brand_id=administrator.brand_id, |
|
1159 |
- admin_id=admin_id, |
|
1160 |
- user_id=contribution.user_id, |
|
1161 |
- activity_id=contribution.activity_id, |
|
1162 |
- contribution_id=contribution_id, |
|
1163 |
- welfare_id=welfare_id, |
|
1164 |
- welfare_type=welfare.welfare_type, |
|
1165 |
- welfare_value=welfare.welfare_value, |
|
1166 |
- ) |
|
1167 |
- except: |
|
1168 |
- unlocking_info = MemberActivityContributionWelfareUnlockingInfo.objects.get( |
|
1169 |
- brand_id=administrator.brand_id, |
|
1170 |
- user_id=contribution.user_id, |
|
1171 |
- activity_id=contribution.activity_id, |
|
1172 |
- welfare_id=welfare_id, |
|
1173 |
- ) |
|
1156 |
+ unlocking_info, _ = MemberActivityContributionWelfareUnlockingInfo.objects.get_or_create( |
|
1157 |
+ brand_id=administrator.brand_id, |
|
1158 |
+ user_id=contribution.user_id, |
|
1159 |
+ activity_id=contribution.activity_id, |
|
1160 |
+ welfare_id=welfare_id, |
|
1161 |
+ defaults={ |
|
1162 |
+ 'admin_id': admin_id, |
|
1163 |
+ 'contribution_id': contribution_id, |
|
1164 |
+ 'welfare_type': welfare.welfare_type, |
|
1165 |
+ 'welfare_value': welfare.welfare_value, |
|
1166 |
+ } |
|
1167 |
+ ) |
|
1174 | 1168 |
|
1175 | 1169 |
# Send template_message |
1176 | 1170 |
try: |
1177 | 1171 |
user = UserInfo.objects.get(user_id=contribution.user_id, status=True) |
1178 | 1172 |
except UserInfo.DoesNotExist: |
1179 | 1173 |
return response(UserStatusCode.USER_NOT_FOUND) |
1174 |
+ |
|
1180 | 1175 |
try: |
1181 | 1176 |
act = MemberActivityInfo.objects.get(activity_id=contribution.activity_id, status=True) |
1182 | 1177 |
except MemberActivityInfo.DoesNotExist: |
1183 |
- return () |
|
1178 |
+ return (MemberActivityStatusCode.ACTIVITY_NOT_FOUND) |
|
1184 | 1179 |
|
1185 | 1180 |
data = { |
1186 | 1181 |
"first": { |
@@ -0,0 +1,18 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 3.2.16 on 2022-11-04 08:08 |
|
3 |
+ |
|
4 |
+from django.db import migrations |
|
5 |
+ |
|
6 |
+ |
|
7 |
+class Migration(migrations.Migration): |
|
8 |
+ |
|
9 |
+ dependencies = [ |
|
10 |
+ ('member', '0050_memberactivityinfo_contribution_content_placeholder'), |
|
11 |
+ ] |
|
12 |
+ |
|
13 |
+ operations = [ |
|
14 |
+ migrations.AlterUniqueTogether( |
|
15 |
+ name='memberactivitycontributionwelfareunlockinginfo', |
|
16 |
+ unique_together={('brand_id', 'activity_id', 'welfare_id', 'user_id')}, |
|
17 |
+ ), |
|
18 |
+ ] |
@@ -859,7 +859,7 @@ class MemberActivityContributionWelfareUnlockingInfo(BaseModelMixin, BrandInfoMi |
||
859 | 859 |
verbose_name_plural = _(u'会员活动投稿福利解锁信息') |
860 | 860 |
|
861 | 861 |
unique_together = ( |
862 |
- ('activity_id', 'welfare_id', 'user_id'), |
|
862 |
+ ('brand_id', 'activity_id', 'welfare_id', 'user_id'), |
|
863 | 863 |
) |
864 | 864 |
|
865 | 865 |
def __unicode__(self): |