|
@@ -52,6 +52,8 @@ class serveManagement(View):
|
|
|
return self.deleteVodBucket(userID, request_dict, response)
|
|
|
elif operation == 'getStoreMealList':
|
|
|
return self.getStoreMealList(userID, request_dict, response)
|
|
|
+ elif operation == 'addOrEditStoreMeal':
|
|
|
+ return self.addOrEditStoreMeal(userID, request_dict, response)
|
|
|
elif operation == 'getCdkList':
|
|
|
return self.getCdkList(userID, request_dict, response)
|
|
|
elif operation == 'createCdk':
|
|
@@ -157,16 +159,16 @@ class serveManagement(View):
|
|
|
'is_free': is_free,
|
|
|
'storeDay': storeDay,
|
|
|
'region_id': region_id,
|
|
|
- 'addTime': now_time,
|
|
|
- 'updTime': now_time,
|
|
|
}
|
|
|
if isEdit:
|
|
|
if not bucketID:
|
|
|
return response.json(444)
|
|
|
+ vod_bucket_data['updTime'] = now_time
|
|
|
VodBucketModel.objects.filter(
|
|
|
id=bucketID).update(
|
|
|
**vod_bucket_data)
|
|
|
else:
|
|
|
+ vod_bucket_data['addTime'] = now_time
|
|
|
VodBucketModel.objects.create(**vod_bucket_data)
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
@@ -237,7 +239,7 @@ class serveManagement(View):
|
|
|
pay_type['id'] for pay_type in Store_Meal.objects.get(
|
|
|
id=store_meal['id']).pay_type.values('id')]
|
|
|
store_meal_list.append({
|
|
|
- 'store_meal_id': store_meal['id'],
|
|
|
+ 'storeMealID': store_meal['id'],
|
|
|
'bucket': store_meal['bucket__bucket'],
|
|
|
'day': store_meal['day'],
|
|
|
'expire': store_meal['expire'],
|
|
@@ -261,6 +263,56 @@ class serveManagement(View):
|
|
|
print(e)
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
|
+ def addOrEditStoreMeal(self, userID, request_dict, response):
|
|
|
+ # 添加/编辑套餐
|
|
|
+ print('request_dict: ', request_dict)
|
|
|
+ storeMealID = request_dict.get('storeMealID', None)
|
|
|
+ bucket = request_dict.get('bucket', '')
|
|
|
+ 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']
|
|
|
+ commodity_code = request_dict.get('commodity_code', '')
|
|
|
+ is_discounts = int(request_dict.get('is_discounts', 0))
|
|
|
+ discount_price = request_dict.get('discount_price', '')
|
|
|
+ virtual_price = request_dict.get('virtual_price', '')
|
|
|
+ price = request_dict.get('price', '')
|
|
|
+ currency = request_dict.get('currency', '')
|
|
|
+ symbol = request_dict.get('symbol', '')
|
|
|
+ is_show = int(request_dict.get('is_show', 0))
|
|
|
+ isEdit = request_dict.get('isEdit', None)
|
|
|
+
|
|
|
+ if not all([bucket, pay_type, price, currency, symbol]):
|
|
|
+ return response.json(444)
|
|
|
+
|
|
|
+ try:
|
|
|
+ bucket_id = VodBucketModel.objects.filter(bucket=bucket).values('id')[0]['id']
|
|
|
+ store_meal_data = {
|
|
|
+ 'bucket_id': bucket_id,
|
|
|
+ 'day': day,
|
|
|
+ 'expire': expire,
|
|
|
+ 'commodity_type': commodity_type,
|
|
|
+ 'commodity_code': commodity_code,
|
|
|
+ 'is_discounts': is_discounts,
|
|
|
+ 'discount_price': discount_price,
|
|
|
+ 'virtual_price': virtual_price,
|
|
|
+ 'price': price,
|
|
|
+ 'currency': currency,
|
|
|
+ 'symbol': symbol,
|
|
|
+ 'is_show': is_show,
|
|
|
+ }
|
|
|
+ if isEdit:
|
|
|
+ if not storeMealID:
|
|
|
+ return response.json(444)
|
|
|
+ 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)
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, repr(e))
|
|
|
+
|
|
|
def getCdkList(self, userID, request_dict, response):
|
|
|
# 获取激活码列表
|
|
|
pageNo = request_dict.get('pageNo', None)
|