mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-02-20 19:20:32 +08:00
Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product
This commit is contained in:
commit
565a8e0e6b
@ -15,7 +15,7 @@
|
||||
<name>${project.artifactId}</name>
|
||||
|
||||
<description>
|
||||
商城大模块,由 product 商品、promotion 营销、trade 交易等组成
|
||||
商城大模块,由 product 商品、promotion 营销、trade 交易、statistics 统计等组成
|
||||
</description>
|
||||
<modules>
|
||||
<module>yudao-module-promotion-api</module>
|
||||
@ -24,6 +24,8 @@
|
||||
<module>yudao-module-product-biz</module>
|
||||
<module>yudao-module-trade-api</module>
|
||||
<module>yudao-module-trade-biz</module>
|
||||
<module>yudao-module-statistics-api</module>
|
||||
<module>yudao-module-statistics-biz</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
33
yudao-module-mall/yudao-module-statistics-api/pom.xml
Normal file
33
yudao-module-mall/yudao-module-statistics-api/pom.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-mall</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>yudao-module-statistics-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
statistics 模块 API,暴露给其它模块调用
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 参数校验 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* TODO 占位,无特殊含义
|
||||
*/
|
||||
package cn.iocoder.yudao.module.statistics.api;
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* TODO 占位,无特殊含义
|
||||
*/
|
||||
package cn.iocoder.yudao.module.statistics.enums;
|
86
yudao-module-mall/yudao-module-statistics-biz/pom.xml
Normal file
86
yudao-module-mall/yudao-module-statistics-biz/pom.xml
Normal file
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-mall</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>yudao-module-statistics-biz</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
statistics 模块,主要实现统计相关功能
|
||||
例如:统计商品、会员、交易等功能。
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-statistics-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-promotion-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-product-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-trade-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-member-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- DB 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test 测试相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 工具类相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* TODO
|
||||
* 1. 会员总数据
|
||||
* 2. 性别统计
|
||||
* 3. 渠道统计
|
||||
* 4. 地域统计
|
||||
* 5. 会员概览
|
||||
*/
|
||||
package cn.iocoder.yudao.module.statistics.controller.member;
|
@ -0,0 +1 @@
|
||||
package cn.iocoder.yudao.module.statistics.controller;
|
@ -0,0 +1,41 @@
|
||||
package cn.iocoder.yudao.module.statistics.controller.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.statistics.dal.mysql.product.ProductSpuStatisticsDO;
|
||||
import cn.iocoder.yudao.module.statistics.dal.mysql.product.ProductStatisticsDO;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "管理后台 - 商品统计")
|
||||
@RestController
|
||||
@RequestMapping("/statistics/product")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class ProductStatisticsController {
|
||||
|
||||
// TODO @麦子:返回 ProductStatisticsComparisonResp, 里面有两个字段,一个是选择的时间范围的合计结果,一个是对比的时间范围的合计结果;
|
||||
// 例如说,选择时间范围是 2023-10-01 ~ 2023-10-02,那么对比就是 2023-09-30,再倒推 2 天;
|
||||
public CommonResult<Object> getProductStatisticsComparison() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO @麦子:查询指定时间范围内的商品统计数据;DO 到时需要改成 VO 哈
|
||||
public CommonResult<List<ProductStatisticsDO>> getProductStatisticsList(
|
||||
LocalDateTime[] times) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO @麦子:查询指定时间范围内的商品 SPU 统计数据;DO 到时需要改成 VO 哈
|
||||
// 入参是分页参数 + 时间范围 + 排序字段
|
||||
public CommonResult<PageResult<ProductSpuStatisticsDO>> getProductSpuStatisticsPage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.statistics.controller.trade;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsDO;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "管理后台 - 交易统计")
|
||||
@RestController
|
||||
@RequestMapping("/statistics/product")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class TradeStatisticsController {
|
||||
|
||||
// TODO @疯狂:有个 summary 接口,返回昨日、本月、支付金额、本月订单金额等数据;具体看 ui 哈;
|
||||
|
||||
// TODO @疯狂:返回 ProductStatisticsComparisonResp, 里面有两个字段,一个是选择的时间范围的合计结果,一个是对比的时间范围的合计结果;
|
||||
// 例如说,选择时间范围是 2023-10-01 ~ 2023-10-02,那么对比就是 2023-09-30,再倒推 2 天;
|
||||
public CommonResult<Object> getTradeStatisticsComparison() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO @疯狂:查询指定时间范围内的交易统计数据;DO 到时需要改成 VO 哈
|
||||
// 总收入(营业额)= 订单、充值的支付 - 订单、充值的退款
|
||||
public CommonResult<List<TradeStatisticsDO>> getTradeStatisticsList(
|
||||
LocalDateTime[] times) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 占位 todo
|
||||
*/
|
||||
package cn.iocoder.yudao.module.statistics.dal.dataobject;
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.statistics.dal.mysql.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 商品 SPU 统计 DO
|
||||
*
|
||||
* 以天为维度,统计商品 SPU 的数据
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("product_spu_statistics")
|
||||
@KeySequence("product_spu_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProductSpuStatisticsDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号,主键自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
*
|
||||
* 关联 ProductSpuDO 的 id 字段
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 统计日期
|
||||
*/
|
||||
private LocalDateTime time;
|
||||
|
||||
/**
|
||||
* 浏览量
|
||||
*/
|
||||
private Integer browseCount;
|
||||
/**
|
||||
* 收藏量
|
||||
*/
|
||||
private Integer favoriteCount;
|
||||
|
||||
/**
|
||||
* 添加购物车次数
|
||||
*
|
||||
* 以商品被添加到购物车的 createTime 计算,后续多次添加,不会增加该值。
|
||||
* 直到该次被下单、或者被删除,后续再次被添加到购物车。
|
||||
*/
|
||||
private Integer addCartCount;
|
||||
/**
|
||||
* 创建订单商品数
|
||||
*/
|
||||
private Integer createOrderCount;
|
||||
/**
|
||||
* 支付订单商品数
|
||||
*/
|
||||
private Integer payOrderCount;
|
||||
/**
|
||||
* 总支付金额,单位:分
|
||||
*/
|
||||
private Integer payPrice;
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.statistics.dal.mysql.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 商品统计 DO
|
||||
*
|
||||
* 以天为维度,统计全部的数据
|
||||
*
|
||||
* 和 {@link ProductSpuStatisticsDO} 的差异是,它是全局的统计
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("product_spu_statistics")
|
||||
@KeySequence("product_spu_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProductStatisticsDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号,主键自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 统计日期
|
||||
*/
|
||||
private LocalDateTime time;
|
||||
|
||||
/**
|
||||
* 浏览量
|
||||
*/
|
||||
private Integer browseCount;
|
||||
/**
|
||||
* 收藏量
|
||||
*/
|
||||
private Integer favoriteCount;
|
||||
|
||||
/**
|
||||
* 添加购物车次数
|
||||
*
|
||||
* 以商品被添加到购物车的 createTime 计算,后续多次添加,不会增加该值。
|
||||
* 直到该次被下单、或者被删除,后续再次被添加到购物车。
|
||||
*/
|
||||
private Integer addCartCount;
|
||||
/**
|
||||
* 创建订单商品数
|
||||
*/
|
||||
private Integer createOrderCount;
|
||||
/**
|
||||
* 支付订单商品数
|
||||
*/
|
||||
private Integer payOrderCount;
|
||||
/**
|
||||
* 总支付金额,单位:分
|
||||
*/
|
||||
private Integer payPrice;
|
||||
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package cn.iocoder.yudao.module.statistics.dal.mysql.trade;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 交易统计 DO
|
||||
*
|
||||
* 以天为维度,统计全部的数据
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("trade_statistics")
|
||||
@KeySequence("trade_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TradeStatisticsDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号,主键自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 统计日期
|
||||
*/
|
||||
private LocalDateTime time;
|
||||
|
||||
/**
|
||||
* 创建订单数
|
||||
*/
|
||||
private Integer orderCreateCount;
|
||||
/**
|
||||
* 支付订单商品数
|
||||
*/
|
||||
private Integer orderPayCount;
|
||||
/**
|
||||
* 总支付金额,单位:分
|
||||
*/
|
||||
private Integer orderPayPrice;
|
||||
/**
|
||||
* 总支付金额(余额),单位:分
|
||||
*/
|
||||
private Integer orderWalletPayPrice;
|
||||
|
||||
/**
|
||||
* 退款订单数
|
||||
*/
|
||||
private Integer afterSaleCount;
|
||||
/**
|
||||
* 总退款金额,单位:分
|
||||
*/
|
||||
private Integer afterSaleRefundPrice;
|
||||
|
||||
/**
|
||||
* 佣金金额(已结算),单位:分
|
||||
*/
|
||||
private Integer brokerageSettlementPrice;
|
||||
|
||||
/**
|
||||
* 充值订单数
|
||||
*
|
||||
* 从 PayWalletRechargeDO 计算
|
||||
*/
|
||||
private Integer rechargePayCount;
|
||||
/**
|
||||
* 充值金额,单位:分
|
||||
*/
|
||||
private Integer rechargePayPrice;
|
||||
/**
|
||||
* 充值退款订单数
|
||||
*/
|
||||
private Integer rechargeRefundCount;
|
||||
/**
|
||||
* 充值退款金额,单位:分
|
||||
*/
|
||||
private Integer rechargeRefundPrice;
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* TODO 芋艿,占坑,无特殊含义
|
||||
*/
|
||||
package cn.iocoder.yudao.module.statistics.job;
|
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* statistics 模块,主要实现统计相关功能。
|
||||
* 例如:统计商品、会员、交易等功能。
|
||||
*
|
||||
* 1. Controller URL:以 /statistics/ 开头,避免和其它 Module 冲突
|
||||
* 2. DataObject 表名:以 statistics_ 为后缀,方便在数据库中区分【特殊】
|
||||
*/
|
||||
package cn.iocoder.yudao.module.statistics;
|
@ -29,8 +29,8 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS = new ErrorCode(1011000024, "交易订单发货失败,发货类型不是快递");
|
||||
ErrorCode ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID = new ErrorCode(1011000025, "交易订单取消失败,订单不是【待支付】状态");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_PAID = new ErrorCode(1011000026, "支付订单调价失败,原因:支付订单已付款,不能调价");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_EQUAL = new ErrorCode(1011000027, "支付订单调价失败,原因:价格没有变化");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_NOT_ITEM = new ErrorCode(1011000028, "支付订单调价失败,原因:订单项不存在");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_ALREADY = new ErrorCode(1011000027, "支付订单调价失败,原因:已经修改过价格");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR = new ErrorCode(1011000028, "支付订单调价失败,原因:调整后支付价格不能小于 0.01 元");
|
||||
ErrorCode ORDER_DELETE_FAIL_STATUS_NOT_CANCEL = new ErrorCode(1011000029, "交易订单删除失败,订单不是【已取消】状态");
|
||||
|
||||
// ========== After Sale 模块 1011000100 ==========
|
||||
|
@ -14,7 +14,9 @@ import lombok.RequiredArgsConstructor;
|
||||
public enum TradeOrderOperateTypeEnum {
|
||||
|
||||
MEMBER_CREATE(1, "用户下单"),
|
||||
MEMBER_PAY(20, "用户付款成功"),
|
||||
ADMIN_UPDATE_PRICE(2, "订单价格 {oldPayPrice} 修改,实际支付金额为 {newPayPrice} 元"),
|
||||
MEMBER_PAY(10, "用户付款成功"),
|
||||
ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"),
|
||||
MEMBER_RECEIVE(30, "用户已收货"),
|
||||
SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"),
|
||||
MEMBER_COMMENT(33, "用户评价"),
|
||||
|
@ -73,7 +73,7 @@ public class TradeOrderController {
|
||||
|
||||
// 查询订单项
|
||||
List<TradeOrderItemDO> orderItems = tradeOrderQueryService.getOrderItemListByOrderId(id);
|
||||
// orderLog
|
||||
// TODO @puhui999:orderLog
|
||||
// 拼接数据
|
||||
MemberUserRespDTO user = memberUserApi.getUser(order.getUserId());
|
||||
return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, user));
|
||||
@ -120,4 +120,6 @@ public class TradeOrderController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO :核销逻辑
|
||||
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ public class AppTradeOrderController {
|
||||
}
|
||||
|
||||
// TODO @芋艿:如果拼团活动、秒杀活动、砍价活动时,是不是要额外在返回活动之类的信息;
|
||||
// TODO @puhui999:需要的
|
||||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得交易订单")
|
||||
@Parameter(name = "id", description = "交易订单编号")
|
||||
|
@ -2,6 +2,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.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -10,6 +11,7 @@ import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||
import cn.iocoder.yudao.module.member.api.address.AddressApi;
|
||||
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
||||
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
||||
@ -40,6 +42,7 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettle
|
||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO;
|
||||
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
|
||||
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.mysql.order.TradeOrderItemMapper;
|
||||
@ -62,6 +65,7 @@ import cn.iocoder.yudao.module.trade.service.order.handler.TradeOrderHandler;
|
||||
import cn.iocoder.yudao.module.trade.service.price.TradePriceService;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@ -409,6 +413,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CANCEL)
|
||||
public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) {
|
||||
// 1.1 校验并获得交易订单(可发货)
|
||||
TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId());
|
||||
@ -420,8 +425,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
// 2. 更新订单为已发货
|
||||
TradeOrderDO updateOrderObj = new TradeOrderDO();
|
||||
// 2.1 快递发货
|
||||
DeliveryExpressDO express = null;
|
||||
if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL)) {
|
||||
deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId());
|
||||
express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId());
|
||||
updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo());
|
||||
} else {
|
||||
// 2.2 无需发货
|
||||
@ -434,11 +440,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
|
||||
}
|
||||
|
||||
// 发送站内信
|
||||
// 3. 记录订单日志
|
||||
TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus(),
|
||||
MapUtil.<String, Object>builder().put("expressName", express != null ? express.getName() : "")
|
||||
.put("logisticsNo", express != null ? deliveryReqVO.getLogisticsNo() : "").build());
|
||||
|
||||
// 4. 发送站内信
|
||||
tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO().setOrderId(order.getId())
|
||||
.setUserId(order.getUserId()).setMessage(null));
|
||||
|
||||
// TODO 芋艿:OrderLog
|
||||
}
|
||||
|
||||
/**
|
||||
@ -465,6 +474,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
// 订单类类型:砍价
|
||||
if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) {
|
||||
// 校验订单砍价是否成功
|
||||
// TODO @puhui999:砍价的话,应该不用校验。因为是砍价成功后,才可以下单
|
||||
if (!bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) {
|
||||
throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS);
|
||||
}
|
||||
@ -685,86 +695,58 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_PRICE)
|
||||
public void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO) {
|
||||
// 1、校验交易订单
|
||||
// 1.1 校验交易订单
|
||||
TradeOrderDO order = validateOrderExists(reqVO.getId());
|
||||
if (order.getPayStatus()) {
|
||||
throw exception(ORDER_UPDATE_PRICE_FAIL_PAID);
|
||||
}
|
||||
// 2、校验订单项
|
||||
List<TradeOrderItemDO> items = tradeOrderItemMapper.selectListByOrderId(order.getId());
|
||||
if (CollUtil.isEmpty(items)) {
|
||||
throw exception(ORDER_UPDATE_PRICE_FAIL_NOT_ITEM);
|
||||
// 1.2 校验调价金额是否变化
|
||||
if (order.getAdjustPrice() > 0) {
|
||||
throw exception(ORDER_UPDATE_PRICE_FAIL_ALREADY);
|
||||
}
|
||||
// 3、校验调价金额是否变化
|
||||
if (ObjectUtil.equal(order.getAdjustPrice(), reqVO.getAdjustPrice())) {
|
||||
throw exception(ORDER_UPDATE_PRICE_FAIL_EQUAL);
|
||||
// 1.3 支付价格不能为 0
|
||||
int newPayPrice = order.getPayPrice() + order.getAdjustPrice();
|
||||
if (newPayPrice <= 0) {
|
||||
throw exception(ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR);
|
||||
}
|
||||
|
||||
// 4、更新订单
|
||||
TradeOrderDO update = new TradeOrderDO();
|
||||
update.setId(order.getId());
|
||||
update.setAdjustPrice(reqVO.getAdjustPrice());
|
||||
int orderPayPrice = order.getAdjustPrice() != null ? (order.getPayPrice() - order.getAdjustPrice())
|
||||
+ reqVO.getAdjustPrice() : order.getPayPrice() + reqVO.getAdjustPrice();
|
||||
update.setPayPrice(orderPayPrice);
|
||||
tradeOrderMapper.updateById(update);
|
||||
// TODO @芋艿:改价时,赠送的积分,要不要做改动???
|
||||
// 2. 更新订单
|
||||
tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId())
|
||||
.setAdjustPrice(reqVO.getAdjustPrice()).setPayPrice(newPayPrice));
|
||||
|
||||
// 5、更新 TradeOrderItem
|
||||
// TradeOrderItemDO 需要做 adjustPrice 的分摊
|
||||
List<Integer> dividePrices = dividePrice(items, orderPayPrice);
|
||||
// 3. 更新 TradeOrderItem,需要做 adjustPrice 的分摊
|
||||
List<TradeOrderItemDO> orderOrderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
|
||||
List<Integer> dividePrices = TradePriceCalculatorHelper.dividePrice2(orderOrderItems, newPayPrice);
|
||||
List<TradeOrderItemDO> updateItems = new ArrayList<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
TradeOrderItemDO item = items.get(i);
|
||||
Integer adjustPrice = item.getPrice() - dividePrices.get(i); // 计算调整的金额
|
||||
updateItems.add(new TradeOrderItemDO().setId(item.getId()).setAdjustPrice(adjustPrice)
|
||||
.setPayPrice(item.getPayPrice() - adjustPrice));
|
||||
for (int i = 0; i < orderOrderItems.size(); i++) {
|
||||
TradeOrderItemDO item = orderOrderItems.get(i);
|
||||
updateItems.add(new TradeOrderItemDO().setId(item.getId()).setAdjustPrice(dividePrices.get(i))
|
||||
.setPayPrice(item.getPayPrice() + dividePrices.get(i)));
|
||||
}
|
||||
tradeOrderItemMapper.updateBatch(updateItems);
|
||||
|
||||
// 6、更新支付订单
|
||||
payOrderApi.updatePayOrderPrice(order.getPayOrderId(), update.getPayPrice());
|
||||
}
|
||||
// 4. 更新支付订单
|
||||
payOrderApi.updatePayOrderPrice(order.getPayOrderId(), newPayPrice);
|
||||
|
||||
/**
|
||||
* 计算订单调价价格分摊
|
||||
*
|
||||
* @param items 订单项
|
||||
* @param orderPayPrice 订单支付金额
|
||||
* @return 分摊金额数组,和传入的 orderItems 一一对应
|
||||
*/
|
||||
private List<Integer> dividePrice(List<TradeOrderItemDO> items, Integer orderPayPrice) {
|
||||
Integer total = getSumValue(items, TradeOrderItemDO::getPrice, Integer::sum);
|
||||
assert total != null;
|
||||
// 遍历每一个,进行分摊
|
||||
List<Integer> prices = new ArrayList<>(items.size());
|
||||
int remainPrice = orderPayPrice;
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
TradeOrderItemDO orderItem = items.get(i);
|
||||
int partPrice;
|
||||
if (i < items.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减
|
||||
partPrice = (int) (orderPayPrice * (1.0D * orderItem.getPayPrice() / total));
|
||||
remainPrice -= partPrice;
|
||||
} else {
|
||||
partPrice = remainPrice;
|
||||
}
|
||||
Assert.isTrue(partPrice >= 0, "分摊金额必须大于等于 0");
|
||||
prices.add(partPrice);
|
||||
}
|
||||
return prices;
|
||||
// 5. 记录订单日志
|
||||
TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus(),
|
||||
MapUtil.<String, Object>builder().put("oldPayPrice", MoneyUtils.fenToYuanStr(order.getPayPrice()))
|
||||
.put("newPayPrice", MoneyUtils.fenToYuanStr(newPayPrice)).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) {
|
||||
// 校验交易订单
|
||||
validateOrderExists(reqVO.getId());
|
||||
// TODO 是否需要校验订单是否发货
|
||||
// TODO @puhui999:是否需要校验订单是否发货
|
||||
// TODO 发货后是否支持修改收货地址
|
||||
|
||||
// 更新
|
||||
TradeOrderDO update = TradeOrderConvert.INSTANCE.convert(reqVO);
|
||||
tradeOrderMapper.updateById(update);
|
||||
tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO));
|
||||
|
||||
// TODO @puhui999:操作日志
|
||||
}
|
||||
|
||||
// =================== Order Item ===================
|
||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
|
||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||
@ -232,6 +233,36 @@ public class TradePriceCalculatorHelper {
|
||||
return prices;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算订单调价价格分摊
|
||||
*
|
||||
* 和 {@link #dividePrice(List, Integer)} 逻辑一致,只是传入的是 TradeOrderItemDO 对象
|
||||
*
|
||||
* @param items 订单项
|
||||
* @param price 订单支付金额
|
||||
* @return 分摊金额数组,和传入的 orderItems 一一对应
|
||||
*/
|
||||
public static List<Integer> dividePrice2(List<TradeOrderItemDO> items, Integer price) {
|
||||
Integer total = getSumValue(items, TradeOrderItemDO::getPrice, Integer::sum);
|
||||
assert total != null;
|
||||
// 遍历每一个,进行分摊
|
||||
List<Integer> prices = new ArrayList<>(items.size());
|
||||
int remainPrice = price;
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
TradeOrderItemDO orderItem = items.get(i);
|
||||
int partPrice;
|
||||
if (i < items.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减
|
||||
partPrice = (int) (price * (1.0D * orderItem.getPayPrice() / total));
|
||||
remainPrice -= partPrice;
|
||||
} else {
|
||||
partPrice = remainPrice;
|
||||
}
|
||||
Assert.isTrue(partPrice >= 0, "分摊金额必须大于等于 0");
|
||||
prices.add(partPrice);
|
||||
}
|
||||
return prices;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加【匹配】单个 OrderItem 的营销明细
|
||||
*
|
||||
|
@ -38,7 +38,7 @@ public class KdNiaoExpressClientIntegrationTest {
|
||||
public void testGetExpressTrackList() {
|
||||
ExpressTrackQueryReqDTO reqDTO = new ExpressTrackQueryReqDTO();
|
||||
reqDTO.setExpressCode("STO");
|
||||
reqDTO.setLogisticsNo("663220402764314");
|
||||
reqDTO.setLogisticsNo("777168349863987");
|
||||
List<ExpressTrackRespDTO> tracks = client.getExpressTrackList(reqDTO);
|
||||
System.out.println(JsonUtils.toJsonPrettyString(tracks));
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ spring:
|
||||
# Quartz 配置项,对应 QuartzProperties 配置类
|
||||
spring:
|
||||
quartz:
|
||||
auto-startup: false # 本地开发环境,尽量不要开启 Job
|
||||
auto-startup: true # 本地开发环境,尽量不要开启 Job
|
||||
scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName
|
||||
job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。
|
||||
wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true
|
||||
|
Loading…
Reference in New Issue
Block a user