@@ -1111,6 +1111,11 @@ def member_activity_contribute_welfare_unlock(request, administrator): |
||
| 1111 | 1111 |
except MemberActivityContributionInfo.DoesNotExist: |
| 1112 | 1112 |
return response(MemberActivityContributionStatusCode.ACTIVITY_CONTRIBUTION_NOT_FOUND) |
| 1113 | 1113 |
|
| 1114 |
+ try: |
|
| 1115 |
+ welfare = MemberActivityContributionWelfareInfo.objects.get(welfare_id=welfare_id, status=True) |
|
| 1116 |
+ except MemberActivityContributionWelfareInfo.DoesNotExist: |
|
| 1117 |
+ return response(MemberActivityContributionWelfareStatusCode.ACTIVITY_CONTRIBUTION_WELFARE_NOT_FOUND) |
|
| 1118 |
+ |
|
| 1114 | 1119 |
MemberActivityContributionWelfareUnlockingInfo.objects.create( |
| 1115 | 1120 |
brand_id=administrator.brand_id, |
| 1116 | 1121 |
admin_id=admin_id, |
@@ -1118,6 +1123,8 @@ def member_activity_contribute_welfare_unlock(request, administrator): |
||
| 1118 | 1123 |
activity_id=contribution.activity_id, |
| 1119 | 1124 |
contribution_id=contribution_id, |
| 1120 | 1125 |
welfare_id=welfare_id, |
| 1126 |
+ welfare_type=welfare.welfare_type, |
|
| 1127 |
+ welfare_value=welfare.welfare_value, |
|
| 1121 | 1128 |
) |
| 1122 | 1129 |
|
| 1123 | 1130 |
return response(200, 'Unlock Member Activity Contribute Welfare Success', u'解锁会员活动投稿福利成功') |
@@ -752,22 +752,22 @@ def activity_contribute_welfare_unlocking_handled(request): |
||
| 752 | 752 |
unlocking.is_handled = True |
| 753 | 753 |
unlocking.save() |
| 754 | 754 |
|
| 755 |
- # TODO: 积分相关逻辑在这里处理? |
|
| 756 |
- try: |
|
| 757 |
- user = UserInfo.objects.select_for_update().get(user_id=user_id, status=True) |
|
| 758 |
- except UserInfo.DoesNotExist: |
|
| 759 |
- return response(UserStatusCode.USER_NOT_FOUND) |
|
| 755 |
+ if unlocking.welfare_type == MemberActivityContributionWelfareUnlockingInfo.WELFARE_INTEGRAL: |
|
| 756 |
+ try: |
|
| 757 |
+ user = UserInfo.objects.select_for_update().get(user_id=user_id, status=True) |
|
| 758 |
+ except UserInfo.DoesNotExist: |
|
| 759 |
+ return response(UserStatusCode.USER_NOT_FOUND) |
|
| 760 | 760 |
|
| 761 |
- user.integral += unlocking.welfare_value |
|
| 762 |
- user.save() |
|
| 761 |
+ user.integral += unlocking.welfare_value |
|
| 762 |
+ user.save() |
|
| 763 | 763 |
|
| 764 |
- UserIntegralIncomeExpensesInfo.objects.create( |
|
| 765 |
- brand_id=brand_id, |
|
| 766 |
- user_id=user_id, |
|
| 767 |
- integral_from=UserIntegralIncomeExpensesInfo.MEMBER_ACTIVITY_CONTRIBUTION_WELFARE, |
|
| 768 |
- integral=unlocking.welfare_value, |
|
| 769 |
- final_integral=user.integral, |
|
| 770 |
- remark=unlocking.id, |
|
| 771 |
- ) |
|
| 764 |
+ UserIntegralIncomeExpensesInfo.objects.create( |
|
| 765 |
+ brand_id=brand_id, |
|
| 766 |
+ user_id=user_id, |
|
| 767 |
+ integral_from=UserIntegralIncomeExpensesInfo.MEMBER_ACTIVITY_CONTRIBUTION_WELFARE, |
|
| 768 |
+ integral=unlocking.welfare_value, |
|
| 769 |
+ final_integral=user.integral, |
|
| 770 |
+ remark=unlocking.id, |
|
| 771 |
+ ) |
|
| 772 | 772 |
|
| 773 | 773 |
return response(200, 'Update Member Activity Contribute Welfare Unblocking Success', u'处理会员活动投稿福利解锁成功') |
@@ -110,7 +110,7 @@ class MemberActivityContributionWelfareInfoAdmin(admin.ModelAdmin): |
||
| 110 | 110 |
|
| 111 | 111 |
|
| 112 | 112 |
class MemberActivityContributionWelfareUnlockingInfoAdmin(admin.ModelAdmin): |
| 113 |
- list_display = ('unlocking_id', 'admin_id', 'user_id', 'activity_id', 'contribution_id', 'welfare_id', 'welfare_value', 'name', 'phone', 'address', 'tracking_number', 'is_handled', 'status', 'created_at', 'updated_at')
|
|
| 113 |
+ list_display = ('unlocking_id', 'admin_id', 'user_id', 'activity_id', 'contribution_id', 'welfare_id', 'welfare_type', 'welfare_value', 'name', 'phone', 'address', 'tracking_number', 'is_handled', 'status', 'created_at', 'updated_at')
|
|
| 114 | 114 |
list_filter = ('admin_id', 'activity_id', 'welfare_id', 'is_handled', 'status')
|
| 115 | 115 |
|
| 116 | 116 |
|
@@ -0,0 +1,19 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 3.2.16 on 2022-10-27 10:46 |
|
| 3 |
+ |
|
| 4 |
+from django.db import migrations, models |
|
| 5 |
+ |
|
| 6 |
+ |
|
| 7 |
+class Migration(migrations.Migration): |
|
| 8 |
+ |
|
| 9 |
+ dependencies = [ |
|
| 10 |
+ ('member', '0046_memberactivitycontributionwelfareunlockinginfo_welfare_value'),
|
|
| 11 |
+ ] |
|
| 12 |
+ |
|
| 13 |
+ operations = [ |
|
| 14 |
+ migrations.AddField( |
|
| 15 |
+ model_name='memberactivitycontributionwelfareunlockinginfo', |
|
| 16 |
+ name='welfare_type', |
|
| 17 |
+ field=models.IntegerField(choices=[(0, '实物'), (1, '积分'), (2, '虚拟')], db_index=True, default=0, help_text='福利类型', verbose_name='welfare_type'), |
|
| 18 |
+ ), |
|
| 19 |
+ ] |
@@ -795,6 +795,7 @@ class MemberActivityContributionWelfareInfo(BaseModelMixin, BrandInfoMixin): |
||
| 795 | 795 |
|
| 796 | 796 |
|
| 797 | 797 |
class MemberActivityContributionWelfareUnlockingInfo(BaseModelMixin, BrandInfoMixin): |
| 798 |
+ WELFARE_INTEGRAL = 1 |
|
| 798 | 799 |
WELFARE_TYPE = ( |
| 799 | 800 |
(0, u'实物'), |
| 800 | 801 |
(1, u'积分'), |
@@ -811,6 +812,7 @@ class MemberActivityContributionWelfareUnlockingInfo(BaseModelMixin, BrandInfoMi |
||
| 811 | 812 |
contribution_id = models.CharField(_(u'contribution_id'), max_length=32, blank=True, null=True, help_text=u'投稿唯一标识', db_index=True) |
| 812 | 813 |
|
| 813 | 814 |
welfare_id = models.CharField(_(u'welfare_id'), max_length=32, blank=True, null=True, help_text=u'福利唯一标识', db_index=True) |
| 815 |
+ welfare_type = models.IntegerField(_(u'welfare_type'), choices=WELFARE_TYPE, default=0, help_text=u'福利类型', db_index=True) |
|
| 814 | 816 |
welfare_value = models.IntegerField(_(u'welfare_value'), default=0, help_text=_(u'福利数量')) |
| 815 | 817 |
|
| 816 | 818 |
name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'姓名') |