Эх сурвалжийг харах

后台云存套装转移日志

linhaohong 10 сар өмнө
parent
commit
d18ae664b5

+ 12 - 4
AdminController/ServeManagementController.py

@@ -6,6 +6,7 @@ import hashlib
 import time
 import time
 import uuid
 import uuid
 import json
 import json
+import logging
 
 
 import paypalrestsdk
 import paypalrestsdk
 import requests
 import requests
@@ -31,6 +32,7 @@ from Object.UnicomObject import UnicomObjeect
 from Object.utils.PayPalUtil import PayPalService
 from Object.utils.PayPalUtil import PayPalService
 from Service.CommonService import CommonService
 from Service.CommonService import CommonService
 
 
+LOGGER = logging.getLogger('info')
 
 
 class serveManagement(View):
 class serveManagement(View):
     def get(self, request, *args, **kwargs):
     def get(self, request, *args, **kwargs):
@@ -1854,12 +1856,16 @@ class serveManagement(View):
             if old_using_uid_bucket.exists():
             if old_using_uid_bucket.exists():
                 if old_using_uid_bucket.first().endTime < nowTime:
                 if old_using_uid_bucket.first().endTime < nowTime:
                     return response.json(10013)
                     return response.json(10013)
-            else:
-                if not old_unusing_uid_bucket.exists():
-                    return response.json(10017)
+            if not old_using_uid_bucket.exists() and not old_unusing_uid_bucket.exists():
+                return response.json(10017)
+
+            if old_using_uid_bucket.exists() and old_unusing_uid_bucket():
+                LOGGER.info(f'云存转移, orderID:{orderID}, 该订单同时出现在已使用和未使用数据库')
+                return response.json(10018)
 
 
             # 订单套餐未使用
             # 订单套餐未使用
-            if old_unusing_uid_bucket.exists():
+            elif old_unusing_uid_bucket.exists():
+                LOGGER.info(f'云存转移, orderID:{orderID}, 该订单套餐在原设备未使用')
                 with transaction.atomic():
                 with transaction.atomic():
                     # 旧设备不包含 ai
                     # 旧设备不包含 ai
                     if old_unusing_uid_bucket.filter(is_ai=1).exists():
                     if old_unusing_uid_bucket.filter(is_ai=1).exists():
@@ -1884,6 +1890,7 @@ class serveManagement(View):
                         # 激活转移的套餐
                         # 激活转移的套餐
                         unused = new_unused_uid_bucket[0]
                         unused = new_unused_uid_bucket[0]
                         endTime = CommonService.calcMonthLater(unused['expire'])
                         endTime = CommonService.calcMonthLater(unused['expire'])
+                        LOGGER.info(f'云存转移, orderID:{orderID}, 激活转移之后的套餐, endTime: {endTime}')
                         # 判断是否有已过期套餐
                         # 判断是否有已过期套餐
                         if UID_Bucket.objects.filter(uid=new_uid).exists():
                         if UID_Bucket.objects.filter(uid=new_uid).exists():
                             UID_Bucket.objects.filter(uid=new_uid).update(status=1, orderId=orderID, updateTime=nowTime,
                             UID_Bucket.objects.filter(uid=new_uid).update(status=1, orderId=orderID, updateTime=nowTime,
@@ -1929,6 +1936,7 @@ class serveManagement(View):
 
 
             # 订单套餐已使用
             # 订单套餐已使用
             else:
             else:
+                LOGGER.info(f'云存转移, orderID:{orderID}, 该订单套餐在原设备已使用')
                 old_using_uid_bucket = old_using_uid_bucket.values('id', 'bucket_id', 'has_unused',
                 old_using_uid_bucket = old_using_uid_bucket.values('id', 'bucket_id', 'has_unused',
                                                                    'bucket__content').order_by('addTime')
                                                                    'bucket__content').order_by('addTime')
                 old_ai_service = AiService.objects.filter(uid=old_uid, endTime__gte=nowTime, use_status=1).values('id',
                 old_ai_service = AiService.objects.filter(uid=old_uid, endTime__gte=nowTime, use_status=1).values('id',