|
@@ -164,28 +164,27 @@ class DeviceMeal(View):
|
|
|
if param_flag is True:
|
|
|
try:
|
|
|
store_meal = Store_Meal.objects.get(id=rank)
|
|
|
- device_meal = Device_Meal.objects.get(id=id)
|
|
|
- # days = store_meal.day
|
|
|
- # now_time = timezone.localtime(timezone.now())
|
|
|
- # if now_time > device_meal.end_time:
|
|
|
- # end_time = now_time + datetime.timedelta(days=int(days))
|
|
|
- # else:
|
|
|
- # end_time = device_meal.end_time + datetime.timedelta(days=int(days))
|
|
|
+ dmqs = Device_Meal.objects.get(id=id)
|
|
|
+ if rank != dmqs.rank_id:
|
|
|
+ days = store_meal.day
|
|
|
+ now_time = timezone.localtime(timezone.now())
|
|
|
+ if now_time > dmqs.end_time:
|
|
|
+ end_time = now_time + datetime.timedelta(days=int(days))
|
|
|
+ else:
|
|
|
+ end_time = dmqs.end_time + datetime.timedelta(days=int(days))
|
|
|
+ dmqs.end_time = end_time
|
|
|
+ dmqs.status = status
|
|
|
+ dmqs.uid = uid
|
|
|
+ dmqs.channel = channel
|
|
|
+ dmqs.rank = store_meal
|
|
|
+ dmqs.save()
|
|
|
except Exception as e:
|
|
|
errorInfo = traceback.format_exc()
|
|
|
print(errorInfo)
|
|
|
return response.json(424, {'details': repr(e)})
|
|
|
else:
|
|
|
- if device_meal.id:
|
|
|
- device_meal.status = status
|
|
|
- device_meal.uid = uid
|
|
|
- device_meal.channel = channel
|
|
|
- # device_meal.end_time = end_time
|
|
|
- device_meal.rank = store_meal
|
|
|
- device_meal.save()
|
|
|
- return response.json(0, {'update_id': device_meal.id,
|
|
|
- 'update_time': str(device_meal.now_time),
|
|
|
- 'end_time': str(device_meal.end_time)})
|
|
|
+ return response.json(0, {'update_id': dmqs.id,'update_time': str(dmqs.now_time),
|
|
|
+ 'end_time': str(dmqs.end_time)})
|
|
|
else:
|
|
|
return response.json(444)
|
|
|
|