/** * 酒店客房修改 * * @author chivalry * @param request * @return 2015-10-12 */ @SuppressWarnings("rawtypes") @PolicyJournal(accessLevel = AccessLevel.PRIVATE) @RequestMapping( value = "/do_edit_hotelRoom", method = {RequestMethod.POST}) @ResponseBody public Response do_edit_hotelRoom( HttpServletRequest request, @Valid HotelRoomBo hotelRoom, BindingResult result, HotelRoomPlanBo hotelRoomPlan) { // 返回对象 Response response = new Response(); // 服务端验证 if (result.hasErrors()) { ValidateParamUtils.analyzeErrors(result, response); return response; } int results = 1; results = this.hotelRoomService.updateHotelRoom(hotelRoom); // 根据客房主键ID删除客房产品 hotelRoomPlan.setId(null); hotelRoomPlan.setRoomId(hotelRoom.getId()); results = this.hotelRoomPlanService.deleteRoomPlanByPk(hotelRoomPlan); // 新增客房产品 hotelRoomPlan.setHotelId(hotelRoom.getHotelId()); hotelRoomPlan.setBedType(hotelRoom.getBedType()); hotelRoomPlan.setRoomStatus(hotelRoom.getRoomStatus()); String[] breakfastTypeStr = request.getParameterValues("isBreakfast"); String[] cancelRuleStr = request.getParameterValues("cancelRule"); String[] discountAmountStr = request.getParameterValues("discount"); String[] cashBackStr = request.getParameterValues("cashBack"); String[] roomPlanName = request.getParameterValues("roomPlanName"); String[] payType = request.getParameterValues("payType"); String[] campaignDaysStr = request.getParameterValues("campaignDays"); List<HotelRoomPlanBo> list = new ArrayList<HotelRoomPlanBo>(); if (breakfastTypeStr != null) { for (int i = 0; i < breakfastTypeStr.length; i++) { hotelRoomPlan.setBreakfastType(breakfastTypeStr[i]); hotelRoomPlan.setCancelRule(cancelRuleStr[i]); hotelRoomPlan.setDiscountAmount(discountAmountStr[i]); hotelRoomPlan.setCashBack(cashBackStr[i]); hotelRoomPlan.setRoomPlanName(roomPlanName[i]); hotelRoomPlan.setPayType(payType[i]); hotelRoomPlan.setCampaignDays(campaignDaysStr[i]); if (hotelRoomPlan.getDiscountAmount() == null || StringUtils.isBlank(hotelRoomPlan.getDiscountAmount())) { response.setFailMessage("折扣未填写完整!"); return response; } if (hotelRoomPlan.getCashBack() == null || StringUtils.isBlank(hotelRoomPlan.getCashBack())) { response.setFailMessage("返现未填写完整!"); return response; } if (hotelRoomPlan.getRoomPlanName() == null || StringUtils.isBlank(hotelRoomPlan.getRoomPlanName())) { response.setFailMessage("产品名称未填写完整!"); return response; } if (hotelRoomPlan.getCampaignDays() == null || StringUtils.isBlank(hotelRoomPlan.getCampaignDays())) { response.setFailMessage("起订天数未填写完整!"); return response; } double price = 0; double discountAmount = Double.parseDouble(discountAmountStr[i]); double cashBack = Double.parseDouble(cashBackStr[i]); double prices = Double.parseDouble(hotelRoom.getPrice()); price = prices * discountAmount / 10 + cashBack; hotelRoomPlan.setPrice(Double.toString(price)); HotelRoomPlanBo hotelRoomPlans = new HotelRoomPlanBo(); BeanUtils.copyProperties(hotelRoomPlan, hotelRoomPlans); list.add(hotelRoomPlans); } } if (list != null && list.size() > 0 && list.get(0).getBreakfastType() != null && list.get(0).getBreakfastType() != "") { results = this.hotelRoomPlanService.insertHotelRoomPlan(list); } if (results >= 0) { response.setSucceessMessage("修改成功"); } else { response.setFailMessage("修改失败"); } return response; }
/** * 酒店房间新增方法 * * @author chivalry * @param request * @return 2015-09-21 */ @SuppressWarnings("rawtypes") @PolicyJournal(accessLevel = AccessLevel.PRIVATE) @RequestMapping( value = "/do_hotelRoom_add", method = {RequestMethod.POST}) @ResponseBody public Response do_hotelRoom_add( HttpServletRequest request, @Valid HotelRoomBo hotelRoom, BindingResult result, HotelRoomPlanBo hotelRoomPlan) { // 返回对象 LoginUser user = LoginSessionUtil.getSystemSession(request); // 判断当前用户是否为加盟商 if (user.getAgentId() != null) { String id = user.getAgentId().toString(); hotelRoomPlan.setAgentId(id); } else { hotelRoomPlan.setAgentId("0"); } Response response = new Response(); // 服务端验证 if (result.hasErrors()) { ValidateParamUtils.analyzeErrors(result, response); return response; } // 返回插入酒店信息主键ID,设置房间产品信息 // 插入图片关联关系 String imageIds = request.getParameter("imageIds"); String[] imageidsStr = imageIds.split(","); List<Map<String, Object>> imageList = new ArrayList<Map<String, Object>>(); for (int i = 0; i < imageidsStr.length; i++) { if (StringUtils.isNotBlank(imageidsStr[i])) { Map<String, Object> map = new HashMap<String, Object>(); map.put("roomId", hotelRoom.getId()); map.put("hotelId", null); map.put("groupHotelId", null); map.put("imageId", imageidsStr[i]); imageList.add(map); } } // if(imageList!=null&&imageList.size()>0&&imageList.get(0).get("imageId")!=null // &&imageList.get(0).get("imageId")!=""){ // imageService.insertRelation(imageList); // } hotelRoomPlan.setHotelId(hotelRoom.getHotelId()); hotelRoomPlan.setBedType(hotelRoom.getBedType()); hotelRoomPlan.setRoomId(hotelRoom.getId()); hotelRoomPlan.setRoomStatus(hotelRoom.getRoomStatus()); String[] breakfastTypeStr = request.getParameterValues("isBreakfast"); String[] cancelRuleStr = request.getParameterValues("cancelRule"); String[] discountAmountStr = request.getParameterValues("discount"); String[] cashBackStr = request.getParameterValues("cashBack"); String[] roomPlanName = request.getParameterValues("roomPlanName"); String[] payType = request.getParameterValues("payType"); String[] campaignDaysStr = request.getParameterValues("campaignDays"); List<HotelRoomPlanBo> list = new ArrayList<HotelRoomPlanBo>(); for (int i = 0; i < breakfastTypeStr.length; i++) { hotelRoomPlan.setBreakfastType(breakfastTypeStr[i]); hotelRoomPlan.setCancelRule(cancelRuleStr[i]); hotelRoomPlan.setDiscountAmount(discountAmountStr[i]); hotelRoomPlan.setCashBack(cashBackStr[i]); hotelRoomPlan.setRoomPlanName(roomPlanName[i]); hotelRoomPlan.setPayType(payType[i]); hotelRoomPlan.setCampaignDays(campaignDaysStr[i]); if (hotelRoomPlan.getDiscountAmount() == null || StringUtils.isBlank(hotelRoomPlan.getDiscountAmount())) { response.setFailMessage("折扣未填写完整!"); return response; } if (hotelRoomPlan.getCashBack() == null || StringUtils.isBlank(hotelRoomPlan.getCashBack())) { response.setFailMessage("返现未填写完整!"); return response; } if (hotelRoomPlan.getRoomPlanName() == null || StringUtils.isBlank(hotelRoomPlan.getRoomPlanName())) { response.setFailMessage("产品名称未填写完整!"); return response; } if (hotelRoomPlan.getCampaignDays() == null || StringUtils.isBlank(hotelRoomPlan.getCampaignDays())) { response.setFailMessage("起订天数未填写完整!"); return response; } double price = 0; double discountAmount = Double.parseDouble(discountAmountStr[i]); double cashBack = Double.parseDouble(cashBackStr[i]); double prices = Double.parseDouble(hotelRoom.getPrice()); price = prices * discountAmount / 10 + cashBack; hotelRoomPlan.setPrice(Double.toString(price)); HotelRoomPlanBo hotelRoomPlans = new HotelRoomPlanBo(); BeanUtils.copyProperties(hotelRoomPlan, hotelRoomPlans); list.add(hotelRoomPlans); } // if(list!=null&&list.size()>0&&list.get(0).getBreakfastType()!=null // &&list.get(0).getBreakfastType()!=""){ // results=this.hotelRoomPlanService.insertHotelRoomPlan(list); // } int results = this.hotelRoomService.insertHotelRoomAndOther(hotelRoom, imageList, list); if (results >= 1) { response.setSucceessMessage("添加成功"); } else { response.setFailMessage("添加失败"); } return response; }