Browse Source

监控当前流量已用完,记录是否有已超流量

zhangdongming 3 years ago
parent
commit
50a614d79c
1 changed files with 6 additions and 4 deletions
  1. 6 4
      Controller/UnicomCombo/UnicomComboTaskController.py

+ 6 - 4
Controller/UnicomCombo/UnicomComboTaskController.py

@@ -132,12 +132,12 @@ class UnicomComboTaskView(View):
                 flow_total = combo_qs['flow_total']
                 # 队列已使用总流量总量
                 flow_total_usage = unicom_api.get_flow_usage_total(iccid)
-                logger.info('--->{}-{},iccid:{};套餐总值:{},激活时当月用量值:{},套餐队列已使用流量量:{}'
-                            .format(year, month, iccid, flow_total, activate_usage_flow, flow_total_usage))
+                logger.info('--->iccid:{};套餐总值:{},激活时队列已用总流量:{},当前最新套餐队列已使用流量量:{}'
+                            .format(iccid, flow_total, activate_usage_flow, flow_total_usage))
                 is_expire = False
+                flow = activate_usage_flow + flow_total
                 if flow_total_usage > 0:
                     # 初始套餐已使用流量 + 套餐总流量
-                    flow = activate_usage_flow + flow_total
                     if flow_total_usage >= flow:
                         is_expire = True
                     usage = (flow_total_usage - activate_usage_flow) if flow_total_usage > activate_usage_flow else 0
@@ -146,7 +146,9 @@ class UnicomComboTaskView(View):
 
                 # 检查是否有当月未使用套餐 没有则停卡
                 if is_expire:
-                    UnicomComboOrderInfo.objects.filter(id=item['id']).update(status=2, updated_time=now_time)
+                    flow_exceed = flow_total_usage - flow
+                    UnicomComboOrderInfo.objects.filter(id=item['id']) \
+                        .update(status=2, updated_time=now_time, flow_exceed=flow_exceed)
                     activate_status = cls.query_unused_combo_and_activate(iccid, year, month,
                                                                           flow_total_usage)
                     if not activate_status: