Browse Source

套餐接口新增苹果内购相关数据

locky 1 year ago
parent
commit
d63d8060ec
1 changed files with 36 additions and 9 deletions
  1. 36 9
      AdminController/ServeManagementController.py

+ 36 - 9
AdminController/ServeManagementController.py

@@ -23,7 +23,8 @@ from Controller.UnicomCombo.UnicomComboTaskController import UnicomComboTaskView
 from Model.models import VodBucketModel, CDKcontextModel, Store_Meal, Order_Model, \
 from Model.models import VodBucketModel, CDKcontextModel, Store_Meal, Order_Model, \
     UID_Bucket, ExperienceContextModel, Lang, CloudLogModel, UidSetModel, Unused_Uid_Meal, \
     UID_Bucket, ExperienceContextModel, Lang, CloudLogModel, UidSetModel, Unused_Uid_Meal, \
     Device_Info, DeviceTypeModel, UnicomComboOrderInfo, AiService, CountryModel, CouponLang, CouponConfigModel, \
     Device_Info, DeviceTypeModel, UnicomComboOrderInfo, AiService, CountryModel, CouponLang, CouponConfigModel, \
-    CouponCombo, CouponModel, Device_User, AbnormalOrder, DailyReconciliation, StsCrdModel, LogModel
+    CouponCombo, CouponModel, Device_User, AbnormalOrder, DailyReconciliation, StsCrdModel, LogModel, \
+    InAppPurchasePackage
 from Object.ResponseObject import ResponseObject
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Object.TokenObject import TokenObject
 from Object.UnicomObject import UnicomObjeect
 from Object.UnicomObject import UnicomObjeect
@@ -370,20 +371,31 @@ class serveManagement(View):
                 'is_show',
                 'is_show',
                 'is_ai',
                 'is_ai',
                 'pixel_level',
                 'pixel_level',
-                'product_id',
                 'add_time',
                 'add_time',
                 'update_time')
                 'update_time')
             total = len(store_meal_val)
             total = len(store_meal_val)
             store_meals = store_meal_val[(page - 1) * line:page * line]
             store_meals = store_meal_val[(page - 1) * line:page * line]
             store_meal_list = []
             store_meal_list = []
             for store_meal in store_meals:
             for store_meal in store_meals:
+                store_meal_id = store_meal['id']
                 # 获取支付方式列表
                 # 获取支付方式列表
                 pay_type_list = [
                 pay_type_list = [
                     pay_type['id'] for pay_type in Store_Meal.objects.get(
                     pay_type['id'] for pay_type in Store_Meal.objects.get(
-                        id=store_meal['id']).pay_type.values('id')]
+                        id=store_meal_id).pay_type.values('id')]
+
+                # 查询product_id
+                product_id = ''
+                in_app_purchase_qs = InAppPurchasePackage.objects.filter(rank__id=store_meal_id).\
+                    values('product_id', 'subscription_group', 'subscription_group_id', 'package_type')
+                if in_app_purchase_qs.exists():
+                    product_id = in_app_purchase_qs[0]['product_id']
+                    subscription_group = in_app_purchase_qs[0]['subscription_group']
+                    subscription_group_id = in_app_purchase_qs[0]['subscription_group_id']
+                    package_type = in_app_purchase_qs[0]['package_type']
+
                 # 组织响应数据
                 # 组织响应数据
                 store_meal_list.append({
                 store_meal_list.append({
-                    'storeMealID': store_meal['id'],
+                    'storeMealID': store_meal_id,
                     'bucket': store_meal['bucket__bucket'],
                     'bucket': store_meal['bucket__bucket'],
                     'day': store_meal['day'],
                     'day': store_meal['day'],
                     'expire': store_meal['expire'],
                     'expire': store_meal['expire'],
@@ -399,7 +411,10 @@ class serveManagement(View):
                     'is_show': store_meal['is_show'],
                     'is_show': store_meal['is_show'],
                     'is_ai': store_meal['is_ai'],
                     'is_ai': store_meal['is_ai'],
                     'pixel_level': store_meal['pixel_level'],
                     'pixel_level': store_meal['pixel_level'],
-                    'product_id': store_meal['product_id'],
+                    'product_id': product_id,
+                    'subscription_group': subscription_group,
+                    'subscription_group_id': subscription_group_id,
+                    'package_type': package_type,
                     'addTime': store_meal['add_time'].strftime("%Y-%m-%d %H:%M:%S"),
                     'addTime': store_meal['add_time'].strftime("%Y-%m-%d %H:%M:%S"),
                     'updTime': store_meal['update_time'].strftime("%Y-%m-%d %H:%M:%S"),
                     'updTime': store_meal['update_time'].strftime("%Y-%m-%d %H:%M:%S"),
                 })
                 })
@@ -432,6 +447,9 @@ class serveManagement(View):
         is_ai = int(request_dict.get('is_ai', 0))
         is_ai = int(request_dict.get('is_ai', 0))
         pixel_level = int(request_dict.get('pixel_level', 0))
         pixel_level = int(request_dict.get('pixel_level', 0))
         product_id = request_dict.get('product_id', '')
         product_id = request_dict.get('product_id', '')
+        subscription_group = request_dict.get('subscription_group', '')
+        subscription_group_id = request_dict.get('subscription_group_id', '')
+        package_type = int(request_dict.get('package_type', 0))
         isEdit = request_dict.get('isEdit', None)
         isEdit = request_dict.get('isEdit', None)
 
 
         if not all([bucket, pay_type, price, currency, symbol]):
         if not all([bucket, pay_type, price, currency, symbol]):
@@ -454,8 +472,7 @@ class serveManagement(View):
                 'symbol': symbol,
                 'symbol': symbol,
                 'is_show': is_show,
                 'is_show': is_show,
                 'is_ai': is_ai,
                 'is_ai': is_ai,
-                'pixel_level': pixel_level,
-                'product_id': product_id
+                'pixel_level': pixel_level
             }
             }
             if isEdit:
             if isEdit:
                 if not storeMealID:
                 if not storeMealID:
@@ -464,9 +481,19 @@ class serveManagement(View):
                     id=storeMealID).update(
                     id=storeMealID).update(
                     **store_meal_data)
                     **store_meal_data)
                 Store_Meal.objects.get(id=storeMealID).pay_type.set(pay_type)
                 Store_Meal.objects.get(id=storeMealID).pay_type.set(pay_type)
+                # 更新苹果内购套餐
+                InAppPurchasePackage.objects.filter(rank__id=storeMealID).\
+                    update(
+                    product_id=product_id, subscription_group=subscription_group,
+                    subscription_group_id=subscription_group_id, package_type=package_type)
             else:
             else:
-                Store_Meal.objects.create(
-                    **store_meal_data).pay_type.set(pay_type)
+                store_meal = Store_Meal.objects.create(**store_meal_data).pay_type.set(pay_type)
+                # 新增苹果内购套餐
+                if any([product_id, subscription_group, subscription_group_id, package_type]):
+                    store_meal_id = store_meal.id
+                    InAppPurchasePackage.objects.create(
+                        rank_id=store_meal_id, subscription_group=subscription_group,
+                        subscription_group_id=subscription_group_id, package_type=package_type)
             return response.json(0)
             return response.json(0)
         except Exception as e:
         except Exception as e:
             print(e)
             print(e)