CargoConsignAction.java 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. package com.fuzamei.web;
  2. import java.util.List;
  3. import java.util.Map;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.web.bind.annotation.RequestBody;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RequestMethod;
  8. import org.springframework.web.bind.annotation.RestController;
  9. import com.fuzamei.constant.HintMSG;
  10. import com.fuzamei.constant.Role;
  11. import com.fuzamei.constant.Status;
  12. import com.fuzamei.entity.Orders;
  13. import com.fuzamei.entity.Param;
  14. import com.fuzamei.entity.UserDetail;
  15. import com.fuzamei.service.CargoConsignService;
  16. import com.fuzamei.service.OrderService;
  17. import com.fuzamei.service.UserAuthoricationService;
  18. import com.fuzamei.util.JSONUtil;
  19. import com.fuzamei.util.PageDTO;
  20. import com.fuzamei.util.ReadConfUtil;
  21. import com.fuzamei.util.ValidationUtil;
  22. @RestController
  23. @RequestMapping(path="/cargoConsign")
  24. public class CargoConsignAction {
  25. @Autowired
  26. private CargoConsignService cargoConsignService;
  27. @Autowired
  28. private UserAuthoricationService userAuthoricationService;
  29. @Autowired
  30. private OrderService orderService;
  31. private static final Integer ROWNUM=Integer.parseInt(ReadConfUtil.getProperty("rowNum"));
  32. /**
  33. *
  34. * @Title: queryOrdersBySupplier
  35. * @Description: TODO(供应商查询订单信息)
  36. {
  37. "userId":"xx",
  38. "page":"1",
  39. "orderId":"",
  40. "boxNo":"",
  41. "statusId":"",
  42. "startTime":"",
  43. "endTime":""
  44. }
  45. * @param @return 设定文件
  46. * @return Map<String,Object> 返回类型
  47. * @author ylx
  48. * @date 2018年1月26日 上午11:35:13
  49. * @throws
  50. */
  51. @RequestMapping(value="/queryOrdersBySupplier",method=RequestMethod.POST)
  52. public Map<String, Object> queryOrdersBySupplier(@RequestBody Param param){
  53. try {
  54. userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(param.getUserId()), Role.SUPPLIER);
  55. int page = ValidationUtil.checkMinAndAssignInt(param.getPage(), 1);
  56. Long startTime=ValidationUtil.checkAndAssignDefaultLong(param.getStartTime(), 0L);
  57. Long endTime=ValidationUtil.checkAndAssignDefaultLong(param.getEndTime(), Long.MAX_VALUE);
  58. param.setStartTime(startTime);
  59. if(startTime<=endTime) param.setEndTime(endTime);
  60. else param.setEndTime(Long.MAX_VALUE);
  61. param.setStartPage((page - 1) * ROWNUM);
  62. param.setRowNum(ROWNUM);
  63. PageDTO pageDto = cargoConsignService.queryOrdersBySupplier(param);
  64. return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, pageDto);
  65. } catch (Exception e) {
  66. return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
  67. }
  68. }
  69. /**
  70. *
  71. * @Title: queryOrdersByCarrier
  72. * @Description: TODO(承运商查看订单信息)
  73. {
  74. "userId":"",
  75. "page":"1",
  76. "orderId":"",
  77. "boxNo":"",
  78. "statusId":"",
  79. "startTime":"",
  80. "endTime":""
  81. }
  82. * @param @return 设定文件
  83. * @return Map<String,Object> 返回类型
  84. * @author ylx
  85. * @date 2018年1月26日 下午1:03:33
  86. * @throws
  87. */
  88. @RequestMapping(value="/queryOrdersByCarrier",method=RequestMethod.POST)
  89. public Map<String, Object> queryOrdersByCarrier(@RequestBody Param param){
  90. try {
  91. userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(param.getUserId()), Role.CARRIER);
  92. int page = ValidationUtil.checkMinAndAssignInt(param.getPage(), 1);
  93. Long startTime=ValidationUtil.checkAndAssignDefaultLong(param.getStartTime(), 0L);
  94. Long endTime=ValidationUtil.checkAndAssignDefaultLong(param.getEndTime(), Long.MAX_VALUE);
  95. param.setStartTime(startTime);
  96. if(startTime<=endTime) param.setEndTime(endTime);
  97. else param.setEndTime(Long.MAX_VALUE);
  98. param.setStartPage((page - 1) * ROWNUM);
  99. param.setRowNum(ROWNUM);
  100. PageDTO pageDto = cargoConsignService.queryOrdersByCarrier(param);
  101. return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, pageDto);
  102. } catch (Exception e) {
  103. return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
  104. }
  105. }
  106. /**
  107. *
  108. * @Title: doCarry
  109. * @Description: TODO(承运商点击承运按钮后对订单表进行更新)
  110. {
  111. "userId":"",
  112. "orderId":"",
  113. "carNo":""
  114. }
  115. * @param @return 设定文件
  116. * @return Map<String,Object> 返回类型
  117. * @author ylx
  118. * @date 2018年1月26日 下午1:14:26
  119. * @throws
  120. */
  121. @RequestMapping(value="/doCarry",method=RequestMethod.POST)
  122. public Map<String, Object> doCarry(@RequestBody Param param){
  123. try {
  124. userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(param.getUserId()), Role.CARRIER);
  125. Orders order = orderService.queryFullOrderByOrderId(ValidationUtil.checkAndAssignInt(param.getOrderId()));
  126. if(order==null) throw new RuntimeException("订单不存在");
  127. if(!Status.UNDELIVER.equals(order.getStatusId())) throw new RuntimeException("非法操作");
  128. if(!param.getUserId().equals(order.getCarrierId())) throw new RuntimeException("无权操作");
  129. cargoConsignService.doCarry(param);
  130. return JSONUtil.getJsonMap(200, true, HintMSG.OPERATION_SUCCESS, null);
  131. } catch (Exception e) {
  132. return JSONUtil.getJsonMap(500, false, HintMSG.OPERATION_FAIL+":"+e.getMessage(), null);
  133. }
  134. }
  135. /**
  136. *
  137. * @Title: showAllCarriersUnderSupplier
  138. * @Description: TODO(当供应商点击发货时候,跳出的弹框中承运商下拉框中显示所有承运商)
  139. {
  140. "userId":"xxx"
  141. }
  142. * @param @return 设定文件
  143. * @return Map<String,Object> 返回类型
  144. * @author ylx
  145. * @date 2018年1月26日 下午12:03:48
  146. * @throws
  147. */
  148. @RequestMapping(value="/showAllCarriersUnderSupplier",method=RequestMethod.POST)
  149. public Map<String, Object> showAllCarriersUnderSupplier(@RequestBody Param param){
  150. try {
  151. userAuthoricationService.queryUserDetail(ValidationUtil.checkAndAssignInt(param.getUserId()), Role.SUPPLIER);
  152. param.setRoleName(Role.CARRIER);
  153. List<UserDetail> carrierList = userAuthoricationService.showAllCarriersUnderSupplier(param);
  154. return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, carrierList);
  155. } catch (Exception e) {
  156. return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
  157. }
  158. }
  159. /**
  160. *
  161. * @Title: orderTracking
  162. * @Description: TODO(供应商和承运商的订单查询)
  163. {
  164. "userId":"xxx",
  165. "orderId":""
  166. }
  167. * @param @return 设定文件
  168. * @return Map<String,Object> 返回类型
  169. * @author ylx
  170. * @date 2018年1月26日 下午1:47:45
  171. * @throws
  172. */
  173. @RequestMapping(value="/orderTracking",method=RequestMethod.POST)
  174. public Map<String, Object> orderTracking(@RequestBody Param param){
  175. try {
  176. userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(param.getUserId()),Role.CARRIER,Role.SUPPLIER);//检测当前操作用户权限
  177. Orders order = orderService.queryFullOrderByOrderId(ValidationUtil.checkAndAssignInt(param.getOrderId()));
  178. param.setOrder(order);
  179. Map<String, Object> map = cargoConsignService.orderTracking(param);
  180. return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, map);
  181. } catch (Exception e) {
  182. return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
  183. }
  184. }
  185. }