diff --git a/bweb/src/main/java/com/bweb/controller/BsGasOrderController.java b/bweb/src/main/java/com/bweb/controller/BsGasOrderController.java new file mode 100644 index 0000000..65538eb --- /dev/null +++ b/bweb/src/main/java/com/bweb/controller/BsGasOrderController.java @@ -0,0 +1,114 @@ +package com.bweb.controller; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsGasOrder; +import com.hfkj.entity.BsOrderSettle; +import com.hfkj.model.ResponseData; +import com.hfkj.model.SecUserSessionObject; +import com.hfkj.model.UserSessionObject; +import com.hfkj.service.gas.BsGasOrderService; +import com.hfkj.service.order.BsOrderService; +import com.hfkj.sysenum.SecUserObjectTypeEnum; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/gasOrder") +@Api(value = "加油订单业务") +public class BsGasOrderController { + private static Logger log = LoggerFactory.getLogger(BsGasOrderController.class); + @Resource + private UserCenter userCenter; + @Resource + private BsGasOrderService gasOrderService; + @Resource + private BsOrderService orderService; + + @RequestMapping(value="/queryUserOilOrder",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询用户加油订单") + public ResponseData queryUserOilOrder(@RequestParam(name = "merId", required = false) Long merId, + @RequestParam(name = "merName", required = false) String merName, + @RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "payTimeS", required = false) Long payTimeS, + @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "refundTimeS", required = false) Long refundTimeS, + @RequestParam(name = "refundTimeE", required = false) Long refundTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + SecUserSessionObject sessionObject = userCenter.getSessionModel(SecUserSessionObject.class); + Map param = new HashMap<>(); + param.put("orderNo", orderNo); + param.put("status", status); + param.put("createTimeS", createTimeS); + param.put("createTimeE", createTimeE); + param.put("payTimeS", payTimeS); + param.put("payTimeE", payTimeE); + param.put("refundTimeS", refundTimeS); + param.put("refundTimeE", refundTimeE); + + if (sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { + param.put("merId", merId); + param.put("merName", merName); + } else if (sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { + param.put("merId", sessionObject.getMerchant().getId()); + } else if (sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type3.getCode())) { + param.put("gasStaffId", sessionObject.getAccount().getObjectId()); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); + } + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(gasOrderService.getGasOrderList(param))); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/queryOilOrder",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询加油订单详情") + public ResponseData queryOilOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { + try { + // 查询加油订单 + BsGasOrder gasOrder = gasOrderService.getDetailByOrderNo(orderNo); + if (gasOrder == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的加油的订单"); + } + Map param = new HashMap<>(); + param.put("gasOrder", gasOrder); + param.put("tradeOrder", orderService.getOrder(gasOrder.getOrderNo())); + return ResponseMsgUtil.success(param); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + +}