tuqin
13 小时以前 7580d02bd3f9399143a6a388732658bea2610bc4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package cn.iocoder.yudao.module.crm.dal.redis.no;
 
import cn.iocoder.yudao.framework.common.util.number.BizNoUtils;
import jakarta.annotation.Resource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;
 
 
/**
 * Crm 订单序号的 Redis DAO
 *
 * @author HUIHUI
 */
@Repository
public class CrmNoRedisDAO {
 
    /**
     * 合同 {@link cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO}
     */
    public static final String CONTRACT_NO_PREFIX = "HT";
 
    /**
     * 回款 {@link cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO}
     */
    public static final String RECEIVABLE_PREFIX = "HK";
 
    /**
     * 销售报价 {@link cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationDO}
     */
    public static final String SALE_QUOTATION_NO_PREFIX = "QT";
 
    /**
     * 开票 {@link cn.iocoder.yudao.module.crm.dal.dataobject.invoice.CrmInvoiceDO}
     */
    public static final String INVOICE_PREFIX = "KP";
 
    @Resource
    private StringRedisTemplate stringRedisTemplate;
 
    /**
     * 生成 16 位纯数字业务编码(全系统唯一)。
     *
     * <p>为兼容既有调用方,保留 {@code prefix} 入参,但不再参与编码拼接。
     *
     * @param prefix 单据类型前缀(已不再参与编码拼接)
     * @return 16 位纯数字编码
     */
    public String generate(String prefix) {
        // 全系统共用同一自增序列,保证编码「16 位纯数字」且全系统唯一
        Long no = stringRedisTemplate.opsForValue().increment(BizNoUtils.GLOBAL_SEQ_KEY);
        return BizNoUtils.format(no);
    }
 
}