Make the following definitions in the project local.properties:

keygen.order.code.digits=8

keygen.order.code.start=00000000

keygen.order.code.numeric=true

keygen.order.code.template=$



core-spring.xml:

<bean id="orderCodeGenerator" class="de.hybris.platform.servicelayer.keygenerator.impl.PersistentKeyGenerator">
<property name="key" value="${keygen.order.code.name}"/>
<property name="digits" value="${keygen.order.code.digits}"/>
<property name="start" value="${keygen.order.code.start}"/>
<property name="numeric" value="${keygen.order.code.numeric}"/>
<property name="template" value="${keygen.order.code.template}"/>
Copy the code

The effect is as follows:



If you do not want to restart Hybris Server after changing the definition, they will take effect immediately using Java code like this:

import de.hybris.platform.jalo.numberseries.*
NumberSeriesManager nm = NumberSeriesManager.getInstance()
def s = nm.getNumberSeries("order_code")
println "Before: current: ${s.currentNumber} type: ${s.type} template: ${s.template}"
nm.resetNumberSeries(s.key, "777", s.type, s.template )
def s2 = nm.getNumberSeries("order_code")
println "After: current: ${s2.currentNumber} type: ${s2.type} template: ${s2.template}"
Copy the code

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: