|
@@ -1271,11 +1271,13 @@ class CronComparedDataView(View):
|
|
timestamp = int(start_time.timestamp())
|
|
timestamp = int(start_time.timestamp())
|
|
count = len(order_list)
|
|
count = len(order_list)
|
|
total = 0
|
|
total = 0
|
|
|
|
+ more_order_list = []
|
|
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'] == 'T1107':
|
|
if item['transaction_info']['transaction_event_code'] == 'T1107':
|
|
trade_no = item['transaction_info']['paypal_reference_id']
|
|
trade_no = item['transaction_info']['paypal_reference_id']
|
|
|
|
+ more_order_list.append(trade_no)
|
|
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', '')
|
|
transaction_subject = item['transaction_info'].get('transaction_subject', '')
|
|
@@ -1310,10 +1312,14 @@ class CronComparedDataView(View):
|
|
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():
|
|
- daily_reconciliation.update(paypal_num=count, paypal_total=total, upd_time=now_time)
|
|
|
|
|
|
+ if daily_reconciliation.first().order_ids:
|
|
|
|
+ more_order_list = daily_reconciliation.first().order_ids.split(',') + more_order_list
|
|
|
|
+ order_ids = ','.join(more_order_list)
|
|
|
|
+ daily_reconciliation.update(paypal_num=count, paypal_total=total, upd_time=now_time, order_ids=order_ids)
|
|
else:
|
|
else:
|
|
|
|
+ order_ids = ','.join(more_order_list)
|
|
DailyReconciliation.objects.create(paypal_num=count, paypal_total=total, time=timestamp,
|
|
DailyReconciliation.objects.create(paypal_num=count, paypal_total=total, time=timestamp,
|
|
- creat_time=now_time, upd_time=now_time)
|
|
|
|
|
|
+ order_ids=order_ids, creat_time=now_time, upd_time=now_time)
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
def compared_wechat_order(response):
|
|
def compared_wechat_order(response):
|
|
@@ -1421,7 +1427,7 @@ class CronComparedDataView(View):
|
|
end_date_stamp = int(end_date.timestamp())
|
|
end_date_stamp = int(end_date.timestamp())
|
|
try:
|
|
try:
|
|
order_qs = Order_Model.objects.filter(status=1, payType=1, payTime__gte=start_date_stamp,
|
|
order_qs = Order_Model.objects.filter(status=1, payType=1, payTime__gte=start_date_stamp,
|
|
- payTime__lt=end_date_stamp).values('trade_no', 'price')
|
|
|
|
|
|
+ payTime__lt=end_date_stamp).values('orderID', 'trade_no', 'price')
|
|
if CONFIG_INFO == CONFIG_EUR:
|
|
if CONFIG_INFO == CONFIG_EUR:
|
|
return response.json(0, list(order_qs))
|
|
return response.json(0, list(order_qs))
|
|
thread = threading.Thread(target=CronComparedDataView.thread_compared_ansjer_order,
|
|
thread = threading.Thread(target=CronComparedDataView.thread_compared_ansjer_order,
|
|
@@ -1452,20 +1458,26 @@ class CronComparedDataView(View):
|
|
count = len(all_order_list)
|
|
count = len(all_order_list)
|
|
paypal_api = paypalrestsdk.Api(PAYPAL_CRD)
|
|
paypal_api = paypalrestsdk.Api(PAYPAL_CRD)
|
|
for index, order in enumerate(all_order_list):
|
|
for index, order in enumerate(all_order_list):
|
|
|
|
+ if not order['trade_no']:
|
|
|
|
+ more_order_list.append(order['orderID'])
|
|
|
|
+ continue
|
|
total += float(order['price'])
|
|
total += float(order['price'])
|
|
if all_order_list.index(order) != index:
|
|
if all_order_list.index(order) != index:
|
|
- more_order_list.append(order['trade_no'])
|
|
|
|
|
|
+ more_order_list.append(order['orderID'])
|
|
continue
|
|
continue
|
|
paypal_url = 'v1/reporting/transactions?start_date={}-{}-01T00:00:00-0700&end_date={}-{}-01T00:00:00-0700&transaction_id={}&fields=all&page_size=100&page=1'.format(
|
|
paypal_url = 'v1/reporting/transactions?start_date={}-{}-01T00:00:00-0700&end_date={}-{}-01T00:00:00-0700&transaction_id={}&fields=all&page_size=100&page=1'.format(
|
|
begin_date.year, begin_date.month, end_date.year, end_date.month, order['trade_no'])
|
|
begin_date.year, begin_date.month, end_date.year, end_date.month, order['trade_no'])
|
|
paypal_order_list = paypal_api.get(paypal_url)
|
|
paypal_order_list = paypal_api.get(paypal_url)
|
|
if not paypal_order_list['transaction_details']:
|
|
if not paypal_order_list['transaction_details']:
|
|
- more_order_list.append(order['trade_no'])
|
|
|
|
- trade_nos = ','.join(more_order_list)
|
|
|
|
|
|
+ more_order_list.append(order['orderID'])
|
|
total = round(total, 2)
|
|
total = round(total, 2)
|
|
daily_reconciliation = DailyReconciliation.objects.filter(time=start_timestamp)
|
|
daily_reconciliation = DailyReconciliation.objects.filter(time=start_timestamp)
|
|
if daily_reconciliation.exists():
|
|
if daily_reconciliation.exists():
|
|
- daily_reconciliation.update(ansjer_total=total, ansjer_num=count, trade_nos=trade_nos, upd_time=now_time)
|
|
|
|
|
|
+ if daily_reconciliation.first().order_ids:
|
|
|
|
+ more_order_list = daily_reconciliation.first().order_ids.split(',') + more_order_list
|
|
|
|
+ order_ids = ','.join(more_order_list)
|
|
|
|
+ daily_reconciliation.update(ansjer_total=total, ansjer_num=count, order_ids=order_ids, upd_time=now_time)
|
|
else:
|
|
else:
|
|
- DailyReconciliation.objects.create(trade_nos=trade_nos, ansjer_total=total, ansjer_num=count,
|
|
|
|
|
|
+ order_ids = ','.join(more_order_list)
|
|
|
|
+ DailyReconciliation.objects.create(order_ids=order_ids, ansjer_total=total, ansjer_num=count,
|
|
time=start_timestamp, creat_time=now_time, upd_time=now_time)
|
|
time=start_timestamp, creat_time=now_time, upd_time=now_time)
|