|  |  |  | 
|---|
|  |  |  | package com.xcong.excoin.common.system.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.hutool.core.date.DateUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.RandomUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.StrUtil; | 
|---|
|  |  |  | import com.xcong.excoin.common.contants.AppContants; | 
|---|
|  |  |  | import com.xcong.excoin.common.system.service.CommonService; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author wzy | 
|---|
|  |  |  | 
|---|
|  |  |  | if (StrUtil.isBlank(cacheCode)) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (code.equals(cacheCode)) { | 
|---|
|  |  |  | redisUtils.del(AppContants.VERIFY_CODE_PREFIX + account); | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return code.equals(cacheCode); | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String generateOrderNo(Long mid) { | 
|---|
|  |  |  | StringBuilder orderNo = new StringBuilder(); | 
|---|
|  |  |  | String date = DateUtil.format(new Date(), "yyyyMMdd"); | 
|---|
|  |  |  | orderNo.append(date); | 
|---|
|  |  |  | orderNo.append(mid); | 
|---|
|  |  |  | orderNo.append(RandomUtil.randomNumbers(2)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Object countObj = redisUtils.get(date); | 
|---|
|  |  |  | if (countObj == null) { | 
|---|
|  |  |  | countObj = 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int count = (int) countObj; | 
|---|
|  |  |  | count++; | 
|---|
|  |  |  | redisUtils.set(date, count, 24 * 60 * 60); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int size = 4; | 
|---|
|  |  |  | for (int i = 0; i < size - String.valueOf(count).length(); i++) { | 
|---|
|  |  |  | orderNo.append("0"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderNo.append(count); | 
|---|
|  |  |  | return orderNo.toString(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|