:art: sendcustomwxamessage

huangqimin 5 jaren geleden
bovenliggende
commit
60a9724fa2
2 gewijzigde bestanden met toevoegingen van 21 en 0 verwijderingen
  1. 5 0
      account/models.py
  2. 16 0
      commands/management/commands/subscribe.py

+ 5 - 0
account/models.py

@@ -457,6 +457,11 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin):
457 457
             'level': self.level,
458 458
         }
459 459
 
460
+    @property
461
+    def sendcustomwxamessage(self):
462
+        # 关注公众号 + 未领保修卡 + 已绑定镜头
463
+        return self.subscribe and not self.has_membercard and self.shots_num
464
+
460 465
 
461 466
 class UserLoginLogInfo(BaseModelMixin):
462 467
     SUCCESS = 0

+ 16 - 0
commands/management/commands/subscribe.py

@@ -12,6 +12,7 @@ from pywe_user import get_user_info
12 12
 
13 13
 from account.models import UserInfo
14 14
 from mch.models import BrandInfo
15
+from pre.custom_message import sendcustomwxamessage
15 16
 from utils.redis.rkeys import SUBSCRIBE_USERINFO_LIST
16 17
 
17 18
 
@@ -77,6 +78,21 @@ class Command(CompatibilityBaseCommand):
77 78
                     })
78 79
                 else:
79 80
                     SubscribeUserInfo.objects.filter(extraid=brand_id, openid=openid).update(subscribe=subscribe)
81
+
80 82
                 UserInfo.objects.filter(unionid=unionid).update(openid=openid, subscribe=subscribe)
81 83
 
84
+                try:
85
+                    user = UserInfo.objects.get(unionid=unionid)
86
+                except UserInfo.DoesNotExist:
87
+                    continue
88
+
89
+                if user.sendcustomwxamessage:
90
+                    sendcustomwxamessage(
91
+                        openid='oK7eEjjqhoE6bTLX3k5Xa2reWzuI',
92
+                        miniappid='wx02c3038b13008270',
93
+                        pagepath='/pages/index/index',
94
+                        thumb_media_id=u'xizg0MLt4x4jSJ38mTpf4dzINBqOMwVbfe3DoNFZ1BoqJ9iVyhGk_dvqwVIHcvlo',
95
+                        title=u'测试一下'
96
+                    )
97
+
82 98
             close_old_connections()