parent
d3c02f2a57
commit
5dd6e5bee8
|
@ -30,7 +30,7 @@ public class AppDecorateController {
|
|||
@Resource
|
||||
private DecorateComponentService decorateComponentService;
|
||||
|
||||
@GetMapping("/get-component-list")
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获取指定页面的组件列表")
|
||||
@Parameter(name = "page", description = "页面编号", required = true)
|
||||
public CommonResult<List<AppDecorateComponentRespVO>> getDecorateComponentListByPage(
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
package cn.iocoder.yudao.module.promotion.service.decorate;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum.ROLLING_NEWS;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum.INDEX;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
|
||||
// TODO @芋艿:后续 review 下
|
||||
/**
|
||||
|
@ -33,14 +23,14 @@ public class DecorateComponentServiceImplTest extends BaseMockitoUnitTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testResp(){
|
||||
List<DecorateComponentDO> list = new ArrayList<>(1);
|
||||
DecorateComponentDO decorateDO = new DecorateComponentDO()
|
||||
.setPage(INDEX.getPage()).setValue("")
|
||||
.setCode(ROLLING_NEWS.getCode()).setId(1L);
|
||||
list.add(decorateDO);
|
||||
//mock 方法
|
||||
Mockito.when(decorateComponentMapper.selectListByPageAndStatus(eq(1))).thenReturn(list);
|
||||
}
|
||||
// @Test
|
||||
// void testResp(){
|
||||
// List<DecorateComponentDO> list = new ArrayList<>(1);
|
||||
// DecorateComponentDO decorateDO = new DecorateComponentDO()
|
||||
// .setPage(INDEX.getPage()).setValue("")
|
||||
// .setCode(ROLLING_NEWS.getCode()).setId(1L);
|
||||
// list.add(decorateDO);
|
||||
// //mock 方法
|
||||
// Mockito.when(decorateComponentMapper.selectListByPageAndStatus(eq(1))).thenReturn(list);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSa
|
|||
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSalePageItemRespVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO;
|
||||
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
|
||||
import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum;
|
||||
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog;
|
||||
import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -19,6 +20,8 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
@ -78,6 +81,17 @@ public class AppTradeAfterSaleController {
|
|||
// return success(afterSaleService.getAfterSalePage(getLoginUserId()));
|
||||
}
|
||||
|
||||
// TODO 芋艿:待实现
|
||||
@GetMapping(value = "/get-reason-list")
|
||||
@Operation(summary = "获得售后原因")
|
||||
@Parameter(name = "way", description = "售后类型", required = true, example = "10")
|
||||
public CommonResult<List<String>> getAfterSaleReasonList(@RequestParam("way") Integer way) {
|
||||
if (Objects.equals(TradeAfterSaleWayEnum.REFUND.getWay(), way)) {
|
||||
return success(Arrays.asList("不想要了", "商品质量问题", "商品描述不符"));
|
||||
}
|
||||
return success(Arrays.asList("不想要了", "商品质量问题", "商品描述不符", "商品错发漏发", "商品包装破损"));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/create")
|
||||
@Operation(summary = "申请售后")
|
||||
@AfterSaleLog(id = "#info.data", content = "'申请售后:售后编号['+#info.data+'],订单编号['+#createReqVO.orderItemId+'], '", operateType = AfterSaleOperateTypeEnum.APPLY)
|
||||
|
|
|
@ -43,6 +43,9 @@ public class AppTradeOrderItemRespVO {
|
|||
@Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "应付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
||||
private Integer payPrice;
|
||||
|
||||
// ========== 营销基本信息 ==========
|
||||
|
||||
// TODO 芋艿:在捉摸一下
|
||||
|
|
|
@ -145,12 +145,17 @@ public class TradeOrderItemDO extends BaseDO {
|
|||
private Integer pointPrice;
|
||||
|
||||
// ========== 售后基本信息 ==========
|
||||
|
||||
/**
|
||||
* 售后单编号
|
||||
*
|
||||
* 关联 {@link TradeAfterSaleDO#getId()} 字段
|
||||
*/
|
||||
private Long afterSaleId;
|
||||
/**
|
||||
* 售后状态
|
||||
*
|
||||
* 枚举 {@link TradeOrderItemAfterSaleStatusEnum}
|
||||
*
|
||||
* @see TradeAfterSaleDO
|
||||
*/
|
||||
private Integer afterSaleStatus;
|
||||
|
||||
|
|
|
@ -12,8 +12,9 @@ import java.util.List;
|
|||
@Mapper
|
||||
public interface TradeOrderItemMapper extends BaseMapperX<TradeOrderItemDO> {
|
||||
|
||||
default int updateAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus) {
|
||||
return update(new TradeOrderItemDO().setAfterSaleStatus(newAfterSaleStatus),
|
||||
default int updateAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus,
|
||||
Long afterSaleId) {
|
||||
return update(new TradeOrderItemDO().setAfterSaleStatus(newAfterSaleStatus).setAfterSaleId(afterSaleId),
|
||||
new LambdaUpdateWrapper<>(new TradeOrderItemDO().setId(id).setAfterSaleStatus(oldAfterSaleStatus)));
|
||||
}
|
||||
|
||||
|
|
|
@ -148,8 +148,8 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
|||
|
||||
// 更新交易订单项的售后状态
|
||||
tradeOrderUpdateService.updateOrderItemAfterSaleStatus(orderItem.getId(),
|
||||
TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(),
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), null);
|
||||
TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(),
|
||||
afterSale.getId(), null);
|
||||
|
||||
// 记录售后日志
|
||||
createAfterSaleLog(orderItem.getUserId(), UserTypeEnum.MEMBER.getValue(),
|
||||
|
@ -200,8 +200,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
|||
|
||||
// 更新交易订单项的售后状态为【未申请】
|
||||
tradeOrderUpdateService.updateOrderItemAfterSaleStatus(afterSale.getOrderItemId(),
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(),
|
||||
TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null);
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -295,8 +294,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
|||
|
||||
// 更新交易订单项的售后状态为【未申请】
|
||||
tradeOrderUpdateService.updateOrderItemAfterSaleStatus(afterSale.getOrderItemId(),
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(),
|
||||
TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null);
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -343,8 +341,8 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
|||
|
||||
// 更新交易订单项的售后状态为【已完成】
|
||||
tradeOrderUpdateService.updateOrderItemAfterSaleStatus(afterSale.getOrderItemId(),
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(),
|
||||
TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus(), afterSale.getRefundPrice());
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus(),
|
||||
null, afterSale.getRefundPrice());
|
||||
}
|
||||
|
||||
private void createPayRefund(String userIp, TradeAfterSaleDO afterSale) {
|
||||
|
@ -385,8 +383,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
|||
|
||||
// 更新交易订单项的售后状态为【未申请】
|
||||
tradeOrderUpdateService.updateOrderItemAfterSaleStatus(afterSale.getOrderItemId(),
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(),
|
||||
TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null);
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
|
|
@ -68,10 +68,22 @@ public interface TradeOrderUpdateService {
|
|||
* @param id 交易订单项编号
|
||||
* @param oldAfterSaleStatus 当前售后状态;如果不符,更新后会抛出异常
|
||||
* @param newAfterSaleStatus 目标售后状态
|
||||
*/
|
||||
default void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus) {
|
||||
updateOrderItemAfterSaleStatus(id, oldAfterSaleStatus, newAfterSaleStatus, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新交易订单项的售后状态
|
||||
*
|
||||
* @param id 交易订单项编号
|
||||
* @param oldAfterSaleStatus 当前售后状态;如果不符,更新后会抛出异常
|
||||
* @param newAfterSaleStatus 目标售后状态
|
||||
* @param afterSaleId 售后单编号;当订单项发起售后时,必须传递该字段
|
||||
* @param refundPrice 退款金额;当订单项退款成功时,必须传递该值
|
||||
*/
|
||||
void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus,
|
||||
Integer newAfterSaleStatus, Integer refundPrice);
|
||||
void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus,
|
||||
Long afterSaleId, Integer refundPrice);
|
||||
|
||||
/**
|
||||
* 创建订单项的评论
|
||||
|
|
|
@ -514,15 +514,22 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||
// =================== Order Item ===================
|
||||
|
||||
@Override
|
||||
public void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, Integer refundPrice) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus,
|
||||
Long afterSaleId, Integer refundPrice) {
|
||||
// 如果退款成功,则 refundPrice 非空
|
||||
if (Objects.equals(newAfterSaleStatus, TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus())
|
||||
&& refundPrice == null) {
|
||||
throw new IllegalArgumentException(StrUtil.format("id({}) 退款成功,退款金额不能为空", id));
|
||||
}
|
||||
// 如果退款发起,则 afterSaleId 非空
|
||||
if (Objects.equals(newAfterSaleStatus, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus())
|
||||
&& afterSaleId == null) {
|
||||
throw new IllegalArgumentException(StrUtil.format("id({}) 退款发起,售后单编号不能为空", id));
|
||||
}
|
||||
|
||||
// 更新订单项
|
||||
int updateCount = tradeOrderItemMapper.updateAfterSaleStatus(id, oldAfterSaleStatus, newAfterSaleStatus);
|
||||
int updateCount = tradeOrderItemMapper.updateAfterSaleStatus(id, oldAfterSaleStatus, newAfterSaleStatus, afterSaleId);
|
||||
if (updateCount <= 0) {
|
||||
throw exception(ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum;
|
|||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties;
|
||||
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
|
||||
import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
@ -52,7 +53,9 @@ public class TradeAfterSaleServiceTest extends BaseDbUnitTest {
|
|||
private TradeAfterSaleLogMapper tradeAfterSaleLogMapper;
|
||||
|
||||
@MockBean
|
||||
private TradeOrderUpdateService tradeOrderService;
|
||||
private TradeOrderUpdateService tradeOrderUpdateService;
|
||||
@Resource
|
||||
private TradeOrderQueryService tradeOrderQueryService;
|
||||
@MockBean
|
||||
private PayRefundApi payRefundApi;
|
||||
|
||||
|
@ -72,12 +75,12 @@ public class TradeAfterSaleServiceTest extends BaseDbUnitTest {
|
|||
o.setOrderId(111L).setUserId(userId).setPayPrice(200);
|
||||
o.setAfterSaleStatus(TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
||||
});
|
||||
when(tradeOrderService.getOrderItem(eq(1024L), eq(1L)))
|
||||
when(tradeOrderQueryService.getOrderItem(eq(1024L), eq(1L)))
|
||||
.thenReturn(orderItem);
|
||||
// mock 方法(交易订单)
|
||||
TradeOrderDO order = randomPojo(TradeOrderDO.class, o -> o.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus())
|
||||
.setNo("202211301234"));
|
||||
when(tradeOrderService.getOrder(eq(1024L), eq(111L))).thenReturn(order);
|
||||
when(tradeOrderQueryService.getOrder(eq(1024L), eq(111L))).thenReturn(order);
|
||||
|
||||
// 调用
|
||||
Long afterSaleId = tradeAfterSaleService.createAfterSale(userId, createReqVO);
|
||||
|
|
Loading…
Reference in New Issue