hotelAction.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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. m = hotelService.updateHotel(hotel);
  155. if (i > 0 && m > 0){
  156. //将新修改的附件关联到流程id
  157. for(FileInfo file : fileList){
  158. file.setId(String.valueOf(UUID.randomUUID()));
  159. file.setLinkId(id);
  160. System.out.println(file.getLinkId());
  161. fileService.insertFile(file);
  162. }
  163. if(hotel.getId()!= null){
  164. fileService.delLinkFile2(String.valueOf(hotel.getManagerId()), " and (`name` is null or `name` not like '%营业执照%') ");
  165. }
  166. for(FileInfo file : fileList){
  167. FileInfo fileInfo = fileService.getById(file.getId());
  168. file.setLinkId(String.valueOf(hotel.getManagerId()));
  169. if(fileInfo==null){
  170. fileService.insertFile(file);
  171. }else{
  172. fileService.updateFile(file);
  173. }
  174. }
  175. hotel.setRemark(hotel1.getRemark());
  176. resultJson.put("message", "已成功提交审批!");
  177. resultJson.put("code", 200);
  178. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  179. return null;
  180. }else {
  181. resultJson.put("message", "提交审批失败!");
  182. resultJson.put("code", 502);
  183. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  184. return null;
  185. }
  186. }else{
  187. hotel.setId(hotelId);
  188. m = hotelService.updateHotel(hotel);
  189. }
  190. }else{
  191. resultJson.put("message", "未找到数据Id:"+hotelId);
  192. resultJson.put("code", 502);
  193. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  194. return null;
  195. }
  196. if (m > 0) {
  197. if(hotel.getId()!= null){
  198. fileService.delLinkFile2(String.valueOf(hotel.getManagerId()), " and (`name` is null or `name` not like '%营业执照%') ");
  199. }
  200. for(FileInfo file : fileList){
  201. FileInfo fileInfo = fileService.getById(file.getId());
  202. file.setLinkId(String.valueOf(hotel.getManagerId()));
  203. if(fileInfo==null){
  204. fileService.insertFile(file);
  205. }else{
  206. fileService.updateFile(file);
  207. }
  208. }
  209. resultJson.put("message", "维护成功");
  210. resultJson.put("code", 200);
  211. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  212. return null;
  213. } else {
  214. resultJson.put("message", "维护失败");
  215. resultJson.put("code", 502);
  216. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  217. return null;
  218. }
  219. } catch (Exception e){
  220. e.printStackTrace();
  221. }
  222. resultJson.put("message", "未知异常");
  223. resultJson.put("code", 205);
  224. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  225. return null;
  226. }
  227. /**
  228. * 描述:查看民宿详细
  229. * @return
  230. */
  231. public String getByHotelInfo(){
  232. JSONObject resultJson = new JSONObject();
  233. StringBuilder s1 = new StringBuilder("");
  234. if (managerId!=null){
  235. s1.append(" and manager_id = '").append(managerId).append("'");
  236. }else{
  237. resultJson.put("message", "请传入managerId");
  238. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  239. return null;
  240. }
  241. if(id!=null){
  242. s1.append(" and id = '").append(id).append("'");
  243. }
  244. //查询商户信息
  245. AdminManager adminManager = adminManagerService.getById(managerId);
  246. //查询民宿信息
  247. Hotel hotel = hotelService.getOen(s1.toString());
  248. HotelEto hotelEto = new HotelEto();
  249. if(adminManager!=null){
  250. hotelEto.setHotelName(adminManager.getHotelName());
  251. hotelEto.setHotelTownship(adminManager.getHotelTownship());
  252. hotelEto.setHotelTownshipName(adminManager.getHotelTownshipName());
  253. hotelEto.setCorpnName(adminManager.getCorpnName());
  254. hotelEto.setCorpnPhone(adminManager.getCorpnPhone());
  255. hotelEto.setManagerId(adminManager.getId());
  256. hotelEto.setBankCard(adminManager.getBankCard());
  257. hotelEto.setCardName(adminManager.getCardName());
  258. }
  259. if(hotel!=null){
  260. //获取有效民宿配置
  261. if(hotel.getHconfig() != null && !"".equals(hotel.getHconfig())){
  262. hotel.setHconfig(hotelDictService.setConfig(hotel.getHconfig()));
  263. }
  264. hotel.setRoomNumber(houseService.getHouseSum(managerId));
  265. if (!"".equals(hotel.getHtype()) && hotel.getHtype() !=null) {
  266. hotel.sethTypeName(hotelDictService.getDictNameById(Integer.parseInt(hotel.getHtype())));
  267. }
  268. BeanUtils.copyProperties(hotel,hotelEto);
  269. hotelEto.setHotelTownshipName(adminManager.getHotelTownshipName());
  270. StringBuilder fileSqlx = new StringBuilder("");
  271. fileSqlx.append("and link_id = '").append(hotel.getManagerId()).append("'");
  272. fileSqlx.append(" and (`name` is null or `name` not like '%营业执照%') ");
  273. List<FileInfo> fileList = fileService.queryList(fileSqlx.toString());
  274. hotelEto.setFileInfoList(fileList);
  275. resultJson.put("message", "查询成功");
  276. resultJson.put("code", 200);
  277. resultJson.put("data", hotelEto);
  278. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  279. }else{
  280. hotelEto.setHstatus(1);
  281. hotelEto.setIsCanorder(1);
  282. hotelEto.setIsOrder(1);
  283. hotelEto.setIsCheckout(1);
  284. hotelEto.setLockTime("15");
  285. }
  286. if(adminManager == null && hotel == null){
  287. resultJson.put("message", "未查到数据请检查参数");
  288. resultJson.put("code", 500);
  289. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  290. return null;
  291. }
  292. hotelEto.setId(Math.toIntExact(UUIDUtil.generateID()));
  293. resultJson.put("message", "查询成功");
  294. resultJson.put("code", 200);
  295. resultJson.put("data", hotelEto);
  296. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  297. return null;
  298. }
  299. /**
  300. * 描述:新增民宿配置字典 code 1.民宿类型;2.民宿服务;3.房型名称;4.房型服务
  301. * @return
  302. */
  303. public String insterHotelDict(){
  304. JSONObject resultJson = new JSONObject();
  305. Gson gson = new Gson();
  306. com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
  307. if (json == null) {
  308. resultJson.put("message", "请传入参数");
  309. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  310. return null;
  311. }
  312. HotelDict hotelDict = new HotelDict();
  313. try{
  314. hotelDict = gson.fromJson(json.toString(), new TypeToken<HotelDict>() {}.getType());
  315. if(hotelDict==null){
  316. resultJson.put("message", "数据为空");
  317. resultJson.put("code", 500);
  318. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  319. return null;
  320. }
  321. if(hotelDict.getName()==null || hotelDict.getCode()==null){
  322. resultJson.put("message", "各参数不能为空");
  323. resultJson.put("code", 500);
  324. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  325. return null;
  326. }
  327. if(hotelDict.getCode()==4 && hotelDict.getFileUrl()==null){
  328. resultJson.put("message", "服务图标不能为空");
  329. resultJson.put("code", 500);
  330. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  331. return null;
  332. }
  333. StringBuilder getOneSqlx = new StringBuilder("");
  334. getOneSqlx.append(" and code = '").append(hotelDict.getCode()).append("'")
  335. .append(" and name = '").append(hotelDict.getName()).append("'");
  336. HotelDict listc = hotelDictService.getOen(getOneSqlx.toString());
  337. if(listc != null){
  338. resultJson.put("message", "已新增过相同名称的数据");
  339. resultJson.put("code", 500);
  340. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  341. return null;
  342. }
  343. int m = hotelDictService.insertHotelDict(hotelDict);
  344. if (m > 0) {
  345. resultJson.put("message", "添加成功");
  346. resultJson.put("code", 200);
  347. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  348. return null;
  349. } else {
  350. resultJson.put("message", "添加失败");
  351. resultJson.put("code", 502);
  352. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  353. return null;
  354. }
  355. }catch (Exception e){
  356. e.printStackTrace();
  357. resultJson.put("message", "未知异常:"+ e);
  358. resultJson.put("code", 205);
  359. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  360. }
  361. resultJson.put("message", "未知异常");
  362. resultJson.put("code", 205);
  363. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  364. return null;
  365. }
  366. /**
  367. * 描述:新增民宿配置字典 code 1.民宿类型;2.民宿服务;3.房型名称;4.房型服务
  368. * @return
  369. */
  370. public String updateHotelDict(){
  371. JSONObject resultJson = new JSONObject();
  372. Gson gson = new Gson();
  373. com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
  374. if (json == null) {
  375. resultJson.put("message", "请传入参数");
  376. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  377. return null;
  378. }
  379. HotelDict hotelDict = new HotelDict();
  380. try{
  381. hotelDict = gson.fromJson(json.toString(), new TypeToken<HotelDict>() {}.getType());
  382. if(hotelDict==null){
  383. resultJson.put("message", "数据为空");
  384. resultJson.put("code", 500);
  385. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  386. return null;
  387. }
  388. if(hotelDict.getId()==null){
  389. resultJson.put("message", "修改Id不能为空");
  390. resultJson.put("code", 500);
  391. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  392. return null;
  393. }
  394. if(hotelDict.getName()==null){
  395. resultJson.put("message", "各参数不能为空");
  396. resultJson.put("code", 500);
  397. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  398. return null;
  399. }
  400. if(hotelDict.getCode()==4 && hotelDict.getFileUrl()==null){
  401. resultJson.put("message", "服务图标不能为空");
  402. resultJson.put("code", 500);
  403. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  404. return null;
  405. }
  406. StringBuilder getOneSqlx = new StringBuilder("");
  407. getOneSqlx.append(" and code = '").append(hotelDict.getCode()).append("'")
  408. .append(" and name = '").append(hotelDict.getName()).append("'")
  409. .append(" and id != '").append(hotelDict.getId()).append("'");
  410. HotelDict listc = hotelDictService.getOen(getOneSqlx.toString());
  411. if(listc != null){
  412. resultJson.put("message", "已新增过相同名称的数据");
  413. resultJson.put("code", 500);
  414. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  415. return null;
  416. }
  417. int m = hotelDictService.updateHotelDict(hotelDict);
  418. if (m > 0) {
  419. resultJson.put("message", "修改成功");
  420. resultJson.put("code", 200);
  421. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  422. return null;
  423. } else {
  424. resultJson.put("message", "修改失败");
  425. resultJson.put("code", 502);
  426. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  427. return null;
  428. }
  429. }catch (Exception e){
  430. e.printStackTrace();
  431. resultJson.put("message", "未知异常:"+ e);
  432. resultJson.put("code", 205);
  433. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  434. }
  435. resultJson.put("message", "未知异常");
  436. resultJson.put("code", 205);
  437. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  438. return null;
  439. }
  440. /**
  441. * 描述:删除民宿配置字典
  442. * @return
  443. */
  444. public String delHotelDict(){
  445. JSONObject resultJson = new JSONObject();
  446. if (id == null) {
  447. resultJson.put("message", "请传入id");
  448. resultJson.put("code", 500);
  449. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  450. return null;
  451. }
  452. int m = hotelDictService.delHotelDict(id);
  453. if (m > 0) {
  454. resultJson.put("message", "删除成功");
  455. resultJson.put("code", 200);
  456. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  457. return null;
  458. }
  459. resultJson.put("message", "未知异常");
  460. resultJson.put("code", 205);
  461. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  462. return null;
  463. }
  464. /**
  465. * 描述:查询民宿配置列表
  466. * @return
  467. */
  468. public String queryList(){
  469. JSONObject resultJson = new JSONObject();
  470. StringBuilder s1 = new StringBuilder("");
  471. StringBuilder s2 = new StringBuilder("");
  472. StringBuilder s3 = new StringBuilder("");
  473. StringBuilder s4 = new StringBuilder("");
  474. if(code==null){//查询全部
  475. s1.append("and code = 1");
  476. List<HotelDict> list1 = hotelDictService.queryList(s1.toString());
  477. s2.append("and code = 2");
  478. List<HotelDict> list2 = hotelDictService.queryList(s2.toString());
  479. s3.append("and code = 3");
  480. List<HotelDict> list3 = hotelDictService.queryList(s3.toString());
  481. s4.append("and code = 4");
  482. List<HotelDict> list4 = hotelDictService.queryList(s4.toString());
  483. resultJson.put("message", "查询成功");
  484. resultJson.put("code", 200);
  485. resultJson.put("date1", list1);
  486. resultJson.put("date2", list2);
  487. resultJson.put("date3", list3);
  488. resultJson.put("date4", list4);
  489. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  490. return null;
  491. }else{
  492. s1.append("and code = ").append(code);
  493. List<HotelDict> list1 = hotelDictService.queryList(s1.toString());
  494. resultJson.put("message", "查询成功");
  495. resultJson.put("code", 200);
  496. resultJson.put("data", list1);
  497. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  498. return null;
  499. }
  500. }
  501. /**
  502. * 描述:查询所有民宿信息列表
  503. *
  504. */
  505. public String queryListhotel(){
  506. JSONObject resultJson = new JSONObject();
  507. List<Hotel> list = hotelService.queryList("");
  508. if (list != null){
  509. resultJson.put("message", "查询成功");
  510. resultJson.put("code", 200);
  511. resultJson.put("data", list);
  512. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  513. }else {
  514. resultJson.put("message", "数据为空!");
  515. resultJson.put("code", 205);
  516. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  517. }
  518. return null;
  519. }
  520. /**
  521. * 描述查询根据状态11的字典
  522. */
  523. public String queryTakeOrderDict(){
  524. JSONObject resultJson = new JSONObject();
  525. StringBuilder s1 = new StringBuilder("");
  526. s1.append("and code = 11");
  527. List<HotelDict> list1 = hotelDictService.queryList(s1.toString());
  528. List<Map<String,String>> data = new ArrayList<>();
  529. list1.forEach(hotelDict -> {
  530. switch (hotelDict.getId()){
  531. case 1111111111 : {
  532. Map<String,String> map = new HashMap<>();
  533. map.put("id", String.valueOf(hotelDict.getId()));
  534. map.put("code",hotelDict.getName());
  535. map.put("description","为多少分钟后接单");
  536. data.add(map);
  537. } break;
  538. case 1000011002 : {
  539. Map<String,String> map = new HashMap<>();
  540. map.put("id", String.valueOf(hotelDict.getId()));
  541. map.put("code",hotelDict.getName());
  542. map.put("description","1.接单 2.拒单");
  543. data.add(map);
  544. } break;
  545. case 1000011003 : {
  546. Map<String,String> map = new HashMap<>();
  547. map.put("id", String.valueOf(hotelDict.getId()));
  548. map.put("code",hotelDict.getName());
  549. map.put("description","可预定多少月内的");
  550. data.add(map);
  551. } break;
  552. }
  553. });
  554. if (data.size()>0){
  555. resultJson.put("message", "查询成功");
  556. resultJson.put("code", 200);
  557. resultJson.put("date", data);
  558. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  559. }else {
  560. resultJson.put("message", "数据为空!");
  561. resultJson.put("code", 205);
  562. ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
  563. }
  564. return null;
  565. }
  566. @SneakyThrows
  567. public void updateTakeOrderDict(){
  568. String postDataStr = GetHttpParam.getRequestPostData(request);
  569. com.alibaba.fastjson.JSONObject postDataJSONObject = com.alibaba.fastjson.JSONObject.parseObject(postDataStr);
  570. List<HotelDict> dicts = postDataJSONObject.getJSONArray("dicts").toJavaList(HotelDict.class);
  571. List<HotelDict> updateDict = new ArrayList<>();
  572. dicts.forEach(dict->{
  573. HotelDict hotelDict = new HotelDict();
  574. hotelDict.setId(dict.getId());
  575. hotelDict.setName(String.valueOf(dict.getCode()));
  576. updateDict.add(hotelDict);
  577. });
  578. int i = hotelDictService.saveBacth(updateDict);
  579. if (i > 0){
  580. ResUtil.writeJson(ServletActionContext.getResponse(), new com.alibaba.fastjson.JSONObject() {{
  581. put("message", "修改成功");
  582. put("code", 200);
  583. }}.toString());
  584. }
  585. }
  586. }