Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
YouJia
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0ad03835
authored
Sep 30, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 门店审批,门店列表相关代码提交
1 parent
9946a5be
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
345 additions
and
25 deletions
sql/02_column_config.sql
youjia-framework/src/main/java/com/youjia/framework/security/CurrentUserHolder.java
youjia-module-store/src/main/java/com/youjia/store/controller/StoreListingController.java
youjia-module-store/src/main/java/com/youjia/store/dto/StoreColumnConfigDTO.java
youjia-module-store/src/main/java/com/youjia/store/dto/StoreListingQueryDTO.java
youjia-module-store/src/main/java/com/youjia/store/entity/StoreColumnConfig.java
youjia-module-store/src/main/java/com/youjia/store/entity/StoreListing.java
youjia-module-store/src/main/java/com/youjia/store/mapper/StoreColumnConfigMapper.java
youjia-module-store/src/main/java/com/youjia/store/service/StoreApprovalService.java
youjia-module-store/src/main/java/com/youjia/store/service/StoreListingService.java
youjia-module-store/src/main/java/com/youjia/store/service/impl/StoreApprovalServiceImpl.java
youjia-module-store/src/main/java/com/youjia/store/service/impl/StoreListingServiceImpl.java
youjia-module-store/src/main/java/com/youjia/store/support/StoreApprovalConfig.java
youjia-module-store/src/main/java/com/youjia/store/support/StoreListingAssembler.java
youjia-module-store/src/main/java/com/youjia/store/vo/StoreApprovalTaskVO.java
youjia-module-store/src/main/java/com/youjia/store/vo/StoreColumnConfigVO.java
youjia-module-store/src/main/java/com/youjia/store/vo/StoreListingDetailVO.java
sql/02_column_config.sql
0 → 100644
View file @
0ad0383
-- ---------------------------------------------------------------------------
-- 11. 门店列表 · 用户列配置(按用户维度持久化显示列与列顺序)
-- ---------------------------------------------------------------------------
DROP
TABLE
IF
EXISTS
`store_column_config`
;
CREATE
TABLE
`store_column_config`
(
`config_id`
BIGINT
NOT
NULL
AUTO_INCREMENT
COMMENT
'配置 ID'
,
`user_id`
BIGINT
NOT
NULL
COMMENT
'用户 ID'
,
`columns_json`
VARCHAR
(
1000
)
NOT
NULL
COMMENT
'显示列字段名列表(JSON 数组,有序)'
,
`create_by`
BIGINT
DEFAULT
NULL
COMMENT
'创建人'
,
`create_time`
DATETIME
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_by`
BIGINT
DEFAULT
NULL
COMMENT
'更新人'
,
`update_time`
DATETIME
DEFAULT
NULL
COMMENT
'更新时间'
,
`is_deleted`
TINYINT
NOT
NULL
DEFAULT
0
COMMENT
'逻辑删除:0-未删除 1-已删除'
,
PRIMARY
KEY
(
`config_id`
),
UNIQUE
KEY
`uk_column_config_user`
(
`user_id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
COMMENT
=
'门店列表·用户列配置'
;
youjia-framework/src/main/java/com/youjia/framework/security/CurrentUserHolder.java
View file @
0ad0383
...
...
@@ -3,6 +3,9 @@ package com.youjia.framework.security;
import
com.youjia.common.constant.CommonConstants
;
import
com.youjia.common.enums.DataScopeEnum
;
import
java.util.Collections
;
import
java.util.List
;
/**
* 当前登录用户 ThreadLocal 上下文。
*
...
...
@@ -51,6 +54,14 @@ public final class CurrentUserHolder {
return
user
==
null
||
user
.
getName
()
==
null
?
"系统用户"
:
user
.
getName
();
}
/** 取当前用户角色编码列表,未登录时返回空列表 */
public
static
List
<
String
>
getRoleCodes
()
{
LoginUser
user
=
HOLDER
.
get
();
return
user
==
null
||
user
.
getRoleCodes
()
==
null
?
Collections
.
emptyList
()
:
user
.
getRoleCodes
();
}
public
static
void
clear
()
{
HOLDER
.
remove
();
}
...
...
youjia-module-store/src/main/java/com/youjia/store/controller/StoreListingController.java
View file @
0ad0383
...
...
@@ -3,17 +3,22 @@ package com.youjia.store.controller;
import
com.youjia.common.core.PageResult
;
import
com.youjia.common.core.Result
;
import
com.youjia.framework.security.RequirePermission
;
import
com.youjia.store.dto.StoreColumnConfigDTO
;
import
com.youjia.store.dto.StoreListingQueryDTO
;
import
com.youjia.store.entity.StoreChangeLog
;
import
com.youjia.store.service.StoreListingService
;
import
com.youjia.store.vo.StoreColumnConfigVO
;
import
com.youjia.store.vo.StoreListingDetailVO
;
import
com.youjia.store.vo.StoreListingVO
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
jakarta.servlet.http.HttpServletResponse
;
import
jakarta.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -59,4 +64,19 @@ public class StoreListingController {
public
void
export
(
StoreListingQueryDTO
query
,
HttpServletResponse
response
)
{
storeListingService
.
export
(
query
,
response
);
}
@RequirePermission
(
"store:list:view"
)
@Operation
(
summary
=
"保存列配置(按用户维度持久化)"
)
@PostMapping
(
"/column-config"
)
public
Result
<
Void
>
saveColumnConfig
(
@Valid
@RequestBody
StoreColumnConfigDTO
dto
)
{
storeListingService
.
saveColumnConfig
(
dto
);
return
Result
.
success
();
}
@RequirePermission
(
"store:list:view"
)
@Operation
(
summary
=
"获取列配置"
)
@GetMapping
(
"/column-config"
)
public
Result
<
StoreColumnConfigVO
>
getColumnConfig
()
{
return
Result
.
success
(
storeListingService
.
getColumnConfig
());
}
}
youjia-module-store/src/main/java/com/youjia/store/dto/StoreColumnConfigDTO.java
0 → 100644
View file @
0ad0383
package
com
.
youjia
.
store
.
dto
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotEmpty
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.List
;
/**
* 保存列配置请求。
*/
@Getter
@Setter
@Schema
(
description
=
"保存列配置请求"
)
public
class
StoreColumnConfigDTO
{
@NotEmpty
(
message
=
"显示列不能为空"
)
@Schema
(
description
=
"显示列字段名列表(有序)"
)
private
List
<
String
>
columns
;
}
youjia-module-store/src/main/java/com/youjia/store/dto/StoreListingQueryDTO.java
View file @
0ad0383
...
...
@@ -31,4 +31,10 @@ public class StoreListingQueryDTO extends PageQuery {
@Schema
(
description
=
"上架时间止(含)"
)
private
LocalDate
endDate
;
@Schema
(
description
=
"排序字段:effectiveDate / changeCount"
)
private
String
sortField
;
@Schema
(
description
=
"排序方向:asc / desc"
)
private
String
sortOrder
;
}
youjia-module-store/src/main/java/com/youjia/store/entity/StoreColumnConfig.java
0 → 100644
View file @
0ad0383
package
com
.
youjia
.
store
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.youjia.common.entity.BaseEntity
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 门店列表用户列配置(store_column_config),按用户维度持久化。
*/
@Getter
@Setter
@EqualsAndHashCode
(
callSuper
=
true
)
@TableName
(
"store_column_config"
)
@Schema
(
description
=
"门店列表·用户列配置"
)
public
class
StoreColumnConfig
extends
BaseEntity
{
@TableId
(
value
=
"config_id"
,
type
=
IdType
.
AUTO
)
private
Long
configId
;
@Schema
(
description
=
"用户 ID"
)
private
Long
userId
;
@Schema
(
description
=
"显示列字段名列表(JSON 数组,有序)"
)
private
String
columnsJson
;
}
youjia-module-store/src/main/java/com/youjia/store/entity/StoreListing.java
View file @
0ad0383
...
...
@@ -41,6 +41,15 @@ public class StoreListing extends BaseEntity {
@Schema
(
description
=
"产品分类数"
)
private
Integer
categoryCount
;
@Schema
(
description
=
"当前审批层级(从 1 开始)"
)
private
Integer
currentLevel
;
@Schema
(
description
=
"当前层级审批角色编码"
)
private
String
levelRoleCode
;
@Schema
(
description
=
"审批总层级数"
)
private
Integer
totalLevel
;
@Schema
(
description
=
"装修、设备总投入(门店维度)"
)
private
BigDecimal
costDecoration
;
...
...
@@ -56,6 +65,9 @@ public class StoreListing extends BaseEntity {
@Schema
(
description
=
"状态:PENDING / APPROVED / REJECTED / REVOKED / VOID"
)
private
String
status
;
@Schema
(
description
=
"是否当前生效记录:1-是 0-否"
)
private
Integer
isEffective
;
@Schema
(
description
=
"所属组织 ID,决定数据可见范围"
)
private
Long
orgId
;
...
...
youjia-module-store/src/main/java/com/youjia/store/mapper/StoreColumnConfigMapper.java
0 → 100644
View file @
0ad0383
package
com
.
youjia
.
store
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.youjia.store.entity.StoreColumnConfig
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
StoreColumnConfigMapper
extends
BaseMapper
<
StoreColumnConfig
>
{
}
youjia-module-store/src/main/java/com/youjia/store/service/StoreApprovalService.java
View file @
0ad0383
...
...
@@ -8,7 +8,7 @@ import com.youjia.store.vo.StoreApprovalTaskVO;
import
com.youjia.store.vo.StoreListingDetailVO
;
/**
* 门店审批服务(
单级审批:提交 → 优加财务经理
→ 生效)。
* 门店审批服务(
多级审批:提交 → 按 Nacos 配置的层级角色逐级审批
→ 生效)。
*/
public
interface
StoreApprovalService
{
...
...
youjia-module-store/src/main/java/com/youjia/store/service/StoreListingService.java
View file @
0ad0383
package
com
.
youjia
.
store
.
service
;
import
com.youjia.common.core.PageResult
;
import
com.youjia.store.dto.StoreColumnConfigDTO
;
import
com.youjia.store.dto.StoreListingQueryDTO
;
import
com.youjia.store.entity.StoreChangeLog
;
import
com.youjia.store.vo.StoreColumnConfigVO
;
import
com.youjia.store.vo.StoreListingDetailVO
;
import
com.youjia.store.vo.StoreListingVO
;
import
jakarta.servlet.http.HttpServletResponse
;
...
...
@@ -10,7 +12,7 @@ import jakarta.servlet.http.HttpServletResponse;
import
java.util.List
;
/**
* 门店列表服务。列表仅展示
状态为「已生效」
的门店数据。
* 门店列表服务。列表仅展示
is_effective = 1
的门店数据。
*/
public
interface
StoreListingService
{
...
...
@@ -24,4 +26,10 @@ public interface StoreListingService {
* 导出当前筛选结果(受数据域限制),上限 5 万行。
*/
void
export
(
StoreListingQueryDTO
query
,
HttpServletResponse
response
);
/** 保存当前用户的列配置 */
void
saveColumnConfig
(
StoreColumnConfigDTO
dto
);
/** 获取当前用户的列配置 */
StoreColumnConfigVO
getColumnConfig
();
}
youjia-module-store/src/main/java/com/youjia/store/service/impl/StoreApprovalServiceImpl.java
View file @
0ad0383
...
...
@@ -22,6 +22,7 @@ import com.youjia.store.mapper.StoreChangeLogMapper;
import
com.youjia.store.mapper.StoreListingItemMapper
;
import
com.youjia.store.mapper.StoreListingMapper
;
import
com.youjia.store.service.StoreApprovalService
;
import
com.youjia.store.support.StoreApprovalConfig
;
import
com.youjia.store.support.StoreListingAssembler
;
import
com.youjia.store.vo.StoreApprovalTaskVO
;
import
com.youjia.store.vo.StoreListingDetailVO
;
...
...
@@ -49,12 +50,16 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
private
final
StoreApprovalLogMapper
storeApprovalLogMapper
;
private
final
StoreChangeLogMapper
storeChangeLogMapper
;
private
final
StoreListingAssembler
storeListingAssembler
;
private
final
StoreApprovalConfig
storeApprovalConfig
;
private
final
DataScopeHelper
dataScopeHelper
;
@Override
public
PageResult
<
StoreApprovalTaskVO
>
pagePending
(
StoreApprovalTaskQueryDTO
query
)
{
List
<
String
>
roleCodes
=
CurrentUserHolder
.
getRoleCodes
();
LambdaQueryWrapper
<
StoreListing
>
wrapper
=
buildWrapper
(
query
)
.
eq
(
StoreListing:
:
getStatus
,
StoreStatusEnum
.
PENDING
.
getCode
())
.
in
(
roleCodes
.
isEmpty
(),
StoreListing:
:
getLevelRoleCode
,
List
.
of
(
"-1"
))
.
in
(!
roleCodes
.
isEmpty
(),
StoreListing:
:
getLevelRoleCode
,
roleCodes
)
.
orderByDesc
(
StoreListing:
:
getSubmitTime
);
return
pageTask
(
query
,
wrapper
);
}
...
...
@@ -89,25 +94,49 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
requireStatus
(
listing
,
StoreStatusEnum
.
PENDING
);
LocalDateTime
now
=
LocalDateTime
.
now
();
StoreListing
update
=
new
StoreListing
();
update
.
setListingId
(
listing
.
getListingId
());
update
.
setVersion
(
listing
.
getVersion
());
update
.
setStatus
(
StoreStatusEnum
.
APPROVED
.
getCode
());
update
.
setApproveUserId
(
CurrentUserHolder
.
getUserId
());
update
.
setApproveUserName
(
CurrentUserHolder
.
getName
());
update
.
setApproveTime
(
now
);
update
.
setEffectiveTime
(
now
);
update
.
setChangeCount
((
listing
.
getChangeCount
()
==
null
?
0
:
listing
.
getChangeCount
())
+
1
);
if
(
storeListingMapper
.
updateById
(
update
)
!=
1
)
{
throw
new
BusinessException
(
ResultCode
.
OPERATION_NOT_ALLOWED
,
"记录已被他人处置,请刷新后重试"
);
}
int
currentLevel
=
listing
.
getCurrentLevel
()
==
null
?
1
:
listing
.
getCurrentLevel
();
int
totalLevel
=
listing
.
getTotalLevel
()
==
null
?
1
:
listing
.
getTotalLevel
();
writeChangeLog
(
listing
,
"status"
,
listing
.
getStatus
(),
StoreStatusEnum
.
APPROVED
.
getCode
(),
now
);
writeApprovalLog
(
listing
.
getListingId
(),
ApprovalActionEnum
.
PASS
,
StoreStatusEnum
.
PENDING
.
getCode
(),
StoreStatusEnum
.
APPROVED
.
getCode
(),
"审批通过"
);
log
.
info
(
"门店上架审批通过:listingId={}, 门店={}, 场景={}"
,
listing
.
getListingId
(),
listing
.
getStoreName
(),
listing
.
getBusinessScene
());
// TODO 接入企业微信通知发起人
if
(
currentLevel
<
totalLevel
)
{
int
nextLevel
=
currentLevel
+
1
;
StoreListing
update
=
new
StoreListing
();
update
.
setListingId
(
listing
.
getListingId
());
update
.
setVersion
(
listing
.
getVersion
());
update
.
setCurrentLevel
(
nextLevel
);
update
.
setLevelRoleCode
(
storeApprovalConfig
.
getRoleCode
(
nextLevel
));
update
.
setApproveUserId
(
CurrentUserHolder
.
getUserId
());
update
.
setApproveUserName
(
CurrentUserHolder
.
getName
());
update
.
setApproveTime
(
now
);
if
(
storeListingMapper
.
updateById
(
update
)
!=
1
)
{
throw
new
BusinessException
(
ResultCode
.
OPERATION_NOT_ALLOWED
,
"记录已被他人处置,请刷新后重试"
);
}
writeApprovalLog
(
listing
.
getListingId
(),
ApprovalActionEnum
.
PASS
,
StoreStatusEnum
.
PENDING
.
getCode
(),
StoreStatusEnum
.
PENDING
.
getCode
(),
"第 "
+
currentLevel
+
" 级审批通过,流转至第 "
+
nextLevel
+
" 级"
);
log
.
info
(
"门店上架审批升级:listingId={}, 第{}级→第{}级"
,
listing
.
getListingId
(),
currentLevel
,
nextLevel
);
}
else
{
StoreListing
update
=
new
StoreListing
();
update
.
setListingId
(
listing
.
getListingId
());
update
.
setVersion
(
listing
.
getVersion
());
update
.
setStatus
(
StoreStatusEnum
.
APPROVED
.
getCode
());
update
.
setApproveUserId
(
CurrentUserHolder
.
getUserId
());
update
.
setApproveUserName
(
CurrentUserHolder
.
getName
());
update
.
setApproveTime
(
now
);
update
.
setEffectiveTime
(
now
);
update
.
setIsEffective
(
1
);
update
.
setChangeCount
((
listing
.
getChangeCount
()
==
null
?
0
:
listing
.
getChangeCount
())
+
1
);
if
(
storeListingMapper
.
updateById
(
update
)
!=
1
)
{
throw
new
BusinessException
(
ResultCode
.
OPERATION_NOT_ALLOWED
,
"记录已被他人处置,请刷新后重试"
);
}
deactivateOldEffective
(
listing
.
getMerchantNo
(),
listing
.
getBusinessScene
(),
listing
.
getListingId
());
writeChangeLog
(
listing
,
"status"
,
listing
.
getStatus
(),
StoreStatusEnum
.
APPROVED
.
getCode
(),
now
);
writeApprovalLog
(
listing
.
getListingId
(),
ApprovalActionEnum
.
PASS
,
StoreStatusEnum
.
PENDING
.
getCode
(),
StoreStatusEnum
.
APPROVED
.
getCode
(),
"审批通过"
);
log
.
info
(
"门店上架审批通过:listingId={}, 门店={}, 场景={}"
,
listing
.
getListingId
(),
listing
.
getStoreName
(),
listing
.
getBusinessScene
());
// TODO 接入企业微信通知发起人
}
}
@Override
...
...
@@ -262,6 +291,16 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
}
}
private
void
deactivateOldEffective
(
String
merchantNo
,
String
businessScene
,
Long
excludeListingId
)
{
StoreListing
deactivate
=
new
StoreListing
();
deactivate
.
setIsEffective
(
0
);
storeListingMapper
.
update
(
deactivate
,
new
LambdaQueryWrapper
<
StoreListing
>()
.
eq
(
StoreListing:
:
getMerchantNo
,
merchantNo
)
.
eq
(
StoreListing:
:
getBusinessScene
,
businessScene
)
.
eq
(
StoreListing:
:
getIsEffective
,
1
)
.
ne
(
StoreListing:
:
getListingId
,
excludeListingId
));
}
private
void
writeApprovalLog
(
Long
listingId
,
ApprovalActionEnum
action
,
String
preStatus
,
String
postStatus
,
String
reason
)
{
StoreApprovalLog
entity
=
new
StoreApprovalLog
();
...
...
@@ -269,6 +308,8 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
entity
.
setAction
(
action
.
name
());
entity
.
setOperatorId
(
CurrentUserHolder
.
getUserId
());
entity
.
setOperatorName
(
CurrentUserHolder
.
getName
());
List
<
String
>
roleCodes
=
CurrentUserHolder
.
getRoleCodes
();
entity
.
setOperatorRole
(
roleCodes
.
isEmpty
()
?
null
:
String
.
join
(
","
,
roleCodes
));
entity
.
setPreStatus
(
preStatus
);
entity
.
setPostStatus
(
postStatus
);
entity
.
setReason
(
reason
);
...
...
youjia-module-store/src/main/java/com/youjia/store/service/impl/StoreListingServiceImpl.java
View file @
0ad0383
...
...
@@ -5,17 +5,20 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.youjia.common.core.PageResult
;
import
com.youjia.common.core.ResultCode
;
import
com.youjia.common.enums.StoreStatusEnum
;
import
com.youjia.common.exception.BusinessException
;
import
com.youjia.framework.security.CurrentUserHolder
;
import
com.youjia.store.dto.StoreColumnConfigDTO
;
import
com.youjia.store.dto.StoreListingQueryDTO
;
import
com.youjia.store.entity.StoreChangeLog
;
import
com.youjia.store.entity.StoreColumnConfig
;
import
com.youjia.store.entity.StoreListing
;
import
com.youjia.store.excel.StoreListingExcelRow
;
import
com.youjia.store.mapper.StoreChangeLogMapper
;
import
com.youjia.store.mapper.StoreColumnConfigMapper
;
import
com.youjia.store.mapper.StoreListingMapper
;
import
com.youjia.store.service.StoreListingService
;
import
com.youjia.store.support.StoreListingAssembler
;
import
com.youjia.store.vo.StoreColumnConfigVO
;
import
com.youjia.store.vo.StoreListingDetailVO
;
import
com.youjia.store.vo.StoreListingVO
;
import
com.youjia.system.support.DataScopeHelper
;
...
...
@@ -25,6 +28,10 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
...
...
@@ -43,8 +50,10 @@ public class StoreListingServiceImpl implements StoreListingService {
private
final
StoreListingMapper
storeListingMapper
;
private
final
StoreChangeLogMapper
storeChangeLogMapper
;
private
final
StoreColumnConfigMapper
storeColumnConfigMapper
;
private
final
StoreListingAssembler
storeListingAssembler
;
private
final
DataScopeHelper
dataScopeHelper
;
private
final
ObjectMapper
objectMapper
;
@Override
public
PageResult
<
StoreListingVO
>
page
(
StoreListingQueryDTO
query
)
{
...
...
@@ -88,20 +97,61 @@ public class StoreListingServiceImpl implements StoreListingService {
// 说明:超过 5 万行时应改为异步生成 + 企业微信推送下载链接
}
@Override
public
void
saveColumnConfig
(
StoreColumnConfigDTO
dto
)
{
Long
userId
=
CurrentUserHolder
.
getUserId
();
String
json
;
try
{
json
=
objectMapper
.
writeValueAsString
(
dto
.
getColumns
());
}
catch
(
JsonProcessingException
e
)
{
throw
new
BusinessException
(
ResultCode
.
FAIL
,
"列配置序列化失败"
);
}
StoreColumnConfig
existing
=
storeColumnConfigMapper
.
selectOne
(
new
LambdaQueryWrapper
<
StoreColumnConfig
>()
.
eq
(
StoreColumnConfig:
:
getUserId
,
userId
));
if
(
existing
!=
null
)
{
existing
.
setColumnsJson
(
json
);
storeColumnConfigMapper
.
updateById
(
existing
);
}
else
{
StoreColumnConfig
config
=
new
StoreColumnConfig
();
config
.
setUserId
(
userId
);
config
.
setColumnsJson
(
json
);
storeColumnConfigMapper
.
insert
(
config
);
}
}
@Override
public
StoreColumnConfigVO
getColumnConfig
()
{
StoreColumnConfigVO
vo
=
new
StoreColumnConfigVO
();
StoreColumnConfig
config
=
storeColumnConfigMapper
.
selectOne
(
new
LambdaQueryWrapper
<
StoreColumnConfig
>()
.
eq
(
StoreColumnConfig:
:
getUserId
,
CurrentUserHolder
.
getUserId
()));
if
(
config
!=
null
&&
StringUtils
.
hasText
(
config
.
getColumnsJson
()))
{
try
{
List
<
String
>
columns
=
objectMapper
.
readValue
(
config
.
getColumnsJson
(),
new
TypeReference
<
List
<
String
>>()
{});
vo
.
setColumns
(
columns
);
}
catch
(
JsonProcessingException
e
)
{
log
.
warn
(
"列配置反序列化失败,userId={}"
,
CurrentUserHolder
.
getUserId
(),
e
);
}
}
return
vo
;
}
// ------------------------------------------------------------ 私有方法
private
LambdaQueryWrapper
<
StoreListing
>
buildWrapper
(
StoreListingQueryDTO
query
)
{
LambdaQueryWrapper
<
StoreListing
>
wrapper
=
new
LambdaQueryWrapper
<
StoreListing
>()
// 门店列表仅展示「已生效」数据
.
eq
(
StoreListing:
:
getStatus
,
StoreStatusEnum
.
APPROVED
.
getCode
())
.
eq
(
StoreListing:
:
getIsEffective
,
1
)
.
like
(
StringUtils
.
hasText
(
query
.
getStoreName
()),
StoreListing:
:
getStoreName
,
query
.
getStoreName
())
.
like
(
StringUtils
.
hasText
(
query
.
getMerchantNo
()),
StoreListing:
:
getMerchantNo
,
query
.
getMerchantNo
())
.
eq
(
StringUtils
.
hasText
(
query
.
getBusinessScene
()),
StoreListing:
:
getBusinessScene
,
query
.
getBusinessScene
())
.
ge
(
query
.
getStartDate
()
!=
null
,
StoreListing:
:
getEffectiveTime
,
query
.
getStartDate
()
==
null
?
null
:
query
.
getStartDate
().
atStartOfDay
())
.
le
(
query
.
getEndDate
()
!=
null
,
StoreListing:
:
getEffectiveTime
,
query
.
getEndDate
()
==
null
?
null
:
query
.
getEndDate
().
atTime
(
LocalTime
.
MAX
))
.
orderByDesc
(
StoreListing:
:
getEffectiveTime
);
query
.
getEndDate
()
==
null
?
null
:
query
.
getEndDate
().
atTime
(
LocalTime
.
MAX
));
applySort
(
wrapper
,
query
.
getSortField
(),
query
.
getSortOrder
());
List
<
Long
>
visibleOrgIds
=
dataScopeHelper
.
resolveVisibleOrgIds
();
if
(
visibleOrgIds
!=
null
)
{
...
...
@@ -113,6 +163,15 @@ public class StoreListingServiceImpl implements StoreListingService {
return
wrapper
;
}
private
void
applySort
(
LambdaQueryWrapper
<
StoreListing
>
wrapper
,
String
sortField
,
String
sortOrder
)
{
boolean
asc
=
!
"desc"
.
equalsIgnoreCase
(
sortOrder
);
if
(
"changeCount"
.
equals
(
sortField
))
{
wrapper
.
orderBy
(
true
,
asc
,
StoreListing:
:
getChangeCount
);
}
else
{
wrapper
.
orderBy
(
true
,
asc
,
StoreListing:
:
getEffectiveTime
);
}
}
private
StoreListing
requireListing
(
Long
listingId
)
{
StoreListing
listing
=
storeListingMapper
.
selectById
(
listingId
);
if
(
listing
==
null
)
{
...
...
youjia-module-store/src/main/java/com/youjia/store/support/StoreApprovalConfig.java
0 → 100644
View file @
0ad0383
package
com
.
youjia
.
store
.
support
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 门店上架多级审批配置,从 Nacos / application 读取。
*
* <p>示例 YAML:
* <pre>
* youjia:
* store:
* approval:
* level-role-codes:
* - finance_manager
* - director
* </pre>
* 列表下标 0 = 第 1 级审批角色编码,依次递增。
*/
@Getter
@Setter
@Component
@ConfigurationProperties
(
prefix
=
"youjia.store.approval"
)
public
class
StoreApprovalConfig
{
/** 各级审批角色编码,按层级顺序排列 */
private
List
<
String
>
levelRoleCodes
=
new
ArrayList
<>();
/** 取审批总层级数 */
public
int
getTotalLevel
()
{
return
levelRoleCodes
.
isEmpty
()
?
1
:
levelRoleCodes
.
size
();
}
/** 取指定层级的角色编码(level 从 1 开始) */
public
String
getRoleCode
(
int
level
)
{
if
(
level
<
1
||
level
>
levelRoleCodes
.
size
())
{
return
null
;
}
return
levelRoleCodes
.
get
(
level
-
1
);
}
}
youjia-module-store/src/main/java/com/youjia/store/support/StoreListingAssembler.java
View file @
0ad0383
...
...
@@ -54,6 +54,8 @@ public class StoreListingAssembler {
vo
.
setBusinessScene
(
listing
.
getBusinessScene
());
vo
.
setCategoryCount
(
listing
.
getCategoryCount
());
vo
.
setCostTotal
(
listing
.
getCostTotal
());
vo
.
setCurrentLevel
(
listing
.
getCurrentLevel
());
vo
.
setTotalLevel
(
listing
.
getTotalLevel
());
vo
.
setSubmitUserName
(
listing
.
getSubmitUserName
());
vo
.
setSubmitTime
(
listing
.
getSubmitTime
());
vo
.
setStatus
(
listing
.
getStatus
());
...
...
@@ -102,6 +104,9 @@ public class StoreListingAssembler {
vo
.
setStatus
(
listing
.
getStatus
());
vo
.
setStatusLabel
(
StoreStatusEnum
.
of
(
listing
.
getStatus
())
.
map
(
StoreStatusEnum:
:
getDesc
).
orElse
(
listing
.
getStatus
()));
vo
.
setCurrentLevel
(
listing
.
getCurrentLevel
());
vo
.
setTotalLevel
(
listing
.
getTotalLevel
());
vo
.
setLevelRoleCode
(
listing
.
getLevelRoleCode
());
vo
.
setEffectiveTime
(
listing
.
getEffectiveTime
());
vo
.
setSubmitTime
(
listing
.
getSubmitTime
());
vo
.
setSubmitUserName
(
listing
.
getSubmitUserName
());
...
...
youjia-module-store/src/main/java/com/youjia/store/vo/StoreApprovalTaskVO.java
View file @
0ad0383
...
...
@@ -30,6 +30,12 @@ public class StoreApprovalTaskVO {
private
String
businessScene
;
private
BigDecimal
costTotal
;
@Schema
(
description
=
"当前审批层级"
)
private
Integer
currentLevel
;
@Schema
(
description
=
"审批总层级数"
)
private
Integer
totalLevel
;
private
String
submitUserName
;
private
LocalDateTime
submitTime
;
...
...
youjia-module-store/src/main/java/com/youjia/store/vo/StoreColumnConfigVO.java
0 → 100644
View file @
0ad0383
package
com
.
youjia
.
store
.
vo
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 列配置响应。
*/
@Getter
@Setter
@Schema
(
description
=
"列配置响应"
)
public
class
StoreColumnConfigVO
{
@Schema
(
description
=
"显示列字段名列表(有序)"
)
private
List
<
String
>
columns
=
new
ArrayList
<>();
}
youjia-module-store/src/main/java/com/youjia/store/vo/StoreListingDetailVO.java
View file @
0ad0383
...
...
@@ -27,6 +27,16 @@ public class StoreListingDetailVO {
private
Integer
categoryCount
;
private
String
status
;
private
String
statusLabel
;
@Schema
(
description
=
"当前审批层级"
)
private
Integer
currentLevel
;
@Schema
(
description
=
"审批总层级数"
)
private
Integer
totalLevel
;
@Schema
(
description
=
"当前层级审批角色编码"
)
private
String
levelRoleCode
;
private
LocalDateTime
effectiveTime
;
private
LocalDateTime
submitTime
;
private
String
submitUserName
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment