package com.ruoyi.web.v2.v1.utils;


import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.ruoyi.web.v2.v1.entity.PayRecord;

import java.util.Date;

public class AccountUtil {
   private static final String LETTER ="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
    public static String getAccount(){

        return RandomUtil.randomString(LETTER,2)+RandomUtil.randomNumbers(6);
    }
    public static String sumPerDoubleString(String str1 , String str2){
        return String.format("%.2f", Double.parseDouble(str1)+ Double.parseDouble(str2));
    }
    public static String jianPerDoubleString(PayRecord payRecord , PayRecord byId){

            return String.format("%.2f", Double.parseDouble(payRecord.getPayAmount())- Double.parseDouble(byId.getPayAmount()));


    }
    public static String getPeyNum(PayRecord one, String userId){

//        return String.format("%.2f",Double.parseDouble(str1)+Double.parseDouble(str2));
        if (ObjectUtil.isEmpty(one)) {
            return DateUtil.format(new Date(), "yyyyMMdd") +  userId + String.format("%02d",1);
        }
        return DateUtil.format(new Date(), "yyyyMMdd") +  one.getUserId() + String.format("%02d",
                Integer.parseInt(one.getPeyNum().substring(one.getPeyNum().length() - 2))+1);
    }
    public static String getDeductionNum(String userId){

//        return String.format("%.2f",Double.parseDouble(str1)+Double.parseDouble(str2));

            return DateUtil.format(new Date(), "yyyyMMdd") +  userId + String.format("%02d",1);

    }

    public static void main(String[] args) {

        String str = "2025122501";
        System.out.println(str.substring(str.length() - 2));
        System.out.println(DateUtil.format(new Date(), "yyyyMMdd")+ String.format("%02d", Integer.parseInt(str.substring(str.length()-2) )+1));

    }


}
