mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 19:50:06 +08:00
!635 分销Review代码修改
Merge pull request !635 from 疯狂的世界/feature/mall_product
This commit is contained in:
commit
c92365128a
@ -1,25 +1,25 @@
|
|||||||
-- 增加配置表
|
-- 增加配置表
|
||||||
create table trade_config
|
CREATE TABLE trade_config
|
||||||
(
|
(
|
||||||
id bigint auto_increment comment '自增主键' primary key,
|
id BIGINT AUTO_INCREMENT COMMENT '自增主键' PRIMARY KEY,
|
||||||
brokerage_enabled bit default 1 not null comment '是否启用分佣',
|
brokerage_enabled BIT DEFAULT 1 NOT NULL COMMENT '是否启用分佣',
|
||||||
brokerage_enabled_condition tinyint default 1 not null comment '分佣模式:1-人人分销 2-指定分销',
|
brokerage_enabled_condition TINYINT DEFAULT 1 NOT NULL COMMENT '分佣模式:1-人人分销 2-指定分销',
|
||||||
brokerage_bind_mode tinyint default 1 not null comment '分销关系绑定模式: 1-没有推广人,2-新用户, 3-扫码覆盖',
|
brokerage_bind_mode TINYINT DEFAULT 1 NOT NULL COMMENT '分销关系绑定模式: 1-没有推广人,2-新用户, 3-扫码覆盖',
|
||||||
brokerage_post_urls varchar(2000) default '' null comment '分销海报图地址数组',
|
brokerage_poster_urls VARCHAR(2000) DEFAULT '' NULL COMMENT '分销海报图地址数组',
|
||||||
brokerage_first_percent int default 0 not null comment '一级返佣比例',
|
brokerage_first_percent INT DEFAULT 0 NOT NULL COMMENT '一级返佣比例',
|
||||||
brokerage_second_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_min_price INT DEFAULT 0 NOT NULL COMMENT '用户提现最低金额',
|
||||||
brokerage_withdraw_fee_percent 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_bank_names VARCHAR(200) DEFAULT '' NOT NULL COMMENT '提现银行(字典类型=brokerage_bank_name)',
|
||||||
brokerage_frozen_days int default 7 not null comment '佣金冻结时间(天)',
|
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-支付宝',
|
brokerage_withdraw_types VARCHAR(32) DEFAULT '1,2,3,4' NOT NULL COMMENT '提现方式:1-钱包;2-银行卡;3-微信;4-支付宝',
|
||||||
creator varchar(64) default '' null comment '创建者',
|
creator VARCHAR(64) DEFAULT '' NULL COMMENT '创建者',
|
||||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间',
|
||||||
updater varchar(64) default '' null comment '更新者',
|
updater VARCHAR(64) DEFAULT '' NULL COMMENT '更新者',
|
||||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
deleted bit default b'0' not null comment '是否删除',
|
deleted BIT DEFAULT b'0' NOT NULL COMMENT '是否删除',
|
||||||
tenant_id bigint default 0 not null comment '租户编号'
|
tenant_id BIGINT DEFAULT 0 NOT NULL COMMENT '租户编号'
|
||||||
) comment '交易中心配置';
|
) COMMENT '交易中心配置';
|
||||||
|
|
||||||
# alter table trade_config
|
# alter table trade_config
|
||||||
# add brokerage_withdraw_fee_percent int default 0 not null comment '提现手续费百分比' after brokerage_withdraw_min_price;
|
# add brokerage_withdraw_fee_percent int default 0 not null comment '提现手续费百分比' after brokerage_withdraw_min_price;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.framework.common.util.number;
|
package cn.iocoder.yudao.framework.common.util.number;
|
||||||
|
|
||||||
|
import cn.hutool.core.math.Money;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -47,4 +48,23 @@ public class MoneyUtils {
|
|||||||
.divide(BigDecimal.valueOf(100), scale, roundingMode); // 除以 100
|
.divide(BigDecimal.valueOf(100), scale, roundingMode); // 除以 100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分转元
|
||||||
|
*
|
||||||
|
* @param fen 分
|
||||||
|
* @return 元
|
||||||
|
*/
|
||||||
|
public static BigDecimal fenToYuan(int fen) {
|
||||||
|
return new Money(0, fen).getAmount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分转元(字符串)
|
||||||
|
*
|
||||||
|
* @param fen 分
|
||||||
|
* @return 元
|
||||||
|
*/
|
||||||
|
public static String fenToYuanStr(int fen) {
|
||||||
|
return new Money(0, fen).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,4 +137,14 @@ public class ProductSpuRespDTO {
|
|||||||
*/
|
*/
|
||||||
private Integer clickCount;
|
private Integer clickCount;
|
||||||
|
|
||||||
|
|
||||||
|
// ========== 分销相关字段 =========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销类型
|
||||||
|
*
|
||||||
|
* false - 默认
|
||||||
|
* true - 自行设置
|
||||||
|
*/
|
||||||
|
private Boolean subCommissionType;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trade 字典类型的枚举类
|
||||||
|
*
|
||||||
|
* @author owen
|
||||||
|
*/
|
||||||
|
public interface DictTypeConstants {
|
||||||
|
|
||||||
|
String BROKERAGE_WITHDRAW_STATUS = "brokerage_withdraw_status"; // 佣金提现状态
|
||||||
|
}
|
@ -22,9 +22,6 @@ public enum BrokerageWithdrawStatusEnum implements IntArrayValuable {
|
|||||||
WITHDRAW_FAIL(21, "提现失败"),
|
WITHDRAW_FAIL(21, "提现失败"),
|
||||||
;
|
;
|
||||||
|
|
||||||
// TODO @疯狂:字典现在枚举在每个模块的 DictTypeConstants 里哈;可以创建一个出来;主要是想,治理每个模块到底有多少个枚举;
|
|
||||||
public static final String DICT_TYPE = "BROKERAGE_WITHDRAW_STATUS";
|
|
||||||
|
|
||||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawStatusEnum::getStatus).toArray();
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawStatusEnum::getStatus).toArray();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,9 +9,12 @@ 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.dal.dataobject.brokerage.BrokerageUserDO;
|
||||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
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.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.bo.UserBrokerageSummaryBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
|
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.BrokerageUserService;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -38,6 +41,8 @@ public class BrokerageUserController {
|
|||||||
private BrokerageUserService brokerageUserService;
|
private BrokerageUserService brokerageUserService;
|
||||||
@Resource
|
@Resource
|
||||||
private BrokerageRecordService brokerageRecordService;
|
private BrokerageRecordService brokerageRecordService;
|
||||||
|
@Resource
|
||||||
|
private BrokerageWithdrawService brokerageWithdrawService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MemberUserApi memberUserApi;
|
private MemberUserApi memberUserApi;
|
||||||
@ -97,9 +102,12 @@ public class BrokerageUserController {
|
|||||||
userId -> userId,
|
userId -> userId,
|
||||||
userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null));
|
userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null));
|
||||||
|
|
||||||
// todo 合计提现
|
// 合计提现
|
||||||
|
Map<Long, UserWithdrawSummaryBO> withdrawMap = convertMap(userIds,
|
||||||
|
userId -> userId,
|
||||||
|
userId -> brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS));
|
||||||
|
|
||||||
return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap));
|
return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap, withdrawMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class TradeConfigBaseVO {
|
|||||||
private Integer brokerageBindMode;
|
private Integer brokerageBindMode;
|
||||||
|
|
||||||
@Schema(description = "分销海报图地址数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/yudao.jpg]")
|
@Schema(description = "分销海报图地址数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/yudao.jpg]")
|
||||||
private List<String> brokeragePostUrls;
|
private List<String> brokeragePosterUrls;
|
||||||
|
|
||||||
@Schema(description = "一级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
@Schema(description = "一级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
||||||
@NotNull(message = "一级返佣比例不能为空")
|
@NotNull(message = "一级返佣比例不能为空")
|
||||||
@ -82,6 +82,6 @@ public class TradeConfigBaseVO {
|
|||||||
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]")
|
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]")
|
||||||
@NotNull(message = "提现方式不能为空")
|
@NotNull(message = "提现方式不能为空")
|
||||||
@InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}")
|
@InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}")
|
||||||
private List<Integer> brokerageWithdrawType;
|
private List<Integer> brokerageWithdrawTypes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBroke
|
|||||||
import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert;
|
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.dal.dataobject.brokerage.BrokerageRecordDO;
|
||||||
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
|
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
|
||||||
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -31,8 +30,6 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLogi
|
|||||||
@Validated
|
@Validated
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AppBrokerageRecordController {
|
public class AppBrokerageRecordController {
|
||||||
@Resource
|
|
||||||
private BrokerageUserService brokerageUserService;
|
|
||||||
@Resource
|
@Resource
|
||||||
private BrokerageRecordService brokerageRecordService;
|
private BrokerageRecordService brokerageRecordService;
|
||||||
|
|
||||||
@ -45,15 +42,10 @@ public class AppBrokerageRecordController {
|
|||||||
return success(BrokerageRecordConvert.INSTANCE.convertPage02(pageResult));
|
return success(BrokerageRecordConvert.INSTANCE.convertPage02(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @疯狂:这里还有一个漏网之鱼~
|
|
||||||
@GetMapping("/get-product-brokerage-price")
|
@GetMapping("/get-product-brokerage-price")
|
||||||
@Operation(summary = "获得商品的分销金额")
|
@Operation(summary = "获得商品的分销金额")
|
||||||
public CommonResult<AppBrokerageProductPriceRespVO> getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
|
public CommonResult<AppBrokerageProductPriceRespVO> getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
|
||||||
AppBrokerageProductPriceRespVO respVO = new AppBrokerageProductPriceRespVO();
|
return success(brokerageRecordService.calculateProductBrokeragePrice(spuId, getLoginUserId()));
|
||||||
respVO.setEnabled(brokerageUserService.getUserBrokerageEnabled(getLoginUserId()));
|
|
||||||
respVO.setBrokerageMinPrice(1);
|
|
||||||
respVO.setBrokerageMaxPrice(2);
|
|
||||||
return success(respVO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ 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.BrokerageRecordService;
|
||||||
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService;
|
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.BrokerageWithdrawService;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -67,8 +68,8 @@ public class AppBrokerageUserController {
|
|||||||
@Operation(summary = "绑定推广员")
|
@Operation(summary = "绑定推广员")
|
||||||
@PreAuthenticated
|
@PreAuthenticated
|
||||||
public CommonResult<Boolean> bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) {
|
public CommonResult<Boolean> bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) {
|
||||||
// TODO @疯狂:是不是 isNewUser 不用传递哈,交给 service 自己计算出来?
|
MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId());
|
||||||
return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId(), false));
|
return success(brokerageUserService.bindBrokerageUser(user.getId(), reqVO.getBindUserId(), user.getCreateTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get-summary")
|
@GetMapping("/get-summary")
|
||||||
@ -82,7 +83,7 @@ public class AppBrokerageUserController {
|
|||||||
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
|
LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday);
|
||||||
AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO()
|
AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO()
|
||||||
.setYesterdayPrice(brokerageRecordService.getSummaryPriceByUserId(userId, BrokerageRecordBizTypeEnum.ORDER.getType(), beginTime, endTime))
|
.setYesterdayPrice(brokerageRecordService.getSummaryPriceByUserId(userId, BrokerageRecordBizTypeEnum.ORDER.getType(), beginTime, endTime))
|
||||||
.setWithdrawPrice(brokerageWithdrawService.getSummaryPriceByUserIdAndStatus(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.getStatus()))
|
.setWithdrawPrice(Optional.ofNullable(brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS)).map(UserWithdrawSummaryBO::getPrice).orElse(0))
|
||||||
.setBrokeragePrice(0).setFrozenPrice(0)
|
.setBrokeragePrice(0).setFrozenPrice(0)
|
||||||
.setFirstBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 1))
|
.setFirstBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 1))
|
||||||
.setSecondBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 2));
|
.setSecondBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 2));
|
||||||
|
@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBro
|
|||||||
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO;
|
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.convert.brokerage.BrokerageWithdrawConvert;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
|
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.BrokerageWithdrawService;
|
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
|
||||||
@ -44,10 +42,7 @@ public class AppBrokerageWithdrawController {
|
|||||||
// 分页查询
|
// 分页查询
|
||||||
PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(
|
PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(
|
||||||
BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId()));
|
BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId()));
|
||||||
// 拼接信息
|
return success(BrokerageWithdrawConvert.INSTANCE.convertPage03(pageResult));
|
||||||
// TODO @疯狂:后端可以直接用 DictFrameworkUtils.getDictDataLabel() 去渲染哈;这样就不用 getDictDataLabelMap 方法了;
|
|
||||||
Map<String, String> statusNameMap = dictDataApi.getDictDataLabelMap(BrokerageWithdrawStatusEnum.DICT_TYPE);
|
|
||||||
return success(BrokerageWithdrawConvert.INSTANCE.convertPage02(pageResult, statusNameMap));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.controller.app.config;
|
|||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
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.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.dal.dataobject.config.TradeConfigDO;
|
||||||
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -33,13 +34,7 @@ public class AppTradeConfigController {
|
|||||||
@Operation(summary = "获得交易配置")
|
@Operation(summary = "获得交易配置")
|
||||||
public CommonResult<AppTradeConfigRespVO> getTradeConfig() {
|
public CommonResult<AppTradeConfigRespVO> getTradeConfig() {
|
||||||
TradeConfigDO tradeConfig = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO());
|
TradeConfigDO tradeConfig = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO());
|
||||||
// TODO @疯狂:是不是直接 convert 就好啦;
|
return success(TradeConfigConvert.INSTANCE.convert02(tradeConfig));
|
||||||
AppTradeConfigRespVO respVO = new AppTradeConfigRespVO()
|
|
||||||
.setBrokeragePosterUrls(tradeConfig.getBrokeragePostUrls())
|
|
||||||
.setBrokerageFrozenDays(tradeConfig.getBrokerageFrozenDays())
|
|
||||||
.setBrokerageWithdrawMinPrice(tradeConfig.getBrokerageWithdrawMinPrice())
|
|
||||||
.setBrokerageWithdrawType(tradeConfig.getBrokerageWithdrawType());
|
|
||||||
return success(respVO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@ public class AppTradeConfigRespVO {
|
|||||||
@Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
@Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
private Integer brokerageWithdrawMinPrice;
|
private Integer brokerageWithdrawMinPrice;
|
||||||
|
|
||||||
// TODO @疯狂:如果是 list,要不加个 s,复数;
|
|
||||||
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
|
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
|
||||||
private List<Integer> brokerageWithdrawType;
|
private List<Integer> brokerageWithdrawTypes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.math.Money;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
|
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.admin.brokerage.vo.record.BrokerageRecordRespVO;
|
||||||
@ -51,7 +52,7 @@ public interface BrokerageRecordConvert {
|
|||||||
.setBizType(bizType.getType()).setBizId(bizId)
|
.setBizType(bizType.getType()).setBizId(bizId)
|
||||||
.setPrice(brokeragePrice).setTotalPrice(user.getBrokeragePrice())
|
.setPrice(brokeragePrice).setTotalPrice(user.getBrokeragePrice())
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setDescription(StrUtil.format(bizType.getDescription(), new Money(0, Math.abs(brokeragePrice))))
|
.setDescription(StrUtil.format(bizType.getDescription(), MoneyUtils.fenToYuanStr(Math.abs(brokeragePrice))))
|
||||||
.setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime)
|
.setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime)
|
||||||
.setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId);
|
.setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.Brokerag
|
|||||||
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO;
|
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.dal.dataobject.brokerage.BrokerageUserDO;
|
||||||
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
|
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.Mapper;
|
||||||
import org.mapstruct.MappingTarget;
|
import org.mapstruct.MappingTarget;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
@ -29,13 +30,14 @@ public interface BrokerageUserConvert {
|
|||||||
|
|
||||||
List<BrokerageUserRespVO> convertList(List<BrokerageUserDO> list);
|
List<BrokerageUserRespVO> convertList(List<BrokerageUserDO> list);
|
||||||
|
|
||||||
PageResult<BrokerageUserRespVO> convertPage(PageResult<BrokerageUserDO> page);
|
PageResult<BrokerageUserRespVO> convertPage(PageResult<BrokerageUserDO> page, Map<Long, MemberUserRespDTO> userMap, Map<Long, Long> brokerageUserCountMap, Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap);
|
||||||
|
|
||||||
default PageResult<BrokerageUserRespVO> convertPage(PageResult<BrokerageUserDO> pageResult,
|
default PageResult<BrokerageUserRespVO> convertPage(PageResult<BrokerageUserDO> pageResult,
|
||||||
Map<Long, MemberUserRespDTO> userMap,
|
Map<Long, MemberUserRespDTO> userMap,
|
||||||
Map<Long, Long> brokerageUserCountMap,
|
Map<Long, Long> brokerageUserCountMap,
|
||||||
Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap) {
|
Map<Long, UserBrokerageSummaryBO> userOrderSummaryMap,
|
||||||
PageResult<BrokerageUserRespVO> result = convertPage(pageResult);
|
Map<Long, UserWithdrawSummaryBO> withdrawMap) {
|
||||||
|
PageResult<BrokerageUserRespVO> result = convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap);
|
||||||
for (BrokerageUserRespVO userVO : result.getList()) {
|
for (BrokerageUserRespVO userVO : result.getList()) {
|
||||||
// 用户信息
|
// 用户信息
|
||||||
copyTo(userMap.get(userVO.getId()), userVO);
|
copyTo(userMap.get(userVO.getId()), userVO);
|
||||||
@ -46,7 +48,10 @@ public interface BrokerageUserConvert {
|
|||||||
Optional<UserBrokerageSummaryBO> orderSummaryOptional = Optional.ofNullable(userOrderSummaryMap.get(userVO.getId()));
|
Optional<UserBrokerageSummaryBO> orderSummaryOptional = Optional.ofNullable(userOrderSummaryMap.get(userVO.getId()));
|
||||||
userVO.setBrokerageOrderCount(orderSummaryOptional.map(UserBrokerageSummaryBO::getCount).orElse(0))
|
userVO.setBrokerageOrderCount(orderSummaryOptional.map(UserBrokerageSummaryBO::getCount).orElse(0))
|
||||||
.setBrokerageOrderPrice(orderSummaryOptional.map(UserBrokerageSummaryBO::getPrice).orElse(0));
|
.setBrokerageOrderPrice(orderSummaryOptional.map(UserBrokerageSummaryBO::getPrice).orElse(0));
|
||||||
// todo 已提现次数、已提现金额
|
// 已提现次数、已提现金额
|
||||||
|
Optional<UserWithdrawSummaryBO> 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);
|
userVO.setWithdrawCount(0).setWithdrawPrice(0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.trade.convert.brokerage;
|
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.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.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.BrokerageWithdrawPageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO;
|
||||||
@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBro
|
|||||||
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO;
|
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.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
|
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.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@ -44,10 +45,10 @@ public interface BrokerageWithdrawConvert {
|
|||||||
|
|
||||||
PageResult<AppBrokerageWithdrawRespVO> convertPage02(PageResult<BrokerageWithdrawDO> pageResult);
|
PageResult<AppBrokerageWithdrawRespVO> convertPage02(PageResult<BrokerageWithdrawDO> pageResult);
|
||||||
|
|
||||||
default PageResult<AppBrokerageWithdrawRespVO> convertPage02(PageResult<BrokerageWithdrawDO> pageResult, Map<String, String> statusNameMap) {
|
default PageResult<AppBrokerageWithdrawRespVO> convertPage03(PageResult<BrokerageWithdrawDO> pageResult) {
|
||||||
PageResult<AppBrokerageWithdrawRespVO> result = convertPage02(pageResult);
|
PageResult<AppBrokerageWithdrawRespVO> result = convertPage02(pageResult);
|
||||||
for (AppBrokerageWithdrawRespVO vo : result.getList()) {
|
for (AppBrokerageWithdrawRespVO vo : result.getList()) {
|
||||||
vo.setStatusName(MapUtil.getStr(statusNameMap, String.valueOf(vo.getStatus()), ""));
|
vo.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, vo.getStatus()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -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.TradeConfigRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO;
|
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 cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
@ -20,4 +21,5 @@ public interface TradeConfigConvert {
|
|||||||
|
|
||||||
TradeConfigRespVO convert(TradeConfigDO bean);
|
TradeConfigRespVO convert(TradeConfigDO bean);
|
||||||
|
|
||||||
|
AppTradeConfigRespVO convert02(TradeConfigDO tradeConfig);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.trade.convert.order;
|
package cn.iocoder.yudao.module.trade.convert.order;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.BooleanUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.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.property.dto.ProductPropertyValueDetailRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
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.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.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
|
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO;
|
||||||
@ -266,11 +268,16 @@ public interface TradeOrderConvert {
|
|||||||
|
|
||||||
TradeOrderDO convert(TradeOrderRemarkReqVO reqVO);
|
TradeOrderDO convert(TradeOrderRemarkReqVO reqVO);
|
||||||
|
|
||||||
default BrokerageAddReqBO convert(MemberUserRespDTO user, TradeOrderItemDO item, ProductSkuRespDTO sku) {
|
default BrokerageAddReqBO convert(MemberUserRespDTO user, TradeOrderItemDO item,
|
||||||
return new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())).setSourceUserId(item.getUserId())
|
ProductSpuRespDTO spu, ProductSkuRespDTO sku) {
|
||||||
|
BrokerageAddReqBO bo = new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())).setSourceUserId(item.getUserId())
|
||||||
.setBasePrice(item.getPayPrice() * item.getCount())
|
.setBasePrice(item.getPayPrice() * item.getCount())
|
||||||
.setTitle(StrUtil.format("{}成功购买{}", user.getNickname(), item.getSpuName()))
|
.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);
|
TradeBeforeOrderCreateReqBO convert(AppTradeOrderCreateReqVO createReqVO);
|
||||||
|
@ -68,7 +68,7 @@ public class TradeConfigDO extends BaseDO {
|
|||||||
* 分销海报图地址数组
|
* 分销海报图地址数组
|
||||||
*/
|
*/
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
private List<String> brokeragePostUrls;
|
private List<String> brokeragePosterUrls;
|
||||||
/**
|
/**
|
||||||
* 一级返佣比例
|
* 一级返佣比例
|
||||||
*/
|
*/
|
||||||
@ -100,6 +100,6 @@ public class TradeConfigDO extends BaseDO {
|
|||||||
* 枚举 {@link BrokerageWithdrawTypeEnum 对应的类}
|
* 枚举 {@link BrokerageWithdrawTypeEnum 对应的类}
|
||||||
*/
|
*/
|
||||||
@TableField(typeHandler = IntegerListTypeHandler.class)
|
@TableField(typeHandler = IntegerListTypeHandler.class)
|
||||||
private List<Integer> brokerageWithdrawType;
|
private List<Integer> brokerageWithdrawTypes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,14 +53,14 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Select("SELECT COUNT(1), SUM(price) FROM trade_brokerage_record " +
|
@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,
|
UserBrokerageSummaryBO selectCountAndSumPriceByUserIdAndBizTypeAndStatus(@Param("userId") Long userId,
|
||||||
@Param("bizType") Integer bizType,
|
@Param("bizType") Integer bizType,
|
||||||
@Param("status") Integer status);
|
@Param("status") Integer status);
|
||||||
|
|
||||||
@Select("SELECT SUM(price) FROM trade_brokerage_record " +
|
@Select("SELECT SUM(price) FROM trade_brokerage_record " +
|
||||||
"WHERE user_id = #{userId} AND biz_type = #{bizType} " +
|
"WHERE user_id = #{userId} AND biz_type = #{bizType} " +
|
||||||
"AND create_time BETWEEN #{beginTime} AND #{endTime}")
|
"AND create_time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE")
|
||||||
Integer selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(@Param("userId") Long userId,
|
Integer selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(@Param("userId") Long userId,
|
||||||
@Param("bizType") Integer bizType,
|
@Param("bizType") Integer bizType,
|
||||||
@Param("beginTime") LocalDateTime beginTime,
|
@Param("beginTime") LocalDateTime beginTime,
|
||||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@ -36,8 +37,8 @@ public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO
|
|||||||
.eq(BrokerageWithdrawDO::getStatus, status));
|
.eq(BrokerageWithdrawDO::getStatus, status));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Select("SELECT SUM(price) FROM trade_brokerage_withdraw " +
|
@Select("SELECT COUNT(1) AS count, SUM(price) AS price FROM trade_brokerage_withdraw " +
|
||||||
"WHERE user_id = #{userId} AND status = #{status}")
|
"WHERE user_id = #{userId} AND status = #{status} AND deleted = FALSE")
|
||||||
Integer selectSummaryPriceByUserIdAndStatus(@Param("userId") Long userId, @Param("status") Integer status);
|
UserWithdrawSummaryBO selectCountAndSumPriceByUserIdAndStatus(@Param("userId") Long userId,
|
||||||
|
@Param("status") Integer status);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.service.brokerage;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO;
|
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
|
||||||
@ -110,4 +111,12 @@ public interface BrokerageRecordService {
|
|||||||
*/
|
*/
|
||||||
Integer getUserRankByPrice(Long userId, LocalDateTime[] times);
|
Integer getUserRankByPrice(Long userId, LocalDateTime[] times);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算商品被购买后,推广员可以得到的佣金
|
||||||
|
*
|
||||||
|
* @param spuId 商品编号
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @return 用户佣金
|
||||||
|
*/
|
||||||
|
AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long spuId, Long userId);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.trade.service.brokerage;
|
package cn.iocoder.yudao.module.trade.service.brokerage;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.math.Money;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.BooleanUtil;
|
import cn.hutool.core.util.BooleanUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
@ -10,7 +10,12 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||||
|
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;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO;
|
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO;
|
||||||
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert;
|
import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert;
|
||||||
@ -37,6 +42,9 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue;
|
||||||
|
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
|
||||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH;
|
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,6 +64,11 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
|||||||
@Resource
|
@Resource
|
||||||
private BrokerageUserService brokerageUserService;
|
private BrokerageUserService brokerageUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProductSpuApi productSpuApi;
|
||||||
|
@Resource
|
||||||
|
private ProductSkuApi productSkuApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BrokerageRecordDO getBrokerageRecord(Integer id) {
|
public BrokerageRecordDO getBrokerageRecord(Integer id) {
|
||||||
return brokerageRecordMapper.selectById(id);
|
return brokerageRecordMapper.selectById(id);
|
||||||
@ -240,7 +253,6 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
|||||||
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
|
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @疯狂:这个求出来,应该是不准的?例如说超过 100+ 名后?
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getUserRankByPrice(Long userId, LocalDateTime[] times) {
|
public Integer getUserRankByPrice(Long userId, LocalDateTime[] times) {
|
||||||
AppBrokerageUserRankPageReqVO pageParam = new AppBrokerageUserRankPageReqVO().setTimes(times);
|
AppBrokerageUserRankPageReqVO pageParam = new AppBrokerageUserRankPageReqVO().setTimes(times);
|
||||||
@ -261,15 +273,14 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
|||||||
int balance = Optional.of(user)
|
int balance = Optional.of(user)
|
||||||
.map(BrokerageUserDO::getBrokeragePrice).orElse(0);
|
.map(BrokerageUserDO::getBrokeragePrice).orElse(0);
|
||||||
if (balance + brokeragePrice < 0) {
|
if (balance + brokeragePrice < 0) {
|
||||||
// TODO @疯狂:要不 MoneyUtils 那,统一搞个 format 金额的方法?然后把分到元的字符串,统一收口掉;
|
throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance));
|
||||||
throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 更新佣金余额
|
// 2. 更新佣金余额
|
||||||
boolean success = brokerageUserService.updateUserPrice(userId, brokeragePrice);
|
boolean success = brokerageUserService.updateUserPrice(userId, brokeragePrice);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// 失败时,则抛出异常。只会出现扣减佣金时,余额不足的情况
|
// 失败时,则抛出异常。只会出现扣减佣金时,余额不足的情况
|
||||||
throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance));
|
throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 新增记录
|
// 3. 新增记录
|
||||||
@ -296,6 +307,50 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long spuId, Long userId) {
|
||||||
|
// 1. 构建默认的返回值
|
||||||
|
AppBrokerageProductPriceRespVO respVO = new AppBrokerageProductPriceRespVO().setEnabled(false)
|
||||||
|
.setBrokerageMinPrice(0).setBrokerageMaxPrice(0);
|
||||||
|
|
||||||
|
// 2.1 校验分销功能是否开启
|
||||||
|
TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig();
|
||||||
|
if (tradeConfig == null || !BooleanUtil.isTrue(tradeConfig.getBrokerageEnabled())) {
|
||||||
|
return respVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.2 校验用户是否有分销资格
|
||||||
|
respVO.setEnabled(brokerageUserService.getUserBrokerageEnabled(getLoginUserId()));
|
||||||
|
if (!BooleanUtil.isTrue(respVO.getEnabled())) {
|
||||||
|
return respVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer fixedMinPrice = 0;
|
||||||
|
Integer fixedMaxPrice = 0;
|
||||||
|
Integer spuMinPrice = 0;
|
||||||
|
Integer spuMaxPrice = 0;
|
||||||
|
// 2.3 校验商品是否存在
|
||||||
|
ProductSpuRespDTO spu = productSpuApi.getSpu(spuId);
|
||||||
|
if (spu == null) {
|
||||||
|
return respVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ProductSkuRespDTO> skuList = productSkuApi.getSkuListBySpuId(ListUtil.of(spuId));
|
||||||
|
if (BooleanUtil.isTrue(spu.getSubCommissionType())) {
|
||||||
|
// 3.1 商品单独分佣模式
|
||||||
|
fixedMinPrice = getMinValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice);
|
||||||
|
fixedMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice);
|
||||||
|
} else {
|
||||||
|
// 3.2 全局分佣模式(根据商品价格比例计算)
|
||||||
|
spuMinPrice = getMinValue(skuList, ProductSkuRespDTO::getPrice);
|
||||||
|
spuMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getPrice);
|
||||||
|
}
|
||||||
|
|
||||||
|
respVO.setBrokerageMinPrice(calculatePrice(spuMinPrice, tradeConfig.getBrokerageFirstPercent(), fixedMinPrice));
|
||||||
|
respVO.setBrokerageMaxPrice(calculatePrice(spuMaxPrice, tradeConfig.getBrokerageFirstPercent(), fixedMaxPrice));
|
||||||
|
return respVO;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得自身的代理对象,解决 AOP 生效问题
|
* 获得自身的代理对象,解决 AOP 生效问题
|
||||||
*
|
*
|
||||||
|
@ -261,12 +261,15 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 下级不能绑定自己的上级
|
// 下级不能绑定自己的上级
|
||||||
// TODO @疯狂:这里是不是查询不到的时候,应该有个 break 结束循环哈
|
|
||||||
for (int i = 0; i <= Short.MAX_VALUE; i++) {
|
for (int i = 0; i <= Short.MAX_VALUE; i++) {
|
||||||
if (Objects.equals(bindUser.getBindUserId(), user.getId())) {
|
if (Objects.equals(bindUser.getBindUserId(), user.getId())) {
|
||||||
throw exception(BROKERAGE_BIND_LOOP);
|
throw exception(BROKERAGE_BIND_LOOP);
|
||||||
}
|
}
|
||||||
bindUser = getBrokerageUser(bindUser.getBindUserId());
|
bindUser = getBrokerageUser(bindUser.getBindUserId());
|
||||||
|
// 找到根节点,结束循环
|
||||||
|
if (bindUser == null || bindUser.getBindUserId() == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.Brok
|
|||||||
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO;
|
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
|
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.enums.brokerage.BrokerageWithdrawStatusEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 佣金提现 Service 接口
|
* 佣金提现 Service 接口
|
||||||
@ -48,12 +49,12 @@ public interface BrokerageWithdrawService {
|
|||||||
Long createBrokerageWithdraw(AppBrokerageWithdrawCreateReqVO createReqVO, Long userId);
|
Long createBrokerageWithdraw(AppBrokerageWithdrawCreateReqVO createReqVO, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得用户已提现金额
|
* 汇总用户提现
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param status 状态
|
* @param status 提现状态
|
||||||
* @return 用户已提现金额
|
* @return 用户提现汇总
|
||||||
*/
|
*/
|
||||||
Integer getSummaryPriceByUserIdAndStatus(Long userId, Integer status);
|
UserWithdrawSummaryBO getWithdrawSummaryByUserId(Long userId, BrokerageWithdrawStatusEnum status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.trade.service.brokerage;
|
|||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.math.Money;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||||
@ -18,6 +17,7 @@ import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants;
|
|||||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
|
||||||
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum;
|
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
||||||
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -93,7 +93,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
|||||||
// 4. 通知用户
|
// 4. 通知用户
|
||||||
Map<String, Object> templateParams = MapUtil.<String, Object>builder()
|
Map<String, Object> templateParams = MapUtil.<String, Object>builder()
|
||||||
.put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime()))
|
.put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime()))
|
||||||
.put("price", new Money(0, withdraw.getPrice()).toString())
|
.put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice()))
|
||||||
.put("reason", withdraw.getAuditReason())
|
.put("reason", withdraw.getAuditReason())
|
||||||
.build();
|
.build();
|
||||||
NotifySendSingleToUserReqDTO reqDTO = new NotifySendSingleToUserReqDTO()
|
NotifySendSingleToUserReqDTO reqDTO = new NotifySendSingleToUserReqDTO()
|
||||||
@ -142,8 +142,9 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getSummaryPriceByUserIdAndStatus(Long userId, Integer status) {
|
public UserWithdrawSummaryBO getWithdrawSummaryByUserId(Long userId, BrokerageWithdrawStatusEnum status) {
|
||||||
return brokerageWithdrawMapper.selectSummaryPriceByUserIdAndStatus(userId, status);
|
UserWithdrawSummaryBO summaryBO = brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userId, status.getStatus());
|
||||||
|
return summaryBO != null ? summaryBO : new UserWithdrawSummaryBO(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,7 +171,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService {
|
|||||||
TradeConfigDO validateWithdrawPrice(Integer withdrawPrice) {
|
TradeConfigDO validateWithdrawPrice(Integer withdrawPrice) {
|
||||||
TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig();
|
TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig();
|
||||||
if (tradeConfig.getBrokerageWithdrawMinPrice() != null && withdrawPrice < tradeConfig.getBrokerageWithdrawMinPrice()) {
|
if (tradeConfig.getBrokerageWithdrawMinPrice() != null && withdrawPrice < tradeConfig.getBrokerageWithdrawMinPrice()) {
|
||||||
throw exception(BROKERAGE_WITHDRAW_MIN_PRICE, new Money(0, tradeConfig.getBrokerageWithdrawMinPrice()));
|
throw exception(BROKERAGE_WITHDRAW_MIN_PRICE, MoneyUtils.fenToYuanStr(tradeConfig.getBrokerageWithdrawMinPrice()));
|
||||||
}
|
}
|
||||||
return tradeConfig;
|
return tradeConfig;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.service.brokerage.bo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户佣金提现合计 BO
|
||||||
|
*
|
||||||
|
* @author owen
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UserWithdrawSummaryBO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提现次数
|
||||||
|
*/
|
||||||
|
private Integer count;
|
||||||
|
/**
|
||||||
|
* 提现金额
|
||||||
|
*/
|
||||||
|
private Integer price;
|
||||||
|
|
||||||
|
}
|
@ -849,7 +849,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||||||
// 每一个订单项,都会去生成分销记录
|
// 每一个订单项,都会去生成分销记录
|
||||||
List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(orderId);
|
List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(orderId);
|
||||||
List<BrokerageAddReqBO> addList = convertList(orderItems,
|
List<BrokerageAddReqBO> addList = convertList(orderItems,
|
||||||
item -> TradeOrderConvert.INSTANCE.convert(user, item, productSkuApi.getSku(item.getSkuId())));
|
item -> TradeOrderConvert.INSTANCE.convert(user, item,
|
||||||
|
productSpuApi.getSpu(item.getSpuId()), productSkuApi.getSku(item.getSkuId())));
|
||||||
brokerageRecordService.addBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, addList);
|
brokerageRecordService.addBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, addList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.member.api.user.dto;
|
|||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息 Response DTO
|
* 用户信息 Response DTO
|
||||||
*
|
*
|
||||||
@ -33,6 +35,10 @@ public class MemberUserRespDTO {
|
|||||||
* 手机
|
* 手机
|
||||||
*/
|
*/
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
// ========== 其它信息 ==========
|
// ========== 其它信息 ==========
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.system.api.dict;
|
|||||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典数据 API 接口
|
* 字典数据 API 接口
|
||||||
@ -32,23 +30,6 @@ public interface DictDataApi {
|
|||||||
*/
|
*/
|
||||||
DictDataRespDTO getDictData(String type, String value);
|
DictDataRespDTO getDictData(String type, String value);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得指定类型的字典数据,从缓存中
|
|
||||||
*
|
|
||||||
* @param type 字典类型
|
|
||||||
* @return 字典数据
|
|
||||||
*/
|
|
||||||
List<DictDataRespDTO> getDictDataList(String type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得指定类型的字典数据 标签字典,从缓存中
|
|
||||||
* key:value, value: label
|
|
||||||
*
|
|
||||||
* @param type 字典类型
|
|
||||||
* @return 字典数据
|
|
||||||
*/
|
|
||||||
Map<String, String> getDictDataLabelMap(String type);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析获得指定的字典数据,从缓存中
|
* 解析获得指定的字典数据,从缓存中
|
||||||
*
|
*
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.system.api.dict;
|
package cn.iocoder.yudao.module.system.api.dict;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert;
|
import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||||
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
||||||
@ -9,10 +8,6 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典数据 API 实现类
|
* 字典数据 API 实现类
|
||||||
@ -36,19 +31,6 @@ public class DictDataApiImpl implements DictDataApi {
|
|||||||
return DictDataConvert.INSTANCE.convert02(dictData);
|
return DictDataConvert.INSTANCE.convert02(dictData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<DictDataRespDTO> getDictDataList(String type) {
|
|
||||||
// TODO @疯狂:不用 DictDataExportReqVO 哈;可以考虑直接加个允许传递 type 传递的
|
|
||||||
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(type));
|
|
||||||
return DictDataConvert.INSTANCE.convertList04(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> getDictDataLabelMap(String type) {
|
|
||||||
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(type));
|
|
||||||
return convertMap(list, DictDataDO::getValue, DictDataDO::getLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DictDataRespDTO parseDictData(String dictType, String label) {
|
public DictDataRespDTO parseDictData(String dictType, String label) {
|
||||||
DictDataDO dictData = dictDataService.parseDictData(dictType, label);
|
DictDataDO dictData = dictDataService.parseDictData(dictType, label);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package cn.iocoder.yudao.module.system.controller.app.dict;
|
package cn.iocoder.yudao.module.system.controller.app.dict;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.app.dict.vo.AppDictDataRespVO;
|
import cn.iocoder.yudao.module.system.controller.app.dict.vo.AppDictDataRespVO;
|
||||||
import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert;
|
import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||||
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -28,11 +28,11 @@ public class AppDictDataController {
|
|||||||
@Resource
|
@Resource
|
||||||
private DictDataService dictDataService;
|
private DictDataService dictDataService;
|
||||||
|
|
||||||
// TODO @疯狂:暂时不用 path 参数哈;主要考虑一些中间件支持的一般,例如说链路追踪之类的;还是作为一个参数噶;
|
@GetMapping("/type")
|
||||||
@GetMapping("/type/{dictType}")
|
|
||||||
@Operation(summary = "根据字典类型查询字典数据信息")
|
@Operation(summary = "根据字典类型查询字典数据信息")
|
||||||
public CommonResult<List<AppDictDataRespVO>> getDictDataList(@PathVariable String dictType) {
|
@Parameter(name = "type", description = "字典类型", required = true, example = "common_status")
|
||||||
List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(dictType));
|
public CommonResult<List<AppDictDataRespVO>> getDictDataListByType(@RequestParam String type) {
|
||||||
|
List<DictDataDO> list = dictDataService.getEnabledDictDataListByType(type);
|
||||||
return success(DictDataConvert.INSTANCE.convertList03(list));
|
return success(DictDataConvert.INSTANCE.convertList03(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +1,41 @@
|
|||||||
package cn.iocoder.yudao.module.system.controller.app.dict.vo;
|
package cn.iocoder.yudao.module.system.controller.app.dict.vo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataBaseVO;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
@Schema(description = "用户 App - 字典数据信息 Response VO")
|
@Schema(description = "用户 App - 字典数据信息 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
public class AppDictDataRespVO {
|
||||||
public class AppDictDataRespVO extends DictDataBaseVO {
|
|
||||||
|
|
||||||
// TODO @疯狂:app 的接口,不集成 admin 接口的 vo 哈;看看是不是只返回必要的字段,类似 remark、sort 不好返回的哈;
|
|
||||||
|
|
||||||
@Schema(description = "字典数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "字典数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "字典标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||||
|
@NotBlank(message = "字典标签不能为空")
|
||||||
|
@Size(max = 100, message = "字典标签长度不能超过100个字符")
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
@Schema(description = "字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "iocoder")
|
||||||
|
@NotBlank(message = "字典键值不能为空")
|
||||||
|
@Size(max = 100, message = "字典键值长度不能超过100个字符")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
@Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "sys_common_sex")
|
||||||
|
@NotBlank(message = "字典类型不能为空")
|
||||||
|
@Size(max = 100, message = "字典类型长度不能超过100个字符")
|
||||||
|
private String dictType;
|
||||||
|
|
||||||
|
@Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default")
|
||||||
|
private String colorType;
|
||||||
|
@Schema(description = "css 样式", example = "btn-visible")
|
||||||
|
private String cssClass;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,4 +48,8 @@ public interface DictDataMapper extends BaseMapperX<DictDataDO> {
|
|||||||
.eqIfPresent(DictDataDO::getStatus, reqVO.getStatus()));
|
.eqIfPresent(DictDataDO::getStatus, reqVO.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<DictDataDO> selectListByTypeAndStatus(String dictType, Integer status) {
|
||||||
|
return selectList(new LambdaQueryWrapper<DictDataDO>()
|
||||||
|
.eq(DictDataDO::getDictType, dictType).eq(DictDataDO::getStatus, status));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,14 @@ public interface DictDataService {
|
|||||||
*/
|
*/
|
||||||
List<DictDataDO> getDictDataList(DictDataExportReqVO reqVO);
|
List<DictDataDO> getDictDataList(DictDataExportReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得字典数据列表
|
||||||
|
*
|
||||||
|
* @param dictType 字典类型
|
||||||
|
* @return 字典数据列表
|
||||||
|
*/
|
||||||
|
List<DictDataDO> getEnabledDictDataListByType(String dictType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得字典数据详情
|
* 获得字典数据详情
|
||||||
*
|
*
|
||||||
|
@ -66,6 +66,13 @@ public class DictDataServiceImpl implements DictDataService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DictDataDO> getEnabledDictDataListByType(String dictType) {
|
||||||
|
List<DictDataDO> list = dictDataMapper.selectListByTypeAndStatus(dictType, CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
list.sort(COMPARATOR_TYPE_AND_SORT);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DictDataDO getDictData(Long id) {
|
public DictDataDO getDictData(Long id) {
|
||||||
return dictDataMapper.selectById(id);
|
return dictDataMapper.selectById(id);
|
||||||
|
Loading…
Reference in New Issue
Block a user