|
@@ -103,16 +103,16 @@ class UnicomComboView(View):
|
|
combo_list = []
|
|
combo_list = []
|
|
combo_order_qs = UnicomComboOrderInfo.objects.filter(iccid=iccid, is_del=False) \
|
|
combo_order_qs = UnicomComboOrderInfo.objects.filter(iccid=iccid, is_del=False) \
|
|
.values('iccid', 'status', 'combo__combo_name', 'combo__flow_total',
|
|
.values('iccid', 'status', 'combo__combo_name', 'combo__flow_total',
|
|
- 'combo__remark', 'expiration_days', 'expiration_type', 'flow_total_usage',
|
|
|
|
- 'expire_time')
|
|
|
|
|
|
+ 'combo__remark', 'combo__expiration_days', 'combo__expiration_type', 'flow_total_usage',
|
|
|
|
+ 'expire_time').order_by('sort', 'created_time')
|
|
for item in combo_order_qs:
|
|
for item in combo_order_qs:
|
|
combo_list.append({
|
|
combo_list.append({
|
|
'iccid': iccid,
|
|
'iccid': iccid,
|
|
'comboName': item['combo__combo_name'],
|
|
'comboName': item['combo__combo_name'],
|
|
'flowTotal': item['combo__flow_total'],
|
|
'flowTotal': item['combo__flow_total'],
|
|
'comboRemark': item['combo__remark'],
|
|
'comboRemark': item['combo__remark'],
|
|
- 'expirationDays': item['expiration_days'],
|
|
|
|
- 'expirationType': item['expiration_type'],
|
|
|
|
|
|
+ 'expirationDays': item['combo__expiration_days'],
|
|
|
|
+ 'expirationType': item['combo__expiration_type'],
|
|
'flowTotalUsage': item['flow_total_usage'],
|
|
'flowTotalUsage': item['flow_total_usage'],
|
|
'expireTime': item['expire_time'],
|
|
'expireTime': item['expire_time'],
|
|
})
|
|
})
|
|
@@ -121,9 +121,9 @@ class UnicomComboView(View):
|
|
elif q_type == 'usage':
|
|
elif q_type == 'usage':
|
|
combo_order_qs = UnicomComboOrderInfo.objects.filter(iccid=iccid, status=1, is_del=False) \
|
|
combo_order_qs = UnicomComboOrderInfo.objects.filter(iccid=iccid, status=1, is_del=False) \
|
|
.values('iccid', 'status', 'combo__status', 'combo__combo_name', 'combo__combo_type',
|
|
.values('iccid', 'status', 'combo__status', 'combo__combo_name', 'combo__combo_type',
|
|
- 'combo__flow_total', 'combo__remark', 'expiration_days', 'expiration_type',
|
|
|
|
|
|
+ 'combo__flow_total', 'combo__remark', 'combo__expiration_days', 'combo__expiration_type',
|
|
'year', 'month', 'flow_total_usage', 'expire_time')
|
|
'year', 'month', 'flow_total_usage', 'expire_time')
|
|
- if not combo_order_qs.exists():
|
|
|
|
|
|
+ if combo_order_qs.exists():
|
|
combo_order = combo_order_qs.first()
|
|
combo_order = combo_order_qs.first()
|
|
flow_details = {
|
|
flow_details = {
|
|
'iccid': iccid,
|
|
'iccid': iccid,
|
|
@@ -131,8 +131,8 @@ class UnicomComboView(View):
|
|
'comboType': combo_order['combo__combo_type'],
|
|
'comboType': combo_order['combo__combo_type'],
|
|
'flowTotal': combo_order['combo__flow_total'],
|
|
'flowTotal': combo_order['combo__flow_total'],
|
|
'comboRemark': combo_order['combo__remark'],
|
|
'comboRemark': combo_order['combo__remark'],
|
|
- 'expirationDays': combo_order['expiration_days'],
|
|
|
|
- 'expirationType': combo_order['expiration_type'],
|
|
|
|
|
|
+ 'expirationDays': combo_order['combo__expiration_days'],
|
|
|
|
+ 'expirationType': combo_order['combo__expiration_type'],
|
|
'year': combo_order['year'],
|
|
'year': combo_order['year'],
|
|
'month': combo_order['month'],
|
|
'month': combo_order['month'],
|
|
'flowTotalUsage': combo_order['flow_total_usage'],
|
|
'flowTotalUsage': combo_order['flow_total_usage'],
|
|
@@ -140,23 +140,27 @@ class UnicomComboView(View):
|
|
}
|
|
}
|
|
if flow_details['year'] == year and flow_details['month'] == month:
|
|
if flow_details['year'] == year and flow_details['month'] == month:
|
|
month_flow = unicom_api.get_flow_usage_total(year, month, iccid)
|
|
month_flow = unicom_api.get_flow_usage_total(year, month, iccid)
|
|
|
|
+ # 当月流量减去 套餐激活时用量
|
|
month_flow = month_flow - float(flow_details['flowTotalUsage'])
|
|
month_flow = month_flow - float(flow_details['flowTotalUsage'])
|
|
flow = flow_details['flowTotal'] - month_flow
|
|
flow = flow_details['flowTotal'] - month_flow
|
|
- flow_details['usageFlow'] = flow
|
|
|
|
|
|
+ flow_details['usableFlow'] = flow
|
|
else:
|
|
else:
|
|
now_month_flow = unicom_api.get_flow_usage_total(year, month, iccid)
|
|
now_month_flow = unicom_api.get_flow_usage_total(year, month, iccid)
|
|
last_month_flow = unicom_api.get_flow_usage_total(flow_details['year'], flow_details['month'],
|
|
last_month_flow = unicom_api.get_flow_usage_total(flow_details['year'], flow_details['month'],
|
|
iccid)
|
|
iccid)
|
|
flow = now_month_flow + last_month_flow - float(flow_details['flowTotalUsage'])
|
|
flow = now_month_flow + last_month_flow - float(flow_details['flowTotalUsage'])
|
|
- flow_details['usageFlow'] = flow_details['flowTotal'] - flow
|
|
|
|
|
|
+ flow_details['usableFlow'] = flow_details['flowTotal'] - flow
|
|
|
|
|
|
- flow_details['usageFlow'] = \
|
|
|
|
- flow_details['flowTotal'] if flow_details['usageFlow'] <= 0 else flow_details['usageFlow']
|
|
|
|
- flow_details['usageFlow'] = Decimal(flow_details['usageFlow']).quantize(Decimal('0.00'))
|
|
|
|
|
|
+ flow_details['usableFlow'] = \
|
|
|
|
+ flow_details['flowTotal'] if flow_details['usableFlow'] <= 0 else flow_details['usableFlow']
|
|
|
|
+ flow_details['usableFlow'] = Decimal(flow_details['usableFlow']).quantize(Decimal('0.00'))
|
|
return response.json(0, flow_details)
|
|
return response.json(0, flow_details)
|
|
|
|
+ return response.json(0)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- print(e)
|
|
|
|
- return response.json(177, repr(e))
|
|
|
|
|
|
+ print(e.args)
|
|
|
|
+ ex = traceback.format_exc()
|
|
|
|
+ print(ex)
|
|
|
|
+ return response.json(177, ex)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def update_combo_order_sort(cls, iccd):
|
|
def update_combo_order_sort(cls, iccd):
|