|
@@ -1275,16 +1275,23 @@ class CronComparedDataView(View):
|
|
for item in order_list:
|
|
for item in order_list:
|
|
total += float(item['transaction_info']['transaction_amount']['value'])
|
|
total += float(item['transaction_info']['transaction_amount']['value'])
|
|
trade_no = item['transaction_info']['transaction_id']
|
|
trade_no = item['transaction_info']['transaction_id']
|
|
- if item['transaction_info']['transaction_event_code'] in ['T1107', 'T1201']:
|
|
|
|
|
|
+ if item['transaction_info']['transaction_event_code'] in ['T1107']: # 付款退款,由商户发起
|
|
trade_no = item['transaction_info']['paypal_reference_id']
|
|
trade_no = item['transaction_info']['paypal_reference_id']
|
|
|
|
+ transaction_subject = item['transaction_info'].get('transaction_subject', '')
|
|
|
|
+ agreement_id = item['transaction_info'].get('paypal_reference_id', '')
|
|
|
|
+ refund_order = False
|
|
|
|
+ if item['transaction_info']['transaction_event_code'] in ['T1107', 'T1201', 'T0114']:
|
|
|
|
+ agreement_id = ''
|
|
|
|
+ if item['transaction_info']['transaction_event_code'] in ['T0114']:
|
|
|
|
+ transaction_subject = '争议费'
|
|
|
|
+ else:
|
|
|
|
+ refund_order = True
|
|
|
|
+ transaction_subject = '退款费'
|
|
more_order_list.append(trade_no)
|
|
more_order_list.append(trade_no)
|
|
pay_time = int(datetime.datetime.strptime(item['transaction_info']['transaction_updated_date'],
|
|
pay_time = int(datetime.datetime.strptime(item['transaction_info']['transaction_updated_date'],
|
|
"%Y-%m-%dT%H:%M:%S%z").timestamp())
|
|
"%Y-%m-%dT%H:%M:%S%z").timestamp())
|
|
order_qs = Order_Model.objects.filter(trade_no=trade_no, payType=1)
|
|
order_qs = Order_Model.objects.filter(trade_no=trade_no, payType=1)
|
|
if not order_qs.exists():
|
|
if not order_qs.exists():
|
|
- transaction_subject = item['transaction_info'].get('transaction_subject', '')
|
|
|
|
- agreement_id = item['transaction_info'].get('paypal_reference_id', '')
|
|
|
|
-
|
|
|
|
order_dict = {
|
|
order_dict = {
|
|
'trade_no': trade_no,
|
|
'trade_no': trade_no,
|
|
'agreement_id': agreement_id,
|
|
'agreement_id': agreement_id,
|
|
@@ -1300,7 +1307,7 @@ class CronComparedDataView(View):
|
|
order_dict['pay_type'] = 0
|
|
order_dict['pay_type'] = 0
|
|
order_dict['meal_name'] = 'paypal_cycle'
|
|
order_dict['meal_name'] = 'paypal_cycle'
|
|
order_dict['order_id'] = transaction_subject
|
|
order_dict['order_id'] = transaction_subject
|
|
- params = {'trade_no': trade_no, 'pay_time': pay_time}
|
|
|
|
|
|
+ params = {'trade_no': trade_no, 'pay_time': pay_time, 'refund_order': refund_order}
|
|
response = requests.get('https://www.zositeche.com/testApi/checkOrderExist', params=params)
|
|
response = requests.get('https://www.zositeche.com/testApi/checkOrderExist', params=params)
|
|
if response.status_code != 200:
|
|
if response.status_code != 200:
|
|
# 如果响应失败,记录在数据库
|
|
# 如果响应失败,记录在数据库
|
|
@@ -1311,7 +1318,8 @@ class CronComparedDataView(View):
|
|
# 如果响应结果为空,记录在数据库
|
|
# 如果响应结果为空,记录在数据库
|
|
AbnormalOrder.objects.create(**order_dict)
|
|
AbnormalOrder.objects.create(**order_dict)
|
|
else:
|
|
else:
|
|
- order_qs.update(payTime=pay_time)
|
|
|
|
|
|
+ if not refund_order:
|
|
|
|
+ order_qs.update(payTime=pay_time)
|
|
total = round(total, 2)
|
|
total = round(total, 2)
|
|
daily_reconciliation = DailyReconciliation.objects.filter(time=timestamp)
|
|
daily_reconciliation = DailyReconciliation.objects.filter(time=timestamp)
|
|
if daily_reconciliation.exists():
|
|
if daily_reconciliation.exists():
|
|
@@ -1424,8 +1432,8 @@ class CronComparedDataView(View):
|
|
def compared_ansjer_order(response):
|
|
def compared_ansjer_order(response):
|
|
today = datetime.datetime.today()
|
|
today = datetime.datetime.today()
|
|
start_date = today - datetime.timedelta(days=1)
|
|
start_date = today - datetime.timedelta(days=1)
|
|
- start_date = datetime.datetime(start_date.year, start_date.month, start_date.day)
|
|
|
|
- end_date = datetime.datetime(today.year, today.month, today.day)
|
|
|
|
|
|
+ start_date = datetime.datetime(start_date.year, start_date.month, 1)
|
|
|
|
+ end_date = datetime.datetime(today.year, today.month, 2)
|
|
start_date_stamp = int(start_date.timestamp())
|
|
start_date_stamp = int(start_date.timestamp())
|
|
end_date_stamp = int(end_date.timestamp())
|
|
end_date_stamp = int(end_date.timestamp())
|
|
try:
|
|
try:
|