Merge branch 'feature/mall_product' of https://gitee.com/CrazyWorld/ruoyi-vue-pro into feature/mall_product

# Conflicts:
#	yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
This commit is contained in:
YunaiV 2023-10-04 17:33:14 +08:00
commit c5824eedf7
40 changed files with 626 additions and 32 deletions

View File

@ -43,6 +43,11 @@
<artifactId>yudao-module-member-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-pay-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>

View File

@ -1,13 +1,18 @@
package cn.iocoder.yudao.module.statistics.convert.trade;
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.time.LocalDateTime;
import java.util.List;
/**
@ -36,7 +41,13 @@ public interface TradeStatisticsConvert {
TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespVO value, TradeSummaryRespVO reference);
TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value, TradeTrendSummaryRespVO reference);
TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value,
TradeTrendSummaryRespVO reference);
List<TradeTrendSummaryExcelVO> convertList02(List<TradeTrendSummaryRespVO> list);
TradeStatisticsDO convert(LocalDateTime time, TradeOrderSummaryRespDTO orderSummary,
AfterSaleSummaryRespDTO afterSaleSummary, Integer brokerageSettlementPrice,
WalletSummaryRespDTO walletSummary);
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.statistics.job.trade;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* 交易统计 Job
*
* @author owen
*/
@Component
public class TradeStatisticsJob implements JobHandler {
@Resource
private TradeStatisticsService tradeStatisticsService;
@Override
@TenantJob
public String execute(String param) {
String times = tradeStatisticsService.statisticsYesterdayTrade();
return StrUtil.format("交易统计耗时: {}", times);
}
}

View File

@ -36,4 +36,11 @@ public interface TradeStatisticsService {
*/
List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime);
/**
* 统计昨日交易
*
* @return 耗时
*/
String statisticsYesterdayTrade();
}

View File

@ -2,13 +2,22 @@ package cn.iocoder.yudao.module.statistics.service.trade;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi;
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert;
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.trade.api.aftersale.TradeAfterSaleApi;
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
import cn.iocoder.yudao.module.trade.api.brokerage.TradeBrokerageApi;
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
@ -28,6 +37,15 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
@Resource
private TradeStatisticsMapper tradeStatisticsMapper;
@Resource
private TradeOrderApi tradeOrderApi;
@Resource
private TradeAfterSaleApi tradeAfterSaleApi;
@Resource
private TradeBrokerageApi tradeBrokerageApi;
@Resource
private PayWalletApi payWalletApi;
@Override
public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() {
// 昨天的数据
@ -59,6 +77,36 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime);
}
@Override
public String statisticsYesterdayTrade() {
// 处理统计参数
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
// 统计
StopWatch stopWatch = new StopWatch("交易统计");
stopWatch.start("统计订单");
TradeOrderSummaryRespDTO orderSummary = tradeOrderApi.getOrderSummary(beginTime, endTime);
stopWatch.stop();
stopWatch.start("统计售后");
AfterSaleSummaryRespDTO afterSaleSummary = tradeAfterSaleApi.getAfterSaleSummary(beginTime, endTime);
stopWatch.stop();
stopWatch.start("统计佣金");
Integer brokerageSettlementPrice = tradeBrokerageApi.getBrokerageSettlementPriceSummary(beginTime, endTime);
stopWatch.stop();
stopWatch.start("统计充值");
WalletSummaryRespDTO walletSummary = payWalletApi.getWalletSummary(beginTime, endTime);
stopWatch.stop();
// 插入数据
TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, brokerageSettlementPrice, walletSummary);
tradeStatisticsMapper.insert(entity);
// 返回计时结果
return stopWatch.prettyPrint();
}
/**
* 统计指定日期的交易数据
*

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.trade.api.aftersale;
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
import java.time.LocalDateTime;
/**
* 售后 API 接口
*
* @author owen
*/
public interface TradeAfterSaleApi {
/**
* 获取售后单统计
*
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 售后统计结果
*/
AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.trade.api.aftersale.dto;
import lombok.Data;
/**
* 售后统计 Response DTO
*
* @author owen
*/
@Data
public class AfterSaleSummaryRespDTO {
/**
* 退款订单数
*/
private Integer afterSaleCount;
/**
* 总退款金额单位
*/
private Integer afterSaleRefundPrice;
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.trade.api.brokerage;
import java.time.LocalDateTime;
/**
* 分销 API 接口
*
* @author owen
*/
public interface TradeBrokerageApi {
/**
* 获取已结算的佣金金额
*
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 已结算的佣金金额
*/
Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -1,5 +1,9 @@
package cn.iocoder.yudao.module.trade.api.order;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
import java.time.LocalDateTime;
/**
* 订单 API 接口
*
@ -16,4 +20,13 @@ public interface TradeOrderApi {
*/
Integer getOrderStatus(Long id);
/**
* 获取订单统计
*
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 订单统计结果
*/
TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.trade.api.order.dto;
import lombok.Data;
/**
* 订单统计 Response DTO
*
* @author owen
*/
@Data
public class TradeOrderSummaryRespDTO {
/**
* 创建订单数
*/
private Long orderCreateCount;
/**
* 支付订单商品数
*/
private Integer orderPayCount;
/**
* 总支付金额单位
*/
private Integer orderPayPrice;
}

View File

@ -32,6 +32,7 @@ public interface ErrorCodeConstants {
ErrorCode ORDER_UPDATE_PRICE_FAIL_ALREADY = new ErrorCode(1_011_000_027, "支付订单调价失败,原因:已经修改过价格");
ErrorCode ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR = new ErrorCode(1_011_000_028, "支付订单调价失败,原因:调整后支付价格不能小于 0.01 元");
ErrorCode ORDER_DELETE_FAIL_STATUS_NOT_CANCEL = new ErrorCode(1_011_000_029, "交易订单删除失败,订单不是【已取消】状态");
ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】");
// ========== After Sale 模块 1-011-000-100 ==========
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在");

View File

@ -19,6 +19,7 @@ public enum TradeOrderOperateTypeEnum {
ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"),
MEMBER_RECEIVE(30, "用户已收货"),
SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"),
PICK_UP_RECEIVE(32, "自提收货"),
MEMBER_COMMENT(33, "用户评价"),
SYSTEM_COMMENT(34, "到期未评价,系统自动评价"),
MEMBER_CANCEL(40, "取消订单"),

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.trade.api.aftersale;
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
* 售后 API 接口实现类
*
* @author owen
*/
@Service
@Validated
public class TradeAfterSaleApiImpl implements TradeAfterSaleApi {
@Resource
private AfterSaleService afterSaleService;
@Override
public AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) {
return afterSaleService.getAfterSaleSummary(beginTime, endTime);
}
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.trade.api.brokerage;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
* 订单 API 接口实现类
*
* @author HUIHUI
*/
@Service
@Validated
public class TradeBrokerageApiImpl implements TradeBrokerageApi {
@Resource
private BrokerageRecordService brokerageRecordService;
@Override
public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) {
return brokerageRecordService.getBrokerageSettlementPriceSummary(beginTime, endTime);
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.trade.api.order;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
import org.springframework.stereotype.Service;
@ -7,6 +8,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND;
@ -31,4 +34,9 @@ public class TradeOrderApiImpl implements TradeOrderApi {
return order.getStatus();
}
@Override
public TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) {
return tradeOrderQueryService.getOrderSummary(beginTime, endTime);
}
}

View File

@ -126,6 +126,12 @@ public class TradeOrderController {
return success(true);
}
// TODO 核销逻辑
@PutMapping("/pick-up")
@Operation(summary = "订单核销")
@PreAuthorize("@ss.hasPermission('trade:order:pick-up')")
public CommonResult<Boolean> pickUpOrder(@RequestParam("id") Long id) {
tradeOrderUpdateService.pickUpOrder(id);
return success(true);
}
}

View File

@ -40,6 +40,9 @@ public class TradeOrderPageReqVO extends PageParam {
@Schema(description = "自提门店编号", example = "[1,2]")
private List<Long> pickUpStoreIds;
@Schema(description = "自提核销码", example = "12345678")
private String pickUpVerifyCode;
@Schema(description = "订单类型", example = "1")
private Integer type;

View File

@ -113,6 +113,9 @@ public class AppTradeOrderDetailRespVO {
@Schema(description = "自提门店编号", example = "1088")
private Long pickUpStoreId;
@Schema(description = "自提核销码", example = "40964096")
private String pickUpVerifyCode;
// ========== 售后基本信息 ==========
// ========== 营销基本信息 ==========

View File

@ -1,14 +1,19 @@
package cn.iocoder.yudao.module.trade.dal.mysql.aftersale;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.yulichang.toolkit.MPJWrappers;
import org.apache.ibatis.annotations.Mapper;
import java.time.LocalDateTime;
import java.util.Collection;
@Mapper
@ -48,4 +53,12 @@ public interface AfterSaleMapper extends BaseMapperX<AfterSaleDO> {
.in(AfterSaleDO::getStatus, statuses));
}
default AfterSaleSummaryRespDTO selectSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<AfterSaleDO>lambdaJoin()
.selectCount(AfterSaleDO::getId, AfterSaleSummaryRespDTO::getAfterSaleCount)
.selectSum(AfterSaleDO::getRefundPrice, AfterSaleSummaryRespDTO::getAfterSaleRefundPrice)
.between(AfterSaleDO::getRefundTime, beginTime, endTime)), 0),
AfterSaleSummaryRespDTO.class);
}
}

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.trade.dal.mysql.brokerage;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@ -108,4 +110,14 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
@Param("status") Integer status,
@Param("beginTime") LocalDateTime beginTime,
@Param("endTime") LocalDateTime endTime);
default Integer selectSummaryPriceByStatusAndUnfreezeTimeBetween(Integer bizType, Integer status,
LocalDateTime beginTime, LocalDateTime endTime) {
return Convert.toInt(CollUtil.getFirst(selectObjs(MPJWrappers.<BrokerageRecordDO>lambdaJoin()
.selectSum(BrokerageRecordDO::getPrice)
.eq(BrokerageRecordDO::getBizType, bizType)
.eq(BrokerageRecordDO::getStatus, status)
.between(BrokerageRecordDO::getUnfreezeTime, beginTime, endTime))), 0);
}
}

View File

@ -1,12 +1,16 @@
package cn.iocoder.yudao.module.trade.dal.mysql.order;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.yulichang.toolkit.MPJWrappers;
import org.apache.ibatis.annotations.Mapper;
import java.time.LocalDateTime;
@ -37,6 +41,7 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
.eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal())
.eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId())
.inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds())
.likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode())
.betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(TradeOrderDO::getId));
}
@ -88,4 +93,21 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
.eq(TradeOrderDO::getSeckillActivityId, seckillActivityId));
}
default TradeOrderSummaryRespDTO selectSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<TradeOrderDO>lambdaJoin()
.selectCount(TradeOrderDO::getId, TradeOrderSummaryRespDTO::getOrderPayCount)
.selectSum(TradeOrderDO::getPayPrice, TradeOrderSummaryRespDTO::getOrderPayPrice)
.between(TradeOrderDO::getPayTime, beginTime, endTime)), 0),
TradeOrderSummaryRespDTO.class);
}
default Long selectCountByCreateTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
return selectCount(new LambdaQueryWrapperX<TradeOrderDO>()
.between(TradeOrderDO::getCreateTime, beginTime, endTime));
}
default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) {
return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode);
}
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.service.aftersale;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO;
@ -9,6 +10,8 @@ import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCre
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO;
import java.time.LocalDateTime;
/**
* 售后订单 Service 接口
*
@ -124,4 +127,13 @@ public interface AfterSaleService {
*/
Long getApplyingAfterSaleCount(Long userId);
/**
* 获取售后单统计
*
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 售后统计结果
*/
AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi;
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
import cn.iocoder.yudao.module.trade.api.aftersale.dto.AfterSaleSummaryRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO;
@ -410,4 +411,9 @@ public class AfterSaleServiceImpl implements AfterSaleService {
return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES);
}
@Override
public AfterSaleSummaryRespDTO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) {
return tradeAfterSaleMapper.selectSummaryByRefundTimeBetween(beginTime,endTime);
}
}

View File

@ -156,4 +156,13 @@ public interface BrokerageRecordService {
*/
AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId);
/**
* 获取已结算的佣金金额
*
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 已结算的佣金金额
*/
Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -356,6 +356,13 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
return respVO;
}
@Override
public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) {
return brokerageRecordMapper.selectSummaryPriceByStatusAndUnfreezeTimeBetween(
BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(),
beginTime, endTime);
}
/**
* 获得自身的代理对象解决 AOP 生效问题
*

View File

@ -1,12 +1,14 @@
package cn.iocoder.yudao.module.trade.service.order;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
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.framework.delivery.core.client.dto.ExpressTrackRespDTO;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
@ -128,4 +130,13 @@ public interface TradeOrderQueryService {
*/
List<TradeOrderItemDO> getOrderItemListByOrderId(Collection<Long> orderIds);
/**
* 获取订单统计
*
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 订单统计结果
*/
TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
@ -21,6 +22,7 @@ import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -156,6 +158,14 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
.setPhone(order.getReceiverMobile()));
}
@Override
public TradeOrderSummaryRespDTO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) {
TradeOrderSummaryRespDTO dto = tradeOrderMapper.selectSummaryByPayTimeBetween(beginTime, endTime);
dto.setOrderCreateCount(tradeOrderMapper.selectCountByCreateTimeBetween(beginTime, endTime));
return dto;
}
// =================== Order Item ===================
@Override

View File

@ -115,6 +115,20 @@ public interface TradeOrderUpdateService {
*/
void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO);
/**
* 管理员核销订单
*
* @param id 订单编号
*/
void pickUpOrder(Long id);
/**
* 管理员核销订单
*
* @param pickUpVerifyCode 自提核销码
*/
void pickUpOrder(String pickUpVerifyCode);
// =================== Order Item ===================
/**

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.service.order;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.spring.SpringUtil;
@ -233,7 +234,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
order.setReceiverName(createReqVO.getReceiverName()).setReceiverMobile(createReqVO.getReceiverMobile());
order.setPickUpVerifyCode(RandomUtil.randomNumbers(8)); // 随机一个核销码长度为 8
}
// TODO @疯狂是不是可以在这里设置下推广人哈
// 设置订单推广人
BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(order.getUserId());
if (brokerageUser != null && brokerageUser.getBindUserId() != null) {
order.setBrokerageUserId(brokerageUser.getBindUserId());
}
return order;
}
@ -294,12 +299,6 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
// 6. 插入订单日志
TradeOrderLogUtils.setOrderInfo(order.getId(), null, order.getStatus());
// 7. 设置订单推广人
BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(order.getUserId());
if (brokerageUser != null && brokerageUser.getBindUserId() != null) {
tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setBrokerageUserId(brokerageUser.getBindUserId()));
}
// TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来!
}
@ -751,6 +750,29 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
// TODO @puhui999操作日志
}
@Override
public void pickUpOrder(Long id) {
getSelf().pickUpOrder(tradeOrderMapper.selectById(id));
}
@Override
public void pickUpOrder(String pickUpVerifyCode) {
getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode));
}
@Transactional(rollbackFor = Exception.class)
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.PICK_UP_RECEIVE)
public void pickUpOrder(TradeOrderDO order) {
if (order == null) {
throw exception(ORDER_NOT_FOUND);
}
if (ObjUtil.notEqual(DeliveryTypeEnum.PICK_UP.getType(), order.getDeliveryType())) {
throw exception(ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP);
}
// todo 校验核销操作人
receiveOrder0(order);
}
// =================== Order Item ===================
@Override

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.pay.api.wallet;
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
import java.time.LocalDateTime;
/**
* 钱包 API 接口
*
* @author owen
*/
public interface PayWalletApi {
/**
* 获取钱包统计
*
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 钱包统计
*/
WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.pay.api.wallet.dto;
import lombok.Data;
/**
* 钱包统计 Response DTO
*
* @author owen
*/
@Data
public class WalletSummaryRespDTO {
/**
* 总支付金额余额单位
*/
private Integer orderWalletPayPrice;
/**
* 充值订单数
*/
private Integer rechargePayCount;
/**
* 充值金额单位
*/
private Integer rechargePayPrice;
/**
* 充值退款订单数
*/
private Integer rechargeRefundCount;
/**
* 充值退款金额单位
*/
private Integer rechargeRefundPrice;
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.pay.api.wallet;
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
* 钱包 API 接口实现类
*
* @author owen
*/
@Service
@Validated
public class PayWalletApiImpl implements PayWalletApi {
@Resource
private PayWalletRechargeService payWalletRechargeService;
@Resource
private PayWalletTransactionService payWalletTransactionService;
@Override
public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) {
WalletSummaryRespDTO walletSummary = payWalletRechargeService.getWalletSummary(beginTime, endTime);
walletSummary.setOrderWalletPayPrice(payWalletTransactionService.getPriceSummary(PayWalletBizTypeEnum.PAYMENT, beginTime, endTime));
return walletSummary;
}
}

View File

@ -1,10 +1,17 @@
package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
import com.github.yulichang.toolkit.MPJWrappers;
import org.apache.ibatis.annotations.Mapper;
import java.time.LocalDateTime;
@Mapper
public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO> {
@ -18,6 +25,24 @@ public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO
.eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus));
}
default WalletSummaryRespDTO selectRechargeSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin()
.selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargePayCount)
.selectSum(PayWalletRechargeDO::getPayPrice, WalletSummaryRespDTO::getRechargePayPrice)
.eq(PayWalletRechargeDO::getPayStatus, true)
.between(PayWalletRechargeDO::getPayTime, beginTime, endTime)), 0),
WalletSummaryRespDTO.class);
}
default WalletSummaryRespDTO selectRechargeSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin()
.selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargeRefundCount)
.selectSum(PayWalletRechargeDO::getRefundPayPrice, WalletSummaryRespDTO::getRechargeRefundPrice)
.eq(PayWalletRechargeDO::getRefundStatus, PayRefundStatusEnum.SUCCESS.getStatus())
.between(PayWalletRechargeDO::getRefundTime, beginTime, endTime)), 0),
WalletSummaryRespDTO.class);
}
}

View File

@ -6,9 +6,12 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import com.github.yulichang.toolkit.MPJWrappers;
import org.apache.ibatis.annotations.Mapper;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
@Mapper
public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> {
@ -35,6 +38,15 @@ public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransac
PayWalletTransactionDO::getBizType, bizType);
}
default Integer selectSummaryByBizTypeAndCreateTimeBetween(Integer type, LocalDateTime beginTime, LocalDateTime endTime) {
return Optional.ofNullable(selectOne(MPJWrappers.<PayWalletTransactionDO>lambdaJoin()
.selectSum(PayWalletTransactionDO::getPrice)
.eq(PayWalletTransactionDO::getBizType, type)
.between(PayWalletTransactionDO::getCreateTime, beginTime, endTime)))
.map(PayWalletTransactionDO::getPrice)
.orElse(0);
}
}

View File

@ -1,8 +1,11 @@
package cn.iocoder.yudao.module.pay.service.wallet;
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
import java.time.LocalDateTime;
/**
* 钱包充值 Service 接口
*
@ -42,4 +45,14 @@ public interface PayWalletRechargeService {
* @param payRefundId 退款单id
*/
void updateWalletRechargeRefunded(Long id, Long payRefundId);
/**
* 获取钱包统计
*
* @param beginTime 起始时间
* @param endTime 截止时间
* @return 钱包统计
*/
WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
@ -257,4 +258,15 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
return payOrder;
}
@Override
public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) {
WalletSummaryRespDTO paySummary = walletRechargeMapper.selectRechargeSummaryByPayTimeBetween(beginTime, endTime);
WalletSummaryRespDTO refundSummary = walletRechargeMapper.selectRechargeSummaryByRefundTimeBetween(beginTime, endTime);
paySummary.setRechargeRefundCount(refundSummary.getRechargeRefundCount());
paySummary.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice());
return paySummary;
}
}

View File

@ -1,9 +1,12 @@
package cn.iocoder.yudao.module.pay.service.wallet;
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
import java.time.LocalDateTime;
/**
* 钱包 Service 接口
*

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.pay.service.wallet;
import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO;
import javax.validation.Valid;
import java.time.LocalDateTime;
/**
* 钱包余额流水 Service 接口
@ -49,4 +50,14 @@ public interface PayWalletTransactionService {
*/
PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type);
/**
* 获取支付金额合计
*
* @param bizType 业务类型
* @param beginTime 开始时间
* @param endTime 结束时间
* @return 支付金额合计
*/
Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime);
}

View File

@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
* 钱包流水 Service 实现类
@ -60,4 +61,9 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ
return payWalletTransactionMapper.selectByBiz(bizId, type.getType());
}
@Override
public Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime) {
return payWalletTransactionMapper.selectSummaryByBizTypeAndCreateTimeBetween(bizType.getType(), beginTime, endTime);
}
}