|
@@ -83,12 +83,22 @@ class UnicomComboView(View):
|
|
|
if serial_no:
|
|
|
unicom_device_qs = unicom_device_qs.filter(serial_no=serial_no)
|
|
|
|
|
|
- device_user_qs = Device_User.objects.filter(userID__in=unicom_device_qs.values('user_id')).values(
|
|
|
+ device_user_qs = Device_User.objects.filter().values(
|
|
|
'userID', 'NickName', 'phone')
|
|
|
+ userID = ''
|
|
|
if NickName:
|
|
|
device_user_qs = device_user_qs.filter(NickName=NickName)
|
|
|
+ if not device_user_qs.exists():
|
|
|
+ return response.json(0, [])
|
|
|
+ userID = device_user_qs.first()['userID']
|
|
|
+
|
|
|
if phone:
|
|
|
device_user_qs = device_user_qs.filter(phone=phone)
|
|
|
+ if not device_user_qs.exists():
|
|
|
+ return response.json(0, [])
|
|
|
+ userID = device_user_qs.first()['userID']
|
|
|
+ if userID:
|
|
|
+ unicom_device_qs.filter(user_id=userID)
|
|
|
|
|
|
if not unicom_device_qs.exists():
|
|
|
return response.json(0, [])
|
|
@@ -101,16 +111,15 @@ class UnicomComboView(View):
|
|
|
'iccid': unicom_device.iccid,
|
|
|
'serialNo': unicom_device.serial_no,
|
|
|
'userID': unicom_device.user_id,
|
|
|
- 'card_type': unicom_device.card_type,
|
|
|
+ 'cardType': unicom_device.card_type,
|
|
|
'main_card': unicom_device.main_card,
|
|
|
- 'created_time': unicom_device.created_time,
|
|
|
+ 'createdTime': unicom_device.created_time,
|
|
|
'NickName': '',
|
|
|
'phone': ''
|
|
|
}
|
|
|
- for device_user in device_user_qs.filter(
|
|
|
- userID=unicom_device.user_id).values('NickName', 'phone'):
|
|
|
- data['NickName'] = device_user['NickName']
|
|
|
- data['phone'] = device_user['phone']
|
|
|
+ device_user_qs = Device_User.objects.filter(userID=unicom_device.user_id).values('NickName', 'phone')
|
|
|
+ data['NickName'] = device_user_qs[0]['NickName']
|
|
|
+ data['phone'] = device_user_qs[0]['phone']
|
|
|
list_data.append(data)
|
|
|
return response.json(0, {'list': list_data, 'total': total})
|
|
|
except Exception as e:
|
|
@@ -133,7 +142,7 @@ class UnicomComboView(View):
|
|
|
line = int(pageSize)
|
|
|
get_info_qs = UnicomDeviceInfo.objects.filter().values(
|
|
|
'iccid', 'serial_no', 'user_id', 'card_type', 'main_card', 'created_time'
|
|
|
- )
|
|
|
+ ).order_by('-created_time')
|
|
|
total = get_info_qs.count()
|
|
|
get_info_qs = get_info_qs[(page - 1) * line:page * line]
|
|
|
try:
|
|
@@ -181,15 +190,7 @@ class UnicomComboView(View):
|
|
|
line = int(pageSize)
|
|
|
|
|
|
try:
|
|
|
- combo_order_qs = UnicomComboOrderInfo.objects.values('status',
|
|
|
- 'iccid',
|
|
|
- 'order_id',
|
|
|
- 'flow_total_usage',
|
|
|
- 'next_month_activate',
|
|
|
- 'activation_time',
|
|
|
- 'expire_time',
|
|
|
- 'combo__combo_name')[(page - 1) * line:page * line]
|
|
|
-
|
|
|
+ combo_order_info_qs = UnicomComboOrderInfo.objects.all()
|
|
|
if serial_no or status:
|
|
|
if serial_no:
|
|
|
unicom_device_qs = UnicomDeviceInfo.objects.filter(serial_no=serial_no).values('iccid',
|
|
@@ -201,23 +202,25 @@ class UnicomComboView(View):
|
|
|
if not unicom_device_qs.exists():
|
|
|
return response.json(0, [])
|
|
|
else:
|
|
|
- if not combo_order_qs.exists():
|
|
|
+ if not combo_order_info_qs.exists():
|
|
|
return response.json(0, [])
|
|
|
unicom_device_qs = UnicomDeviceInfo.objects.filter().values('user_id', 'iccid',
|
|
|
'serial_no')
|
|
|
- total = combo_order_qs.count()
|
|
|
+ combo_order_info_qs = combo_order_info_qs.order_by('-created_time')[(page - 1) * line:page * line]
|
|
|
+ total = combo_order_info_qs.count()
|
|
|
data_list = []
|
|
|
- for combo_order in combo_order_qs:
|
|
|
+ for combo_order in combo_order_info_qs:
|
|
|
data = {'nickName': '',
|
|
|
- 'iccid': combo_order['iccid'],
|
|
|
+ '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']}
|
|
|
+ '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,
|
|
|
+ 'activationTime': combo_order.activation_time,
|
|
|
+ 'expireTime': combo_order.expire_time,
|
|
|
+ 'createdTime': combo_order.created_time}
|
|
|
for unicom_device in unicom_device_qs:
|
|
|
userID = unicom_device['user_id']
|
|
|
device_user = Device_User.objects.filter(userID=userID).values('NickName')
|
|
@@ -248,6 +251,7 @@ class UnicomComboView(View):
|
|
|
pay_type = request_dict.get(
|
|
|
'payTypes', '')[
|
|
|
1:-1].split(',') # '[1,2]' -> ['1','2']
|
|
|
+ sort = request_dict.get('sort', None)
|
|
|
price = request_dict.get('price', None)
|
|
|
remark = request_dict.get('remark', None)
|
|
|
is_show = request_dict.get('isShow', None)
|
|
@@ -260,6 +264,7 @@ class UnicomComboView(View):
|
|
|
status = int(status)
|
|
|
combo_type = int(combo_type)
|
|
|
is_show = int(is_show)
|
|
|
+ sort = int(sort)
|
|
|
|
|
|
unicom_combo_qs = UnicomCombo.objects.all()
|
|
|
|
|
@@ -273,6 +278,7 @@ class UnicomComboView(View):
|
|
|
'expiration_days': expiration_days,
|
|
|
'expiration_type': expiration_type,
|
|
|
'price': price,
|
|
|
+ 'sort': sort,
|
|
|
'remark': remark if remark else '',
|
|
|
'is_show': is_show
|
|
|
}
|
|
@@ -311,7 +317,7 @@ class UnicomComboView(View):
|
|
|
'expiration_days',
|
|
|
'expiration_type', 'price', 'is_unlimited',
|
|
|
'updated_time', 'created_time',
|
|
|
- 'remark', 'is_show')[(page - 1) * line:page * line]
|
|
|
+ 'remark', 'is_show', 'sort')[(page - 1) * line:page * line]
|
|
|
if not combo_qs.exists():
|
|
|
return response.json(0, [])
|
|
|
total = combo_qs.count()
|
|
@@ -329,6 +335,7 @@ class UnicomComboView(View):
|
|
|
'expirationDays': item['expiration_days'],
|
|
|
'expirationType': item['expiration_type'],
|
|
|
'price': item['price'],
|
|
|
+ 'sort': item['sort'],
|
|
|
'isUnlimited': item['is_unlimited'],
|
|
|
'updatedTime': item['updated_time'],
|
|
|
'createdTime': item['created_time'],
|