lang 3 жил өмнө
parent
commit
eac6cb6a23

+ 19 - 3
Controller/PaymentCycle.py

@@ -305,14 +305,17 @@ class PaypalCycleNotify(View):
                     # 订阅续费订单(如果完成周期数`不是0, 则说明是续费订单,)
                     if billing_agreement.agreement_details.cycles_completed == '0':
                         return HttpResponse('success')
-                    orderID = billing_agreement.description
-                    order_qs = Order_Model.objects.filter(orderID=orderID, status=1)
+                    oldOrderID = billing_agreement.description
+                    order_qs = Order_Model.objects.filter(orderID=oldOrderID, status=1)
                     if not order_qs:
                         return HttpResponse('fail')
                     order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts",
                                                  "userID__userID","uid_bucket_id",
-                                                 "userID__username",'plan_id','addTime','desc','payType','currency','commodity_type')
+                                                 "userID__username",'plan_id','addTime','desc','payType','currency','commodity_type','updTime')
                     nowTime = int(time.time())
+                    if order_list[0]['userID__userID'] + 9200 > nowTime:  #避免续费订单重复支付
+                        return HttpResponse('success')
+
                     userid = order_list[0]['userID__userID']
                     username = order_list[0]['userID__username']
                     UID = order_list[0]['UID']
@@ -401,6 +404,19 @@ class PaypalCycleNotify(View):
                                                                         sys_msg_text_list, 'SMS_219738485')
                         logger.info('-----------------------result')
                         logger.info('success')
+
+                        #更新agreement
+                        billing_agreement_update_attributes = [
+                            {
+                                "op": "replace",
+                                "path": "/",
+                                "value": {
+                                    "description": orderID,
+                                }
+                            }
+                        ]
+                        billing_agreement.replace(billing_agreement_update_attributes)
+
                         return HttpResponse('success')
                 except Exception as e:
                     print(e)