|
@@ -1,5 +1,6 @@
|
|
|
#!/usr/bin/env python3
|
|
|
# -*- coding: utf-8 -*-
|
|
|
+import time
|
|
|
|
|
|
from django.views.generic.base import View
|
|
|
from Model.models import Lang, AiStoreMeal, AiService, Order_Model
|
|
@@ -52,6 +53,9 @@ class AiServeView(View):
|
|
|
# ai用户信息相关
|
|
|
elif operation == 'getAiUserList':
|
|
|
return self.getAiUserList(request_dict, response)
|
|
|
+ # ai服务开通数量数据
|
|
|
+ elif operation == 'getAiDataList':
|
|
|
+ return self.getAiDataList(request_dict, response)
|
|
|
else:
|
|
|
return response.json(404)
|
|
|
|
|
@@ -420,3 +424,56 @@ class AiServeView(View):
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
return response.json(500, repr(e))
|
|
|
+
|
|
|
+ def getAiDataList(self, request_dict, response):
|
|
|
+ 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")))
|
|
|
+ Mar = int(time.mktime(time.strptime(year + '-3-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ Apr = int(time.mktime(time.strptime(year + '-4-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ May = int(time.mktime(time.strptime(year + '-5-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ Jun = int(time.mktime(time.strptime(year + '-6-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ Jul = int(time.mktime(time.strptime(year + '-7-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ Aug = int(time.mktime(time.strptime(year + '-8-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ Sep = int(time.mktime(time.strptime(year + '-9-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ Oct = int(time.mktime(time.strptime(year + '-10-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ Nov = int(time.mktime(time.strptime(year + '-11-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ Dec = int(time.mktime(time.strptime(year + '-12-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+ Jan_next = int(time.mktime(time.strptime(str(int(year)+1) + '-1-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
+
|
|
|
+ list_data = []
|
|
|
+ ai_store_meal_qs = AiStoreMeal.objects.filter(lang__lang='cn').values('id', 'lang__title', 'lang__content')
|
|
|
+ if not ai_store_meal_qs.exists():
|
|
|
+ return response.json(173)
|
|
|
+ try:
|
|
|
+ for ai_store_meal in ai_store_meal_qs:
|
|
|
+ name = ai_store_meal['lang__title']+'-'+ai_store_meal['lang__content']
|
|
|
+ order = Order_Model.objects.filter(order_type=1, status=1, ai_rank=ai_store_meal['id'])
|
|
|
+ if not order.exists():
|
|
|
+ continue
|
|
|
+ Jan_count = order.filter(status=1, addTime__range=[Jan, Feb]).count()
|
|
|
+ Feb_count = order.filter(status=1, addTime__range=[Feb, Mar]).count()
|
|
|
+ Mar_count = order.filter(status=1, addTime__range=[Mar, Apr]).count()
|
|
|
+ Apr_count = order.filter(status=1, addTime__range=[Apr, May]).count()
|
|
|
+ May_count = order.filter(status=1, addTime__range=[May, Jun]).count()
|
|
|
+ Jun_count = order.filter(status=1, addTime__range=[Jun, Jul]).count()
|
|
|
+ Jul_count = order.filter(status=1, addTime__range=[Jul, Aug]).count()
|
|
|
+ Aug_count = order.filter(status=1, addTime__range=[Aug, Sep]).count()
|
|
|
+ Sep_count = order.filter(status=1, addTime__range=[Sep, Oct]).count()
|
|
|
+ Oct_count = order.filter(status=1, addTime__range=[Oct, Nov]).count()
|
|
|
+ Nov_count = order.filter(status=1, addTime__range=[Nov, Dec]).count()
|
|
|
+ Dec_count = order.filter(status=1, addTime__range=[Dec, Jan_next]).count()
|
|
|
+ data = [Jan_count, Feb_count, Mar_count, Apr_count, May_count, Jun_count, Jul_count, Aug_count, Sep_count,
|
|
|
+ Oct_count, Nov_count, Dec_count]
|
|
|
+
|
|
|
+ cloud_data = {
|
|
|
+ 'name': name,
|
|
|
+ 'type': 'line',
|
|
|
+ 'data': data,
|
|
|
+ }
|
|
|
+ list_data.append(cloud_data)
|
|
|
+
|
|
|
+ return response.json(0, {'list': list_data})
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, repr(e))
|