Browse Source

feature:测试支付宝支付回调功能

chenjunkai 6 years ago
parent
commit
fb1193bd62
2 changed files with 10 additions and 8 deletions
  1. 9 7
      Controller/CloudVod.py
  2. 1 1
      Controller/Test.py

+ 9 - 7
Controller/CloudVod.py

@@ -189,14 +189,14 @@ class CloudVodView(View):
         return response.json(0, signature)
 
     def do_pay_by_ali(self, request_dict, userID, response):
-        did = request_dict.get('did', None)
+        uid = request_dict.get('uid', None)
         rank = request_dict.get('rank', None)
         channel = request_dict.get('channel', None)
-        qs = Device_Info.objects.filter(userID_id=userID, id=did, isShare=False).values("UID")
+        qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False)
         if not qs.exists():
             return response.json(12)
-        if not did or not channel or not rank:
-            return response.json(444, 'did,channel,rank')
+        if not channel or not rank:
+            return response.json(444, 'channel,rank')
         smqs = Store_Meal.objects.filter(id=rank). \
             values("currency", "price", "content", "day", "bucket__storeDay", "bucket__region")
         if not smqs.exists():
@@ -205,7 +205,6 @@ class CloudVodView(View):
         price = smqs[0]['price']
         content = smqs[0]['content']
         day = smqs[0]['day']
-        uid = qs[0]['UID']
         nowTime = int(time.time())
         ubqs = UID_Bucket.objects.filter(uid=uid, channel=channel, endTime__gte=nowTime). \
             values("bucket__storeDay", "bucket__region")
@@ -235,16 +234,19 @@ class CloudVodView(View):
                 out_trade_no=orderID,
                 total_amount=0.01,
                 subject="实用性充气式玩具",
-                return_url="http://test.dvema.com/cloudVod/payOK",
-                notify_url="http://test.dvema.com/cloudVod/aliPayCallback")
+                return_url="https://test.dvema.com/cloudVod/payOK",
+                notify_url="https://test.dvema.com/cloudVod/aliPayCallback")
         except Exception as e:
             print(repr(e))
             return response.json(10, repr(e))
         if order_string:
             redirectUrl = "https://openapi.alipaydev.com/gateway.do?" + order_string
+            # from django.http import HttpResponseRedirect
+            # return HttpResponseRedirect("https://openapi.alipaydev.com/gateway.do?" + order_string)
             Order_Model.objects.create(orderID=orderID, UID=uid, channel=channel, userID_id=userID, desc=content,
                                        price=price, currency=currency, addTime=nowTime, updTime=nowTime,
                                        endTime=nowTime + int(day) * 3600 * 24, rank_id=rank, paypal='', payType=1)
+            return JsonResponse(status=200, data={"redirectUrl": redirectUrl,"code":0})
             return response.json(0, {"redirectUrl": redirectUrl})
         else:
             return response.json(10, '生成订单错误')

+ 1 - 1
Controller/Test.py

@@ -51,7 +51,7 @@ class Test(View):
         from django.http import HttpResponseRedirect
         # return response.json(0,"https://openapi.alipay.com/gateway.do? + {order_string}".format(order_string=order_string))
         print(order_string)
-        return HttpResponseRedirect("https://openapi.alipaydev.com/gateway.do?" + order_string+'&order')
+        return HttpResponseRedirect("https://openapi.alipaydev.com/gateway.do?" + order_string)
         return HttpResponseRedirect("https://openapi.alipay.com/gateway.do?" + order_string)
 
     def post(self, request, *args, **kwargs):