|
|
@@ -79,14 +79,33 @@ public class AfterSaleOrderServiceImpl extends ServiceImpl<AfterSaleOrderMapper,
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void edit(AfterSaleOrderUpdateDTO dto) {
|
|
|
- AfterSaleOrder afterSaleOrder = this.afterSaleOrderMapper.selectById(dto.getAfterSaleOrderId());
|
|
|
+
|
|
|
+ // 1. 校验参数
|
|
|
+ Long id = dto.getAfterSaleOrderId();
|
|
|
+ if (ObjectUtil.isNull(id)) {
|
|
|
+ throw new IllegalArgumentException("售后单ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 获取“同意退货/换货”的售后单
|
|
|
+ LambdaQueryWrapper<AfterSaleOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AfterSaleOrder::getId, id)
|
|
|
+ .eq(AfterSaleOrder::getAfterSaleStatus, AfterSaleStatusEnum.AGREE_RETURN.getCode());
|
|
|
+
|
|
|
+ AfterSaleOrder afterSaleOrder = this.afterSaleOrderMapper.selectOne(queryWrapper);
|
|
|
if (ObjectUtil.isNull(afterSaleOrder)) {
|
|
|
- throw new ServiceException("售后订单不存在");
|
|
|
+ throw new ServiceException("同意退货/换货的售后单不存在");
|
|
|
}
|
|
|
|
|
|
- afterSaleOrder.setLogisticsNo(dto.getLogisticsNo());
|
|
|
- afterSaleOrder.setUpdateTime(LocalDateTime.now());
|
|
|
- this.afterSaleOrderMapper.updateById(afterSaleOrder);
|
|
|
+ AfterSaleOrder updateInfo = new AfterSaleOrder();
|
|
|
+ updateInfo.setId(id);
|
|
|
+ updateInfo.setLogisticsNo(dto.getLogisticsNo());
|
|
|
+ updateInfo.setUpdateTime(LocalDateTime.now());
|
|
|
+ updateInfo.setAfterSaleStatus(AfterSaleStatusEnum.WAITING_USER_RETURN.getCode());
|
|
|
+
|
|
|
+ boolean updateResult = this.updateById(updateInfo);
|
|
|
+ if (!updateResult) {
|
|
|
+ throw new ServiceException("取消售后单填写物流单号失败");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -118,8 +137,8 @@ public class AfterSaleOrderServiceImpl extends ServiceImpl<AfterSaleOrderMapper,
|
|
|
// 更新售后订单状态为已取消
|
|
|
afterSaleOrder.setAfterSaleStatus(AfterSaleStatusEnum.CANCELLED.getCode());
|
|
|
afterSaleOrder.setUpdateTime(LocalDateTime.now());
|
|
|
- boolean afterSaleUpdateResult = this.updateById(afterSaleOrder);
|
|
|
- if (!afterSaleUpdateResult ) {
|
|
|
+ boolean afterSaleUpdateResult = this.updateById(afterSaleOrder);
|
|
|
+ if (!afterSaleUpdateResult) {
|
|
|
throw new ServiceException("取消售后订单失败");
|
|
|
}
|
|
|
|
|
|
@@ -129,12 +148,52 @@ public class AfterSaleOrderServiceImpl extends ServiceImpl<AfterSaleOrderMapper,
|
|
|
updateInfo.setOrderStatus(ProductOrderStatusEnum.WAIT_RECEIVE.getCode());
|
|
|
updateInfo.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
|
- boolean orderUpdateResult = this.productOrderInfoService.updateById(updateInfo);
|
|
|
- if (!orderUpdateResult ) {
|
|
|
+ boolean orderUpdateResult = this.productOrderInfoService.updateById(updateInfo);
|
|
|
+ if (!orderUpdateResult) {
|
|
|
throw new ServiceException("订单状态已变更,请刷新后重试");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void editByWechat(AfterSaleOrderUpdateDTO dto) {
|
|
|
+
|
|
|
+ Long orderId = dto.getOrderId();
|
|
|
+
|
|
|
+ if (ObjectUtil.isNull(orderId)) {
|
|
|
+ throw new IllegalArgumentException("订单ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1. 获取当前登录用户(公共方法提取)
|
|
|
+ WxLoginUser loginUser = getCurrentWxLoginUser();
|
|
|
+
|
|
|
+ // 2. 查询并校验订单(公共方法提取)
|
|
|
+ this.productOrderInfoService.getAndCheckOrder(orderId, loginUser.getCOpenid());
|
|
|
+
|
|
|
+ // 3. 获取“同意退货/换货”的售后单
|
|
|
+ LambdaQueryWrapper<AfterSaleOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AfterSaleOrder::getOrderId, orderId)
|
|
|
+ .eq(AfterSaleOrder::getOpenId, loginUser.getCOpenid())
|
|
|
+ .eq(AfterSaleOrder::getAfterSaleStatus, AfterSaleStatusEnum.AGREE_RETURN.getCode());
|
|
|
+
|
|
|
+ AfterSaleOrder afterSaleOrder = this.afterSaleOrderMapper.selectOne(queryWrapper);
|
|
|
+ if (ObjectUtil.isNull(afterSaleOrder)) {
|
|
|
+ throw new ServiceException("同意退货/换货的售后单不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. 更新售后单信息
|
|
|
+ AfterSaleOrder updateInfo = new AfterSaleOrder();
|
|
|
+ updateInfo.setId(afterSaleOrder.getId());
|
|
|
+ updateInfo.setLogisticsNo(dto.getLogisticsNo());
|
|
|
+ updateInfo.setUpdateTime(LocalDateTime.now());
|
|
|
+ updateInfo.setAfterSaleStatus(AfterSaleStatusEnum.WAITING_USER_RETURN.getCode());
|
|
|
+
|
|
|
+ boolean updateResult = this.updateById(updateInfo);
|
|
|
+ if (!updateResult) {
|
|
|
+ throw new ServiceException("取消售后单填写物流单号失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private WxLoginUser getCurrentWxLoginUser() {
|
|
|
WxLoginUser loginUser = SecurityUtils.getWxLoginUser();
|
|
|
if (ObjectUtil.isNull(loginUser)) {
|