Compare commits

..

4 Commits

Author SHA1 Message Date
huk
d751de05c2 feat(goods): 查询商品分类及子分类 2025-09-15 18:01:57 +08:00
huk
9c6f5f3add Merge remote-tracking branch 'origin/wzj-main' into wzj-main 2025-09-15 18:00:53 +08:00
huk
52494134ee feat(system): 完善租户查询功能并优化相关逻辑
- 添加获取子级租户列表的方法
- 优化租户列表查询逻辑,支持根据父级ID筛选
- 让店铺和商品的业务功能适配动态切换租户
2025-09-15 15:34:58 +08:00
huk
841c35106d fix(transaction): 易生分账返回状态枚举修正 2025-09-15 10:17:55 +08:00
23 changed files with 198 additions and 132 deletions

View File

@ -16,6 +16,7 @@ import me.zhyd.oauth.utils.AuthStateUtils;
import org.dromara.common.core.constant.SystemConstants;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.domain.model.LoginBody;
import org.dromara.common.core.domain.model.LoginUser;
import org.dromara.common.core.domain.model.RegisterBody;
import org.dromara.common.core.domain.model.SocialLoginBody;
import org.dromara.common.core.utils.*;
@ -28,6 +29,7 @@ import org.dromara.common.social.utils.SocialUtils;
import org.dromara.common.sse.dto.SseMessageDto;
import org.dromara.common.sse.utils.SseMessageUtils;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.system.domain.SysTenant;
import org.dromara.system.domain.bo.SysTenantBo;
import org.dromara.system.domain.vo.SysClientVo;
import org.dromara.system.domain.vo.SysTenantVo;
@ -190,6 +192,9 @@ public class AuthController {
/**
* 登录页面租户下拉框
* 超级管理员可查看所有租户
* 代理租户管理员可查自己租户和parentIds中包含自己的租户
* 店铺租户和达人租户只可查看自己的租户
*
* @return 租户列表
*/
@ -203,31 +208,27 @@ public class AuthController {
if (!enable) {
return R.ok(result);
}
List<SysTenantVo> tenantList = tenantService.queryList(new SysTenantBo());
List<TenantListVo> voList = MapstructUtils.convert(tenantList, TenantListVo.class);
try {
// 如果只超管返回所有租户
if (LoginHelper.isSuperAdmin()) {
result.setVoList(voList);
return R.ok(result);
}
} catch (NotLoginException ignored) {
SysTenantVo sysTenantVo = tenantService.queryByTenantId(LoginHelper.getTenantId());
List<SysTenantVo> sysTenantList = tenantService.getByParentId(sysTenantVo.getId());
List<TenantListVo> voList = MapstructUtils.convert(sysTenantList, TenantListVo.class);
if (voList != null) {
voList.add(TenantListVo.builder().tenantId(sysTenantVo.getTenantId()).companyName(sysTenantVo.getCompanyName()).domain(sysTenantVo.getDomain()).build());
}
result.setVoList(voList);
// 获取域名
String host;
String referer = request.getHeader("referer");
if (StringUtils.isNotBlank(referer)) {
// 这里从referer中取值是为了本地使用hosts添加虚拟域名方便本地环境调试
host = referer.split("//")[1].split("/")[0];
} else {
host = new URL(request.getRequestURL().toString()).getHost();
}
// 根据域名进行筛选
List<TenantListVo> list = StreamUtils.filter(voList, vo ->
StringUtils.equalsIgnoreCase(vo.getDomain(), host));
result.setVoList(CollUtil.isNotEmpty(list) ? list : voList);
// 获取域名 --- 暂时不需要
// String host;
// String referer = request.getHeader("referer");
// if (StringUtils.isNotBlank(referer)) {
// // 这里从referer中取值是为了本地使用hosts添加虚拟域名方便本地环境调试
// host = referer.split("//")[1].split("/")[0];
// } else {
// host = new URL(request.getRequestURL().toString()).getHost();
// }
// // 根据域名进行筛选
// List<TenantListVo> list = StreamUtils.filter(voList, vo ->
// StringUtils.equalsIgnoreCase(vo.getDomain(), host));
// result.setVoList(CollUtil.isNotEmpty(list) ? list : voList);
return R.ok(result);
}

View File

@ -1,5 +1,8 @@
package org.dromara.web.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import org.dromara.system.domain.vo.SysTenantVo;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
@ -11,6 +14,9 @@ import lombok.Data;
*/
@Data
@AutoMapper(target = SysTenantVo.class)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TenantListVo {
/**

View File

@ -91,8 +91,8 @@ public class PlusDataPermissionHandler {
currentUser = LoginHelper.getLoginUser();
DataPermissionHelper.setVariable("user", currentUser);
}
// 如果是超级管理员或租户管理员则不过滤数据
if (LoginHelper.isSuperAdmin() || LoginHelper.isTenantAdmin()) {
// 如果是超级管理员则不过滤数据
if (LoginHelper.isSuperAdmin()) {
return where;
}
// 构造数据过滤条件的 SQL 片段

View File

@ -15,6 +15,7 @@ import com.wzj.soopin.goods.service.SkuService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.common.web.core.BusinessImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -47,7 +48,7 @@ public class ProductBusinessImpl extends BusinessImpl<ProductService, ProductCon
Product product = converter.toPo(bo);
product.setType(1);
product.setSales("0");
product.setTenantId(LoginHelper.getTenantId());
product.setTenantId(TenantHelper.getTenantId());
productService.saveOrUpdate(product);
//清理掉旧的SKU
skuService.remove(new LambdaQueryWrapper<Sku>().eq(Sku::getProductId, product.getId()));
@ -57,7 +58,7 @@ public class ProductBusinessImpl extends BusinessImpl<ProductService, ProductCon
.map(skuBO -> {
Sku sku = skuConvert.toPo(skuBO);
sku.setProductId(product.getId());
sku.setTenantId(LoginHelper.getTenantId());
sku.setTenantId(TenantHelper.getTenantId());
return sku;
})
.collect(Collectors.toList());

View File

@ -35,7 +35,7 @@ public class ProductController extends BaseController {
@Tag(name ="查询商品信息列表")
@PostMapping("list")
public R<IPage<ProductVO>> list(@RequestBody ProductBo bo,@RequestBody Page<Product> page) {
public R<IPage<ProductVO>> list(@RequestBody ProductBo bo) {
return R.ok(business.page(bo));
}

View File

@ -23,6 +23,9 @@ public class ProductBo extends BaseBO<Product> {
@Schema(description = "CATEGORY_ID 精确匹配")
private Long categoryId;
@Schema(description = "查询分类及子分类id", hidden = true)
private List<Long> categoryIds;
@Schema(description = "商品编码 精确匹配")
private String outProductId;

View File

@ -33,12 +33,16 @@ public class SkuBo {
@Schema(description = "库存")
private Integer stock;
@Schema(description = "租户id")
private String tenantId;
public Wrapper<Sku> toWrapper() {
return new LambdaQueryWrapper<Sku>()
.eq(productId != null, Sku::getProductId, productId)
.eq(outSkuId != null && !outSkuId.isEmpty(), Sku::getOutSkuId, outSkuId)
.eq(price != null, Sku::getPrice, price)
.eq(pic != null && !pic.isEmpty(), Sku::getPic, pic)
.eq(tenantId != null && !tenantId.isEmpty(), Sku::getTenantId, tenantId)
.eq(spData != null && !spData.isEmpty(), Sku::getSpData, spData);
}
}

View File

@ -2,6 +2,8 @@ package com.wzj.soopin.goods.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wzj.soopin.goods.domain.entity.ProductCategory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@ -10,6 +12,7 @@ import java.util.List;
*
* @author zcc
*/
@Mapper
public interface ProductCategoryMapper extends BaseMapper<ProductCategory> {
/**
* 查询商品分类列表
@ -18,4 +21,13 @@ public interface ProductCategoryMapper extends BaseMapper<ProductCategory> {
* @return 商品分类集合
*/
List<ProductCategory> selectByEntity(ProductCategory productCategory);
/**
* 查询所有子分类
*
* @param categoryId
* @return
*/
@Select("select * from pms_product_category where parent_id = #{categoryId}")
List<ProductCategory> selectByParentId(Long categoryId);
}

View File

@ -32,8 +32,7 @@ public interface ProductMapper extends BaseMapper<Product> {
List<Product> selectByEntity(Product product);
@InterceptorIgnore(tenantLine = "true")
Page<ProductVO> getlist(@Param("page") Page<Product> page, @Param("query") ProductBo query, @Param("tenantIds") List<String> tenantIds);
Page<ProductVO> getlist(@Param("page") Page<Product> page, @Param("query") ProductBo query);

View File

@ -30,7 +30,7 @@ public interface SkuMapper extends BaseMapper<Sku> {
int updateStockById(@Param("skuId")Long skuId, @Param("optDate")LocalDateTime optDate, @Param("quantity")Integer quantity);
IPage<SkuVO> getlist(@Param("page") Page<Sku> page,@Param("query") SkuBo query, @Param("tenantId") Long tenantId);
IPage<SkuVO> getlist(@Param("page") Page<Sku> page,@Param("query") SkuBo query);
SkuVO selectSkuByid(@Param("id") Long id);

View File

@ -2,23 +2,19 @@ package com.wzj.soopin.goods.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzj.soopin.goods.domain.bo.ProductBo;
import com.wzj.soopin.goods.domain.entity.Product;
import com.wzj.soopin.goods.domain.entity.ProductCategory;
import com.wzj.soopin.goods.domain.vo.ProductVO;
import com.wzj.soopin.goods.mapper.ProductCategoryMapper;
import com.wzj.soopin.goods.mapper.ProductMapper;
import com.wzj.soopin.goods.mapper.SkuMapper;
import com.wzj.soopin.goods.service.ProductService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.enums.TenantType;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.system.domain.SysDept;
import org.dromara.system.domain.SysTenant;
import org.dromara.system.domain.vo.SysUserTenantVO;
import org.dromara.system.mapper.SysDeptMapper;
import org.dromara.system.mapper.SysTenantMapper;
import org.dromara.system.mapper.SysUserTenantMapper;
@ -40,6 +36,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
private final ProductMapper productMapper;
private final ProductCategoryMapper productCategoryMapper;
private final SkuMapper skuMapper;
private final SysTenantMapper sysTenantMapper;
private final SysDeptMapper sysDeptMapper;
@ -47,25 +44,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override
public Page<ProductVO> getList(ProductBo query, Page<Product> page) {
String tenantId = LoginHelper.getTenantId();
List<String> tenantIds = CollUtil.newArrayList(tenantId);
if(LoginHelper.isTenantAdmin()){
SysTenant sysTenant = sysTenantMapper.selectOne(Wrappers.lambdaQuery(SysTenant.class).eq(SysTenant::getTenantId, tenantId));
if(sysTenant.getType() != TenantType.MERCHANT.getType()){
// 非商铺管理员则查看其所属租户创建的全部商铺
List<Long> deptIdList = sysDeptMapper.selectList().stream().map(SysDept::getDeptId).toList();
tenantIds = sysTenantMapper.selectByTenantTypeAndCreateDept(TenantType.MERCHANT.getType(), deptIdList).stream().map(SysTenant::getTenantId).toList();
}
}
// 获取当前登录人被分配的,可管理的商铺租户id
List<String> list = sysUserTenantMapper.getUserTenantList(LoginHelper.getUserId(), TenantType.MERCHANT.getType())
.stream().map(SysUserTenantVO::getTenantId).toList();
if(CollUtil.isNotEmpty(list)){
tenantIds = new ArrayList<>(tenantIds);
tenantIds.addAll(list);
}
List<String> finalTenantIds = tenantIds;
return TenantHelper.ignore(() -> productMapper.getlist(page, query, finalTenantIds));
return productMapper.getlist(page, query);
}
@ -73,9 +52,9 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
public IPage<ProductVO> getRecommendPage( Page<Product> page) {
//推荐商品要根据算法获取
List<String> tenantIds = new ArrayList<>();
return productMapper.getlist(page,new ProductBo(), tenantIds);
return productMapper.getlist(page,new ProductBo());
}
@ -99,6 +78,12 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
* @return
*/
public IPage<ProductVO> getProduct(Page<Product> page, ProductBo query) {
if(query.getCategoryId() != null){
ArrayList<Long> categoryIds = CollUtil.newArrayList(query.getCategoryId());
categoryIds.addAll(productCategoryMapper.selectByParentId(query.getCategoryId())
.stream().map(ProductCategory::getId).toList());
query.setCategoryIds(categoryIds);
}
return TenantHelper.ignore(() -> productMapper.getProduct(page, query));
}

View File

@ -14,6 +14,7 @@ import com.wzj.soopin.goods.service.SkuService;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.tenant.helper.TenantHelper;
import org.springframework.stereotype.Service;
@ -32,8 +33,8 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements SkuSe
private final ProductMapper productMapper;
public IPage<SkuVO> getList(SkuBo query, Page<Sku> page) {
Long tenantId = Long.valueOf(LoginHelper.getTenantId());
return skuMapper.getlist(page,query,tenantId);
query.setTenantId(TenantHelper.getTenantId());
return skuMapper.getlist(page,query);
}
public SkuVO selectSkuByid(Long id) {

View File

@ -66,8 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
pc.name AS productCategoryName,
s.id AS sku_id,
s.out_sku_id,
s.price,
s.pic,
s.price AS skuPrice,
s.pic AS skuPic,
s.stock,
s.sp_data,
s.product_id
@ -77,31 +77,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN sys_tenant t ON p.tenant_id = t.tenant_id
LEFT JOIN pms_product_category pc ON p.category_id = pc.id
LEFT JOIN pms_sku s ON p.id = s.product_id
WHERE 1=1
<if test="query.nameLike != null and query.nameLike != ''">
AND p.name LIKE CONCAT('%', #{query.nameLike}, '%')
</if>
<if test="query.outProductId != null">
AND p.out_product_id = #{query.outProductId}
</if>
<if test="query.brandId != null">
AND p.brand_id = #{query.brandId}
</if>
<if test="query.publishStatus != null">
AND p.publish_status = #{query.publishStatus}
</if>
<if test="query.authFlag != null">
AND p.auth_flag = #{query.authFlag}
</if>
<if test="query.categoryId != null">
AND p.category_id = #{query.categoryId}
</if>
<if test="tenantIds != null and tenantIds.size() > 0">
AND p.tenant_id IN
<foreach collection="tenantIds" item="tenantId" open="(" separator="," close=")">
#{tenantId}
</foreach>
</if>
<where>
<if test="query.nameLike != null and query.nameLike != ''">
AND p.name LIKE CONCAT('%', #{query.nameLike}, '%')
</if>
<if test="query.outProductId != null and query.outProductId != ''">
AND p.out_product_id = #{query.outProductId}
</if>
<if test="query.brandId != null">
AND p.brand_id = #{query.brandId}
</if>
<if test="query.publishStatus != null">
AND p.publish_status = #{query.publishStatus}
</if>
<if test="query.authFlag != null">
AND p.auth_flag = #{query.authFlag}
</if>
<if test="query.categoryId != null">
AND p.category_id = #{query.categoryId}
</if>
</where>
ORDER BY
p.sales DESC,
@ -143,8 +138,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.nameLike != null and query.nameLike != ''">
AND p.name LIKE CONCAT('%', #{query.nameLike}, '%')
</if>
<if test="query.categoryId != null">
AND p.category_id = #{query.categoryId}
<!-- <if test="query.categoryId != null">-->
<!-- AND p.category_id = #{query.categoryId}-->
<!-- </if>-->
<if test="query.categoryIds != null and query.categoryIds.size() > 0">
AND p.category_id IN
<foreach collection="query.categoryIds" item="categoryId" open="(" separator="," close=")">
#{categoryId}
</foreach>
</if>
</where>
</select>

View File

@ -47,33 +47,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getlist" resultType="com.wzj.soopin.goods.domain.vo.SkuVO">
SELECT
s.*,
p.name AS productName
s.id,
s.product_id,
s.out_sku_id,
s.price,
s.pic,
s.sp_data,
s.stock,
s.create_by,
s.create_time,
s.update_by,
s.update_time,
p.name AS productName
FROM
pms_sku s
pms_sku s
LEFT JOIN
pms_product p ON s.product_id = p.id
WHERE 1=1
<if test="tenantId != '000000'">
AND s.tenant_id = #{tenantId}
</if>
<if test="query.productName != null and query.productName != ''">
AND p.name LIKE CONCAT('%', #{query.productName}, '%')
</if>
<if test="query.productId != null and query.productId != ''">
AND p.id = #{query.productId}
</if>
<if test="query.outSkuId != null and query.outSkuId != ''">
AND s.out_sku_id LIKE CONCAT('%', #{query.outSkuId}, '%')
</if>
<if test="query.price != null and query.price != ''">
AND s.price LIKE CONCAT('%', #{query.price}, '%')
</if>
<if test="query.pic != null and query.pic != ''">
AND s.pic LIKE CONCAT('%', #{query.pic}, '%')
</if>
pms_product p ON s.product_id = p.id
<where>
<if test="query.productName != null and query.productName != ''">
AND p.name LIKE CONCAT('%', #{query.productName}, '%')
</if>
<if test="query.productId != null">
AND p.id = #{query.productId}
</if>
<if test="query.outSkuId != null and query.outSkuId != ''">
AND s.out_sku_id LIKE CONCAT('%', #{query.outSkuId}, '%')
</if>
<if test="query.price != null">
AND s.price = #{query.price}
</if>
<if test="query.pic != null and query.pic != ''">
AND s.pic LIKE CONCAT('%', #{query.pic}, '%')
</if>
<if test="query.tenantId != null and query.tenantId != ''">
AND s.tenant_id = #{query.tenantId}
</if>
</where>
ORDER BY
s.create_time DESC
s.create_time DESC
</select>

View File

@ -110,10 +110,12 @@ public class SysUserController extends BaseController {
public R<UserInfoVo> getInfo() {
UserInfoVo userInfoVo = new UserInfoVo();
LoginUser loginUser = LoginHelper.getLoginUser();
if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) {
// 超级管理员 如果重新加载用户信息需清除动态租户
TenantHelper.clearDynamic();
}
// if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) {
// // 超级管理员 如果重新加载用户信息需清除动态租户
// TenantHelper.clearDynamic();
// }
TenantHelper.clearDynamic();
SysUserVo user = userService.selectUserById(loginUser.getUserId());
if (ObjectUtil.isNull(user)) {
return R.fail("没有权限访问用户数据!");

View File

@ -1,5 +1,7 @@
package org.dromara.system.domain.bo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.system.domain.SysTenant;
@ -21,6 +23,7 @@ import org.dromara.common.mybatis.core.domain.BaseEntity;
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = SysTenant.class, reverseConvertGenerate = false)
@Builder
public class SysTenantBo extends BaseEntity {
/**
@ -29,6 +32,9 @@ public class SysTenantBo extends BaseEntity {
@NotNull(message = "id不能为空", groups = { EditGroup.class })
private Long id;
@Schema(description = "某个父级id")
private Long oneParentId;
/**
* 租户编号
*/

View File

@ -17,6 +17,9 @@ public class SysTenantExtendBo {
@TableId(value = "id")
private Long id;
@Schema(description = "其中一个父级id")
private Long oneParentId;
@Schema(description = "租户编号")
private String tenantId;

View File

@ -45,10 +45,6 @@ public interface SysTenantMapper extends BaseMapperPlus<SysTenant, SysTenantVo>
"LIMIT 20")
List<Map<String, Object>> getTop20Stores();
@DataPermission({
@DataColumn(key = "deptName", value = "t.create_dept"),
@DataColumn(key = "userName", value = "t.create_by")
})
IPage<TenantDTO> getlist(@Param("page") Page<SysTenant> page, @Param("query") SysTenantExtendBo query);
@Select(" SELECT " +

View File

@ -120,4 +120,12 @@ public interface ISysTenantService {
void confirmedSign(String tenantId);
SysTenant queryByDeptId(Long deptId);
/**
* 根据id查询其所有子级租户
*
* @param id
* @return
*/
List<SysTenantVo> getByParentId(Long id);
}

View File

@ -28,6 +28,7 @@ import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.enums.DataScopeType;
import org.dromara.common.redis.utils.CacheUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.tenant.core.TenantEntity;
@ -111,6 +112,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
private LambdaQueryWrapper<SysTenant> buildQueryWrapper(SysTenantBo bo) {
LambdaQueryWrapper<SysTenant> lqw = Wrappers.lambdaQuery();
lqw.eq(StringUtils.isNotBlank(bo.getTenantId()), SysTenant::getTenantId, bo.getTenantId());
lqw.like(bo.getOneParentId() != null, SysTenant::getParentIds, String.valueOf(bo.getOneParentId()));
lqw.like(StringUtils.isNotBlank(bo.getContactUserName()), SysTenant::getContactUserName, bo.getContactUserName());
lqw.eq(StringUtils.isNotBlank(bo.getContactPhone()), SysTenant::getContactPhone, bo.getContactPhone());
lqw.like(StringUtils.isNotBlank(bo.getCompanyName()), SysTenant::getCompanyName, bo.getCompanyName());
@ -122,7 +124,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
lqw.eq(bo.getExpireTime() != null, SysTenant::getExpireTime, bo.getExpireTime());
lqw.eq(bo.getAccountCount() != null, SysTenant::getAccountCount, bo.getAccountCount());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysTenant::getStatus, bo.getStatus());
lqw.orderByAsc(SysTenant::getId);
lqw.orderByAsc(SysTenant::getType);
return lqw;
}
@ -135,8 +137,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
// 处理sys_tenant表数据
SysTenant tenant = new SysTenant();
String currentTenantId = LoginHelper.getTenantId();
String currentTenantId = TenantHelper.getTenantId();
SysTenantVo currentTenant = this.queryByTenantId(currentTenantId);
Assert.isTrue(TenantType.allowCreateByType(currentTenant.getType(), bo.getType()), () -> new ServiceException("您无权限创建此类型的租户"));
@ -387,6 +388,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
role.setRoleKey(TenantConstants.TENANT_ADMIN_ROLE_KEY);
role.setRoleSort(1);
role.setStatus(SystemConstants.NORMAL);
role.setDataScope(DataScopeType.DEPT_AND_CHILD_OR_SELF.getCode());
roleMapper.insert(role);
Long roleId = role.getRoleId();
@ -726,6 +728,8 @@ public class SysTenantServiceImpl implements ISysTenantService {
@Override
public IPage<TenantDTO> getlist(Page<SysTenant> page, SysTenantExtendBo query) {
SysTenantVo sysTenantVo = queryByTenantId(TenantHelper.getTenantId());
query.setOneParentId(sysTenantVo.getId());
IPage<TenantDTO> resultPage = baseMapper.getlist(page,query);
return resultPage;
}
@ -815,5 +819,10 @@ public class SysTenantServiceImpl implements ISysTenantService {
return baseMapper.queryByDeptId(deptId);
}
@Override
public List<SysTenantVo> getByParentId(Long id) {
return this.queryList(SysTenantBo.builder().oneParentId(id).status("0").build());
}
}

View File

@ -25,6 +25,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.tenantId != null and query.tenantId != ''">
AND t.tenant_id LIKE CONCAT('%', #{query.tenantId}, '%')
</if>
<if test="query.oneParentId != null ">
AND t.parent_ids LIKE CONCAT('%', #{query.oneParentId}, '%')
</if>
<if test="query.personName != null and query.personName != ''">
AND e.person_name LIKE CONCAT('%', #{query.personName}, '%')
</if>

View File

@ -10,16 +10,32 @@ import java.util.Arrays;
/**
* 分账单状态处理中成功失败已退款
* 0 -> 交易成功
* 1 -> 交易部分成功
* X -> 交易失败
* 9 -> 支付中具体状态未知
* A -> 已撤销
* C -> 已关闭
* R -> 已退款
* E -> 已冲正
*
*
*
*
* 已撤销
*/
@Getter
@AllArgsConstructor
public enum SepaStatus {
SUCCESS("0", "成功"),
FAIL("FAIL", "失败"),
PENDING("PENDING", "处理中"),
PROCESSING("PROCESSING", "处理中"),
REFUNDED("REFUNDED", "已退款");
PARTIALLY_SUCCESS("1", "交易部分成功"),
FAIL("X", "失败"),
PENDING("9", "处理中"),
A("A", "已撤销"),
C("C", "已关闭"),
R("R", "已退款"),
E("E", "已冲正");
/**

View File

@ -777,11 +777,9 @@ public class EasypayServiceImpl implements IEasypayService {
divideDetail.setFee(BigDecimal.valueOf(separateRespInfo.getSepaPlatStlmAmount() - separateRespInfo.getSepaStlmAmount()));
SepaStatus sepaStatus = SepaStatus.getByValue(separateRespInfo.getSepaStatus());
switch (sepaStatus) {
case SUCCESS -> divideDetail.setStatus(DivideStatus.SUCCESS.getCode());
case FAIL -> divideDetail.setStatus(DivideStatus.FAIL.getCode());
case SUCCESS, PARTIALLY_SUCCESS -> divideDetail.setStatus(DivideStatus.SUCCESS.getCode());
case FAIL, A, C, R, E -> divideDetail.setStatus(DivideStatus.FAIL.getCode());
case PENDING -> divideDetail.setStatus(DivideStatus.PENDING.getCode());
case REFUNDED -> divideDetail.setStatus(DivideStatus.REFUNDED.getCode());
case PROCESSING -> divideDetail.setStatus(DivideStatus.PROCESSING.getCode());
default -> divideDetail.setStatus(DivideStatus.PROCESSING.getCode());
}
updateDetailList.add(divideDetail);