Browse Source

发布周视国内云存

zhangdongming 1 ngày trước cách đây
mục cha
commit
f0541951ac

+ 47 - 14
AdminController/ServeManagementController.py

@@ -312,13 +312,17 @@ class serveManagement(View):
         isSelect = request_dict.get('isSelect', None)
         if isSelect:
             # 获取套餐ID作为选项
-            store_meal_qs = Store_Meal.objects.all().values('id', 'bucket__bucket')
+            store_meal_qs = Store_Meal.objects.all().values('id', 'bucket__bucket').order_by('-add_time')
             return response.json(
                 0, {'list': CommonService.qs_to_list(store_meal_qs)})
 
         bucket = request_dict.get('bucket', None)
         pageNo = request_dict.get('pageNo', None)
         pageSize = request_dict.get('pageSize', None)
+        subscription_group = request_dict.get('subscription_group', None)
+        subscription_group_id = request_dict.get('subscription_group_id', None)
+        package_type = request_dict.get('package_type', None)
+        is_show = request_dict.get('is_show', None)
 
         if not all([pageNo, pageSize]):
             return response.json(444)
@@ -326,14 +330,41 @@ class serveManagement(View):
         page = int(pageNo)
         line = int(pageSize)
         try:
-            if bucket:  # 条件查询
-                bucket_id = VodBucketModel.objects.filter(
-                    bucket=bucket).values('id')[0]['id']
-                store_meal_qs = Store_Meal.objects.filter(
-                    bucket_id=bucket_id)
-            else:  # 查询全部
-                store_meal_qs = Store_Meal.objects.filter()
-            store_meal_val = store_meal_qs.values(
+            store_meal_qs = Store_Meal.objects.select_related(
+                'bucket'
+            ).prefetch_related(
+                'inapppurchasepackage',
+                'pay_type'
+            ).order_by('-add_time')
+
+            if bucket:
+                bucket_qs = VodBucketModel.objects.filter(bucket__contains=bucket).first()
+                if not bucket_qs:
+                    return response.json(0, {'list': [], 'total': 0})
+                bucket_id = bucket_qs.id
+                store_meal_qs = Store_Meal.objects.filter(bucket_id=bucket_id).order_by('-add_time')
+
+            if is_show is not None and is_show != '':
+                store_meal_qs = store_meal_qs.filter(is_show=int(is_show))
+
+            if package_type is not None and package_type != '':
+                store_meal_qs = store_meal_qs.filter(
+                    inapppurchasepackage__package_type=int(package_type)
+                ).distinct()
+
+            if subscription_group and subscription_group.strip():
+                store_meal_qs = store_meal_qs.filter(
+                    inapppurchasepackage__subscription_group__contains=subscription_group.strip()
+                ).distinct()
+
+            if subscription_group_id and subscription_group_id.strip():
+                store_meal_qs = store_meal_qs.filter(
+                    inapppurchasepackage__subscription_group_id__contains=subscription_group_id.strip()
+                ).distinct()
+
+            total = store_meal_qs.count()
+            paginated_qs = store_meal_qs[(page - 1) * line:page * line]
+            store_meal_val = paginated_qs.values(
                 'id',
                 'bucket__bucket',
                 'day',
@@ -350,11 +381,10 @@ class serveManagement(View):
                 'is_ai',
                 'pixel_level',
                 'add_time',
-                'update_time')
-            total = len(store_meal_val)
-            store_meals = store_meal_val[(page - 1) * line:page * line]
+                'update_time',
+                'is_4g')
             store_meal_list = []
-            for store_meal in store_meals:
+            for store_meal in store_meal_val:
                 store_meal_id = store_meal['id']
                 # 获取支付方式列表
                 pay_type_list = [
@@ -396,6 +426,7 @@ class serveManagement(View):
                     'subscription_group': subscription_group,
                     'subscription_group_id': subscription_group_id,
                     'package_type': package_type,
+                    'is_4g':store_meal['is_4g'],
                     'addTime': store_meal['add_time'].strftime("%Y-%m-%d %H:%M:%S"),
                     'updTime': store_meal['update_time'].strftime("%Y-%m-%d %H:%M:%S"),
                 })
@@ -432,6 +463,7 @@ class serveManagement(View):
         subscription_group_id = request_dict.get('subscription_group_id', '')
         package_type = int(request_dict.get('package_type', 0))
         isEdit = request_dict.get('isEdit', None)
+        is_4g = int(request_dict.get('is_4g', 0))
 
         if not all([bucket, pay_type, price, currency, symbol]):
             return response.json(444)
@@ -454,7 +486,8 @@ class serveManagement(View):
                 'symbol': symbol,
                 'is_show': is_show,
                 'is_ai': is_ai,
-                'pixel_level': pixel_level
+                'pixel_level': pixel_level,
+                'is_4g': is_4g
             }
             if isEdit:
                 if not storeMealID:

+ 19 - 3
Controller/CloudStorage.py

@@ -29,6 +29,7 @@ from Ansjer.config import SERVER_DOMAIN, PAYPAL_CRD, SERVER_DOMAIN_SSL, \
 from Controller.CheckUserData import DataValid
 from Controller.CloudPhoto.CloudServiceController import CloudServiceController
 from Controller.PaymentCycle import Paypal
+from Controller.UserDevice.DeviceVersionInfoController import DeviceVersionInfoView
 from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, UID_Bucket, StsCrdModel, \
     ExperienceContextModel, Pay_Type, CDKcontextModel, Device_User, SysMsgModel, Unused_Uid_Meal, PromotionRuleModel, \
     VideoPlaybackTimeModel, CouponModel, VodBucketModel, VodHlsSummary, VodHlsTagType, UidSetModel, AiService, \
@@ -209,7 +210,7 @@ class CloudStorageView(View):
             return response.json(0)
         try:
             # 查询设备像素
-            uid_set_qs = UidSetModel.objects.filter(uid=uid).values('ucode', 'is_ai')
+            uid_set_qs = UidSetModel.objects.filter(uid=uid).values('ucode', 'is_ai', 'mobile_4g', 'version')
             if not uid_set_qs.exists():
                 return response.json(173)
             ucode = uid_set_qs[0]['ucode']
@@ -220,17 +221,29 @@ class CloudStorageView(View):
                 else:
                     dpi_flag = int(ucode[-5])
             pixel_level = 1 if ucode and dpi_flag >= 8 else 0
+
+            # 查询是否为4G设备
+            is_4g = 0
+
+            ver = uid_set_qs[0]['version']
+            if ver:
+                ver = ver.replace('V', '')
+
+            d_ver = DeviceVersionInfoView.cache_device_version_info(ucode, ver)
+            if d_ver:
+                is_4g = 1 if d_ver['has_4g_cloud'] == 1 else 0
+
             store_qs = Store_Meal.objects.filter(Q(lang__lang=lang), Q(is_show=0), ~Q(pay_type='11'))  # 过滤激活码、隐藏套餐
             experience_context_qs = ExperienceContextModel.objects.filter(uid=uid, experience_type=0)
 
             ios_meal = None
             if mold:
                 store_qs = store_qs.filter(bucket__mold=mold)
-                if uid in ['5Z1LZLK7D5Y6WKDE111A','7ZB7V8B5LA48K1MC111A','4XES12WGN9D9KLEJ111A']:
+                if uid in ['5Z1LZLK7D5Y6WKDE111A', '7ZB7V8B5LA48K1MC111A', '4XES12WGN9D9KLEJ111A']:
                     ios_meal = store_qs  # 提审测试UID
 
             # 没体验过的设备只返回体验套餐,体验过的不返回体验套餐
-            if experience_context_qs.exists() and ios_meal is None:
+            if experience_context_qs.exists() or is_4g == 1:
                 if not is_ai:  # 返回云存套餐
                     store_qs = store_qs.filter(~Q(pay_type='10'), Q(is_ai=0))  # 筛选像素等级
                 else:  # 返回云存+AI套餐
@@ -243,6 +256,9 @@ class CloudStorageView(View):
                 if CONFIG_INFO != CONFIG_CN:  # 国内生产环境不筛选像素 加载所有上架套餐
                     store_qs = store_qs.filter(Q(pixel_level=pixel_level))
 
+                # 根据是否支持4g过滤设备
+                store_qs = store_qs.filter(is_4g=is_4g)
+
                 # 判断是否支持内购周期付款
                 if is_ios and version.parse(ios_version) >= version.parse("15.0"):
                     store_qs = store_qs.filter(pay_type=5, app_type=app_type)

+ 19 - 3
Controller/EquipmentManagerV3.py

@@ -17,6 +17,7 @@ from Controller.DeviceConfirmRegion import Device_Region
 from Controller.SensorGateway.EquipmentFamilyController import EquipmentFamilyView
 from Controller.UnicomCombo.UnicomComboController import UnicomComboView
 from Controller.UnicomCombo.WXTechController import WXTechControllerView
+from Controller.UserDevice.DeviceVersionInfoController import DeviceVersionInfoView
 from Model.models import Device_Info, UID_Bucket, UID_Preview, UidSetModel, UidChannelSetModel, \
     Device_User, iotdeviceInfoModel, UIDCompanySerialModel, UnicomDeviceInfo, CountryModel, \
     DeviceCloudPhotoInfo, UidPushModel, ExperienceContextModel, LogModel, UserAudioVideoPush, UIDModel
@@ -884,16 +885,31 @@ class EquipmentManagerV3(View):
             p['View_Password'] = self.encrypt_pwd(p['View_Password'])
 
             # 判断设备是否支持4G和查询移动侦测状态
-            uid_set_qs = UidSetModel.objects.filter(uid=p['UID']).values('mobile_4g', 'detect_status')
+            uid_set_qs = UidSetModel.objects.filter(uid=p['UID']).values('detect_status', 'ucode', 'version')
             if uid_set_qs.exists():
                 uid_set_qs = uid_set_qs.first()
-                if uid_set_qs['mobile_4g'] == 1:
-                    p['isCameraOpenCloud'] = 0
+                p['has_4g_cloud'] = self.get_device_is_4G(uid_set_qs['ucode'], uid_set_qs['version'])
+                if p['has_4g_cloud'] == 1:
+                    p['IsCameraOpenCloud'] = 1
                 p['NotificationMode'] = uid_set_qs['detect_status']
             data.append(p)
         result = data
         return response.json(0, result)
 
+    @staticmethod
+    def get_device_is_4G(ucode, ver):
+        try:
+            if not all([ucode, ver]):
+                return 0
+            ver = ver.replace('V', '')
+            d_ver = DeviceVersionInfoView.cache_device_version_info(ucode, ver)
+            if d_ver:
+                return 1 if d_ver['has_4g_cloud'] == 1 else 0
+            return 0
+        except Exception as e:
+            LOGGER.error(f'{ucode}首页返回配置信息异常{repr(e)}')
+            return 0
+
     @staticmethod
     def get_vod_use_status(uid, now_time):
         """

+ 1 - 0
Model/models.py

@@ -1689,6 +1689,7 @@ class Store_Meal(models.Model):
     pixel_level = models.SmallIntegerField(default=0, verbose_name='像素等级')  # 0:低于4k像素;1:大于等于4k像素
     is_ai = models.SmallIntegerField(default=0, verbose_name='是否支持AI')  # 0:不支持;1:支持
     app_type = models.SmallIntegerField(default=0, verbose_name='app类型')  # 1:ZosiSmart苹果; 2:Vsees苹果
+    is_4g = models.SmallIntegerField(default=0, verbose_name='是否支持4G')
 
     def __str__(self):
         return self.id