提交代码

dev-discount
胡锐 2 years ago
parent 73b7434ae6
commit c96a584877
  1. 140
      hai-order/src/main/java/com/web/controller/OrderRefundController.java
  2. 10
      hai-service/src/main/java/com/hai/order/model/ExportGasOrderModel.java
  3. 11
      hai-service/src/main/java/com/hai/order/service/OrderRefundService.java
  4. 37
      hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.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<String, Object> 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);
}
}
}

@ -17,9 +17,13 @@ import java.util.Date;
public class ExportGasOrderModel { public class ExportGasOrderModel {
@ColumnWidth(25) @ColumnWidth(25)
@ExcelProperty("交易单号") @ExcelProperty("交易单号")
private String orderNo; private String orderNo;
@ColumnWidth(15)
@ExcelProperty("客户电话")
private String memPhone;
@ColumnWidth(25) @ColumnWidth(25)
@ExcelProperty("加油站") @ExcelProperty("加油站")
private String storeName; private String storeName;
@ -28,10 +32,6 @@ public class ExportGasOrderModel {
@ExcelProperty("加油员") @ExcelProperty("加油员")
private String gasStaffName; private String gasStaffName;
@ColumnWidth(15)
@ExcelProperty("客户手机号")
private String memPhone;
@ColumnWidth(15) @ColumnWidth(15)
@ExcelProperty({ "加油信息", "加油金额"}) @ExcelProperty({ "加油信息", "加油金额"})
private BigDecimal gasRefuelPrice; private BigDecimal gasRefuelPrice;

@ -4,6 +4,9 @@ import com.hai.entity.HighChildOrder;
import com.hai.entity.HighOrder; import com.hai.entity.HighOrder;
import com.hai.entity.HighOrderRefund; import com.hai.entity.HighOrderRefund;
import java.util.List;
import java.util.Map;
/** /**
* 订单退款业务 * 订单退款业务
* @className: OrderRefundService * @className: OrderRefundService
@ -27,4 +30,12 @@ public interface OrderRefundService {
*/ */
HighOrderRefund createOrderChildRefund(HighChildOrder orderChild, String refundNo, Integer refundGoodsCount, String remarks) throws Exception; HighOrderRefund createOrderChildRefund(HighChildOrder orderChild, String refundNo, Integer refundGoodsCount, String remarks) throws Exception;
/**
* 获取退款订单列表
* @param param
* @return
*/
List<HighOrderRefund> getRefundOrderList(Map<String, Object> param);
} }

@ -7,6 +7,7 @@ import com.hai.dao.HighOrderRefundMapper;
import com.hai.entity.HighChildOrder; import com.hai.entity.HighChildOrder;
import com.hai.entity.HighOrder; import com.hai.entity.HighOrder;
import com.hai.entity.HighOrderRefund; import com.hai.entity.HighOrderRefund;
import com.hai.entity.HighOrderRefundExample;
import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderRefundService;
import com.hai.order.service.OrderService; import com.hai.order.service.OrderService;
import com.hai.order.type.OrderChildStatus; 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.type.OrderStatus;
import com.hai.order.utils.OrderUtil; import com.hai.order.utils.OrderUtil;
import com.hai.service.HighUserService; import com.hai.service.HighUserService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -110,6 +114,39 @@ public class OrderRefundServiceImpl implements OrderRefundService {
return orderRefund; return orderRefund;
} }
@Override
public List<HighOrderRefund> getRefundOrderList(Map<String, Object> 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 订单号 * @param orderNo 订单号

Loading…
Cancel
Save