|
@@ -41,9 +41,6 @@ class UnicomManageControllerView(View):
|
|
|
# 添加和编辑卡套餐
|
|
|
elif operation == 'edit/combo':
|
|
|
return self.edit_combo(request_dict, response)
|
|
|
- # 获取/筛选4G流量卡订单信息
|
|
|
- elif operation == 'order/info':
|
|
|
- return self.get_order_info(request_dict, response)
|
|
|
# 统计4G套餐
|
|
|
elif operation == 'getComboDataList':
|
|
|
return self.static_info(request_dict, response)
|
|
@@ -56,6 +53,7 @@ class UnicomManageControllerView(View):
|
|
|
# 充值流量
|
|
|
elif operation == 'getFlowPackages':
|
|
|
return self.get_flow_packages(request_dict, response)
|
|
|
+ # 获取 / 筛选4G流量卡订单信息
|
|
|
elif operation == 'query-order':
|
|
|
return self.query_4G_user_order(request_dict, response)
|
|
|
else:
|
|
@@ -131,96 +129,6 @@ class UnicomManageControllerView(View):
|
|
|
print(e)
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
|
- @staticmethod
|
|
|
- def get_order_info(request_dict, response):
|
|
|
- """
|
|
|
- 获取/筛选4G流量卡订单信息
|
|
|
- @param request_dict:
|
|
|
- @param response:
|
|
|
- @return:
|
|
|
- serial_no 设备序列号
|
|
|
- """
|
|
|
- UID = request_dict.get('uid', None)
|
|
|
- serial_no = request_dict.get('serialNo', None)
|
|
|
- status = request_dict.get('status', None)
|
|
|
- pageNo = request_dict.get('pageNo', None)
|
|
|
- pageSize = request_dict.get('pageSize', None)
|
|
|
-
|
|
|
- if not all({pageNo, pageSize}):
|
|
|
- return response.json(444)
|
|
|
- page = int(pageNo)
|
|
|
- line = int(pageSize)
|
|
|
-
|
|
|
- try:
|
|
|
- combo_order_info_qs = UnicomComboOrderInfo.objects.all()
|
|
|
- # 序列号查询
|
|
|
- if serial_no:
|
|
|
- unicom_device_qs = UnicomDeviceInfo.objects.filter(serial_no__icontains=serial_no) \
|
|
|
- .values('serial_no', 'user_id', 'iccid')
|
|
|
- if not unicom_device_qs.exists():
|
|
|
- return response.json(0, [])
|
|
|
- combo_order_info_qs = combo_order_info_qs.filter(iccid__icontains=unicom_device_qs[0]['iccid'])
|
|
|
- # UID查询
|
|
|
- if UID:
|
|
|
- device_qs = Device_Info.objects.filter(UID=UID).values('serial_number')
|
|
|
- if not device_qs.exists():
|
|
|
- return response.json(0, [])
|
|
|
- unicom_device_qs = UnicomDeviceInfo.objects.filter(
|
|
|
- serial_no__icontains=device_qs[0]['serial_number']).values('serial_no', 'user_id', 'iccid')
|
|
|
- if not unicom_device_qs.exists():
|
|
|
- return response.json(0, [])
|
|
|
- combo_order_info_qs = combo_order_info_qs.filter(iccid__icontains=unicom_device_qs[0]['iccid'])
|
|
|
- # 状态查询
|
|
|
- if status:
|
|
|
- status = int(status)
|
|
|
- combo_order_info_qs = combo_order_info_qs.filter(status=status)
|
|
|
- if not combo_order_info_qs.exists():
|
|
|
- return response.json(0, [])
|
|
|
- total = combo_order_info_qs.count()
|
|
|
- combo_order_info_qs = combo_order_info_qs.order_by('-created_time')[(page - 1) * line:page * line]
|
|
|
- data_list = []
|
|
|
- for combo_order in combo_order_info_qs:
|
|
|
- if not UnicomManageControllerView.check_sim_user(combo_order.iccid):
|
|
|
- continue
|
|
|
- data = {'userName': '',
|
|
|
- 'UID': '',
|
|
|
- 'iccid': combo_order.iccid,
|
|
|
- 'status': combo_order.status,
|
|
|
- 'order_id': combo_order.order_id,
|
|
|
- 'flow_total_usage': combo_order.flow_total_usage,
|
|
|
- 'next_month_activate': combo_order.next_month_activate,
|
|
|
- 'activationTime': combo_order.activation_time,
|
|
|
- 'expireTime': combo_order.expire_time,
|
|
|
- 'createdTime': combo_order.created_time,
|
|
|
- 'updated_time': combo_order.updated_time}
|
|
|
- unicom_combo_qs = UnicomCombo.objects.filter(id=combo_order.combo_id).values('combo_name', 'price')
|
|
|
- data['price'] = unicom_combo_qs[0]['price'] if unicom_combo_qs.exists() else ''
|
|
|
- data['comboName'] = unicom_combo_qs[0]['combo_name'] if unicom_combo_qs.exists() else ''
|
|
|
- unicom_device_qs = UnicomDeviceInfo.objects.filter(iccid__icontains=combo_order.iccid).values('user_id',
|
|
|
- 'serial_no')
|
|
|
- userID = unicom_device_qs[0]['user_id'] if unicom_device_qs.exists() else ''
|
|
|
- data['serialNo'] = unicom_device_qs[0]['serial_no'] if unicom_device_qs.exists() else ''
|
|
|
- serial_no = data['serialNo']
|
|
|
- device_info_qs = Device_Info.objects.filter(userID__userID=userID, serial_number=serial_no).values(
|
|
|
- 'userID__username', 'UID')
|
|
|
- if device_info_qs.exists():
|
|
|
- nick_name = device_info_qs[0]['userID__username']
|
|
|
- data['userName'] = nick_name
|
|
|
- if data['serialNo'] != '':
|
|
|
- data['UID'] = CommonService.query_serial_with_uid(data['serialNo'])
|
|
|
- if combo_order.status == 1:
|
|
|
- total_flow = UnicomObjeect.current_sim_traffic_usage_details(combo_order.iccid) # 4G总值
|
|
|
- flow_total_usage = combo_order.flow_total_usage # 激活时当月已用流量
|
|
|
- flow_total_usage = float(flow_total_usage)
|
|
|
- data['using_total'] = total_flow - flow_total_usage
|
|
|
- else:
|
|
|
- data['using_total'] = 0
|
|
|
- data_list.append(data)
|
|
|
- return response.json(0, {'list': data_list, 'total': total})
|
|
|
- except Exception as e:
|
|
|
- print(e)
|
|
|
- return response.json(500, repr(e))
|
|
|
-
|
|
|
@staticmethod
|
|
|
def query_sql_4g():
|
|
|
"""
|
|
@@ -229,7 +137,8 @@ class UnicomManageControllerView(View):
|
|
|
"""
|
|
|
sql = 'SELECT '
|
|
|
sql += 'du.username,du.phone,o.UID as uid,o.`status`,udi.serial_no as serialNo,o.orderID,o.`desc`, '
|
|
|
- sql += 'o.price,uo.next_month_activate as nextActivate,uo.iccid,uo.`status` as useStatus, '
|
|
|
+ sql += 'o.price,uo.next_month_activate as nextActivate,uo.iccid,uo.`status` as useStatus, ' \
|
|
|
+ 'uo.`flow_total_usage` as flowTotal, '
|
|
|
sql += 'uo.updated_time as upTime, uo.activation_time as acTime,uo.expire_time as epTime '
|
|
|
sql += 'FROM orders o '
|
|
|
sql += 'LEFT JOIN unicom_combo_order_info uo ON o.orderID = uo.order_id '
|
|
@@ -278,6 +187,13 @@ class UnicomManageControllerView(View):
|
|
|
col_names = [desc[0] for desc in cursor.description]
|
|
|
for item in data_obj:
|
|
|
order_dict = dict(zip(col_names, item))
|
|
|
+ if order_dict['status'] == 1:
|
|
|
+ total_flow = UnicomObjeect.current_sim_traffic_usage_details(order_dict['iccid']) # 4G总值
|
|
|
+ flow_total_usage = order_dict['flowTotal'] # 激活时当月已用流量
|
|
|
+ flow_total_usage = float(flow_total_usage)
|
|
|
+ order_dict['using_total'] = total_flow - flow_total_usage
|
|
|
+ else:
|
|
|
+ order_dict['using_total'] = 0
|
|
|
result_list.append(order_dict)
|
|
|
return response.json(0, {'orderList': result_list, 'total': total})
|
|
|
except Exception as e:
|