Просмотр исходного кода

更新优惠券弹窗,红点标记功能

lang 3 лет назад
Родитель
Сommit
34a879c87d
1 измененных файлов с 67 добавлено и 9 удалено
  1. 67 9
      Controller/AppSetController.py

+ 67 - 9
Controller/AppSetController.py

@@ -12,13 +12,15 @@
 @Contact: chanjunkai@163.com
 """
 from Ansjer.config import SERVER_TYPE
-from Model.models import AppSetModel,PromotionRuleModel
+from Model.models import AppSetModel, PromotionRuleModel
 from django.views.generic.base import View
 from Object.RedisObject import RedisObject
 from Object.TokenObject import TokenObject
 from Service.ModelService import ModelService
-import time,json
+import time, json
 from Object.ResponseObject import ResponseObject
+
+
 class AppSetView(View):
     def get(self, request, *args, **kwargs):
         request.encoding = 'utf-8'
@@ -67,12 +69,66 @@ class AppSetView(View):
             if not app_set_qs[0]['content']:
                 return response.json(0)
             dict_json = json.loads(app_set_qs[0]['content'])
-            #加入促销弹窗
-            promotion = PromotionRuleModel.objects.filter(status=1).values('startTime','endTime','popups')
+
+            # 弹窗 后续根据数据库配置
+            dict_json['popups'] = {
+                'title': '20% off',
+                'content': 'on Cloud Storage Subscription',
+                'start_time': 1653275226,
+                'end_time': 1753275226,
+                'now_time': int(time.time())
+            }
+
+            # 红点标记 后续根据数据库配置
+            dict_json['red_dots'] = {
+                'cloud_storage':{
+                    'status':0,
+                    'start_time':0,
+                    'end_time':0,
+                },
+                'ai_detection': {
+                    'status': 0,
+                    'start_time': 0,
+                    'end_time': 0,
+                },
+                'coupon': {
+                    'status': 1,
+                    'start_time': 1653275226,
+                    'end_time': '1753275226',
+                },
+                'add': {
+                    'status': 0,
+                    'start_time': 0,
+                    'end_time': 0,
+                },
+                'setting': {
+                    'status': 0,
+                    'start_time': 0,
+                    'end_time': 0,
+                },
+                'my': {
+                    'status': 0,
+                    'start_time': 0,
+                    'end_time': 0,
+                },
+                'cloud_storage_purchases': {
+                    'status': 0,
+                    'start_time': 0,
+                    'end_time': 0,
+                },
+                'ai_detects_purchases': {
+                    'status': 0,
+                    'start_time': 0,
+                    'end_time': 0,
+                },
+            }
+
+            # 加入促销弹窗
+            promotion = PromotionRuleModel.objects.filter(status=1).values('startTime', 'endTime', 'popups')
             if promotion.exists():
                 dict_json['popupsStartTime'] = promotion[0]['startTime']
                 dict_json['popupsEndTime'] = promotion[0]['endTime']
-                dict_json['popupsContent'] = json.loads(promotion[0]['popups']).get(lang,'')
+                dict_json['popupsContent'] = json.loads(promotion[0]['popups']).get(lang, '')
                 dict_json['nowTime'] = int(time.time())
             if 'editionUpgrading' in dict_json:
                 if dict_json['editionUpgrading'] == 1:
@@ -82,9 +138,11 @@ class AppSetView(View):
                         dict_json['editionUpgrading'] = 'Upgrading, please sign in later'
                 else:
                     dict_json['editionUpgrading'] = ''
+
             return response.json(0, dict_json)
         except Exception as e:
-            return response.json(500, repr(e))
+            return response.json(500, "错误行数:{errLine}, 错误信息: {errmsg}".format(errLine=e.__traceback__.tb_lineno,
+                                                                              errmsg=repr(e)))
 
         # res = {}
         # res['grade'] = 1
@@ -115,7 +173,7 @@ class AppSetView(View):
         sm_qs = AppSetModel.objects.filter(appBundleId=appBundleId)
         count = sm_qs.count()
         nowTime = int(time.time())
-        if count>0:
+        if count > 0:
             sm_qs = sm_qs.values('id', 'appBundleId', 'content', 'addTime', 'updTime')
             return response.json(0, {'data': list(sm_qs), 'count': count})
         else:
@@ -137,7 +195,7 @@ class AppSetView(View):
         sm_qs = AppSetModel.objects.filter(appBundleId=appBundleId)
         redis = RedisObject()
         if SERVER_TYPE != "Ansjer.formal_settings":
-            key_id= "www"+appBundleId
+            key_id = "www" + appBundleId
         else:
             key_id = "test" + appBundleId
         redis.del_data(key=key_id)
@@ -145,4 +203,4 @@ class AppSetView(View):
             sm_qs.update(content=content, updTime=nowTime)
             return response.json(0)
         else:
-            return response.json(173)
+            return response.json(173)