File was renamed from ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/util/CodeFactoryUtil.java |
| | |
| | | package com.ruoyi.order.util; |
| | | |
| | | package com.ruoyi.common.security.utils; |
| | | |
| | | |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | 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 javax.annotation.Resource; |
| | | import java.security.SecureRandom; |
| | | import java.util.Date; |
| | | import java.util.Random; |
| | |
| | | private static final String ORDER_PREFIX = "SC"; |
| | | |
| | | /** |
| | | * 活动订单前缀 |
| | | */ |
| | | private static final String ACTIVITY_ORDER_PREFIX = "MS"; |
| | | |
| | | /** |
| | | * 店铺创建订单前缀 |
| | | */ |
| | | private static final String SHOP_ORDER_PREFIX = "CJ"; |
| | | |
| | | |
| | | /** |
| | | * 退款订单前缀 |
| | | */ |
| | | private static final String ORDER_REFUND_PREFIX = "RO"; |
| | |
| | | * 用户id和随机数总长度 |
| | | */ |
| | | |
| | | private static final int MAX_LENGTH = 4; |
| | | /** |
| | | * 用户id和随机数总长度 |
| | | */ |
| | | |
| | | private static final int SHOP_LENGTH = 4; |
| | | |
| | | private static final int MEMBER_LENGTH = 6; |
| | | |
| | | private static final int ORDER_LENGTH = 4; |
| | | |
| | | /** |
| | | * 更具id进行加密+加随机数组成固定长度编码 |
| | | */ |
| | | |
| | | public static void main(String[] args) { |
| | | Long orderId = 1L; |
| | | String userNo = getShopNo(orderId); |
| | | System.out.println(userNo); |
| | | } |
| | | /*public static void main(String[] args) { |
| | | |
| | | }*/ |
| | | |
| | | /** |
| | | * 获取商户编号 |
| | |
| | | */ |
| | | public static String getShopNo(Long shopId) { |
| | | String prefix = SHOP_PREFIX; |
| | | return toFillZeroCode(prefix, MAX_LENGTH, shopId); |
| | | return toFillZeroCode(prefix, SHOP_LENGTH, shopId); |
| | | } |
| | | |
| | | /** |
| | | * 获取会员编号 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | public static String getMemberNo(Long userId) { |
| | | String prefix = APP_USER_PREFIX; |
| | | return toFillZeroCode(prefix, MEMBER_LENGTH, userId); |
| | | } |
| | | |
| | | public static String getShopOrderNo() { |