parent
73b7434ae6
commit
c96a584877
@ -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); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue