Browse Source

增加云存有效期字段;增加套餐类型及筛选功能

guanhailong 2 years ago
parent
commit
2e674c350f
1 changed files with 20 additions and 3 deletions
  1. 20 3
      AdminController/ServeManagementController.py

+ 20 - 3
AdminController/ServeManagementController.py

@@ -82,7 +82,7 @@ class serveManagement(View):
                 return self.getDeviceOrderList(request_dict, response)
             elif operation == 'deleteDeviceOrder':
                 return self.deleteDeviceOrder(userID, request_dict, response)
-            elif operation == 'getDevicePackageList':
+            elif operation == 'getDevicePackageList':  # 云存设备套餐
                 return self.getDevicePackageList(request_dict, response)
             elif operation == 'deleteDevicePackage':
                 return self.deleteDevicePackage(userID, request_dict, response)
@@ -605,6 +605,7 @@ class serveManagement(View):
         payType = request_dict.get('payType', None)
         status = request_dict.get('status', None)
         timeRange = request_dict.getlist('timeRange[]', None)
+        orderType = request_dict.get('orderType', None)
 
         if not all([pageNo, pageSize]):
             return response.json(444)
@@ -628,6 +629,8 @@ class serveManagement(View):
                 omqs = omqs.filter(payType=payType)
             if status:
                 omqs = omqs.filter(status=status)
+            if orderType:
+                omqs = omqs.filter(order_type=int(orderType))
             if timeRange:
                 startTime, endTime = int(
                     timeRange[0][:-3]), int(timeRange[1][:-3])
@@ -655,7 +658,8 @@ class serveManagement(View):
                 "payType",
                 "rank__day",
                 "rank__price",
-                "status")
+                "status",
+                "order_type")
             order_ql = order_ql.order_by('-addTime')  # 根据CDK创建时间降序排序
             order_ql = order_ql[(page - 1) * line:page * line]
             return response.json(
@@ -735,7 +739,8 @@ class serveManagement(View):
         else:
             return response.json(0, '重置云存体验失败')
 
-    def getCloudUserList(self, request_dict, response):
+    @classmethod
+    def getCloudUserList(cls, request_dict, response):
         print('request_dict: ', request_dict)
 
         # UID_Bucket表查询数据
@@ -867,6 +872,17 @@ class serveManagement(View):
                         endTime = time.strftime("%Y--%m--%d %H:%M:%S", time.localtime(endTime))
                     else:
                         endTime = time.strftime("%Y--%m--%d %H:%M:%S", time.localtime(uid_bucket.endTime))
+                    nowTime = int(time.time())
+                    Time = time.strptime(endTime, "%Y--%m--%d %H:%M:%S")
+                    Time = time.mktime(Time)
+                    nowTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(nowTime))
+                    if nowTime < endTime:
+                        Time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(Time))
+                        nowTime = datetime.datetime.strptime(nowTime, '%Y-%m-%d %H:%M:%S')
+                        Time = datetime.datetime.strptime(Time, '%Y-%m-%d %H:%M:%S')
+                        expirationDate = (Time - nowTime).days
+                    else:
+                        expirationDate = 0
 
                     uid = uid_bucket.uid.upper()
                     data = {
@@ -875,6 +891,7 @@ class serveManagement(View):
                         'channel': uid_bucket.channel,
                         'status': uid_bucket.status,
                         'endTime': endTime,
+                        'ExpirationDate': expirationDate,
                         'addTime': time.strftime("%Y--%m--%d %H:%M:%S", time.localtime(uid_bucket.addTime)),
                         'use_status': uid_bucket.use_status,
                         'has_unused': uid_bucket.has_unused,