xiaoyong931011
2020-06-18 254973f19bf7569a60d17ed6aa9eee2c9c9d71a3
src/main/java/com/xcong/excoin/common/system/service/impl/CommonServiceImpl.java
@@ -1,5 +1,7 @@
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;
@@ -8,6 +10,7 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
/**
 * @author wzy
@@ -26,7 +29,35 @@
        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();
    }
}