Explorar el Código

优化查询流量统计接口、设备绑定ICCID接口新增SIM卡类型字段

zhangdongming hace 3 años
padre
commit
409763ab00
Se han modificado 1 ficheros con 8 adiciones y 5 borrados
  1. 8 5
      Controller/UnicomCombo/UnicomComboController.py

+ 8 - 5
Controller/UnicomCombo/UnicomComboController.py

@@ -19,13 +19,13 @@ from django.views.generic.base import View
 
 
 from Model.models import UnicomDeviceInfo, UnicomCombo, Pay_Type, Order_Model, Store_Meal, AiStoreMeal, \
 from Model.models import UnicomDeviceInfo, UnicomCombo, Pay_Type, Order_Model, Store_Meal, AiStoreMeal, \
     UnicomComboOrderInfo, UnicomComboExperienceHistory, UnicomDeviceStatusChangePush, SysMsgModel, UnicomFlowPush
     UnicomComboOrderInfo, UnicomComboExperienceHistory, UnicomDeviceStatusChangePush, SysMsgModel, UnicomFlowPush
+from Object.RedisObject import RedisObject
 from Object.ResponseObject import ResponseObject
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Object.TokenObject import TokenObject
 from Object.UnicomObject import UnicomObjeect
 from Object.UnicomObject import UnicomObjeect
 from Object.utils import LocalDateTimeUtil
 from Object.utils import LocalDateTimeUtil
 from Object.utils.PayUtil import PayService
 from Object.utils.PayUtil import PayService
 from Service.CommonService import CommonService
 from Service.CommonService import CommonService
-from Object.RedisObject import RedisObject
 
 
 
 
 class UnicomComboView(View):
 class UnicomComboView(View):
@@ -125,10 +125,11 @@ class UnicomComboView(View):
                 activate_flow = float(flow_details['flowTotalUsage'])
                 activate_flow = float(flow_details['flowTotalUsage'])
                 flow_total_usage = unicom_api.get_flow_usage_total(iccid)
                 flow_total_usage = unicom_api.get_flow_usage_total(iccid)
                 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
-                flow_details['usableFlow'] = flow_details['flowTotal'] - flow
-
+                # 因APP问题,usableFlow可用流量替换为,已用流量值
+                flow_details['usableFlow'] = 0 if flow == 0 else flow
                 flow_details['usableFlow'] = \
                 flow_details['usableFlow'] = \
-                    0.00 if flow_details['usableFlow'] <= 0 else 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)
@@ -294,6 +295,7 @@ class UnicomComboView(View):
         serial_no = request_dict.get('serialNo', None)
         serial_no = request_dict.get('serialNo', None)
         time_stamp = request_dict.get('timeStamp', None)
         time_stamp = request_dict.get('timeStamp', None)
         sign = request_dict.get('sign', None)
         sign = request_dict.get('sign', None)
+        sim = int(request_dict.get('sim', 1))
         logger = logging.getLogger('info')
         logger = logging.getLogger('info')
         logger.info('--->设备调用4G注册接口')
         logger.info('--->设备调用4G注册接口')
         if not all([iccid, serial_no, sign, time_stamp]):
         if not all([iccid, serial_no, sign, time_stamp]):
@@ -309,6 +311,7 @@ class UnicomComboView(View):
                 # 待完善代码 根据uid与用户id验证系统设备
                 # 待完善代码 根据uid与用户id验证系统设备
                 unicom_device_qs = UnicomDeviceInfo.objects.filter(iccid=iccid)
                 unicom_device_qs = UnicomDeviceInfo.objects.filter(iccid=iccid)
                 if unicom_device_qs.exists():
                 if unicom_device_qs.exists():
+                    unicom_device_qs.update(main_card=sim, updated_time=n_time)
                     if unicom_device_qs.first().status == 1 and unicom_device_qs.first().serial_no == serial_no:
                     if unicom_device_qs.first().status == 1 and unicom_device_qs.first().serial_no == serial_no:
                         key = 'ASJ:UNICOM:RESET:{}'.format(serial_no)
                         key = 'ASJ:UNICOM:RESET:{}'.format(serial_no)
                         reset_cache = redis.get_data(key)
                         reset_cache = redis.get_data(key)
@@ -326,7 +329,7 @@ class UnicomComboView(View):
                             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,
                         params = {'iccid': iccid, 'serial_no': serial_no, 'updated_time': n_time,
-                                  'created_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)