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

Merge remote-tracking branch 'origin/bin' into bin

# Conflicts:
#	Object/ResponseObject.py
locky 4 жил өмнө
parent
commit
eebacdd28b

+ 6 - 6
Ansjer/local_settings.py

@@ -73,15 +73,15 @@ TEMPLATES = [
 WSGI_APPLICATION = 'Ansjer.local_wsgi.application'
 
 # 服务器类型
-DATABASE_DATA = 'ansjerlocal'
+DATABASE_DATA = 'AnsjerTest'
 SERVER_HOST = '127.0.0.1'
 DATABASES_USER = 'root'
-DATABASES_PASS = '123456'
+DATABASES_PASS = 'mysqlfyzs9wl'
 
-# DATABASE_DATA2 = 'asjl'
-# SERVER_HOST2 = '127.0.0.1'
-# DATABASES_USER2 = 'root'
-# DATABASES_PASS2 = '123456'
+DATABASE_DATA2 = 'AnsjerTest'
+SERVER_HOST2 = '127.0.0.1'
+DATABASES_USER2 = 'root'
+DATABASES_PASS2 = 'mysqlfyzs9wl'
 
 DATABASES = {
     'default': {

+ 91 - 54
Controller/CloudStorage.py

@@ -210,7 +210,7 @@ class CloudStorageView(View):
         qs = qs.values("id", "title", "content", "price","day", "currency", "bucket__storeDay",
                        "bucket__bucket", "bucket__area","commodity_code",
                        "commodity_type", "is_discounts", "virtual_price", "expire",
-                       "discount_price", "discount_content")
+                       "discount_price", "discount_content","symbol")
 
         if qs.exists():
             ql = list(qs)
@@ -246,7 +246,7 @@ class CloudStorageView(View):
         vh_qs = VodHlsModel.objects.filter(uid=uid, channel=channel, time=storeTime, endTime__gte=now_time). \
             values("sec", "fg", "bucket__bucket", "bucket__endpoint", "bucket__region", "bucket__mold")
         if not vh_qs.exists():
-            return response.json(11,'不存在.')
+            return response.json(173)
         sec = vh_qs[0]['sec']
         fg = vh_qs[0]['fg']
         bucket__region = vh_qs[0]['bucket__region']
@@ -326,8 +326,8 @@ class CloudStorageView(View):
         print(uid)
         now_time = int(time.time())
         ubqs = UID_Bucket.objects.filter(uid=uid, channel=channel, endTime__gte=now_time). \
-            values("bucket__mold", "bucket__bucket", "bucket__endpoint",
-                   "bucket__region", "endTime").order_by('endTime')[:1]
+                   values("bucket__mold", "bucket__bucket", "bucket__endpoint",
+                          "bucket__region", "endTime").order_by('addTime')[:1]
         if ubqs.exists():
             if ubqs[0]["bucket__mold"] == 0:
                 # 阿里云 oss sts
@@ -474,13 +474,16 @@ class CloudStorageView(View):
         uid = request_dict.get('uid', None)
         channel = request_dict.get('channel', None)
 
-        dv_qs = Device_Info.objects.filter(UID=uid, userID_id=userID, isShare=False)
+        dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False).values('primaryUserID',
+                                                                                                       'primaryMaster')
         if not dv_qs.exists():
             return response.json(12)
+        if dv_qs[0]['primaryUserID'] != '' and dv_qs[0]['primaryUserID'] != userID:
+            return response.json(10034)
         now_time = int(time.time())
-        bv_qs = UID_Bucket.objects.filter(uid=uid,channel=channel, endTime__gte=now_time).order_by('endTime')
+        bv_qs = UID_Bucket.objects.filter(uid=uid,channel=channel, endTime__gte=now_time).order_by('addTime')
         if not bv_qs.exists():
-            return response.json(103,'未购买')
+            return response.json(10030)
         vh_qs = VodHlsModel.objects.filter \
             ( uid=uid, channel=channel, time__range=(startTime, endTime), endTime__gte=now_time). \
             values("id", "time", "sec", "bucket__bucket", "fg", "bucket__endpoint", "bucket__region", "bucket__mold")
@@ -564,8 +567,8 @@ class CloudStorageView(View):
         print(channel)
         now_time = int(time.time())
         ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel, endTime__gte=now_time). \
-            values("bucket__mold", "bucket__bucket", "bucket__endpoint",
-                   "bucket__region", "status", "bucket__storeDay", "bucket__id").order_by('endTime')[:1]
+                   values("bucket__mold", "bucket__bucket", "bucket__endpoint",
+                          "bucket__region", "status", "bucket__storeDay", "bucket__id").order_by('addTime')[:1]
         if ubqs.exists():
             ub_qs_data = ubqs[0]
             store_day = ub_qs_data['bucket__storeDay']
@@ -656,12 +659,12 @@ class CloudStorageView(View):
         dvqs = Device_Info.objects.filter(UID=uid, userID_id=userID, isShare=False)
         if not dvqs.exists():
             return response.json(12)
-        ubqs = UID_Bucket.objects.filter(channel=channel, uid=uid).order_by('endTime')
+        ubqs = UID_Bucket.objects.filter(channel=channel, uid=uid).order_by('addTime')
         if not ubqs.exists():
-            return response.json(10, '未购买')
+            return response.json(10030)
         now_time = int(time.time())
         if now_time > ubqs[0].endTime:
-            return response.json(102,'已过期')
+            return response.json(10031)
         ubqs.update(status=status)
         if status == 0:
             return response.json(0)
@@ -847,7 +850,7 @@ class CloudStorageView(View):
         response = ResponseObject()
         data = request.POST.dict()
         asy = threading.Thread(target=ModelService.add_log,
-                               args=(CommonService.get_ip_address(request),data['out_trade_no'], '进来了,阿里支付成功回调'))
+                               args=(CommonService.get_ip_address(request), data['out_trade_no'], '进来了,阿里支付成功回调'))
         asy.start()
         signature = data["sign"]
         data.pop('sign')
@@ -868,7 +871,9 @@ class CloudStorageView(View):
             print("trade succeed")
             order_qs = Order_Model.objects.filter(orderID=orderID)
             nowTime = int(time.time())
-            order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts")
+            order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts", "userID__userID", "userID__username")
+            userid = order_list[0]['userID__userID']
+            username = order_list[0]['userID__username']
             UID = order_list[0]['UID']
             channel = order_list[0]['channel']
             rank = order_list[0]['rank']
@@ -876,11 +881,10 @@ class CloudStorageView(View):
                 values("day", "bucket_id", "bucket__storeDay", "expire")
             bucketId = smqs[0]['bucket_id']
             if not smqs.exists():
-                return response.json(0, '套餐已删除')
+                return response.json(173)
             ubqs = UID_Bucket.objects.filter(bucket__id=bucketId, uid=UID, channel=channel, endTime__gte=nowTime). \
-                       values("id", "bucket__storeDay", "bucket__region", "endTime").order_by('endTime')[:1]
+                       values("id", "bucket__storeDay", "bucket__region", "endTime").order_by('addTime')[:1]
             nowTime = int(time.time())
-
             expire = smqs[0]['expire']
             if order_list[0]['isSelectDiscounts'] == 1:
                 expire = smqs[0]['expire'] * 2
@@ -889,14 +893,22 @@ class CloudStorageView(View):
                 endTime = CommonService.calcMonthLater(expire, ubq['endTime'])
                 ub_cqs = UID_Bucket.objects.filter(id=ubq['id']).update \
                     (uid=UID, channel=channel, bucket_id=bucketId,
-                     endTime=endTime)
+                     endTime=endTime,updateTime=nowTime)
                 uid_bucket_id = ubq['id']
             else:
                 endTime = CommonService.calcMonthLater(expire)
                 ub_cqs = UID_Bucket.objects.create \
-                    (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime)
+                    (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime, addTime=nowTime, updateTime=nowTime)
                 uid_bucket_id = ub_cqs.id
 
+            dvq = Device_Info.objects.filter(UID=UID, primaryUserID='', primaryMaster='')
+            if dvq.exists():
+                dvq_set_update_dict = {
+                    'primaryUserID': userid,
+                    'primaryMaster': username
+                }
+                dvq.update(**dvq_set_update_dict)
+
             order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
             red_url = "{SERVER_DOMAIN}cloudstorage/payOK".format(SERVER_DOMAIN=SERVER_DOMAIN)
             return HttpResponseRedirect(red_url)
@@ -906,21 +918,24 @@ class CloudStorageView(View):
         paymentId = request_dict.get('paymentId', None)
         PayerID = request_dict.get('PayerID', None)
         orderID = request_dict.get('orderID', None)
-        if not paymentId or not PayerID or not orderID:
-            red_url = "{SERVER_DOMAIN}cloudstorage/payError".format(SERVER_DOMAIN=SERVER_DOMAIN)
-            return HttpResponseRedirect(red_url)
-        paypalrestsdk.configure(PAYPAL_CRD)
-        # ID of the payment. This ID is provided when creating payment.
-        payment = paypalrestsdk.Payment.find(paymentId)
-        payres = payment.execute({"payer_id": PayerID})
-        print(payres)
-        if not payres:
-            red_url = "{SERVER_DOMAIN}cloudstorage/payError".format(SERVER_DOMAIN=SERVER_DOMAIN)
-            return HttpResponseRedirect(red_url)
-        print("Payment execute successfully")
+        # if not paymentId or not PayerID or not orderID:
+        #     red_url = "{SERVER_DOMAIN}cloudstorage/payError".format(SERVER_DOMAIN=SERVER_DOMAIN)
+        #     return HttpResponseRedirect(red_url)
+        # paypalrestsdk.configure(PAYPAL_CRD)
+        # # ID of the payment. This ID is provided when creating payment.
+        # payment = paypalrestsdk.Payment.find(paymentId)
+        # payres = payment.execute({"payer_id": PayerID})
+        # print(payres)
+        # if not payres:
+        #     red_url = "{SERVER_DOMAIN}cloudstorage/payError".format(SERVER_DOMAIN=SERVER_DOMAIN)
+        #     return HttpResponseRedirect(red_url)
+        # print("Payment execute successfully")
         order_qs = Order_Model.objects.filter(orderID=orderID)
         nowTime = int(time.time())
-        order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts")
+        order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts", "userID__userID",
+                                     "userID__username")
+        userid = order_list[0]['userID__userID']
+        username = order_list[0]['userID__username']
         UID = order_list[0]['UID']
         channel = order_list[0]['channel']
         rank = order_list[0]['rank']
@@ -928,10 +943,10 @@ class CloudStorageView(View):
             values("day", "bucket_id", "bucket__storeDay", "expire")
         bucketId = smqs[0]['bucket_id']
         if not smqs.exists():
-            return response.json(0, '套餐已删除')
+            return response.json(173)
         # ##
         ubqs = UID_Bucket.objects.filter(bucket__id=bucketId, uid=UID, channel=channel, endTime__gte=nowTime). \
-            values("id", "bucket__storeDay", "bucket__region", "endTime").order_by('endTime')[:1]
+                   values("id", "bucket__storeDay", "bucket__region", "endTime").order_by('addTime')[:1]
         expire = smqs[0]['expire']
         if order_list[0]['isSelectDiscounts'] == 1:
             expire = smqs[0]['expire'] * 2
@@ -940,20 +955,27 @@ class CloudStorageView(View):
             endTime = CommonService.calcMonthLater(expire,ubq['endTime'])
             ub_cqs = UID_Bucket.objects.filter(id=ubq['id']).update \
                 (uid=UID, channel=channel, bucket_id=bucketId,
-                 endTime=endTime)
+                 endTime=endTime,updateTime=nowTime)
             uid_bucket_id = ubq['id']
         else:
             endTime = CommonService.calcMonthLater(expire)
             ub_cqs = UID_Bucket.objects.create \
-                (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime)
+                (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime, addTime=nowTime, updateTime=nowTime)
             uid_bucket_id = ub_cqs.id
+
+        dvq = Device_Info.objects.filter(UID=UID, primaryUserID='', primaryMaster='')
+        if dvq.exists():
+            dvq_set_update_dict = {
+                'primaryUserID': userid,
+                'primaryMaster': username
+            }
+            dvq.update(**dvq_set_update_dict)
         order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
 
         # return response.json(0)
         red_url = "{SERVER_DOMAIN}cloudstorage/payOK".format(SERVER_DOMAIN=SERVER_DOMAIN)
         return HttpResponseRedirect(red_url)
 
-
     def do_pay_by_wechat_callback(self, request_dict, response):
         result_code = request_dict.get('result_code', None)
         if result_code == 'SUCCESS':
@@ -964,7 +986,10 @@ class CloudStorageView(View):
             orderID = request_dict.get('out_trade_no',None)
             order_qs = Order_Model.objects.filter(orderID=orderID)
             nowTime = int(time.time())
-            order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts")
+            order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts",
+                                         "userID__userID", "userID__username")
+            userid = order_list[0]['userID__userID']
+            username = order_list[0]['userID__username']
             UID = order_list[0]['UID']
             channel = order_list[0]['channel']
             rank = order_list[0]['rank']
@@ -975,7 +1000,7 @@ class CloudStorageView(View):
                 return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'FAIL', 'return_msg':'套餐不存在'}))
             # ##
             ubqs = UID_Bucket.objects.filter(bucket__id=bucketId, uid=UID, channel=channel, endTime__gte=nowTime). \
-                values("id", "bucket__storeDay", "bucket__region", "endTime").order_by('endTime')[:1]
+                       values("id", "bucket__storeDay", "bucket__region", "endTime").order_by('addTime')[:1]
             expire = smqs[0]['expire']
             if order_list[0]['isSelectDiscounts'] == 1:
                 expire = smqs[0]['expire'] * 2
@@ -984,13 +1009,21 @@ class CloudStorageView(View):
                 endTime = CommonService.calcMonthLater(expire,ubq['endTime'])
                 ub_cqs = UID_Bucket.objects.filter(id=ubq['id']).update \
                     (uid=UID, channel=channel, bucket_id=bucketId,
-                     endTime=endTime)
+                     endTime=endTime, updateTime=nowTime)
                 uid_bucket_id = ubq['id']
             else:
                 endTime = CommonService.calcMonthLater(expire)
                 ub_cqs = UID_Bucket.objects.create \
-                    (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime)
+                    (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime, addTime=nowTime, updateTime=nowTime)
                 uid_bucket_id = ub_cqs.id
+
+            dvq = Device_Info.objects.filter(UID=UID, primaryUserID='', primaryMaster='')
+            if dvq.exists():
+                dvq_set_update_dict = {
+                    'primaryUserID': userid,
+                    'primaryMaster': username
+                }
+                dvq.update(**dvq_set_update_dict)
             order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
             return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'SUCCESS', 'return_msg':'OK'}))
         return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'FAIL', 'return_msg':'参数格式校验错误'}))
@@ -1002,16 +1035,20 @@ class CloudStorageView(View):
         rank = request_dict.get('rank', None)
         is_select_discount = request_dict.get('is_select_discount', 0)
         if not uid or not channel or not pay_type or not rank:
-            return response.json(13, '参数有误.')
-        dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False, isExist=1)
+            return response.json(444)
+        dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False, isExist=1).values('primaryUserID',
+                                                                                                       'primaryMaster')
         if not dv_qs.exists():
             return response.json(12)
+
+        if dv_qs[0]['primaryUserID'] != '' and dv_qs[0]['primaryUserID'] != userID:
+            return response.json(10033)
         smqs = Store_Meal.objects.filter(id=rank, pay_type=pay_type). \
             values('currency', 'price', 'content', 'day',
                    'commodity_type', 'title', 'content',
                    'expire', 'commodity_code', 'discount_price')
         if not smqs.exists():
-            return response.json(10, '套餐不存在')
+            return response.json(173)
         currency = smqs[0]['currency']
         price = smqs[0]['price']
         if is_select_discount == '1':
@@ -1251,21 +1288,21 @@ class CloudStorageView(View):
                 VodHlsModel.objects.filter(uid=uid).delete()
             else:
                 if type(vod_id_list).__name__ != 'list':
-                    return response.json(424, 'vod_id_list格式错误')
+                    return response.json(444)
                 VodHlsModel.objects.filter(id__in=vod_id_list).delete()
         except Exception as e:
             return response.json(424, repr(e))
         else:
-            return response.json(0, '删除成功.')
+            return response.json(0)
 
     #设备关联套餐列表
     def device_commodity(self, request_dict, response):
         uid = request_dict.get('uid',None)
         now_time = int(time.time())
         uid_bucket = UID_Bucket.objects.filter(uid=uid, endTime__gte=now_time).values("id", "uid", "endTime",
-                                                                     "bucket__content").order_by('endTime')
+                                                                                      "bucket__content").order_by('addTime')
         if not uid_bucket.exists():
-            return response.json(404,'该设备未购买云存套餐.')
+            return response.json(10030)
         for index, value in enumerate(uid_bucket):
             value['is_use'] = 0
             if index == 0:
@@ -1278,21 +1315,21 @@ class CloudStorageView(View):
         switch_commodity_id = request_dict.get('switch_commodity_id',None)
         if switch_commodity_id:
             #切换设备套餐关联
-            using_uid_bucket = UID_Bucket.objects.filter(uid=uid, endTime__gte=int(time.time())).values("id", "uid", "endTime",
-                                                                               "bucket__content").order_by('endTime')
+            using_uid_bucket = UID_Bucket.objects.filter(uid=uid, endTime__gte=int(time.time())).values("id", "uid",
+                                                                        "endTime","bucket__content").order_by('addTime')
 
             if not using_uid_bucket.exists():
-                return response.json(404,'该设备未购买云存套餐.')
+                return response.json(10030)
 
             if int(using_uid_bucket[0]['id']) == int(switch_commodity_id):
-                return response.json(404,'切换的云存套餐ID不能与正在使用中的相同.')
+                return response.json(10032)
 
             # UID_Bucket.objects.filter(id=switch_commodity_id).update(is_use=1)  #更新转移的云存套餐为使用中
             UID_Bucket.objects.filter(id=using_uid_bucket[0]['id']).delete()    #删除原来使用中的云存套餐
             VodHlsModel.objects.filter(uid=uid).delete()                        #删除播放列表
             StsCrdModel.objects.filter(uid=uid).delete()                        #删除sts记录
-            return response.json(0,'切换云存套餐成功')
-        return response.json(404,'切换的套餐ID不能为空')
+            return response.json(0)
+        return response.json(444)
 
 #删除过期云存播放列表
 def deleteVodHls(request):

+ 79 - 134
Controller/CloudVod.py

@@ -1120,81 +1120,84 @@ class CloudVodView(View):
         response = HttpResponse()
         success_pay_content = '''
 
-                <!DOCTYPE html>
-                <html>
-                <head>
-                	<!--浏览器不缓存-->
-                	<meta http-equiv="Pragma" content="no-cache">
-                	<meta http-equiv="Cache-Control" content="no-cache">
-                	<meta http-equiv="Expires" content="0">
-                	<!--utf-8-->
-                    <meta http-equiv="content-type" content="text/html;charset=utf-8">
-                    <!-- viewport的<meta>标签,这个标签可以修改在大部分的移动设备上面的显示,为了确保适当的绘制和触屏缩放。-->
-                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-                    <link rel="shortcut icon" href="https://test.dvema.com/web/images/favicon.ico" type="image/x-icon"  charset="utf-8"/>  
-                    <title>Trading particulars</title>
-                    <style>
-                    	.title_head{
-                    		height: 50px;
-                    		border-radius: 5px;
-                    		background-color: #c3c6c7; 
-                    		text-align: center;
-                    		line-height: 50px;
-                    	}
-                    	.content{
-                    		text-align: center;
-                    		margin-top: 50px;
-                    		font-size: 20px;
-                    		color : green
-                    	}
-                    	.content_img{
-                    		width: 60px; 
-                    		height: 60px;
-                    	}
-                    	.bottom{
-                    		 margin-bottom: 10px; 
-                    		 margin-top: 250px; 
-                    		 color : green
-                    	}
-                    	.bottom_div{
-                    		border: 1px solid green; 
-                    		line-height: 38px; 
-                    		text-align: center; 
-                    		width: 100px; 
-                    		height: 38px;
-                    		border-radius: 5px;
-                    	}
-
-                    	.bottom_div:hover{
-                    		background-color: #dde4e2;
-                    	}
-                    </style>
-                </head>
-                <body>
-                	<div class="title_head">Trading particulars</div>
-                    <div class="content">
-                    	<p >
-                    		<img src="https://test.dvema.com/web/images/timg.jpg" class="content_img">
-                    		<br />
-                    		Successful payment
-                    	</p>
-                    </div>
-                    <center class="bottom">
-                    	<div class="bottom_div" onclick="payOKButton()"> 
-                    	 Finish
-                    	</div>
-                    </center>
-                    <script> 	    // 点击付款成功按钮
-                    function payOKButton() {
-                        // 复杂数据
-                        console.log('success')
-                        //window.webkit.messageHandlers.jsCallOC.postMessage({"status": 1});
-                        window.location.href="https://www.baidu.com?page=closePage";  
 
-                    }
-                	</script>
-                </body> 
-                </html>
+<!-- saved from url=(0040)http://test.dvema.com/cloudstorage/payOK -->
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <!--浏览器不缓存-->
+        <meta http-equiv="Pragma" content="no-cache">
+        <meta http-equiv="Cache-Control" content="no-cache">
+        <meta http-equiv="Expires" content="0">
+        <!--utf-8-->
+    
+    <!-- viewport的<meta>标签,这个标签可以修改在大部分的移动设备上面的显示,为了确保适当的绘制和触屏缩放。-->
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link rel="shortcut icon" href="https://test.dvema.com/web/images/favicon.ico" type="image/x-icon" charset="utf-8">  
+    <title>支付成功</title>
+    <style>
+            .title_head{
+                    height: 50px;
+                    border-radius: 5px;
+                    background-color: #c3c6c7; 
+                    text-align: center;
+                    line-height: 50px;
+            }
+            .content{
+                    text-align: center;
+                    margin-top: 50px;
+                    font-size: 15px;
+                    color:#0000008A;
+					
+            }
+            .content_img{
+					margin-bottom:15px;
+                    width: 60px; 
+                    height: 60px;
+            }
+            .bottom{
+                     margin-bottom: 10px; 
+                     margin-top: 250px; 
+                     color : white;
+            }
+            .bottom_div{
+                    border: 1px solid #68c9c5; 
+                    line-height: 38px; 
+                    text-align: center; 
+                    width: 100px; 
+                    height: 38px;
+                    border-radius: 30px;
+					background-color:#68c9c5; 
+            }
+            
+            .bottom_div:hover{
+                    background-color: #dde4e2;
+            }
+    </style>
+</head>
+<body style="" rlt="1" inmaintabuse="true">
+        
+    <div class="content">
+            <p>
+					<img src="./支付成功_files/success.png" class="content_img">
+                    <br>
+                    支付成功
+            </p>
+    </div>
+    <center class="bottom">
+            <div class="bottom_div" onclick="payOKButton()"> 
+             完成
+            </div>
+    </center>
+    <script src="./支付成功_files/hm.js.下载"></script><script>             // 点击付款成功按钮
+    function payOKButton() {
+        // 复杂数据
+        console.log('success')
+        window.location.href="https://www.baidu.com?page=closePage"  
+    }
+        </script>
+ 
+
+        <div id="qds" style="display:none;"></div>
+        </body></html>
                         '''
         falil_pay_content = '''
         <!DOCTYPE html>
@@ -1277,67 +1280,9 @@ class CloudVodView(View):
                 response.content = success_pay_content
                 return response
             else:
-                # response.content = falil_pay_content
-                # return response
-                # exit()
-                # 如果未支付则调用查询订单是否支付成功
-                aliPayObj = AliPayObject()
-                alipay = aliPayObj.conf()
-                # check order status
-                print("now sleep 3s")
-                # time.sleep(3)
-                result = alipay.api_alipay_trade_query(out_trade_no=orderID)
-                if result.get("trade_status", "") == "TRADE_SUCCESS":
-                    print('paid')
-                    print("trade succeed")
-                    logger = logging.getLogger('django')
-
-                    order_qs = Order_Model.objects.filter(orderID=orderID, status=0)
-                    if order_qs.exists():
-                        nowTime = int(time.time())
-                        order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts")
-                        UID = order_list[0]['UID']
-                        channel = order_list[0]['channel']
-                        rank = order_list[0]['rank']
-                        smqs = Store_Meal.objects.filter(id=rank). \
-                            values("day", "bucket_id", "bucket__storeDay", "expire")
-                        bucketId = smqs[0]['bucket_id']
-                        if not smqs.exists():
-                            response.content = falil_pay_content
-                            return response
-                            # ##
-                        ubqs = UID_Bucket.objects.filter(bucket__id=bucketId, uid=UID, channel=channel, endTime__gte=nowTime). \
-                            values("id", "bucket__storeDay", "bucket__region", "endTime").order_by('endTime')[:1]
-                        expire = smqs[0]['expire']
-                        if order_list[0]['isSelectDiscounts'] == 1:
-                            expire = smqs[0]['expire'] * 2
-                        if ubqs.exists():
-                            logger.error('————————--------into uid_bucket:')
-                            ubq = ubqs[0]
-                            endTime = CommonService.calcMonthLater(expire,ubq['endTime'])
-                            logger.error(endTime)
-                            ub_cqs = UID_Bucket.objects.filter(id=ubq['id']).update \
-                                (uid=UID, channel=channel, bucket_id=bucketId,
-                                 endTime=endTime)
-                            uid_bucket_id = ubq['id']
-                            logger.error(uid_bucket_id)
 
-                        else:
-                            endTime = CommonService.calcMonthLater(expire)
-                            ub_cqs = UID_Bucket.objects.create \
-                                (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime)
-                            uid_bucket_id = ub_cqs.id
-                        order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
-
-                        response.content = success_pay_content
-                        return response
-                    else:
-                        response.content = falil_pay_content
-                        return response
-                else:
-                    print("not paid...")
-                    response.content = falil_pay_content
-                    return response
+                response.content = falil_pay_content
+                return response
 
         else:
             response.content = falil_pay_content

+ 2 - 2
Controller/EquipmentManager.py

@@ -388,14 +388,14 @@ def addInterface(request):
                 # if is_bind:
                 #     return response.json(15)
 
-                main_exist = Device_Info.objects.filter(UID=UID, primaryUserID='',primaryMaster__isnull='')
+                main_exist = Device_Info.objects.filter(UID=UID, primaryUserID='',primaryMaster='')
                 pk = CommonService.getUserID(getUser=False)
                 primaryMaster = ''
                 primaryUserID = ''
                 if not main_exist:
 
                     duq = Device_User.objects.filter(userID=userID).values('username')
-                    if duq[0].exists():
+                    if duq.exists():
                         username = duq[0]['username']
                         primaryMaster = username
                         primaryUserID = userID

+ 147 - 2
Controller/EquipmentManagerV3.py

@@ -47,6 +47,8 @@ class EquipmentManagerV3(View):
                 return self.do_query(userID, request_dict, response)
             elif operation == 'modify':
                 return self.do_modify(userID, request_dict, response, request)
+            elif operation == 'fuzzyQuery':
+                return self.do_fuzzy_query(userID, request_dict, response)
             else:
                 return response.json(414)
         else:
@@ -87,14 +89,14 @@ class EquipmentManagerV3(View):
                     # if is_bind:
                     #     return response.json(15)
 
-                    main_exist = Device_Info.objects.filter(UID=UID, primaryUserID='', primaryMaster__isnull='')
+                    main_exist = Device_Info.objects.filter(UID=UID, primaryUserID='', primaryMaster='')
                     pk = CommonService.getUserID(getUser=False)
                     primaryMaster = ''
                     primaryUserID = ''
                     if not main_exist:
 
                         duq = Device_User.objects.filter(userID=userID).values('username')
-                        if duq[0].exists():
+                        if duq.exists():
                             username = duq[0]['username']
                             primaryMaster = username
                             primaryUserID = userID
@@ -388,6 +390,149 @@ class EquipmentManagerV3(View):
         else:
             return response.json(tko.code)
 
+    def do_fuzzy_query(self, userID, request_dict, response):
+        fuzzy = request_dict.get('fuzzy', None)
+        page = request_dict.get('page', None)
+        line = request_dict.get('line', None)
+
+        if page and line:
+            page = int(page)
+            line = int(line)
+            device_qs = Device_Info.objects.filter(userID=userID)
+            device_qs = device_qs.filter(~Q(isExist=2))
+            if device_qs.exists():
+                if fuzzy:
+                    device_qs = device_qs.filter(Q(UID__contains=fuzzy) | Q(NickName__contains=fuzzy))
+
+                device_qs = device_qs.values('id', 'userID', 'NickName', 'UID', 'View_Account',
+                               'View_Password', 'ChannelIndex', 'Type', 'isShare',
+                               'primaryUserID', 'primaryMaster', 'data_joined',
+                               'version', 'isVod', 'isExist', 'NotificationMode')
+
+                dvls = CommonService.qs_to_list(device_qs)
+                uid_list = []
+                for dvl in dvls:
+                    uid_list.append(dvl['UID'])
+                ubqs = UID_Bucket.objects.filter(uid__in=uid_list). \
+                    values('bucket__content', 'status', 'channel', 'endTime', 'uid')
+                upqs = UID_Preview.objects.filter(uid__in=uid_list).order_by('channel').values('id', 'uid', 'channel')
+                auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
+                bucket = oss2.Bucket(auth, 'oss-cn-hongkong.aliyuncs.com', 'statres')
+                nowTime = int(time.time())
+                data = []
+                # 设备拓展信息表
+                us_qs = UidSetModel.objects.filter(uid__in=uid_list).values('id', 'uid', 'version', 'nickname', 'ucode',
+                                                                            'detect_status', 'detect_group',
+                                                                            'detect_interval',
+                                                                            'region_alexa', 'is_alexa', 'deviceModel',
+                                                                            'TimeZone', 'TimeStatus', 'SpaceUsable',
+                                                                            'SpaceSum', 'MirrorType', 'RecordType',
+                                                                            'OutdoorModel', 'WIFIName', 'isDetector',
+                                                                            'DetectorRank')
+                uv_dict = {}
+                for us in us_qs:
+                    uv_dict[us['uid']] = {
+                        'version': us['version'],
+                        'nickname': us['nickname'],
+                        'ucode': us['ucode'],
+                        'detect_interval': us['detect_interval'],
+                        'detect_group': us['detect_group'],
+                        'detect_status': us['detect_status'],
+                        'region_alexa': us['region_alexa'],
+                        'is_alexa': us['is_alexa'],
+                        'deviceModel': us['deviceModel'],
+                        'TimeZone': us['TimeZone'],
+                        'TimeStatus': us['TimeStatus'],
+                        'SpaceUsable': us['SpaceUsable'],
+                        'SpaceSum': us['SpaceSum'],
+                        'MirrorType': us['MirrorType'],
+                        'RecordType': us['RecordType'],
+                        'OutdoorModel': us['OutdoorModel'],
+                        'WIFIName': us['WIFIName'],
+                        'isDetector': us['isDetector'],
+                        'DetectorRank': us['DetectorRank']
+                    }
+                    # 从uid_channel里面取出通道配置信息
+                    ucs_qs = UidChannelSetModel.objects.filter(uid__id=us['id']).values()
+                    channels = []
+                    for ucs in ucs_qs:
+                        channel = {
+                            'channel': ucs['channel'],
+                            'pir_audio': ucs['pir_audio'],
+                            'mic_audio': ucs['mic_audio'],
+                            'battery_status': ucs['battery_status'],
+                            'battery_level': ucs['battery_level'],
+                            'sleep_status': ucs['sleep_status'],
+                            'sleep_time': ucs['sleep_time'],
+                            'light_night_model': ucs['light_night_model'],
+                            'light_alarm_type': ucs['light_alarm_type'],
+                            'light_alarm_level': ucs['light_alarm_level'],
+                            'light_alarm_man_en': ucs['light_alarm_man_en'],
+                            'light_alarm_vol': ucs['light_alarm_vol'],
+                            'light_long_light': ucs['light_long_light']
+                        }
+                        channels.append(channel)
+                    uv_dict[us['uid']]['channels'] = channels
+
+                for p in dvls:
+                    p['vod'] = []
+                    for dm in ubqs:
+                        if p['UID'] == dm['uid']:
+                            if dm['endTime'] > nowTime:
+                                p['vod'].append(dm)
+                    p['preview'] = []
+                    for up in upqs:
+                        if p['UID'] == up['uid']:
+                            obj = 'uid_preview/{uid}/channel_{channel}.png'.format(uid=up['uid'], channel=up['channel'])
+                            img_sign = bucket.sign_url('GET', obj, 300)
+                            p['preview'].append(img_sign)
+                    p_uid = p['UID']
+                    if p_uid in uv_dict:
+                        # 设备版本号
+                        p['uid_version'] = uv_dict[p_uid]['version']
+                        p['ucode'] = uv_dict[p_uid]['ucode']
+                        p['detect_interval'] = uv_dict[p_uid]['detect_interval']
+                        p['detect_status'] = uv_dict[p_uid]['detect_status']
+                        p['detect_group'] = uv_dict[p_uid]['detect_group']
+                        p['region_alexa'] = uv_dict[p_uid]['region_alexa']
+                        p['is_alexa'] = uv_dict[p_uid]['is_alexa']
+                        p['deviceModel'] = uv_dict[p_uid]['deviceModel']
+                        p['TimeZone'] = uv_dict[p_uid]['TimeZone']
+                        p['TimeStatus'] = uv_dict[p_uid]['TimeStatus']
+                        p['SpaceUsable'] = uv_dict[p_uid]['SpaceUsable']
+                        p['SpaceSum'] = uv_dict[p_uid]['SpaceSum']
+                        p['MirrorType'] = uv_dict[p_uid]['MirrorType']
+                        p['RecordType'] = uv_dict[p_uid]['RecordType']
+                        p['OutdoorModel'] = uv_dict[p_uid]['OutdoorModel']
+                        p['WIFIName'] = uv_dict[p_uid]['WIFIName']
+                        p['isDetector'] = uv_dict[p_uid]['isDetector']
+                        p['DetectorRank'] = uv_dict[p_uid]['DetectorRank']
+                        p['channels'] = uv_dict[p_uid]['channels']
+                        # 设备昵称 调用影子信息昵称,先阶段不可
+                        if uv_dict[p_uid]['nickname']:
+                            p['NickName'] = uv_dict[p_uid]['nickname']
+                    else:
+                        # 设备版本号
+                        p['uid_version'] = ''
+                        p['ucode'] = ''
+                    data.append(p)
+                result = data
+                items = []
+                # print('缓存分页')
+                for index, item in enumerate(result):
+                    if (page - 1) * line <= index:
+                        if index < page * line:
+                            # 加密
+                            item['View_Password'] = self.encrypt_pwd(item['View_Password'])
+                            print(item)
+                            items.append(item)
+                print(items)
+                return response.json(0, items)
+            else:
+                return response.json(0, [])
+        else:
+            return response.json(444)
+
     # 加密
     def encrypt_pwd(self,userPwd):
         for i in range(1, 4):

+ 111 - 9
Controller/VoicePromptController.py

@@ -44,8 +44,16 @@ class VoicePromptView(View):
             return self.do_delete(token.userID, request_dict, response)
         elif operation == 'query':
             return self.do_query(request_dict, response)
+        elif operation == 'update':
+            return self.do_update(token.userID, request_dict, response)
         elif operation == 'adminAdd':
-            return self.do_admin_add(request_dict, response)
+            return self.do_admin_add(token.userID, request_dict, response)
+        elif operation == 'adminQuery':
+            return self.do_admin_query(token.userID, request_dict, response)
+        elif operation == 'adminUpdate':
+            return self.do_admin_update(token.userID, request_dict, response)
+        elif operation == 'adminDelete':
+            return self.do_admin_delete(token.userID, request_dict, response)
         else:
             return response.json(404)
 
@@ -93,6 +101,25 @@ class VoicePromptView(View):
         else:
             return response.json(444)
 
+    def do_update(self, userID, request_dict, response):
+        id = request_dict.get('id', None)
+        title = request_dict.get('title', None)
+
+        if id and title:
+            voice_qs = VoicePromptModel.objects.filter(id=id)
+            if voice_qs.exists():
+                uid = voice_qs[0].uid
+                device_qs = Device_Info.objects.filter(UID=uid, userID=userID)
+                if device_qs.exists():
+                    voice_qs.update(title=title)
+                    return response.json(0)
+                else:
+                    return response.json(404)
+            else:
+                return response.json(173)
+        else:
+            return response.json(444)
+
     def do_delete(self, userID, request_dict, response):
         id = request_dict.get('id', None)
         if id:
@@ -119,7 +146,7 @@ class VoicePromptView(View):
 
         if uid and channel and lang:
             voice_qs = VoicePromptModel.objects.filter(uid=uid, channel=channel, classification=1)
-            system_qs = VoicePromptModel.objects.filter(classification=0, language=lang)
+            system_qs = VoicePromptModel.objects.filter(classification=0, language=lang, status=1)
             channel_qs = UidChannelSetModel.objects.filter(uid__uid=uid, channel=channel)
 
             res = {
@@ -157,7 +184,7 @@ class VoicePromptView(View):
                 system_qs = system_qs.values('id', 'title', 'filename', 'type')
                 for system in system_qs:
                     filename = system['filename']
-                    obj = 'voice_prompt/' + uid + '/' + channel + '/' + filename
+                    obj = 'voice_prompt/system/' + filename
                     url = bucket.sign_url('GET', obj, 3600)
                     system['url'] = url
                     del system['filename']
@@ -199,16 +226,16 @@ class VoicePromptView(View):
         else:
             return response.json(444)
 
-    def do_admin_add(self, request_dict, response):
+    def do_admin_add(self, userID, request_dict, response):
+        own_perm = ModelService.check_perm(userID, 10)
+        if not own_perm:
+            return response.json(404)
+
         filename = request_dict.get('filename', None)
         title = request_dict.get('title', None)
         type = request_dict.get('type', None)
         lang = request_dict.get('lang', '')
 
-        # own_perm = ModelService.check_perm(userID, 10)
-        # if not own_perm:
-        #     return response.json(404)
-
         if filename and title and type:
             voice_prompt = VoicePromptModel()
             voice_prompt.filename = filename
@@ -217,7 +244,82 @@ class VoicePromptView(View):
             voice_prompt.language = lang
             voice_prompt.classification = 0
             voice_prompt.add_time = int(time.time())
+            voice_prompt.status = 0
             voice_prompt.save()
             return response.json(0)
         else:
-            return response.json(444)
+            return response.json(444)
+
+    def do_admin_query(self, userID, request_dict, response):
+        own_perm = ModelService.check_perm(userID, 10)
+        if not own_perm:
+            return response.json(404)
+
+        type = request_dict.get('type', 1)
+        page = request_dict.get('page', None)
+        line = request_dict.get('line', None)
+
+        if page is None or line is None:
+            return response.json(444)
+
+        voice_qs = VoicePromptModel.objects.filter(classification=0, type=type)
+        res = {
+            'count': 0
+        }
+
+        if voice_qs.exists():
+            page = int(page)
+            line = int(line)
+
+            start = (page - 1) * line
+            end = start + line
+            count = voice_qs.count()
+            res['count'] = count
+
+            voice_qs = voice_qs.values('id', 'title', 'type', 'language', 'status', 'filename')[start:end]
+
+            auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
+            bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'ansjer-static-resources')
+
+            for item in voice_qs:
+                filename = item['filename']
+                obj = 'voice_prompt/system/' + filename
+                url = bucket.sign_url('GET', obj, 3600)
+                item['url'] = url
+                del item['filename']
+            res['data'] = list(voice_qs)
+            return response.json(0, res)
+        else:
+            res['data'] = []
+            return response.json(0, res)
+
+    def do_admin_update(self, userID, request_dict, response):
+        own_perm = ModelService.check_perm(userID, 10)
+        if not own_perm:
+            return response.json(404)
+
+        id = request_dict.get('id', None)
+        status = request_dict.get('status', None)
+        title = request_dict.get('title', None)
+
+        if id and status and title:
+            VoicePromptModel.objects.filter(id=id, classification=0).update(status=status, title=title)
+            return response.json(0)
+        else:
+            return response.json(444)
+
+    def do_admin_delete(self, userID, request_dict, response):
+        own_perm = ModelService.check_perm(userID, 10)
+        if not own_perm:
+            return response.json(404)
+
+        id = request_dict.get('id', None)
+        if id:
+            VoicePromptModel.objects.filter(id=id, classification=0).delete()
+            return response.json(0)
+        else:
+            return response.json(444)
+
+
+
+

+ 3 - 0
Model/models.py

@@ -637,6 +637,8 @@ class UID_Bucket(models.Model):
     bucket = models.ForeignKey(VodBucketModel, blank=True, to_field='id', on_delete=models.CASCADE, verbose_name='存储空间')
     status = models.SmallIntegerField(default=0, verbose_name='状态[0:开启,1:关闭]')
     endTime = models.IntegerField(verbose_name='套餐结束时间', default=0)
+    addTime = models.IntegerField(verbose_name='添加时间', default=0)
+    updateTime = models.IntegerField(verbose_name='更新时间', default=0)
     # is_use = models.IntegerField(verbose_name='是否使用中[0:未使用,1:使用中]', default=0)
 
     class Meta:
@@ -1142,6 +1144,7 @@ class VoicePromptModel(models.Model):
     add_time = models.IntegerField(default=0, verbose_name='添加时间')
     uid = models.CharField(max_length=20, default='0', verbose_name='关联设备UID')
     channel = models.IntegerField(default=0, verbose_name='通道号')
+    status = models.SmallIntegerField(default=1, verbose_name='是否启用。0:不启用,1:启用')
 
     class Meta:
         db_table = 'voice_prompt'

+ 15 - 5
Object/ResponseObject.py

@@ -82,6 +82,11 @@ class ResponseObject(object):
             10012: 'Experience packages cannot be transferred',
             10013: 'Original equipment package has expired and cannot be transferred',
             10014: 'Accept transfer of equipment packages that have not expired and cannot be transferred',
+            10030: 'No purchase of cloud storage',
+            10031: 'The cloud storage has expired',
+            10032: 'The switched cloud storage package ID cannot be the same as the one in use',
+            10033: 'The primary user of the device cannot purchase it',
+            10034: 'Non device primary users cannot view cloud storage',
         }
         data_cn = {
             0: '成功',
@@ -154,11 +159,16 @@ class ResponseObject(object):
             10008: '用户没有此设备,无法转移',
             10009: '用户已拥有此设备,无法转移',
             10010: '不是同一账户下的设备,无法转移',
-            10011: '接受转移设备不存在,无法转移',
-            10012: '体验套餐无法转移',
-            10013: '原设备套餐已过期,无法转移',
-            10014: '接受转移设备套餐未过期,无法转移',
-
+            10011: '原设备正在正常使用云存储服务,无法转移',
+            # 10012: '接受转移设备未开通过云存储服务,无法转移',
+            10013: '接受转移设备套餐未过期,无法转移',
+            10014: '体验套餐无法转移',
+            10015: '原设备套餐已过期,无法转移',
+            10030: '未购买云存',
+            10031: '云存已过期',
+            10032: '切换的云存套餐ID不能与正在使用中的相同',
+            10033: '非设备主用户无法购买',
+            10034: '非设备主用户无法查看云存',
         }
         if self.lang == 'cn':
             msg = data_cn