فهرست منبع

优化编辑苹果内购套餐数据

locky 1 سال پیش
والد
کامیت
978042cfbb
1فایلهای تغییر یافته به همراه10 افزوده شده و 4 حذف شده
  1. 10 4
      AdminController/ServeManagementController.py

+ 10 - 4
AdminController/ServeManagementController.py

@@ -485,10 +485,16 @@ class serveManagement(View):
                     **store_meal_data)
                 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)
+                in_app_purchase_qs = InAppPurchasePackage.objects.filter(rank__id=storeMealID)
+                if in_app_purchase_qs.exists():
+                    in_app_purchase_qs.update(
+                        product_id=product_id, subscription_group=subscription_group,
+                        subscription_group_id=subscription_group_id, package_type=package_type)
+                else:
+                    if any([product_id, subscription_group, subscription_group_id, package_type]):
+                        InAppPurchasePackage.objects.create(
+                            rank_id=storeMealID, subscription_group=subscription_group,
+                            subscription_group_id=subscription_group_id, package_type=package_type)
             else:
                 store_meal = Store_Meal.objects.create(**store_meal_data).pay_type.set(pay_type)
                 # 新增苹果内购套餐