package com.thinkgem.jeesite.modules.pay.huanqiuhuiju.service;

import com.alibaba.fastjson.JSONObject;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.constant.ComCode;
import com.thinkgem.jeesite.common.utils.IdGen;
import com.thinkgem.jeesite.modules.pay.huanqiuhuiju.utils.HttpUtil;
import com.thinkgem.jeesite.modules.pay.huanqiuhuiju.utils.SignUtils;
import com.thinkgem.jeesite.modules.pay.juhezhong.utils.Bean2Map;
import com.thinkgem.jeesite.modules.pay.juhezhong.utils.MakeOrderNum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.SortedMap;

@Transactional
@Service
public class HuanqiuhuijuService {

    public JSONObject huanqiuhuijuPay(JSONObject dto) throws Exception {
        SortedMap map = Bean2Map.JSONObject2SortedMap(dto);
        String sign = SignUtils.createSign(map, ComCode.HUANQIUHUIJU_MERCHANT_KEY);
        map.put("sign",sign);

        String result = HttpUtil.postRequest(ComCode.HUANQIUHUIJU_PAYURL,JSONObject.toJSONString(map));
        System.out.println("result:"+result);
        return JSONObject.parseObject(result);

    }

}
