This commit is contained in:
parent
5a9abe6a2c
commit
ebd524e694
|
|
@ -22,7 +22,7 @@ public interface AccTradeMapper {
|
|||
*/
|
||||
public AccTrade selectAccTradeByTradeId(Long tradeId);
|
||||
|
||||
public AccTrade selectAccTradeByOrderNo(String orderNo);
|
||||
public List<AccTrade> selectAccTradeByOrderNo(String orderNo);
|
||||
|
||||
/**
|
||||
* 查询账户交易记录列表
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public interface IAccTradeService {
|
|||
*/
|
||||
public AccTrade selectAccTradeByTradeId(Long tradeId);
|
||||
|
||||
public AccTrade selectAccTradeByOrderNo(String orderNo);
|
||||
public List<AccTrade> selectAccTradeByOrderNo(String orderNo);
|
||||
|
||||
/**
|
||||
* 查询账户交易记录列表
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class AccTradeServiceImpl implements IAccTradeService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AccTrade selectAccTradeByOrderNo(String orderNo) {
|
||||
public List<AccTrade> selectAccTradeByOrderNo(String orderNo) {
|
||||
return accTradeMapper.selectAccTradeByOrderNo(orderNo);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package com.bonus.canteen.core.order.constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public enum OrderRefundStateEnum {
|
||||
FINISH(1, "已退单"),
|
||||
PART_SUCC(2, "部分退单");
|
||||
|
||||
private final Integer key;
|
||||
private final String desc;
|
||||
|
||||
private OrderRefundStateEnum(Integer key, String desc) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
* @date 2025-04-14
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/system/info")
|
||||
@RequestMapping("/order")
|
||||
public class OrderInfoController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
|
|
@ -69,6 +69,15 @@ public class OrderInfoController extends BaseController
|
|||
return toAjax(orderInfoService.insertOrderInfo(orderAddParam));
|
||||
}
|
||||
|
||||
@SysLog(title = "退单", module = "订单", businessType = OperaType.UPDATE)
|
||||
@PostMapping("/refund/{orderId}")
|
||||
@ResponseBody
|
||||
public AjaxResult refund(@PathVariable("orderId") Long orderId)
|
||||
{
|
||||
orderInfoService.refund(orderId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改订单
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -60,4 +60,6 @@ public interface IOrderInfoService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteOrderInfoByOrderId(Long orderId);
|
||||
|
||||
public void refund(Long orderId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.canteen.core.order.service.impl;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
|
|
@ -10,8 +11,11 @@ import com.bonus.canteen.core.account.constants.AccWalletIdEnum;
|
|||
import com.bonus.canteen.core.account.domain.AccWalletInfo;
|
||||
import com.bonus.canteen.core.account.domain.WalletUpdateDTO;
|
||||
import com.bonus.canteen.core.account.mq.AccMqSender;
|
||||
import com.bonus.canteen.core.account.service.IAccTradeService;
|
||||
import com.bonus.canteen.core.account.service.IAccWalletInfoService;
|
||||
import com.bonus.canteen.core.common.utils.RedisUtil;
|
||||
import com.bonus.canteen.core.order.constants.OrderRefundStateEnum;
|
||||
import com.bonus.canteen.core.order.constants.OrderStateEnum;
|
||||
import com.bonus.canteen.core.order.domain.OrderInfo;
|
||||
import com.bonus.canteen.core.order.domain.param.OrderAddParam;
|
||||
import com.bonus.canteen.core.order.mapper.OrderInfoMapper;
|
||||
|
|
@ -44,6 +48,8 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
|||
private OrderInfoMapper orderInfoMapper;
|
||||
@Autowired
|
||||
private IAccWalletInfoService accWalletInfoService;
|
||||
@Autowired
|
||||
private IAccTradeService accTradeService;
|
||||
|
||||
/**
|
||||
* 查询订单
|
||||
|
|
@ -188,4 +194,27 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
|||
{
|
||||
return orderInfoMapper.deleteOrderInfoByOrderId(orderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refund(Long orderId) {
|
||||
if(Objects.isNull(orderId) || orderId <= 0) {
|
||||
throw new ServiceException("订单ID不能为空");
|
||||
}
|
||||
OrderInfo orderInfo = selectOrderInfoByOrderId(orderId);
|
||||
if(Objects.isNull(orderInfo)) {
|
||||
throw new ServiceException("订单不存在");
|
||||
}
|
||||
if(!PayStateEnum.PAY_SUCC.getKey().equals(orderInfo.getPayState())) {
|
||||
throw new ServiceException("订单未支付");
|
||||
}
|
||||
if(orderInfo.getOrderRefundState().equals(OrderRefundStateEnum.FINISH.getKey())) {
|
||||
throw new ServiceException("订单已退款");
|
||||
}
|
||||
String refundKey = String.format("sc:order_refund_order_%s", orderId);
|
||||
if (!RedisUtil.setNx(refundKey, LeConstants.COMMON_YES, 2)) {
|
||||
log.info("订单退款处理中:{}", refundKey);
|
||||
throw new ServiceException("订单退款处理中");
|
||||
}
|
||||
accTradeService.selectAccTradeByOrderNo(String.valueOf(orderId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import java.io.PrintWriter;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
|
|
@ -75,7 +76,7 @@ public class NotifyCotroller {
|
|||
String third_trade_no = request.getParameter("trade_no");
|
||||
//交易状态
|
||||
String trade_status = request.getParameter("trade_status");
|
||||
AccTrade accTradeInDB = accTradeService.selectAccTradeByOrderNo(order_no);
|
||||
AccTrade accTradeInDB = accTradeService.selectAccTradeByOrderNo(order_no).get(0);
|
||||
if (AliPayTradeStatusEnum.TRADE_STATUS_FINISHED.getKey().equals(trade_status)) {
|
||||
//判断该笔订单是否已经做过处理
|
||||
//如果没做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详情,判断金额是否等于 total_amount,并执行商户的业务程序
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class PayController {
|
|||
updateTrade.setPayState(PayStateEnum.PAY_SUCC.getKey());
|
||||
updateTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey().longValue());
|
||||
updateTrade.setFailReason(trade_status);
|
||||
AccTrade accTradeInDB = accTradeService.selectAccTradeByOrderNo(accTradeVo.getOrderNo());
|
||||
AccTrade accTradeInDB = accTradeService.selectAccTradeByOrderNo(accTradeVo.getOrderNo()).get(0);
|
||||
if (PayStateEnum.PAY_INPROCESS.getKey().equals(accTradeInDB.getPayState())) {
|
||||
BigDecimal totalAmount = new BigDecimal(response.getTotalAmount());
|
||||
WalletUpdateDTO walletUpdateDTO = new WalletUpdateDTO();
|
||||
|
|
|
|||
Loading…
Reference in New Issue