Compare commits

...
5 Commits
Author SHA1 Message Date
Timi b6f20c976d v1.0.56
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-25 23:43:25 +08:00
Timi 369da9f997 add main agent DSL 2026-09-25 22:07:42 +08:00
Timi cd8e552d21 support sku filter 2026-09-25 22:07:31 +08:00
Timi b30434777d v1.0.55
CI / build-deploy (pull_request) Successful in 27s
CI / notify-on-failure (pull_request) Skipped
2026-09-23 23:15:19 +08:00
Timi 4aafb17214 add point chart 2026-09-23 21:54:39 +08:00
12 changed files with 1732 additions and 1 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
<groupId>com.imyeyu.timiserverapi</groupId>
<artifactId>TimiServerAPI</artifactId>
<version>1.0.54</version>
<version>1.0.56</version>
<packaging>jar</packaging>
<name>TimiServerAPI</name>
<description>imyeyu.com API</description>
File diff suppressed because it is too large Load Diff
@@ -3,8 +3,13 @@ package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.annotation.RequireCorePermission;
import com.imyeyu.api.bean.CorePermissionCode;
import com.imyeyu.api.bean.ModuleCode;
import com.imyeyu.api.modules.gao.entity.GaoStore;
import com.imyeyu.api.modules.gao.service.GaoStoreService;
import com.imyeyu.api.modules.user.bean.AuthOwnerType;
import com.imyeyu.api.modules.user.entity.Role;
import com.imyeyu.api.modules.user.service.AuthorizationScopeService;
import com.imyeyu.api.modules.user.service.PermissionService;
import com.imyeyu.api.modules.user.service.RoleService;
import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
@@ -26,6 +31,9 @@ public class GaoRoleController {
private final UserLoginService userLoginService;
private final AuthorizationScopeService authorizationScopeService;
private final GaoStoreService gaoStoreService;
private final PermissionService permissionService;
private final RoleService roleService;
@AOPLog
@RequestRateLimit
@@ -34,4 +42,40 @@ public class GaoRoleController {
public List<Role> availableList() {
return authorizationScopeService.listGrantableRole(userLoginService.getRequireLoginUserId(), ModuleCode.GAO);
}
/// 查询登录用户所属门店内可管理的角色
///
/// @return 门店角色列表
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.ROLE_READ)
@PostMapping("/management/list")
public List<Role> managementList() {
String loginUserId = userLoginService.getRequireLoginUserId();
GaoStore store = gaoStoreService.getByUserId(loginUserId);
if (store == null) {
return List.of();
}
List<Role> roleList = authorizationScopeService.listManageableRole(loginUserId, ModuleCode.GAO)
.stream()
.filter(role -> role.getOwnerType() == AuthOwnerType.STORE)
.filter(role -> store.getId().equals(role.getOwnerId()))
.toList();
roleList.forEach(this::fillRoleDetail);
return roleList;
}
/// 填充角色详情
///
/// @param role 角色
private void fillRoleDetail(Role role) {
role.setPermissionList(permissionService.listByRoleId(role.getId()));
role.setAllPermissionList(roleService.listPermissionByRoleId(role.getId()));
role.setChildRoleList(roleService.listChildByParentRoleId(role.getId()));
if (role.getParentRoleId() != null) {
role.setParentRole(roleService.get(role.getParentRoleId()));
}
role.setDelegationPermissionList(roleService.listDelegationPermissionByRoleId(role.getId()));
}
}
@@ -2,6 +2,7 @@ package com.imyeyu.api.modules.gao.controller;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
import com.imyeyu.api.modules.gao.service.GaoPointChartService;
import com.imyeyu.api.modules.gao.service.GaoStoreChartService;
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
import com.imyeyu.api.modules.gao.vo.GaoCustomerAgeStatView;
@@ -10,6 +11,8 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoPointDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoPointRedemptionProductRankView;
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.AOPLog;
@@ -33,6 +36,7 @@ import java.util.List;
public class GaoStoreChartController {
private final GaoStoreChartService service;
private final GaoPointChartService pointChartService;
private final GaoStoreScopeService storeScopeService;
/// 查询客户增长趋势
@@ -96,4 +100,26 @@ public class GaoStoreChartController {
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
return service.eventRecordCalendar(req);
}
/// 查询每日积分获得、消耗和差值
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/point/ledger/daily")
public List<GaoPointDailyStatView> pointDaily(@RequestBody GaoStoreChartReq req) {
TimiException.required(req, "积分图表请求不能为空");
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
return pointChartService.dailyTrend(req);
}
/// 查询积分兑换产品排行
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
@PostMapping("/point/redemption/product/rank")
public List<GaoPointRedemptionProductRankView> pointRedemptionProductRank(@RequestBody GaoStoreChartReq req) {
TimiException.required(req, "积分兑换排行请求不能为空");
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
return pointChartService.redemptionProductRank(req);
}
}
@@ -0,0 +1,20 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.vo.GaoPointDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoPointRedemptionProductRankView;
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
import java.util.List;
/// 门店积分图表统计 Mapper
///
/// @author Codex
/// @since 2026-09-23
public interface GaoPointChartMapper {
/// 按天汇总积分获得和消耗
List<GaoPointDailyStatView> selectDailyTrend(GaoStoreChartReq req);
/// 按产品汇总兑换积分并取前 10
List<GaoPointRedemptionProductRankView> selectRedemptionProductRank(GaoStoreChartReq req);
}
@@ -0,0 +1,20 @@
package com.imyeyu.api.modules.gao.service;
import com.imyeyu.api.modules.gao.vo.GaoPointDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoPointRedemptionProductRankView;
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
import java.util.List;
/// 门店积分图表统计服务
///
/// @author Codex
/// @since 2026-09-23
public interface GaoPointChartService {
/// 查询每日积分获得、消耗和差值
List<GaoPointDailyStatView> dailyTrend(GaoStoreChartReq req);
/// 查询积分兑换产品排行,按实际扣除积分取前 10
List<GaoPointRedemptionProductRankView> redemptionProductRank(GaoStoreChartReq req);
}
@@ -0,0 +1,43 @@
package com.imyeyu.api.modules.gao.service.implement;
import com.imyeyu.api.modules.gao.mapper.GaoPointChartMapper;
import com.imyeyu.api.modules.gao.service.GaoPointChartService;
import com.imyeyu.api.modules.gao.vo.GaoPointDailyStatView;
import com.imyeyu.api.modules.gao.vo.GaoPointRedemptionProductRankView;
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
import com.imyeyu.java.bean.timi.TimiException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/// 门店积分图表统计服务实现
///
/// @author Codex
/// @since 2026-09-23
@Service
@RequiredArgsConstructor
public class GaoPointChartServiceImplement implements GaoPointChartService {
private final GaoPointChartMapper mapper;
@Override
public List<GaoPointDailyStatView> dailyTrend(GaoStoreChartReq req) {
checkRangeReq(req);
return mapper.selectDailyTrend(req);
}
@Override
public List<GaoPointRedemptionProductRankView> redemptionProductRank(GaoStoreChartReq req) {
checkRangeReq(req);
return mapper.selectRedemptionProductRank(req);
}
private void checkRangeReq(GaoStoreChartReq req) {
TimiException.required(req, "积分图表请求不能为空");
TimiException.required(req.getStoreId(), "积分图表门店不能为空");
TimiException.required(req.getBeginAt(), "积分图表开始时间不能为空");
TimiException.required(req.getEndAt(), "积分图表结束时间不能为空");
TimiException.requiredTrue(req.getBeginAt() <= req.getEndAt(), "积分图表结束时间早于开始时间");
}
}
@@ -5,6 +5,8 @@ import com.imyeyu.java.bean.BasePage;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/// GAO 统一履约分页查询请求
///
/// @author Codex
@@ -22,6 +24,9 @@ public class GaoOrderFulfillmentPage extends BasePage {
/// 客户 ID
private String customerId;
/// SKU ID 列表,任一 SKU 命中即匹配
private List<String> skuIdList;
/// 履约状态
private GaoOrderFulfillment.Status status;
@@ -0,0 +1,23 @@
package com.imyeyu.api.modules.gao.vo;
import lombok.Data;
/// 每日积分获得与消耗统计
///
/// @author Codex
/// @since 2026-09-23
@Data
public class GaoPointDailyStatView {
/// 日期值,格式为 yyyyMMdd
private Integer dateValue;
/// 每日获得积分
private Long earnedPoints;
/// 每日消耗积分,以正数返回
private Long consumedPoints;
/// 获得积分减消耗积分
private Long netChangePoints;
}
@@ -0,0 +1,23 @@
package com.imyeyu.api.modules.gao.vo;
import lombok.Data;
/// 积分兑换产品排行统计
///
/// @author Codex
/// @since 2026-09-23
@Data
public class GaoPointRedemptionProductRankView {
/// 产品 ID
private String productId;
/// 产品名称
private String productName;
/// 兑换单数
private Long redemptionCount;
/// 实际扣除积分合计,不扣除退回积分
private Long pointCost;
}
@@ -39,6 +39,14 @@
<if test="storeId != null and storeId != ''">AND `store_id` = #{storeId}</if>
<if test="salesOrderId != null and salesOrderId != ''">AND `sales_order_id` = #{salesOrderId}</if>
<if test="customerId != null and customerId != ''">AND `customer_id` = #{customerId}</if>
<if test="skuIdList != null and skuIdList.size() > 0">
AND EXISTS (
SELECT 1 FROM `gao_order_fulfillment_item` fulfillment_item
WHERE fulfillment_item.`fulfillment_id` = `gao_order_fulfillment`.`id`
AND fulfillment_item.`sku_id` IN
<foreach collection="skuIdList" item="skuId" open="(" separator="," close=")">#{skuId}</foreach>
)
</if>
<if test="status != null">AND `status` = #{status}</if>
<if test="beginAt != null">AND `delivered_at` &gt;= #{beginAt}</if>
<if test="endAt != null">AND `delivered_at` &lt;= #{endAt}</if>
@@ -0,0 +1,36 @@
<?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" >
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoPointChartMapper">
<select id="selectDailyTrend" resultType="com.imyeyu.api.modules.gao.vo.GaoPointDailyStatView">
SELECT
CAST(DATE_FORMAT(FROM_UNIXTIME(l.`occurred_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
COALESCE(SUM(CASE WHEN l.`change_type` = 'EARN' THEN l.`point_delta` ELSE 0 END), 0) AS `earnedPoints`,
COALESCE(SUM(CASE WHEN l.`change_type` = 'CONSUME' THEN -l.`point_delta` ELSE 0 END), 0) AS `consumedPoints`,
COALESCE(SUM(l.`point_delta`), 0) AS `netChangePoints`
FROM `gao_point_ledger` l
WHERE l.`deleted_at` IS NULL
AND l.`store_id` = #{storeId}
AND l.`occurred_at` &gt;= #{beginAt}
AND l.`occurred_at` &lt;= #{endAt}
AND l.`change_type` IN ('EARN', 'CONSUME')
GROUP BY DATE_FORMAT(FROM_UNIXTIME(l.`occurred_at` / 1000), '%Y%m%d')
ORDER BY `dateValue` ASC
</select>
<select id="selectRedemptionProductRank" resultType="com.imyeyu.api.modules.gao.vo.GaoPointRedemptionProductRankView">
SELECT
r.`product_id_snapshot` AS `productId`,
COALESCE(MAX(NULLIF(r.`product_name_snapshot`, '')), '未命名产品') AS `productName`,
COUNT(1) AS `redemptionCount`,
COALESCE(SUM(r.`actual_point_cost`), 0) AS `pointCost`
FROM `gao_point_redemption` r
WHERE r.`deleted_at` IS NULL
AND r.`store_id` = #{storeId}
AND r.`product_id_snapshot` IS NOT NULL
AND r.`redeemed_at` &gt;= #{beginAt}
AND r.`redeemed_at` &lt;= #{endAt}
GROUP BY r.`product_id_snapshot`
ORDER BY `pointCost` DESC, `redemptionCount` DESC, `productName` ASC, `productId` ASC
LIMIT 10
</select>
</mapper>