|
@@ -255,7 +255,6 @@ class PaypalCycleNotify(View):
|
|
|
(uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime, addTime=nowTime,
|
|
|
updateTime=nowTime, use_status=1)
|
|
|
uid_bucket_id = ub_cqs.id
|
|
|
-
|
|
|
dvq = Device_Info.objects.filter(UID=UID, vodPrimaryUserID='', vodPrimaryMaster='')
|
|
|
if dvq.exists():
|
|
|
dvq_set_update_dict = {
|
|
@@ -396,7 +395,7 @@ class PaypalCycleNotify(View):
|
|
|
PaypalWebHookEventInsert['agreement_desc'] = repr(billing_agreement)
|
|
|
PaypalWebHookEventInsert['agreement_id'] = agreement_id
|
|
|
PaypalWebHookEventInsert['orderID'] = billing_agreement.description
|
|
|
- PaypalWebHookEvent.objects.create(**PaypalWebHookEventInsert)
|
|
|
+ paypal_webhook_event_qs = PaypalWebHookEvent.objects.create(**PaypalWebHookEventInsert)
|
|
|
|
|
|
# 查询订单数据
|
|
|
order_id = billing_agreement.description
|
|
@@ -411,9 +410,6 @@ class PaypalCycleNotify(View):
|
|
|
PAY_LOGGER.info('PayPal周期扣款失败---根据order_id查询订单数据不存在')
|
|
|
return HttpResponse('fail', status=500)
|
|
|
|
|
|
- # 更新PayPal交易号
|
|
|
- order_qs.update(trade_no=paypal_transaction_id)
|
|
|
-
|
|
|
# 判断用户地区是否跟服务器地区匹配
|
|
|
uid = order_qs[0]['UID']
|
|
|
country_id = order_qs[0]['userID__region_country']
|
|
@@ -423,7 +419,7 @@ class PaypalCycleNotify(View):
|
|
|
UID = order_qs[0]['UID']
|
|
|
# PayPal周期扣款首次扣款
|
|
|
if billing_agreement.agreement_details.cycles_completed == '0':
|
|
|
- order_qs.update(status=1, updTime=nowTime)
|
|
|
+ order_qs.update(status=1, trade_no=paypal_transaction_id, updTime=nowTime)
|
|
|
PAY_LOGGER.info('{} PayPal周期扣款首次扣款成功'.format(UID))
|
|
|
return HttpResponse('success')
|
|
|
|
|
@@ -448,7 +444,6 @@ class PaypalCycleNotify(View):
|
|
|
|
|
|
bucketId = store_meal_qs[0]['bucket_id']
|
|
|
expire = store_meal_qs[0]['expire']
|
|
|
-
|
|
|
ubqs = UID_Bucket.objects.filter(uid=UID).values("id", "bucket_id", "bucket__storeDay", "bucket__region",
|
|
|
"endTime", "use_status")
|
|
|
|
|
@@ -525,7 +520,11 @@ class PaypalCycleNotify(View):
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
- billing_agreement.replace(billing_agreement_update_attributes)
|
|
|
+ update_status = billing_agreement.replace(billing_agreement_update_attributes)
|
|
|
+
|
|
|
+ # 记录新订单号和更新状态
|
|
|
+ PaypalWebHookEvent.objects.filter(id=paypal_webhook_event_qs.id).update(newOrderID=orderID,
|
|
|
+ update_status=update_status)
|
|
|
PAY_LOGGER.info('{} PayPal周期扣款成功'.format(UID))
|
|
|
return HttpResponse('success')
|
|
|
except Exception as e:
|