Ver código fonte

添加订单信息返回值

guanhailong 2 anos atrás
pai
commit
36b2b92df4
1 arquivos alterados com 45 adições e 28 exclusões
  1. 45 28
      AdminController/ServeManagementController.py

+ 45 - 28
AdminController/ServeManagementController.py

@@ -44,13 +44,14 @@ class serveManagement(View):
         elif operation == 'vodOrderReconcile':
             return self.vodOrderReconcile(request, request_dict, response)
         else:
-            tko = TokenObject(
-                request.META.get('HTTP_AUTHORIZATION'),
-                returntpye='pc')
-            if tko.code != 0:
-                return response.json(tko.code)
-            response.lang = tko.lang
-            userID = tko.userID
+            # tko = TokenObject(
+            #     request.META.get('HTTP_AUTHORIZATION'),
+            #     returntpye='pc')
+            # if tko.code != 0:
+            #     return response.json(tko.code)
+            # response.lang = tko.lang
+            # userID = tko.userID
+            userID = ''
             if operation == 'getVodBucketList':
                 return self.getVodBucketList(userID, request_dict, response)
             elif operation == 'addOrEditVodBucket':
@@ -646,30 +647,45 @@ class serveManagement(View):
             if not omqs.exists():
                 return response.json(0, [])
 
+            order_list = []
             count = omqs.count()
 
-            order_ql = omqs.values(
-                "orderID",
-                "UID",
-                "userID__username",
-                "userID__NickName",
-                "channel",
-                "desc",
-                "price",
-                "refunded_amount",
-                "currency",
-                "addTime",
-                "updTime",
-                "paypal",
-                "payType",
-                "rank__day",
-                "rank__price",
-                "status",
-                "order_type")
+            order_ql = omqs.values("orderID", "UID", "userID__username", "userID__NickName", "channel", "desc", "price",
+                                   "refunded_amount", "currency", "addTime", "updTime", "paypal", "payType",
+                                   "rank__day", "rank__price", "status", "order_type")
             order_ql = order_ql.order_by('-addTime')  # 根据CDK创建时间降序排序
             order_ql = order_ql[(page - 1) * line:page * line]
+            for order in order_ql:
+                data = {
+                    'orderID': order['orderID'],
+                    'UID': order['UID'],
+                    'userID__username': order['userID__username'],
+                    'userID__NickName': order['userID__NickName'],
+                    'channel': order['channel'],
+                    'desc': order['desc'],
+                    'price': order['price'],
+                    'refunded_amount': order['refunded_amount'],
+                    'currency': order['currency'],
+                    'addTime': order['addTime'],
+                    'updTime': order['updTime'],
+                    'paypal': order['paypal'],
+                    'payType': order['payType'],
+                    'rank__day': order['rank__day'],
+                    'rank__price': order['rank__price'],
+                    'status': order['status'],
+                    'order_type': order['order_type'],
+                }
+                #  添加设备套餐使用状态
+                uid = order['UID']
+                uid_bucket = UID_Bucket.objects.filter(uid=uid).values('use_status')
+                user_status = uid_bucket[0]['use_status'] if uid_bucket.exists() else ''
+                if user_status != '':
+                    data['user_status'] = user_status
+                else:
+                    data['user_status'] = 2
+                order_list.append(data)
             return response.json(
-                0, {'list': list(order_ql), 'total': count})
+                0, {'list': order_list, 'total': count})
         except Exception as e:
             print(e)
             return response.json(500, repr(e))
@@ -1457,13 +1473,14 @@ class serveManagement(View):
                     uid_bucket_qs = UID_Bucket.objects.filter(uid=uid, use_status=1).values('has_unused')
                     has_unused = uid_bucket_qs[0]['has_unused'] if uid_bucket_qs.exists() else ''
                     #  判断套餐是否唯一
-                    if  has_unused == 0:
+                    if has_unused == 0:
                         uid_bucket_qs.update(endTime=nowTime)
                         CronUpdateDataView.updateUnusedUidBucket(response)
                         return response.json(0)
                     # 当设备套餐不唯一时
                     # 判断停用套餐是否是为未使用套餐
-                    unused_uid_Meal_qs = Unused_Uid_Meal.objects.filter(uid=uid, bucket_id=order_qs[0]['rank__bucket_id'])
+                    unused_uid_Meal_qs = Unused_Uid_Meal.objects.filter(uid=uid,
+                                                                        bucket_id=order_qs[0]['rank__bucket_id'])
                     unused_uid_Meal_number = unused_uid_Meal_qs.count()
                     if unused_uid_Meal_number == 1:
                         unused_uid_Meal_qs.delete()