|
@@ -74,6 +74,8 @@ class MealManage(View):
|
|
return self.add_language(request_dict, response)
|
|
return self.add_language(request_dict, response)
|
|
elif operation == 'delete_language':
|
|
elif operation == 'delete_language':
|
|
return self.delete_language(request_dict, response)
|
|
return self.delete_language(request_dict, response)
|
|
|
|
+ elif operation == 'edit_language':
|
|
|
|
+ return self.edit_language(request_dict, response)
|
|
else:
|
|
else:
|
|
return response.json(444, 'operation')
|
|
return response.json(444, 'operation')
|
|
|
|
|
|
@@ -155,10 +157,10 @@ class MealManage(View):
|
|
|
|
|
|
def update(self, request_dict, userID, response):
|
|
def update(self, request_dict, userID, response):
|
|
id = request_dict.get('id', None)
|
|
id = request_dict.get('id', None)
|
|
- title = request_dict.get('title', None)
|
|
|
|
|
|
+ # title = request_dict.get('title', None)
|
|
price = request_dict.get('price', None)
|
|
price = request_dict.get('price', None)
|
|
day = request_dict.get('day', None)
|
|
day = request_dict.get('day', None)
|
|
- content = request_dict.get('content', None)
|
|
|
|
|
|
+ # content = request_dict.get('content', None)
|
|
currency = request_dict.get('currency', None)
|
|
currency = request_dict.get('currency', None)
|
|
bucketID = request_dict.get('bucketID', None)
|
|
bucketID = request_dict.get('bucketID', None)
|
|
commodity_type = request_dict.get('commodity_type', None)
|
|
commodity_type = request_dict.get('commodity_type', None)
|
|
@@ -169,8 +171,10 @@ class MealManage(View):
|
|
expire = request_dict.get('expire', None)
|
|
expire = request_dict.get('expire', None)
|
|
symbol = request_dict.get('symbol', None)
|
|
symbol = request_dict.get('symbol', None)
|
|
type = request_dict.get('type', None)
|
|
type = request_dict.get('type', None)
|
|
- if not id or not title or not price or not content or not day or not type:
|
|
|
|
- return response.json(444, 'id, title, price, content, day,type')
|
|
|
|
|
|
+ # if not id or not title or not price or not content or not day or not type:
|
|
|
|
+ if not id or not price or not day or not type:
|
|
|
|
+ # return response.json(444, 'id, title, price, content, day,type')
|
|
|
|
+ return response.json(444, 'id, price, day,type')
|
|
own_perm = ModelService.check_perm(userID=userID, permID=30)
|
|
own_perm = ModelService.check_perm(userID=userID, permID=30)
|
|
if own_perm is not True:
|
|
if own_perm is not True:
|
|
return response.json(404)
|
|
return response.json(404)
|
|
@@ -178,9 +182,9 @@ class MealManage(View):
|
|
store_meal = Store_Meal.objects.get(id=id)
|
|
store_meal = Store_Meal.objects.get(id=id)
|
|
now_time = timezone.localtime(timezone.now())
|
|
now_time = timezone.localtime(timezone.now())
|
|
print(now_time)
|
|
print(now_time)
|
|
- store_meal.title = title
|
|
|
|
|
|
+ # store_meal.title = title
|
|
store_meal.price = price
|
|
store_meal.price = price
|
|
- store_meal.content = content
|
|
|
|
|
|
+ # store_meal.content = content
|
|
store_meal.commodity_type = commodity_type
|
|
store_meal.commodity_type = commodity_type
|
|
store_meal.commodity_code = commodity_code
|
|
store_meal.commodity_code = commodity_code
|
|
store_meal.virtual_price = virtual_price
|
|
store_meal.virtual_price = virtual_price
|
|
@@ -267,7 +271,7 @@ class MealManage(View):
|
|
content = request_dict.get('content', None)
|
|
content = request_dict.get('content', None)
|
|
discount_content = request_dict.get('discount_content', None)
|
|
discount_content = request_dict.get('discount_content', None)
|
|
if not store_meal_id or not lang or not title or not content or not discount_content:
|
|
if not store_meal_id or not lang or not title or not content or not discount_content:
|
|
- return response.json(444, 'store_meal_id,lang,title,content')
|
|
|
|
|
|
+ return response.json(444, 'store_meal_id,lang,title,content,discount_content')
|
|
# 查询该套餐是否存在
|
|
# 查询该套餐是否存在
|
|
storeMeal_qs = Store_Meal.objects.get(id=store_meal_id)
|
|
storeMeal_qs = Store_Meal.objects.get(id=store_meal_id)
|
|
if not storeMeal_qs:
|
|
if not storeMeal_qs:
|
|
@@ -275,13 +279,33 @@ class MealManage(View):
|
|
lang_obj = Lang.objects.filter(lang=lang, title=title, content=content, discount_content=discount_content)
|
|
lang_obj = Lang.objects.filter(lang=lang, title=title, content=content, discount_content=discount_content)
|
|
if not lang_obj.exists():
|
|
if not lang_obj.exists():
|
|
# 数据不存在,lang表创建数据
|
|
# 数据不存在,lang表创建数据
|
|
- lang_obj = Lang.objects.create(lang=lang, title=title, content=content, discount_content=discount_content)
|
|
|
|
|
|
+ Lang.objects.create(lang=lang, title=title, content=content, discount_content=discount_content)
|
|
|
|
+ lang_obj = Lang.objects.filter(lang=lang, title=title, content=content, discount_content=discount_content)
|
|
|
|
+ storeMeal_qs.lang.add(*lang_obj) # store_meal表添加语言数据
|
|
|
|
+ return response.json(0)
|
|
|
|
+
|
|
|
|
+ def edit_language(self, request_dict, response):
|
|
|
|
+ # 编辑套餐语言
|
|
|
|
+ store_meal_id = request_dict.get('store_meal_id', None)
|
|
|
|
+ lang_id = request_dict.get('lang_id', None)
|
|
|
|
+ lang = request_dict.get('lang', None)
|
|
|
|
+ title = request_dict.get('title', None)
|
|
|
|
+ content = request_dict.get('content', None)
|
|
|
|
+ discount_content = request_dict.get('discount_content', None)
|
|
|
|
+ if not store_meal_id or not lang_id or not lang or not title or not content or not discount_content:
|
|
|
|
+ return response.json(444, 'store_meal_id,lang_id,lang,title,content,discount_content')
|
|
|
|
+ storeMeal_qs = Store_Meal.objects.get(id=store_meal_id)
|
|
|
|
+ if not storeMeal_qs:
|
|
|
|
+ return response.json(500)
|
|
|
|
+ # 删除原有数据
|
|
|
|
+ lang_qs = Lang.objects.filter(id=lang_id)
|
|
|
|
+ storeMeal_qs.lang.remove(*lang_qs)
|
|
|
|
+ lang_obj = Lang.objects.filter(lang=lang, title=title, content=content, discount_content=discount_content)
|
|
|
|
+ if not lang_obj.exists():
|
|
|
|
+ # 数据不存在,lang表创建数据
|
|
|
|
+ Lang.objects.create(lang=lang, title=title, content=content, discount_content=discount_content)
|
|
|
|
+ lang_obj = Lang.objects.filter(lang=lang, title=title, content=content, discount_content=discount_content)
|
|
storeMeal_qs.lang.add(*lang_obj) # store_meal表添加语言数据
|
|
storeMeal_qs.lang.add(*lang_obj) # store_meal表添加语言数据
|
|
- # count = lang_obj.count()
|
|
|
|
- # res = {
|
|
|
|
- # 'datas': list(lang_obj),
|
|
|
|
- # 'count': count
|
|
|
|
- # }
|
|
|
|
return response.json(0)
|
|
return response.json(0)
|
|
|
|
|
|
def delete_language(self, request_dict, response):
|
|
def delete_language(self, request_dict, response):
|
|
@@ -290,7 +314,9 @@ class MealManage(View):
|
|
lang_id = request_dict.get('lang_id', None)
|
|
lang_id = request_dict.get('lang_id', None)
|
|
|
|
|
|
storeMeal_qs = Store_Meal.objects.get(id=store_meal_id)
|
|
storeMeal_qs = Store_Meal.objects.get(id=store_meal_id)
|
|
- lang_qs = Lang.objects.get(id=lang_id)
|
|
|
|
|
|
+ if not storeMeal_qs:
|
|
|
|
+ return response.json(500)
|
|
|
|
+ lang_qs = Lang.objects.filter(id=lang_id)
|
|
storeMeal_qs.lang.remove(*lang_qs)
|
|
storeMeal_qs.lang.remove(*lang_qs)
|
|
return response.json(0)
|
|
return response.json(0)
|
|
|
|
|