mall:订单统计接口

This commit is contained in:
YunaiV 2023-05-20 10:11:38 +08:00
parent 83aa656bda
commit be7c664e07
4 changed files with 31 additions and 9 deletions

View File

@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderI
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; 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.TradeOrderDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderService; import cn.iocoder.yudao.module.trade.service.order.TradeOrderService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -171,17 +172,17 @@ public class AppTradeOrderController {
return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems, propertyValueDetails)); return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems, propertyValueDetails));
} }
// TODO 芋艿后续实现
@GetMapping("/get-count") @GetMapping("/get-count")
@Operation(summary = "获得交易订单数量") @Operation(summary = "获得交易订单数量")
public CommonResult<Map<String, Integer>> getOrderCount() { public CommonResult<Map<String, Long>> getOrderCount() {
Map<String, Integer> orderCount = new HashMap<>(); Map<String, Long> orderCount = new HashMap<>();
orderCount.put("allCount", 10); // 全部
orderCount.put("unpaidCount", 5); orderCount.put("allCount", tradeOrderService.getOrderCount(getLoginUserId(), null, null));
orderCount.put("undeliveredCount", 2); // 待付款未支付
orderCount.put("deliveredCount", 1); orderCount.put("unpaidCount", tradeOrderService.getOrderCount(getLoginUserId(), TradeOrderStatusEnum.UNPAID.getStatus(), null));
orderCount.put("uncommentedCount", 3); orderCount.put("undeliveredCount", tradeOrderService.getOrderCount(getLoginUserId(), TradeOrderStatusEnum.UNDELIVERED.getStatus(), null));
orderCount.put("allPrice", 300); orderCount.put("deliveredCount", tradeOrderService.getOrderCount(getLoginUserId(), TradeOrderStatusEnum.DELIVERED.getStatus(), null));
orderCount.put("uncommentedCount", tradeOrderService.getOrderCount(getLoginUserId(), TradeOrderStatusEnum.COMPLETED.getStatus(), false));
return success(orderCount); return success(orderCount);
} }

View File

@ -44,4 +44,10 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
.orderByDesc(TradeOrderDO::getId)); // TODO 芋艿未来不同的 status不同的排序 .orderByDesc(TradeOrderDO::getId)); // TODO 芋艿未来不同的 status不同的排序
} }
default Long selectCountByUserIdAndStatus(Long userId, Integer status, Boolean commentStatus) {
return selectCount(new LambdaQueryWrapperX<TradeOrderDO>()
.eq(TradeOrderDO::getUserId, userId)
.eqIfPresent(TradeOrderDO::getStatus, status)
.eqIfPresent(TradeOrderDO::getCommentStatus, commentStatus));
}
} }

View File

@ -91,6 +91,16 @@ public interface TradeOrderService {
*/ */
PageResult<TradeOrderDO> getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO); PageResult<TradeOrderDO> getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO);
/**
* 会员获得交易订单数量
*
* @param userId 用户编号
* @param status 订单状态如果为空则不进行筛选
* @param commonStatus 评价状态如果为空则不进行筛选
* @return 订单数量
*/
Long getOrderCount(Long userId, Integer status, Boolean commonStatus);
// =================== Order Item =================== // =================== Order Item ===================
/** /**

View File

@ -451,6 +451,11 @@ public class TradeOrderServiceImpl implements TradeOrderService {
return tradeOrderMapper.selectPage(reqVO, userId); return tradeOrderMapper.selectPage(reqVO, userId);
} }
@Override
public Long getOrderCount(Long userId, Integer status, Boolean commentStatus) {
return tradeOrderMapper.selectCountByUserIdAndStatus(userId, status, commentStatus);
}
// =================== Order Item =================== // =================== Order Item ===================
@Override @Override