|
@@ -286,30 +286,32 @@ class AiView(View):
|
|
def do_commodity_list(self, userID, request_dict, response):
|
|
def do_commodity_list(self, userID, request_dict, response):
|
|
uid = request_dict.get('uid', None)
|
|
uid = request_dict.get('uid', None)
|
|
lang = request_dict.get('lang', 'en')
|
|
lang = request_dict.get('lang', 'en')
|
|
- nowTime = int(time.time())
|
|
|
|
- # DVR/NVR设备暂不返回套餐列表
|
|
|
|
- device_info_qs = Device_Info.objects.filter(Q(UID=uid), Q(Type__lte=4) | Q(Type=10001))
|
|
|
|
- if device_info_qs.exists():
|
|
|
|
- return response.json(0)
|
|
|
|
|
|
|
|
- qs = AiStoreMeal.objects
|
|
|
|
|
|
+ try:
|
|
|
|
+ # DVR/NVR设备暂不返回套餐列表
|
|
|
|
+ device_info_qs = Device_Info.objects.filter(Q(UID=uid), Q(Type__lte=4) | Q(Type=10001))
|
|
|
|
+ if device_info_qs.exists():
|
|
|
|
+ return response.json(0)
|
|
|
|
|
|
- qs = qs.filter(is_show=1) # 过滤隐藏套餐
|
|
|
|
- qs = qs.annotate(ai_meal_id=F('id'))
|
|
|
|
- qs = qs.values("ai_meal_id", "title", "content", "price", "effective_day", "currency",
|
|
|
|
- "virtual_price", "symbol")
|
|
|
|
- if not qs.exists():
|
|
|
|
- return response.json(0)
|
|
|
|
|
|
+ # 查询套餐数据
|
|
|
|
+ ai_meal_qs = AiStoreMeal.objects.filter(is_show=1, lang__lang=lang).\
|
|
|
|
+ annotate(ai_meal_id=F('id'), title=F('lang__title'), content=F('lang__content')).\
|
|
|
|
+ values("ai_meal_id", "title", "content", "price", "effective_day", "currency", "virtual_price", "symbol")
|
|
|
|
+ if not ai_meal_qs.exists():
|
|
|
|
+ return response.json(0)
|
|
|
|
|
|
- # 查询每种套餐的所有支付方式
|
|
|
|
- ai_meal_list = list(qs)
|
|
|
|
- for ai_meal in ai_meal_list:
|
|
|
|
- pay_type_qs = Pay_Type.objects.filter(aistoremeal=ai_meal['ai_meal_id']).values('id', 'payment')
|
|
|
|
- ai_meal['pay_type'] = list(pay_type_qs)
|
|
|
|
- result = {
|
|
|
|
- 'meals': ai_meal_list,
|
|
|
|
- }
|
|
|
|
- return response.json(0, result)
|
|
|
|
|
|
+ # 查询每种套餐的所有支付方式
|
|
|
|
+ ai_meal_list = list(ai_meal_qs)
|
|
|
|
+ for ai_meal in ai_meal_list:
|
|
|
|
+ pay_type_qs = Pay_Type.objects.filter(aistoremeal=ai_meal['ai_meal_id']).values('id', 'payment')
|
|
|
|
+ ai_meal['pay_type'] = list(pay_type_qs)
|
|
|
|
+ result = {
|
|
|
|
+ 'meals': ai_meal_list,
|
|
|
|
+ }
|
|
|
|
+ return response.json(0, result)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ return response.json(500, repr(e))
|
|
|
|
|
|
def do_querylist(self, userID, request_dict, response):
|
|
def do_querylist(self, userID, request_dict, response):
|
|
page = request_dict.get('page', None)
|
|
page = request_dict.get('page', None)
|