|
@@ -55,7 +55,7 @@ class UnicomComboView(View):
|
|
|
|
|
|
def get_user_info(self, request_dict, response):
|
|
|
"""
|
|
|
- 获取卡用户信息
|
|
|
+ 筛选卡用户信息
|
|
|
@param request_dict:
|
|
|
@param response:
|
|
|
@return:
|
|
@@ -104,8 +104,8 @@ class UnicomComboView(View):
|
|
|
'card_type': unicom_device.card_type,
|
|
|
'main_card': unicom_device.main_card,
|
|
|
'created_time': unicom_device.created_time,
|
|
|
- 'NickName':'',
|
|
|
- 'phone':''
|
|
|
+ 'NickName': '',
|
|
|
+ 'phone': ''
|
|
|
}
|
|
|
for device_user in device_user_qs.filter(
|
|
|
userID=unicom_device.user_id).values('NickName', 'phone'):
|
|
@@ -173,33 +173,62 @@ class UnicomComboView(View):
|
|
|
serial_no 设备序列号
|
|
|
"""
|
|
|
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([pageSize, pageNo]):
|
|
|
+
|
|
|
+ if not all({pageNo, pageSize}):
|
|
|
return response.json(444)
|
|
|
- # else:
|
|
|
page = int(pageNo)
|
|
|
line = int(pageSize)
|
|
|
|
|
|
- # 参考云端获取设备套餐信息(代码逻辑)
|
|
|
- # 参考云端多情况(条件)下的查询,返回结果
|
|
|
-
|
|
|
try:
|
|
|
- get_info_qs = UnicomDeviceInfo.objects.filter().values('iccid')
|
|
|
- iccid = get_info_qs[0]['iccid']
|
|
|
- if serial_no:
|
|
|
- get_info_qs = get_info_qs.filter(serial_no__contains=serial_no).values('iccid')
|
|
|
- iccid = get_info_qs[0]['iccid']
|
|
|
-
|
|
|
- if not get_info_qs.exists():
|
|
|
- return response.json(0, [])
|
|
|
- combo_info_qs = UnicomComboOrderInfo.objects.filter(iccid=iccid).values()
|
|
|
-
|
|
|
- combo_info_qs = combo_info_qs.values()
|
|
|
- combo_info_qs = combo_info_qs.order_by('-created_time')
|
|
|
- combo_info_qs = combo_info_qs[(page - 1) * line:page * line]
|
|
|
- total = combo_info_qs.count()
|
|
|
- return response.json(0, {'list': list(combo_info_qs), 'total': total})
|
|
|
+ combo_order_qs = UnicomComboOrderInfo.objects.filter().values('status',
|
|
|
+ 'iccid',
|
|
|
+ 'order_id',
|
|
|
+ 'flow_total_usage',
|
|
|
+ 'next_month_activate',
|
|
|
+ 'activation_time',
|
|
|
+ 'expire_time',
|
|
|
+ 'combo__combo_name')[
|
|
|
+ (page - 1) * line:page * line]
|
|
|
+
|
|
|
+ if serial_no or status:
|
|
|
+ if serial_no:
|
|
|
+ unicom_device_qs = UnicomDeviceInfo.objects.filter(serial_no=serial_no).values('iccid',
|
|
|
+ 'serial_no',
|
|
|
+ 'user_id').distinct()
|
|
|
+ else:
|
|
|
+ unicom_device_qs = UnicomDeviceInfo.objects.filter(status=status).values('iccid', 'serial_no',
|
|
|
+ 'user_id').distinct()
|
|
|
+ if not unicom_device_qs.exists():
|
|
|
+ return response.json(0, [])
|
|
|
+ else:
|
|
|
+ if not combo_order_qs.exists():
|
|
|
+ return response.json(0, [])
|
|
|
+ unicom_device_qs = UnicomDeviceInfo.objects.filter().values('user_id', 'iccid',
|
|
|
+ 'serial_no')
|
|
|
+ data = {}
|
|
|
+ for unicom_device in unicom_device_qs:
|
|
|
+ userID = unicom_device['user_id']
|
|
|
+ device_user = Device_User.objects.filter(userID=userID).values('NickName')
|
|
|
+ nick_name = device_user[0]['NickName']
|
|
|
+ for combo_order in combo_order_qs:
|
|
|
+ data = {'nickName': '',
|
|
|
+ 'iccid': combo_order['iccid'],
|
|
|
+ 'serialNo': '',
|
|
|
+ 'status': combo_order['status'],
|
|
|
+ 'order_id': combo_order['order_id'],
|
|
|
+ 'comboName': combo_order['combo__combo_name'],
|
|
|
+ 'flow_total_usage': combo_order['flow_total_usage'],
|
|
|
+ 'next_month_activate': combo_order['next_month_activate'],
|
|
|
+ 'activation_time': combo_order['activation_time'],
|
|
|
+ 'expire_time': combo_order['expire_time']}
|
|
|
+ data['serialNo'] = unicom_device['serial_no']
|
|
|
+ data['nickName'] = nick_name
|
|
|
+ total = combo_order_qs.count()
|
|
|
+
|
|
|
+ return response.json(0, {'list': data, 'total': total})
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
return response.json(500, repr(e))
|