|
@@ -127,9 +127,9 @@ class UnicomComboView(View):
|
|
flow = 0 if flow_total_usage <= 0 else flow_total_usage - activate_flow
|
|
flow = 0 if flow_total_usage <= 0 else flow_total_usage - activate_flow
|
|
# 因APP问题,usableFlow可用流量替换为,已用流量值
|
|
# 因APP问题,usableFlow可用流量替换为,已用流量值
|
|
flow_details['usableFlow'] = 0 if flow == 0 else flow
|
|
flow_details['usableFlow'] = 0 if flow == 0 else flow
|
|
- flow_details['usableFlow'] = \
|
|
|
|
- flow_details['flowTotal'] if flow_details['usableFlow'] > flow_details['flowTotal'] else \
|
|
|
|
- flow_details['usableFlow']
|
|
|
|
|
|
+ flow_details['usableFlow'] = flow_details['flowTotal'] \
|
|
|
|
+ if flow_details['usableFlow'] > flow_details['flowTotal'] \
|
|
|
|
+ else flow_details['usableFlow']
|
|
flow_details['usableFlow'] = Decimal(flow_details['usableFlow']).quantize(Decimal('0.00'))
|
|
flow_details['usableFlow'] = Decimal(flow_details['usableFlow']).quantize(Decimal('0.00'))
|
|
flow_details.pop('flowTotalUsage')
|
|
flow_details.pop('flowTotalUsage')
|
|
cls.update_combo_order_sort(iccid)
|
|
cls.update_combo_order_sort(iccid)
|
|
@@ -217,6 +217,10 @@ class UnicomComboView(View):
|
|
device_info_qs = UnicomDeviceInfo.objects.filter(serial_no=serial_no)
|
|
device_info_qs = UnicomDeviceInfo.objects.filter(serial_no=serial_no)
|
|
if device_info_qs.exists():
|
|
if device_info_qs.exists():
|
|
iccid = device_info_qs.first().iccid
|
|
iccid = device_info_qs.first().iccid
|
|
|
|
+ if device_info_qs.first().card_type == 1:
|
|
|
|
+ cls.reset_telecom_user(serial_no)
|
|
|
|
+ device_info_qs.update(updated_time=now_time, user_id='')
|
|
|
|
+ return response.json(0)
|
|
key = 'ASJ:UNICOM:RESET:{}'.format(serial_no)
|
|
key = 'ASJ:UNICOM:RESET:{}'.format(serial_no)
|
|
flow_push_qs = UnicomFlowPush.objects.filter(serial_no=serial_no)
|
|
flow_push_qs = UnicomFlowPush.objects.filter(serial_no=serial_no)
|
|
if flow_push_qs.exists():
|
|
if flow_push_qs.exists():
|
|
@@ -241,6 +245,18 @@ class UnicomComboView(View):
|
|
logger.info('PC工具重置异常ICCID{},msg={}'.format(iccid, ex))
|
|
logger.info('PC工具重置异常ICCID{},msg={}'.format(iccid, ex))
|
|
return response.json(177, ex)
|
|
return response.json(177, ex)
|
|
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def reset_telecom_user(serial_no):
|
|
|
|
+ """
|
|
|
|
+ 重置电信用户 消息记录
|
|
|
|
+ @param serial_no:
|
|
|
|
+ @return:
|
|
|
|
+ """
|
|
|
|
+ sys_msg_qs = SysMsgModel.objects.filter(uid=serial_no)
|
|
|
|
+ if sys_msg_qs.exists():
|
|
|
|
+ sys_msg_qs.delete()
|
|
|
|
+ return True
|
|
|
|
+
|
|
@classmethod
|
|
@classmethod
|
|
def update_device_card_type(cls, request_dict, response):
|
|
def update_device_card_type(cls, request_dict, response):
|
|
"""
|
|
"""
|
|
@@ -276,10 +292,10 @@ class UnicomComboView(View):
|
|
@param response:
|
|
@param response:
|
|
@return:
|
|
@return:
|
|
"""
|
|
"""
|
|
- serial_no = request_dict.get('serialNumber', None)
|
|
|
|
- if not serial_no:
|
|
|
|
|
|
+ iccid = request_dict.get('iccid', None)
|
|
|
|
+ if not iccid:
|
|
return response.json(444)
|
|
return response.json(444)
|
|
- unicom_device_info_qs = UnicomDeviceInfo.objects.filter(serial_no=serial_no).values()
|
|
|
|
|
|
+ unicom_device_info_qs = UnicomDeviceInfo.objects.filter(iccid=iccid).values()
|
|
if not unicom_device_info_qs.exists():
|
|
if not unicom_device_info_qs.exists():
|
|
return response.json(173)
|
|
return response.json(173)
|
|
return response.json(0, dict(unicom_device_info_qs.first()))
|
|
return response.json(0, dict(unicom_device_info_qs.first()))
|
|
@@ -324,6 +340,13 @@ class UnicomComboView(View):
|
|
if sim == 0:
|
|
if sim == 0:
|
|
return response.json(0, '外置卡不保存相关信息{}'.format(serial_no))
|
|
return response.json(0, '外置卡不保存相关信息{}'.format(serial_no))
|
|
unicom_obj = UnicomObjeect()
|
|
unicom_obj = UnicomObjeect()
|
|
|
|
+ params = {'iccid': iccid, 'serial_no': serial_no, 'updated_time': n_time,
|
|
|
|
+ 'created_time': n_time, 'main_card': sim}
|
|
|
|
+ if cls.check_iccid(iccid):
|
|
|
|
+ params['card_type'] = 1
|
|
|
|
+ params['status'] = 2
|
|
|
|
+ UnicomDeviceInfo.objects.create(**params)
|
|
|
|
+ return response.json(0)
|
|
result = unicom_obj.verify_device(iccid=iccid)
|
|
result = unicom_obj.verify_device(iccid=iccid)
|
|
if result.status_code == 200 and result.text:
|
|
if result.status_code == 200 and result.text:
|
|
res_dict = json.loads(result.text)
|
|
res_dict = json.loads(result.text)
|
|
@@ -331,8 +354,6 @@ class UnicomComboView(View):
|
|
if res_dict['data']['status'] == 0:
|
|
if res_dict['data']['status'] == 0:
|
|
logger.info('--->设备请求绑定{}验证不存在{}'.format(iccid, res_dict))
|
|
logger.info('--->设备请求绑定{}验证不存在{}'.format(iccid, res_dict))
|
|
return response.json(173)
|
|
return response.json(173)
|
|
- params = {'iccid': iccid, 'serial_no': serial_no, 'updated_time': n_time,
|
|
|
|
- 'created_time': n_time, 'main_card': sim}
|
|
|
|
unicom_obj.change_device_to_activate(iccid)
|
|
unicom_obj.change_device_to_activate(iccid)
|
|
UnicomDeviceInfo.objects.create(**params)
|
|
UnicomDeviceInfo.objects.create(**params)
|
|
return response.json(0)
|
|
return response.json(0)
|
|
@@ -345,6 +366,20 @@ class UnicomComboView(View):
|
|
logger.info('--->设备调用4G注册接口异常:{}'.format(ex))
|
|
logger.info('--->设备调用4G注册接口异常:{}'.format(ex))
|
|
return response.json(177, repr(e))
|
|
return response.json(177, repr(e))
|
|
|
|
|
|
|
|
+ @classmethod
|
|
|
|
+ def check_iccid(cls, iccid):
|
|
|
|
+ """
|
|
|
|
+ 检查ICCID是否是五兴科技卡
|
|
|
|
+ @return: True or False
|
|
|
|
+ """
|
|
|
|
+ if not iccid:
|
|
|
|
+ return False
|
|
|
|
+ iccid = iccid[0:6]
|
|
|
|
+ arr_list = ['898603', '898611']
|
|
|
|
+ if iccid in arr_list:
|
|
|
|
+ return True
|
|
|
|
+ return False
|
|
|
|
+
|
|
@classmethod
|
|
@classmethod
|
|
def user_activate_flow(cls, iccid):
|
|
def user_activate_flow(cls, iccid):
|
|
"""
|
|
"""
|