TRX 1 an în urmă
părinte
comite
953d824d3b

+ 79 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/base/CommonService.java

@@ -0,0 +1,79 @@
+package com.zhongshu.payment.server.core.service.base;
+
+import com.mongodb.client.result.UpdateResult;
+import com.zhongshu.payment.server.core.utils.CommonUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * @author TRX
+ * @date 2024/5/31
+ */
+@Slf4j
+@Service
+public class CommonService {
+
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+    /**
+     * 编辑数据
+     *
+     * @param standardData
+     * @param collectionName
+     * @return
+     */
+    public Object updateData(Map<String, Object> standardData, String collectionName) {
+        collectionName = CommonUtil.getCollectionName(collectionName);
+        Object id = standardData.get("id");
+        Query query = new Query(Criteria.where("_id").is(id));
+        Update update = new Update();
+        standardData.forEach((key, value) -> {
+            if (!"id".equals(key)) {
+                update.set(key, value);
+            }
+        });
+        UpdateResult updateResult = mongoTemplate.upsert(query, update, collectionName);
+        return updateResult.getUpsertedId();
+    }
+
+    public Object updateData(String id, Map<String, Object> standardData, String collectionName) {
+        collectionName = CommonUtil.getCollectionName(collectionName);
+        Query query = new Query(Criteria.where("_id").is(id));
+        Update update = new Update();
+        standardData.forEach((key, value) -> {
+            if (!"id".equals(key)) {
+                update.set(key, value);
+            }
+        });
+        UpdateResult updateResult = mongoTemplate.upsert(query, update, collectionName);
+        return updateResult.getUpsertedId();
+    }
+
+    public Object updateData(Map<String, Object> where, Map<String, Object> standardData, String collectionName) {
+        collectionName = CommonUtil.getCollectionName(collectionName);
+        Criteria criteria = new Criteria();
+        if (where != null) {
+            where.forEach((key, value) -> {
+                criteria.and(key).is(value);
+            });
+        }
+        Query query = new Query(criteria);
+        Update update = new Update();
+        standardData.forEach((key, value) -> {
+            if (!"id".equals(key)) {
+                update.set(key, value);
+            }
+        });
+        UpdateResult updateResult = mongoTemplate.upsert(query, update, collectionName);
+        return updateResult.getUpsertedId();
+    }
+
+}

+ 89 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/base/RedisService.java

@@ -0,0 +1,89 @@
+package com.zhongshu.payment.server.core.service.base;
+
+import com.zhongshu.payment.server.core.utils.exception.ServiceException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.TimeUnit;
+
+
+@Service
+public class RedisService {
+
+    @Autowired
+    private StringRedisTemplate template;
+
+    public void addExpireToken(String loginName, String token, long tokenExpirePeriod) {
+        try {
+            String[] tokens = token.split("\\.");
+            //template.boundValueOps(tokenKey).set(loginName, 10000, TimeUnit.MILLISECONDS);
+            template.opsForValue().set(tokens[1], loginName, tokenExpirePeriod, TimeUnit.MILLISECONDS);
+        } catch (Exception e) {
+            throw new ServiceException("系统故障,请联系服务商");
+        }
+    }
+
+    public void removeExpireToken(String loginName, String token) {
+        try {
+            String[] tokens = token.split("\\.");
+            //template.boundValueOps(tokenKey).set(loginName, 10000, TimeUnit.MILLISECONDS);
+            template.delete(tokens[1]);
+        } catch (Exception e) {
+            throw new ServiceException("系统故障,请联系服务商");
+        }
+    }
+
+    public boolean verifyExpireJwtToken(String loginName, String jwtToken) {
+        try {
+            String[] tokens = jwtToken.split("\\.");
+            //template.boundValueOps(tokenKey).set(loginName, 10000, TimeUnit.MILLISECONDS);
+            return template.hasKey(tokens[1]);
+        } catch (Exception e) {
+            throw new ServiceException("系统故障,请联系服务商");
+        }
+    }
+
+    public boolean verifyExpireCode(String code) {
+        try {
+            //template.boundValueOps(tokenKey).set(loginName, 10000, TimeUnit.MILLISECONDS);
+            return template.hasKey(code);
+        } catch (Exception e) {
+            throw new ServiceException("系统故障,请联系服务商");
+        }
+    }
+
+
+    public void setValue(String key, String value, long expirePeriod) {
+        try {
+            template.opsForValue().set(key, value, expirePeriod, TimeUnit.MILLISECONDS);
+        } catch (Exception e) {
+            throw new ServiceException("系统故障,请联系服务商");
+        }
+    }
+
+    public void setValueSecond(String key, String value, long expirePeriod) {
+        try {
+            template.opsForValue().set(key, value, expirePeriod, TimeUnit.SECONDS);
+        } catch (Exception e) {
+            throw new ServiceException("系统故障,请联系服务商");
+        }
+    }
+
+    public String getValue(String key) {
+        try {
+            return template.opsForValue().get(key);
+        } catch (Exception e) {
+            throw new ServiceException("系统故障,请联系服务商");
+        }
+    }
+
+    public void removeValue(String key) {
+        try {
+            template.delete(key);
+        } catch (Exception e) {
+            throw new ServiceException("系统故障,请联系服务商");
+        }
+    }
+
+}

+ 160 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/base/SuperService.java

@@ -0,0 +1,160 @@
+package com.zhongshu.payment.server.core.service.base;
+
+import com.github.microservice.auth.security.helper.AuthHelper;
+import com.zhongshu.card.client.model.base.SuperParam;
+import com.zhongshu.card.client.model.base.SuperSearch;
+import com.zhongshu.payment.server.core.domain.base.SuperMain;
+import com.zhongshu.payment.server.core.utils.DateUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.Assert;
+
+import java.util.List;
+
+/**
+ * @author TRX
+ * @date 2024/6/3
+ */
+public abstract class SuperService {
+
+    @Autowired
+    private AuthHelper authHelper;
+
+    /**
+     * 得到当前的用户ID
+     *
+     * @return
+     */
+    public String getCurrentUserId() {
+        if (authHelper != null && authHelper.getCurrentUser() != null) {
+            return authHelper.getCurrentUser().getUserId();
+        }
+        return null;
+    }
+
+    /**
+     * 得到当前的Oid
+     *
+     * @return
+     */
+    public String getCurrentOid() {
+        if (authHelper != null && authHelper.getCurrentUser() != null) {
+            return authHelper.getOrgId();
+        }
+        return null;
+    }
+
+    /**
+     * 初始Entity的默认参数 oid、createUser (oid为空会抛出异常)
+     *
+     * @param entity
+     */
+    public void initEntity(SuperMain entity) {
+        if (entity != null) {
+            String oid = entity.getOid();
+            if (StringUtils.isEmpty(oid)) {
+                entity.setOid(getCurrentOid());
+            }
+            Assert.hasText(entity.getOid(), "oid不能为空");
+
+            if (authHelper != null && authHelper.getCurrentUser() != null) {
+                entity.setCreateUserId(authHelper.getCurrentUser().getUserId());
+                entity.setCreateUserName(authHelper.getCurrentUser().getUserName());
+                entity.setCreatePhone(authHelper.getCurrentUser().getPhone());
+            }
+        }
+    }
+
+    public void initEntityNoCheckOid(SuperMain entity) {
+        if (entity != null) {
+            String oid = entity.getOid();
+            if (StringUtils.isEmpty(oid)) {
+                entity.setOid(getCurrentOid());
+            }
+            if (authHelper != null && authHelper.getCurrentUser() != null) {
+                entity.setCreateUserId(authHelper.getCurrentUser().getUserId());
+                entity.setCreateUserName(authHelper.getCurrentUser().getUserName());
+                entity.setCreatePhone(authHelper.getCurrentUser().getPhone());
+            }
+        }
+    }
+
+    /**
+     * 填充当前用户和oid信息 (oid为空会抛出异常)
+     *
+     * @param param
+     */
+    public void initDefaultUserAndOid(SuperParam param) {
+        initDefaultUserParam(param);
+        initOid(param);
+        if (param.getId() != null && param.getId().trim().equals("")) {
+            param.setId(null);
+        }
+    }
+
+    public void initDefaultUserAndOidNoExcept(SuperParam param) {
+        initDefaultUserParam(param);
+        String oid = param.getOid();
+        if (StringUtils.isEmpty(oid)) {
+            param.setOid(getCurrentOid());
+        }
+        if (param.getId() != null && param.getId().trim().equals("")) {
+            param.setId(null);
+        }
+    }
+
+    public void initDefaultUserParam(SuperParam param) {
+        if (authHelper != null && authHelper.getCurrentUser() != null && StringUtils.isEmpty(param.getCreateUserId())) {
+            param.setCreateUserId(authHelper.getCurrentUser().getUserId());
+            param.setCreateUserName(authHelper.getCurrentUser().getUserName());
+            param.setCreatePhone(authHelper.getCurrentUser().getPhone());
+        }
+    }
+
+    public void initOid(SuperParam param) {
+        String oid = param.getOid();
+        if (StringUtils.isEmpty(oid)) {
+            param.setOid(getCurrentOid());
+        }
+        Assert.hasText(param.getOid(), "oid不能为空");
+    }
+
+    /**
+     * 初始填充搜索 oid times
+     *
+     * @param param
+     */
+    public void initOidSearchParam(SuperSearch param) {
+        String oid = param.getOid();
+        if (StringUtils.isEmpty(oid)) {
+            param.setOid(getCurrentOid());
+        }
+        Assert.hasText(param.getOid(), "oid不能为空");
+        List<Long> times = param.getTimes();
+        if (ObjectUtils.isNotEmpty(times) && times.size() == 2) {
+            Long startTime = times.get(0);
+            startTime = DateUtils.getDayStartTime(startTime);
+            Long endTime = times.get(1);
+            endTime = DateUtils.getDayEndTime(endTime);
+            param.setStartTime(startTime);
+            param.setEndTime(endTime);
+        }
+    }
+
+    public void initOidSearchParamNoCheckOid(SuperSearch param) {
+        String oid = param.getOid();
+        if (StringUtils.isEmpty(oid)) {
+            param.setOid(getCurrentOid());
+        }
+        List<Long> times = param.getTimes();
+        if (ObjectUtils.isNotEmpty(times) && times.size() == 2) {
+            Long startTime = times.get(0);
+            startTime = DateUtils.getDayStartTime(startTime);
+            Long endTime = times.get(1);
+            endTime = DateUtils.getDayEndTime(endTime);
+            param.setStartTime(startTime);
+            param.setEndTime(endTime);
+        }
+    }
+}

+ 14 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/wxPayment/WxPaymentService.java

@@ -0,0 +1,14 @@
+package com.zhongshu.payment.server.core.service.wxPayment;
+
+import com.zhongshu.payment.server.core.service.base.SuperService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author TRX
+ * @date 2024/7/22
+ */
+@Slf4j
+@Service
+public class WxPaymentService extends SuperService {
+}

+ 454 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/utils/CommonUtil.java

@@ -0,0 +1,454 @@
+package com.zhongshu.payment.server.core.utils;
+
+import com.google.common.collect.Lists;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.client.j2se.MatrixToImageWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.QRCodeWriter;
+import com.zhongshu.card.client.utils.ITree;
+import com.zhongshu.card.client.utils.type.Sex;
+import com.zhongshu.card.server.core.domain.base.SuperMain;
+import com.zhongshu.card.server.core.util.exception.BusinessException;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.bson.types.Decimal128;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.Pageable;
+
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
+
+/**
+ * 工具类方法
+ *
+ * @author TRX
+ * @date 2024/3
+ */
+@Slf4j
+public class CommonUtil {
+
+    private static final List<String> outKeys = List.of("id", "createTime", "updateTime", "remark", "hashCode", "isSync2Platform", "syncTime", "isSync2Shop");
+
+    /**
+     * 生成指定长度的随机码(由数字构成)
+     *
+     * @param length
+     * @return
+     */
+    public static String randomCode(int length) {
+        StringBuilder str = new StringBuilder();
+        Random random = new Random();
+        for (int i = 0; i < length; i++) {
+            str.append(random.nextInt(10));
+        }
+        return str.toString();
+    }
+
+    /**
+     * 生产UUID
+     *
+     * @return
+     */
+    public static String UUID() {
+        return UUID.randomUUID().toString().replaceAll("-", "");
+    }
+
+    /**
+     * 创建空分页对象
+     *
+     * @param pageable
+     * @param cls
+     * @param <T>
+     * @return
+     */
+    public static <T> Page<T> buildEmptyPage(Pageable pageable, Class<T> cls) {
+        return new PageImpl<T>(Lists.newArrayList(), pageable, 0);
+    }
+
+    public static Long getLongZero(Long number) {
+        if (number == null) {
+            return Long.valueOf(0);
+        }
+        return number;
+    }
+
+    /**
+     * 判断long值是否为空:为 null 或 0 时都为空
+     *
+     * @param longValue
+     * @return
+     */
+    public static boolean longIsEmpty(Long longValue) {
+        if (longValue == null || longValue <= 0) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 判断bigDecimal值是否为空:为 null 或 0 时都为空
+     *
+     * @param bigDecimal
+     * @return
+     */
+    public static boolean bigDecimalIsEmpty(BigDecimal bigDecimal) {
+        if (bigDecimal == null || bigDecimal.compareTo(BigDecimal.ZERO) <= 0) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 把消费机的金额转为 数字 单位:分,
+     *
+     * @param amount 2.45 (传过来的单位是:元)
+     * @return
+     */
+    public static BigDecimal turnMoney2BigDecimal(String amount) {
+        BigDecimal money = BigDecimal.ZERO;
+        try {
+            money = new BigDecimal(amount).multiply(BigDecimal.valueOf(100));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return money;
+    }
+
+    public static String turnMoney2Show(BigDecimal amount) {
+        String str = "0.00";
+        try {
+            str = amount.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).toString();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return str;
+    }
+
+    /**
+     * 2个Long是否相等
+     *
+     * @param val1
+     * @param val2
+     * @return
+     */
+    public static boolean longIsEqual(Long val1, Long val2) {
+        if (val1 == null || val2 == null) {
+            return false;
+        }
+        if (val1.longValue() == val2.longValue()) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 判断2个时间 是否是同一天
+     *
+     * @param time1
+     * @param time2
+     * @return
+     */
+    public static boolean isSameDay(Long time1, Long time2) {
+        if (time1 == null || time2 == null) {
+            return false;
+        }
+        if (DateUtils.paresTime(time1, DateUtils.pattern).equals(DateUtils.paresTime(time2, DateUtils.pattern))) {
+            return true;
+        }
+        return false;
+    }
+
+    public static BigDecimal getBigDecimalByLong(Long number) {
+        if (number != null) {
+            return BigDecimal.valueOf(number);
+        }
+        return BigDecimal.ZERO;
+    }
+
+    public static String getCollectionName(Class domainClass) {
+        if (domainClass != null) {
+            String className = domainClass.getSimpleName();
+            String collectionName = className.replace(className.charAt(0), String.valueOf(className.charAt(0)).toLowerCase().toCharArray()[0]);
+            return collectionName;
+        } else {
+            return null;
+        }
+    }
+
+    public static String getCollectionName(String collectionName) {
+        if (StringUtils.isNotEmpty(collectionName)) {
+            String[] arr = collectionName.split(".");
+            if (arr.length > 1) {
+                collectionName = arr[(arr.length - 1)];
+            }
+            collectionName = collectionName.replace(collectionName.charAt(0), String.valueOf(collectionName.charAt(0)).toLowerCase().toCharArray()[0]);
+            return collectionName;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * obj对象转 BigDecimal
+     *
+     * @param obj
+     * @return
+     */
+    public static BigDecimal getBigDecimalByObj(Object obj) {
+        BigDecimal count = BigDecimal.ZERO;
+        if (obj != null) {
+            if (obj instanceof Integer) {
+                count = new BigDecimal((Integer) obj);
+            } else if (obj instanceof Decimal128) {
+                Decimal128 countDecimal = (Decimal128) obj;
+                count = countDecimal.bigDecimalValue();
+            } else if (obj instanceof BigDecimal) {
+                count = (BigDecimal) obj;
+            } else if (obj instanceof Long) {
+                count = new BigDecimal((Long) obj);
+            }
+        }
+        return count;
+    }
+
+    /**
+     * BigDecimal 保留四位小数
+     *
+     * @param bigDecimal
+     * @return
+     */
+    public static BigDecimal getBigDecimalScale4(BigDecimal bigDecimal) {
+        if (bigDecimal != null) {
+            String ss = bigDecimal.setScale(4, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
+            bigDecimal = new BigDecimal(ss);
+            return bigDecimal;
+        }
+        return BigDecimal.ZERO;
+    }
+
+    /**
+     * 向上取整,如:16.251、16.256 -> 16.25
+     *
+     * @param bigDecimal
+     * @return
+     */
+    public static BigDecimal getBigDecimalScale2(BigDecimal bigDecimal) {
+        if (bigDecimal != null) {
+            String ss = bigDecimal.setScale(2, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
+            bigDecimal = new BigDecimal(ss);
+            return bigDecimal;
+        }
+        return BigDecimal.ZERO;
+    }
+
+    public static BigDecimal getBigDecimalScale2Floor(BigDecimal bigDecimal) {
+        if (bigDecimal != null) {
+            String ss = bigDecimal.setScale(2, RoundingMode.FLOOR).stripTrailingZeros().toPlainString();
+            bigDecimal = new BigDecimal(ss);
+            return bigDecimal;
+        }
+        return BigDecimal.ZERO;
+    }
+
+    /**
+     * 不保留小数,, 四舍五入
+     *
+     * @param bigDecimal
+     * @return
+     */
+    public static BigDecimal getBigDecimalScale0(BigDecimal bigDecimal) {
+        if (bigDecimal != null) {
+            String ss = bigDecimal.setScale(0, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
+            bigDecimal = new BigDecimal(ss);
+            return bigDecimal;
+        }
+        return BigDecimal.ZERO;
+    }
+
+    /**
+     * 不要小数,,而且 向下取数 如:16.2455、16.874 -> 16
+     *
+     * @param bigDecimal
+     * @return
+     */
+    public static BigDecimal getBigDecimalScale0Floor(BigDecimal bigDecimal) {
+        if (bigDecimal != null) {
+            String ss = bigDecimal.setScale(0, RoundingMode.FLOOR).stripTrailingZeros().toPlainString();
+            bigDecimal = new BigDecimal(ss);
+            return bigDecimal;
+        }
+        return BigDecimal.ZERO;
+    }
+
+
+    public static Map<String, Object> filterData(Collection<Map<String, Object>> datas, List<String> props) {
+        Map<String, Object> useDataMap = new HashMap<>(props.size());
+        datas.forEach(actDataMap -> {
+            for (String prop : props) {
+                if (actDataMap.containsKey(prop)) {
+                    useDataMap.put(prop, actDataMap.get(prop));
+                }
+            }
+        });
+        return useDataMap;
+    }
+
+    /**
+     * BigDecimal 是否含有小数,如:12.202 true  12.0000 false
+     *
+     * @param number
+     * @return
+     */
+    public static boolean bigDecimalHasDec(BigDecimal number) {
+        boolean b = false;
+        if (number != null) {
+            BigDecimal number1 = BigDecimal.valueOf(number.intValue());
+            if (number1.compareTo(number) != 0) {
+                b = true;
+            }
+        }
+        return b;
+    }
+
+    /**
+     * 判断 BigDecimal 是否是最小值
+     *
+     * @param number
+     * @return
+     */
+    public static boolean bigDecimalIsSmall(BigDecimal number) {
+        if (number.compareTo(BigDecimal.valueOf(0.02)) <= 0) {
+            return true;
+        }
+        return false;
+    }
+
+    public static boolean treeIdIsTop(String id) {
+        if (StringUtils.isEmpty(id) || id.equals(ITree.ROOT_ID)) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 小时转为分钟,,保留整数 (最小 1 分钟)
+     *
+     * @param hours 1.5
+     * @return 90
+     */
+    public static int trun2Mins(BigDecimal hours) {
+        int mins = 0;
+        if (hours != null) {
+            BigDecimal number = getBigDecimalScale0(hours.multiply(BigDecimal.valueOf(60)));
+            mins = number.intValue();
+            if (mins <= 0) {
+                mins = 1;
+            }
+        }
+        return mins;
+    }
+
+    @SneakyThrows
+    public static String getQRCode(String text, int width, int height) {
+        QRCodeWriter qrCodeWriter = new QRCodeWriter();
+        BitMatrix bitMatrix = qrCodeWriter.encode(new String(text.getBytes("UTF-8"), "ISO-8859-1"), BarcodeFormat.QR_CODE, width, height);
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        MatrixToImageWriter.writeToStream(bitMatrix, "PNG", outputStream);
+        return Base64.getEncoder().encodeToString(outputStream.toByteArray());
+    }
+
+    public static String getIvKey(String phone, String iv) {
+        return String.format("wxApp=%s%s", phone, iv);
+    }
+
+    /**
+     * 汉字转为拼音
+     *
+     * @param chinaStr
+     * @return
+     */
+    public static String getPinyin(String chinaStr) {
+        if (StringUtils.isEmpty(chinaStr)) {
+            return "";
+        }
+        HanyuPinyinOutputFormat forMat = new HanyuPinyinOutputFormat();
+        forMat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
+        forMat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+        forMat.setVCharType(HanyuPinyinVCharType.WITH_V);
+        char[] arrays = chinaStr.trim().toCharArray();
+        String result = "";
+        try {
+            for (int i = 0; i < arrays.length; i++) {
+                char ti = arrays[i];
+                if (Character.toString(ti).matches("[\\u4e00-\\u9fa5]")) { //匹配是否是中文
+                    String[] temp = PinyinHelper.toHanyuPinyinStringArray(ti, forMat);
+                    result += temp[0];
+                } else {
+                    result += ti;
+                }
+            }
+        } catch (BadHanyuPinyinOutputFormatCombination e) {
+            e.printStackTrace();
+        }
+        //判断如果包含重庆,则替换拼音中的zhongqing为chongqing
+        if (chinaStr.indexOf("重庆") == -1) {
+            //do nothing
+        } else {
+            result = result.replace("zhongqing", "chongqing");
+        }
+        return result;
+    }
+
+    public static Sex getSexByStr(String str) {
+        if (StringUtils.isNotEmpty(str)) {
+            str = str.trim();
+            for (Sex sex : Sex.values()) {
+                if (sex.getRemark().equals(str)) {
+                    return sex;
+                }
+            }
+        }
+        return null;
+    }
+
+    public static <E extends Enum<E>> E getEnumByName(Class<E> t, String name) {
+        try {
+            if (StringUtils.isNotEmpty(name) && t != null) {
+                name = name.trim();
+                return Enum.valueOf(t, name);
+            }
+        } catch (Exception e) {
+        }
+        return null;
+    }
+
+    /**
+     * 月份搜索的时候转换
+     *
+     * @param month
+     * @return
+     */
+    public static String turnMonthSearch(String month) {
+        if (StringUtils.isNotEmpty(month)) {
+            if (month.length() == 2) {
+                return month;
+            } else {
+                return String.format("0%s", month);
+            }
+        }
+        return month;
+    }
+
+}

+ 725 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/utils/DateUtils.java

@@ -0,0 +1,725 @@
+package com.zhongshu.payment.server.core.utils;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.temporal.WeekFields;
+import java.util.*;
+
+@Slf4j
+public class DateUtils {
+
+    public final static String FORMAT_LONG = "yyyy-MM-dd HH:mm:ss";
+
+    public static Long timeToLong(String time) {
+        return timeToLong(time, FORMAT_LONG);
+    }
+
+
+    public static Long timeToLong(String time, String format) {
+        if (!org.springframework.util.StringUtils.hasText(time)) {
+            return null;
+        }
+        try {
+            return new SimpleDateFormat(format).parse(time).getTime();
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    @SneakyThrows
+    public static Double timeToDouble(String time, String format) {
+        assert format != null;
+
+        Long timestamp = null;
+        if (StringUtils.isNotBlank(time)) {
+            timestamp = new SimpleDateFormat(format).parse(time).getTime();
+        }
+        if (timestamp != null) {
+            return timestamp.doubleValue();
+        }
+        return null;
+    }
+
+    public final static String pattern = "yyyy-MM-dd";
+
+    /**
+     * yyyyMMdd
+     */
+    public final static String pattern1 = "yyyyMMdd";
+
+    public final static String patternStr = "yyyy年MM月dd日";
+
+    public final static String patternyyyyMM = "yyyy-MM";
+
+    public final static String patternyyyyM = "yyyy-M";
+
+    public final static String patternHHmm = "HH:mm";
+
+    public final static String patternyyyyMis = "yyyy-MM-dd HH:mm";
+
+    public final static String patternyyyySSS = "yyyy-MM-dd HH:mm:ss SSS";
+
+    public final static String patternyyyy = "yyyy";
+
+    public final static String patternMM = "MM";
+
+    public static String paresTime(Long time, String pattern) {
+        if (time == null || time <= 0) {
+            return "";
+        }
+        Date date = new Date(time);
+        SimpleDateFormat formatter = new SimpleDateFormat(pattern);
+        return formatter.format(date);
+    }
+
+    /**
+     * 获得本周的第一天,周一
+     *
+     * @return
+     */
+    public static Long getCurrentWeekDayStartTime() {
+        Calendar c = Calendar.getInstance();
+
+        int weekday = c.get(Calendar.DAY_OF_WEEK) - 2;
+        c.add(Calendar.DATE, -weekday);
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 获得上周的第一天,周一
+     *
+     * @return
+     */
+    public static Long getBeforeWeekDayStartTime() {
+        Calendar c = Calendar.getInstance();
+
+        int weekday = c.get(Calendar.DAY_OF_WEEK) - 2 + 7;
+        c.add(Calendar.DATE, -weekday);
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+        return c.getTimeInMillis();
+    }
+
+
+    /**
+     * 获得上周的最后一天,周日
+     *
+     * @return
+     */
+    public static Long getBeforeWeekDayEndTime() {
+        Calendar c = Calendar.getInstance();
+
+        int weekday = c.get(Calendar.DAY_OF_WEEK);
+        c.add(Calendar.DATE, 8 - weekday - 7);
+
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+
+        return c.getTimeInMillis();
+    }
+
+
+    /**
+     * 获得本周的最后一天,周日
+     *
+     * @return
+     */
+    public static Long getCurrentWeekDayEndTime() {
+        Calendar c = Calendar.getInstance();
+
+        int weekday = c.get(Calendar.DAY_OF_WEEK);
+        c.add(Calendar.DATE, 8 - weekday);
+
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 获得本天的开始时间
+     *
+     * @return
+     */
+    public static Date getCurrentDayStartTime() {
+        ZoneId zoneId = ZoneId.systemDefault();
+        LocalDateTime date = LocalDateTime.now();
+        LocalDateTime startOfTheDay = LocalDateTime.of(date.toLocalDate(), LocalTime.MIN);
+        Date beginTime = Date.from(startOfTheDay.atZone(zoneId).toInstant());
+        return beginTime;
+    }
+
+    /**
+     * 获得本天的结束时间
+     *
+     * @return
+     */
+    public static Date getCurrentDayEndTime() {
+        ZoneId zoneId = ZoneId.systemDefault();
+        LocalDateTime date = LocalDateTime.now();
+        LocalDateTime startOfTheDay = LocalDateTime.of(date.toLocalDate(), LocalTime.MAX);
+        Date beginTime = Date.from(startOfTheDay.atZone(zoneId).toInstant());
+        return beginTime;
+    }
+
+    /**
+     * 获得本小时的开始时间
+     *
+     * @return
+     */
+    public static Long getCurrentHourStartTime() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        return calendar.getTimeInMillis();
+    }
+
+    /**
+     * 获得本小时的结束时间
+     *
+     * @return
+     */
+    public static Long getCurrentHourEndTime() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        return calendar.getTimeInMillis();
+    }
+
+
+    /**
+     * 获得本月的开始时间
+     *
+     * @return
+     */
+    public static Long getCurrentMonthStartTime() {
+        Calendar c = Calendar.getInstance();
+
+        c.set(Calendar.DATE, 1);
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 获得上个月的开始时间
+     *
+     * @return
+     */
+    public static Long getBeforeMonthStartTime() {
+        Calendar c = Calendar.getInstance();
+
+        c.add(Calendar.MONTH, -1);
+        c.set(Calendar.DATE, 1);
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+
+        return c.getTimeInMillis();
+    }
+
+
+    /**
+     * 本月的结束时间
+     *
+     * @return
+     */
+    public static Long getCurrentMonthEndTime() {
+        Calendar c = Calendar.getInstance();
+
+        c.set(Calendar.DATE, 1);
+        c.add(Calendar.MONTH, 1);
+        c.add(Calendar.DATE, -1);
+
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+
+        return c.getTimeInMillis();
+    }
+
+    public static Long getBeforeMonthEndTime() {
+        Calendar c = Calendar.getInstance();
+
+        c.set(Calendar.DATE, 1);
+        c.add(Calendar.DATE, -1);
+
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 当前年的开始时间
+     *
+     * @return
+     */
+    public static Long getCurrentYearStartTime() {
+        Calendar c = Calendar.getInstance();
+
+        c.set(Calendar.MONTH, 0);
+        c.set(Calendar.DATE, 1);
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 当前年的结束时间
+     *
+     * @return
+     */
+    public static Long getCurrentYearEndTime() {
+        Calendar c = Calendar.getInstance();
+        Date now = null;
+
+        c.set(Calendar.MONTH, 11);
+        c.set(Calendar.DATE, 31);
+
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 当前季度的开始时间
+     *
+     * @return
+     */
+    public static Long getCurrentQuarterStartTime() {
+        Calendar c = Calendar.getInstance();
+        int currentMonth = c.get(Calendar.MONTH) + 1;
+
+        if (currentMonth >= 1 && currentMonth <= 3)
+            c.set(Calendar.MONTH, 0);
+        else if (currentMonth >= 4 && currentMonth <= 6)
+            c.set(Calendar.MONTH, 3);
+        else if (currentMonth >= 7 && currentMonth <= 9)
+            c.set(Calendar.MONTH, 4);
+        else if (currentMonth >= 10 && currentMonth <= 12)
+            c.set(Calendar.MONTH, 9);
+        c.set(Calendar.DATE, 1);
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 当前季度的结束时间
+     *
+     * @return
+     */
+    public static Long getCurrentQuarterEndTime() {
+        Calendar c = Calendar.getInstance();
+        int currentMonth = c.get(Calendar.MONTH) + 1;
+        Date now = null;
+        try {
+            if (currentMonth >= 1 && currentMonth <= 3) {
+                c.set(Calendar.MONTH, 2);
+                c.set(Calendar.DATE, 31);
+            } else if (currentMonth >= 4 && currentMonth <= 6) {
+                c.set(Calendar.MONTH, 5);
+                c.set(Calendar.DATE, 30);
+            } else if (currentMonth >= 7 && currentMonth <= 9) {
+                c.set(Calendar.MONTH, 8);
+                c.set(Calendar.DATE, 30);
+            } else if (currentMonth >= 10 && currentMonth <= 12) {
+                c.set(Calendar.MONTH, 11);
+                c.set(Calendar.DATE, 31);
+            }
+
+            c.set(Calendar.HOUR_OF_DAY, 23);
+            c.set(Calendar.MINUTE, 59);
+            c.set(Calendar.SECOND, 59);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return now.getTime();
+    }
+
+    /**
+     * 获取前/后半年的开始时间
+     *
+     * @return
+     */
+    public static Long getHalfYearStartTime() {
+        Calendar c = Calendar.getInstance();
+        int currentMonth = c.get(Calendar.MONTH) + 1;
+
+        if (currentMonth >= 1 && currentMonth <= 6) {
+            c.set(Calendar.MONTH, 0);
+        } else if (currentMonth >= 7 && currentMonth <= 12) {
+            c.set(Calendar.MONTH, 6);
+        }
+        c.set(Calendar.DATE, 1);
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 获取前/后半年的结束时间
+     *
+     * @return
+     */
+    public static Long getHalfYearEndTime() {
+        Calendar c = Calendar.getInstance();
+        int currentMonth = c.get(Calendar.MONTH) + 1;
+
+        if (currentMonth >= 1 && currentMonth <= 6) {
+            c.set(Calendar.MONTH, 5);
+            c.set(Calendar.DATE, 30);
+        } else if (currentMonth >= 7 && currentMonth <= 12) {
+            c.set(Calendar.MONTH, 11);
+            c.set(Calendar.DATE, 31);
+        }
+
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+
+        return c.getTimeInMillis();
+    }
+
+    public static Date parseStr2Date(String dateStr) {
+        SimpleDateFormat longSdf = new SimpleDateFormat(FORMAT_LONG);
+        try {
+            return longSdf.parse(dateStr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static String getShort2Str(Date date) {
+        if (date == null) {
+            return null;
+        }
+        SimpleDateFormat shortSdf = new SimpleDateFormat(pattern);
+        return shortSdf.format(date);
+    }
+
+
+    /**
+     * 毫秒数转时间
+     *
+     * @return
+     */
+    public static String millsToDuration(long mills) {
+        long dayBal = mills % (86400000);
+        int days = Long.valueOf(mills / 86400000).intValue();
+
+        long hourBal = dayBal % (3600000);
+        int hours = Long.valueOf(dayBal / (3600000)).intValue();
+
+        long minuteBal = hourBal % (60000);
+        int minutes = Long.valueOf(hourBal / (60000)).intValue();
+
+        int seconds = Long.valueOf(Long.valueOf(minuteBal / 1000).intValue()).intValue();
+        String str = "";
+        if (days > 0) {
+            str += days + "天";
+        }
+        if (hours > 0) {
+            str += hours + "小时";
+        }
+        if (minutes > 0) {
+            str += minutes + "分钟";
+        }
+        if (seconds > 0) {
+            str += seconds + "秒";
+        }
+        return str;
+    }
+
+
+    public static Long getDayStartTime(Long timestamp) {
+        ZoneId zoneId = ZoneId.systemDefault();
+        LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), zoneId);
+        LocalDateTime startOfTheDay = LocalDateTime.of(date.toLocalDate(), LocalTime.MIN);
+        return Timestamp.valueOf(startOfTheDay).getTime();
+    }
+
+    /**
+     * 获得本天的结束时间
+     *
+     * @return
+     */
+    public static Long getDayEndTime(Long timestamp) {
+        ZoneId zoneId = ZoneId.systemDefault();
+        LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), zoneId);
+        LocalDateTime endOfTheDay = LocalDateTime.of(date.toLocalDate(), LocalTime.MAX);
+        return Timestamp.valueOf(endOfTheDay).getTime();
+    }
+
+
+    /**
+     * 获得时间在当年的周数
+     *
+     * @return
+     */
+    public static Integer getWeekOfYear(Long timestamp) {
+        ZoneId zoneId = ZoneId.systemDefault();
+        LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), zoneId);
+        // WeekFields.ISO = 一星期从周一开始算, 其它的请自己摸索.
+        WeekFields weekFields = WeekFields.ISO;
+        int weekNumber = date.get(weekFields.weekOfWeekBasedYear());
+        return weekNumber;
+    }
+
+    public static Integer getYearWeekCount(Integer year) {
+        Calendar c = Calendar.getInstance();
+        c.set(Calendar.YEAR, year);
+        c.set(Calendar.MONTH, Calendar.DECEMBER);
+        c.set(Calendar.DATE, 31);
+        Integer weekCount = getWeekOfYear(c.getTimeInMillis());
+        //log.info("多少周:{}",weekCount);
+        return weekCount;
+    }
+
+    public static Long getWeekStartTime(Integer year, Integer week) {
+        Calendar c = new GregorianCalendar();
+        //获得指定年的第几周的开始日期(dayOfWeek是从周日开始排序的)
+        c.setWeekDate(year, week, 2);
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+        //获得Calendar的时间
+        Date starttime = c.getTime();
+        //log.info("{}年第{}周的开始日期为{}" ,year,week,paresTime(starttime.getTime(),FORMAT_LONG));
+        return starttime.getTime();
+    }
+
+    public static Long getWeekEndTime(Integer year, Integer week) {
+        Calendar c = new GregorianCalendar();
+        //获得指定年的第几周的结束日期
+        c.setWeekDate(year, week + 1, 1);
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+
+        Date endtime = c.getTime();
+        //将时间戳格式化为指定格式
+        //log.info("{}年第{}周的结束日期为{}" ,year,week,paresTime(endtime.getTime(),FORMAT_LONG));
+        return endtime.getTime();
+    }
+
+    /**
+     * 本月的结束时间
+     *
+     * @return
+     */
+    public static Long getMonthStartTime(Integer year, Integer month) {
+        Calendar c = Calendar.getInstance();
+
+        c.set(Calendar.YEAR, year);
+        c.set(Calendar.MONTH, month - 1);
+        c.set(Calendar.DATE, 1);
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+
+        return c.getTimeInMillis();
+
+    }
+
+
+    /**
+     * 本月的结束时间
+     *
+     * @return
+     */
+    public static Long getMonthEndTime(Integer year, Integer month) {
+        Calendar c = Calendar.getInstance();
+
+        c.set(Calendar.YEAR, year);
+        c.set(Calendar.MONTH, month - 1);
+        c.add(Calendar.MONTH, 1);
+        c.set(Calendar.DAY_OF_MONTH, 0);
+
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+        return c.getTimeInMillis();
+    }
+
+
+    /**
+     * 本年的开始时间
+     *
+     * @return
+     */
+    public static Long getYearStartTime(Integer year) {
+        Calendar c = Calendar.getInstance();
+
+        c.set(Calendar.YEAR, year);
+        c.set(Calendar.MONTH, Calendar.JANUARY);
+        c.set(Calendar.DATE, 1);
+
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+
+        return c.getTimeInMillis();
+    }
+
+
+    /**
+     * 本年的开始时间
+     *
+     * @return
+     */
+    public static Long getYearEndTime(Integer year) {
+        Calendar c = Calendar.getInstance();
+
+        c.set(Calendar.YEAR, year);
+        c.set(Calendar.MONTH, Calendar.DECEMBER);
+        c.set(Calendar.DATE, 31);
+
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 得到给定时间的 当天开始时间
+     *
+     * @param time
+     * @return
+     */
+    public static Long getDayStart(Long time) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(time);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        return calendar.getTimeInMillis();
+    }
+
+    /**
+     * 得到给定时间的 当天最大时间
+     *
+     * @param time
+     * @return
+     */
+    public static Long getDayEnd(Long time) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(time);
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        return calendar.getTimeInMillis();
+    }
+
+    /**
+     * 转换日期为:2023-10-10 00:00:00  再加上天数
+     *
+     * @param time
+     * @param days
+     * @return
+     */
+    public static Calendar getCalendarDayAndDays(Long time, int days) {
+        Calendar calendar = Calendar.getInstance();
+        Date endDate = new Date(time);
+        calendar.setTime(endDate);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        calendar.add(Calendar.DATE, days);
+        return calendar;
+    }
+
+    /**
+     * 日期加减天数,,中间跳过节假日 (不包括自己)
+     *
+     * @param time
+     * @param days
+     * @param holiday
+     * @return
+     */
+    public static Calendar getCalendarDayAndDays(Long time, int days, List<String> holiday) {
+        if (holiday == null) {
+            holiday = new ArrayList<>();
+        }
+        Calendar calendar = Calendar.getInstance();
+        Date endDate = new Date(time);
+        calendar.setTime(endDate);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        if (days != 0) {
+            boolean isAdd = true;
+            if (days < 0) {
+                isAdd = false;
+            }
+            int count = Math.abs(days);
+            int sumCount = 0;
+            while (true) {
+                if (isAdd) {
+                    calendar.add(Calendar.DATE, 1);
+                } else {
+                    calendar.add(Calendar.DATE, -1);
+                }
+                String str = DateUtils.paresTime(calendar.getTimeInMillis(), DateUtils.pattern);
+                if (!holiday.contains(str)) {
+                    sumCount++;
+                } else {
+                    log.info("休息日:{}", str);
+                }
+                if (count == sumCount) {
+                    break;
+                }
+            }
+        }
+        return calendar;
+    }
+
+    public static void main(String[] args) {
+        log.info("本年开始时间:{},结束时间:{}", paresTime(getYearStartTime(2023), FORMAT_LONG), paresTime(getYearEndTime(2023), FORMAT_LONG));
+        log.info("本月开始时间:{},结束时间:{}", paresTime(getMonthStartTime(2023, 9), FORMAT_LONG), paresTime(getMonthEndTime(2023, 9), FORMAT_LONG));
+
+        Integer weekNumber = getWeekOfYear(System.currentTimeMillis());
+        log.info("本年一共{}周,本周是第{}周,本周时间区间:{}-{}", getYearWeekCount(2023), weekNumber, paresTime(getWeekStartTime(2023, weekNumber), FORMAT_LONG), paresTime(getWeekEndTime(2023, weekNumber), FORMAT_LONG));
+    }
+}

+ 19 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/utils/exception/BusinessException.java

@@ -0,0 +1,19 @@
+package com.zhongshu.payment.server.core.utils.exception;
+
+/**
+ * 统一业务异常
+ */
+public class BusinessException extends RuntimeException{
+
+    public BusinessException(){}
+
+    public BusinessException(String message)
+    {
+        super(message);
+    }
+
+    public BusinessException(String message, Throwable throwable)
+    {
+        super(message,throwable);
+    }
+}

+ 19 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/utils/exception/ServiceException.java

@@ -0,0 +1,19 @@
+package com.zhongshu.payment.server.core.utils.exception;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@Setter
+@Getter
+@AllArgsConstructor
+@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) //, reason = ""
+public class ServiceException extends RuntimeException{
+
+	private static final long serialVersionUID = 552192089988571466L;
+
+	private String message;
+
+}

+ 21 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/utils/exception/UnauthorizedException.java

@@ -0,0 +1,21 @@
+package com.zhongshu.payment.server.core.utils.exception;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@Setter
+@Getter
+@AllArgsConstructor
+@ResponseStatus(value = HttpStatus.UNAUTHORIZED) //, reason = ""
+public class UnauthorizedException extends RuntimeException{
+
+	private static final long serialVersionUID = 7227904251082562156L;
+
+	private String message;
+
+	public UnauthorizedException(){}
+
+}