|
@@ -45,18 +45,87 @@ class UnicomComboView(View):
|
|
|
return self.get_order_info(request_dict, response)
|
|
|
# 统计4G套餐
|
|
|
elif operation == 'getComboDataList':
|
|
|
- return self.combo_list(request_dict, response)
|
|
|
+ return self.static_info(request_dict, response)
|
|
|
# 删除卡套餐
|
|
|
elif operation == 'dele/combo/info':
|
|
|
return self.combo_order_info(request_dict, response)
|
|
|
+ # 筛选用户信息
|
|
|
+ elif operation == 'filter/user':
|
|
|
+ return self.get_user_info(request_dict, response)
|
|
|
+
|
|
|
+ def get_user_info(self, request_dict, response):
|
|
|
+ """
|
|
|
+ 获取卡用户信息
|
|
|
+ @param request_dict:
|
|
|
+ @param response:
|
|
|
+ @return:
|
|
|
+ NickName:用户昵称 phone: 电话
|
|
|
+ serial_no: 设备序列号
|
|
|
+ """
|
|
|
+ NickName = request_dict.get('NickName', None)
|
|
|
+ phone = request_dict.get('phone', None)
|
|
|
+ iccid = request_dict.get('iccid', None)
|
|
|
+ serial_no = request_dict.get('serialNo', None)
|
|
|
+ pageSize = request_dict.get('pageSize', None)
|
|
|
+ pageNo = request_dict.get('pageNo', None)
|
|
|
+
|
|
|
+ if not all({pageNo, pageSize}):
|
|
|
+ return response.json(444)
|
|
|
+
|
|
|
+ page = int(pageNo)
|
|
|
+ line = int(pageSize)
|
|
|
+
|
|
|
+ try:
|
|
|
+
|
|
|
+ unicom_device_qs = UnicomDeviceInfo.objects.all()
|
|
|
+ if iccid:
|
|
|
+ unicom_device_qs = unicom_device_qs.filter(iccid=iccid)
|
|
|
+ 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(
|
|
|
+ 'userID', 'NickName', 'phone')
|
|
|
+ if NickName:
|
|
|
+ device_user_qs = device_user_qs.filter(NickName=NickName)
|
|
|
+ if phone:
|
|
|
+ device_user_qs = device_user_qs.filter(phone=phone)
|
|
|
+
|
|
|
+ if not unicom_device_qs.exists():
|
|
|
+ return response.json(0, [])
|
|
|
+ total = unicom_device_qs.count()
|
|
|
+ unicom_device_qs = unicom_device_qs[(page - 1) * line:page * line]
|
|
|
+
|
|
|
+ list_data = []
|
|
|
+ for unicom_device in unicom_device_qs:
|
|
|
+ data = {
|
|
|
+ 'iccid': unicom_device.iccid,
|
|
|
+ 'serialNo': unicom_device.serial_no,
|
|
|
+ 'userID': unicom_device.user_id,
|
|
|
+ 'card_type': unicom_device.card_type,
|
|
|
+ 'main_card': unicom_device.main_card,
|
|
|
+ 'created_time': 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']
|
|
|
+ list_data.append(data)
|
|
|
+ return response.json(0, {'list': list_data, 'total': total})
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, repr(e))
|
|
|
|
|
|
@staticmethod
|
|
|
def get_user_combo(request_dict, response):
|
|
|
"""
|
|
|
- 定时检查是否有次月激活套餐
|
|
|
+ 获取卡用户信息
|
|
|
@param request_dict:
|
|
|
@param response:
|
|
|
@return:
|
|
|
+ cardType:状态(0:联通,1:电信,2:移动)
|
|
|
+ mainCard:状态(0:主卡,1:拔插卡)
|
|
|
"""
|
|
|
pageNo = request_dict.get('pageNo', None)
|
|
|
pageSize = request_dict.get('pageSize', None)
|
|
@@ -64,12 +133,11 @@ class UnicomComboView(View):
|
|
|
return response.json(444)
|
|
|
page = int(pageNo)
|
|
|
line = int(pageSize)
|
|
|
- # cardType:状态(0:联通,1:电信,2:移动)
|
|
|
- # mainCard:状态(0:主卡,1:拔插卡)
|
|
|
get_info_qs = UnicomDeviceInfo.objects.filter().values(
|
|
|
'iccid', 'serial_no', 'user_id', 'card_type', 'main_card', 'created_time'
|
|
|
- )[(page - 1) * line:page * line]
|
|
|
+ )
|
|
|
total = get_info_qs.count()
|
|
|
+ get_info_qs = get_info_qs[(page - 1) * line:page * line]
|
|
|
try:
|
|
|
res_list = []
|
|
|
for item in get_info_qs:
|
|
@@ -84,9 +152,12 @@ class UnicomComboView(View):
|
|
|
usreID = get_info_qs[0]['user_id']
|
|
|
user_info_qs = Device_User.objects.filter(userID=usreID).values(
|
|
|
'NickName', 'phone')
|
|
|
- res['userID'] = usreID
|
|
|
- res['NickName'] = user_info_qs.first()['NickName']
|
|
|
- res['phone'] = user_info_qs.first()['phone']
|
|
|
+ if user_info_qs.exists():
|
|
|
+ res['userID'] = usreID
|
|
|
+ res['NickName'] = user_info_qs.first()['NickName']
|
|
|
+ res['phone'] = user_info_qs.first()['phone']
|
|
|
+ else:
|
|
|
+ res['userID'] = ''
|
|
|
res_list.append(res)
|
|
|
return response.json(0, {'list': res_list, 'total': total})
|
|
|
except Exception as e:
|
|
@@ -95,10 +166,11 @@ class UnicomComboView(View):
|
|
|
@staticmethod
|
|
|
def get_order_info(request_dict, response):
|
|
|
"""
|
|
|
- 获取卡套餐信息
|
|
|
+ 获取设备套餐信息
|
|
|
@param request_dict:
|
|
|
@param response:
|
|
|
@return:
|
|
|
+ serial_no 设备序列号
|
|
|
"""
|
|
|
serial_no = request_dict.get('serialNo', None)
|
|
|
pageNo = request_dict.get('pageNo', None)
|
|
@@ -136,6 +208,9 @@ class UnicomComboView(View):
|
|
|
def edit_combo(cls, request_dict, response):
|
|
|
"""
|
|
|
添加和编辑卡套餐
|
|
|
+ @param request_dict:
|
|
|
+ @param response:
|
|
|
+ @return:
|
|
|
"""
|
|
|
combo_id = request_dict.get('comboID', None)
|
|
|
package_id = request_dict.get('packageId', None)
|
|
@@ -251,7 +326,13 @@ class UnicomComboView(View):
|
|
|
def combo_order_info(cls, request_doct, response):
|
|
|
pass
|
|
|
|
|
|
- def combo_list(self, request_dict, response):
|
|
|
+ def static_info(self, request_dict, response):
|
|
|
+ """
|
|
|
+ 统计联通套餐
|
|
|
+ @param request_dict:
|
|
|
+ @param response:
|
|
|
+ @return:
|
|
|
+ """
|
|
|
year = request_dict.get('year', None)
|
|
|
Jan = int(time.mktime(time.strptime(year + '-1-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
Feb = int(time.mktime(time.strptime(year + '-2-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|