售后问题修复

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

@ -207,7 +207,7 @@ public class WechatController {
storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue());
storeOrder.setRefundPrice(refundFee);
orderService.updateById(storeOrder);
orderService.retrunStock(orderId);
orderService.returnStock(orderId);
//售后状态修改
LambdaQueryWrapper<StoreAfterSales> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StoreAfterSales::getOrderCode, orderId);

View File

@ -298,5 +298,10 @@ public interface YxStoreOrderService extends BaseService<YxStoreOrder>{
Map<String,Object> chartCount();
void retrunStock(String orderId);
/**
* 回滚库存、退积分、优惠券
*
* @param orderId 订单id
*/
void returnStock(String orderId);
}

View File

@ -690,7 +690,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
price.doubleValue(),
NumberUtil.add(price, userQueryVo.getNowMoney()).doubleValue(),
"订单退款到余额" + price + "", orderQueryVo.getId().toString());
this.retrunStock(orderQueryVo.getOrderId());
this.returnStock(orderQueryVo.getOrderId());
StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery()
.eq(StoreAfterSales::getUserId, orderQueryVo.getUid())
.eq(StoreAfterSales::getOrderCode, orderQueryVo.getOrderId()).one();
@ -707,7 +707,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
yxStoreOrderMapper.updateById(storeOrder);
orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.ORDER_EDIT.getValue(), "退款给用户:" + orderQueryVo.getPayIntegral() + "");
this.retrunStock(orderQueryVo.getOrderId());
this.returnStock(orderQueryVo.getOrderId());
}
orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(), "退款给用户:" + price + "");
@ -1380,7 +1380,10 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
wrapperSeven.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue())
.in(YxStoreOrder::getRefundStatus, Arrays.asList(strArr));
Long refundCount = yxStoreOrderMapper.selectCount(wrapperSeven);
//售后退款
Long salesCount = storeAfterSalesService.lambdaQuery()
.eq(Objects.nonNull(uid),StoreAfterSales::getUserId, uid)
.count();
return UserOrderCountVo.builder()
.orderCount(orderCount)
@ -1390,7 +1393,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
.receivedCount(receivedCount)
.evaluatedCount(evaluatedCount)
.completeCount(completeCount)
.refundCount(refundCount)
.refundCount(salesCount)
.build();
}
@ -2258,7 +2261,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
}
@Override
public void retrunStock(String orderId) {
public void returnStock(String orderId) {
YxStoreOrderQueryVo order = this.getOrderInfo(orderId, null);
this.regressionIntegral(order, 1);
this.regressionStock(order, 1);

View File

@ -237,21 +237,25 @@ public class StoreAfterSalesServiceImpl extends BaseServiceImpl<StoreAfterSalesM
@Override
public Boolean revoke(String key, Long uid, Long id) {
StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.<StoreAfterSales>lambdaQuery().eq(StoreAfterSales::getUserId, uid).eq(StoreAfterSales::getId, id).eq(StoreAfterSales::getOrderCode, key));
StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.<StoreAfterSales>lambdaQuery().
eq(StoreAfterSales::getUserId, uid).eq(StoreAfterSales::getId, id)
.eq(StoreAfterSales::getOrderCode, key));
if (storeAfterSales == null) {
throw new YshopException("未查询到售后订单信息");
}
if (storeAfterSales.getState().equals(AfterSalesStatusEnum.STATUS_2.getValue()) || storeAfterSales.getState().equals(AfterSalesStatusEnum.STATUS_3.getValue())) {
if (storeAfterSales.getState().equals(AfterSalesStatusEnum.STATUS_2.getValue())
|| storeAfterSales.getState().equals(AfterSalesStatusEnum.STATUS_3.getValue())) {
throw new YshopException("订单不能撤销");
}
storeAfterSales.setSalesState(1);
YxStoreOrder yxStoreOrder = storeOrderMapper.selectOne(Wrappers.<YxStoreOrder>lambdaQuery().eq(YxStoreOrder::getOrderId, key));
// yxStoreOrder.setStatus(OrderInfoEnum.STATUS_0.getValue());
yxStoreOrder.setStatus(OrderInfoEnum.STATUS_0.getValue());
yxStoreOrder.setRefundStatus(OrderInfoEnum.STATUS_0.getValue());
storeOrderMapper.updateById(yxStoreOrder);
List<YxStoreOrderCartInfo> yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.<YxStoreOrderCartInfo>lambdaQuery().eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId()));
List<YxStoreOrderCartInfo> yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.<YxStoreOrderCartInfo>lambdaQuery()
.eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId()));
for (YxStoreOrderCartInfo yxStoreOrderCartInfo : yxStoreOrderCartInfos) {
yxStoreOrderCartInfo.setIsAfterSales(1);
storeOrderCartInfoMapper.updateById(yxStoreOrderCartInfo);
@ -261,7 +265,7 @@ public class StoreAfterSalesServiceImpl extends BaseServiceImpl<StoreAfterSalesM
StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus();
storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId());
storeAfterSalesStatus.setChangeType(5);
storeAfterSalesStatus.setChangeMessage("售后订单生成");
storeAfterSalesStatus.setChangeMessage("售后订单撤回");
storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now()));
storeAfterSalesStatus.setOperator("用户操作");
storeAfterSalesStatusMapper.insert(storeAfterSalesStatus);
@ -310,8 +314,6 @@ public class StoreAfterSalesServiceImpl extends BaseServiceImpl<StoreAfterSalesM
storeAfterSales.setConsignee(consignee);
storeAfterSales.setPhoneNumber(phoneNumber);
storeAfterSales.setAddress(address);
} else {
this.makeMoney(storeAfterSales.getId(),storeAfterSales.getOrderCode());
}
//操作记录
StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus();

View File

@ -13,7 +13,7 @@
<properties>
<jjwt.version>0.10.6</jjwt.version>
<mybatis-plus-boot-starter.version>3.5.3</mybatis-plus-boot-starter.version>
<mybatis-plus-boot-starter.version>3.5.3.1</mybatis-plus-boot-starter.version>
</properties>
<dependencies>
<dependency>

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);
}