v1.0.17 #26
@@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/// GAO 客户积分规则接口
|
/// GAO 客户积分规则接口
|
||||||
///
|
///
|
||||||
/// @author Codex
|
/// @author Codex
|
||||||
@@ -78,6 +80,19 @@ public class GaoPointRuleController {
|
|||||||
ruleService.update(rule);
|
ruleService.update(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_UPDATE)
|
||||||
|
@PostMapping("/rule/sort")
|
||||||
|
public void sort(@RequestBody List<String> idList) {
|
||||||
|
if (idList != null) {
|
||||||
|
for (GaoPointRule rule : ruleService.listByIdList(idList)) {
|
||||||
|
checkStore(rule.getStoreId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ruleService.sort(idList);
|
||||||
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_DELETE)
|
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_DELETE)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.imyeyu.api.modules.gao.entity.GaoPointRule;
|
|||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/// GAO 客户积分规则 Mapper
|
/// GAO 客户积分规则 Mapper
|
||||||
@@ -12,6 +13,8 @@ import java.util.List;
|
|||||||
/// @since 2026-08-11
|
/// @since 2026-08-11
|
||||||
public interface GaoPointRuleMapper extends BaseMapper<GaoPointRule, String> {
|
public interface GaoPointRuleMapper extends BaseMapper<GaoPointRule, String> {
|
||||||
|
|
||||||
|
List<GaoPointRule> selectByIdList(Collection<String> idList);
|
||||||
|
|
||||||
/// 查询当前时间可匹配的启用规则
|
/// 查询当前时间可匹配的启用规则
|
||||||
///
|
///
|
||||||
/// @param storeId 门店 ID
|
/// @param storeId 门店 ID
|
||||||
|
|||||||
@@ -19,6 +19,17 @@ public interface GaoPointRuleService extends BaseService<GaoPointRule, String> {
|
|||||||
/// @return 规则列表
|
/// @return 规则列表
|
||||||
List<GaoPointRule> listActive(String storeId, String eventId, long now);
|
List<GaoPointRule> listActive(String storeId, String eventId, long now);
|
||||||
|
|
||||||
|
/// 查询规则 ID 列表
|
||||||
|
///
|
||||||
|
/// @param idList 规则 ID 列表
|
||||||
|
/// @return 规则列表
|
||||||
|
List<GaoPointRule> listByIdList(List<String> idList);
|
||||||
|
|
||||||
|
/// 按客户端提交的顺序更新启用规则优先级
|
||||||
|
///
|
||||||
|
/// @param idList 规则 ID 列表
|
||||||
|
void sort(List<String> idList);
|
||||||
|
|
||||||
/// 创建积分规则
|
/// 创建积分规则
|
||||||
///
|
///
|
||||||
/// @param rule 积分规则
|
/// @param rule 积分规则
|
||||||
|
|||||||
+32
@@ -16,6 +16,11 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/// GAO 客户积分规则服务实现
|
/// GAO 客户积分规则服务实现
|
||||||
///
|
///
|
||||||
@@ -42,6 +47,32 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
|
|||||||
return mapper.selectActiveByStoreIdAndEventId(storeId, eventId, now);
|
return mapper.selectActiveByStoreIdAndEventId(storeId, eventId, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GaoPointRule> listByIdList(List<String> idList) {
|
||||||
|
if (TimiJava.isEmpty(idList)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
return mapper.selectByIdList(new LinkedHashSet<>(idList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void sort(List<String> idList) {
|
||||||
|
if (TimiJava.isEmpty(idList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> distinctIdList = new ArrayList<>(new LinkedHashSet<>(idList));
|
||||||
|
Map<String, GaoPointRule> ruleMap = mapper.selectByIdList(new LinkedHashSet<>(distinctIdList)).stream()
|
||||||
|
.collect(Collectors.toMap(GaoPointRule::getId, Function.identity()));
|
||||||
|
TimiException.requiredTrue(ruleMap.size() == distinctIdList.size(), "积分规则列表包含不存在的规则");
|
||||||
|
for (int i = 0; i < distinctIdList.size(); i++) {
|
||||||
|
GaoPointRule rule = ruleMap.get(distinctIdList.get(i));
|
||||||
|
TimiException.requiredTrue(rule.getStatus() == GaoPointRule.Status.ACTIVE, "只能调整启用规则排序");
|
||||||
|
rule.setPriority(i);
|
||||||
|
mapper.update(rule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void create(GaoPointRule rule) {
|
public void create(GaoPointRule rule) {
|
||||||
@@ -149,6 +180,7 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
|
|||||||
TimiException.required(sourceEvent, "TIER.sourceEventId 对应事件不存在");
|
TimiException.required(sourceEvent, "TIER.sourceEventId 对应事件不存在");
|
||||||
TimiException.requiredTrue(storeId.equals(sourceEvent.getStoreId()), "TIER 来源事件和规则不属于同一门店");
|
TimiException.requiredTrue(storeId.equals(sourceEvent.getStoreId()), "TIER 来源事件和规则不属于同一门店");
|
||||||
TimiException.requiredTrue(sourceEvent.getValueType() == GaoEvent.ValueType.NUMBER, "TIER 来源事件必须配置为 NUMBER 类型");
|
TimiException.requiredTrue(sourceEvent.getValueType() == GaoEvent.ValueType.NUMBER, "TIER 来源事件必须配置为 NUMBER 类型");
|
||||||
|
TimiException.required(sourceEvent.getValueUnit(), "TIER 来源事件必须配置数值单位");
|
||||||
|
|
||||||
JsonNode sourceValueField = condition.get("sourceValueField");
|
JsonNode sourceValueField = condition.get("sourceValueField");
|
||||||
TimiException.requiredTrue(sourceValueField != null && sourceValueField.isTextual() && "numberValue".equals(sourceValueField.asText()), "TIER.sourceValueField 目前只能是 numberValue");
|
TimiException.requiredTrue(sourceValueField != null && sourceValueField.isTextual() && "numberValue".equals(sourceValueField.asText()), "TIER.sourceValueField 目前只能是 numberValue");
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoPointRuleMapper">
|
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoPointRuleMapper">
|
||||||
|
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
|
||||||
|
SELECT *
|
||||||
|
FROM gao_point_rule
|
||||||
|
WHERE deleted_at IS NULL
|
||||||
|
AND id IN
|
||||||
|
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectActiveByStoreIdAndEventId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
|
<select id="selectActiveByStoreIdAndEventId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `gao_point_rule`
|
FROM `gao_point_rule`
|
||||||
|
|||||||
Reference in New Issue
Block a user