|
@@ -86,7 +86,7 @@ class UnicomComboTaskView(View):
|
|
|
if not combo_qs.exists():
|
|
|
continue
|
|
|
# 查询当月用量情况
|
|
|
- flow_total_usage = unicom_api.get_flow_usage_total(year, month, item['iccid'])
|
|
|
+ flow_total_usage = unicom_api.get_flow_usage_total(item['iccid'])
|
|
|
flow_total_usage = Decimal(flow_total_usage).quantize(
|
|
|
Decimal('0.00')) if flow_total_usage > 0 else 0
|
|
|
flow_total_usage = str(flow_total_usage)
|
|
@@ -123,48 +123,32 @@ class UnicomComboTaskView(View):
|
|
|
if not u_device_info_qs.exists():
|
|
|
continue
|
|
|
u_device_info_qs = u_device_info_qs.first()
|
|
|
- usage_flow = float(item['flow_total_usage']) if item['flow_total_usage'] else 0.0
|
|
|
+ activate_usage_flow = float(item['flow_total_usage']) if item['flow_total_usage'] else 0.0
|
|
|
combo_id = item['combo_id']
|
|
|
combo_qs = UnicomCombo.objects.filter(id=combo_id).values()
|
|
|
if not combo_qs.exists():
|
|
|
continue
|
|
|
combo_qs = combo_qs.first()
|
|
|
flow_total = combo_qs['flow_total']
|
|
|
- # 查询当前月用量历史
|
|
|
- month_usage_flow = unicom_api.get_flow_usage_total(year, month, iccid)
|
|
|
- logger.info('--->{}-{},iccid:{};套餐总值:{},激活时当月用量值:{},月已用量:{}'
|
|
|
- .format(year, month, iccid, flow_total, usage_flow, month_usage_flow))
|
|
|
+ # 队列已使用总流量总量
|
|
|
+ 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))
|
|
|
is_expire = False
|
|
|
- if item['year'] == year and item['month'] == month:
|
|
|
- if month_usage_flow > 0:
|
|
|
- # 初始套餐已使用流量 + 套餐总流量
|
|
|
- flow = usage_flow + flow_total
|
|
|
- if month_usage_flow >= flow:
|
|
|
- is_expire = True
|
|
|
- usage = (month_usage_flow - usage_flow) if month_usage_flow > usage_flow else 0
|
|
|
- cls.flow_warning_push(u_device_info_qs.user_id, u_device_info_qs.serial_no, item['id'], flow_total,
|
|
|
- usage)
|
|
|
- else:
|
|
|
- activate_year = item['year']
|
|
|
- activate_month = item['month']
|
|
|
- # 上月使用流量
|
|
|
- last_usage_flow = unicom_api.get_flow_usage_total(activate_year, activate_month, iccid)
|
|
|
- # 上月套餐实际使用量
|
|
|
- actual_usage_flow = last_usage_flow - usage_flow
|
|
|
- # 剩余
|
|
|
- surplus_flow = flow_total - actual_usage_flow
|
|
|
- if month_usage_flow > 0:
|
|
|
- if month_usage_flow >= surplus_flow:
|
|
|
- is_expire = True
|
|
|
- usage = (month_usage_flow + last_usage_flow - usage_flow) \
|
|
|
- if (month_usage_flow + last_usage_flow) > usage_flow else 0
|
|
|
+ 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
|
|
|
cls.flow_warning_push(u_device_info_qs.user_id, u_device_info_qs.serial_no, item['id'], flow_total,
|
|
|
usage)
|
|
|
+
|
|
|
# 检查是否有当月未使用套餐 没有则停卡
|
|
|
if is_expire:
|
|
|
UnicomComboOrderInfo.objects.filter(id=item['id']).update(status=2, updated_time=now_time)
|
|
|
activate_status = cls.query_unused_combo_and_activate(iccid, year, month,
|
|
|
- month_usage_flow)
|
|
|
+ flow_total_usage)
|
|
|
if not activate_status:
|
|
|
# 停用
|
|
|
unicom_api.change_device_to_disable(iccid)
|
|
@@ -281,7 +265,7 @@ class UnicomComboTaskView(View):
|
|
|
is_del=False).values()
|
|
|
if activate_combo_qs.exists():
|
|
|
continue
|
|
|
- usage_flow = unicom_api.get_flow_usage_total(year, month, item)
|
|
|
+ usage_flow = unicom_api.get_flow_usage_total(item)
|
|
|
result = cls.query_unused_combo_and_activate(item, year, month, usage_flow)
|
|
|
if not result:
|
|
|
# 停用设备
|