售后问题修复

This commit is contained in:
taozi
2023-04-05 19:43:33 +08:00
parent 61382e277c
commit 631f584494
6 changed files with 64 additions and 26 deletions

View File

@ -58,7 +58,42 @@ public class StoreAfterSalesController {
@PreAuthorize("@el.check('admin','yxStoreAfterSales:edit')")
@PostMapping(value = "/salesCheck")
public ResponseEntity salesCheck(@RequestBody SalesCheckDto salesCheckDto) {
return new ResponseEntity<>(storeAfterSalesService.salesCheck(salesCheckDto.getSalesId(), salesCheckDto.getOrderCode(), salesCheckDto.getApprovalStatus(), salesCheckDto.getConsignee(), salesCheckDto.getPhoneNumber(), salesCheckDto.getAddress()), HttpStatus.OK);
Object salesCheck = storeAfterSalesService.salesCheck(salesCheckDto.getSalesId(), salesCheckDto.getOrderCode(),
salesCheckDto.getApprovalStatus(), salesCheckDto.getConsignee(), salesCheckDto.getPhoneNumber(),
salesCheckDto.getAddress());
StoreAfterSales storeAfterSales = storeAfterSalesService.makeMoney(salesCheckDto.getSalesId(), salesCheckDto.getOrderCode());
if (storeAfterSales.getServiceType() == 0) {
BigDecimal bigDecimal = new BigDecimal("100");
int payPrice = bigDecimal.multiply(storeAfterSales.getRefundAmount()).intValue();
YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(salesCheckDto.getOrderCode(), null);
if (PayTypeEnum.WEIXIN.getValue().equals(orderInfo.getPayType())) {
checkOrderInfo(orderInfo);
weixinPayService.refundOrder(salesCheckDto.getOrderCode(), payPrice);
// 回滚库存、退积分、退优惠券
storeOrderService.returnStock(salesCheckDto.getOrderCode());
} else {
storeOrderService.orderRefund(salesCheckDto.getOrderCode(), storeAfterSales.getRefundAmount(), 1);
}
}
return new ResponseEntity<>(salesCheck, HttpStatus.OK);
}
/**
* 判断订单信息
*
* @param orderInfo 订单信息
*/
private void checkOrderInfo(YxStoreOrderQueryVo orderInfo) {
if (ObjectUtil.isNull(orderInfo)) {
throw new YshopException("订单不存在");
}
YxUserQueryVo userQueryVo = userService.getYxUserById(orderInfo.getUid());
if (ObjectUtil.isNull(userQueryVo)) {
throw new YshopException("用户不存在");
}
if (OrderInfoEnum.REFUND_STATUS_2.getValue().equals(orderInfo.getRefundStatus())) {
throw new YshopException("订单已经退款了哦!");
}
}
/**
@ -74,17 +109,10 @@ public class StoreAfterSalesController {
int payPrice = bigDecimal.multiply(sales.getRefundAmount()).intValue();
YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(orderCode, null);
if (PayTypeEnum.WEIXIN.getValue().equals(orderInfo.getPayType())) {
if (ObjectUtil.isNull(orderInfo)) {
throw new YshopException("订单不存在");
}
YxUserQueryVo userQueryVo = userService.getYxUserById(orderInfo.getUid());
if (ObjectUtil.isNull(userQueryVo)) {
throw new YshopException("用户不存在");
}
if (OrderInfoEnum.REFUND_STATUS_2.getValue().equals(orderInfo.getRefundStatus())) {
throw new YshopException("订单已经退款了哦!");
}
checkOrderInfo(orderInfo);
weixinPayService.refundOrder(orderCode, payPrice);
// 回滚库存、退积分、退优惠券
storeOrderService.returnStock(sales.getOrderCode());
} else {
storeOrderService.orderRefund(orderCode, sales.getRefundAmount(), 1);
}