You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
3.2 KiB
66 lines
3.2 KiB
3 months ago
|
import time
|
||
|
from django_redis import get_redis_connection
|
||
|
from dspt_api.util.general.get_order_num import general_order_num
|
||
|
from dspt_api.util.general.handle_redis import get_data_from_redis
|
||
|
|
||
|
|
||
|
class ApiEcardRefund:
|
||
|
def __init__(self, **kwargs):
|
||
|
self.member_type = kwargs.get('member_type')
|
||
|
self.api = kwargs.get('api')
|
||
|
self.ip = kwargs.get('ip')
|
||
|
|
||
|
def get_suggestion(self):
|
||
|
# partner_order_no
|
||
|
order_num = general_order_num('REF', self.api, self.member_type, self.ip)
|
||
|
# source_order_no
|
||
|
_now = int(time.time() * 1000)
|
||
|
request_renew = {'name': '3.4.3 联名卡续卡', 'path': 'ecard/renew'}
|
||
|
redis_key_renew_order_num = f'dspt_api_{self.ip}_{self.member_type}_{request_renew["path"]}_order_num'
|
||
|
redis_key_renew = f'dspt_api_{self.ip}_{self.member_type}_{request_renew["path"]}'
|
||
|
|
||
|
request_regist = {'name': '3.4.2 联名卡开卡', 'path': 'ecard/regist'}
|
||
|
redis_key_regist_order_num = f'dspt_api_{self.ip}_{self.member_type}_{request_regist["path"]}_order_num'
|
||
|
redis_key_regist = f'dspt_api_{self.ip}_{self.member_type}_{request_regist["path"]}'
|
||
|
|
||
|
result_renew, _format__renew, redis_data_renew, _timestamp_renew = get_data_from_redis(redis_key_renew)
|
||
|
result_regist, _format_regist, redis_data_regist, _timestamp_regist = get_data_from_redis(redis_key_regist)
|
||
|
|
||
|
redis_conn = get_redis_connection()
|
||
|
order_num_renew = redis_conn.get(redis_key_renew_order_num)
|
||
|
print('order_num_renew', order_num_renew)
|
||
|
order_num_regist = redis_conn.get(redis_key_regist_order_num)
|
||
|
print('order_num_regist', order_num_regist)
|
||
|
|
||
|
order_num_result = [
|
||
|
{'param': 'source_order_no', 'value': '请手动输入参数!', 'is_checked': True, 'result': True,
|
||
|
'timestamp': _now},
|
||
|
{'param': 'partner_order_no', 'value': order_num, 'is_checked': True, 'result': True,
|
||
|
'timestamp': int(time.time() * 1000)}]
|
||
|
|
||
|
if order_num_regist:
|
||
|
order_num_result_regist = [
|
||
|
{'param': 'source_order_no', 'value': str(order_num_regist, encoding='utf-8'), 'is_checked': True,
|
||
|
'result': True, 'timestamp': _now},
|
||
|
{'param': 'partner_order_no', 'value': order_num, 'is_checked': True, 'result': True,
|
||
|
'timestamp': int(time.time() * 1000)}]
|
||
|
if order_num_renew:
|
||
|
order_num_result_renew = [
|
||
|
{'param': 'source_order_no', 'value': str(order_num_renew, encoding='utf-8'), 'is_checked': True,
|
||
|
'result': True,
|
||
|
'timestamp': _now},
|
||
|
{'param': 'partner_order_no', 'value': order_num, 'is_checked': True, 'result': True,
|
||
|
'timestamp': int(time.time() * 1000)}]
|
||
|
|
||
|
if order_num_renew:
|
||
|
order_num_result = order_num_result_renew
|
||
|
if order_num_regist:
|
||
|
order_num_result = order_num_result_regist
|
||
|
if order_num_renew and order_num_regist:
|
||
|
order_num_result = order_num_result_regist if _timestamp_regist > _timestamp_renew else order_num_result_renew
|
||
|
|
||
|
return order_num_result
|
||
|
|
||
|
def get_timestamp(self):
|
||
|
return int(time.time() * 1000)
|