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.
43 lines
2.2 KiB
43 lines
2.2 KiB
from dspt_api.util.general.handle_redis import get_data_from_redis |
|
from dspt_api.util.general.get_order_num import general_order_num |
|
import time |
|
import random |
|
|
|
|
|
class ApiEcardRegist: |
|
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): |
|
request_api = {'name': '3.4.1 获取联名卡等级', 'path': 'ecard/ecard-levels'} |
|
redis_key_api = f'dspt_api_{self.ip}_{self.member_type}_{request_api["path"]}' |
|
result, _format, redis_data, _timestamp = get_data_from_redis(redis_key_api) |
|
if result: |
|
level_data = random.choice(redis_data) |
|
level_no = level_data['ecardLevelNo'] |
|
fee = level_data['registerFee'] |
|
order_num = general_order_num('REG', self.api, self.member_type, self.ip) |
|
return [ |
|
{'param': 'mobile', 'value': 18688886666, 'is_checked': True, 'result': True, 'timestamp': _timestamp}, |
|
{'param': 'register_fee', 'value': fee, 'is_checked': True, 'result': True, 'timestamp': _timestamp}, |
|
{'param': 'ecard_level_no', 'value': level_no, 'is_checked': True, 'result': True, |
|
'timestamp': _timestamp}, |
|
{'param': 'partner_order_no', 'value': order_num, 'is_checked': True, 'result': True, |
|
'timestamp': _timestamp}] |
|
else: |
|
# 返回推荐参数应该包含参数名,参数值,和是否勾选的状态 |
|
return [ |
|
{'param': 'mobile', 'value': 18688886666, 'is_checked': True, 'result': True, 'timestamp': _timestamp}, |
|
{'param': 'register_fee', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': True, |
|
'timestamp': _timestamp}, |
|
{'param': 'ecard_level_no', 'value': redis_data + request_api["name"], 'is_checked': True, |
|
'result': True, |
|
'timestamp': _timestamp}, |
|
{'param': 'partner_order_no', 'value': '', 'is_checked': True, 'result': True, |
|
'timestamp': _timestamp} |
|
] |
|
|
|
def get_timestamp(self): |
|
return int(time.time() * 1000)
|
|
|