package com.gxwebsoft;

import cn.hutool.core.util.NumberUtil;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;

/**
 * Created by WebSoft on 2020-03-23 23:37
 */
@SpringBootTest
public class TestMain {
  /**
   * 生成唯一的key用于jwt工具类
   */
  @Test
  public void testGenJwtKey() {

    BigDecimal bigDecimal = new BigDecimal(NumberUtil.decimalFormat("0.00", 1 * 0.01));
    System.out.println("实际付款金额 = " + bigDecimal);
//    System.out.println(JwtUtil.encodeKey(JwtUtil.randomKey()));

//    final String encrypt = CommonUtil.encrypt("123456");
//    System.out.println("encrypt = " + encrypt);
//
//    final String decrypt = CommonUtil.decrypt(encrypt);
//    System.out.println("decrypt = " + decrypt);
  }


  private String fenToYuan(String amount){
    NumberFormat format = NumberFormat.getInstance();
    try{
      Number number = format.parse(amount);
      double temp = number.doubleValue() / 100.0;
      format.setGroupingUsed(false);
      // 设置返回的小数部分所允许的最大位数
      format.setMaximumFractionDigits(2);
      amount = format.format(temp);
    } catch (ParseException e){
      e.printStackTrace();
    }
    return amount;
  }
}
