|
@@ -308,21 +308,25 @@ class UnicomObjeect:
|
|
|
return True
|
|
|
return None
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def current_sim_traffic_usage_details(icc_id):
|
|
|
+ """
|
|
|
+ 当前sim卡流量使用详情
|
|
|
+ @param icc_id:20位数字iccid
|
|
|
+ @return: traffic
|
|
|
+ """
|
|
|
+ redis = RedisObject()
|
|
|
+ traffic_key = 'ASJ:UNICOM:FLOW:{}'.format(icc_id)
|
|
|
+ traffic_sys = 'ASJ:SIM:TRAFFIC:{}'.format(icc_id)
|
|
|
+ traffic_val = redis.get_data(traffic_key)
|
|
|
+ if traffic_val:
|
|
|
+ traffic_dict = json.loads(traffic_val)
|
|
|
+ redis.set_data(key=traffic_sys, val=traffic_val, expire=60 * 60 * 24)
|
|
|
+ else:
|
|
|
+ traffic_val = redis.get_data(traffic_sys)
|
|
|
+ if not traffic_val:
|
|
|
+ return 0
|
|
|
+ traffic_dict = json.loads(traffic_val)
|
|
|
+ return traffic_dict['data']['flowTotalUsage']
|
|
|
|
|
|
-if __name__ == '__main__':
|
|
|
- unicom_api = UnicomObjeect()
|
|
|
- # result = unicom_api.generate_token()
|
|
|
- # result = unicom_api.refresh_token('5d0c0f30-99bd-4f17-9614-3524495b05d4')
|
|
|
- params = {'iccid': '89860620170009631443', 'status': 1}
|
|
|
- # response = unicom_api.verify_device(**params)
|
|
|
- # response = unicom_api.query_device_status(**params)
|
|
|
- response = unicom_api.update_device_state(**params)
|
|
|
- # response = unicom_api.query_device_usage_history(**params)
|
|
|
- # response = unicom_api.query_current_renew_list_usage_details(**params)
|
|
|
- # unicom_api.get_device_batch_detail()
|
|
|
- # response = unicom_api.query_package_list(**params)
|
|
|
- # response = unicom_api.query_renewal_list(**params)
|
|
|
|
|
|
- if response.status_code == 200:
|
|
|
- res = json.loads(response.text)
|
|
|
- print(res)
|