提交代码

dev-discount
胡锐 2 years ago
parent f22e34bbf2
commit ed0fde9d99
  1. 72
      hai-order/src/main/java/com/web/controller/OrderController.java
  2. 2
      hai-order/src/main/java/com/web/controller/OrderRefundController.java
  3. 57
      hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java
  4. 23
      hai-service/src/main/java/com/hai/order/model/RefundPriceModel.java
  5. 9
      hai-service/src/main/java/com/hai/order/service/OrderRefundHandleService.java
  6. 26
      hai-service/src/main/java/com/hai/order/service/OrderRefundService.java
  7. 9
      hai-service/src/main/java/com/hai/order/service/impl/OrderRefundHandleServiceImpl.java
  8. 125
      hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java
  9. 41
      hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java
  10. 1
      hai-service/src/main/java/com/hai/order/topic/OrderTopic.java

@ -140,55 +140,6 @@ public class OrderController {
} }
} }
@RequestMapping(value="/refundOrder",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="/refundOrderChild",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="/getDetailByOrderNo",method = RequestMethod.GET) @RequestMapping(value="/getDetailByOrderNo",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据订单号查询详情") @ApiOperation(value = "根据订单号查询详情")
@ -236,29 +187,6 @@ public class OrderController {
} }
} }
@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, "未找到订单");
}
HighOrder order = orderService.getOrderDetailByNo(body.getString("orderNo"));
return ResponseMsgUtil.success(orderPaySuccessService.orderPaySuccessHandle(order.getOrderNo(),
OrderPayType.PAY_TYPE5,
"",
new BigDecimal("0"),
null));
} catch (Exception e) {
log.error("OrderController -> paySuccess() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/orderCheck", method = RequestMethod.GET) @RequestMapping(value = "/orderCheck", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据订单id查看订单") @ApiOperation(value = "根据订单id查看订单")

@ -85,7 +85,7 @@ public class OrderRefundController {
@RequestMapping(value="/refundChild",method = RequestMethod.POST) @RequestMapping(value="/refundChild",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "子订单退款") @ApiOperation(value = "子订单退款")
public ResponseData refundOrderChild(@RequestBody JSONObject body) { public ResponseData refundChild(@RequestBody JSONObject body) {
try { try {
if (body == null if (body == null
|| StringUtils.isBlank(body.getString("childOrderNo")) || StringUtils.isBlank(body.getString("childOrderNo"))

@ -0,0 +1,57 @@
package com.web.rocketmq.consumer;
import com.hai.entity.HighOrder;
import com.hai.entity.HighOrderRefund;
import com.hai.order.service.OrderRefundHandleService;
import com.hai.order.service.OrderRefundService;
import com.hai.order.service.OrderService;
import com.hai.order.type.OrderChildGoodsType;
import com.hai.order.type.OrderStatus;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
@Slf4j
@RocketMQMessageListener(consumerGroup = "order-refund-success-group", topic = "order-topic",selectorExpression = "refund-success")
public class OrderRefundSuccessConsumer implements RocketMQListener<HighOrderRefund> {
@Resource
private OrderService orderService;
@Resource
private OrderRefundService orderRefundService;
@Resource
private OrderRefundHandleService refundHandleService;
@Override
public void onMessage(HighOrderRefund orderRefund) {
if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE1.getNumber())) {
refundHandleService.couponHandle(orderRefund);
} else if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE2.getNumber())) {
} else if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE3.getNumber())) {
refundHandleService.oilHandle(orderRefund);
} else if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE4.getNumber())) {
} else if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE5.getNumber())) {
} else if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE6.getNumber())) {
} else if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE7.getNumber())) {
} else if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE8.getNumber())) {
} else if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE9.getNumber())) {
} else if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE10.getNumber())) {
}
}
}

@ -0,0 +1,23 @@
package com.hai.order.model;
import lombok.Data;
/**
* 退款模型
* @className: RefundPriceModel
* @author: HuRui
* @date: 2022/10/28
**/
@Data
public class RefundPriceModel {
// 退款成功
private Boolean refundSuccess;
// 退款订单号
private String refundOrderNo;
// 第三方退款订单号
private String thirdPartyRefundOrderNo;
}

@ -1,6 +1,7 @@
package com.hai.order.service; package com.hai.order.service;
import com.hai.entity.HighChildOrder; import com.hai.entity.HighChildOrder;
import com.hai.entity.HighOrderRefund;
/** /**
* 退款订单-业务处理 * 退款订单-业务处理
@ -12,16 +13,16 @@ public interface OrderRefundHandleService {
/** /**
* 卡券业务 * 卡券业务
* @param childOrder 子订单 * @param orderRefund
* @return * @return
* @throws Exception * @throws Exception
*/ */
void couponHandle(HighChildOrder childOrder) ; void couponHandle(HighOrderRefund orderRefund) ;
/** /**
* 加油业务 * 加油业务
* @param childOrder * @param orderRefund
*/ */
void oilHandle(HighChildOrder childOrder) ; void oilHandle(HighOrderRefund orderRefund) ;
} }

@ -3,7 +3,10 @@ package com.hai.order.service;
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.order.model.RefundPriceModel;
import com.hai.order.type.OrderPayType;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -15,20 +18,37 @@ import java.util.Map;
**/ **/
public interface OrderRefundService { public interface OrderRefundService {
/**
* 修改
* @param orderRefund
*/
void update(HighOrderRefund orderRefund);
/** /**
* 交易订单退款 * 交易订单退款
* @param order 交易订单 * @param order 交易订单
* @param remarks 退款备注 * @param remarks 退款备注
*/ */
HighOrder createOrderRefund(HighOrder order, String remarks) throws Exception; HighOrder createOrderRefund(String refundOrderNo,HighOrder order, String remarks) throws Exception;
/** /**
* 子订单退款 * 子订单退款
* @param orderChild 子订单 * @param orderChild 子订单
* @param refundOrderNo 退款单号
* @param refundGoodsCount 退款商品数量 * @param refundGoodsCount 退款商品数量
* @param remarks 退款备注 * @param remarks 退款备注
*/ */
HighOrderRefund createOrderChildRefund(HighChildOrder orderChild, String refundNo, Integer refundGoodsCount, String remarks) throws Exception; HighOrderRefund createOrderChildRefund(HighChildOrder orderChild, String refundOrderNo, Integer refundGoodsCount, String remarks) throws Exception;
/**
* 交易退钱
* @param order
* @param orderPayType
* @param refundPrice
* @param refundIntegral
* @return
*/
RefundPriceModel refundPrice(String refundOrderNo, HighOrder order, OrderPayType orderPayType, BigDecimal refundPrice, Integer refundIntegral) throws Exception;
/** /**
* 获取退款订单列表 * 获取退款订单列表
@ -42,7 +62,7 @@ public interface OrderRefundService {
* @param refundOrderNo * @param refundOrderNo
* @return * @return
*/ */
HighOrderRefund getRefundByRefundNo(String refundOrderNo); List<HighOrderRefund> getRefundByRefundNo(String refundOrderNo);
} }

@ -5,6 +5,7 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.entity.HighChildOrder; import com.hai.entity.HighChildOrder;
import com.hai.entity.HighGasOrder; import com.hai.entity.HighGasOrder;
import com.hai.entity.HighOrderRefund;
import com.hai.order.service.OrderRefundHandleService; import com.hai.order.service.OrderRefundHandleService;
import com.hai.order.type.OrderOilStatus; import com.hai.order.type.OrderOilStatus;
import com.hai.service.HighGasOrderService; import com.hai.service.HighGasOrderService;
@ -25,21 +26,21 @@ public class OrderRefundHandleServiceImpl implements OrderRefundHandleService {
private HighGasOrderService gasOrderService; private HighGasOrderService gasOrderService;
@Override @Override
public void couponHandle(HighChildOrder childOrder) { public void couponHandle(HighOrderRefund orderRefund) {
} }
@Override @Override
public void oilHandle(HighChildOrder childOrder) { public void oilHandle(HighOrderRefund orderRefund) {
// 查询加油订单 // 查询加油订单
HighGasOrder gasOrder = gasOrderService.getDetailByChildOrderNo(childOrder.getChildOrderNo()); HighGasOrder gasOrder = gasOrderService.getDetailByChildOrderNo(orderRefund.getOrderChildNo());
if (gasOrder == null) { if (gasOrder == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油订单"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油订单");
} }
if (!gasOrder.getStatus().equals(OrderOilStatus.STATUS2.getNumber())) { if (!gasOrder.getStatus().equals(OrderOilStatus.STATUS2.getNumber())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "加油订单不处于已支付状态"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "加油订单不处于已支付状态");
} }
gasOrder.setRefundTime(childOrder.getRefundTime()); gasOrder.setRefundTime(orderRefund.getRefundTime());
gasOrder.setStatus(OrderOilStatus.STATUS4.getNumber()); gasOrder.setStatus(OrderOilStatus.STATUS4.getNumber());
gasOrderService.updateGasOrder(gasOrder); gasOrderService.updateGasOrder(gasOrder);
} }

@ -1,13 +1,20 @@
package com.hai.order.service.impl; package com.hai.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.config.UnionPayConfig;
import com.hai.config.WxOrderConfig;
import com.hai.dao.HighOrderRefundMapper; 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.entity.HighOrderRefundExample;
import com.hai.model.OrderRefundModel;
import com.hai.order.model.RefundPriceModel;
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,6 +22,7 @@ import com.hai.order.type.OrderPayType;
import com.hai.order.type.OrderRefundStatus; 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.HighOilCardService;
import com.hai.service.HighUserService; import com.hai.service.HighUserService;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -22,6 +30,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -44,11 +53,19 @@ public class OrderRefundServiceImpl implements OrderRefundService {
@Resource @Resource
private OrderService orderService; private OrderService orderService;
@Resource
private HighUserService highUserService;
@Resource
private HighOilCardService oilCardService;
@Override @Override
public HighOrder createOrderRefund(HighOrder order, String remarks) throws Exception { public void update(HighOrderRefund orderRefund) {
// 退款订单号 orderRefundMapper.updateByPrimaryKey(orderRefund);
String refundOrderNo = OrderUtil.generateRefundOrderNo(); }
@Override
public HighOrder createOrderRefund(String refundOrderNo,HighOrder order, String remarks) throws Exception {
for (HighChildOrder orderChild : order.getHighChildOrderList()) { for (HighChildOrder orderChild : order.getHighChildOrderList()) {
// 创建退款记录 // 创建退款记录
HighOrderRefund orderRefund = createOrderChildRefund(orderChild, refundOrderNo, orderChild.getSaleCount(), remarks); HighOrderRefund orderRefund = createOrderChildRefund(orderChild, refundOrderNo, orderChild.getSaleCount(), remarks);
@ -63,7 +80,7 @@ public class OrderRefundServiceImpl implements OrderRefundService {
} }
@Override @Override
public HighOrderRefund createOrderChildRefund(HighChildOrder orderChild,String refundNo,Integer refundGoodsCount, String remarks) throws Exception { public HighOrderRefund createOrderChildRefund(HighChildOrder orderChild,String refundOrderNo,Integer refundGoodsCount, String remarks) throws Exception {
if (!orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS2.getNumber()) if (!orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS2.getNumber())
&& !orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS3.getNumber())){ && !orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS3.getNumber())){
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "子订单状态错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "子订单状态错误");
@ -92,7 +109,7 @@ public class OrderRefundServiceImpl implements OrderRefundService {
orderRefund.setOrderChildId(orderChild.getId()); orderRefund.setOrderChildId(orderChild.getId());
orderRefund.setOrderChildNo(orderChild.getChildOrderNo()); orderRefund.setOrderChildNo(orderChild.getChildOrderNo());
orderRefund.setMemId(orderChild.getMemId()); orderRefund.setMemId(orderChild.getMemId());
orderRefund.setMemName(orderChild.getMemPhone()); orderRefund.setMemName(orderChild.getMemName());
orderRefund.setMemPhone(orderChild.getMemPhone()); orderRefund.setMemPhone(orderChild.getMemPhone());
orderRefund.setGoodsType(orderChild.getGoodsType()); orderRefund.setGoodsType(orderChild.getGoodsType());
orderRefund.setGoodsId(orderChild.getGoodsId()); orderRefund.setGoodsId(orderChild.getGoodsId());
@ -101,7 +118,7 @@ public class OrderRefundServiceImpl implements OrderRefundService {
orderRefund.setGoodsImg(orderChild.getGoodsImg()); orderRefund.setGoodsImg(orderChild.getGoodsImg());
orderRefund.setGoodsSpecName(orderChild.getGoodsSpecName()); orderRefund.setGoodsSpecName(orderChild.getGoodsSpecName());
orderRefund.setGoodsCount(orderChild.getSaleCount()); orderRefund.setGoodsCount(orderChild.getSaleCount());
orderRefund.setRefundOrderNo(refundNo==null?OrderUtil.generateRefundOrderNo():refundNo); orderRefund.setRefundOrderNo(refundOrderNo==null?OrderUtil.generateRefundOrderNo():refundOrderNo);
orderRefund.setRefundGoodsNum(refundGoodsCount); orderRefund.setRefundGoodsNum(refundGoodsCount);
orderRefund.setReturnTotalPrice(refundPrice.add(new BigDecimal(refundIntegral).divide(new BigDecimal("100")))); orderRefund.setReturnTotalPrice(refundPrice.add(new BigDecimal(refundIntegral).divide(new BigDecimal("100"))));
orderRefund.setRefundPrice(refundPrice); orderRefund.setRefundPrice(refundPrice);
@ -114,6 +131,85 @@ public class OrderRefundServiceImpl implements OrderRefundService {
return orderRefund; return orderRefund;
} }
@Override
public RefundPriceModel refundPrice(String refundOrderNo, HighOrder order, OrderPayType orderPayType, BigDecimal refundPrice, Integer refundIntegral) {
RefundPriceModel refundPriceModel = new RefundPriceModel();
refundPriceModel.setRefundSuccess(false);
refundPriceModel.setRefundOrderNo(refundOrderNo);
try {
// 积分退款
if (refundIntegral != null && refundIntegral > 0) {
String remark = "订单" + order.getOrderNo() + "退款,退还积分:" + refundIntegral;
// 积分退款
highUserService.goldHandle(order.getMemId(), order.getPayGold(),1, 3, order.getId() , remark);
}
// 第三方退款
if (orderPayType.getNumber().equals(OrderPayType.PAY_TYPE2.getNumber())) {
// 微信退款
OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(),order.getPayRealPrice(), order.getAccountMerchantNum(), refundPrice);
if(orderRefundModel.getResult_code().equals("SUCCESS")) {
refundPriceModel.setRefundSuccess(true);
refundPriceModel.setThirdPartyRefundOrderNo(orderRefundModel.getRefund_id());
}
} else if (orderPayType.getNumber().equals(OrderPayType.PAY_TYPE4.getNumber())) {
JSONObject refund = HuiLianTongUnionCardConfig.refund(refundOrderNo, order.getPaySerialNo());
if (!refund.getString("respCode").equals("0000")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR,refund.getString("respMessage"));
}
JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(refund.getString("data"));
if (consumptionResult.getBoolean("success") != true) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "交易失败!"+consumptionResult.getString("message"));
}
refundPriceModel.setRefundSuccess(true);
refundPriceModel.setThirdPartyRefundOrderNo(consumptionResult.getString("orderId"));
} else if (orderPayType.getNumber().equals(OrderPayType.PAY_TYPE5.getNumber())) {
Calendar startTime = Calendar.getInstance();
startTime.set(Calendar.HOUR_OF_DAY, 00);
startTime.set(Calendar.MINUTE, 00);
startTime.set(Calendar.SECOND, 00);
Calendar endTime = Calendar.getInstance();
startTime.set(Calendar.HOUR_OF_DAY, 23);
startTime.set(Calendar.MINUTE, 59);
startTime.set(Calendar.SECOND, 59);
// 订单是否处于当日的订单
if (DateUtil.isEffectiveDate(order.getPayTime(), startTime.getTime(), endTime.getTime())) {
// 订单撤销
JSONObject refund = UnionPayConfig.cancel(UnionPayConfig.MER_ID3, UnionPayConfig.TERM_ID3, order.getOrderNo(), order.getPaySerialNo());
System.out.println(refund.toJSONString());
if (!refund.getString("resultcode").equals("00") || !refund.getString("resultcode").equals("W6")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg"));
}
refundPriceModel.setRefundSuccess(true);
} else {
// 订单退款
JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID3, UnionPayConfig.TERM_ID3, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue());
System.out.println(refund.toJSONString());
if (!refund.getString("resultcode").equals("00") || !refund.getString("resultcode").equals("W6")) {
JSONObject refund2 = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID1, UnionPayConfig.TERM_ID1, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue());
if (!refund2.getString("resultcode").equals("00") || !refund.getString("resultcode").equals("W6")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund2.getString("returnmsg"));
}
}
refundPriceModel.setRefundSuccess(true);
}
} else if (orderPayType.getNumber().equals(OrderPayType.PAY_TYPE7.getNumber())) {
// 油卡退款
oilCardService.refund(order.getOrderNo());
refundPriceModel.setRefundSuccess(true);
}
} catch (Exception e) {
refundPriceModel.setRefundSuccess(false);
}
return refundPriceModel;
}
@Override @Override
public List<HighOrderRefund> getRefundOrderList(Map<String, Object> param) { public List<HighOrderRefund> getRefundOrderList(Map<String, Object> param) {
HighOrderRefundExample example = new HighOrderRefundExample(); HighOrderRefundExample example = new HighOrderRefundExample();
@ -171,23 +267,10 @@ public class OrderRefundServiceImpl implements OrderRefundService {
} }
@Override @Override
public HighOrderRefund getRefundByRefundNo(String refundOrderNo) { public List<HighOrderRefund> getRefundByRefundNo(String refundOrderNo) {
HighOrderRefundExample example = new HighOrderRefundExample(); HighOrderRefundExample example = new HighOrderRefundExample();
example.createCriteria().andRefundOrderNoEqualTo(refundOrderNo); example.createCriteria().andRefundOrderNoEqualTo(refundOrderNo);
List<HighOrderRefund> list = orderRefundMapper.selectByExample(example); return orderRefundMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
} }
/**
* 金额退回用户
* @param orderNo 订单号
* @param refundPrice 退款金额
* @param refundIntegral 退款积分
*/
public void refundPrice(String orderNo,BigDecimal refundPrice,Integer refundIntegral) throws Exception {
}
} }

@ -15,6 +15,7 @@ import com.hai.enum_type.DiscountUseScope;
import com.hai.enum_type.OrderStatusEnum; import com.hai.enum_type.OrderStatusEnum;
import com.hai.order.model.CreateOrderChildModel; import com.hai.order.model.CreateOrderChildModel;
import com.hai.order.model.CreateOrderModel; import com.hai.order.model.CreateOrderModel;
import com.hai.order.model.RefundPriceModel;
import com.hai.order.service.*; import com.hai.order.service.*;
import com.hai.order.topic.OrderTopic; import com.hai.order.topic.OrderTopic;
import com.hai.order.type.*; import com.hai.order.type.*;
@ -511,18 +512,17 @@ public class OrderServiceImpl implements OrderService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单无法退款!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单无法退款!");
} }
// 退款订单号
String refundOrderNo = OrderUtil.generateRefundOrderNo();
// 创建退款 // 创建退款
order = orderRefundService.createOrderRefund(order, remarks); order = orderRefundService.createOrderRefund(refundOrderNo, order, remarks);
for (HighChildOrder childOrder : order.getHighChildOrderList()) { for (HighChildOrder childOrder : order.getHighChildOrderList()) {
if (childOrder.getGiveawayType() == false) { if (childOrder.getGiveawayType() == false) {
childOrder.setRefundRemarks(remarks); childOrder.setRefundRemarks(remarks);
childOrder.setRefundTime(new Date()); childOrder.setRefundTime(new Date());
childOrder.setChildOrderStatus(OrderChildStatus.STATUS4.getNumber()); childOrder.setChildOrderStatus(OrderChildStatus.STATUS4.getNumber());
if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE3.getNumber())) {
orderRefundHandleService.oilHandle(childOrder);
}
} }
} }
@ -532,8 +532,23 @@ public class OrderServiceImpl implements OrderService {
order.setOrderStatus(OrderStatus.STATUS4.getNumber()); order.setOrderStatus(OrderStatus.STATUS4.getNumber());
// todo 退款金额,原路返回 // todo 退款金额,原路返回
RefundPriceModel refundPrice = orderRefundService.refundPrice(refundOrderNo
, order
, OrderPayType.getDataByType(order.getPayType())
, order.getPayRealPrice()
, order.getPayGold());
if (refundPrice.getRefundSuccess() == true) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败,请稍后重试");
}
List<HighOrderRefund> refundList = orderRefundService.getRefundByRefundNo(refundOrderNo);
for (HighOrderRefund orderRefund : refundList) {
orderRefund.setRefundStatus(OrderRefundStatus.STATUS2.getNumber());
orderRefund.setRefundTime(new Date());
orderRefundService.update(orderRefund);
rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_REFUND_SUCCESS.getTopic(), orderRefund);
}
return updateOrderData(order); return updateOrderData(order);
} }
@ -565,6 +580,20 @@ public class OrderServiceImpl implements OrderService {
} }
// todo 退款金额,原路返回 // todo 退款金额,原路返回
RefundPriceModel refundPrice = orderRefundService.refundPrice(orderRefund.getRefundOrderNo()
, order
, OrderPayType.getDataByType(order.getPayType())
, orderRefund.getRefundPrice()
, orderRefund.getRefundIntegral());
if (!refundPrice.getRefundSuccess() == true) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败,请稍后重试");
}
childOrderMapper.updateByPrimaryKey(orderChild);
orderRefund.setRefundTime(new Date());
orderRefund.setRefundStatus(OrderRefundStatus.STATUS2.getNumber());
orderRefundService.update(orderRefund);
// 购买的订单列表 // 购买的订单列表
@ -591,6 +620,7 @@ public class OrderServiceImpl implements OrderService {
order.setRefundTime(new Date()); order.setRefundTime(new Date());
order.setOrderStatus(OrderStatus.STATUS4.getNumber()); order.setOrderStatus(OrderStatus.STATUS4.getNumber());
} }
rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_REFUND_SUCCESS.getTopic(), orderRefund);
return updateOrderData(order); return updateOrderData(order);
} }
@ -666,4 +696,5 @@ public class OrderServiceImpl implements OrderService {
orderMapper.updateByPrimaryKey(highOrder); orderMapper.updateByPrimaryKey(highOrder);
} }
} }
} }

@ -9,6 +9,7 @@ package com.hai.order.topic;
public enum OrderTopic { public enum OrderTopic {
ORDER_TOPIC("order-topic", "订单主题"), ORDER_TOPIC("order-topic", "订单主题"),
ORDER_TOPIC_CANCEL(ORDER_TOPIC.getTopic() + ":cancel", "订单取消"), ORDER_TOPIC_CANCEL(ORDER_TOPIC.getTopic() + ":cancel", "订单取消"),
ORDER_TOPIC_REFUND_SUCCESS(ORDER_TOPIC.getTopic() + ":refund-success", "订单退款成功业务"),
ORDER_TOPIC_PROFIT_SHARING(ORDER_TOPIC.getTopic() + ":profit-sharing", "订单分账业务"), ORDER_TOPIC_PROFIT_SHARING(ORDER_TOPIC.getTopic() + ":profit-sharing", "订单分账业务"),
; ;

Loading…
Cancel
Save