hotelAction.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. package com.happy.action;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.google.gson.Gson;
  4. import com.google.gson.reflect.TypeToken;
  5. import com.happy.Model.*;
  6. import com.happy.Until.GetHttpParam;
  7. import com.happy.Until.PwdDefind;
  8. import com.happy.Until.ResUtil;
  9. import com.happy.Until.UUIDUtil;
  10. import com.happy.dto.HotelEto;
  11. import com.happy.dto.IPage;
  12. import com.happy.service.*;
  13. import com.opensymphony.xwork2.ActionSupport;
  14. import lombok.SneakyThrows;
  15. import net.sf.json.JSONObject;
  16. import org.apache.struts2.ServletActionContext;
  17. import org.apache.struts2.interceptor.ServletRequestAware;
  18. import org.springframework.beans.BeanUtils;
  19. import javax.annotation.Resource;
  20. import javax.servlet.http.HttpServletRequest;
  21. import javax.servlet.http.HttpServletResponse;
  22. import java.util.*;
  23. public class hotelAction extends ActionSupport implements ServletRequestAware {
  24. private HttpServletRequest request;
  25. public HttpServletResponse response;
  26. @Resource
  27. public BookService bookService;
  28. @Resource
  29. public WorkflowService workflowService;
  30. @Resource
  31. public AdminManagerService adminManagerService;
  32. @Resource
  33. public HotelService hotelService;
  34. @Resource
  35. public HotelDictService hotelDictService;
  36. @Resource
  37. public HouseService houseService;
  38. @Resource
  39. public FileService fileService;
  40. public Integer id;
  41. public Integer managerId;//所属商家账号id
  42. public Integer code;//查询字典编码
  43. public int page; // 当前页
  44. public int rows;// 每页显示的行数rows
  45. public String fileListJson;
  46. public HttpServletRequest getRequest() {
  47. return request;
  48. }
  49. public void setRequest(HttpServletRequest request) {
  50. this.request = request;
  51. }
  52. public void setServletRequest(HttpServletRequest request) {
  53. this.request = request;
  54. }
  55. public HttpServletResponse getResponse() {
  56. return response;
  57. }
  58. public void setResponse(HttpServletResponse response) {
  59. this.response = response;
  60. }
  61. /**
  62. * 描述:维护民宿信息
  63. * @return
  64. */
  65. public String updateHotel(){
  66. JSONObject resultJson = new JSONObject();
  67. Gson gson = new Gson();
  68. com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
  69. if (json == null) {
  70. resultJson.put("message", "请传入参数");
  71. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  72. return null;
  73. }
  74. HotelEto hotelEto = new HotelEto();
  75. try{
  76. hotelEto = gson.fromJson(json.toString(), new TypeToken<HotelEto>() {}.getType());
  77. Hotel hotel = new Hotel();
  78. BeanUtils.copyProperties(hotelEto,hotel);
  79. int hotelId = hotel.getId()!=null ? hotel.getId():Math.toIntExact(UUIDUtil.generateID());
  80. if(hotelId==0){
  81. hotelId = Math.toIntExact(UUIDUtil.generateID());
  82. }
  83. int m = 0;
  84. //详细图附件
  85. List<FileInfo> fileList = JSONArray.parseArray(fileListJson, FileInfo.class);
  86. if(fileList==null || fileList.size() == 0){
  87. resultJson.put("message", "请上传详细图");
  88. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  89. return null;
  90. }
  91. //保存基本信息
  92. Hotel hotel1 = hotelService.getById(hotel.getId());
  93. boolean isOk = false;
  94. if(hotel1!= null){
  95. //修改
  96. if (1 == hotel1.getHstatus() && 2 == hotel.getHstatus()){ // 判断营业改休息
  97. StringBuilder s1 = new StringBuilder("");
  98. s1.append(" and order_status in ( 1,2,3,4,10) "); //待支付、已支付、待入住、已入住、退款中
  99. s1.append(" and hotel_id = '").append(hotel.getId()).append("' ");
  100. List<Booking> list = bookService.queryList(s1.toString()); // 查询分页
  101. if (list != null){
  102. resultJson.put("message", "民宿存在“待支付、已支付、待入住、已入住、退款中”状态的订单,不可更改民宿状态。");
  103. resultJson.put("code", 200);
  104. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  105. return null;
  106. }
  107. }
  108. //判断是否修改简介
  109. if (hotel1.getRemark() != null && !"".equals(hotel1.getRemark())){
  110. if (!hotel1.getRemark().equals(hotel.getRemark())){
  111. isOk = true;
  112. }
  113. }else {
  114. isOk = true;
  115. }
  116. //判断是否修改了封面图
  117. if (hotel1.getCoverImg() != null && !"".equals(hotel1.getCoverImg())){
  118. if ( !hotel1.getCoverImg().equals(hotel.getCoverImg()) && hotel.getCoverImg() != null && !"".equals(hotel.getCoverImg())){
  119. isOk = true;
  120. }
  121. }else {
  122. isOk = true;
  123. }
  124. //判断是否修改图片
  125. for(FileInfo file : fileList){
  126. if ( "".equals(file.getLinkId()) || file.getLinkId()==null || file.getLinkId().length() == 0) {
  127. isOk = true;
  128. break;
  129. }
  130. }
  131. //判断图片是否有删除
  132. List<FileInfo> fileInfoList = fileService.queryList("and link_id ='"+hotel.getManagerId()+"' and (`name` is null or `name` not like '%营业执照%') ");
  133. System.out.println("==="+fileInfoList+"==="+fileList);
  134. if (fileInfoList != null){
  135. if (fileInfoList.size() != fileList.size()){
  136. isOk = true;
  137. }
  138. }else {
  139. isOk = true;
  140. }
  141. if (isOk){
  142. Workflow workflow = new Workflow();
  143. String id = String.valueOf(UUID.randomUUID());
  144. workflow.setLinkId(String.valueOf(hotel.getManagerId()));
  145. workflow.setRemark(hotel.getRemark());
  146. workflow.setCreateId(String.valueOf(hotel.getCreateId()));
  147. workflow.setId(id);
  148. workflow.setStatus(1);
  149. workflow.setType(1);
  150. workflow.setCoverImg(hotel.getCoverImg());
  151. hotel.setRemark(hotel1.getRemark());
  152. hotel.setCoverImg(hotel.getCoverImg());
  153. int i = workflowService.insert(workflow);
  154. hotel.setWorkflowId(workflow.getId());
  155. m = hotelService.updateHotel(hotel);
  156. if (i > 0 && m > 0){
  157. //将新修改的附件关联到流程id
  158. for(FileInfo file : fileList){
  159. file.setId(String.valueOf(UUID.randomUUID()));
  160. file.setLinkId(id);
  161. System.out.println(file.getLinkId());
  162. fileService.insertFile(file);
  163. }
  164. if(hotel.getId()!= null){
  165. fileService.delLinkFile2(String.valueOf(hotel.getManagerId()), " and (`name` is null or `name` not like '%营业执照%') ");
  166. }
  167. for(FileInfo file : fileList){
  168. FileInfo fileInfo = fileService.getById(file.getId());
  169. file.setLinkId(String.valueOf(hotel.getManagerId()));
  170. if(fileInfo==null){
  171. fileService.insertFile(file);
  172. }else{
  173. fileService.updateFile(file);
  174. }
  175. }
  176. hotel.setRemark(hotel1.getRemark());
  177. resultJson.put("message", "已成功提交审批!");
  178. resultJson.put("code", 200);
  179. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  180. return null;
  181. }else {
  182. resultJson.put("message", "提交审批失败!");
  183. resultJson.put("code", 502);
  184. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  185. return null;
  186. }
  187. }else{
  188. hotel.setId(hotelId);
  189. m = hotelService.updateHotel(hotel);
  190. }
  191. }else{
  192. resultJson.put("message", "未找到数据Id:"+hotelId);
  193. resultJson.put("code", 502);
  194. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  195. return null;
  196. }
  197. if (m > 0) {
  198. if(hotel.getId()!= null){
  199. fileService.delLinkFile2(String.valueOf(hotel.getManagerId()), " and (`name` is null or `name` not like '%营业执照%') ");
  200. }
  201. for(FileInfo file : fileList){
  202. FileInfo fileInfo = fileService.getById(file.getId());
  203. file.setLinkId(String.valueOf(hotel.getManagerId()));
  204. if(fileInfo==null){
  205. fileService.insertFile(file);
  206. }else{
  207. fileService.updateFile(file);
  208. }
  209. }
  210. resultJson.put("message", "维护成功");
  211. resultJson.put("code", 200);
  212. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  213. return null;
  214. } else {
  215. resultJson.put("message", "维护失败");
  216. resultJson.put("code", 502);
  217. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  218. return null;
  219. }
  220. } catch (Exception e){
  221. e.printStackTrace();
  222. }
  223. resultJson.put("message", "未知异常");
  224. resultJson.put("code", 205);
  225. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  226. return null;
  227. }
  228. /**
  229. * 描述:查看民宿详细
  230. * @return
  231. */
  232. public String getByHotelInfo(){
  233. JSONObject resultJson = new JSONObject();
  234. StringBuilder s1 = new StringBuilder("");
  235. if (managerId!=null){
  236. s1.append(" and manager_id = '").append(managerId).append("'");
  237. }else{
  238. resultJson.put("message", "请传入managerId");
  239. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  240. return null;
  241. }
  242. if(id!=null){
  243. s1.append(" and id = '").append(id).append("'");
  244. }
  245. //查询商户信息
  246. AdminManager adminManager = adminManagerService.getById(managerId);
  247. //查询民宿信息
  248. Hotel hotel = hotelService.getOen(s1.toString());
  249. HotelEto hotelEto = new HotelEto();
  250. if(adminManager!=null){
  251. hotelEto.setHotelName(adminManager.getHotelName());
  252. hotelEto.setHotelTownship(adminManager.getHotelTownship());
  253. hotelEto.setHotelTownshipName(adminManager.getHotelTownshipName());
  254. hotelEto.setCorpnName(adminManager.getCorpnName());
  255. hotelEto.setCorpnPhone(adminManager.getCorpnPhone());
  256. hotelEto.setManagerId(adminManager.getId());
  257. hotelEto.setBankCard(adminManager.getBankCard());
  258. hotelEto.setCardName(adminManager.getCardName());
  259. }
  260. if(hotel!=null){
  261. //获取有效民宿配置
  262. if(hotel.getHconfig() != null && !"".equals(hotel.getHconfig())){
  263. hotel.setHconfig(hotelDictService.setConfig(hotel.getHconfig()));
  264. }
  265. hotel.setRoomNumber(houseService.getHouseSum(managerId));
  266. if (!"".equals(hotel.getHtype()) && hotel.getHtype() !=null) {
  267. hotel.sethTypeName(hotelDictService.getDictNameById(Integer.parseInt(hotel.getHtype())));
  268. }
  269. BeanUtils.copyProperties(hotel,hotelEto);
  270. hotelEto.setHotelTownshipName(adminManager.getHotelTownshipName());
  271. StringBuilder fileSqlx = new StringBuilder("");
  272. fileSqlx.append("and link_id = '").append(hotel.getManagerId()).append("'");
  273. fileSqlx.append(" and (`name` is null or `name` not like '%营业执照%') ");
  274. List<FileInfo> fileList = fileService.queryList(fileSqlx.toString());
  275. hotelEto.setFileInfoList(fileList);
  276. resultJson.put("message", "查询成功");
  277. resultJson.put("code", 200);
  278. resultJson.put("data", hotelEto);
  279. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  280. }else{
  281. hotelEto.setHstatus(1);
  282. hotelEto.setIsCanorder(1);
  283. hotelEto.setIsOrder(1);
  284. hotelEto.setIsCheckout(1);
  285. hotelEto.setLockTime("15");
  286. }
  287. if(adminManager == null && hotel == null){
  288. resultJson.put("message", "未查到数据请检查参数");
  289. resultJson.put("code", 500);
  290. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  291. return null;
  292. }
  293. hotelEto.setId(Math.toIntExact(UUIDUtil.generateID()));
  294. resultJson.put("message", "查询成功");
  295. resultJson.put("code", 200);
  296. resultJson.put("data", hotelEto);
  297. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  298. return null;
  299. }
  300. /**
  301. * 描述:新增民宿配置字典 code 1.民宿类型;2.民宿服务;3.房型名称;4.房型服务
  302. * @return
  303. */
  304. public String insterHotelDict(){
  305. JSONObject resultJson = new JSONObject();
  306. Gson gson = new Gson();
  307. com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
  308. if (json == null) {
  309. resultJson.put("message", "请传入参数");
  310. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  311. return null;
  312. }
  313. HotelDict hotelDict = new HotelDict();
  314. try{
  315. hotelDict = gson.fromJson(json.toString(), new TypeToken<HotelDict>() {}.getType());
  316. if(hotelDict==null){
  317. resultJson.put("message", "数据为空");
  318. resultJson.put("code", 500);
  319. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  320. return null;
  321. }
  322. if(hotelDict.getName()==null || hotelDict.getCode()==null){
  323. resultJson.put("message", "各参数不能为空");
  324. resultJson.put("code", 500);
  325. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  326. return null;
  327. }
  328. if(hotelDict.getCode()==4 && hotelDict.getFileUrl()==null){
  329. resultJson.put("message", "服务图标不能为空");
  330. resultJson.put("code", 500);
  331. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  332. return null;
  333. }
  334. StringBuilder getOneSqlx = new StringBuilder("");
  335. getOneSqlx.append(" and code = '").append(hotelDict.getCode()).append("'")
  336. .append(" and name = '").append(hotelDict.getName()).append("'");
  337. HotelDict listc = hotelDictService.getOen(getOneSqlx.toString());
  338. if(listc != null){
  339. resultJson.put("message", "已新增过相同名称的数据");
  340. resultJson.put("code", 500);
  341. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  342. return null;
  343. }
  344. int m = hotelDictService.insertHotelDict(hotelDict);
  345. if (m > 0) {
  346. resultJson.put("message", "添加成功");
  347. resultJson.put("code", 200);
  348. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  349. return null;
  350. } else {
  351. resultJson.put("message", "添加失败");
  352. resultJson.put("code", 502);
  353. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  354. return null;
  355. }
  356. }catch (Exception e){
  357. e.printStackTrace();
  358. resultJson.put("message", "未知异常:"+ e);
  359. resultJson.put("code", 205);
  360. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  361. }
  362. resultJson.put("message", "未知异常");
  363. resultJson.put("code", 205);
  364. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  365. return null;
  366. }
  367. /**
  368. * 描述:新增民宿配置字典 code 1.民宿类型;2.民宿服务;3.房型名称;4.房型服务
  369. * @return
  370. */
  371. public String updateHotelDict(){
  372. JSONObject resultJson = new JSONObject();
  373. Gson gson = new Gson();
  374. com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
  375. if (json == null) {
  376. resultJson.put("message", "请传入参数");
  377. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  378. return null;
  379. }
  380. HotelDict hotelDict = new HotelDict();
  381. try{
  382. hotelDict = gson.fromJson(json.toString(), new TypeToken<HotelDict>() {}.getType());
  383. if(hotelDict==null){
  384. resultJson.put("message", "数据为空");
  385. resultJson.put("code", 500);
  386. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  387. return null;
  388. }
  389. if(hotelDict.getId()==null){
  390. resultJson.put("message", "修改Id不能为空");
  391. resultJson.put("code", 500);
  392. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  393. return null;
  394. }
  395. if(hotelDict.getName()==null){
  396. resultJson.put("message", "各参数不能为空");
  397. resultJson.put("code", 500);
  398. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  399. return null;
  400. }
  401. if(hotelDict.getCode()==4 && hotelDict.getFileUrl()==null){
  402. resultJson.put("message", "服务图标不能为空");
  403. resultJson.put("code", 500);
  404. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  405. return null;
  406. }
  407. StringBuilder getOneSqlx = new StringBuilder("");
  408. getOneSqlx.append(" and code = '").append(hotelDict.getCode()).append("'")
  409. .append(" and name = '").append(hotelDict.getName()).append("'")
  410. .append(" and id != '").append(hotelDict.getId()).append("'");
  411. HotelDict listc = hotelDictService.getOen(getOneSqlx.toString());
  412. if(listc != null){
  413. resultJson.put("message", "已新增过相同名称的数据");
  414. resultJson.put("code", 500);
  415. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  416. return null;
  417. }
  418. int m = hotelDictService.updateHotelDict(hotelDict);
  419. if (m > 0) {
  420. resultJson.put("message", "修改成功");
  421. resultJson.put("code", 200);
  422. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  423. return null;
  424. } else {
  425. resultJson.put("message", "修改失败");
  426. resultJson.put("code", 502);
  427. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  428. return null;
  429. }
  430. }catch (Exception e){
  431. e.printStackTrace();
  432. resultJson.put("message", "未知异常:"+ e);
  433. resultJson.put("code", 205);
  434. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  435. }
  436. resultJson.put("message", "未知异常");
  437. resultJson.put("code", 205);
  438. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  439. return null;
  440. }
  441. /**
  442. * 描述:删除民宿配置字典
  443. * @return
  444. */
  445. public String delHotelDict(){
  446. JSONObject resultJson = new JSONObject();
  447. if (id == null) {
  448. resultJson.put("message", "请传入id");
  449. resultJson.put("code", 500);
  450. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  451. return null;
  452. }
  453. int m = hotelDictService.delHotelDict(id);
  454. if (m > 0) {
  455. resultJson.put("message", "删除成功");
  456. resultJson.put("code", 200);
  457. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  458. return null;
  459. }
  460. resultJson.put("message", "未知异常");
  461. resultJson.put("code", 205);
  462. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  463. return null;
  464. }
  465. /**
  466. * 描述:查询民宿配置列表
  467. * @return
  468. */
  469. public String queryList(){
  470. JSONObject resultJson = new JSONObject();
  471. StringBuilder s1 = new StringBuilder("");
  472. StringBuilder s2 = new StringBuilder("");
  473. StringBuilder s3 = new StringBuilder("");
  474. StringBuilder s4 = new StringBuilder("");
  475. if(code==null){//查询全部
  476. s1.append("and code = 1");
  477. List<HotelDict> list1 = hotelDictService.queryList(s1.toString());
  478. s2.append("and code = 2");
  479. List<HotelDict> list2 = hotelDictService.queryList(s2.toString());
  480. s3.append("and code = 3");
  481. List<HotelDict> list3 = hotelDictService.queryList(s3.toString());
  482. s4.append("and code = 4");
  483. List<HotelDict> list4 = hotelDictService.queryList(s4.toString());
  484. resultJson.put("message", "查询成功");
  485. resultJson.put("code", 200);
  486. resultJson.put("date1", list1);
  487. resultJson.put("date2", list2);
  488. resultJson.put("date3", list3);
  489. resultJson.put("date4", list4);
  490. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  491. return null;
  492. }else{
  493. s1.append("and code = ").append(code);
  494. List<HotelDict> list1 = hotelDictService.queryList(s1.toString());
  495. resultJson.put("message", "查询成功");
  496. resultJson.put("code", 200);
  497. resultJson.put("data", list1);
  498. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  499. return null;
  500. }
  501. }
  502. /**
  503. * 描述:查询所有民宿信息列表
  504. *
  505. */
  506. public String queryListhotel(){
  507. JSONObject resultJson = new JSONObject();
  508. List<Hotel> list = hotelService.queryList("");
  509. if (list != null){
  510. resultJson.put("message", "查询成功");
  511. resultJson.put("code", 200);
  512. resultJson.put("data", list);
  513. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  514. }else {
  515. resultJson.put("message", "数据为空!");
  516. resultJson.put("code", 205);
  517. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  518. }
  519. return null;
  520. }
  521. /**
  522. * 描述查询根据状态11的字典
  523. */
  524. public String queryTakeOrderDict(){
  525. JSONObject resultJson = new JSONObject();
  526. StringBuilder s1 = new StringBuilder("");
  527. s1.append("and code = 11");
  528. List<HotelDict> list1 = hotelDictService.queryList(s1.toString());
  529. List<Map<String,String>> data = new ArrayList<>();
  530. list1.forEach(hotelDict -> {
  531. switch (hotelDict.getId()){
  532. case 1111111111 : {
  533. Map<String,String> map = new HashMap<>();
  534. map.put("id", String.valueOf(hotelDict.getId()));
  535. map.put("code",hotelDict.getName());
  536. map.put("description","为多少分钟后接单");
  537. data.add(map);
  538. } break;
  539. case 1000011002 : {
  540. Map<String,String> map = new HashMap<>();
  541. map.put("id", String.valueOf(hotelDict.getId()));
  542. map.put("code",hotelDict.getName());
  543. map.put("description","1.接单 2.拒单");
  544. data.add(map);
  545. } break;
  546. case 1000011003 : {
  547. Map<String,String> map = new HashMap<>();
  548. map.put("id", String.valueOf(hotelDict.getId()));
  549. map.put("code",hotelDict.getName());
  550. map.put("description","可预定多少月内的");
  551. data.add(map);
  552. } break;
  553. }
  554. });
  555. if (data.size()>0){
  556. resultJson.put("message", "查询成功");
  557. resultJson.put("code", 200);
  558. resultJson.put("date", data);
  559. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  560. }else {
  561. resultJson.put("message", "数据为空!");
  562. resultJson.put("code", 205);
  563. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  564. }
  565. return null;
  566. }
  567. @SneakyThrows
  568. public void updateTakeOrderDict(){
  569. String postDataStr = GetHttpParam.getRequestPostData(request);
  570. com.alibaba.fastjson.JSONObject postDataJSONObject = com.alibaba.fastjson.JSONObject.parseObject(postDataStr);
  571. List<HotelDict> dicts = postDataJSONObject.getJSONArray("dicts").toJavaList(HotelDict.class);
  572. List<HotelDict> updateDict = new ArrayList<>();
  573. dicts.forEach(dict->{
  574. HotelDict hotelDict = new HotelDict();
  575. hotelDict.setId(dict.getId());
  576. hotelDict.setName(String.valueOf(dict.getCode()));
  577. updateDict.add(hotelDict);
  578. });
  579. int i = hotelDictService.saveBacth(updateDict);
  580. if (i > 0){
  581. ResUtil.writeJson(ServletActionContext.getResponse(), new com.alibaba.fastjson.JSONObject() {{
  582. put("message", "修改成功");
  583. put("code", 200);
  584. }}.toString());
  585. }
  586. }
  587. }