package com.hfkj.phone;

import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.pay.util.sdk.WXPayConstants;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.config.CommonSysConst;
import com.hfkj.config.GenerateSign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
  * @ClassName PhoneBillService
  * @Author Sum1Dream
  * @Description 话费
  * @Date 2024/6/19 上午11:29
 **/
public class PhoneBillService {


    private static Logger log = LoggerFactory.getLogger(PhoneBillService.class);

    /**
     * 请求
     * @param postUrl  接口请求地址
     * @param param       参数
     * @return
     * @throws Exception
     */
    public static JSONObject requestCt(String postUrl, Map<String,Object> param) throws Exception {

        log.info("============ 话费请求-START =============");
        param.put("mchid" , CommonSysConst.getSysConfig().getCtMemberId());
        param.put("sign", GenerateSign.generateSignatureCt(param , CommonSysConst.getSysConfig().getCtApiKey() , WXPayConstants.SignType.MD5));
        log.info("请求接口：" + postUrl);
        log.info("请求参数：" + JSONObject.toJSONString(param));

        JSONObject response = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getCtPostUrl() + postUrl, GenerateSign.paramSort(param) , new HashMap<>());

        log.info("响应参数：" + response.toJSONString());
        log.info("============ 话费请求-END ==============");
        return response;

    }





}
