|
@@ -8,10 +8,12 @@
|
|
|
"""
|
|
|
from django.http import QueryDict
|
|
|
from django.views import View
|
|
|
+from django.core.paginator import Paginator
|
|
|
from datetime import datetime
|
|
|
|
|
|
-from AgentModel.models import AgentCustomerInfo, AgentCustomerCard, AgentCustomerPackage, AgentCloudServicePackage
|
|
|
-from Model.models import UnicomCombo, Store_Meal
|
|
|
+from AgentModel.models import AgentCustomerInfo, AgentCustomerCard, AgentCustomerPackage, AgentCloudServicePackage, \
|
|
|
+ AgentDeviceOrder
|
|
|
+from Model.models import UnicomCombo, Store_Meal, Device_User
|
|
|
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -52,82 +54,26 @@ class AgentCustomerView(View):
|
|
|
return response.json(444, 'operation')
|
|
|
|
|
|
def get_unicom_and_icloud(self, response):
|
|
|
+ """
|
|
|
+ 查询云存储套餐和物联网卡套餐列表
|
|
|
+ @param response: 响应对象
|
|
|
+ @return:
|
|
|
+ """
|
|
|
try:
|
|
|
- # 云存储套餐查询,只包括is_show=1的记录
|
|
|
- store_meal_qs = Store_Meal.objects.filter(is_show=1).values(
|
|
|
- 'id',
|
|
|
- 'bucket__bucket',
|
|
|
- 'day',
|
|
|
- 'expire',
|
|
|
- 'commodity_type',
|
|
|
- 'commodity_code',
|
|
|
- 'is_discounts',
|
|
|
- 'discount_price',
|
|
|
- 'virtual_price',
|
|
|
- 'price',
|
|
|
- 'currency',
|
|
|
- 'symbol',
|
|
|
- 'is_show',
|
|
|
- 'is_ai',
|
|
|
- 'pixel_level',
|
|
|
- 'add_time',
|
|
|
- 'update_time'
|
|
|
- )
|
|
|
- store_meal_list = [{
|
|
|
- 'storeMealID': store_meal['id'],
|
|
|
- 'bucket': store_meal['bucket__bucket'],
|
|
|
- 'day': store_meal['day'],
|
|
|
- 'expire': store_meal['expire'],
|
|
|
- 'commodity_type': store_meal['commodity_type'],
|
|
|
- 'pay_type': [pay_type['id'] for pay_type in
|
|
|
- Store_Meal.objects.get(id=store_meal['id']).pay_type.values('id')],
|
|
|
- 'commodity_code': store_meal['commodity_code'],
|
|
|
- 'is_discounts': store_meal['is_discounts'],
|
|
|
- 'discount_price': store_meal['discount_price'],
|
|
|
- 'virtual_price': store_meal['virtual_price'],
|
|
|
- 'price': store_meal['price'],
|
|
|
- 'currency': store_meal['currency'],
|
|
|
- 'symbol': store_meal['symbol'],
|
|
|
- 'is_show': store_meal['is_show'],
|
|
|
- 'is_ai': store_meal['is_ai'],
|
|
|
- 'pixel_level': store_meal['pixel_level'],
|
|
|
- 'addTime': store_meal['add_time'].strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
- 'updTime': store_meal['update_time'].strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
- } for store_meal in store_meal_qs]
|
|
|
+ # 云存储套餐名称查询,只包括is_show=1的记录
|
|
|
+ store_meal_names = Store_Meal.objects.filter(is_show=1).values_list('bucket__bucket', flat=True).distinct()
|
|
|
|
|
|
- # 联通套餐查询,只包括is_show=1的记录
|
|
|
- combo_qs = UnicomCombo.objects.filter(is_show=1, is_del=False).values(
|
|
|
- 'id', 'status', 'combo_name',
|
|
|
- 'flow_total', 'combo_type',
|
|
|
- 'expiration_days',
|
|
|
- 'expiration_type', 'price', 'is_unlimited',
|
|
|
- 'updated_time', 'created_time',
|
|
|
- 'remark', 'is_show', 'sort', 'virtual_price'
|
|
|
- )
|
|
|
- combo_list = [{
|
|
|
- 'id': item['id'],
|
|
|
- 'status': item['status'],
|
|
|
- 'comboType': item['combo_type'],
|
|
|
- 'comboName': item['combo_name'],
|
|
|
- 'flowTotal': item['flow_total'],
|
|
|
- 'expirationDays': item['expiration_days'],
|
|
|
- 'expirationType': item['expiration_type'],
|
|
|
- 'price': item['price'],
|
|
|
- 'sort': item['sort'],
|
|
|
- 'isUnlimited': item['is_unlimited'],
|
|
|
- 'updatedTime': datetime.utcfromtimestamp(item['updated_time']).strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
- 'createdTime': datetime.utcfromtimestamp(item['created_time']).strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
- 'remark': item['remark'],
|
|
|
- 'isShow': item['is_show'],
|
|
|
- 'payTypes': [pay_type['id'] for pay_type in
|
|
|
- UnicomCombo.objects.get(id=item['id']).pay_type.values('id')],
|
|
|
- 'virtualPrice': item['virtual_price']
|
|
|
- } for item in combo_qs]
|
|
|
+ # 联通套餐名称查询,只包括is_show=1且未被删除的记录
|
|
|
+ unicom_combo_names = UnicomCombo.objects.filter(is_show=1, is_del=False).values_list('combo_name',
|
|
|
+ flat=True).distinct()
|
|
|
+ # 将查询结果转换为列表
|
|
|
+ store_meal_name_list = list(store_meal_names)
|
|
|
+ unicom_combo_name_list = list(unicom_combo_names)
|
|
|
|
|
|
# 合并结果并返回
|
|
|
return response.json(0, {
|
|
|
- 'storeMealList': store_meal_list,
|
|
|
- 'comboList': combo_list,
|
|
|
+ 'storeMealNames': store_meal_name_list,
|
|
|
+ 'unicomComboNames': unicom_combo_name_list,
|
|
|
})
|
|
|
except Exception as e:
|
|
|
print(e)
|