| | |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.gkhy.exam.pay.entity.PayReqData; |
| | | import com.xjhys.edu.fee.sdk.client.BillClient; |
| | | import com.xjhys.edu.fee.sdk.client.impl.ClientFactory; |
| | | import com.xjhys.edu.fee.sdk.model.ResponseDataVo; |
| | | import com.xjhys.edu.fee.sdk.model.SignatureFileVo; |
| | | import com.xjhys.edu.fee.sdk.model.UploadXmlReponseDataVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.apache.http.HttpEntity; |
| | |
| | | String jmsignfile = this.signFilejdnew(trr2); |
| | | String zuizhongpath = montageXmlV3(xmlFilePath, jmsignfile); |
| | | String zzsignfile = convertFileToBase64(zuizhongpath); |
| | | this.uploadXmlV2(orderNo1, zzsignfile); |
| | | Boolean b = this.uploadXmlV2(orderNo1, zzsignfile); |
| | | |
| | | File file = new File(xmlFilePath); |
| | | file.delete(); |
| | | File file1 = new File(zuizhongpath); |
| | | file1.delete(); |
| | | if (b) { |
| | | return resultVo; |
| | | } else { |
| | | resultVo.setRespcode("BUS8888"); |
| | | } |
| | | return resultVo; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public ResultVo uploadXmlV2(String orderId, String plain) { |
| | | Map<String, String> params = new HashMap<>(); |
| | | |
| | | |
| | | String appid = "A1749891493E4CDDBFE4506357B1F0AB"; |
| | | String uploadUrl = "http://finpt.xjcz.gov.cn/fs-service/fs-pay/uploadXml.do"; |
| | | |
| | | public Boolean uploadXmlV2(String orderNo, String signFile) { |
| | | log.info("上传验签开始"); |
| | | log.info("上传验签参数订单号:" + orderNo + "签名文件:" + signFile); |
| | | ResponseDataVo<?> res = ClientFactory.sdkConfig("A1749891493E4CDDBFE4506357B1F0AB", "http://finpt.xjcz.gov.cn/fs-service", "http://finpt.xjcz.gov.cn/fs-service"); |
| | | SignatureFileVo signatureFile = new SignatureFileVo(); |
| | | signatureFile.setFileData(plain); |
| | | signatureFile.setOrderNo(orderId); |
| | | String reqdatastr = JSONObject.toJSONString(signatureFile); |
| | | signatureFile.setFileData(signFile); |
| | | signatureFile.setOrderNo(orderNo); |
| | | BillClient billClient = ClientFactory.getBillClient(); |
| | | ResponseDataVo<UploadXmlReponseDataVo> dataRes = billClient.uploadXml(signatureFile); |
| | | |
| | | String mac = this.getMD5("A1749891493E4CDDBFE4506357B1F0AB||" + this.getBase64(reqdatastr)); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("appid", "A1749891493E4CDDBFE4506357B1F0AB"); |
| | | jsonObject.put("mac", mac); |
| | | jsonObject.put("reqdata", this.getBase64(reqdatastr)); |
| | | Map<String, String> header = new HashMap(); |
| | | header.put("Accept", "application/json;charset=utf-8"); |
| | | header.put("Content-Type", "application/json;charset=utf-8"); |
| | | String resultStr = HttpUtil.post(uploadUrl, jsonObject); |
| | | JSONObject result = JSONObject.parseObject(resultStr); |
| | | |
| | | // String reqdata = getBase64(signatureFile.toString()); |
| | | // String mac = appid + "||" + reqdata; |
| | | // mac = DigestUtils.md5Hex(mac.getBytes()); |
| | | // |
| | | // params.put("appid", appid); |
| | | // params.put("reqdata", reqdata); |
| | | // params.put("mac", mac); |
| | | // |
| | | // HttpPost httpPost = new HttpPost(orderUrl); |
| | | // httpPost.setEntity(assemblyFormEntity(params, "utf-8")); |
| | | // HttpClient httpClient = getHttpClient(orderUrl); |
| | | // HttpResultVo execute = null; |
| | | // try { |
| | | // execute = httpClient.execute(httpPost, getResponseHandler()); |
| | | // } catch (IOException e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | // String stringContent = execute.getStringContent(); |
| | | ResultVo resultVo = JSONObject.parseObject(resultStr, ResultVo.class); |
| | | log.info("请求结果转为:" + resultVo); |
| | | return resultVo; |
| | | if (!dataRes.getRespcode().equals("BUS0000")) { |
| | | log.info("上传验签失败:" + dataRes); |
| | | return false; |
| | | } |
| | | // String mac = this.getMD5("A1749891493E4CDDBFE4506357B1F0AB||" + this.getBase64(signatureFile.toString())); |
| | | // JSONObject jsonObject = new JSONObject(); |
| | | // jsonObject.put("appid", "A1749891493E4CDDBFE4506357B1F0AB"); |
| | | // jsonObject.put("mac", mac); |
| | | // jsonObject.put("reqdata", this.getBase64(signatureFile.toString())); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | public String getMD5(String input) { |
| | | try { |