package com.cweb.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cweb.config.SysConst;
import com.hai.common.Base64Util;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.*;
import com.hai.config.*;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.*;
import com.hai.enum_type.MerchantStoreSourceType;
import com.hai.model.*;
import com.hai.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.bouncycastle.util.encoders.UrlBase64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.IdGenerator;
import org.springframework.web.bind.annotation.*;
import sun.nio.cs.StreamEncoder;

import javax.annotation.Resource;
import javax.net.ssl.SSLContext;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.security.KeyStore;
import java.util.*;

/**
 * @Auther: 胡锐
 * @Description:
 * @Date: 2021/3/26 23:08
 */
@Controller
@RequestMapping(value = "/test")
@Api(value = "订单接口")
public class HighTestController {

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

    @Resource
    private PayloService payloService;

    @Resource
    private HighGasService gasService;

    @RequestMapping(value = "/ycShellPageQueryAllStation", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "订单退款")
    public ResponseData ycShellPageQueryAllStation() {
        try {
            return ResponseMsgUtil.success(payloService.ycShellPageQueryAllStation(1, 50));

        } catch (Exception e) {
            log.error("HighOrderController --> getBackendToken() error!", e);
            return ResponseMsgUtil.exception(e);
        }
    }
    @RequestMapping(value = "/HuiLianTongConfigPayOrderByCouNo", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "")
    public ResponseData HuiLianTongConfigPayOrderByCouNo(@RequestParam(name = "couNo", required = true) String couNo) {
        try {

            JSONObject jsonObject = HuiLianTongConfig.getPayOrderByCouNo(couNo);
            if (jsonObject.getString("respCode").equals("0000")) {
                JSONObject data = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data"));
                return ResponseMsgUtil.success(data);

            } else {
                log.error("getRechargeProduct error!", "查询失败！");
                throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "查询失败");
            }
        } catch (Exception e) {
            log.error("HighOrderController --> getBackendToken() error!", e);
            return ResponseMsgUtil.exception(e);
        }
    }

    @RequestMapping(value = "/getPayloAllStation", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "paylo油站")
    public ResponseData getPayloAllStation(HttpServletRequest request) {
        try {

            gasService.getPayloAllStation();

            return ResponseMsgUtil.success("");

        } catch (Exception e) {
            log.error("HighOrderController --> unionStagingPay() error!", e);
            return ResponseMsgUtil.exception(e);
        }
    }

}
