校验是否绑定或解绑

FFIB 14 часов назад
Родитель
Сommit
a930108f66
1 измененных файлов с 9 добавлено и 6 удалено
  1. 9 6
      api/encrypt_views.py

+ 9 - 6
api/encrypt_views.py

@@ -15,7 +15,7 @@ from pywe_storage import RedisStorage
15 15
 from account.models import UserInfo
16 16
 from logs.models import MchInfoDecryptLogInfo, MchInfoEncryptLogInfo
17 17
 from marketcode.models import MarketCodeInfo
18
-from mch.models import ActivityInfo, BrandInfo, ConsumeShotUnbindingInfo, ModelInfo
18
+from mch.models import ActivityInfo, BrandInfo, ConsumeShotUnbindingInfo, ModelInfo, ConsumeInfoSubmitLogInfo
19 19
 from sales.models import LotteryCampaignInfo
20 20
 from utils.algorithm.b64 import b64_decrypt, b64_encrypt
21 21
 from utils.algorithm.caesar import caesar_decrypt, caesar_encrypt
@@ -257,6 +257,7 @@ def decrypt2(request, v='v2'):
257 257
         mdli.save()
258 258
 
259 259
     unbound = ConsumeShotUnbindingInfo.objects.filter(model_id=model.model_id, sn=sn, status=True).exists()
260
+    dupload = ConsumeInfoSubmitLogInfo.objects.filter(model_id=model.model_id, serialNo=sn, status=True).exists()
260 261
 
261 262
     if v == 'v1':
262 263
         has_unexpired_activity = False
@@ -266,13 +267,15 @@ def decrypt2(request, v='v2'):
266 267
         activities = ActivityInfo.objects.filter(status=True).order_by('-pk')
267 268
         coupon_infos = [act.coupon_info3 for act in activities if act.has_unexpired_activity(model.model_name)]
268 269
     
269
-    lotterys = LotteryCampaignInfo.objects.filter(status=True)
270
-   
271
-    if lotterys.exists():
272
-        active_lotterys = [lottery.data for lottery in lotterys if lottery.is_active() and model.model_uni_name in lottery.model_ids]
270
+    if dupload or unbound:  
271
+        lotterys = LotteryCampaignInfo.objects.filter(status=True)
272
+        if lotterys.exists():
273
+            active_lotterys = [lottery.data for lottery in lotterys if lottery.is_active() and model.model_uni_name in lottery.model_ids]
274
+        else:
275
+            active_lotterys = None
273 276
     else:
274 277
         active_lotterys = None
275
-
278
+    
276 279
     return response(200, data={
277 280
         'plaintext': plaintext,
278 281
         'lotterys': active_lotterys,