|
@@ -57,6 +57,8 @@ class UnicomComboView(View):
|
|
|
return self.device_add(request_dict, response)
|
|
|
elif operation == 'device-status':
|
|
|
return self.update_device_status(request_dict, response)
|
|
|
+ elif operation == 'update-card':
|
|
|
+ return self.update_device_card_type(request_dict, response)
|
|
|
elif operation == 'xxx-sign':
|
|
|
return self.get_test_sign(request_dict, response)
|
|
|
else:
|
|
@@ -121,7 +123,7 @@ class UnicomComboView(View):
|
|
|
}
|
|
|
activate_flow = float(flow_details['flowTotalUsage'])
|
|
|
flow_total_usage = unicom_api.get_flow_usage_total(iccid)
|
|
|
- flow = flow_total_usage - activate_flow
|
|
|
+ flow = 0 if flow_total_usage <= 0 else flow_total_usage - activate_flow
|
|
|
flow_details['usableFlow'] = flow_details['flowTotal'] - flow
|
|
|
|
|
|
flow_details['usableFlow'] = \
|
|
@@ -235,6 +237,33 @@ class UnicomComboView(View):
|
|
|
logger.info('PC工具重置异常ICCID{},msg={}'.format(iccid, ex))
|
|
|
return response.json(177, ex)
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def update_device_card_type(cls, request_dict, response):
|
|
|
+ """
|
|
|
+ 修改设备卡类型(0:内置卡,1:外插卡)
|
|
|
+ """
|
|
|
+ serial_no = request_dict.get('serialNo', None)
|
|
|
+ time_stamp = request_dict.get('timeStamp', None)
|
|
|
+ sign = request_dict.get('sign', None)
|
|
|
+ main_card = request_dict.get('type', None)
|
|
|
+ if not all([serial_no, main_card, sign, time_stamp]):
|
|
|
+ return response.json(444)
|
|
|
+ try:
|
|
|
+ if not CommonService.check_time_stamp_token(sign, time_stamp):
|
|
|
+ return response.json(13)
|
|
|
+ now_time = int(time.time())
|
|
|
+ with transaction.atomic():
|
|
|
+ unicom_device_qs = UnicomDeviceInfo.objects.filter(serial_no=serial_no)
|
|
|
+ if not unicom_device_qs.exists():
|
|
|
+ return response.json(173)
|
|
|
+ unicom_device_qs.update(main_card=int(main_card), updated_time=now_time)
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ print(e.args)
|
|
|
+ ex = traceback.format_exc()
|
|
|
+ print(ex)
|
|
|
+ return response.json(177, ex)
|
|
|
+
|
|
|
@classmethod
|
|
|
def get_device_info(cls, request_dict, response):
|
|
|
"""
|