/**
 * Copyright (C), 2022-06-28
 * FileName: CardUntils
 * Author:   wanglongda
 * Date:     2022/6/28 15:23
 * Description: 一卡通工具类
 */
package me.zhengjie.modules.quartz.utils;/**
 * Created Name: wanglongda
 * Created Time: 2022/6/28 15:23
 * Description: iot-ykt
 */

import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.utils.StringUtils;

import java.math.BigDecimal;

/**
 * <功能简要> <br>
 * <一卡通工具类>
 *
 * @Author wanglongda
 * @createTime 2022/6/28 15:23
 * @Version 1.0.0
 */

@Slf4j
public class CardUntils {

    //  获取一卡通余额接口
    private final static String GET_CARD_BALANCE_URL = "https://smartpark.caih.com/dxapi/dxtop/staff/cardBalance?card=";



    public static JSONObject getCardBalance(String card){

        try {
             String s = new BigDecimal(card).toString();
            String msg = HttpRequest.get(GET_CARD_BALANCE_URL+s).execute().body();
             JSONObject jsonObject = JSONObject.parseObject(msg);
                return jsonObject;
        }catch (Exception e){
            log.info("查询余额失败,错误原因：{}",e.getMessage());
            return null;
        }

    }

}
