d=activity_id, status=True)
+ if query:
+ logs = logs.filter(Q(lensman_name__icontains=query) | Q(lensman_phone__icontains=query))
+
+ count = logs.count()
+ logs, left = pagination(logs, page, num)
+ logs = [log.admindata for log in logs]
+
+ return response(200, 'Get Member Activity Data List Success', u'获取会员活动数据列表成功', data={
+ 'logs': logs,
+ 'count': count,
+ 'left': left,
+ })
+
+@check_admin
+def activity_integral_add(request, administrator):
+ activity_id = request.POST.get('activity_id', '')
+ user_id = request.POST.get('user_id', '')
+ lensman_id = request.POST.get('lensman_id', '')
+ integral = int(request.POST.get('integral', 0))
+ remark = request.POST.get('remark', '')
+ brand_id = request.POST.get('brand_id') or settings.KODO_DEFAULT_BRAND_ID
+
+ try:
+ user = UserInfo.objects.get(user_id=user_id, status=True)
+ except UserInfo.DoesNotExist:
+ return response(UserStatusCode.USER_NOT_FOUND)
+
+ try:
+ lensman = LensmanInfo.objects.get(lensman_id=lensman_id, status=True)
+ except LensmanInfo.DoesNotExist:
+ return response('400001', 'LensmanInfo Not Found', '摄影师不存在')
+
+ user.integral += integral
+ user.save()
+
+ LensmanIntegralIncomeExpensesInfo.objects.create(
+ brand_id=brand_id,
+ user_id=user_id,
+ integral=integral,
+ activity_id=activity_id,
+ remark=remark,
+ expired_at=lensman.end_date,
+ )
+
+ return response(200, 'Add Member Activity Integral Success', u'添加积分成功')
@@ -0,0 +1,82 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+ |
|
| 3 |
+from django.conf import settings |
|
| 4 |
+from django_logit import logit |
|
| 5 |
+from django.db.models import Q |
|
| 6 |
+from django_response import response |
|
| 7 |
+ |
|
| 8 |
+from account.models import LensmanInfo |
|
| 9 |
+from member.models import MemberActivityInfo, MemberActivityDataInfo, MemberActivitySignupInfo |
|
| 10 |
+from utils.error.errno_utils import MemberActivityStatusCode |
|
| 11 |
+ |
|
| 12 |
+@logit |
|
| 13 |
+def activity_data_submit(request): |
|
| 14 |
+ user_id = request.POST.get('user_id', '')
|
|
| 15 |
+ lensman_id = request.POST.get('lensman_id', '')
|
|
| 16 |
+ activity_id = request.POST.get('activity_id', '')
|
|
| 17 |
+ data_fields = request.POST.get('data_fields', '[]')
|
|
| 18 |
+ |
|
| 19 |
+ try: |
|
| 20 |
+ act = MemberActivityInfo.objects.get(activity_id=activity_id, status=True) |
|
| 21 |
+ except MemberActivityInfo.DoesNotExist: |
|
| 22 |
+ return response(MemberActivityStatusCode.ACTIVITY_NOT_FOUND) |
|
| 23 |
+ |
|
| 24 |
+ try: |
|
| 25 |
+ lensman = LensmanInfo.objects.get(lensman_id=lensman_id, status=True) |
|
| 26 |
+ except LensmanInfo.DoesNotExist: |
|
| 27 |
+ return response('400001', 'LensmanInfo Not Found', '摄影师不存在')
|
|
| 28 |
+ |
|
| 29 |
+ if lensman.is_expired: |
|
| 30 |
+ return response(40001, 'Lensman Has Expired', '摄影师合作已到期') |
|
| 31 |
+ |
|
| 32 |
+ MemberActivityDataInfo.objects.update_or_create(user_id=user_id, activity_id=activity_id, defaults={
|
|
| 33 |
+ 'title': act.title, |
|
| 34 |
+ 'lensman_id': lensman_id, |
|
| 35 |
+ 'lensman_name': lensman.name, |
|
| 36 |
+ 'lensman_phone': lensman.phone, |
|
| 37 |
+ 'data_fields': data_fields, |
|
| 38 |
+ }) |
|
| 39 |
+ |
|
| 40 |
+ return response(data={
|
|
| 41 |
+ 'activity': act.data(user_id), |
|
| 42 |
+ }) |
|
| 43 |
+ |
|
| 44 |
+ |
|
| 45 |
+@logit |
|
| 46 |
+def activity_data_detail(request): |
|
| 47 |
+ user_id = request.POST.get('user_id', '')
|
|
| 48 |
+ activity_id = request.POST.get('activity_id', '')
|
|
| 49 |
+ |
|
| 50 |
+ try: |
|
| 51 |
+ data_info = MemberActivityDataInfo.objects.get(user_id=user_id, activity_id=activity_id, status=True) |
|
| 52 |
+ except MemberActivityDataInfo.DoesNotExist: |
|
| 53 |
+ return response() |
|
| 54 |
+ |
|
| 55 |
+ return response(data={
|
|
| 56 |
+ 'data_info': data_info.data, |
|
| 57 |
+ }) |
|
| 58 |
+ |
|
| 59 |
+ |
|
| 60 |
+@logit |
|
| 61 |
+def activity_signup_message(request): |
|
| 62 |
+ user_id = request.POST.get('user_id', '')
|
|
| 63 |
+ |
|
| 64 |
+ lensman_acts = MemberActivityInfo.objects.values_list('activity_id', flat=True).filter(activity_section=4, status=True)
|
|
| 65 |
+ infos = MemberActivitySignupInfo.objects.filter(Q(user_id=user_id) & Q(activity_id__in=lensman_acts) & Q(is_read=False)).exclude(audit_status=MemberActivitySignupInfo.UNAUDITED) |
|
| 66 |
+ |
|
| 67 |
+ infos = [info.data for info in infos] |
|
| 68 |
+ |
|
| 69 |
+ return response(data={
|
|
| 70 |
+ 'messages': infos |
|
| 71 |
+ }) |
|
| 72 |
+ |
|
| 73 |
+@logit |
|
| 74 |
+def activity_signup_message_read(request): |
|
| 75 |
+ user_id = request.POST.get('user_id', '')
|
|
| 76 |
+ signup_id = request.POST.get('signup_id', '')
|
|
| 77 |
+ |
|
| 78 |
+ MemberActivitySignupInfo.objects.filter(user_id=user_id, signup_id=signup_id).update(is_read=True) |
|
| 79 |
+ |
|
| 80 |
+ return response(200, 'Activity Signup Message Has Read Success', '活动报名消息已读') |
|
| 81 |
+ |
|
| 82 |
+ |
@@ -0,0 +1,44 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+ |
|
| 3 |
+# Generated by Django 3.2.16 on 2024-03-27 07:50 |
|
| 4 |
+ |
|
| 5 |
+from django.db import migrations, models |
|
| 6 |
+ |
|
| 7 |
+ |
|
| 8 |
+class Migration(migrations.Migration): |
|
| 9 |
+ |
|
| 10 |
+ dependencies = [ |
|
| 11 |
+ ('member', '0069_auto_20240312_1350'),
|
|
| 12 |
+ ] |
|
| 13 |
+ |
|
| 14 |
+ operations = [ |
|
| 15 |
+ migrations.RemoveField( |
|
| 16 |
+ model_name='memberactivitysignupinfo', |
|
| 17 |
+ name='passed', |
|
| 18 |
+ ), |
|
| 19 |
+ migrations.AddField( |
|
| 20 |
+ model_name='memberactivityinfo', |
|
| 21 |
+ name='end_data_submit_date', |
|
| 22 |
+ field=models.DateField(blank=True, help_text='活动数据提交截止日期', null=True, verbose_name='end_data_submit_date'), |
|
| 23 |
+ ), |
|
| 24 |
+ migrations.AddField( |
|
| 25 |
+ model_name='memberactivityinfo', |
|
| 26 |
+ name='start_data_submit_date', |
|
| 27 |
+ field=models.DateField(blank=True, help_text='活动数据提交开始日期', null=True, verbose_name='start_data_submit_date'), |
|
| 28 |
+ ), |
|
| 29 |
+ migrations.AddField( |
|
| 30 |
+ model_name='memberactivitysignupinfo', |
|
| 31 |
+ name='audit_status', |
|
| 32 |
+ field=models.IntegerField(choices=[(0, '未审核'), (1, '已通过'), (2, '未通过')], db_index=True, default=0, help_text='审核状态', verbose_name='audit_status'), |
|
| 33 |
+ ), |
|
| 34 |
+ migrations.AddField( |
|
| 35 |
+ model_name='memberactivitysignupinfo', |
|
| 36 |
+ name='is_read', |
|
| 37 |
+ field=models.BooleanField(default=False, help_text='报名消息是否已读', verbose_name='is_read'), |
|
| 38 |
+ ), |
|
| 39 |
+ migrations.AlterField( |
|
| 40 |
+ model_name='memberactivityinfo', |
|
| 41 |
+ name='activity_section', |
|
| 42 |
+ field=models.IntegerField(choices=[(0, 'Tamron Life'), (1, 'Tamron LRC直播课'), (2, '会员投稿'), (3, '其他'), (4, '摄影师')], db_index=True, default=3, help_text='活动分区', verbose_name='activity_section'), |
|
| 43 |
+ ), |
|
| 44 |
+ ] |
@@ -379,7 +379,7 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin): |
||
| 379 | 379 |
(1, u'Tamron LRC直播课'), |
| 380 | 380 |
(2, u'会员投稿'), |
| 381 | 381 |
(3, u'其他'), |
| 382 |
- (4, u'会员投稿'), |
|
| 382 |
+ (4, u'摄影师'), |
|
| 383 | 383 |
) |
| 384 | 384 |
|
| 385 | 385 |
activity_id = ShortUUIDField(_(u'activity_id'), max_length=32, blank=True, help_text=u'活动唯一标识', db_index=True, unique=True) |
@@ -395,6 +395,8 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin): |
||
| 395 | 395 |
end_date = models.DateField(_(u'end_date'), blank=True, null=True, help_text=u'活动报名截止日期') |
| 396 | 396 |
start_display_date = models.DateField(_(u'start_display_date'), blank=True, null=True, help_text=u'活动展示开始日期') |
| 397 | 397 |
end_display_date = models.DateField(_(u'end_display_date'), blank=True, null=True, help_text=u'活动展示截止日期') |
| 398 |
+ start_data_submit_date = models.DateField(_(u'start_data_submit_date'), blank=True, null=True, help_text=u'活动数据提交开始日期') |
|
| 399 |
+ end_data_submit_date = models.DateField(_(u'end_data_submit_date'), blank=True, null=True, help_text=u'活动数据提交截止日期') |
|
| 398 | 400 |
|
| 399 | 401 |
city = models.CharField(_(u'city'), max_length=255, blank=True, default='', help_text=u'活动城市') |
| 400 | 402 |
location = models.CharField(_(u'location'), max_length=255, blank=True, default='', help_text=u'活动地点') |
@@ -507,7 +509,7 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin): |
||
| 507 | 509 |
return MemberActivityContributionInfo.objects.filter(user_id=user_id, activity_id=self.activity_id, status=True).exists() |
| 508 | 510 |
|
| 509 | 511 |
def is_signup_passed(self, user_id): |
| 510 |
- return MemberActivitySignupInfo.objects.filter(user_id=user_id, activity_id=self.activity_id, passed=True, status=True).exists() |
|
| 512 |
+ return MemberActivitySignupInfo.objects.filter(user_id=user_id, activity_id=self.activity_id, audit_status=MemberActivitySignupInfo.PASSED, status=True).exists() |
|
| 511 | 513 |
|
| 512 | 514 |
@property |
| 513 | 515 |
def welfares(self): |
@@ -544,6 +546,8 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin): |
||
| 544 | 546 |
'end_date': tc.local_date_string(self.end_date), |
| 545 | 547 |
'start_display_date': tc.local_date_string(self.start_display_date), |
| 546 | 548 |
'end_display_date': tc.local_date_string(self.end_display_date), |
| 549 |
+ 'start_data_submit_date': tc.local_date_string(self.start_data_submit_date), |
|
| 550 |
+ 'end_data_submit_date': tc.local_date_string(self.end_data_submit_date), |
|
| 547 | 551 |
'city': self.city, |
| 548 | 552 |
'location': self.location, |
| 549 | 553 |
'lat': self.lat, |
@@ -590,6 +594,8 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin): |
||
| 590 | 594 |
'end_date': tc.local_date_string(self.end_date), |
| 591 | 595 |
'start_display_date': tc.local_date_string(self.start_display_date), |
| 592 | 596 |
'end_display_date': tc.local_date_string(self.end_display_date), |
| 597 |
+ 'start_data_submit_date': tc.local_date_string(self.start_data_submit_date), |
|
| 598 |
+ 'end_data_submit_date': tc.local_date_string(self.end_data_submit_date), |
|
| 593 | 599 |
'city': self.city, |
| 594 | 600 |
'location': self.location, |
| 595 | 601 |
'lat': self.lat, |
@@ -638,6 +644,8 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin): |
||
| 638 | 644 |
'end_date': tc.local_date_string(self.end_date), |
| 639 | 645 |
'start_display_date': tc.local_date_string(self.start_display_date), |
| 640 | 646 |
'end_display_date': tc.local_date_string(self.end_display_date), |
| 647 |
+ 'start_data_submit_date': tc.local_date_string(self.start_data_submit_date), |
|
| 648 |
+ 'end_data_submit_date': tc.local_date_string(self.end_data_submit_date), |
|
| 641 | 649 |
'city': self.city, |
| 642 | 650 |
'location': self.location, |
| 643 | 651 |
'lat': self.lat, |
@@ -685,6 +693,8 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin): |
||
| 685 | 693 |
'end_date': tc.local_date_string(self.end_date), |
| 686 | 694 |
'start_display_date': tc.local_date_string(self.start_display_date), |
| 687 | 695 |
'end_display_date': tc.local_date_string(self.end_display_date), |
| 696 |
+ 'start_data_submit_date': tc.local_date_string(self.start_data_submit_date), |
|
| 697 |
+ 'end_data_submit_date': tc.local_date_string(self.end_data_submit_date), |
|
| 688 | 698 |
'city': self.city, |
| 689 | 699 |
'location': self.location, |
| 690 | 700 |
'lat': self.lat, |
@@ -723,6 +733,16 @@ class MemberActivityInfo(BaseModelMixin, BrandInfoMixin): |
||
| 723 | 733 |
|
| 724 | 734 |
|
| 725 | 735 |
class MemberActivitySignupInfo(BaseModelMixin, BrandInfoMixin): |
| 736 |
+ UNAUDITED = 0 |
|
| 737 |
+ PASSED = 1 |
|
| 738 |
+ UNPASSED = 2 |
|
| 739 |
+ |
|
| 740 |
+ AUDIT_STATUS = ( |
|
| 741 |
+ (UNAUDITED, '未审核'), |
|
| 742 |
+ (PASSED, '已通过'), |
|
| 743 |
+ (UNPASSED, '未通过'), |
|
| 744 |
+ ) |
|
| 745 |
+ |
|
| 726 | 746 |
signup_id = ShortUUIDField(_(u'signup_id'), max_length=32, blank=True, null=True, help_text=u'活动报名唯一标识', db_index=True, unique=True) |
| 727 | 747 |
|
| 728 | 748 |
user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True) |
@@ -738,10 +758,12 @@ class MemberActivitySignupInfo(BaseModelMixin, BrandInfoMixin): |
||
| 738 | 758 |
|
| 739 | 759 |
fields = JSONField(_(u'fields'), blank=True, null=True, default='[]', help_text=u'自定义报名字段') |
| 740 | 760 |
|
| 741 |
- passed = models.BooleanField(_(u'passed'), default=False, help_text=u'是否通过') |
|
| 761 |
+ audit_status = models.IntegerField(_(u'audit_status'), choices=AUDIT_STATUS, default=UNAUDITED, help_text=u'审核状态', db_index=True) |
|
| 742 | 762 |
|
| 743 | 763 |
is_signin = models.BooleanField(_(u'is_signin'), default=False, help_text=u'是否已签到') |
| 744 | 764 |
|
| 765 |
+ is_read = models.BooleanField(_(u'is_read'), default=False, help_text=u'报名消息是否已读') |
|
| 766 |
+ |
|
| 745 | 767 |
class Meta: |
| 746 | 768 |
verbose_name = _(u'会员活动报名信息') |
| 747 | 769 |
verbose_name_plural = _(u'会员活动报名信息') |
@@ -756,6 +778,7 @@ class MemberActivitySignupInfo(BaseModelMixin, BrandInfoMixin): |
||
| 756 | 778 |
@property |
| 757 | 779 |
def final_avatar(self): |
| 758 | 780 |
return self.avatar and self.avatar.replace(settings.QINIU_FILE_URL_BEFORE, settings.QINIU_FILE_URL_AFTER).replace(settings.QINIU_FILE_URL_BEFORE2, settings.QINIU_FILE_URL_AFTER) |
| 781 |
+ |
|
| 759 | 782 |
|
| 760 | 783 |
@property |
| 761 | 784 |
def data(self): |
@@ -767,7 +790,7 @@ class MemberActivitySignupInfo(BaseModelMixin, BrandInfoMixin): |
||
| 767 | 790 |
'name': self.name, |
| 768 | 791 |
'phone': self.phone, |
| 769 | 792 |
'fields': json.loads(self.fields) if self.fields else [], |
| 770 |
- 'passed': self.passed, |
|
| 793 |
+ 'audit_status': self.audit_status, |
|
| 771 | 794 |
} |
| 772 | 795 |
|
| 773 | 796 |
@property |
@@ -783,7 +806,7 @@ class MemberActivitySignupInfo(BaseModelMixin, BrandInfoMixin): |
||
| 783 | 806 |
'phone': self.phone, |
| 784 | 807 |
'fields': json.loads(self.fields) if self.fields else [], |
| 785 | 808 |
'is_signin': self.is_signin, |
| 786 |
- 'passed': self.passed, |
|
| 809 |
+ 'audit_status': self.audit_status, |
|
| 787 | 810 |
} |
| 788 | 811 |
|
| 789 | 812 |
class MemberActivityDataInfo(BaseModelMixin, BrandInfoMixin): |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 |
|
| 3 | 3 |
from django.conf.urls import url |
| 4 | 4 |
|
| 5 |
-from member import activity_mp_views |
|
| 5 |
+from member import activity_mp_views, lensman_activity_mp_views |
|
| 6 | 6 |
|
| 7 | 7 |
# activity |
| 8 | 8 |
urlpatterns = [ |
@@ -22,8 +22,8 @@ urlpatterns += [ |
||
| 22 | 22 |
|
| 23 | 23 |
# activity data |
| 24 | 24 |
urlpatterns += [ |
| 25 |
- url(r'^member/activity/data/submit$', activity_mp_views.activity_data_submit, name='mp_member_activity_data_submit'), # 会员活动数据提交 |
|
| 26 |
- url(r'^member/activity/data/detail$', activity_mp_views.activity_data_detail, name='mp_member_activity_data_detail'), # 获取会员活动报名信息 |
|
| 25 |
+ url(r'^member/activity/data/submit$', lensman_activity_mp_views.activity_data_submit, name='mp_member_activity_data_submit'), # 会员活动数据提交 |
|
| 26 |
+ url(r'^member/activity/data/detail$', lensman_activity_mp_views.activity_data_detail, name='mp_member_activity_data_detail'), # 获取会员活动报名信息 |
|
| 27 | 27 |
] |
| 28 | 28 |
|
| 29 | 29 |
|
@@ -36,3 +36,9 @@ urlpatterns += [ |
||
| 36 | 36 |
|
| 37 | 37 |
url(r'^member/activity/contribute/detail/lastest$', activity_mp_views.activity_contribute_detail_lastest, name='member_activity_contribute_detail_lastest'), |
| 38 | 38 |
] |
| 39 |
+ |
|
| 40 |
+#activity message |
|
| 41 |
+urlpatterns += [ |
|
| 42 |
+ url(r'^member/activity/signup/message$', lensman_activity_mp_views.activity_signup_message, name='mp_member_activity_signup_message'), |
|
| 43 |
+ url(r'^member/activity/signup/message/read$', lensman_activity_mp_views.activity_signup_message_read, name='mp_member_activity_signup_message_read'), |
|
| 44 |
+] |