123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- package com.fuzamei.web;
- import java.util.List;
- import java.util.Map;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.fuzamei.constant.HintMSG;
- import com.fuzamei.constant.Role;
- import com.fuzamei.constant.Status;
- import com.fuzamei.entity.Orders;
- import com.fuzamei.entity.Param;
- import com.fuzamei.entity.UserDetail;
- import com.fuzamei.service.CargoConsignService;
- import com.fuzamei.service.OrderService;
- import com.fuzamei.service.UserAuthoricationService;
- import com.fuzamei.util.JSONUtil;
- import com.fuzamei.util.PageDTO;
- import com.fuzamei.util.ReadConfUtil;
- import com.fuzamei.util.ValidationUtil;
- @RestController
- @RequestMapping(path="/cargoConsign")
- public class CargoConsignAction {
- @Autowired
- private CargoConsignService cargoConsignService;
-
- @Autowired
- private UserAuthoricationService userAuthoricationService;
-
- @Autowired
- private OrderService orderService;
-
- private static final Integer ROWNUM=Integer.parseInt(ReadConfUtil.getProperty("rowNum"));
- /**
- *
- * @Title: queryOrdersBySupplier
- * @Description: TODO(供应商查询订单信息)
- {
- "userId":"xx",
- "page":"1",
- "orderId":"",
- "boxNo":"",
- "statusId":"",
- "startTime":"",
- "endTime":""
- }
- * @param @return 设定文件
- * @return Map<String,Object> 返回类型
- * @author ylx
- * @date 2018年1月26日 上午11:35:13
- * @throws
- */
- @RequestMapping(value="/queryOrdersBySupplier",method=RequestMethod.POST)
- public Map<String, Object> queryOrdersBySupplier(@RequestBody Param param){
- try {
- userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(param.getUserId()), Role.SUPPLIER);
- int page = ValidationUtil.checkMinAndAssignInt(param.getPage(), 1);
- Long startTime=ValidationUtil.checkAndAssignDefaultLong(param.getStartTime(), 0L);
- Long endTime=ValidationUtil.checkAndAssignDefaultLong(param.getEndTime(), Long.MAX_VALUE);
- param.setStartTime(startTime);
- if(startTime<=endTime) param.setEndTime(endTime);
- else param.setEndTime(Long.MAX_VALUE);
- param.setStartPage((page - 1) * ROWNUM);
- param.setRowNum(ROWNUM);
- PageDTO pageDto = cargoConsignService.queryOrdersBySupplier(param);
- return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, pageDto);
- } catch (Exception e) {
- return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
- }
- }
-
- /**
- *
- * @Title: queryOrdersByCarrier
- * @Description: TODO(承运商查看订单信息)
- {
- "userId":"",
- "page":"1",
- "orderId":"",
- "boxNo":"",
- "statusId":"",
- "startTime":"",
- "endTime":""
- }
- * @param @return 设定文件
- * @return Map<String,Object> 返回类型
- * @author ylx
- * @date 2018年1月26日 下午1:03:33
- * @throws
- */
- @RequestMapping(value="/queryOrdersByCarrier",method=RequestMethod.POST)
- public Map<String, Object> queryOrdersByCarrier(@RequestBody Param param){
- try {
- userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(param.getUserId()), Role.CARRIER);
- int page = ValidationUtil.checkMinAndAssignInt(param.getPage(), 1);
- Long startTime=ValidationUtil.checkAndAssignDefaultLong(param.getStartTime(), 0L);
- Long endTime=ValidationUtil.checkAndAssignDefaultLong(param.getEndTime(), Long.MAX_VALUE);
- param.setStartTime(startTime);
- if(startTime<=endTime) param.setEndTime(endTime);
- else param.setEndTime(Long.MAX_VALUE);
- param.setStartPage((page - 1) * ROWNUM);
- param.setRowNum(ROWNUM);
- PageDTO pageDto = cargoConsignService.queryOrdersByCarrier(param);
- return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, pageDto);
- } catch (Exception e) {
- return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
- }
- }
-
- /**
- *
- * @Title: doCarry
- * @Description: TODO(承运商点击承运按钮后对订单表进行更新)
- {
- "userId":"",
- "orderId":"",
- "carNo":""
- }
- * @param @return 设定文件
- * @return Map<String,Object> 返回类型
- * @author ylx
- * @date 2018年1月26日 下午1:14:26
- * @throws
- */
- @RequestMapping(value="/doCarry",method=RequestMethod.POST)
- public Map<String, Object> doCarry(@RequestBody Param param){
- try {
- userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(param.getUserId()), Role.CARRIER);
- Orders order = orderService.queryFullOrderByOrderId(ValidationUtil.checkAndAssignInt(param.getOrderId()));
- if(order==null) throw new RuntimeException("订单不存在");
- if(!Status.UNDELIVER.equals(order.getStatusId())) throw new RuntimeException("非法操作");
- if(!param.getUserId().equals(order.getCarrierId())) throw new RuntimeException("无权操作");
- cargoConsignService.doCarry(param);
- return JSONUtil.getJsonMap(200, true, HintMSG.OPERATION_SUCCESS, null);
- } catch (Exception e) {
- return JSONUtil.getJsonMap(500, false, HintMSG.OPERATION_FAIL+":"+e.getMessage(), null);
- }
- }
-
-
- /**
- *
- * @Title: showAllCarriersUnderSupplier
- * @Description: TODO(当供应商点击发货时候,跳出的弹框中承运商下拉框中显示所有承运商)
- {
- "userId":"xxx"
- }
- * @param @return 设定文件
- * @return Map<String,Object> 返回类型
- * @author ylx
- * @date 2018年1月26日 下午12:03:48
- * @throws
- */
- @RequestMapping(value="/showAllCarriersUnderSupplier",method=RequestMethod.POST)
- public Map<String, Object> showAllCarriersUnderSupplier(@RequestBody Param param){
- try {
- userAuthoricationService.queryUserDetail(ValidationUtil.checkAndAssignInt(param.getUserId()), Role.SUPPLIER);
- param.setRoleName(Role.CARRIER);
- List<UserDetail> carrierList = userAuthoricationService.showAllCarriersUnderSupplier(param);
- return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, carrierList);
- } catch (Exception e) {
- return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
- }
- }
-
-
- /**
- *
- * @Title: orderTracking
- * @Description: TODO(供应商和承运商的订单查询)
- {
- "userId":"xxx",
- "orderId":""
- }
- * @param @return 设定文件
- * @return Map<String,Object> 返回类型
- * @author ylx
- * @date 2018年1月26日 下午1:47:45
- * @throws
- */
- @RequestMapping(value="/orderTracking",method=RequestMethod.POST)
- public Map<String, Object> orderTracking(@RequestBody Param param){
- try {
- userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(param.getUserId()),Role.CARRIER,Role.SUPPLIER);//检测当前操作用户权限
- Orders order = orderService.queryFullOrderByOrderId(ValidationUtil.checkAndAssignInt(param.getOrderId()));
- param.setOrder(order);
- Map<String, Object> map = cargoConsignService.orderTracking(param);
- return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, map);
- } catch (Exception e) {
- return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
- }
- }
-
- }
|