Compare commits
7
Commits
v1.0.54
...
982b1ee3e4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
982b1ee3e4 | ||
|
|
b6f20c976d | ||
|
|
369da9f997 | ||
|
|
cd8e552d21 | ||
|
|
05e28c2c6d | ||
|
|
b30434777d | ||
|
|
4aafb17214 |
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||||
<artifactId>TimiServerAPI</artifactId>
|
<artifactId>TimiServerAPI</artifactId>
|
||||||
<version>1.0.54</version>
|
<version>1.0.56</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>TimiServerAPI</name>
|
<name>TimiServerAPI</name>
|
||||||
<description>imyeyu.com API</description>
|
<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.annotation.RequireCorePermission;
|
||||||
import com.imyeyu.api.bean.CorePermissionCode;
|
import com.imyeyu.api.bean.CorePermissionCode;
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
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.entity.Role;
|
||||||
import com.imyeyu.api.modules.user.service.AuthorizationScopeService;
|
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.api.modules.user.service.UserLoginService;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
@@ -26,6 +31,9 @@ public class GaoRoleController {
|
|||||||
|
|
||||||
private final UserLoginService userLoginService;
|
private final UserLoginService userLoginService;
|
||||||
private final AuthorizationScopeService authorizationScopeService;
|
private final AuthorizationScopeService authorizationScopeService;
|
||||||
|
private final GaoStoreService gaoStoreService;
|
||||||
|
private final PermissionService permissionService;
|
||||||
|
private final RoleService roleService;
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@@ -34,4 +42,40 @@ public class GaoRoleController {
|
|||||||
public List<Role> availableList() {
|
public List<Role> availableList() {
|
||||||
return authorizationScopeService.listGrantableRole(userLoginService.getRequireLoginUserId(), ModuleCode.GAO);
|
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.annotation.RequireGaoPermission;
|
||||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
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.GaoStoreChartService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerAgeStatView;
|
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.GaoEventRecordCalendarView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
|
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.api.modules.gao.vo.GaoStoreChartReq;
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
@@ -33,6 +36,7 @@ import java.util.List;
|
|||||||
public class GaoStoreChartController {
|
public class GaoStoreChartController {
|
||||||
|
|
||||||
private final GaoStoreChartService service;
|
private final GaoStoreChartService service;
|
||||||
|
private final GaoPointChartService pointChartService;
|
||||||
private final GaoStoreScopeService storeScopeService;
|
private final GaoStoreScopeService storeScopeService;
|
||||||
|
|
||||||
/// 查询客户增长趋势
|
/// 查询客户增长趋势
|
||||||
@@ -96,4 +100,26 @@ public class GaoStoreChartController {
|
|||||||
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||||
return service.eventRecordCalendar(req);
|
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);
|
||||||
|
}
|
||||||
+43
@@ -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.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/// GAO 统一履约分页查询请求
|
/// GAO 统一履约分页查询请求
|
||||||
///
|
///
|
||||||
/// @author Codex
|
/// @author Codex
|
||||||
@@ -22,6 +24,9 @@ public class GaoOrderFulfillmentPage extends BasePage {
|
|||||||
/// 客户 ID
|
/// 客户 ID
|
||||||
private String customerId;
|
private String customerId;
|
||||||
|
|
||||||
|
/// SKU ID 列表,任一 SKU 命中即匹配
|
||||||
|
private List<String> skuIdList;
|
||||||
|
|
||||||
/// 履约状态
|
/// 履约状态
|
||||||
private GaoOrderFulfillment.Status status;
|
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="storeId != null and storeId != ''">AND `store_id` = #{storeId}</if>
|
||||||
<if test="salesOrderId != null and salesOrderId != ''">AND `sales_order_id` = #{salesOrderId}</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="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="status != null">AND `status` = #{status}</if>
|
||||||
<if test="beginAt != null">AND `delivered_at` >= #{beginAt}</if>
|
<if test="beginAt != null">AND `delivered_at` >= #{beginAt}</if>
|
||||||
<if test="endAt != null">AND `delivered_at` <= #{endAt}</if>
|
<if test="endAt != null">AND `delivered_at` <= #{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` >= #{beginAt}
|
||||||
|
AND l.`occurred_at` <= #{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` >= #{beginAt}
|
||||||
|
AND r.`redeemed_at` <= #{endAt}
|
||||||
|
GROUP BY r.`product_id_snapshot`
|
||||||
|
ORDER BY `pointCost` DESC, `redemptionCount` DESC, `productName` ASC, `productId` ASC
|
||||||
|
LIMIT 10
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user