|
@@ -54,6 +54,8 @@ class serveManagement(View):
|
|
|
return self.getStoreMealList(userID, request_dict, response)
|
|
|
elif operation == 'addOrEditStoreMeal':
|
|
|
return self.addOrEditStoreMeal(userID, request_dict, response)
|
|
|
+ elif operation == 'deleteStoreMeal':
|
|
|
+ return self.deleteStoreMeal(userID, request_dict, response)
|
|
|
elif operation == 'getCdkList':
|
|
|
return self.getCdkList(userID, request_dict, response)
|
|
|
elif operation == 'createCdk':
|
|
@@ -192,8 +194,6 @@ class serveManagement(View):
|
|
|
# 获取云存套餐信息数据
|
|
|
print('request_dict: ', request_dict)
|
|
|
bucket = request_dict.get('bucket', None)
|
|
|
- mold = request_dict.get('mold', None)
|
|
|
- is_free = request_dict.get('is_free', None)
|
|
|
pageNo = request_dict.get('pageNo', None)
|
|
|
pageSize = request_dict.get('pageSize', None)
|
|
|
|
|
@@ -203,24 +203,19 @@ class serveManagement(View):
|
|
|
page = int(pageNo)
|
|
|
line = int(pageSize)
|
|
|
try:
|
|
|
- # if bucket or mold or is_free: # 条件查询
|
|
|
- # if bucket:
|
|
|
- # vod_bucket_qs = VodBucketModel.objects.filter(
|
|
|
- # bucket=bucket)
|
|
|
- # elif mold:
|
|
|
- # vod_bucket_qs = VodBucketModel.objects.filter(
|
|
|
- # mold=int(mold))
|
|
|
- # elif is_free:
|
|
|
- # vod_bucket_qs = VodBucketModel.objects.filter(
|
|
|
- # is_free=int(is_free))
|
|
|
- # else: # 查询全部
|
|
|
- store_meal_qs = Store_Meal.objects.filter().values(
|
|
|
+ if bucket: # 条件查询
|
|
|
+ if bucket:
|
|
|
+ bucket_id = VodBucketModel.objects.filter(
|
|
|
+ bucket=bucket).values('id')[0]['id']
|
|
|
+ store_meal = Store_Meal.objects.filter(bucket_id=bucket_id)
|
|
|
+ else: # 查询全部
|
|
|
+ store_meal = Store_Meal.objects.filter()
|
|
|
+ store_meal_qs = store_meal.values(
|
|
|
'id',
|
|
|
'bucket__bucket',
|
|
|
'day',
|
|
|
'expire',
|
|
|
'commodity_type',
|
|
|
- # 'pay_type',
|
|
|
'commodity_code',
|
|
|
'is_discounts',
|
|
|
'discount_price',
|
|
@@ -233,7 +228,7 @@ class serveManagement(View):
|
|
|
'update_time')
|
|
|
total = len(store_meal_qs)
|
|
|
store_meals = store_meal_qs[(page - 1) * line:page * line]
|
|
|
- store_meal_list = pay_type_list = []
|
|
|
+ store_meal_list = []
|
|
|
for store_meal in store_meals:
|
|
|
pay_type_list = [
|
|
|
pay_type['id'] for pay_type in Store_Meal.objects.get(
|
|
@@ -271,7 +266,9 @@ class serveManagement(View):
|
|
|
day = int(request_dict.get('day', 0))
|
|
|
expire = int(request_dict.get('expire', 0))
|
|
|
commodity_type = int(request_dict.get('commodity_type', 0))
|
|
|
- pay_type = request_dict.get('pay_type', '')[1:-1].split(',') # '[1,2]' -> ['1','2']
|
|
|
+ pay_type = request_dict.get(
|
|
|
+ 'pay_type', '')[
|
|
|
+ 1:-1].split(',') # '[1,2]' -> ['1','2']
|
|
|
commodity_code = request_dict.get('commodity_code', '')
|
|
|
is_discounts = int(request_dict.get('is_discounts', 0))
|
|
|
discount_price = request_dict.get('discount_price', '')
|
|
@@ -286,7 +283,8 @@ class serveManagement(View):
|
|
|
return response.json(444)
|
|
|
|
|
|
try:
|
|
|
- bucket_id = VodBucketModel.objects.filter(bucket=bucket).values('id')[0]['id']
|
|
|
+ bucket_id = VodBucketModel.objects.filter(
|
|
|
+ bucket=bucket).values('id')[0]['id']
|
|
|
store_meal_data = {
|
|
|
'bucket_id': bucket_id,
|
|
|
'day': day,
|
|
@@ -304,10 +302,26 @@ class serveManagement(View):
|
|
|
if isEdit:
|
|
|
if not storeMealID:
|
|
|
return response.json(444)
|
|
|
- Store_Meal.objects.filter(id=storeMealID).update(**store_meal_data)
|
|
|
+ Store_Meal.objects.filter(
|
|
|
+ id=storeMealID).update(
|
|
|
+ **store_meal_data)
|
|
|
Store_Meal.objects.get(id=storeMealID).pay_type.set(pay_type)
|
|
|
else:
|
|
|
- Store_Meal.objects.create(**store_meal_data).pay_type.set(pay_type)
|
|
|
+ Store_Meal.objects.create(
|
|
|
+ **store_meal_data).pay_type.set(pay_type)
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, repr(e))
|
|
|
+
|
|
|
+ def deleteStoreMeal(self, userID, request_dict, response):
|
|
|
+ # 删除存储桶
|
|
|
+ print('request_dict: ', request_dict)
|
|
|
+ storeMealID = request_dict.get('storeMealID', None)
|
|
|
+ if not storeMealID:
|
|
|
+ return response.json(444)
|
|
|
+ try:
|
|
|
+ Store_Meal.objects.filter(id=storeMealID).delete()
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
print(e)
|