//房价日历--修改
@ResponseBody
@RequestMapping("/room/price/search/update")
public Response search_update(@RequestBody JSONObject hotelRoomPriceGet) throws Exception {
String hotelRoomPriceGetStr = hotelRoomPriceGet.toJSONString();
JSONObject jsonObject = JSON.parseObject(hotelRoomPriceGetStr);
String obj = jsonObject.getString("obj");
//将obj转换为hotelRoomPriceGet对象匹配格式
List<HotelRoomPriceGet> hotelRoomPriceGets = JSON.parseArray(URLDecoder.decode(obj, "UTF-8"), HotelRoomPriceGet.class);
if (!CollectionUtils.isEmpty(hotelRoomPriceGets)){
for (HotelRoomPriceGet roomPriceGet : hotelRoomPriceGets) {
Long product_id = roomPriceGet.getProduct_id();
String date_start = roomPriceGet.getDate_start();
String date_end = roomPriceGet.getDate_end();
String price = roomPriceGet.getPrice();
Date startDate = DateUtils.parseDate(date_start,"yyyy-MM-dd");
Date endDate = DateUtils.parseDate(date_end,"yyyy-MM-dd");
for (Date d = startDate;d.getTime()<=endDate.getTime();d=DateUtils.addDays(d, 1)){
hotelRoomPriceService.update(product_id,d,price);
}
}
return new Response().success("修改房价成功");
}else {
return new Response().failed("修改房价失败,数据为空");
}
}
public class HotelRoomPriceGet {
private Long product_id;//产品id
private String date_start;//开始时间
private String date_end;//结束时间
private String price;//价格
}
res.product_id = productId;
res.date_start = startTime;
res.date_end = endTime;
res.price = price;
arr.push(res)
result["obj"] = arr;
}
})
console.log(result)
console.log(JSON.stringify(result))
$.ajax({
type: 'POST',
url: '/room/price/search/update',
// data: result,
data: JSON.stringify(result),
contentType : "application/json;charsetset=UTF-8",
dataType: 'json',
success: function (res) {
console.log(res)