会员:会员配置的积分相关字段加上point前缀
This commit is contained in:
parent
ab35fcbe9b
commit
2168145c3e
@ -815,10 +815,10 @@ COMMIT;
|
|||||||
DROP TABLE IF EXISTS `member_config`;
|
DROP TABLE IF EXISTS `member_config`;
|
||||||
CREATE TABLE `member_config` (
|
CREATE TABLE `member_config` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
|
||||||
`trade_deduct_enable` bit(1) NOT NULL COMMENT '是否开启积分抵扣',
|
`point_trade_deduct_enable` bit(1) NOT NULL COMMENT '是否开启积分抵扣',
|
||||||
`trade_deduct_unit_price` int NOT NULL COMMENT '积分抵扣(单位:分)',
|
`point_trade_deduct_unit_price` int NOT NULL COMMENT '积分抵扣(单位:分)',
|
||||||
`trade_deduct_max_price` int NULL DEFAULT NULL COMMENT '积分抵扣最大值',
|
`point_trade_deduct_max_price` int NULL DEFAULT NULL COMMENT '积分抵扣最大值',
|
||||||
`trade_give_point` bigint NULL DEFAULT NULL COMMENT '1 元赠送多少分',
|
`point_trade_give_point` bigint NULL DEFAULT NULL COMMENT '1 元赠送多少分',
|
||||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||||
@ -832,7 +832,7 @@ CREATE TABLE `member_config` (
|
|||||||
-- Records of member_config
|
-- Records of member_config
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO `member_config` (`id`, `trade_deduct_enable`, `trade_deduct_unit_price`, `trade_deduct_max_price`, `trade_give_point`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (5, b'1', 100, 2, 3, '1', '2023-08-20 09:54:42', '1', '2023-08-20 09:54:42', b'0', 1);
|
INSERT INTO `member_config` (`id`, `point_trade_deduct_enable`, `point_trade_deduct_unit_price`, `point_trade_deduct_max_price`, `point_trade_give_point`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (5, b'1', 100, 2, 3, '1', '2023-08-20 09:54:42', '1', '2023-08-20 09:54:42', b'0', 1);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
@ -34,8 +34,8 @@ public class TradePointGiveCalculator implements TradePriceCalculator {
|
|||||||
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
|
||||||
// 1.1 校验积分功能是否开启
|
// 1.1 校验积分功能是否开启
|
||||||
int givePointPerYuan = Optional.ofNullable(memberConfigApi.getConfig())
|
int givePointPerYuan = Optional.ofNullable(memberConfigApi.getConfig())
|
||||||
.filter(config -> BooleanUtil.isTrue(config.getTradeDeductEnable()))
|
.filter(config -> BooleanUtil.isTrue(config.getPointTradeDeductEnable()))
|
||||||
.map(MemberConfigRespDTO::getTradeGivePoint)
|
.map(MemberConfigRespDTO::getPointTradeGivePoint)
|
||||||
.orElse(0);
|
.orElse(0);
|
||||||
if (givePointPerYuan <= 0) {
|
if (givePointPerYuan <= 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -78,18 +78,18 @@ public class TradePointUsePriceCalculator implements TradePriceCalculator {
|
|||||||
|
|
||||||
private boolean isDeductPointEnable(MemberConfigRespDTO config) {
|
private boolean isDeductPointEnable(MemberConfigRespDTO config) {
|
||||||
return config != null &&
|
return config != null &&
|
||||||
!BooleanUtil.isTrue(config.getTradeDeductEnable()) && // 积分功能是否启用
|
!BooleanUtil.isTrue(config.getPointTradeDeductEnable()) && // 积分功能是否启用
|
||||||
config.getTradeDeductUnitPrice() != null && config.getTradeDeductUnitPrice() > 0; // 有没有配置:1 积分抵扣多少分
|
config.getPointTradeDeductUnitPrice() != null && config.getPointTradeDeductUnitPrice() > 0; // 有没有配置:1 积分抵扣多少分
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer calculatePointPrice(MemberConfigRespDTO config, Integer usePoint, TradePriceCalculateRespBO result) {
|
private Integer calculatePointPrice(MemberConfigRespDTO config, Integer usePoint, TradePriceCalculateRespBO result) {
|
||||||
// 每个订单最多可以使用的积分数量
|
// 每个订单最多可以使用的积分数量
|
||||||
if (config.getTradeDeductMaxPrice() != null && config.getTradeDeductMaxPrice() > 0) {
|
if (config.getPointTradeDeductMaxPrice() != null && config.getPointTradeDeductMaxPrice() > 0) {
|
||||||
usePoint = Math.min(usePoint, config.getTradeDeductMaxPrice());
|
usePoint = Math.min(usePoint, config.getPointTradeDeductMaxPrice());
|
||||||
}
|
}
|
||||||
// TODO @疯狂:这里应该是,抵扣到只剩下 0.01;
|
// TODO @疯狂:这里应该是,抵扣到只剩下 0.01;
|
||||||
// 积分优惠金额(分)
|
// 积分优惠金额(分)
|
||||||
int pointPrice = usePoint * config.getTradeDeductUnitPrice();
|
int pointPrice = usePoint * config.getPointTradeDeductUnitPrice();
|
||||||
if (result.getPrice().getPayPrice() <= pointPrice) {
|
if (result.getPrice().getPayPrice() <= pointPrice) {
|
||||||
// 禁止 0 元购
|
// 禁止 0 元购
|
||||||
throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL);
|
throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL);
|
||||||
@ -99,7 +99,7 @@ public class TradePointUsePriceCalculator implements TradePriceCalculator {
|
|||||||
// pointPrice = result.getPrice().getPayPrice();
|
// pointPrice = result.getPrice().getPayPrice();
|
||||||
// // 反推需要扣除的积分
|
// // 反推需要扣除的积分
|
||||||
// usePoint = NumberUtil.toBigDecimal(pointPrice)
|
// usePoint = NumberUtil.toBigDecimal(pointPrice)
|
||||||
// .divide(NumberUtil.toBigDecimal(config.getTradeDeductUnitPrice()), 0, RoundingMode.HALF_UP)
|
// .divide(NumberUtil.toBigDecimal(config.getPointTradeDeductUnitPrice()), 0, RoundingMode.HALF_UP)
|
||||||
// .intValue();
|
// .intValue();
|
||||||
// }
|
// }
|
||||||
// 记录使用的积分
|
// 记录使用的积分
|
||||||
|
@ -13,20 +13,20 @@ public class MemberConfigRespDTO {
|
|||||||
/**
|
/**
|
||||||
* 积分抵扣开关
|
* 积分抵扣开关
|
||||||
*/
|
*/
|
||||||
private Boolean tradeDeductEnable;
|
private Boolean pointTradeDeductEnable;
|
||||||
/**
|
/**
|
||||||
* 积分抵扣,单位:分
|
* 积分抵扣,单位:分
|
||||||
* <p>
|
* <p>
|
||||||
* 1 积分抵扣多少分
|
* 1 积分抵扣多少分
|
||||||
*/
|
*/
|
||||||
private Integer tradeDeductUnitPrice;
|
private Integer pointTradeDeductUnitPrice;
|
||||||
/**
|
/**
|
||||||
* 积分抵扣最大值
|
* 积分抵扣最大值
|
||||||
*/
|
*/
|
||||||
private Integer tradeDeductMaxPrice;
|
private Integer pointTradeDeductMaxPrice;
|
||||||
/**
|
/**
|
||||||
* 1 元赠送多少分
|
* 1 元赠送多少分
|
||||||
*/
|
*/
|
||||||
private Integer tradeGivePoint;
|
private Integer pointTradeGivePoint;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,18 +14,18 @@ public class MemberConfigBaseVO {
|
|||||||
|
|
||||||
@Schema(description = "积分抵扣开关", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "积分抵扣开关", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||||
@NotNull(message = "积分抵扣开发不能为空")
|
@NotNull(message = "积分抵扣开发不能为空")
|
||||||
private Boolean tradeDeductEnable;
|
private Boolean pointTradeDeductEnable;
|
||||||
|
|
||||||
@Schema(description = "积分抵扣,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "13506")
|
@Schema(description = "积分抵扣,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "13506")
|
||||||
@NotNull(message = "积分抵扣不能为空")
|
@NotNull(message = "积分抵扣不能为空")
|
||||||
private Integer tradeDeductUnitPrice;
|
private Integer pointTradeDeductUnitPrice;
|
||||||
|
|
||||||
@Schema(description = "积分抵扣最大值", requiredMode = Schema.RequiredMode.REQUIRED, example = "32428")
|
@Schema(description = "积分抵扣最大值", requiredMode = Schema.RequiredMode.REQUIRED, example = "32428")
|
||||||
@NotNull(message = "积分抵扣最大值不能为空")
|
@NotNull(message = "积分抵扣最大值不能为空")
|
||||||
private Integer tradeDeductMaxPrice;
|
private Integer pointTradeDeductMaxPrice;
|
||||||
|
|
||||||
@Schema(description = "1 元赠送多少分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
@Schema(description = "1 元赠送多少分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
@NotNull(message = "1 元赠送积分不能为空")
|
@NotNull(message = "1 元赠送积分不能为空")
|
||||||
private Integer tradeGivePoint;
|
private Integer pointTradeGivePoint;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,20 +29,20 @@ public class MemberConfigDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 积分抵扣开关
|
* 积分抵扣开关
|
||||||
*/
|
*/
|
||||||
private Boolean tradeDeductEnable;
|
private Boolean pointTradeDeductEnable;
|
||||||
/**
|
/**
|
||||||
* 积分抵扣,单位:分
|
* 积分抵扣,单位:分
|
||||||
*
|
*
|
||||||
* 1 积分抵扣多少分
|
* 1 积分抵扣多少分
|
||||||
*/
|
*/
|
||||||
private Integer tradeDeductUnitPrice;
|
private Integer pointTradeDeductUnitPrice;
|
||||||
/**
|
/**
|
||||||
* 积分抵扣最大值
|
* 积分抵扣最大值
|
||||||
*/
|
*/
|
||||||
private Integer tradeDeductMaxPrice;
|
private Integer pointTradeDeductMaxPrice;
|
||||||
/**
|
/**
|
||||||
* 1 元赠送多少分
|
* 1 元赠送多少分
|
||||||
*/
|
*/
|
||||||
private Integer tradeGivePoint;
|
private Integer pointTradeGivePoint;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user