feat(system): 添加租户签约功能
- 新增租户签约状态枚举 - 在租户服务接口中添加提交签约、审核提交和确认签约的方法
This commit is contained in:
parent
1869dbb3a4
commit
329d25d4da
@ -0,0 +1,31 @@
|
||||
package org.dromara.common.core.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 租户签约状态
|
||||
* 0->待提交
|
||||
* 1->待审核
|
||||
* 2->待确认
|
||||
* 3->有效
|
||||
* 4->无效
|
||||
* 5->过期
|
||||
*
|
||||
* @author huk
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TenantSignStatus
|
||||
{
|
||||
TO_BE_SUBMITTED("0", "待提交"),
|
||||
TO_BE_REVIEWED("1", "待审核"),
|
||||
TO_BE_CONFIRMED("2", "待确认"),
|
||||
IN_EFFECT("3", "签约生效"),
|
||||
INVALID("4", "无效"),
|
||||
EXPIRED("5", "过期");
|
||||
|
||||
private final String status;
|
||||
private final String desc;
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.domain.SysTenant;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
import org.dromara.system.domain.bo.SysTenantExtendBo;
|
||||
import org.dromara.system.domain.bo.SysTenantReviewBo;
|
||||
import org.dromara.system.domain.dto.TenantDTO;
|
||||
import org.dromara.system.service.ISysTenantService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@ -129,6 +130,48 @@ public class SysTenantController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提交签约
|
||||
*/
|
||||
@Tag(name ="提交签约")
|
||||
@SaCheckRole(TenantConstants.TENANT_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:submitSign")
|
||||
@Log(title = "租户管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/submitSign/{tenantId}")
|
||||
public R<Void> submitSign(@PathVariable String tenantId) {
|
||||
tenantService.checkTenantAllowed(tenantId);
|
||||
return toAjax(tenantService.submitSign(tenantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核提交的签约
|
||||
*/
|
||||
@Tag(name ="审核提交的签约")
|
||||
@SaCheckRole(TenantConstants.TENANT_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:reviewSubmitted")
|
||||
@Log(title = "租户管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/reviewSubmitted")
|
||||
public R<Void> reviewSubmitted(@RequestBody SysTenantReviewBo bo) {
|
||||
tenantService.checkTenantAllowed(bo.getTenantId());
|
||||
tenantService.reviewSubmitted(bo);
|
||||
return R.ok("审核成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认审核通过的签约
|
||||
*/
|
||||
@Tag(name ="确认审核通过的签约")
|
||||
@SaCheckRole(TenantConstants.TENANT_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:confirmedSign")
|
||||
@Log(title = "租户管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/confirmedSign/{tenantId}")
|
||||
public R<Void> confirmedSign(@PathVariable String tenantId) {
|
||||
tenantService.checkTenantAllowed(tenantId);
|
||||
tenantService.confirmedSign(tenantId);
|
||||
return R.ok("确认成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,18 @@
|
||||
package org.dromara.system.domain;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -128,10 +126,10 @@ public class SysTenant extends BaseEntity {
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "所属代理商")
|
||||
private Long agencyTenantId;
|
||||
private String agencyTenantId;
|
||||
|
||||
@Schema(description = "所属推广人")
|
||||
private Long promoterTenantId;
|
||||
private String promoterTenantId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.dromara.system.domain;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -11,7 +10,6 @@ import org.dromara.common.core.domain.model.BaseAudit;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("sys_tenant_extend")
|
||||
@ -22,7 +20,7 @@ public class SysTenantExtend extends BaseAudit {
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "租户编号")
|
||||
private Long tenantId;
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "店铺id")
|
||||
private Long storeId;
|
||||
@ -87,6 +85,9 @@ public class SysTenantExtend extends BaseAudit {
|
||||
@Schema(description = "签约状态(0.待审核1.有效 2.无效 3.编辑 4.过期)")
|
||||
private String signStatus;
|
||||
|
||||
@Schema(description = "未通过原因")
|
||||
private String failureReason;
|
||||
|
||||
@Schema(description = "收款方名称")
|
||||
private String payeeName;
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package org.dromara.system.domain.bo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
/**
|
||||
* 租户签约审核
|
||||
*/
|
||||
@Data
|
||||
public class SysTenantReviewBo {
|
||||
|
||||
@Schema(description = "租户编号")
|
||||
@NotBlank(message = "租户编号不能为空")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "是否通过")
|
||||
@NotNull(message = "是否通过不能为空")
|
||||
private Boolean isPass;
|
||||
|
||||
@Schema(description = "未通过原因")
|
||||
@Length(max = 255, message = "未通过原因长度不能超过255个字符")
|
||||
private String failureReason;
|
||||
|
||||
|
||||
|
||||
}
|
@ -8,7 +8,6 @@ import lombok.Data;
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TenantDTO {
|
||||
@ -146,6 +145,9 @@ public class TenantDTO {
|
||||
@Schema(description = "签约状态(0.待审核1.有效 2.无效 3.编辑 4.过期)")
|
||||
private String signStatus;
|
||||
|
||||
@Schema(description = "未通过原因")
|
||||
private String failureReason;
|
||||
|
||||
@Schema(description = "邀请人名称")
|
||||
private String inviteUserName;
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.SysTenantExtend;
|
||||
import org.dromara.system.domain.vo.SysTenantExtendVo;
|
||||
|
||||
@Mapper
|
||||
public interface SysTenantExtendMapper extends BaseMapperPlus<SysTenantExtend, SysTenantExtendVo> {
|
||||
|
||||
@Select("select * from sys_tenant_extend where tenant_id = #{tenantId}")
|
||||
SysTenantExtend selectByTenantId(String tenantId);
|
||||
}
|
||||
|
@ -75,5 +75,5 @@ public interface SysTenantMapper extends BaseMapperPlus<SysTenant, SysTenantVo>
|
||||
int batchDeleteTenantByIds(List<Long> ids);
|
||||
|
||||
@Select("SELECT * FROM sys_tenant WHERE tenant_id = #{tenantId}")
|
||||
SysTenant selectByBelongId(Long belongId);
|
||||
SysTenant selectByTenantId(String tenantId);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.dromara.system.domain.SysTenant;
|
||||
import org.dromara.system.domain.bo.SysTenantExtendBo;
|
||||
import org.dromara.system.domain.bo.SysTenantReviewBo;
|
||||
import org.dromara.system.domain.dto.TenantDTO;
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
@ -98,4 +99,23 @@ public interface ISysTenantService {
|
||||
|
||||
|
||||
Boolean batchRemoveByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 提交签约
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
int submitSign(String tenantId);
|
||||
|
||||
/**
|
||||
* 审核租户提交的签约
|
||||
* @param bo
|
||||
*/
|
||||
void reviewSubmitted(SysTenantReviewBo bo);
|
||||
|
||||
/**
|
||||
* 确认签约
|
||||
* @param tenantId
|
||||
*/
|
||||
void confirmedSign(String tenantId);
|
||||
}
|
||||
|
@ -4,8 +4,10 @@ import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
@ -16,6 +18,7 @@ import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
import org.dromara.common.core.enums.TenantSignStatus;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.service.WorkflowService;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
@ -30,6 +33,7 @@ import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.system.domain.*;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
import org.dromara.system.domain.bo.SysTenantExtendBo;
|
||||
import org.dromara.system.domain.bo.SysTenantReviewBo;
|
||||
import org.dromara.system.domain.dto.TenantDTO;
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
import org.dromara.system.mapper.*;
|
||||
@ -134,11 +138,10 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
// 处理sys_tenant表数据
|
||||
SysTenant tenant = new SysTenant();
|
||||
|
||||
Long belongId = Long.valueOf(LoginHelper.getTenantId());
|
||||
|
||||
String currentTenantId = LoginHelper.getTenantId();
|
||||
|
||||
if (bo.getExpiryDate() != null) {
|
||||
SysTenant sysTenant = baseMapper.selectByBelongId(belongId);
|
||||
SysTenant sysTenant = baseMapper.selectByTenantId(currentTenantId);
|
||||
if (sysTenant != null) {
|
||||
Integer type = sysTenant.getType();
|
||||
if (type != 1 && type != 3) {
|
||||
@ -150,7 +153,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
}
|
||||
|
||||
if (bo.getStoreName() != null) {
|
||||
SysTenant sysTenant = baseMapper.selectByBelongId(belongId);
|
||||
SysTenant sysTenant = baseMapper.selectByTenantId(currentTenantId);
|
||||
if (sysTenant != null) {
|
||||
Integer type = sysTenant.getType();
|
||||
if (type != 2 && type != 3) {
|
||||
@ -197,10 +200,10 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
tenant.setQualification(bo.getQualification());
|
||||
tenant.setType(bo.getType());
|
||||
if (bo.getType() == 2){
|
||||
tenant.setAgencyTenantId(belongId);
|
||||
tenant.setAgencyTenantId(currentTenantId);
|
||||
}
|
||||
if (bo.getType() == 0){
|
||||
tenant.setPromoterTenantId(belongId);
|
||||
tenant.setPromoterTenantId(currentTenantId);
|
||||
}
|
||||
|
||||
// 插入sys_tenant表
|
||||
@ -213,7 +216,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
// 处理sys_tenant_extend表数据
|
||||
SysTenantExtend tenantExtend = new SysTenantExtend();
|
||||
// 设置租户ID关联
|
||||
tenantExtend.setTenantId(Long.valueOf(tenantId));
|
||||
tenantExtend.setTenantId(tenantId);
|
||||
// 设置扩展表字段
|
||||
tenantExtend.setStoreId(tenant.getId());
|
||||
tenantExtend.setIdCard(bo.getIdCard());
|
||||
@ -789,6 +792,45 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
return extendDeleteCount >= 0 && tenantDeleteCount >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int submitSign(String tenantId) {
|
||||
SysTenantExtend tenantExtend = tenantExtendMapper.selectByTenantId(tenantId);
|
||||
Assert.notNull(tenantExtend, () -> new ServiceException("无效的租户信息"));
|
||||
Assert.isTrue(TenantSignStatus.TO_BE_SUBMITTED.getStatus().equals(tenantExtend.getSignStatus()), () -> new ServiceException("当前状态不可提交签约"));
|
||||
SysTenantExtend updateTenantExtend = new SysTenantExtend();
|
||||
updateTenantExtend.setId(tenantExtend.getId());
|
||||
updateTenantExtend.setSignStatus(TenantSignStatus.TO_BE_REVIEWED.getStatus());
|
||||
return tenantExtendMapper.updateById(updateTenantExtend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reviewSubmitted(SysTenantReviewBo bo) {
|
||||
SysTenantExtend tenantExtend = tenantExtendMapper.selectByTenantId(bo.getTenantId());
|
||||
Assert.notNull(tenantExtend, () -> new ServiceException("无效的租户信息"));
|
||||
Assert.isTrue(TenantSignStatus.TO_BE_REVIEWED.getStatus().equals(tenantExtend.getSignStatus()), () -> new ServiceException("当前状态不可审核"));
|
||||
Boolean isPass = bo.getIsPass();
|
||||
Assert.isTrue(!isPass && StrUtil.isNotBlank(bo.getFailureReason()), () -> new ServiceException("请填写审核未通过原因"));
|
||||
SysTenantExtend updateTenantExtend = new SysTenantExtend();
|
||||
updateTenantExtend.setId(tenantExtend.getId());
|
||||
if (isPass) {
|
||||
updateTenantExtend.setSignStatus(TenantSignStatus.TO_BE_CONFIRMED.getStatus());
|
||||
}else{
|
||||
updateTenantExtend.setSignStatus(TenantSignStatus.TO_BE_SUBMITTED.getStatus());
|
||||
updateTenantExtend.setFailureReason(bo.getFailureReason());
|
||||
}
|
||||
tenantExtendMapper.updateById(updateTenantExtend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmedSign(String tenantId) {
|
||||
SysTenantExtend tenantExtend = tenantExtendMapper.selectByTenantId(tenantId);
|
||||
Assert.notNull(tenantExtend, () -> new ServiceException("无效的租户信息"));
|
||||
Assert.isTrue(TenantSignStatus.TO_BE_CONFIRMED.getStatus().equals(tenantExtend.getSignStatus()), () -> new ServiceException("未审核通过的签约不可确认"));
|
||||
SysTenantExtend updateTenantExtend = new SysTenantExtend();
|
||||
updateTenantExtend.setId(tenantExtend.getId());
|
||||
updateTenantExtend.setSignStatus(TenantSignStatus.IN_EFFECT.getStatus());
|
||||
tenantExtendMapper.updateById(updateTenantExtend);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user