|
@@ -1432,7 +1432,7 @@ class CronComparedDataView(View):
|
|
('transaction_status', 'S')
|
|
('transaction_status', 'S')
|
|
)
|
|
)
|
|
order_list = PayPalService(PAYPAL_CRD['client_id'], PAYPAL_CRD['client_secret']).get_transactions(data)
|
|
order_list = PayPalService(PAYPAL_CRD['client_id'], PAYPAL_CRD['client_secret']).get_transactions(data)
|
|
- thread = threading.Thread(target=CronComparedDataView.thread_compared_pyapal_order,
|
|
|
|
|
|
+ thread = threading.Thread(target=CronComparedDataView.thread_compared_paypal_order,
|
|
args=(order_list['transaction_details'], end_date))
|
|
args=(order_list['transaction_details'], end_date))
|
|
thread.start()
|
|
thread.start()
|
|
return response.json(0)
|
|
return response.json(0)
|
|
@@ -1442,7 +1442,7 @@ class CronComparedDataView(View):
|
|
return response.json(500)
|
|
return response.json(500)
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
- def thread_compared_pyapal_order(order_list, start_time):
|
|
|
|
|
|
+ def thread_compared_paypal_order(order_list, start_time):
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
timestamp = int(start_time.timestamp())
|
|
timestamp = int(start_time.timestamp())
|
|
count = len(order_list)
|
|
count = len(order_list)
|
|
@@ -1597,7 +1597,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')
|
|
|
|
|
|
+ payTime__lt=end_date_stamp).values('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,
|
|
@@ -1605,7 +1605,7 @@ class CronComparedDataView(View):
|
|
thread.start()
|
|
thread.start()
|
|
return response.json(0)
|
|
return response.json(0)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- LOGGER.info('CronComparedDataView.compared_paypal_order, errLine:{}, errMsg:{}'.format(
|
|
|
|
|
|
+ LOGGER.info('CronComparedDataView.compared_ansjer_order, errLine:{}, errMsg:{}'.format(
|
|
e.__traceback__.tb_lineno, repr(e)))
|
|
e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500)
|
|
return response.json(500)
|
|
|
|
|
|
@@ -1626,22 +1626,15 @@ class CronComparedDataView(View):
|
|
total = 0
|
|
total = 0
|
|
all_order_list = order_list + eur_order_list
|
|
all_order_list = order_list + eur_order_list
|
|
count = len(all_order_list)
|
|
count = len(all_order_list)
|
|
-
|
|
|
|
|
|
+ paypal_api = paypalrestsdk.Api(PAYPAL_CRD)
|
|
for index, order in enumerate(all_order_list):
|
|
for index, order in enumerate(all_order_list):
|
|
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['trade_no'])
|
|
continue
|
|
continue
|
|
- data = (
|
|
|
|
- ('start_date', '{}-{}-01T00:00:00-0700'.format(begin_date.year, begin_date.month)),
|
|
|
|
- ('end_date', '{}-{}-01T00:00:00-0700'.format(end_date.year, end_date.month)),
|
|
|
|
- ('transaction_id', order['trade_no']),
|
|
|
|
- ('fields', 'all'),
|
|
|
|
- ('page_size', '100'),
|
|
|
|
- ('page', '1'),
|
|
|
|
- )
|
|
|
|
- paypal_order_list = PayPalService(PAYPAL_CRD['client_id'], PAYPAL_CRD['client_secret']).get_transactions(
|
|
|
|
- data)
|
|
|
|
|
|
+ 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'])
|
|
|
|
+ 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'])
|
|
more_order_list.append(order['trade_no'])
|
|
trade_nos = ','.join(more_order_list)
|
|
trade_nos = ','.join(more_order_list)
|