diff --git a/sql/mysql/brokerage.sql b/sql/mysql/brokerage.sql
index 179bfcda0..797f2563a 100644
--- a/sql/mysql/brokerage.sql
+++ b/sql/mysql/brokerage.sql
@@ -1,24 +1,28 @@
-- 增加配置表
-create table trade_config
+CREATE TABLE trade_config
(
- id bigint auto_increment comment '自增主键' primary key,
- brokerage_enabled bit default 1 not null comment '是否启用分佣',
- brokerage_enabled_condition tinyint default 0 not null comment '分佣模式:1-人人分销 2-指定分销',
- brokerage_bind_mode tinyint default 0 not null comment '分销关系绑定模式: 1-没有推广人,2-新用户, 3-扫码覆盖',
- brokerage_post_urls varchar(2000) default '' null comment '分销海报图地址数组',
- brokerage_first_percent int default 0 not null comment '一级返佣比例',
- brokerage_second_percent int default 0 not null comment '二级返佣比例',
- brokerage_withdraw_min_price int default 0 not null comment '用户提现最低金额',
- brokerage_bank_names varchar(200) default '' not null comment '提现银行(字典类型=brokerage_bank_name)',
- brokerage_frozen_days int default 7 not null comment '佣金冻结时间(天)',
- brokerage_withdraw_type varchar(32) default '1,2,3,4' not null comment '提现方式:1-钱包;2-银行卡;3-微信;4-支付宝',
- creator varchar(64) default '' null comment '创建者',
- create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
- updater varchar(64) default '' null comment '更新者',
- update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
- deleted bit default b'0' not null comment '是否删除',
- tenant_id bigint default 0 not null comment '租户编号'
-) comment '交易中心配置';
+ id BIGINT AUTO_INCREMENT COMMENT '自增主键' PRIMARY KEY,
+ brokerage_enabled BIT DEFAULT 1 NOT NULL COMMENT '是否启用分佣',
+ brokerage_enabled_condition TINYINT DEFAULT 1 NOT NULL COMMENT '分佣模式:1-人人分销 2-指定分销',
+ brokerage_bind_mode TINYINT DEFAULT 1 NOT NULL COMMENT '分销关系绑定模式: 1-没有推广人,2-新用户, 3-扫码覆盖',
+ brokerage_poster_urls VARCHAR(2000) DEFAULT '' NULL COMMENT '分销海报图地址数组',
+ brokerage_first_percent INT DEFAULT 0 NOT NULL COMMENT '一级返佣比例',
+ brokerage_second_percent INT DEFAULT 0 NOT NULL COMMENT '二级返佣比例',
+ brokerage_withdraw_min_price INT DEFAULT 0 NOT NULL COMMENT '用户提现最低金额',
+ brokerage_withdraw_fee_percent INT DEFAULT 0 NOT NULL COMMENT '提现手续费百分比',
+ brokerage_bank_names VARCHAR(200) DEFAULT '' NOT NULL COMMENT '提现银行(字典类型=brokerage_bank_name)',
+ brokerage_frozen_days INT DEFAULT 7 NOT NULL COMMENT '佣金冻结时间(天)',
+ brokerage_withdraw_types VARCHAR(32) DEFAULT '1,2,3,4' NOT NULL COMMENT '提现方式:1-钱包;2-银行卡;3-微信;4-支付宝',
+ creator VARCHAR(64) DEFAULT '' NULL COMMENT '创建者',
+ create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间',
+ updater VARCHAR(64) DEFAULT '' NULL COMMENT '更新者',
+ update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ deleted BIT DEFAULT b'0' NOT NULL COMMENT '是否删除',
+ tenant_id BIGINT DEFAULT 0 NOT NULL COMMENT '租户编号'
+) COMMENT '交易中心配置';
+
+# alter table trade_config
+# add brokerage_withdraw_fee_percent int default 0 not null comment '提现手续费百分比' after brokerage_withdraw_min_price;
# alter table trade_brokerage_user
# add level int not null default 1 comment '等级' after frozen_price;
@@ -36,8 +40,6 @@ create table trade_brokerage_user
brokerage_time datetime null comment '成为分销员时间',
price int default 0 not null comment '可用佣金',
frozen_price int default 0 not null comment '冻结佣金',
- level int default 1 not null comment '等级',
- path varchar(2000) null comment '路径',
creator varchar(64) default '' null comment '创建者',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
updater varchar(64) default '' null comment '更新者',
@@ -83,7 +85,7 @@ create index idx_status on trade_brokerage_record (status) comment '状态';
create table trade_brokerage_withdraw
(
- id int auto_increment comment '编号'
+ id bigint auto_increment comment '编号'
primary key,
user_id bigint not null comment '用户编号',
price int default 0 not null comment '提现金额',
@@ -137,7 +139,8 @@ insert into system_dict_type(type, name)
values ('brokerage_record_biz_type', '佣金记录业务类型');
insert into system_dict_data(dict_type, label, value, sort)
values ('brokerage_record_biz_type', '订单返佣', 1, 1),
- ('brokerage_record_biz_type', '申请提现', 2, 2);
+ ('brokerage_record_biz_type', '申请提现', 2, 2),
+ ('brokerage_record_biz_type', '申请提现驳回', 3, 3);
insert into system_dict_type(type, name)
values ('brokerage_record_status', '佣金记录状态');
diff --git a/sql/mysql/point.sql b/sql/mysql/point.sql
new file mode 100644
index 000000000..44123ea1b
--- /dev/null
+++ b/sql/mysql/point.sql
@@ -0,0 +1,6 @@
+ALTER TABLE trade_order ADD COLUMN use_point int NOT NULL DEFAULT 0 COMMENT '使用的积分' AFTER point_price;
+ALTER TABLE trade_order ADD COLUMN refund_point int NOT NULL DEFAULT 0 COMMENT '退还的使用积分' AFTER use_point;
+ALTER TABLE trade_order ADD COLUMN give_point int NOT NULL DEFAULT 0 COMMENT '赠送的积分' AFTER refund_point;
+
+ALTER TABLE trade_order_item ADD COLUMN use_point int NOT NULL DEFAULT 0 COMMENT '使用的积分' AFTER point_price;
+ALTER TABLE trade_order_item ADD COLUMN give_point int NOT NULL DEFAULT 0 COMMENT '赠送的积分' AFTER use_point;
diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
index 275e9f5a1..414c0af7d 100644
--- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
+++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
@@ -43,17 +43,6 @@ public class LocalDateTimeUtils {
return LocalDateTime.of(year, mouth, day, 0, 0, 0);
}
- /**
- * 创建指定时间
- *
- * @param timeStr 时间字符串
- * @return 指定时间
- */
- public static LocalDateTime buildTime(String timeStr) {
- // TODO @puhui999:这个方法的实现,和 LocalDateTimeUtil.parse() 的差异点是啥呀
- return LocalDateTime.of(LocalDate.now(), LocalTime.parse(timeStr));
- }
-
public static LocalDateTime[] buildBetweenTime(int year1, int mouth1, int day1,
int year2, int mouth2, int day2) {
return new LocalDateTime[]{buildTime(year1, mouth1, day1), buildTime(year2, mouth2, day2)};
diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/MoneyUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/MoneyUtils.java
index e2fd3fa6e..e0b739920 100644
--- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/MoneyUtils.java
+++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/MoneyUtils.java
@@ -1,5 +1,6 @@
package cn.iocoder.yudao.framework.common.util.number;
+import cn.hutool.core.math.Money;
import cn.hutool.core.util.NumberUtil;
import java.math.BigDecimal;
@@ -16,7 +17,7 @@ public class MoneyUtils {
* 计算百分比金额,四舍五入
*
* @param price 金额
- * @param rate 百分比,例如说 56.77% 则传入 56.77
+ * @param rate 百分比,例如说 56.77% 则传入 56.77
* @return 百分比金额
*/
public static Integer calculateRatePrice(Integer price, Double rate) {
@@ -27,24 +28,46 @@ public class MoneyUtils {
* 计算百分比金额,向下传入
*
* @param price 金额
- * @param rate 百分比,例如说 56.77% 则传入 56.77
+ * @param rate 百分比,例如说 56.77% 则传入 56.77
* @return 百分比金额
*/
public static Integer calculateRatePriceFloor(Integer price, Double rate) {
return calculateRatePrice(price, rate, 0, RoundingMode.FLOOR).intValue();
}
- /**
- * 计算百分比金额
- *
- * @param price 金额
- * @param rate 百分比,例如说 56.77% 则传入 56.77
- * @param scale 保留小数位数
- * @param roundingMode 舍入模式
- */
- public static BigDecimal calculateRatePrice(Number price, Number rate, int scale, RoundingMode roundingMode) {
- return NumberUtil.toBigDecimal(price).multiply(NumberUtil.toBigDecimal(rate)) // 乘以
- .divide(BigDecimal.valueOf(100), scale, roundingMode); // 除以 100
- }
+ /**
+ * 计算百分比金额
+ *
+ * @param price 金额
+ * @param rate 百分比,例如说 56.77% 则传入 56.77
+ * @param scale 保留小数位数
+ * @param roundingMode 舍入模式
+ */
+ public static BigDecimal calculateRatePrice(Number price, Number rate, int scale, RoundingMode roundingMode) {
+ return NumberUtil.toBigDecimal(price).multiply(NumberUtil.toBigDecimal(rate)) // 乘以
+ .divide(BigDecimal.valueOf(100), scale, roundingMode); // 除以 100
+ }
+
+ /**
+ * 分转元
+ *
+ * @param fen 分
+ * @return 元
+ */
+ public static BigDecimal fenToYuan(int fen) {
+ return new Money(0, fen).getAmount();
+ }
+
+ /**
+ * 分转元(字符串)
+ *
+ * 例如说 fen 为 1 时,则结果为 0.01
+ *
+ * @param fen 分
+ * @return 元
+ */
+ public static String fenToYuanStr(int fen) {
+ return new Money(0, fen).toString();
+ }
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-error-code/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-error-code/pom.xml
index ff3c32d97..06e41c1eb 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-error-code/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-biz-error-code/pom.xml
@@ -14,7 +14,7 @@
${project.artifactId}
错误码 ErrorCode 的自动配置功能,提供如下功能:
- 1. 远程读取:项目启动时,从 system-server 服务,读取数据库中的 ErrorCode 错误码,实现错误码的提水可配置;
+ 1. 远程读取:项目启动时,从 system-server 服务,读取数据库中的 ErrorCode 错误码,实现错误码的提示可配置;
2. 自动更新:管理员在管理后台修数据库中的 ErrorCode 错误码时,项目自动从 system-server 服务加载最新的 ErrorCode 错误码;
3. 自动写入:项目启动时,将项目本地的错误码写到 system-server 服务中,方便管理员在管理后台编辑;
diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java
index 7cfd096a4..a728365e6 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java
+++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java
@@ -100,14 +100,6 @@ public class LambdaQueryWrapperX extends LambdaQueryWrapper {
return betweenIfPresent(column, val1, val2);
}
- // TODO @疯狂:这个是 mysql 独有的,不好做成通用的哈。如果多层级,有没可能先查询一个层级,再查询一个层级;形成 set 后,直接去 in?
- public LambdaQueryWrapperX findInSetIfPresent(SFunction column, Object val) {
- if (val != null) {
- return (LambdaQueryWrapperX) super.apply("FIND_IN_SET({0}, " + columnToString(column) + ")", val);
- }
- return this;
- }
-
// ========== 重写父类方法,方便链式调用 ==========
@Override
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java
index 56f9aeaa6..40b446b28 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/jackson/config/YudaoJacksonAutoConfiguration.java
@@ -1,18 +1,24 @@
package cn.iocoder.yudao.framework.jackson.config;
-import cn.iocoder.yudao.framework.jackson.core.databind.NumberSerializer;
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.jackson.core.databind.LocalDateTimeDeserializer;
import cn.iocoder.yudao.framework.jackson.core.databind.LocalDateTimeSerializer;
-import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import cn.iocoder.yudao.framework.jackson.core.databind.NumberSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
+import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.LocalTime;
@AutoConfiguration
@Slf4j
@@ -36,6 +42,10 @@ public class YudaoJacksonAutoConfiguration {
simpleModule
.addSerializer(Long.class, NumberSerializer.INSTANCE)
.addSerializer(Long.TYPE, NumberSerializer.INSTANCE)
+ .addSerializer(LocalDate.class, LocalDateSerializer.INSTANCE)
+ .addDeserializer(LocalDate.class, LocalDateDeserializer.INSTANCE)
+ .addSerializer(LocalTime.class, LocalTimeSerializer.INSTANCE)
+ .addDeserializer(LocalTime.class, LocalTimeDeserializer.INSTANCE)
.addSerializer(LocalDateTime.class, LocalDateTimeSerializer.INSTANCE)
.addDeserializer(LocalDateTime.class, LocalDateTimeDeserializer.INSTANCE);
diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java
index ab93431f4..cad6bfcb2 100644
--- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java
+++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java
@@ -110,6 +110,11 @@ public class ProductSpuRespDTO {
// ========== 物流相关字段 =========
+ /**
+ * 赠送积分
+ */
+ private Integer giveIntegral;
+
/**
* 物流配置模板编号
*
@@ -132,4 +137,15 @@ public class ProductSpuRespDTO {
*/
private Integer clickCount;
+
+ // ========== 分销相关字段 =========
+
+ /**
+ * 分销类型
+ *
+ * false - 默认
+ * true - 自行设置
+ */
+ private Boolean subCommissionType;
+
}
diff --git a/yudao-module-mall/yudao-module-product-biz/pom.xml b/yudao-module-mall/yudao-module-product-biz/pom.xml
index 674f49fc4..f6190ceda 100644
--- a/yudao-module-mall/yudao-module-product-biz/pom.xml
+++ b/yudao-module-mall/yudao-module-product-biz/pom.xml
@@ -23,12 +23,6 @@
yudao-module-product-api
${revision}
-
-
- cn.iocoder.boot
- yudao-module-trade-api
- ${revision}
-
cn.iocoder.boot
yudao-module-member-api
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApiImpl.java
index 9aab9e560..d3eaaf42d 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApiImpl.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApiImpl.java
@@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.product.api.property;
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
-import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
+import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java
index fbac32712..54ce881d1 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java
@@ -1,14 +1,12 @@
package cn.iocoder.yudao.module.product.controller.admin.property;
-import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.crypto.symmetric.AES;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
-import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
+import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -20,9 +18,6 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
-import java.util.Arrays;
-import java.util.List;
-
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 商品属性值")
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
index 5d79ba7d1..3c9d8f8be 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
@@ -1,10 +1,15 @@
package cn.iocoder.yudao.module.product.controller.app.spu;
+import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
+import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
+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.controller.app.spu.vo.AppProductSpuDetailRespVO;
-import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
+import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO;
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
@@ -23,10 +28,12 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
+import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
@@ -41,6 +48,11 @@ public class AppProductSpuController {
@Resource
private ProductSkuService productSkuService;
+ @Resource
+ private MemberLevelApi memberLevelApi;
+ @Resource
+ private MemberUserApi memberUserApi;
+
@GetMapping("/list")
@Operation(summary = "获得商品 SPU 列表")
@Parameters({
@@ -51,14 +63,32 @@ public class AppProductSpuController {
@RequestParam("recommendType") String recommendType,
@RequestParam(value = "count", defaultValue = "10") Integer count) {
List list = productSpuService.getSpuList(recommendType, count);
- return success(ProductSpuConvert.INSTANCE.convertListForGetSpuList(list));
+ if (CollUtil.isEmpty(list)) {
+ return success(Collections.emptyList());
+ }
+
+ // 拼接返回
+ List voList = ProductSpuConvert.INSTANCE.convertListForGetSpuList(list);
+ // 处理 vip 价格
+ MemberLevelRespDTO memberLevel = getMemberLevel();
+ voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
+ return success(voList);
}
@GetMapping("/page")
@Operation(summary = "获得商品 SPU 分页")
public CommonResult> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) {
PageResult pageResult = productSpuService.getSpuPage(pageVO);
- return success(ProductSpuConvert.INSTANCE.convertPageForGetSpuPage(pageResult));
+ if (CollUtil.isEmpty(pageResult.getList())) {
+ return success(PageResult.empty(pageResult.getTotal()));
+ }
+
+ // 拼接返回
+ PageResult voPageResult = ProductSpuConvert.INSTANCE.convertPageForGetSpuPage(pageResult);
+ // 处理 vip 价格
+ MemberLevelRespDTO memberLevel = getMemberLevel();
+ voPageResult.getList().forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
+ return success(voPageResult);
}
@GetMapping("/get-detail")
@@ -74,10 +104,40 @@ public class AppProductSpuController {
throw exception(SPU_NOT_ENABLE);
}
- // 查询商品 SKU
+ // 拼接返回
List skus = productSkuService.getSkuListBySpuId(spu.getId());
- // 拼接
- return success(ProductSpuConvert.INSTANCE.convertForGetSpuDetail(spu, skus));
+ AppProductSpuDetailRespVO detailVO = ProductSpuConvert.INSTANCE.convertForGetSpuDetail(spu, skus);
+ // 处理 vip 价格
+ MemberLevelRespDTO memberLevel = getMemberLevel();
+ detailVO.setVipPrice(calculateVipPrice(detailVO.getPrice(), memberLevel));
+ return success(detailVO);
+ }
+
+ private MemberLevelRespDTO getMemberLevel() {
+ Long userId = getLoginUserId();
+ if (userId == null) {
+ return null;
+ }
+ MemberUserRespDTO user = memberUserApi.getUser(userId);
+ if (user.getLevelId() == null || user.getLevelId() <= 0) {
+ return null;
+ }
+ return memberLevelApi.getMemberLevel(user.getLevelId());
+ }
+
+ /**
+ * 计算会员 VIP 优惠价格
+ *
+ * @param price 原价
+ * @param memberLevel 会员等级
+ * @return 优惠价格
+ */
+ public Integer calculateVipPrice(Integer price, MemberLevelRespDTO memberLevel) {
+ if (memberLevel == null || memberLevel.getDiscountPercent() == null) {
+ return 0;
+ }
+ Integer newPrice = price * memberLevel.getDiscountPercent() / 100;
+ return price - newPrice;
}
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/ProductPropertyValueConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyValueConvert.java
similarity index 97%
rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/ProductPropertyValueConvert.java
rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyValueConvert.java
index d6167c174..5429f35fe 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/ProductPropertyValueConvert.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyValueConvert.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.product.convert.propertyvalue;
+package cn.iocoder.yudao.module.product.convert.property;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
index 6d52e5cad..e8e6a8bc1 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
@@ -79,8 +79,6 @@ public interface ProductSpuConvert {
ProductSpuDO spu = list.get(i);
AppProductSpuPageRespVO spuVO = voList.get(i);
spuVO.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
- // 计算 vip 价格 TODO 芋艿:临时的逻辑,等 vip 支持后
- spuVO.setVipPrice((int) (spuVO.getPrice() * 0.9));
}
return voList;
}
@@ -95,11 +93,6 @@ public interface ProductSpuConvert {
.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
// 处理 SKU
spuVO.setSkus(convertListForGetSpuDetail(skus));
- // 计算 vip 价格 TODO 芋艿:临时的逻辑,等 vip 支持后
- if (true) {
- spuVO.setVipPrice((int) (spuVO.getPrice() * 0.9));
- spuVO.getSkus().forEach(sku -> sku.setVipPrice((int) (sku.getPrice() * 0.9)));
- }
return spuVO;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java
index 905bb890b..9e073fee7 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java
@@ -179,6 +179,7 @@ public class ProductSpuDO extends BaseDO {
@TableField(typeHandler = JacksonTypeHandler.class)
private List giveCouponTemplateIds;
+ // TODO @puhui999:字段估计要改成 brokerageType
/**
* 分销类型
*
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java
index 01967857e..e32942933 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java
@@ -1,5 +1,5 @@
/**
- * trade 模块,主要实现交易相关功能
+ * product 模块,主要实现交易相关功能
* 例如:订单、退款、购物车等功能。
*
* 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java
index 6b4d1e9c8..0f74bca1f 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java
@@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
-import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
+import cn.iocoder.yudao.module.product.convert.property.ProductPropertyValueConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper;
diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java
index eb912e417..0f9812629 100644
--- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java
+++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java
@@ -11,7 +11,7 @@ public interface BargainActivityApi {
* 更新砍价活动库存
*
* @param id 砍价活动编号
- * @param count 购买数量
+ * @param count 购买数量
*/
void updateBargainActivityStock(Long id, Integer count);
diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java
index ebe4bb0e5..11cc22864 100644
--- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java
+++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java
@@ -7,14 +7,13 @@ package cn.iocoder.yudao.module.promotion.api.seckill;
*/
public interface SeckillActivityApi {
- // TODO @puhui999:activityId 改成 id 好点哈;
/**
* 更新秒杀库存
*
- * @param activityId 活动编号
+ * @param id 活动编号
* @param skuId sku 编号
* @param count 数量
*/
- void updateSeckillStock(Long activityId, Long skuId, Integer count);
+ void updateSeckillStock(Long id, Long skuId, Integer count);
}
diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
index c39fbb316..4fc58004a 100644
--- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
+++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
@@ -56,7 +56,6 @@ public interface ErrorCodeConstants {
ErrorCode SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013008004, "秒杀活动未关闭或未结束,不能删除");
ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1013008005, "秒杀活动已关闭,不能重复关闭");
ErrorCode SECKILL_ACTIVITY_UPDATE_STOCK_FAIL = new ErrorCode(1013008006, "秒杀失败,原因秒杀库存不足");
- ErrorCode SECKILL_ACTIVITY_FAIL_STATUS_CLOSED = new ErrorCode(1013008007, "秒杀活动已关闭");
// ========== 秒杀时段 1013009000 ==========
ErrorCode SECKILL_CONFIG_NOT_EXISTS = new ErrorCode(1013009000, "秒杀时段不存在");
diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java
index 874651ea3..009781c5c 100644
--- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java
+++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java
@@ -22,8 +22,9 @@ public enum PromotionTypeEnum implements IntArrayValuable {
DISCOUNT_ACTIVITY(4, "限时折扣"),
REWARD_ACTIVITY(5, "满减送"),
- MEMBER(6, "会员折扣"),
- COUPON(7, "优惠劵")
+ MEMBER_LEVEL(6, "会员折扣"),
+ COUPON(7, "优惠劵"),
+ POINT(8, "积分")
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray();
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java
index 624af86c6..9a15a0ca9 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java
@@ -17,8 +17,8 @@ public class SeckillActivityApiImpl implements SeckillActivityApi {
private SeckillActivityService activityService;
@Override
- public void updateSeckillStock(Long activityId, Long skuId, Integer count) {
- activityService.updateSeckillStock(activityId, skuId, count);
+ public void updateSeckillStock(Long id, Long skuId, Integer count) {
+ activityService.updateSeckillStock(id, skuId, count);
}
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java
index 72facf935..a996b4521 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java
@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
+import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@@ -39,7 +40,7 @@ public class AppBargainActivityController {
@GetMapping("/page")
@Operation(summary = "获得砍价活动分页")
public CommonResult> getBargainActivityPage(PageParam pageReqVO) {
- PageResult result = bargainActivityService.getBargainActivityPageForApp(pageReqVO);
+ PageResult result = bargainActivityService.getBargainActivityPage(pageReqVO);
if (CollUtil.isEmpty(result.getList())) {
return success(PageResult.empty(result.getTotal()));
}
@@ -54,7 +55,7 @@ public class AppBargainActivityController {
@Parameter(name = "count", description = "需要展示的数量", example = "6")
public CommonResult> getBargainActivityList(
@RequestParam(name = "count", defaultValue = "6") Integer count) {
- List list = bargainActivityService.getBargainActivityListForApp(count);
+ List list = bargainActivityService.getBargainActivityListByCount(defaultIfNull(count, 6));
if (CollUtil.isEmpty(list)) {
return success(BargainActivityConvert.INSTANCE.convertAppList(list));
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java
index 75693f90b..ee1d5ed17 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java
@@ -1,10 +1,19 @@
package cn.iocoder.yudao.module.promotion.controller.app.combination;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
+import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO;
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO;
+import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
+import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
+import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
+import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -14,11 +23,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
+import javax.annotation.Resource;
+import java.util.Collections;
import java.util.List;
+import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@Tag(name = "用户 APP - 拼团活动")
@RestController
@@ -26,104 +37,51 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class AppCombinationActivityController {
+ @Resource
+ private CombinationActivityService activityService;
+ @Resource
+ private ProductSpuApi spuApi;
+
+ // TODO 芋艿:增加 Spring Cache
@GetMapping("/list")
@Operation(summary = "获得拼团活动列表", description = "用于小程序首页")
- // TODO 芋艿:增加 Spring Cache
- // TODO 芋艿:缺少 swagger 注解
+ @Parameter(name = "count", description = "需要展示的数量", example = "6")
public CommonResult> getCombinationActivityList(
@RequestParam(name = "count", defaultValue = "6") Integer count) {
- List activityList = new ArrayList<>();
- AppCombinationActivityRespVO activity1 = new AppCombinationActivityRespVO();
- activity1.setId(1L);
- activity1.setName("618 大拼团");
- activity1.setUserSize(3);
- activity1.setSpuId(2048L);
- activity1.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
- activity1.setMarketPrice(50);
- activity1.setCombinationPrice(100);
- activityList.add(activity1);
-
- AppCombinationActivityRespVO activity2 = new AppCombinationActivityRespVO();
- activity2.setId(2L);
- activity2.setName("双十一拼团");
- activity2.setUserSize(5);
- activity2.setSpuId(4096L);
- activity2.setPicUrl("https://static.iocoder.cn/mall/132.jpeg");
- activity2.setMarketPrice(100);
- activity2.setCombinationPrice(200);
- activityList.add(activity2);
-
- return success(activityList);
+ List list = activityService.getCombinationActivityListByCount(defaultIfNull(count, 6));
+ if (CollUtil.isEmpty(list)) {
+ return success(Collections.emptyList());
+ }
+ // 拼接返回
+ List spuList = spuApi.getSpuList(convertList(list, CombinationActivityDO::getSpuId));
+ return success(CombinationActivityConvert.INSTANCE.convertAppList(list, spuList));
}
@GetMapping("/page")
@Operation(summary = "获得拼团活动分页")
public CommonResult> getCombinationActivityPage(PageParam pageParam) {
- List activityList = new ArrayList<>();
- AppCombinationActivityRespVO activity1 = new AppCombinationActivityRespVO();
- activity1.setId(1L);
- activity1.setName("618 大拼团");
- activity1.setUserSize(3);
- activity1.setSpuId(2048L);
- activity1.setPicUrl("商品图片地址");
- activity1.setMarketPrice(50);
- activity1.setCombinationPrice(100);
- activityList.add(activity1);
-
- AppCombinationActivityRespVO activity2 = new AppCombinationActivityRespVO();
- activity2.setId(2L);
- activity2.setName("双十一拼团");
- activity2.setUserSize(5);
- activity2.setSpuId(4096L);
- activity2.setPicUrl("商品图片地址");
- activity2.setMarketPrice(100);
- activity2.setCombinationPrice(200);
- activityList.add(activity2);
-
- return success(new PageResult<>(activityList, 2L));
+ PageResult result = activityService.getCombinationActivityPage(pageParam);
+ if (CollUtil.isEmpty(result.getList())) {
+ return success(PageResult.empty(result.getTotal()));
+ }
+ // 拼接返回
+ List spuList = spuApi.getSpuList(convertList(result.getList(), CombinationActivityDO::getSpuId));
+ return success(CombinationActivityConvert.INSTANCE.convertAppPage(result, spuList));
}
@GetMapping("/get-detail")
@Operation(summary = "获得拼团活动明细")
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
public CommonResult getCombinationActivityDetail(@RequestParam("id") Long id) {
- // TODO 芋艿:如果禁用的时候,需要抛出异常;
- AppCombinationActivityDetailRespVO obj = new AppCombinationActivityDetailRespVO();
- // 设置其属性的值
- obj.setId(id);
- obj.setName("晚九点限时秒杀");
- obj.setStatus(1);
- obj.setStartTime(LocalDateTime.of(2023, 6, 15, 0, 0, 0));
- obj.setEndTime(LocalDateTime.of(2023, 6, 20, 23, 59, 0));
- obj.setUserSize(2);
- obj.setSuccessCount(100);
- obj.setSpuId(633L);
- obj.setSingleLimitCount(2);
- obj.setTotalLimitCount(3);
-
- // 创建一个Product对象的列表
- List productList = new ArrayList<>();
- // 创建三个新的Product对象并设置其属性的值
- AppCombinationActivityDetailRespVO.Product product1 = new AppCombinationActivityDetailRespVO.Product();
- product1.setSkuId(1L);
- product1.setCombinationPrice(100);
- // 将第一个Product对象添加到列表中
- productList.add(product1);
- // 创建第二个Product对象并设置其属性的值
- AppCombinationActivityDetailRespVO.Product product2 = new AppCombinationActivityDetailRespVO.Product();
- product2.setSkuId(2L);
- product2.setCombinationPrice(200);
- // 将第二个Product对象添加到列表中
- productList.add(product2);
- // 创建第三个Product对象并设置其属性的值
- AppCombinationActivityDetailRespVO.Product product3 = new AppCombinationActivityDetailRespVO.Product();
- product3.setSkuId(3L);
- product3.setCombinationPrice(300);
- // 将第三个Product对象添加到列表中
- productList.add(product3);
- // 将Product列表设置为对象的属性值
- obj.setProducts(productList);
- return success(obj);
+ // 1、获取活动
+ CombinationActivityDO combinationActivity = activityService.getCombinationActivity(id);
+ if (combinationActivity == null
+ || ObjectUtil.equal(combinationActivity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
+ return success(null);
+ }
+ // 2、获取活动商品
+ List products = activityService.getCombinationProductsByActivityId(combinationActivity.getId());
+ return success(CombinationActivityConvert.INSTANCE.convert3(combinationActivity, products));
}
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java
index b536e8abe..64462a377 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java
@@ -28,7 +28,6 @@ public class AppCombinationActivityRespVO {
private Integer marketPrice;
@Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
- // 从拼团商品里取最低价
private Integer combinationPrice;
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java
index 66aa3bd97..a83b87ae2 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java
@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.controller.app.seckill;
+import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
@@ -27,14 +28,10 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
-import java.util.Arrays;
import java.util.List;
-import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
-import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween;
-import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_ACTIVITY_FAIL_STATUS_CLOSED;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@Tag(name = "用户 App - 秒杀活动")
@RestController
@@ -50,27 +47,21 @@ public class AppSeckillActivityController {
@Resource
private ProductSpuApi spuApi;
- @GetMapping("/get-now")
- @Operation(summary = "获得当前秒杀活动") // 提供给首页使用
// TODO 芋艿:需要增加 spring cache
+ @GetMapping("/get-now")
+ @Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用")
public CommonResult getNowSeckillActivity() {
// 1. 获取当前时间处在哪个秒杀阶段
- // TODO @puhui999:可以考虑在 service 写个方法;这样 controller 不用关注过多逻辑
- List configList = configService.getSeckillConfigList();
- SeckillConfigDO filteredConfig = findFirst(configList, config -> ObjectUtil.equal(config.getStatus(),
- CommonStatusEnum.ENABLE.getStatus()) && isBetween(config.getStartTime(), config.getEndTime()));
- if (filteredConfig == null) { // 时段不存在直接返回 null
+ SeckillConfigDO configList = configService.getSeckillConfigListByStatusOnCurrentTime(CommonStatusEnum.ENABLE.getStatus());
+ if (configList == null) { // 时段不存在直接返回 null
return success(null);
}
// 2. 查询满足当前阶段的活动
- // TODO @puhui999:最好直接返回开启的;不多查询数据
- List activityList = activityService.getSeckillActivityListByConfigIds(Arrays.asList(filteredConfig.getId()));
- List filteredList = filterList(activityList, item -> ObjectUtil.equal(item.getStatus(), CommonStatusEnum.ENABLE.getStatus()));
-
- // 3. 拼接数据
- List spuList = spuApi.getSpuList(convertList(filteredList, SeckillActivityDO::getSpuId));
- return success(SeckillActivityConvert.INSTANCE.convert(filteredConfig, filteredList, spuList));
+ List activityList = activityService.getSeckillActivityListByConfigIdAndStatus(configList.getId(), CommonStatusEnum.ENABLE.getStatus());
+ // 3 获取 spu 信息
+ List spuList = spuApi.getSpuList(convertList(activityList, SeckillActivityDO::getSpuId));
+ return success(SeckillActivityConvert.INSTANCE.convert(configList, activityList, spuList));
}
@GetMapping("/page")
@@ -78,7 +69,9 @@ public class AppSeckillActivityController {
public CommonResult> getSeckillActivityPage(AppSeckillActivityPageReqVO pageReqVO) {
// 1. 查询满足当前阶段的活动
PageResult pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO);
-
+ if (CollUtil.isEmpty(pageResult.getList())) {
+ return success(PageResult.empty(pageResult.getTotal()));
+ }
// 2. 拼接数据
List spuList = spuApi.getSpuList(convertList(pageResult.getList(), SeckillActivityDO::getSpuId));
return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult, spuList));
@@ -88,28 +81,22 @@ public class AppSeckillActivityController {
@Operation(summary = "获得秒杀活动明细")
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
public CommonResult getSeckillActivity(@RequestParam("id") Long id) {
- // 1、获取当前时间处在哪个秒杀阶段
- // TODO puhui999:这里,和 58 行是雷同的
- List configList = configService.getSeckillConfigList();
- SeckillConfigDO filteredConfig = findFirst(configList, config -> ObjectUtil.equal(config.getStatus(),
- CommonStatusEnum.ENABLE.getStatus()) && isBetween(config.getStartTime(), config.getEndTime()));
- if (filteredConfig == null) { // 时段不存在直接返回 null
+ // 1. 获取当前时间处在哪个秒杀阶段
+ SeckillConfigDO configList = configService.getSeckillConfigListByStatusOnCurrentTime(CommonStatusEnum.ENABLE.getStatus());
+ if (configList == null) { // 时段不存在直接返回 null
return success(null);
}
// 2. 获取活动
SeckillActivityDO seckillActivity = activityService.getSeckillActivity(id);
- if (seckillActivity == null) {
+ if (seckillActivity == null
+ || ObjectUtil.equal(seckillActivity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
return success(null);
}
- // TODO 芋艿:如果禁用的时候,需要抛出异常;
- if (ObjectUtil.equal(seckillActivity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
- throw exception(SECKILL_ACTIVITY_FAIL_STATUS_CLOSED);
- }
// 3. 拼接数据
- List products = activityService.getSeckillProductListByActivityId(seckillActivity.getId());
- return success(SeckillActivityConvert.INSTANCE.convert3(seckillActivity, products, filteredConfig));
+ List productList = activityService.getSeckillProductListByActivityId(seckillActivity.getId());
+ return success(SeckillActivityConvert.INSTANCE.convert3(seckillActivity, productList, configList));
}
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java
index fc30a2f24..ec60b2141 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java
@@ -1,11 +1,9 @@
package cn.iocoder.yudao.module.promotion.controller.app.seckill;
-import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO;
import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert;
-import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillconfig.SeckillConfigDO;
import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -15,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
-import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -31,13 +28,8 @@ public class AppSeckillConfigController {
@GetMapping("/list")
@Operation(summary = "获得秒杀时间段列表")
public CommonResult> getSeckillConfigList() {
- List list = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus());
- // TODO @puhui999:如果这种,不用判空也问题不大;
- if (CollectionUtil.isEmpty(list)) {
- return success(Collections.emptyList());
- }
-
- return success(SeckillConfigConvert.INSTANCE.convertList2(list));
+ return success(SeckillConfigConvert.INSTANCE.convertList2(
+ configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus())));
}
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java
index 42f5a5ff4..278ee04a1 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java
@@ -25,6 +25,9 @@ public class AppSeckillActivityRespVO {
// 从 SPU 的 marketPrice 读取
private Integer marketPrice;
+ @Schema(description = "秒杀活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+ private Integer status;
+
@Schema(description = "秒杀库存(剩余)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer stock;
@Schema(description = "秒杀库存(总共)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java
index 24297990f..92791ed76 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java
@@ -46,9 +46,7 @@ public interface BargainActivityConvert {
Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
List list = CollectionUtils.convertList(result.getList(), item -> {
findAndThen(spuMap, item.getSpuId(), spu -> {
- // TODO @puhui999:这里可以使用链式哈
- item.setPicUrl(spu.getPicUrl());
- item.setSpuName(spu.getName());
+ item.setPicUrl(spu.getPicUrl()).setSpuName(spu.getName());
});
return item;
});
@@ -75,11 +73,7 @@ public interface BargainActivityConvert {
// 拼接关联属性
Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
List list = CollectionUtils.convertList(result.getList(), item -> {
- findAndThen(spuMap, item.getSpuId(), spu -> {
- // TODO @puhui999:这里可以使用链式哈
- item.setPicUrl(spu.getPicUrl());
- item.setMarketPrice(spu.getMarketPrice());
- });
+ findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
return item;
});
result.setList(list);
@@ -92,11 +86,7 @@ public interface BargainActivityConvert {
List activityList = convertAppList(list);
Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
return CollectionUtils.convertList(activityList, item -> {
- findAndThen(spuMap, item.getSpuId(), spu -> {
- // TODO @puhui999:这里可以使用链式哈
- item.setPicUrl(spu.getPicUrl());
- item.setMarketPrice(spu.getMarketPrice());
- });
+ findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
return item;
});
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
index d95428cd4..f92dbef59 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
@@ -13,6 +13,8 @@ import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activit
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO;
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO;
+import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO;
+import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
@@ -25,6 +27,7 @@ import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
+import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
/**
* 拼团活动 Convert
@@ -58,10 +61,7 @@ public interface CombinationActivityConvert {
Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
PageResult pageResult = convertPage(page);
pageResult.getList().forEach(item -> {
- MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> {
- item.setSpuName(spu.getName());
- item.setPicUrl(spu.getPicUrl());
- });
+ MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()));
item.setProducts(convertList2(productList));
});
return pageResult;
@@ -97,18 +97,51 @@ public interface CombinationActivityConvert {
default CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO,
CombinationActivityDO activity, MemberUserRespDTO user,
ProductSpuRespDTO spu, ProductSkuRespDTO sku) {
- // TODO @puhui999:搞成链式的 set;这样会更规整一点;
- CombinationRecordDO record = convert(reqDTO);
- record.setVirtualGroup(false);
- record.setExpireTime(record.getStartTime().plusHours(activity.getLimitDuration()));
- record.setUserSize(activity.getUserSize());
- record.setNickname(user.getNickname());
- record.setAvatar(user.getAvatar());
- record.setSpuName(spu.getName());
- record.setPicUrl(sku.getPicUrl());
- return record;
+ // TODO @puhui999:订单付款后需要设置开始时间和结束时间;
+ return convert(reqDTO)
+ .setVirtualGroup(false)
+ .setExpireTime(activity.getStartTime().plusHours(activity.getLimitDuration()))
+ .setUserSize(activity.getUserSize())
+ .setNickname(user.getNickname())
+ .setAvatar(user.getAvatar())
+ .setSpuName(spu.getName())
+ .setPicUrl(sku.getPicUrl());
}
List convert(List bean);
+ List convertAppList(List list);
+
+ default List convertAppList(List list, List spuList) {
+ List activityList = convertAppList(list);
+ Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
+ return CollectionUtils.convertList(activityList, item -> {
+ findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
+ return item;
+ });
+ }
+
+ PageResult convertAppPage(PageResult result);
+
+ default PageResult convertAppPage(PageResult result, List spuList) {
+ PageResult appPage = convertAppPage(result);
+ Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
+ List list = CollectionUtils.convertList(appPage.getList(), item -> {
+ findAndThen(spuMap, item.getSpuId(), spu -> {
+ item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice());
+ });
+ return item;
+ });
+ appPage.setList(list);
+ return appPage;
+ }
+
+ AppCombinationActivityDetailRespVO convert2(CombinationActivityDO combinationActivity);
+
+ List convertList1(List products);
+
+ default AppCombinationActivityDetailRespVO convert3(CombinationActivityDO combinationActivity, List products) {
+ return convert2(combinationActivity).setProducts(convertList1(products));
+ }
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java
index e4c4d5e36..e1fcc35d8 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java
@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity;
+import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
@@ -29,7 +30,6 @@ import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
-import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
/**
* 秒杀活动 Convert
@@ -98,10 +98,9 @@ public interface SeckillActivityConvert {
Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
respVO.setActivities(CollectionUtils.convertList(convertList3(activityList), item -> {
findAndThen(spuMap, item.getSpuId(), spu -> {
- // TODO @puhui999:可以尝试链式 set 哈;
- item.setPicUrl(spu.getPicUrl());
- item.setMarketPrice(spu.getMarketPrice());
- item.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
+ item.setPicUrl(spu.getPicUrl())
+ .setMarketPrice(spu.getMarketPrice())
+ .setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
});
return item;
}));
@@ -114,12 +113,8 @@ public interface SeckillActivityConvert {
PageResult result = convertPage1(pageResult);
Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
List list = CollectionUtils.convertList(result.getList(), item -> {
- findAndThen(spuMap, item.getSpuId(), spu -> {
- // TODO @puhui999:可以尝试链式 set 哈;
- item.setPicUrl(spu.getPicUrl());
- item.setMarketPrice(spu.getMarketPrice());
- item.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
- });
+ findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())
+ .setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())));
return item;
});
result.setList(list);
@@ -131,12 +126,13 @@ public interface SeckillActivityConvert {
List convertList1(List products);
default AppSeckillActivityDetailRespVO convert3(SeckillActivityDO seckillActivity, List products, SeckillConfigDO filteredConfig) {
- AppSeckillActivityDetailRespVO respVO = convert2(seckillActivity);
- respVO.setProducts(convertList1(products));
- // TODO @puhui999:可以尝试链式 set 哈;
- respVO.setStartTime(buildTime(filteredConfig.getStartTime()));
- respVO.setEndTime(buildTime(filteredConfig.getEndTime()));
- return respVO;
+ return convert2(seckillActivity)
+ .setProducts(convertList1(products))
+ // TODO @puhui999:要不要在里面 default 一个方法,处理这个事件;简洁一点;
+ .setStartTime(LocalDateTimeUtil.parse(LocalDateTimeUtil.format(seckillActivity.getStartTime(), "yyyy-MM-dd") + " " + filteredConfig.getStartTime(),
+ "yyyy-MM-dd HH:mm:ss")) // 活动开始日期和时段结合
+ .setEndTime(LocalDateTimeUtil.parse(LocalDateTimeUtil.format(seckillActivity.getEndTime(), "yyyy-MM-dd") + " " + filteredConfig.getEndTime(),
+ "yyyy-MM-dd HH:mm:ss")); // 活动结束日期和时段结合
}
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
index f098895d2..de518f60c 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
@@ -38,18 +38,41 @@ public interface BargainActivityMapper extends BaseMapperX {
* @param count 扣减的库存数量
* @return 影响的行数
*/
- default int updateActivityStock(Long id, int count) {
+ default int updateStock(Long id, int count) {
return update(null, new LambdaUpdateWrapper()
.eq(BargainActivityDO::getId, id)
.ge(BargainActivityDO::getStock, count)
.setSql("stock = stock - " + count));
}
- default PageResult selectAppPage(PageParam pageReqVO, Integer status, LocalDateTime now) {
+ /**
+ * 查询处在 now 日期时间且是 status 状态的活动分页
+ *
+ * @param pageReqVO 分页参数
+ * @param status 状态
+ * @param now 当前日期时间
+ * @return 活动分页
+ */
+ default PageResult selectPage(PageParam pageReqVO, Integer status, LocalDateTime now) {
return selectPage(pageReqVO, new LambdaQueryWrapperX()
.eq(BargainActivityDO::getStatus, status)
.le(BargainActivityDO::getStartTime, now)
.ge(BargainActivityDO::getEndTime, now));
}
+ /**
+ * 查询处在 now 日期时间且是 status 状态的活动分页
+ *
+ * @param status 状态
+ * @param now 当前日期时间
+ * @return 活动分页
+ */
+ default List selectList(Integer count, Integer status, LocalDateTime now) {
+ return selectList(new LambdaQueryWrapperX()
+ .eq(BargainActivityDO::getStatus, status)
+ .le(BargainActivityDO::getStartTime, now)
+ .ge(BargainActivityDO::getEndTime, now)
+ .last("LIMIT " + count));
+ }
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java
index c2868d191..5672c34dc 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java
@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.dal.mysql.combination;
+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;
@@ -28,4 +29,15 @@ public interface CombinationActivityMapper extends BaseMapperX selectPage(PageParam pageParam, Integer status) {
+ return selectPage(pageParam, new LambdaQueryWrapperX()
+ .eq(CombinationActivityDO::getStatus, status));
+ }
+
+ default List selectListByStatus(Integer status, Integer count) {
+ return selectList(new LambdaQueryWrapperX()
+ .eq(CombinationActivityDO::getStatus, status)
+ .last("LIMIT " + count));
+ }
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java
index 8ce12092f..7e2afdc85 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java
@@ -41,7 +41,7 @@ public interface SeckillActivityMapper extends BaseMapperX {
* @param count 扣减的库存数量
* @return 影响的行数
*/
- default int updateActivityStock(Long id, int count) {
+ default int updateStock(Long id, int count) {
return update(null, new LambdaUpdateWrapper()
.eq(SeckillActivityDO::getId, id)
.gt(SeckillActivityDO::getTotalStock, 0)
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java
index 5ca2dae24..db34aa744 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java
@@ -16,8 +16,13 @@ import java.util.List;
@Mapper
public interface SeckillProductMapper extends BaseMapperX {
- default List selectListByActivityId(Long id) {
- return selectList(SeckillProductDO::getActivityId, id);
+ default List selectListByActivityId(Long activityId) {
+ return selectList(SeckillProductDO::getActivityId, activityId);
+ }
+
+ default SeckillProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId) {
+ return selectOne(SeckillProductDO::getActivityId, activityId,
+ SeckillProductDO::getSkuId, skuId);
}
default List selectListByActivityId(Collection ids) {
@@ -31,7 +36,7 @@ public interface SeckillProductMapper extends BaseMapperX {
* @param count 扣减的库存数量
* @return 影响的行数
*/
- default int updateActivityStock(Long id, int count) {
+ default int updateStock(Long id, int count) {
return update(null, new LambdaUpdateWrapper()
.eq(SeckillProductDO::getId, id)
.gt(SeckillProductDO::getStock, count)
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
index 1b3bd35dd..9a0c17af9 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
@@ -63,22 +63,20 @@ public interface BargainActivityService {
*/
PageResult getBargainActivityPage(BargainActivityPageReqVO pageReqVO);
- // TODO @puhui999:这里可以改成进行中的活动;尽量避免专门为 app 定制,或者类似的名字哈;mapper 那也是
-
/**
- * 获取 APP 端活动分页数据
+ * 获取正在进行的活动分页数据
*
* @param pageReqVO 分页请求
* @return 砍价活动分页
*/
- PageResult getBargainActivityPageForApp(PageParam pageReqVO);
+ PageResult getBargainActivityPage(PageParam pageReqVO);
/**
- * 获取 APP 端活动展示数据
+ * 获取正在进行的活动分页数据
*
* @param count 需要的数量
* @return 砍价活动分页
*/
- List getBargainActivityListForApp(Integer count);
+ List getBargainActivityListByCount(Integer count);
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java
index 5aa075250..546b95041 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java
@@ -75,16 +75,18 @@ public class BargainActivityServiceImpl implements BargainActivityService {
}
@Override
- @Transactional(rollbackFor = Exception.class)
public void updateBargainActivityStock(Long id, Integer count) {
// 查询砍价活动
BargainActivityDO activity = getBargainActivity(id);
if (activity == null) {
throw exception(BARGAIN_ACTIVITY_NOT_EXISTS);
}
+ if (count > activity.getStock()) {
+ throw exception(BARGAIN_ACTIVITY_UPDATE_STOCK_FAIL);
+ }
// 更新砍价库存
- int updateCount = bargainActivityMapper.updateActivityStock(id, count);
+ int updateCount = bargainActivityMapper.updateStock(id, count);
if (updateCount == 0) {
throw exception(BARGAIN_ACTIVITY_UPDATE_STOCK_FAIL);
}
@@ -114,7 +116,7 @@ public class BargainActivityServiceImpl implements BargainActivityService {
public void deleteBargainActivity(Long id) {
// 校验存在
BargainActivityDO activityDO = validateBargainActivityExists(id);
- // 校验状态
+ // 校验状态 TODO puhui: 测试完成后需要恢复校验
//if (ObjectUtil.equal(activityDO.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
// throw exception(BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END);
//}
@@ -142,21 +144,14 @@ public class BargainActivityServiceImpl implements BargainActivityService {
}
@Override
- public PageResult getBargainActivityPageForApp(PageParam pageReqVO) {
+ public PageResult getBargainActivityPage(PageParam pageReqVO) {
// 只查询进行中,且在时间范围内的
- return bargainActivityMapper.selectAppPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now());
+ return bargainActivityMapper.selectPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now());
}
@Override
- public List getBargainActivityListForApp(Integer count) {
- // TODO @puhui999:这种 default count 的逻辑,可以放到 controller 哈;然后可以使用 ObjectUtils.default 方法
- if (count == null) {
- count = 6;
- }
- // TODO @puhui999:这种不要用 page;会浪费一次 count;
- PageResult result = bargainActivityMapper.selectAppPage(new PageParam().setPageSize(count),
- CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now());
- return result.getList();
+ public List getBargainActivityListByCount(Integer count) {
+ return bargainActivityMapper.selectList(count, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now());
}
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java
index 3529932a4..c5f72e6a6 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java
@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.promotion.service.combination;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO;
@@ -9,6 +10,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationP
import javax.validation.Valid;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
/**
@@ -64,6 +66,16 @@ public interface CombinationActivityService {
*/
PageResult getCombinationActivityPage(CombinationActivityPageReqVO pageReqVO);
+ /**
+ * 获得拼团活动商品列表
+ *
+ * @param activityId 拼团活动 id
+ * @return 拼团活动的商品列表
+ */
+ default List getCombinationProductsByActivityId(Long activityId) {
+ return getCombinationProductsByActivityIds(Collections.singletonList(activityId));
+ }
+
/**
* 获得拼团活动商品列表
*
@@ -83,4 +95,20 @@ public interface CombinationActivityService {
*/
void validateCombination(Long activityId, Long userId, Long skuId, Integer count);
+ /**
+ * 获取正在进行的活动分页数据
+ *
+ * @param count 需要的数量
+ * @return 拼团活动分页
+ */
+ List getCombinationActivityListByCount(Integer count);
+
+ /**
+ * 获取正在进行的活动分页数据
+ *
+ * @param pageParam 分页请求
+ * @return 拼团活动分页
+ */
+ PageResult getCombinationActivityPage(PageParam pageParam);
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java
index 2224bf626..2dc715039 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.combination;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
@@ -223,8 +224,7 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE);
}
// 1.3 校验是否超出单次限购数量
- // TODO puhui999:count > activity.getSingleLimitCount() 会更好理解点;
- if (activity.getSingleLimitCount() < count) {
+ if (count > activity.getSingleLimitCount()) {
throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED);
}
@@ -245,4 +245,14 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
}
}
+ @Override
+ public List getCombinationActivityListByCount(Integer count) {
+ return combinationActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus(), count);
+ }
+
+ @Override
+ public PageResult getCombinationActivityPage(PageParam pageParam) {
+ return combinationActivityMapper.selectPage(pageParam, CommonStatusEnum.ENABLE.getStatus());
+ }
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
index bb62295b8..047e060a9 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
@@ -96,12 +96,15 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
return recordDO;
}
+ // TODO @puhui999:有一个应该在创建那要做下;就是当前 activityId 已经有未支付的订单,不允许在发起新的;要么支付,要么去掉先;
+
@Override
@Transactional(rollbackFor = Exception.class)
public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
// 1.1 校验拼团活动
CombinationActivityDO activity = combinationActivityService.validateCombinationActivityExists(reqDTO.getActivityId());
// 1.2 需要校验下,他当前是不是已经参加了该拼团;
+ // TODO @puhui999:拼团应该可以重复参加;应该去校验总共的上限哈,就是 activity.totalLimitCount
CombinationRecordDO recordDO = recordMapper.selectByUserIdAndOrderId(reqDTO.getUserId(), reqDTO.getOrderId());
if (recordDO != null) {
throw exception(COMBINATION_RECORD_EXISTS);
@@ -111,6 +114,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
if (CollUtil.isNotEmpty(recordDOList)) {
throw exception(COMBINATION_RECORD_FAILED_HAVE_JOINED);
}
+ // TODO @puhui999:有个开始时间未校验
// 1.4 校验当前活动是否过期
if (LocalDateTime.now().isAfter(activity.getEndTime())) {
throw exception(COMBINATION_RECORD_FAILED_TIME_END);
@@ -128,6 +132,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
}
}
+ // TODO @puhui999:单次限购
+
// 2. 创建拼团记录
MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId());
ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId());
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java
index 2be81ccb9..3cbee8126 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java
@@ -37,11 +37,11 @@ public interface SeckillActivityService {
/**
* 更新秒杀库存
*
- * @param activityId 活动编号
+ * @param id 活动编号
* @param skuId sku 编号
* @param count 数量
*/
- void updateSeckillStock(Long activityId, Long skuId, Integer count);
+ void updateSeckillStock(Long id, Long skuId, Integer count);
/**
* 关闭秒杀活动
@@ -97,6 +97,15 @@ public interface SeckillActivityService {
*/
List getSeckillActivityListByConfigIds(Collection ids);
+ /**
+ * 通过活动时段编号获取指定 status 的秒杀活动
+ *
+ * @param configId 时段配置编号
+ * @param status 状态
+ * @return 秒杀活动列表
+ */
+ List getSeckillActivityListByConfigIdAndStatus(Long configId, Integer status);
+
/**
* 通过活动时段获取秒杀活动
*
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java
index 10891e071..6e05191bf 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java
@@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.service.seckill;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
@@ -31,6 +30,7 @@ import java.util.Map;
import static cn.hutool.core.collection.CollUtil.isNotEmpty;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
+import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
@@ -148,32 +148,26 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
@Override
@Transactional(rollbackFor = Exception.class)
- public void updateSeckillStock(Long activityId, Long skuId, Integer count) {
- // 1、校验秒杀活动是否存在
- SeckillActivityDO seckillActivity = getSeckillActivity(activityId);
- // 1.1、校验库存是否充足
- if (seckillActivity.getTotalStock() < count) {
+ public void updateSeckillStock(Long id, Long skuId, Integer count) {
+ // 1.1 校验活动库存是否充足
+ SeckillActivityDO seckillActivity = getSeckillActivity(id);
+ if (count > seckillActivity.getTotalStock()) {
+ throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL);
+ }
+ // 1.2 校验商品库存是否充足
+ SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(id, skuId);
+ if (product == null || count > product.getStock()) {
throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL);
}
- // 2、获取活动商品
- List products = getSeckillProductListByActivityId(activityId);
- // 2.1、过滤出购买的商品
- SeckillProductDO product = findFirst(products, item -> ObjectUtil.equal(skuId, item.getSkuId()));
- // 2.2、检查活动商品库存是否充足
- boolean isSufficient = product == null || (product.getStock() == 0 || (product.getStock() < count) || (product.getStock() - count) < 0);
- if (isSufficient) {
- throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL);
- }
-
- // 3、更新活动商品库存
- int updateCount = seckillProductMapper.updateActivityStock(product.getId(), count);
+ // 2.1 更新活动商品库存
+ int updateCount = seckillProductMapper.updateStock(product.getId(), count);
if (updateCount == 0) {
throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL);
}
- // 4、更新活动库存
- updateCount = seckillActivityMapper.updateActivityStock(seckillActivity.getId(), count);
+ // 2.2 更新活动库存
+ updateCount = seckillActivityMapper.updateStock(seckillActivity.getId(), count);
if (updateCount == 0) {
throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL);
}
@@ -268,8 +262,15 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
@Override
public List getSeckillActivityListByConfigIds(Collection ids) {
- return CollectionUtils.filterList(seckillActivityMapper.selectList(),
- item -> CollectionUtils.anyMatch(item.getConfigIds(), ids::contains));
+ return filterList(seckillActivityMapper.selectList(),
+ item -> anyMatch(item.getConfigIds(), ids::contains));
+ }
+
+ @Override
+ public List getSeckillActivityListByConfigIdAndStatus(Long configId, Integer status) {
+ return filterList(seckillActivityMapper.selectList(SeckillActivityDO::getStatus, status),
+ item -> anyMatch(item.getConfigIds(), id -> ObjectUtil.equal(id, configId)) // 校验时段
+ && isBetween(item.getStartTime(), item.getEndTime())); // 追加当前日期是否处在活动日期之间的校验条件
}
@Override
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java
index 5cbf4fd32..c8377e630 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java
@@ -54,6 +54,7 @@ public interface SeckillConfigService {
*/
List getSeckillConfigList();
+
/**
* 校验秒杀时段是否存在
*
@@ -85,4 +86,12 @@ public interface SeckillConfigService {
*/
void updateSeckillConfigStatus(Long id, Integer status);
+ /**
+ * 获取当前日期时间处于的秒杀时段且状态为 status
+ *
+ * @param status 状态
+ * @return 时段
+ */
+ SeckillConfigDO getSeckillConfigListByStatusOnCurrentTime(Integer status);
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java
index ce2171079..a5d2309c8 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java
@@ -20,6 +20,8 @@ import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst;
+import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween;
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
/**
@@ -67,6 +69,12 @@ public class SeckillConfigServiceImpl implements SeckillConfigService {
seckillConfigMapper.updateById(new SeckillConfigDO().setId(id).setStatus(status));
}
+ @Override
+ public SeckillConfigDO getSeckillConfigListByStatusOnCurrentTime(Integer status) {
+ return findFirst(seckillConfigMapper.selectList(SeckillConfigDO::getStatus, status),
+ config -> isBetween(config.getStartTime(), config.getEndTime()));
+ }
+
@Override
public void deleteSeckillConfig(Long id) {
// 校验存在
diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java
new file mode 100644
index 000000000..ff09e59d8
--- /dev/null
+++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java
@@ -0,0 +1,12 @@
+package cn.iocoder.yudao.module.trade.enums;
+
+/**
+ * Trade 字典类型的枚举类
+ *
+ * @author owen
+ */
+public interface DictTypeConstants {
+
+ String BROKERAGE_WITHDRAW_STATUS = "brokerage_withdraw_status"; // 佣金提现状态
+
+}
diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
index 500601442..da0d8fa2b 100644
--- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
+++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
@@ -12,12 +12,6 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
public interface ErrorCodeConstants {
// ========== Order 模块 1011000000 ==========
- ErrorCode ORDER_CREATE_SKU_NOT_FOUND = new ErrorCode(1011000001, "商品 SKU 不存在");
- ErrorCode ORDER_CREATE_SPU_NOT_SALE = new ErrorCode(1011000002, "商品 SPU 不可售卖");
- ErrorCode ORDER_CREATE_SKU_STOCK_NOT_ENOUGH = new ErrorCode(1011000004, "商品 SKU 库存不足");
- ErrorCode ORDER_CREATE_SPU_NOT_FOUND = new ErrorCode(1011000005, "商品 SPU 不可售卖");
- ErrorCode ORDER_CREATE_ADDRESS_NOT_FOUND = new ErrorCode(1011000006, "收货地址不存在");
-
ErrorCode ORDER_ITEM_NOT_FOUND = new ErrorCode(1011000010, "交易订单项不存在");
ErrorCode ORDER_NOT_FOUND = new ErrorCode(1011000011, "交易订单不存在");
ErrorCode ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL = new ErrorCode(1011000012, "交易订单项更新售后状态失败,请重试");
@@ -37,6 +31,7 @@ public interface ErrorCodeConstants {
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_DELETE_FAIL_STATUS_NOT_CANCEL = new ErrorCode(1011000029, "交易订单删除失败,订单不是【已取消】状态");
// ========== After Sale 模块 1011000100 ==========
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在");
@@ -58,9 +53,8 @@ public interface ErrorCodeConstants {
// ========== Price 相关 1011003000 ============
ErrorCode PRICE_CALCULATE_PAY_PRICE_ILLEGAL = new ErrorCode(1011003000, "支付价格计算异常,原因:价格小于等于 0");
- ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_USER_ADDRESS_IS_EMPTY = new ErrorCode(1011003001, "计算快递运费异常,收件人地址编号为空");
ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND = new ErrorCode(1011003002, "计算快递运费异常,找不到对应的运费模板");
- ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_PICK_UP_STORE_IS_EMPTY = new ErrorCode(1011003003, "计算快递运费异常,自提点为空");
+ ErrorCode PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER = new ErrorCode(1011003004, "参与秒杀、拼团、砍价的营销商品,无法使用优惠劵");
// ========== 物流 Express 模块 1011004000 ==========
ErrorCode EXPRESS_NOT_EXISTS = new ErrorCode(1011004000, "快递公司不存在");
@@ -93,5 +87,7 @@ public interface ErrorCodeConstants {
// ========== 分销提现 模块 1011008000 ==========
ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1011008000, "佣金提现记录不存在");
ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1011008001, "佣金提现记录状态不是审核中");
+ ErrorCode BROKERAGE_WITHDRAW_MIN_PRICE = new ErrorCode(1011008002, "提现金额不能低于 {} 元");
+ ErrorCode BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH = new ErrorCode(1011008003, "您当前最多可提现 {} 元");
}
diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java
index ae798a6ac..73fbb4c91 100644
--- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java
+++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java
@@ -17,6 +17,7 @@ public enum BrokerageRecordBizTypeEnum implements IntArrayValuable {
ORDER(1, "获得推广佣金", "获得推广佣金 {}", true),
WITHDRAW(2, "提现申请", "提现申请扣除佣金 {}", false),
+ WITHDRAW_REJECT(3, "提现申请驳回", "提现申请驳回返还佣金 {}", true),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageRecordBizTypeEnum::getType).toArray();
diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java
index a4b5252ee..7503dd322 100644
--- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java
+++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java
@@ -16,7 +16,7 @@ import java.util.Arrays;
@Getter
public enum DeliveryExpressChargeModeEnum implements IntArrayValuable {
- PIECE(1, "按件"),
+ COUNT(1, "按件"),
WEIGHT(2,"按重量"),
VOLUME(3, "按体积");
diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java
index f16e35601..517928551 100644
--- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java
+++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java
@@ -14,7 +14,10 @@ import lombok.RequiredArgsConstructor;
public enum TradeOrderOperateTypeEnum {
MEMBER_CREATE(1, "用户下单"),
- TEST(2, "用户({nickname})做了({thing})"),
+ MEMBER_RECEIVE(30, "用户已收货"),
+ MEMBER_COMMENT(31, "用户评价"),
+ MEMBER_CANCEL(40, "取消订单"),
+ MEMBER_DELETE(41, "删除订单"),
;
/**
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
index 0bf5a9cd9..3b438568b 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
@@ -8,11 +8,11 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.*;
+import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.TradeAfterSaleLogRespVO;
import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO;
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.aftersalelog.core.dto.TradeAfterSaleLogRespDTO;
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService;
import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
@@ -87,13 +87,13 @@ public class TradeAfterSaleController {
// 拼接数据
MemberUserRespDTO user = memberUserApi.getUser(afterSale.getUserId());
// 获取售后日志
- List logs = afterSaleLogService.getLog(afterSale.getId());
+ List logs = afterSaleLogService.getLog(afterSale.getId());
// TODO 方便测试看效果,review 后移除
if (logs == null) {
logs = new ArrayList<>();
}
for (int i = 1; i <= 6; i++) {
- TradeAfterSaleLogRespDTO respVO = new TradeAfterSaleLogRespDTO();
+ TradeAfterSaleLogRespVO respVO = new TradeAfterSaleLogRespVO();
respVO.setId((long) i);
respVO.setUserId((long) i);
respVO.setUserType(i % 2 == 0 ? 2 : 1);
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/BrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java
similarity index 89%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/BrokerageRecordController.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java
index 9bb135670..ff9bd5285 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/BrokerageRecordController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java
@@ -1,14 +1,14 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.record;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
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.controller.admin.brokerage.record.vo.BrokerageRecordPageReqVO;
-import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.BrokerageRecordRespVO;
-import cn.iocoder.yudao.module.trade.convert.brokerage.record.BrokerageRecordConvert;
-import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.BrokerageRecordDO;
-import cn.iocoder.yudao.module.trade.service.brokerage.record.BrokerageRecordService;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO;
+import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/BrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java
similarity index 79%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/BrokerageUserController.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java
index d90900061..8d27dd3b4 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/BrokerageUserController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java
@@ -1,17 +1,20 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
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.controller.admin.brokerage.user.vo.*;
-import cn.iocoder.yudao.module.trade.convert.brokerage.user.BrokerageUserConvert;
-import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.*;
+import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
+import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
-import cn.iocoder.yudao.module.trade.service.brokerage.record.BrokerageRecordService;
-import cn.iocoder.yudao.module.trade.service.brokerage.user.BrokerageUserService;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService;
+import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -38,6 +41,8 @@ public class BrokerageUserController {
private BrokerageUserService brokerageUserService;
@Resource
private BrokerageRecordService brokerageRecordService;
+ @Resource
+ private BrokerageWithdrawService brokerageWithdrawService;
@Resource
private MemberUserApi memberUserApi;
@@ -87,6 +92,7 @@ public class BrokerageUserController {
Set userIds = convertSet(pageResult.getList(), BrokerageUserDO::getId);
// 查询用户信息
Map userMap = memberUserApi.getUserMap(userIds);
+ // TODO @疯狂:看看下面两个 getBrokerageUserCountByBindUserId、getWithdrawSummaryByUserId 有没可能一次性出结果,不然 n 次有点太花性能了;
// 合计分佣订单
Map userOrderSummaryMap = convertMap(userIds,
userId -> userId,
@@ -96,10 +102,13 @@ public class BrokerageUserController {
Map brokerageUserCountMap = convertMap(userIds,
userId -> userId,
userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null));
-
- // todo 合计提现
-
- return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap));
+ // 合计提现
+ Map withdrawMap = convertMap(userIds,
+ userId -> userId,
+ userId -> brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS));
+ // 拼接返回
+ return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap,
+ userOrderSummaryMap, withdrawMap));
}
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/BrokerageWithdrawController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java
similarity index 89%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/BrokerageWithdrawController.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java
index 1ba6130a2..609cfa433 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/BrokerageWithdrawController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java
@@ -1,16 +1,16 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
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.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRejectReqVO;
-import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawPageReqVO;
-import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRespVO;
-import cn.iocoder.yudao.module.trade.convert.brokerage.withdraw.BrokerageWithdrawConvert;
-import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRejectReqVO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO;
+import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
-import cn.iocoder.yudao.module.trade.service.brokerage.withdraw.BrokerageWithdrawService;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java
similarity index 99%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordBaseVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java
index 425758631..0c53f99fb 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordBaseVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java
similarity index 98%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordPageReqVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java
index 8d0eeff3f..36c4744e8 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordPageReqVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java
similarity index 99%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordRespVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java
index 1f58b53ee..224ecf1e5 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordRespVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java
similarity index 99%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserBaseVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java
index 34f792b72..05e5935b0 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserBaseVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserClearBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java
similarity index 98%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserClearBrokerageUserReqVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java
index edb0102a0..5a05c56ce 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserClearBrokerageUserReqVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java
similarity index 99%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserPageReqVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java
index 1f7816355..cb0ce8954 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserPageReqVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java
similarity index 99%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserRespVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java
index 4aa3e5732..4713d8e13 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserRespVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserUpdateBrokerageEnabledReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java
similarity index 98%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserUpdateBrokerageEnabledReqVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java
index 92001e698..d097855a2 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserUpdateBrokerageEnabledReqVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserUpdateBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java
similarity index 98%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserUpdateBrokerageUserReqVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java
index d62c7fd1e..56391c4d5 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserUpdateBrokerageUserReqVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java
similarity index 99%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawBaseVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java
index 58f0ee8ef..8aca8a2bb 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawBaseVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java
similarity index 99%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawPageReqVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java
index c6f56878a..b18ff74af 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawPageReqVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawRejectReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java
similarity index 98%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawRejectReqVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java
index 72e26c547..23e6c28e5 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawRejectReqVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java
similarity index 98%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawRespVO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java
index c21d5b539..de74bb4f6 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawRespVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo;
+package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java
index ee20156f1..dfad27e03 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java
@@ -19,6 +19,17 @@ import java.util.List;
*/
@Data
public class TradeConfigBaseVO {
+ /**
+ * 是否启用全场包邮
+ */
+ @Schema(description = "是否启用全场包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
+ @NotNull(message = "是否启用全场包邮不能为空")
+ private Boolean deliveryExpressFreeEnabled;
+
+ @Schema(description = "全场包邮的最小金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
+ @NotNull(message = "全场包邮的最小金额不能为空")
+ @PositiveOrZero(message = "全场包邮的最小金额不能是负数")
+ private Integer deliveryExpressFreePrice;
// ========== 分销相关 ==========
@@ -37,7 +48,7 @@ public class TradeConfigBaseVO {
private Integer brokerageBindMode;
@Schema(description = "分销海报图地址数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/yudao.jpg]")
- private List brokeragePostUrls;
+ private List brokeragePosterUrls;
@Schema(description = "一级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
@NotNull(message = "一级返佣比例不能为空")
@@ -54,6 +65,11 @@ public class TradeConfigBaseVO {
@PositiveOrZero(message = "用户提现最低金额不能是负数")
private Integer brokerageWithdrawMinPrice;
+ @Schema(description = "用户提现手续费百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
+ @NotNull(message = "用户提现手续费百分比不能为空")
+ @PositiveOrZero(message = "用户提现手续费百分比不能是负数")
+ private Integer brokerageWithdrawFeePercent;
+
@Schema(description = "提现银行", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]")
@NotEmpty(message = "提现银行不能为空")
private List brokerageBankNames;
@@ -66,6 +82,6 @@ public class TradeConfigBaseVO {
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]")
@NotNull(message = "提现方式不能为空")
@InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}")
- private List brokerageWithdrawType;
+ private List brokerageWithdrawTypes;
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java
index 66fb2994a..7cbd6e551 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java
@@ -6,7 +6,9 @@ import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO;
-import cn.iocoder.yudao.module.trade.service.brokerage.user.BrokerageUserService;
+import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@@ -18,11 +20,9 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
-import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
-import static java.util.Arrays.asList;
@Tag(name = "用户 APP - 分销用户")
@RestController
@@ -31,30 +31,21 @@ import static java.util.Arrays.asList;
@Slf4j
public class AppBrokerageRecordController {
@Resource
- private BrokerageUserService brokerageUserService;
+ private BrokerageRecordService brokerageRecordService;
- // TODO 芋艿:临时 mock =>
@GetMapping("/page")
@Operation(summary = "获得分销记录分页")
@PreAuthenticated
public CommonResult> getBrokerageRecordPage(@Valid AppBrokerageRecordPageReqVO pageReqVO) {
- AppBrokerageRecordRespVO vo1 = new AppBrokerageRecordRespVO()
- .setId(1L).setPrice(10).setTitle("收到钱").setCreateTime(LocalDateTime.now())
- .setFinishTime(LocalDateTime.now());
- AppBrokerageRecordRespVO vo2 = new AppBrokerageRecordRespVO()
- .setId(2L).setPrice(-20).setTitle("提现钱").setCreateTime(LocalDateTime.now())
- .setFinishTime(LocalDateTime.now());
- return success(new PageResult<>(asList(vo1, vo2), 10L));
+ PageResult pageResult = brokerageRecordService.getBrokerageRecordPage(
+ BrokerageRecordConvert.INSTANCE.convert(pageReqVO, getLoginUserId()));
+ return success(BrokerageRecordConvert.INSTANCE.convertPage02(pageResult));
}
@GetMapping("/get-product-brokerage-price")
@Operation(summary = "获得商品的分销金额")
public CommonResult getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
- AppBrokerageProductPriceRespVO respVO = new AppBrokerageProductPriceRespVO();
- respVO.setEnabled(brokerageUserService.getUserBrokerageEnabled(getLoginUserId()));
- respVO.setBrokerageMinPrice(1);
- respVO.setBrokerageMaxPrice(2);
- return success(respVO);
+ return success(brokerageRecordService.calculateProductBrokeragePrice(spuId, getLoginUserId()));
}
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java
index 208ecee2e..da78f9dff 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java
@@ -1,10 +1,21 @@
package cn.iocoder.yudao.module.trade.controller.app.brokerage;
+import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
+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.controller.app.brokerage.vo.user.*;
-import cn.iocoder.yudao.module.trade.service.brokerage.user.BrokerageUserService;
+import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert;
+import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
+import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
+import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService;
+import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -16,11 +27,13 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.time.LocalDateTime;
+import java.util.Map;
+import java.util.Optional;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-import static java.util.Arrays.asList;
@Tag(name = "用户 APP - 分销用户")
@RestController
@@ -30,16 +43,24 @@ import static java.util.Arrays.asList;
public class AppBrokerageUserController {
@Resource
private BrokerageUserService brokerageUserService;
+ @Resource
+ private BrokerageRecordService brokerageRecordService;
+ @Resource
+ private BrokerageWithdrawService brokerageWithdrawService;
+
+ @Resource
+ private MemberUserApi memberUserApi;
- // TODO 芋艿:临时 mock =>
@GetMapping("/get")
@Operation(summary = "获得个人分销信息")
@PreAuthenticated
public CommonResult getBrokerageUser() {
+ Optional user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId()));
+ // 返回数据
AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO()
- .setBrokerageEnabled(true)
- .setPrice(2000)
- .setFrozenPrice(3000);
+ .setBrokerageEnabled(user.map(BrokerageUserDO::getBrokerageEnabled).orElse(false))
+ .setBrokeragePrice(user.map(BrokerageUserDO::getBrokeragePrice).orElse(0))
+ .setFrozenPrice(user.map(BrokerageUserDO::getFrozenPrice).orElse(0));
return success(respVO);
}
@@ -47,88 +68,70 @@ public class AppBrokerageUserController {
@Operation(summary = "绑定推广员")
@PreAuthenticated
public CommonResult bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) {
- return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId(), false));
+ MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId());
+ return success(brokerageUserService.bindBrokerageUser(user.getId(), reqVO.getBindUserId(), user.getCreateTime()));
}
- // TODO 芋艿:临时 mock =>
@GetMapping("/get-summary")
@Operation(summary = "获得个人分销统计")
@PreAuthenticated
public CommonResult getBrokerageUserSummary() {
+ Long userId = getLoginUserId();
+ // TODO @疯狂:后面这种,要不也改成 convert;感觉 controller 这样更容易看到整体;核心其实是 86、8/87、9/90、9/91 这阶段
+ // 统计 yesterdayPrice、withdrawPrice、firstBrokerageUserCount、secondBrokerageUserCount 字段
+ LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
+ LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday);
+ LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO()
- .setYesterdayPrice(1)
- .setBrokeragePrice(2)
- .setFrozenPrice(3)
- .setWithdrawPrice(4)
- .setFirstBrokerageUserCount(166)
- .setSecondBrokerageUserCount(233);
+ .setYesterdayPrice(brokerageRecordService.getSummaryPriceByUserId(userId, BrokerageRecordBizTypeEnum.ORDER.getType(), beginTime, endTime))
+ .setWithdrawPrice(Optional.ofNullable(brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS))
+ .map(UserWithdrawSummaryBO::getPrice).orElse(0))
+ .setBrokeragePrice(0).setFrozenPrice(0)
+ .setFirstBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 1))
+ .setSecondBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 2));
+ // 设置 brokeragePrice、frozenPrice 字段
+ Optional.ofNullable(brokerageUserService.getBrokerageUser(userId))
+ .ifPresent(user -> respVO.setBrokeragePrice(user.getBrokeragePrice()).setFrozenPrice(user.getFrozenPrice()));
return success(respVO);
}
- // TODO 芋艿:临时 mock =>
@GetMapping("/rank-page-by-user-count")
@Operation(summary = "获得分销用户排行分页(基于用户量)")
@PreAuthenticated
public CommonResult> getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO) {
- AppBrokerageUserRankByUserCountRespVO vo1 = new AppBrokerageUserRankByUserCountRespVO()
- .setId(1L).setNickname("芋1**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokerageUserCount(10);
- AppBrokerageUserRankByUserCountRespVO vo2 = new AppBrokerageUserRankByUserCountRespVO()
- .setId(2L).setNickname("芋2**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokerageUserCount(6);
- AppBrokerageUserRankByUserCountRespVO vo3 = new AppBrokerageUserRankByUserCountRespVO()
- .setId(3L).setNickname("芋3**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokerageUserCount(4);
- AppBrokerageUserRankByUserCountRespVO vo4 = new AppBrokerageUserRankByUserCountRespVO()
- .setId(3L).setNickname("芋3**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokerageUserCount(4);
- return success(new PageResult<>(asList(vo1, vo2, vo3, vo4), 10L));
+ // 分页查询
+ PageResult pageResult = brokerageUserService.getBrokerageUserRankPageByUserCount(pageReqVO);
+ // 拼接数据
+ Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByUserCountRespVO::getId));
+ return success(BrokerageUserConvert.INSTANCE.convertPage03(pageResult, userMap));
}
- // TODO 芋艿:临时 mock =>
@GetMapping("/rank-page-by-price")
@Operation(summary = "获得分销用户排行分页(基于佣金)")
@PreAuthenticated
public CommonResult> getBrokerageUserChildSummaryPageByPrice(AppBrokerageUserRankPageReqVO pageReqVO) {
- AppBrokerageUserRankByPriceRespVO vo1 = new AppBrokerageUserRankByPriceRespVO()
- .setId(1L).setNickname("芋1**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokeragePrice(10);
- AppBrokerageUserRankByPriceRespVO vo2 = new AppBrokerageUserRankByPriceRespVO()
- .setId(2L).setNickname("芋2**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokeragePrice(6);
- AppBrokerageUserRankByPriceRespVO vo3 = new AppBrokerageUserRankByPriceRespVO()
- .setId(3L).setNickname("芋3**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokeragePrice(4);
- AppBrokerageUserRankByPriceRespVO vo4 = new AppBrokerageUserRankByPriceRespVO()
- .setId(3L).setNickname("芋3**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokeragePrice(4);
- return success(new PageResult<>(asList(vo1, vo2, vo3, vo4), 10L));
+ // 分页查询
+ PageResult pageResult = brokerageRecordService.getBrokerageUserChildSummaryPageByPrice(pageReqVO);
+ // 拼接数据
+ Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByPriceRespVO::getId));
+ return success(BrokerageRecordConvert.INSTANCE.convertPage03(pageResult, userMap));
}
- // TODO 芋艿:临时 mock =>
@GetMapping("/child-summary-page")
@Operation(summary = "获得下级分销统计分页")
@PreAuthenticated
public CommonResult> getBrokerageUserChildSummaryPage(
AppBrokerageUserChildSummaryPageReqVO pageReqVO) {
- AppBrokerageUserChildSummaryRespVO vo1 = new AppBrokerageUserChildSummaryRespVO()
- .setId(1L).setNickname("芋1**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokeragePrice(10).setBrokeragePrice(20).setBrokerageOrderCount(30)
- .setBrokerageTime(LocalDateTime.now());
- AppBrokerageUserChildSummaryRespVO vo2 = new AppBrokerageUserChildSummaryRespVO()
- .setId(1L).setNickname("芋2**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
- .setBrokeragePrice(20).setBrokeragePrice(30).setBrokerageOrderCount(40)
- .setBrokerageTime(LocalDateTime.now());
- return success(new PageResult<>(asList(vo1, vo2), 10L));
+ PageResult pageResult = brokerageUserService.getBrokerageUserChildSummaryPage(pageReqVO, getLoginUserId());
+ return success(pageResult);
}
- // TODO 芋艿:临时 mock =>
@GetMapping("/get-rank-by-price")
@Operation(summary = "获得分销用户排行(基于佣金)")
@Parameter(name = "times", description = "时间段", required = true)
- public CommonResult bindBrokerageUser(
+ public CommonResult getRankByPrice(
@RequestParam("times") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime[] times) {
- return success(1);
+ return success(brokerageRecordService.getUserRankByPrice(getLoginUserId(), times));
}
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java
index 1f6d383ea..8ca12b79b 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java
@@ -3,19 +3,24 @@ package cn.iocoder.yudao.module.trade.controller.app.brokerage;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
+import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO;
+import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService;
import io.swagger.v3.oas.annotations.Operation;
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.*;
+import javax.annotation.Resource;
import javax.validation.Valid;
-import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-import static java.util.Arrays.asList;
+import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
@Tag(name = "用户 APP - 分销提现")
@RestController
@@ -24,24 +29,27 @@ import static java.util.Arrays.asList;
@Slf4j
public class AppBrokerageWithdrawController {
- // TODO 芋艿:临时 mock =>
+ @Resource
+ private BrokerageWithdrawService brokerageWithdrawService;
+
+ @Resource
+ private DictDataApi dictDataApi;
+
@GetMapping("/page")
@Operation(summary = "获得分销提现分页")
@PreAuthenticated
- public CommonResult> getBrokerageWithdrawPage() {
- AppBrokerageWithdrawRespVO vo1 = new AppBrokerageWithdrawRespVO()
- .setId(1L).setStatus(10).setPrice(10).setStatusName("审批通过").setCreateTime(LocalDateTime.now());
- AppBrokerageWithdrawRespVO vo2 = new AppBrokerageWithdrawRespVO()
- .setId(2L).setStatus(0).setPrice(20).setStatusName("审批中").setCreateTime(LocalDateTime.now());
- return success(new PageResult<>(asList(vo1, vo2), 10L));
+ public CommonResult> getBrokerageWithdrawPage(AppBrokerageWithdrawPageReqVO pageReqVO) {
+ // 分页查询
+ PageResult pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(
+ BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId()));
+ return success(BrokerageWithdrawConvert.INSTANCE.convertPage03(pageResult));
}
- // TODO 芋艿:临时 mock =>
@PostMapping("/create")
@Operation(summary = "创建分销提现")
@PreAuthenticated
public CommonResult createBrokerageWithdraw(@RequestBody @Valid AppBrokerageWithdrawCreateReqVO createReqVO) {
- return success(1L);
+ return success(brokerageWithdrawService.createBrokerageWithdraw(createReqVO, getLoginUserId()));
}
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java
index 1beb1b5e2..6bc4184e8 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java
@@ -27,7 +27,7 @@ public class AppBrokerageUserChildSummaryRespVO {
@Schema(description = "分销用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30")
private Integer brokerageUserCount;
- @Schema(description = "成为分销员时间", requiredMode = Schema.RequiredMode.REQUIRED)
+ @Schema(description = "绑定推广员的时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime brokerageTime;
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java
index cc9a03ebc..8a0c387c6 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java
@@ -20,9 +20,9 @@ public class AppBrokerageUserMySummaryRespVO {
private Integer frozenPrice;
@Schema(description = "分销用户数量(一级)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
- private Integer firstBrokerageUserCount;
+ private Long firstBrokerageUserCount;
@Schema(description = "分销用户数量(二级)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
- private Integer secondBrokerageUserCount;
+ private Long secondBrokerageUserCount;
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java
index 40b70bed2..f98da7eb6 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java
@@ -11,7 +11,7 @@ public class AppBrokerageUserRespVO {
private Boolean brokerageEnabled;
@Schema(description = "可用的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2408")
- private Integer price;
+ private Integer brokeragePrice;
@Schema(description = "冻结的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "234")
private Integer frozenPrice;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java
index a8b1523b2..d49957d25 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java
@@ -8,8 +8,9 @@ import lombok.Data;
import org.hibernate.validator.constraints.URL;
import javax.validation.Validator;
-import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.PositiveOrZero;
@Schema(description = "用户 App - 分销提现创建 Request VO")
@Data
@@ -20,7 +21,8 @@ public class AppBrokerageWithdrawCreateReqVO {
private Integer type;
@Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
- @Min(value = 1, message = "提现金额不能小于 1")
+ @PositiveOrZero(message = "提现金额不能小于 0")
+ @NotNull(message = "提现金额不能为空")
private Integer price;
// ========== 银行卡、微信、支付宝 提现相关字段 ==========
@@ -41,7 +43,7 @@ public class AppBrokerageWithdrawCreateReqVO {
@NotBlank(message = "持卡人姓名不能为空", groups = {Bank.class})
private String name;
@Schema(description = "提现银行", example = "1")
- @NotBlank(message = "提现银行不能为空", groups = {Bank.class})
+ @NotNull(message = "提现银行不能为空", groups = {Bank.class})
private Integer bankName;
@Schema(description = "开户地址", example = "海淀支行")
private String bankAddress;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java
new file mode 100644
index 000000000..b1757d43e
--- /dev/null
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java
@@ -0,0 +1,22 @@
+package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.validation.InEnum;
+import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
+import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "应用 App - 分销提现分页 Request VO")
+@Data
+public class AppBrokerageWithdrawPageReqVO extends PageParam {
+
+ @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+ @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "类型必须是 {value}")
+ private Integer type;
+
+ @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+ @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}")
+ private Integer status;
+
+}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java
index 65c879a02..6b7660a1c 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java
@@ -1,7 +1,12 @@
package cn.iocoder.yudao.module.trade.controller.app.config;
+import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO;
+import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert;
+import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
+import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
+import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -10,8 +15,9 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-import static java.util.Arrays.asList;
@Tag(name = "用户 App - 交易配置")
@RestController
@@ -21,17 +27,14 @@ import static java.util.Arrays.asList;
@Slf4j
public class AppTradeConfigController {
+ @Resource
+ private TradeConfigService tradeConfigService;
+
@GetMapping("/get")
+ @Operation(summary = "获得交易配置")
public CommonResult getTradeConfig() {
- AppTradeConfigRespVO respVO = new AppTradeConfigRespVO();
- respVO.setBrokeragePosterUrls(asList(
- "https://api.java.crmeb.net/crmebimage/product/2020/08/03/755bf516b1ca4b6db3bfeaa4dd5901cdh71kob20re.jpg",
- "https://api.java.crmeb.net/crmebimage/maintain/2021/03/01/406d729b84ed4ec9a2171bfcf6fd0634ughzbz9kfi.jpg",
- "https://api.java.crmeb.net/crmebimage/maintain/2021/03/01/efb1e4e7fe604fe1988b4213ce08cb11tdsyijtd2r.jpg"
- ));
- respVO.setBrokerageFrozenDays(10);
- respVO.setBrokerageWithdrawMinPrice(100);
- return success(respVO);
+ TradeConfigDO tradeConfig = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO());
+ return success(TradeConfigConvert.INSTANCE.convert02(tradeConfig));
}
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java
index 73abf7ab4..0d590f834 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java
@@ -18,4 +18,7 @@ public class AppTradeConfigRespVO {
@Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer brokerageWithdrawMinPrice;
+ @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
+ private List brokerageWithdrawTypes;
+
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java
index d5b86fcb0..1d4e36f90 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java
@@ -17,6 +17,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class AppDeliverConfigController {
+ // TODO @芋艿:这里后面干掉,合并到 AppTradeConfigController 中
@GetMapping("/get")
@Operation(summary = "获得配送配置")
public CommonResult getDeliveryConfig() {
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java
index 4bbd98a27..f1d361d91 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java
@@ -156,7 +156,7 @@ public class AppTradeOrderController {
@Operation(summary = "删除交易订单")
@Parameter(name = "id", description = "交易订单编号")
public CommonResult deleteOrder(@RequestParam("id") Long id) {
- // TODO @芋艿:未实现,mock 用
+ tradeOrderUpdateService.deleteOrder(getLoginUserId(), id);
return success(true);
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java
index bd0312753..4b5d98a37 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java
@@ -82,6 +82,9 @@ public class AppTradeOrderSettlementRespVO {
@Schema(description = "积分抵扣的金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
private Integer pointPrice;
+ @Schema(description = "VIP 减免金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "30")
+ private Integer vipPrice;
+
@Schema(description = "实际支付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "450")
private Integer payPrice;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java
index 0c84c6967..9faaefb5d 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java
@@ -16,7 +16,6 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleLogDO;
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.aftersalelog.core.dto.TradeAfterSaleLogRespDTO;
import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@@ -68,10 +67,10 @@ public interface TradeAfterSaleConvert {
PageResult convertPage02(PageResult page);
- List convertList(List list);
-
+ List convertList(List list);
+
default TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, TradeOrderDO order, List orderItems,
- MemberUserRespDTO user, List logs) {
+ MemberUserRespDTO user, List logs) {
TradeAfterSaleDetailRespVO respVO = convert(afterSale, orderItems);
// 处理用户信息
respVO.setUser(convert(user));
@@ -81,7 +80,8 @@ public interface TradeAfterSaleConvert {
respVO.setLogs(convertList1(logs));
return respVO;
}
- List convertList1(List list);
+
+ List convertList1(List list);
@Mapping(target = "id", source = "afterSale.id")
TradeAfterSaleDetailRespVO convert(TradeAfterSaleDO afterSale, List orderItems);
TradeOrderBaseVO convert(TradeOrderDO order);
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/BrokerageRecordConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java
similarity index 65%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/BrokerageRecordConvert.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java
index 5d620a898..e6c0e4f8c 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/BrokerageRecordConvert.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java
@@ -1,15 +1,22 @@
-package cn.iocoder.yudao.module.trade.convert.brokerage.record;
+package cn.iocoder.yudao.module.trade.convert.brokerage;
+import cn.hutool.core.math.Money;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
-import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.BrokerageRecordRespVO;
-import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.BrokerageRecordDO;
-import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;
import java.time.LocalDateTime;
@@ -45,7 +52,7 @@ public interface BrokerageRecordConvert {
.setBizType(bizType.getType()).setBizId(bizId)
.setPrice(brokeragePrice).setTotalPrice(user.getBrokeragePrice())
.setTitle(title)
- .setDescription(StrUtil.format(bizType.getDescription(), String.format("¥%.2f", brokeragePrice / 100d)))
+ .setDescription(StrUtil.format(bizType.getDescription(), MoneyUtils.fenToYuanStr(Math.abs(brokeragePrice))))
.setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime)
.setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId);
}
@@ -60,4 +67,17 @@ public interface BrokerageRecordConvert {
}
return result;
}
+
+ BrokerageRecordPageReqVO convert(AppBrokerageRecordPageReqVO pageReqVO, Long userId);
+
+ PageResult convertPage02(PageResult pageResult);
+
+ default PageResult convertPage03(PageResult pageResult, Map userMap) {
+ for (AppBrokerageUserRankByPriceRespVO vo : pageResult.getList()) {
+ copyTo(userMap.get(vo.getId()), vo);
+ }
+ return pageResult;
+ }
+
+ void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByPriceRespVO to);
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/user/BrokerageUserConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java
similarity index 58%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/user/BrokerageUserConvert.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java
index 83101a1de..6a578032d 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/user/BrokerageUserConvert.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java
@@ -1,12 +1,15 @@
-package cn.iocoder.yudao.module.trade.convert.brokerage.user;
+package cn.iocoder.yudao.module.trade.convert.brokerage;
import cn.hutool.core.map.MapUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
-import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.BrokerageUserRespVO;
-import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserRespVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
+import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;
import java.util.List;
@@ -27,13 +30,14 @@ public interface BrokerageUserConvert {
List convertList(List list);
- PageResult convertPage(PageResult page);
+ PageResult convertPage(PageResult page, Map userMap, Map brokerageUserCountMap, Map userOrderSummaryMap);
default PageResult convertPage(PageResult pageResult,
Map userMap,
Map brokerageUserCountMap,
- Map userOrderSummaryMap) {
- PageResult result = convertPage(pageResult);
+ Map userOrderSummaryMap,
+ Map withdrawMap) {
+ PageResult result = convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap);
for (BrokerageUserRespVO userVO : result.getList()) {
// 用户信息
copyTo(userMap.get(userVO.getId()), userVO);
@@ -44,7 +48,10 @@ public interface BrokerageUserConvert {
Optional orderSummaryOptional = Optional.ofNullable(userOrderSummaryMap.get(userVO.getId()));
userVO.setBrokerageOrderCount(orderSummaryOptional.map(UserBrokerageSummaryBO::getCount).orElse(0))
.setBrokerageOrderPrice(orderSummaryOptional.map(UserBrokerageSummaryBO::getPrice).orElse(0));
- // todo 已提现次数、已提现金额
+ // 已提现次数、已提现金额
+ Optional withdrawSummaryOptional = Optional.ofNullable(withdrawMap.get(userVO.getId()));
+ userVO.setWithdrawCount(withdrawSummaryOptional.map(UserWithdrawSummaryBO::getCount).orElse(0))
+ .setWithdrawPrice(withdrawSummaryOptional.map(UserWithdrawSummaryBO::getPrice).orElse(0));
userVO.setWithdrawCount(0).setWithdrawPrice(0);
}
return result;
@@ -55,4 +62,13 @@ public interface BrokerageUserConvert {
user -> target.setNickname(user.getNickname()).setAvatar(user.getAvatar()));
return target;
}
+
+ default PageResult convertPage03(PageResult pageResult,
+ Map userMap) {
+ pageResult.getList().forEach(vo -> copyTo(userMap.get(vo.getId()), vo));
+ return pageResult;
+ }
+
+ void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByUserCountRespVO to);
+
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java
new file mode 100644
index 000000000..69441ab07
--- /dev/null
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java
@@ -0,0 +1,57 @@
+package cn.iocoder.yudao.module.trade.convert.brokerage;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
+import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
+import cn.iocoder.yudao.module.trade.enums.DictTypeConstants;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * 佣金提现 Convert
+ *
+ * @author 芋道源码
+ */
+@Mapper
+public interface BrokerageWithdrawConvert {
+
+ BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class);
+
+ BrokerageWithdrawDO convert(AppBrokerageWithdrawCreateReqVO createReqVO, Long userId, Integer feePrice);
+
+ BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean);
+
+ List convertList(List list);
+
+ PageResult convertPage(PageResult page);
+
+ default PageResult convertPage(PageResult pageResult, Map userMap) {
+ PageResult result = convertPage(pageResult);
+ for (BrokerageWithdrawRespVO vo : result.getList()) {
+ vo.setUserNickname(Optional.ofNullable(userMap.get(vo.getUserId())).map(MemberUserRespDTO::getNickname).orElse(null));
+ }
+ return result;
+ }
+
+ PageResult convertPage02(PageResult pageResult);
+
+ default PageResult convertPage03(PageResult pageResult) {
+ PageResult result = convertPage02(pageResult);
+ for (AppBrokerageWithdrawRespVO vo : result.getList()) {
+ vo.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, vo.getStatus()));
+ }
+ return result;
+ }
+
+ BrokerageWithdrawPageReqVO convert(AppBrokerageWithdrawPageReqVO pageReqVO, Long userId);
+}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/withdraw/BrokerageWithdrawConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/withdraw/BrokerageWithdrawConvert.java
deleted file mode 100644
index 3aa28db5e..000000000
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/withdraw/BrokerageWithdrawConvert.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.iocoder.yudao.module.trade.convert.brokerage.withdraw;
-
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
-import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRejectReqVO;
-import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRespVO;
-import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO;
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * 佣金提现 Convert
- *
- * @author 芋道源码
- */
-@Mapper
-public interface BrokerageWithdrawConvert {
-
- BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class);
-
- BrokerageWithdrawDO convert(BrokerageWithdrawRejectReqVO bean);
-
- BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean);
-
- List convertList(List list);
-
- PageResult convertPage(PageResult page);
-
- default PageResult convertPage(PageResult pageResult, Map userMap) {
- PageResult result = convertPage(pageResult);
- for (BrokerageWithdrawRespVO vo : result.getList()) {
- vo.setUserNickname(Optional.ofNullable(userMap.get(vo.getUserId())).map(MemberUserRespDTO::getNickname).orElse(null));
- }
- return result;
- }
-
-}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java
index 031f1198a..57da020c2 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.convert.config;
import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO;
import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO;
+import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@@ -20,4 +21,5 @@ public interface TradeConfigConvert {
TradeConfigRespVO convert(TradeConfigDO bean);
+ AppTradeConfigRespVO convert02(TradeConfigDO tradeConfig);
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
index aa78cd170..1dcbda7e0 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.trade.convert.order;
+import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
@@ -14,6 +15,7 @@ import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDT
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
+import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO;
@@ -65,6 +67,7 @@ public interface TradeOrderConvert {
@Mapping(source = "calculateRespBO.price.deliveryPrice", target = "deliveryPrice"),
@Mapping(source = "calculateRespBO.price.couponPrice", target = "couponPrice"),
@Mapping(source = "calculateRespBO.price.pointPrice", target = "pointPrice"),
+ @Mapping(source = "calculateRespBO.price.vipPrice", target = "vipPrice"),
@Mapping(source = "calculateRespBO.price.payPrice", target = "payPrice")
})
TradeOrderDO convert(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO,
@@ -265,11 +268,16 @@ public interface TradeOrderConvert {
TradeOrderDO convert(TradeOrderRemarkReqVO reqVO);
- default BrokerageAddReqBO convert(MemberUserRespDTO user, TradeOrderItemDO item, ProductSkuRespDTO sku) {
- return new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())).setSourceUserId(item.getUserId())
+ default BrokerageAddReqBO convert(MemberUserRespDTO user, TradeOrderItemDO item,
+ ProductSpuRespDTO spu, ProductSkuRespDTO sku) {
+ BrokerageAddReqBO bo = new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())).setSourceUserId(item.getUserId())
.setBasePrice(item.getPayPrice() * item.getCount())
.setTitle(StrUtil.format("{}成功购买{}", user.getNickname(), item.getSpuName()))
- .setFirstFixedPrice(sku.getFirstBrokeragePrice()).setSecondFixedPrice(sku.getSecondBrokeragePrice());
+ .setFirstFixedPrice(0).setSecondFixedPrice(0);
+ if (BooleanUtil.isTrue(spu.getSubCommissionType())) {
+ bo.setFirstFixedPrice(sku.getFirstBrokeragePrice()).setSecondFixedPrice(sku.getSecondBrokeragePrice());
+ }
+ return bo;
}
TradeBeforeOrderCreateReqBO convert(AppTradeOrderCreateReqVO createReqVO);
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/record/BrokerageRecordDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java
similarity index 96%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/record/BrokerageRecordDO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java
index 0f59eada5..c819d723b 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/record/BrokerageRecordDO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record;
+package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/user/BrokerageUserDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java
similarity index 87%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/user/BrokerageUserDO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java
index 3493cac97..8d73858ec 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/user/BrokerageUserDO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user;
+package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
@@ -59,13 +59,4 @@ public class BrokerageUserDO extends BaseDO {
* 冻结佣金
*/
private Integer frozenPrice;
-
- /**
- * 等级
- */
- private Integer level;
- /**
- * 路径
- */
- private String path;
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/withdraw/BrokerageWithdrawDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java
similarity index 95%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/withdraw/BrokerageWithdrawDO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java
index be5b41285..f31c23800 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/withdraw/BrokerageWithdrawDO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw;
+package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
@@ -29,7 +29,7 @@ public class BrokerageWithdrawDO extends BaseDO {
* 编号
*/
@TableId
- private Integer id;
+ private Long id;
/**
* 用户编号
*
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java
index a6704db4f..01de52b5b 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java
@@ -36,7 +36,7 @@ public class TradeConfigDO extends BaseDO {
private Long id;
// ========== 配送相关 ==========
- // TODO 芋艿:未配置
+
/**
* 是否启用全场包邮
*/
@@ -68,7 +68,7 @@ public class TradeConfigDO extends BaseDO {
* 分销海报图地址数组
*/
@TableField(typeHandler = JacksonTypeHandler.class)
- private List brokeragePostUrls;
+ private List brokeragePosterUrls;
/**
* 一级返佣比例
*/
@@ -81,6 +81,10 @@ public class TradeConfigDO extends BaseDO {
* 用户提现最低金额
*/
private Integer brokerageWithdrawMinPrice;
+ /**
+ * 用户提现手续费百分比
+ */
+ private Integer brokerageWithdrawFeePercent;
/**
* 提现银行
*/
@@ -96,6 +100,6 @@ public class TradeConfigDO extends BaseDO {
* 枚举 {@link BrokerageWithdrawTypeEnum 对应的类}
*/
@TableField(typeHandler = IntegerListTypeHandler.class)
- private List brokerageWithdrawType;
+ private List brokerageWithdrawTypes;
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java
index bb68fc1ac..8a3b5b23f 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java
@@ -168,6 +168,7 @@ public class TradeOrderDO extends BaseDO {
* - {@link #discountPrice}
* + {@link #deliveryPrice}
* + {@link #adjustPrice}
+ * - {@link #vipPrice}
*/
private Integer payPrice;
@@ -265,9 +266,17 @@ public class TradeOrderDO extends BaseDO {
* 对应 taobao 的 trade.point_fee 字段
*/
private Integer pointPrice;
-// /**
-// * 奖励的积分 TODO 疯狂:可以使用这个字段哈;
-// */
-// private Integer rewardPoint;
+ /**
+ * 赠送的积分
+ */
+ private Integer givePoint;
+ /**
+ * 退还的使用的积分
+ */
+ private Integer refundPoint;
+ /**
+ * VIP 减免金额,单位:分
+ */
+ private Integer vipPrice;
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java
index 27dd13f67..4849aad0b 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java
@@ -126,6 +126,7 @@ public class TradeOrderItemDO extends BaseDO {
* - {@link #discountPrice}
* + {@link #deliveryPrice}
* + {@link #adjustPrice}
+ * - {@link #vipPrice}
*/
private Integer payPrice;
@@ -143,6 +144,18 @@ public class TradeOrderItemDO extends BaseDO {
* 对应 taobao 的 trade.point_fee 字段
*/
private Integer pointPrice;
+ /**
+ * 使用的积分
+ */
+ private Integer usePoint;
+ /**
+ * 赠送的积分
+ */
+ private Integer givePoint;
+ /**
+ * VIP 减免金额,单位:分
+ */
+ private Integer vipPrice;
// TODO @芋艿:如果商品 vip 折扣时,到底是新增一个 vipPrice 记录优惠记录,还是 vipDiscountPrice,记录 vip 的优惠;还是直接使用 vipPrice;
// 目前 crmeb 的选择,单独一个 vipPrice 记录优惠价格;感觉不一定合理,可以在看看有赞的;
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/BrokerageRecordMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java
similarity index 58%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/BrokerageRecordMapper.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java
index dcc627b78..eb55a8c4c 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/BrokerageRecordMapper.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java
@@ -1,12 +1,14 @@
-package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.record;
+package cn.iocoder.yudao.module.trade.dal.mysql.brokerage;
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.controller.admin.brokerage.record.vo.BrokerageRecordPageReqVO;
-import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.BrokerageRecordDO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@@ -23,7 +25,6 @@ import java.util.List;
public interface BrokerageRecordMapper extends BaseMapperX {
default PageResult selectPage(BrokerageRecordPageReqVO reqVO) {
- // 分页查询
return selectPage(reqVO, new LambdaQueryWrapperX()
.eqIfPresent(BrokerageRecordDO::getUserId, reqVO.getUserId())
.eqIfPresent(BrokerageRecordDO::getBizType, reqVO.getBizType())
@@ -52,9 +53,28 @@ public interface BrokerageRecordMapper extends BaseMapperX {
}
@Select("SELECT COUNT(1), SUM(price) FROM trade_brokerage_record " +
- "WHERE user_id = #{userId} AND biz_type = #{bizType} AND status = #{status}")
+ "WHERE user_id = #{userId} AND biz_type = #{bizType} AND status = #{status} AND deleted = FALSE")
UserBrokerageSummaryBO selectCountAndSumPriceByUserIdAndBizTypeAndStatus(@Param("userId") Long userId,
@Param("bizType") Integer bizType,
@Param("status") Integer status);
+ @Select("SELECT SUM(price) FROM trade_brokerage_record " +
+ "WHERE user_id = #{userId} AND biz_type = #{bizType} " +
+ "AND create_time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE")
+ Integer selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(@Param("userId") Long userId,
+ @Param("bizType") Integer bizType,
+ @Param("beginTime") LocalDateTime beginTime,
+ @Param("endTime") LocalDateTime endTime);
+
+ @Select("SELECT user_id AS id, SUM(price) AS brokeragePrice FROM trade_brokerage_record " +
+ "WHERE biz_type = #{bizType} AND status = #{status} AND deleted = FALSE " +
+ "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} " +
+ "GROUP BY user_id " +
+ "ORDER BY brokeragePrice DESC")
+ IPage selectSummaryPricePageGroupByUserId(IPage> page,
+ @Param("bizType") Integer bizType,
+ @Param("status") Integer status,
+ @Param("beginTime") LocalDateTime beginTime,
+ @Param("endTime") LocalDateTime endTime);
+
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/BrokerageUserMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java
similarity index 63%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/BrokerageUserMapper.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java
index 239625b17..fc53ce942 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/BrokerageUserMapper.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java
@@ -1,14 +1,22 @@
-package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user;
+package cn.iocoder.yudao.module.trade.dal.mysql.brokerage;
import cn.hutool.core.lang.Assert;
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.controller.admin.brokerage.user.vo.BrokerageUserPageReqVO;
-import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO;
+import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO;
+import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO;
+import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import java.time.LocalDateTime;
import java.util.List;
/**
@@ -19,13 +27,12 @@ import java.util.List;
@Mapper
public interface BrokerageUserMapper extends BaseMapperX {
- default PageResult selectPage(BrokerageUserPageReqVO reqVO, List levels) {
+ default PageResult selectPage(BrokerageUserPageReqVO reqVO, List bindUserIds) {
return selectPage(reqVO, new LambdaQueryWrapperX()
.eqIfPresent(BrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled())
.betweenIfPresent(BrokerageUserDO::getCreateTime, reqVO.getCreateTime())
.betweenIfPresent(BrokerageUserDO::getBindUserTime, reqVO.getBindUserTime())
- .findInSetIfPresent(BrokerageUserDO::getPath, reqVO.getBindUserId())
- .inIfPresent(BrokerageUserDO::getLevel, levels)
+ .inIfPresent(BrokerageUserDO::getBindUserId, bindUserIds)
.orderByDesc(BrokerageUserDO::getId));
}
@@ -38,7 +45,7 @@ public interface BrokerageUserMapper extends BaseMapperX {
default void updatePriceIncr(Long id, Integer incrCount) {
Assert.isTrue(incrCount > 0);
LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper()
- .setSql(" price = price + " + incrCount)
+ .setSql(" brokerage_price = brokerage_price + " + incrCount)
.eq(BrokerageUserDO::getId, id);
update(null, lambdaUpdateWrapper);
}
@@ -49,13 +56,14 @@ public interface BrokerageUserMapper extends BaseMapperX {
*
* @param id 用户编号
* @param incrCount 增加佣金(负数)
+ * @return 更新行数
*/
- default void updatePriceDecr(Long id, Integer incrCount) {
+ default int updatePriceDecr(Long id, Integer incrCount) {
Assert.isTrue(incrCount < 0);
LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper()
- .setSql(" price = price + " + incrCount) // 负数,所以使用 + 号
+ .setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号
.eq(BrokerageUserDO::getId, id);
- update(null, lambdaUpdateWrapper);
+ return update(null, lambdaUpdateWrapper);
}
/**
@@ -98,7 +106,7 @@ public interface BrokerageUserMapper extends BaseMapperX {
Assert.isTrue(incrCount < 0);
LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper()
.setSql(" frozen_price = frozen_price + " + incrCount + // 负数,所以使用 + 号
- ", price = price + " + -incrCount) // 负数,所以使用 - 号
+ ", brokerage_price = brokerage_price + " + -incrCount) // 负数,所以使用 - 号
.eq(BrokerageUserDO::getId, id)
.ge(BrokerageUserDO::getFrozenPrice, -incrCount); // cas 逻辑
return update(null, lambdaUpdateWrapper);
@@ -107,8 +115,7 @@ public interface BrokerageUserMapper extends BaseMapperX {
default void updateBindUserIdAndBindUserTimeToNull(Long id) {
update(null, new LambdaUpdateWrapper()
.eq(BrokerageUserDO::getId, id)
- .set(BrokerageUserDO::getBindUserId, null).set(BrokerageUserDO::getBindUserTime, null)
- .set(BrokerageUserDO::getLevel, 1).set(BrokerageUserDO::getPath, ""));
+ .set(BrokerageUserDO::getBindUserId, null).set(BrokerageUserDO::getBindUserTime, null));
}
default void updateEnabledFalseAndBrokerageTimeToNull(Long id) {
@@ -117,10 +124,26 @@ public interface BrokerageUserMapper extends BaseMapperX {
.set(BrokerageUserDO::getBrokerageEnabled, false).set(BrokerageUserDO::getBrokerageTime, null));
}
- default Long selectCountByBindUserIdAndLevelIn(Long bindUserId, List levels) {
+ default Long selectCountByBindUserIdIn(List bindUserIds) {
return selectCount(new LambdaQueryWrapperX