| | |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.apache.poi.ss.usermodel.DateUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.security.SecureRandom; |
| | | import java.util.Date; |
| | |
| | | * @date 2023年02月13日 |
| | | * @version: 1.0 |
| | | */ |
| | | @Component |
| | | public class CodeFactoryUtil { |
| | | |
| | | |
| | |
| | | |
| | | //将静态属性以入参(形参)的方式传入一个方法中,然后将此方法通过 @Autowired 注入到Spring容器中 |
| | | @Autowired |
| | | public void setService(RedisService redisService) { |
| | | public void setService(RedisService redisService) { |
| | | CodeFactoryUtil.redisService = redisService; |
| | | } |
| | | |
| | |
| | | * 用户id和随机数总长度 |
| | | */ |
| | | |
| | | private static final int maxLength = 4; |
| | | private static final int MAX_LENGTH = 4; |
| | | |
| | | /** |
| | | * 更具id进行加密+加随机数组成固定长度编码 |
| | |
| | | */ |
| | | public static String getShopNo(Long shopId) { |
| | | String prefix = SHOP_PREFIX; |
| | | return toFillZeroCode(prefix, maxLength, shopId); |
| | | return toFillZeroCode(prefix, MAX_LENGTH, shopId); |
| | | } |
| | | |
| | | public static String getShopOrderNo() { |