package com.brilliance.isc.common.utils;

import com.alibaba.fastjson2.JSON;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import com.brilliance.isc.common.umdmod.service.impl.UmdmodServiceImpl;
import com.brilliance.isc.common.umdmod.vo.UmdmodVo;
import com.brilliance.isc.utils.DateUtils;
import org.apache.commons.codec.digest.DigestUtils;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author hushichao
 * @date 2023/8/28
 * @description TODO
 */

public class UmdmodUtil {
    private static Logger logger = LoggerFactory.getLogger(UmdmodUtil.class);

    public static String calculateMac(UmdmodVo umdmodVo) {
        Map<String, Object> macMap = new LinkedHashMap<>();
//        macMap.put("CASE_NO", umdmodVo.getCASE_NO());
        //隔日重新筛查
        macMap.put("today", DateUtils.dateTimeNow("yyyyMMdd"));
        macMap.put("LOAN_FLAG", umdmodVo.getLOAN_FLAG());
        macMap.put("TRANS_CUR", umdmodVo.getTRANS_CUR());
        macMap.put("QUERY_TYPE", umdmodVo.getQUERY_TYPE());
        macMap.put("TRANS_AMT", umdmodVo.getTRANS_AMT());
        macMap.put("CUSTS", umdmodVo.getCUSTS());
        macMap.put("TRANS", umdmodVo.getTRANS());
        macMap.put("TAGS", umdmodVo.getTAGS());
        macMap.put("BENNAM", umdmodVo.getBennam());
        String data = JSON.toJSONString(macMap);
        umdmodVo.setMaccontent(data);
        logger.info("#########the macdata is {}", data);
        String mac = DigestUtils.sha1Hex(DigestUtils.md5(data)).substring(0, 8);
        return mac;
    }
}
