浏览代码

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

lang 3 年之前
父节点
当前提交
34a879c87d
共有 1 个文件被更改,包括 67 次插入9 次删除
  1. 67 9
      Controller/AppSetController.py

+ 67 - 9
Controller/AppSetController.py

@@ -12,13 +12,15 @@
 @Contact: chanjunkai@163.com
 @Contact: chanjunkai@163.com
 """
 """
 from Ansjer.config import SERVER_TYPE
 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 django.views.generic.base import View
 from Object.RedisObject import RedisObject
 from Object.RedisObject import RedisObject
 from Object.TokenObject import TokenObject
 from Object.TokenObject import TokenObject
 from Service.ModelService import ModelService
 from Service.ModelService import ModelService
-import time,json
+import time, json
 from Object.ResponseObject import ResponseObject
 from Object.ResponseObject import ResponseObject
+
+
 class AppSetView(View):
 class AppSetView(View):
     def get(self, request, *args, **kwargs):
     def get(self, request, *args, **kwargs):
         request.encoding = 'utf-8'
         request.encoding = 'utf-8'
@@ -67,12 +69,66 @@ class AppSetView(View):
             if not app_set_qs[0]['content']:
             if not app_set_qs[0]['content']:
                 return response.json(0)
                 return response.json(0)
             dict_json = json.loads(app_set_qs[0]['content'])
             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():
             if promotion.exists():
                 dict_json['popupsStartTime'] = promotion[0]['startTime']
                 dict_json['popupsStartTime'] = promotion[0]['startTime']
                 dict_json['popupsEndTime'] = promotion[0]['endTime']
                 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())
                 dict_json['nowTime'] = int(time.time())
             if 'editionUpgrading' in dict_json:
             if 'editionUpgrading' in dict_json:
                 if dict_json['editionUpgrading'] == 1:
                 if dict_json['editionUpgrading'] == 1:
@@ -82,9 +138,11 @@ class AppSetView(View):
                         dict_json['editionUpgrading'] = 'Upgrading, please sign in later'
                         dict_json['editionUpgrading'] = 'Upgrading, please sign in later'
                 else:
                 else:
                     dict_json['editionUpgrading'] = ''
                     dict_json['editionUpgrading'] = ''
+
             return response.json(0, dict_json)
             return response.json(0, dict_json)
         except Exception as e:
         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 = {}
         # res['grade'] = 1
         # res['grade'] = 1
@@ -115,7 +173,7 @@ class AppSetView(View):
         sm_qs = AppSetModel.objects.filter(appBundleId=appBundleId)
         sm_qs = AppSetModel.objects.filter(appBundleId=appBundleId)
         count = sm_qs.count()
         count = sm_qs.count()
         nowTime = int(time.time())
         nowTime = int(time.time())
-        if count>0:
+        if count > 0:
             sm_qs = sm_qs.values('id', 'appBundleId', 'content', 'addTime', 'updTime')
             sm_qs = sm_qs.values('id', 'appBundleId', 'content', 'addTime', 'updTime')
             return response.json(0, {'data': list(sm_qs), 'count': count})
             return response.json(0, {'data': list(sm_qs), 'count': count})
         else:
         else:
@@ -137,7 +195,7 @@ class AppSetView(View):
         sm_qs = AppSetModel.objects.filter(appBundleId=appBundleId)
         sm_qs = AppSetModel.objects.filter(appBundleId=appBundleId)
         redis = RedisObject()
         redis = RedisObject()
         if SERVER_TYPE != "Ansjer.formal_settings":
         if SERVER_TYPE != "Ansjer.formal_settings":
-            key_id= "www"+appBundleId
+            key_id = "www" + appBundleId
         else:
         else:
             key_id = "test" + appBundleId
             key_id = "test" + appBundleId
         redis.del_data(key=key_id)
         redis.del_data(key=key_id)
@@ -145,4 +203,4 @@ class AppSetView(View):
             sm_qs.update(content=content, updTime=nowTime)
             sm_qs.update(content=content, updTime=nowTime)
             return response.json(0)
             return response.json(0)
         else:
         else:
-            return response.json(173)
+            return response.json(173)