chanjunkai 5 年 前
コミット
d52afa5f57
2 ファイル変更40 行追加6 行削除
  1. 1 1
      Ansjer/test_settings.py
  2. 39 5
      Controller/CloudStorage.py

+ 1 - 1
Ansjer/test_settings.py

@@ -119,7 +119,7 @@ USE_TZ = True
 # 跨域增加忽略
 CORS_ALLOW_CREDENTIALS = True
 CORS_ORIGIN_ALLOW_ALL = True
-CORS_ORIGIN_WHITELIST = ('*')
+# CORS_ORIGIN_WHITELIST = ('*')
 
 CORS_ALLOW_METHODS = (
     'DELETE',

+ 39 - 5
Controller/CloudStorage.py

@@ -45,10 +45,10 @@ http://test.dvema.com/cloudstorage/changevodstatus?token=eyJhbGciOiJIUzI1NiIsInR
 # 获取播放列表
 http://test.dvema.com/cloudstorage/queryvodlist?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiIxNTY3NzU4MjE4NjE5MTM4MDAxMzgwMDAiLCJleHAiOjE1ODk1MjM0OTIsIm1fY29kZSI6IjEyMzQxMzI0MzIxNCIsImxhbmciOiJlbiIsInVzZXIiOiIxMzExOTY1NzcxMyJ9.e2NdhJtbXrDngZTSmOX_52Y-oxyfUEXjZD_qNxg6VrU&uid=VVDHCVBYDKFMJRWA111A&startTime=1&endTime=1954687458
 
-http://test.dvema.com/cloudstorage/storeplaylist?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJWVkRIQ1ZCWURLRk1KUldBMTExQSIsImNoYW5uZWwiOiIxIn0.eGwi5QKyrXi4WSKRbrUG7iFTChv_Utec2hSnqZkDKt8
-
 http://test.dvema.com/cloudstorage/storeplaylist?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJWVkRIQ1ZCWURLRk1KUldBMTExQSIsImNoYW5uZWwiOiIxIn0.eGwi5QKyrXi4WSKRbrUG7iFTChv_Utec2hSnqZkDKt8&time=1586940120&sec=20&fg=10
 
+http://localhost:8077/cloudstorage/queryorder?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySUQiOiIxNTY3NzU4MjE4NjE5MTM4MDAxMzgwMDAiLCJsYW5nIjoiZW4iLCJ1c2VyIjoiMTMxMTk2NTc3MTMiLCJtX2NvZGUiOiIxMjM0MTMyNDMyMTQiLCJleHAiOjE1ODk1OTIyNzh9.u211DHiMKg-pqhXv4b2yR__eNyOcSwBZCyPUGjsxFLU&page=1&line=10&uid=VVDHCVBYDKFMJRWA111A
+
 '''
 
 
@@ -127,8 +127,42 @@ class CloudStorageView(View):
         return response
 
     def do_query_order(self, request_dict, userID, response):
-
-        return
+        status = request_dict.get('status', None)
+        page = int(request_dict.get('page', None))
+        line = int(request_dict.get('line', None))
+        uid = request_dict.get('uid', None)
+        order_qs = Order_Model.objects.filter(userID_id=userID)
+        if status:
+            order_qs = order_qs.filter(status=status)
+        # 筛选指定设备id的订单
+        if uid:
+            order_qs = order_qs.filter(UID=uid)
+        if not order_qs.exists():
+            return response.json(173)
+            # return response.json(10, '订单不存在')
+        count = order_qs.count()
+        order_ql = order_qs[(page - 1) * line:page * line]. \
+            values("orderID", "UID", "channel", "desc", "price", "currency",
+                   "addTime", "updTime", "endTime", "pay_url", "payType", "status")
+        order_list = list(order_ql)
+        data = []
+        nowTime = int(time.time())
+        # 这里需要进行优化
+        uid_list = []
+        for od in order_list:
+            uid_list.append(od['UID'])
+        didqs = Device_Info.objects.filter(userID_id=userID, UID__in=uid_list). \
+            values('id', 'UID', 'Type')
+        for d in order_list:
+            if d['status'] == 0:
+                if d['addTime'] + 3600 < nowTime:
+                    d['status'] = 3
+            for did in didqs:
+                if d['UID'] == did['UID']:
+                    d['did'] = did['id']
+                    d['Type'] = did['Type']
+                    data.append(d)
+        return response.json(0, {'data': data, 'count': count})
 
     def do_commodity_list(self, request_dict, userID, response):
         mold = request_dict.get('mold', None)
@@ -344,7 +378,7 @@ class CloudStorageView(View):
                     'ip': ip,
                 }
                 if sts_qs.exists():
-                    sts_qs.update(data=json.dumps(res), addTime=now_time)
+                    sts_qs.update(data=json.dumps(res,default=str), addTime=now_time)
                 else:
                     StsCrdModel.objects.create(uid=uid, channel=channel, data=json.dumps(res, default=str),
                                                addTime=now_time, type=1)