|
@@ -400,13 +400,15 @@ class PaypalCycleNotify(View):
|
|
|
paymentID = paypal_body.get('parent_payment')
|
|
|
if paymentID and paypal_transaction_id:
|
|
|
# 查询客户地区信息,地区跟服务器配置不匹配,返回500
|
|
|
- order_qs = Order_Model.objects.filter(paymentID=paymentID).values('userID__region_country')
|
|
|
+ order_qs = Order_Model.objects.filter(paymentID=paymentID).values('UID', 'userID__region_country')
|
|
|
if not order_qs.exists():
|
|
|
PAY_LOGGER.info('PayPal周期扣款失败---根据paymentID查询订单数据不存在')
|
|
|
return HttpResponse('Fail', status=500)
|
|
|
|
|
|
+ # 判断用户地区是否跟服务器地区匹配
|
|
|
+ uid = order_qs[0]['UID']
|
|
|
country_id = order_qs[0]['userID__region_country']
|
|
|
- if not self.config_match_region(country_id):
|
|
|
+ if not self.config_match_region(uid, country_id):
|
|
|
return HttpResponse('Fail', status=500)
|
|
|
|
|
|
order_qs.update(status=1, updTime=nowTime, trade_no=paypal_transaction_id)
|
|
@@ -440,8 +442,10 @@ class PaypalCycleNotify(View):
|
|
|
PAY_LOGGER.info('PayPal周期扣款失败---根据order_id查询订单数据不存在')
|
|
|
return HttpResponse('fail', status=500)
|
|
|
|
|
|
+ # 判断用户地区是否跟服务器地区匹配
|
|
|
+ uid = order_qs[0]['UID']
|
|
|
country_id = order_qs[0]['userID__region_country']
|
|
|
- if not self.config_match_region(country_id):
|
|
|
+ if not self.config_match_region(uid, country_id):
|
|
|
return HttpResponse('Fail', status=500)
|
|
|
|
|
|
UID = order_qs[0]['UID']
|
|
@@ -579,9 +583,21 @@ class PaypalCycleNotify(View):
|
|
|
return HttpResponse('fail', status=500)
|
|
|
|
|
|
@staticmethod
|
|
|
- def config_match_region(country_id):
|
|
|
+ def config_match_region(uid, country_id):
|
|
|
+ """
|
|
|
+ 判断用户地区是否跟服务器地区匹配
|
|
|
+ @param uid: uid
|
|
|
+ @param country_id: 国家表id
|
|
|
+ @return: bool
|
|
|
+ """
|
|
|
country_qs = CountryModel.objects.filter(id=country_id).values('region_id')
|
|
|
+ # 不确定用户地区信息,默认美洲
|
|
|
+ if not country_qs.exists() and CONFIG_INFO == CONFIG_EUR:
|
|
|
+ PAY_LOGGER.info('PayPal周期扣款失败---不确定地区的用户请求欧洲服,uid:{},country_id:{}'.format(uid, country_id))
|
|
|
+ return False
|
|
|
+
|
|
|
region_id = country_qs[0]['region_id']
|
|
|
+ PAY_LOGGER.info('uid{}的用户地区信息: country_id:{}, region_id:{}'.format(uid, country_id, region_id))
|
|
|
if (CONFIG_INFO == CONFIG_US and region_id == 4) or (CONFIG_INFO == CONFIG_EUR and region_id != 4):
|
|
|
PAY_LOGGER.info('PayPal周期扣款失败---服务器跟用户地区不匹配')
|
|
|
return False
|