|
@@ -10,7 +10,7 @@ from urllib.parse import quote, parse_qs, unquote
|
|
|
|
|
|
import paypalrestsdk
|
|
import paypalrestsdk
|
|
from django.db import transaction, connection
|
|
from django.db import transaction, connection
|
|
-from django.db.models import Q
|
|
|
|
|
|
+from django.db.models import Q, Sum
|
|
from django.http import HttpResponse, HttpResponseRedirect
|
|
from django.http import HttpResponse, HttpResponseRedirect
|
|
from django.views import View
|
|
from django.views import View
|
|
|
|
|
|
@@ -515,7 +515,7 @@ class IcloudMeal(View):
|
|
data['title'] = '1G Permanent Package'
|
|
data['title'] = '1G Permanent Package'
|
|
data['note'] = 'Gift'
|
|
data['note'] = 'Gift'
|
|
if service['type'] == 1:
|
|
if service['type'] == 1:
|
|
- orders_qs = Order_Model.objects.filter(orderID=service['order_id'], order_type=4). \
|
|
|
|
|
|
+ orders_qs = Order_Model.objects.filter(orderID=service['order_id'], order_type=0). \
|
|
values('desc', 'unify_combo_id')
|
|
values('desc', 'unify_combo_id')
|
|
data['note'] = orders_qs[0]['desc']
|
|
data['note'] = orders_qs[0]['desc']
|
|
cloud_store_qs = ICloudStoreMeal.objects.filter(id=orders_qs[0]['unify_combo_id'],
|
|
cloud_store_qs = ICloudStoreMeal.objects.filter(id=orders_qs[0]['unify_combo_id'],
|
|
@@ -542,26 +542,18 @@ class IcloudMeal(View):
|
|
@return: response
|
|
@return: response
|
|
"""
|
|
"""
|
|
try:
|
|
try:
|
|
- select_part = 'SELECT'
|
|
|
|
- sum_used_size = 'SUM(u.use_size) AS total_used_size'
|
|
|
|
- sum_size = 'SUM(i.size) AS total_all_size'
|
|
|
|
- from_part = 'FROM icloud_use_details AS u JOIN icloud_service AS i ON i.use_details_id = u.id'
|
|
|
|
- where_part = "WHERE u.user_id = %s"
|
|
|
|
- # 合并SQL查询
|
|
|
|
- query = f'{select_part} {sum_used_size}, {sum_size} {from_part} {where_part}'
|
|
|
|
-
|
|
|
|
- with connection.cursor() as cursor:
|
|
|
|
- cursor.execute(query, (user_id,))
|
|
|
|
- result = cursor.fetchone()
|
|
|
|
- connection.close()
|
|
|
|
- if result != (None, None):
|
|
|
|
- data = {
|
|
|
|
- 'M_size': round(result[0], 2),
|
|
|
|
- 'G_size': round(result[1], 0)
|
|
|
|
- }
|
|
|
|
- return response.json(0, data)
|
|
|
|
- else:
|
|
|
|
- return response.json(173)
|
|
|
|
|
|
+ cloud_use_qs = IcloudUseDetails.objects.filter(user_id=user_id).values('id').aggregate(
|
|
|
|
+ total_used_size=Sum('use_size'),
|
|
|
|
+ id=Sum('id'))
|
|
|
|
+ id = cloud_use_qs['id']
|
|
|
|
+ cloud_service_qs = IcloudService.objects.filter(use_details_id=id).aggregate(
|
|
|
|
+ total_size=Sum('size'))
|
|
|
|
+
|
|
|
|
+ data = {
|
|
|
|
+ 'M_size': round(cloud_use_qs['total_used_size'], 2),
|
|
|
|
+ 'G_size': round(cloud_service_qs['total_size'], 0)
|
|
|
|
+ }
|
|
|
|
+ return response.json(0, data)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logging.info('异常错误,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
logging.info('异常错误,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, e)
|
|
return response.json(500, e)
|