From c96a5848777630be5f2225c6de6bddb8363f38c9 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Sun, 16 Oct 2022 14:09:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/OrderRefundController.java | 140 ++++++++++++++++++ .../hai/order/model/ExportGasOrderModel.java | 10 +- .../hai/order/service/OrderRefundService.java | 11 ++ .../service/impl/OrderRefundServiceImpl.java | 37 +++++ 4 files changed, 193 insertions(+), 5 deletions(-) create mode 100644 hai-order/src/main/java/com/web/controller/OrderRefundController.java diff --git a/hai-order/src/main/java/com/web/controller/OrderRefundController.java b/hai-order/src/main/java/com/web/controller/OrderRefundController.java new file mode 100644 index 00000000..62afead3 --- /dev/null +++ b/hai-order/src/main/java/com/web/controller/OrderRefundController.java @@ -0,0 +1,140 @@ +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.HighOrder; +import com.hai.model.HighUserModel; +import com.hai.model.ResponseData; +import com.hai.order.model.CreateOrderChildModel; +import com.hai.order.model.CreateOrderModel; +import com.hai.order.service.OrderPaySuccessService; +import com.hai.order.service.OrderRefundService; +import com.hai.order.service.OrderService; +import com.hai.order.type.OrderChildGoodsType; +import com.hai.order.type.OrderChildStatus; +import com.hai.order.type.OrderPayType; +import com.hai.order.utils.OrderUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "") +@Api(value = "订单退款业务") +public class OrderRefundController { + + private static Logger log = LoggerFactory.getLogger(OrderRefundController.class); + + @Resource + private OrderService orderService; + + @Resource + private OrderRefundService orderRefundService; + + @Resource + private UserCenter userCenter; + + @Autowired + private RocketMQTemplate rocketMQTemplate; + + @RequestMapping(value="/refund",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "交易订单退款") + public ResponseData refundOrder(@RequestBody JSONObject body) { + try { + 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("退款成功"); + + } catch (Exception e) { + log.error("OrderController -> refundOrder() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/refundChild",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "子订单退款") + public ResponseData refundOrderChild(@RequestBody JSONObject body) { + try { + if (body == null + || StringUtils.isBlank(body.getString("childOrderNo")) + || body.getInteger("refundGoodsNum") == null + ) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); + } + + // 查询订单编号 + 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 -> refundOrderChild() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value="/getRefundList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取退款列表") + public ResponseData getRefundList(@RequestParam(name = "title", required = false) String title, + @RequestParam(name = "searchTitle", required = false) String searchTitle, + @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("title", title); + param.put("searchTitle", searchTitle); + param.put("orderNo", orderNo); + param.put("productType", productType); + param.put("status", status); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderList(param))); + + } catch (Exception e) { + log.error("OrderController -> getUserOrderList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/hai-service/src/main/java/com/hai/order/model/ExportGasOrderModel.java b/hai-service/src/main/java/com/hai/order/model/ExportGasOrderModel.java index 64321e9b..d82215a9 100644 --- a/hai-service/src/main/java/com/hai/order/model/ExportGasOrderModel.java +++ b/hai-service/src/main/java/com/hai/order/model/ExportGasOrderModel.java @@ -17,9 +17,13 @@ import java.util.Date; public class ExportGasOrderModel { @ColumnWidth(25) - @ExcelProperty("交易订单号") + @ExcelProperty("交易单号") private String orderNo; + @ColumnWidth(15) + @ExcelProperty("客户电话") + private String memPhone; + @ColumnWidth(25) @ExcelProperty("加油站") private String storeName; @@ -28,10 +32,6 @@ public class ExportGasOrderModel { @ExcelProperty("加油员") private String gasStaffName; - @ColumnWidth(15) - @ExcelProperty("客户手机号") - private String memPhone; - @ColumnWidth(15) @ExcelProperty({ "加油信息", "加油金额"}) private BigDecimal gasRefuelPrice; diff --git a/hai-service/src/main/java/com/hai/order/service/OrderRefundService.java b/hai-service/src/main/java/com/hai/order/service/OrderRefundService.java index 100a43f4..443b7cc8 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderRefundService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderRefundService.java @@ -4,6 +4,9 @@ import com.hai.entity.HighChildOrder; import com.hai.entity.HighOrder; import com.hai.entity.HighOrderRefund; +import java.util.List; +import java.util.Map; + /** * 订单退款业务 * @className: OrderRefundService @@ -27,4 +30,12 @@ public interface OrderRefundService { */ HighOrderRefund createOrderChildRefund(HighChildOrder orderChild, String refundNo, Integer refundGoodsCount, String remarks) throws Exception; + /** + * 获取退款订单列表 + * @param param + * @return + */ + List getRefundOrderList(Map param); + + } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java index 238d0958..8f85928c 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java @@ -7,6 +7,7 @@ import com.hai.dao.HighOrderRefundMapper; import com.hai.entity.HighChildOrder; import com.hai.entity.HighOrder; import com.hai.entity.HighOrderRefund; +import com.hai.entity.HighOrderRefundExample; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderChildStatus; @@ -15,12 +16,15 @@ import com.hai.order.type.OrderRefundStatus; import com.hai.order.type.OrderStatus; import com.hai.order.utils.OrderUtil; import com.hai.service.HighUserService; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -110,6 +114,39 @@ public class OrderRefundServiceImpl implements OrderRefundService { return orderRefund; } + @Override + public List getRefundOrderList(Map param) { + HighOrderRefundExample example = new HighOrderRefundExample(); + HighOrderRefundExample.Criteria criteria = example.createCriteria(); + + if (StringUtils.isNotBlank(MapUtils.getString(param, "orderNo"))) { + criteria.andOrderNoLike("%"+MapUtils.getString(param, "orderNo")+"%"); + } + + if (StringUtils.isNotBlank(MapUtils.getString(param, "orderChildNo"))) { + criteria.andOrderChildNoEqualTo(MapUtils.getString(param, "orderChildNo")); + } + + if (StringUtils.isNotBlank(MapUtils.getString(param, "memPhone"))) { + criteria.andMemPhoneEqualTo(MapUtils.getString(param, "memPhone")); + } + + if (MapUtils.getInteger(param, "goodsType") != null) { + criteria.andGoodsTypeEqualTo(MapUtils.getInteger(param, "goodsType")); + } + + if (StringUtils.isNotBlank(MapUtils.getString(param, "goodsName"))) { + criteria.andGoodsNameLike("%"+MapUtils.getString(param, "goodsName")+"%"); + } + + if (StringUtils.isNotBlank(MapUtils.getString(param, "goodsName"))) { + criteria.andGoodsNameLike("%"+MapUtils.getString(param, "goodsName")+"%"); + } + + example.setOrderByClause("create_time desc"); + return orderRefundMapper.selectByExample(example); + } + /** * 金额退回用户 * @param orderNo 订单号