fix: 订单列表重构 ①

This commit is contained in:
puhui999 2023-08-22 00:42:20 +08:00
parent a159a983a2
commit c2b6c0d72a
13 changed files with 132 additions and 36 deletions

View File

@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
public class BargainActivityBaseVO {
@Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "越拼越省钱")
@Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "砍得越多省得越多,是兄弟就来砍我")
@NotNull(message = "砍价名称不能为空")
private String name;

View File

@ -1,11 +1,11 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO;
import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
@ -67,6 +67,15 @@ public class DeliveryExpressController {
return success(DeliveryExpressConvert.INSTANCE.convert(deliveryExpress));
}
@GetMapping("/list-all-simple")
@Operation(summary = "获取快递公司精简信息列表", description = "主要用于前端的下拉选项")
public CommonResult<List<DeliveryExpressSimpleRespVO>> getSimpleBrandList() {
// 获取品牌列表只要开启状态的
List<DeliveryExpressDO> list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus());
// 排序后返回给前端
return success(DeliveryExpressConvert.INSTANCE.convertList1(list));
}
@GetMapping("/page")
@Operation(summary = "获得快递公司分页")
@PreAuthorize("@ss.hasPermission('trade:delivery:express:query')")

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 快递公司精简信息 Response VO")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DeliveryExpressSimpleRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592")
@NotNull(message = "编号不能为空")
private Long id;
@Schema(description = "快递公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "顺丰速运")
@NotNull(message = "快递公司名称不能为空")
private String name;
}

View File

@ -7,10 +7,7 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi;
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDetailRespVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*;
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
@ -97,4 +94,19 @@ public class TradeOrderController {
return success(true);
}
@PostMapping("/remark")
@Operation(summary = "发货订单")
@PreAuthorize("@ss.hasPermission('trade:order:remark')")
public CommonResult<Boolean> remarkOrder(@RequestBody TradeOrderRemarkReqVO remarkReqVO) {
tradeOrderUpdateService.remarkOrder(getLoginUserId(), remarkReqVO);
return success(true);
}
// TODO @puhui999 订单物流详情
// TODO @puhui999 前台订单取消
// TODO @puhui999 后台订单取消
// TODO @puhui999 前台订单核销
// TODO @puhui999 前台订单删除
// TODO @puhui999 后台订单统计
}

View File

@ -1,7 +1,5 @@
package cn.iocoder.yudao.module.trade.controller.admin.order.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -16,12 +14,6 @@ public class TradeOrderDeliveryReqVO {
@NotNull(message = "订单编号不能为空")
private Long id;
// TODO @puhui999可以去掉 type如果无需发货 logisticsId 传递 0logisticsNo 传递空串
@Schema(description = "发货类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
@InEnum(DeliveryTypeEnum.class)
@NotNull(message = "发货类型不能为空")
private Integer type;
@Schema(description = "发货物流公司编号", example = "1")
@NotNull(message = "发货物流公司不能为空")
private Long logisticsId;

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.trade.controller.admin.order.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 订单备注 Request VO")
@Data
public class TradeOrderRemarkReqVO {
@Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "订单编号不能为空")
private Long id;
@Schema(description = "商家备注", example = "你猜一下")
@NotEmpty(message = "订单备注不能为空")
private String remark;
}

View File

@ -1,17 +1,13 @@
package cn.iocoder.yudao.module.trade.convert.delivery;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExcelVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressRespVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface DeliveryExpressConvert {
@ -29,4 +25,5 @@ public interface DeliveryExpressConvert {
List<DeliveryExpressExcelVO> convertList02(List<DeliveryExpressDO> list);
List<DeliveryExpressSimpleRespVO> convertList1(List<DeliveryExpressDO> list);
}

View File

@ -36,6 +36,11 @@ public interface DeliveryExpressMapper extends BaseMapperX<DeliveryExpressDO> {
return selectOne(new LambdaQueryWrapper<DeliveryExpressDO>()
.eq(DeliveryExpressDO::getCode, code));
}
default List<DeliveryExpressDO> selectListByStatus(Integer status) {
return selectList(DeliveryExpressDO::getStatus, status);
}
}

View File

@ -1,8 +1,5 @@
package cn.iocoder.yudao.module.trade.service.delivery;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO;
@ -10,6 +7,10 @@ import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.Delive
import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
* 快递公司 Service 接口
*
@ -71,4 +72,11 @@ public interface DeliveryExpressService {
*/
List<DeliveryExpressDO> getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO);
/**
* 获取指定状态的快递公司列表
*
* @param status 状态
* @return 返回快递公司列表
*/
List<DeliveryExpressDO> getDeliveryExpressListByStatus(Integer status);
}

View File

@ -9,14 +9,15 @@ import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_CODE_DUPLICATE;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS;
/**
* 快递公司 Service 实现类
@ -99,4 +100,9 @@ public class DeliveryExpressServiceImpl implements DeliveryExpressService {
return deliveryExpressMapper.selectList(exportReqVO);
}
@Override
public List<DeliveryExpressDO> getDeliveryExpressListByStatus(Integer status) {
return deliveryExpressMapper.selectListByStatus(status);
}
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.trade.service.order;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO;
@ -60,6 +61,14 @@ public interface TradeOrderUpdateService {
*/
void receiveOrder(Long userId, Long id);
/**
* 管理员交易订单备注
*
* @param loginUserId 管理员编号
* @param remarkReqVO 备注请求
*/
void remarkOrder(Long loginUserId, TradeOrderRemarkReqVO remarkReqVO);
// =================== Order Item ===================
/**

View File

@ -30,6 +30,7 @@ import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi;
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO;
@ -398,7 +399,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
TradeOrderDO updateOrderObj = new TradeOrderDO();
// 判断发货类型
// 2.1 快递发货
if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) {
if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), 0L)) {
// 校验快递公司
DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId());
if (deliveryExpress == null) {
@ -408,11 +409,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
throw exception(EXPRESS_STATUS_NOT_ENABLE);
}
updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode());
}
// TODO @puhui999无需发货时更新 logisticsId 0
// 2.2 无需发货
if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) {
updateOrderObj.setLogisticsId(null).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode());
} else {
// 2.2 无需发货
updateOrderObj.setLogisticsId(0L).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode());
}
// 更新 TradeOrderDO 状态为已发货等待收货
@ -489,6 +488,17 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
// TODO 芋艿lili 发送商品被购买完成的数据
}
@Override
public void remarkOrder(Long loginUserId, TradeOrderRemarkReqVO remarkReqVO) {
// 校验并获得交易订单
validateOrderDeliverable(remarkReqVO.getId());
TradeOrderDO updateOrderObj = new TradeOrderDO();
updateOrderObj.setId(remarkReqVO.getId());
updateOrderObj.setRemark(remarkReqVO.getRemark());
tradeOrderMapper.updateById(updateOrderObj);
}
/**
* 校验交易订单满足可售货的条件
*

View File

@ -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;
@ -54,6 +55,8 @@ public class TradeAfterSaleServiceTest extends BaseDbUnitTest {
@MockBean
private TradeOrderUpdateService tradeOrderService;
@MockBean
private TradeOrderQueryService tradeOrderQueryService;
@MockBean
private PayRefundApi payRefundApi;
@MockBean
@ -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);