退款bugfix

This commit is contained in:
taozi
2023-04-09 22:01:11 +08:00
parent 265d2e567b
commit 0e70360afd
6 changed files with 40 additions and 25 deletions

View File

@ -164,7 +164,7 @@ public class ShoperController {
@PostMapping("/admin/order/refund")
@ApiOperation(value = "订单退款",notes = "订单退款")
public ApiResult<Boolean> orderRefund(@Validated @RequestBody OrderRefundParam param){
storeOrderService.orderRefund(param.getOrderId(),new BigDecimal(param.getPrice()),param.getType());
storeOrderService.orderRefund(param.getOrderId(),new BigDecimal(param.getPrice()),param.getType(), null);
return ApiResult.ok();
}

View File

@ -62,11 +62,13 @@ public interface YxStoreOrderService extends BaseService<YxStoreOrder>{
/**
* 确认订单退款
*
* @param orderId 单号
* @param price 金额
* @param type ShopCommonEnum
* @param price 金额
* @param type ShopCommonEnum
* @param salesId 售后id
*/
void orderRefund(String orderId, BigDecimal price, Integer type);
void orderRefund(String orderId, BigDecimal price, Integer type,Long salesId);
/**
* 订单发货

View File

@ -636,9 +636,10 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
* @param orderId 单号
* @param price 金额
* @param type ShopCommonEnum
* @param salesId 售后id
*/
@Override
public void orderRefund(String orderId, BigDecimal price, Integer type) {
public void orderRefund(String orderId, BigDecimal price, Integer type, Long salesId) {
YxStoreOrderQueryVo orderQueryVo = getOrderInfo(orderId, null);
if (ObjectUtil.isNull(orderQueryVo)) {
@ -664,14 +665,18 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
if (ShopCommonEnum.AGREE_2.getValue().equals(type)) {
storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue());
yxStoreOrderMapper.updateById(storeOrder);
StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery()
.eq(StoreAfterSales::getUserId, orderQueryVo.getUid())
.eq(StoreAfterSales::getOrderCode, orderQueryVo.getOrderId()).one();
if (ObjectUtil.isNotNull(storeAfterSales)) {
storeAfterSalesService.lambdaUpdate()
.eq(StoreAfterSales::getId, storeAfterSales.getId())
.set(StoreAfterSales::getSalesState, ShopCommonEnum.AGREE_2.getValue())
.update();
if (null != salesId) {
StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery()
.eq(StoreAfterSales::getUserId, orderQueryVo.getUid())
.eq(StoreAfterSales::getOrderCode, orderQueryVo.getOrderId())
.eq(StoreAfterSales::getId, salesId)
.one();
if (ObjectUtil.isNotNull(storeAfterSales)) {
storeAfterSalesService.lambdaUpdate()
.eq(StoreAfterSales::getId, storeAfterSales.getId())
.set(StoreAfterSales::getSalesState, ShopCommonEnum.AGREE_2.getValue())
.update();
}
}
return;
}
@ -691,14 +696,19 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
NumberUtil.add(price, userQueryVo.getNowMoney()).doubleValue(),
"订单退款到余额" + price + "", orderQueryVo.getId().toString());
this.returnStock(orderQueryVo.getOrderId());
StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery()
.eq(StoreAfterSales::getUserId, orderQueryVo.getUid())
.eq(StoreAfterSales::getOrderCode, orderQueryVo.getOrderId()).one();
if (ObjectUtil.isNotNull(storeAfterSales)) {
storeAfterSalesService.lambdaUpdate()
.eq(StoreAfterSales::getId, storeAfterSales.getId())
.set(StoreAfterSales::getState, AfterSalesStatusEnum.STATUS_3.getValue())
.update();
if (null != salesId) {
StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery()
.eq(StoreAfterSales::getUserId, orderQueryVo.getUid())
.eq(StoreAfterSales::getOrderCode, orderQueryVo.getOrderId())
.eq(StoreAfterSales::getId, salesId)
.one();
if (ObjectUtil.isNotNull(storeAfterSales)) {
storeAfterSalesService.lambdaUpdate()
.eq(StoreAfterSales::getId, storeAfterSales.getId())
.set(StoreAfterSales::getState, AfterSalesStatusEnum.STATUS_3.getValue())
.update();
}
}
} else if (PayTypeEnum.INTEGRAL.getValue().equals(orderQueryVo.getPayType())) {

View File

@ -258,7 +258,7 @@ public class StoreOrderController {
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity refund(@Validated @RequestBody YxStoreOrder resources) {
yxStoreOrderService.orderRefund(resources.getOrderId(),resources.getPayPrice(),
ShopCommonEnum.AGREE_1.getValue());
ShopCommonEnum.AGREE_1.getValue(), null);
return new ResponseEntity(HttpStatus.NO_CONTENT);
}

View File

@ -75,7 +75,7 @@ public class StoreAfterSalesController {
// 回滚库存、退积分、退优惠券
storeOrderService.returnStock(salesCheckDto.getOrderCode());
} else {
storeOrderService.orderRefund(salesCheckDto.getOrderCode(), storeAfterSales.getRefundAmount(), 1);
storeOrderService.orderRefund(salesCheckDto.getOrderCode(), storeAfterSales.getRefundAmount(), 1, storeAfterSales.getId());
}
}
return new ResponseEntity<>(salesCheck, HttpStatus.OK);
@ -117,7 +117,7 @@ public class StoreAfterSalesController {
// 回滚库存、退积分、退优惠券
storeOrderService.returnStock(sales.getOrderCode());
} else {
storeOrderService.orderRefund(orderCode, sales.getRefundAmount(), 1);
storeOrderService.orderRefund(orderCode, sales.getRefundAmount(), 1, salesId);
}
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@ -171,7 +171,10 @@ public class WeixinPayService {
if(orderInfo.getExtendOrderId()!=null){
orderId=orderInfo.getExtendOrderId();
}
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.toType(orderInfo.getPayType()));
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
if (StrUtil.isEmpty(wxPayService.getConfig().getAppId())) {
wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
}
WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
BigDecimal bigDecimal = new BigDecimal("100");
int totalFee = bigDecimal.multiply(orderInfo.getPayPrice()).intValue();