新增发送模板消息

FFIB 8 maanden geleden
bovenliggende
commit
2ba6124b69
2 gewijzigde bestanden met toevoegingen van 21 en 1 verwijderingen
  1. 20 1
      api/lensman/contract_admin_views.py
  2. 1 0
      kodo/settings.py

+ 20 - 1
api/lensman/contract_admin_views.py

@@ -11,8 +11,11 @@ from utils.tencentcloud.ess import describe_file_urls
11 11
 from api.lensman import contract_mp_views
12 12
 
13 13
 from apps.contract.models import LensmanContributionContractInfo
14
-from account.models import LensmanInfo
14
+from account.models import LensmanInfo, UserInfo
15
+from member.models import MemberActivityInfo
16
+from pre.custom_message import sendwxasubscribemessage
15 17
 
18
+WECHAT = settings.WECHAT
16 19
 
17 20
 @logit(res=True)
18 21
 @check_admin
@@ -43,6 +46,8 @@ def start_contribution_contract_sign_api(request, administrator):
43 46
     contribution_id = request.POST.get('contribution_id', '')
44 47
 
45 48
     lensman = LensmanInfo.objects.get(user_id=user_id)
49
+    act = MemberActivityInfo.objects.get(activity_id=activity_id)
50
+    user = UserInfo.objects.get(user_id=user_id)
46 51
 
47 52
     contract, _ = LensmanContributionContractInfo.objects.update_or_create(
48 53
         user_id=user_id,
@@ -65,4 +70,18 @@ def start_contribution_contract_sign_api(request, administrator):
65 70
     # 发起签署流程
66 71
     flow_status = contract_mp_views.start_contribution_contract_flow(flow_id)
67 72
 
73
+    data = {
74
+        "thing7": {
75
+            "value": act.title[:20],
76
+        },
77
+        "thing6": {
78
+            "value": lensman.identity_card_name + u"的投稿合同",
79
+        },
80
+    }
81
+
82
+    wxcfg = WECHAT.get('MINIAPP', {})
83
+    appid = wxcfg.get('appID')
84
+
85
+    res = sendwxasubscribemessage(openid=user.openid_miniapp, template_id=settings.TEMPLATE_ID_CONTRIBUTION_CONTRACT, data=data, miniprogram_state=None, lang=None, page='/pages/member/activity/activity?activity_id={}'.format(act.activity_id))
86
+
68 87
     return response(200, 'Start Contribution Contract Sign Success', u'发起投稿授权书签署成功', data={})

+ 1 - 0
kodo/settings.py

@@ -459,6 +459,7 @@ TEMPLATE_ID_COMPLEMENT = 'DXJzPqLPaxa-G2IjAQnv-5Lbca63OZwIqANwvBbMm5I'
459 459
 TEMPLATE_ID_MAINTENANCE = '8RnRElbNaTiAgCvWdTz0njeed060v9szOcVD2ilx5dk'
460 460
 TEMPLATE_ID_UNLOCKING_WELFARE = 'pgJgnPxIOL35YnCR5NYEIwTryHtodUmM462KF8pMqxY'
461 461
 TEMPLATE_ID_TENANCY = '_x-_jog64rYJecb_2yh8Zcy3czomKVuvjKHO-CDrrDo'
462
+TEMPLATE_ID_CONTRIBUTION_CONTRACT = 'rW26D1ncbu0IPWPO9uzXOWxTPtf4eqB5UMrsNFD3WoY'
462 463
 
463 464
 KODO_BRAND_NAME = ''
464 465