diff --git a/hai-order/src/main/java/com/web/controller/OrderController.java b/hai-order/src/main/java/com/web/controller/OrderController.java index 3a47d802..dbb7a0af 100644 --- a/hai-order/src/main/java/com/web/controller/OrderController.java +++ b/hai-order/src/main/java/com/web/controller/OrderController.java @@ -1,11 +1,15 @@ package com.web.controller; import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighChildOrder; +import com.hai.entity.HighUser; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderChildModel; @@ -13,6 +17,7 @@ import com.hai.order.model.CreateOrderModel; import com.hai.order.service.OrderPaySuccessService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderChildGoodsType; +import com.hai.order.type.OrderChildStatus; import com.hai.order.utils.OrderUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -25,6 +30,8 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; @Controller @RequestMapping(value = "") @@ -128,39 +135,54 @@ public class OrderController { } } - @RequestMapping(value="/refund",method = RequestMethod.POST) + @RequestMapping(value="/refundOrder",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "订单退款") - public ResponseData refund(@RequestBody JSONObject body) { + public ResponseData refundOrder(@RequestBody JSONObject body) { try { - if (body == null || StringUtils.isBlank(body.getString("childOrderNo"))) { + if (body == null || StringUtils.isBlank(body.getString("orderNo"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); } + orderService.refundOrder(body.getString("orderNo"), body.getString("remarks")); - return ResponseMsgUtil.success(null); + return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { - log.error("OrderController -> cancel() error!",e); + log.error("OrderController -> refundOrder() error!",e); return ResponseMsgUtil.exception(e); } } -/* - @RequestMapping(value="/paySuccess",method = RequestMethod.POST) + + @RequestMapping(value="/refundOrderChild",method = RequestMethod.POST) @ResponseBody - @ApiOperation(value = "支付成功") - public ResponseData paySuccess(@RequestBody JSONObject body) { + @ApiOperation(value = "子订单退款") + public ResponseData refundOrderChild(@RequestBody JSONObject body) { try { - if (body == null || StringUtils.isBlank(body.getString("orderNo"))) { + if (body == null + || StringUtils.isBlank(body.getString("childOrderNo")) + || body.getInteger("refundGoodsNum") == null + ) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); } - return ResponseMsgUtil.success(orderService.orderPaySuccessBus(orderService.getOrderDetailByNo(body.getString("orderNo")))); + // 查询订单编号 + HighChildOrder orderChild = orderService.getChildOrderByNo(body.getString("childOrderNo")); + if (orderChild == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单编号"); + } + if (orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS2.getNumber()) + || orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS3.getNumber())){ + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "子订单状态错误"); + } + orderService.refundChildOrder(orderChild.getOrderNo(), body.getString("childOrderNo"), body.getInteger("refundGoodsNum"), body.getString("remarks")); + + return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { - log.error("OrderController -> paySuccess() error!",e); + log.error("OrderController -> refundOrderChild() error!",e); return ResponseMsgUtil.exception(e); } - }*/ + } @RequestMapping(value="/getDetailByOrderNo",method = RequestMethod.GET) @ResponseBody @@ -176,4 +198,50 @@ public class OrderController { } } + @RequestMapping(value="/getUserOrderList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取用户订单列表") + public ResponseData getUserOrderList(@RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "productType", required = false) Integer productType, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + HighUserModel userModel = userCenter.getSessionModel(HighUserModel.class); + if (userModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.USE_VISIT_ILLEGAL, ""); + } + + Map param = new HashMap<>(); + param.put("orderNo", orderNo); + param.put("productType", productType); + param.put("status", status); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>()); + + } catch (Exception e) { + log.error("OrderController -> getUserOrderList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + +/* + @RequestMapping(value="/paySuccess",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "支付成功") + public ResponseData paySuccess(@RequestBody JSONObject body) { + try { + if (body == null || StringUtils.isBlank(body.getString("orderNo"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); + } + + return ResponseMsgUtil.success(orderService.orderPaySuccessBus(orderService.getOrderDetailByNo(body.getString("orderNo")))); + + } catch (Exception e) { + log.error("OrderController -> paySuccess() error!",e); + return ResponseMsgUtil.exception(e); + } + }*/ + } diff --git a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java index cdd08fb7..1f25c01e 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java @@ -10,7 +10,7 @@ import com.hai.order.model.CreateOrderChildModel; import java.util.List; /** - * 创建订单-业务校验 + * 创建订单-业务校验、组装数据 * @className: CreateOrderCheckService * @author: HuRui * @date: 2022/8/25 diff --git a/hai-service/src/main/java/com/hai/order/service/OrderService.java b/hai-service/src/main/java/com/hai/order/service/OrderService.java index c77e3cf1..de180b51 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderService.java @@ -74,6 +74,11 @@ public interface OrderService { */ HighChildOrder getChildOrderByNo(String childOrderNo); + /** + * 查询订单列表 + * @param param 参数 + * @return + */ List getOrderList(Map param); } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 360f7e89..fa00a2f1 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -261,6 +261,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { childOrder.setGasStaffId(gasStaff.getId()); childOrder.setGasStaffName(gasStaff.getName()); }*/ + } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 7f3f5c48..695d3c9e 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -21,6 +21,7 @@ import com.hai.service.HighDiscountAgentCodeService; import com.hai.service.HighDiscountUserRelService; import com.hai.service.HighUserPayPasswordService; import com.hai.service.HighUserService; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.integration.support.MessageBuilder; @@ -511,6 +512,22 @@ public class OrderServiceImpl implements OrderService { @Override public List getOrderList(Map param) { - return null; + HighOrderExample example = new HighOrderExample(); + HighOrderExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(param, "userId") != null) { + criteria.andMemIdEqualTo(MapUtils.getLong(param, "userId")); + } + + if (MapUtils.getInteger(param, "productType") != null) { + criteria.andProductTypeEqualTo(MapUtils.getInteger(param, "productType")); + } + + if (MapUtils.getInteger(param, "status") != null) { + criteria.andOrderStatusEqualTo(MapUtils.getInteger(param, "status")); + } + + example.setOrderByClause("createTime desc"); + return orderMapper.selectByExample(example); } }