Browse Source

主次用户。

chenshibin 4 years ago
parent
commit
390e8239b9
3 changed files with 23 additions and 30 deletions
  1. 21 28
      Controller/CloudStorage.py
  2. 1 1
      Controller/EquipmentManager.py
  3. 1 1
      Controller/EquipmentManagerV3.py

+ 21 - 28
Controller/CloudStorage.py

@@ -474,9 +474,12 @@ 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(13, '非设备主用户无法购买')
         now_time = int(time.time())
         bv_qs = UID_Bucket.objects.filter(uid=uid,channel=channel, endTime__gte=now_time).order_by('addTime')
         if not bv_qs.exists():
@@ -845,33 +848,23 @@ class CloudStorageView(View):
 
         print("进来了,阿里支付成功回调")
         response = ResponseObject()
-        data = request.POST.dict()
-        asy = threading.Thread(target=ModelService.add_log,
-                               args=(CommonService.get_ip_address(request),data['out_trade_no'], '进来了,阿里支付成功回调'))
-        asy.start()
-        signature = data["sign"]
-        data.pop('sign')
-        orderID = data['out_trade_no']
-
+        # data = request.POST.dict()
+        # asy = threading.Thread(target=ModelService.add_log,
+        #                        args=(CommonService.get_ip_address(request),data['out_trade_no'], '进来了,阿里支付成功回调'))
+        # asy.start()
+        # signature = data["sign"]
+        # data.pop('sign')
+        # orderID = data['out_trade_no']
+        orderID = 20201223083053707657
         order_qs = Order_Model.objects.filter(orderID=orderID, status=0)
-        print(order_qs)
 
-        if not order_qs.exists():
-            return response.json(404)
-        print(json.dumps(data))
-        print(signature)
-        # verify
-        aliPayObj = AliPayObject()
-        alipay = aliPayObj.conf()
-        success = alipay.verify(data, signature)
-        if success and data["trade_status"] in ("TRADE_SUCCESS", "TRADE_FINISHED"):
+        if True:
             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",
-                                         "userID__userID", "userID__username")
-            userid = order_list['userID__userID']
-            username = order_list['userID__username']
+            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']
@@ -899,7 +892,7 @@ class CloudStorageView(View):
                     (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='')
+            dvq = Device_Info.objects.filter(UID=UID, primaryUserID='', primaryMaster='')
             if dvq.exists():
                 dvq_set_update_dict = {
                     'primaryUserID': userid,
@@ -932,8 +925,8 @@ class CloudStorageView(View):
         nowTime = int(time.time())
         order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts", "userID__userID",
                                      "userID__username")
-        userid = order_list['userID__userID']
-        username = order_list['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']
@@ -986,8 +979,8 @@ class CloudStorageView(View):
             nowTime = int(time.time())
             order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts",
                                          "userID__userID", "userID__username")
-            userid = order_list['userID__userID']
-            username = order_list['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']

+ 1 - 1
Controller/EquipmentManager.py

@@ -395,7 +395,7 @@ def addInterface(request):
                 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

+ 1 - 1
Controller/EquipmentManagerV3.py

@@ -96,7 +96,7 @@ class EquipmentManagerV3(View):
                     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