激活码相关接口

This commit is contained in:
张松
2025-02-11 11:18:33 +08:00
parent 48a9376657
commit 1603139acb
11 changed files with 137 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
package com.czg.service.account.dto.register;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
public record MerchantRegisterDTO(
@NotNull(message = "激活时长不能为空")
@Min(1)
Integer periodMonth,
@NotNull(message = "数量不为空")
@Min(1)
@Max(10)
Integer num
) {
}

View File

@@ -11,7 +11,7 @@ public record ShopInfoAddDTO(
String shopName,
@NotEmpty(message = "店铺类型不为空")
String shopType,
String subTitle,
String chainName,
@NotEmpty(message = "店铺logo不为空")
String logo,
@NotEmpty(message = "门头照不为空")
@@ -33,7 +33,6 @@ public record ShopInfoAddDTO(
@NotNull(message = "角色id不为空")
Long roleId,
String address,
Integer status,
String phone
) {
}

View File

@@ -1,8 +1,13 @@
package com.czg.service.account.service;
import com.czg.service.account.dto.PageDTO;
import com.czg.service.account.dto.register.MerchantRegisterDTO;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import com.czg.service.account.entity.MerchantRegister;
import java.time.LocalDateTime;
/**
* 激活码 服务层。
*
@@ -11,4 +16,7 @@ import com.czg.service.account.entity.MerchantRegister;
*/
public interface MerchantRegisterService extends IService<MerchantRegister> {
Page<MerchantRegister> get(PageDTO pageDTO, Integer state, LocalDateTime startTime, LocalDateTime endTime);
Boolean add(MerchantRegisterDTO merchantRegisterDTO);
}

View File

@@ -1,11 +1,22 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.util.IdUtil;
import com.czg.service.account.dto.PageDTO;
import com.czg.service.account.dto.register.MerchantRegisterDTO;
import com.czg.service.account.entity.SysRole;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.service.account.entity.MerchantRegister;
import com.czg.service.account.mapper.MerchantRegisterMapper;
import com.czg.service.account.service.MerchantRegisterService;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import static com.mybatisflex.core.query.QueryMethods.column;
/**
* 激活码 服务层实现。
*
@@ -15,4 +26,35 @@ import org.springframework.stereotype.Service;
@Service
public class MerchantRegisterServiceImpl extends ServiceImpl<MerchantRegisterMapper, MerchantRegister> implements MerchantRegisterService{
@Override
public Page<MerchantRegister> get(PageDTO pageDTO, Integer state, LocalDateTime startTime, LocalDateTime endTime) {
QueryWrapper queryWrapper = new QueryWrapper();
if (state != null) {
queryWrapper.eq(MerchantRegister::getStatus, state);
}
if (startTime != null) {
queryWrapper.ge(SysRole::getCreateTime, startTime);
}
if (endTime != null) {
queryWrapper.le(SysRole::getCreateTime, endTime);
}
return page(new Page<>(pageDTO.page(), pageDTO.size()), queryWrapper);
}
@Override
public Boolean add(MerchantRegisterDTO merchantRegisterDTO) {
ArrayList<MerchantRegister> registers = new ArrayList<>();
for (int i = 0; i < merchantRegisterDTO.num(); i++) {
MerchantRegister tbMerchantRegister = new MerchantRegister();
tbMerchantRegister.setRegisterCode(IdUtil.simpleUUID());
tbMerchantRegister.setStatus(0);
tbMerchantRegister.setPeriodMonth(merchantRegisterDTO.periodMonth());
registers.add(tbMerchantRegister);
}
return saveBatch(registers);
}
}

View File

@@ -71,6 +71,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
shopInfo.setId(sysUser.getId());
//设置激活码
shopInfo.setStatus(1);
shopInfo.setProfiles("release");
shopInfo.setExpireTime(DateUtil.offsetMonth(DateUtil.date(), merchantRegister.getPeriodMonth()).toLocalDateTime());
return save(shopInfo);
}

View File

@@ -2,6 +2,6 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.account.mapper.TbShopInfoMapper">
<mapper namespace="com.czg.service.account.mapper.ShopInfoMapper">
</mapper>

View File

@@ -2,6 +2,6 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.account.mapper.TbShopUserMapper">
<mapper namespace="com.czg.service.account.mapper.ShopStaffMapper">
</mapper>

View File

@@ -2,6 +2,6 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.account.mapper.TbShopStaffMapper">
<mapper namespace="com.czg.service.account.mapper.ShopUserMapper">
</mapper>