|
@@ -33,6 +33,44 @@ public class PayBillToolUtil {
|
|
|
public static final String ENTITY_NAME = "cas_paybill";
|
|
|
protected static final Log log = LogFactory.getLog(PayBillToolUtil.class);
|
|
|
|
|
|
+ public static String queryPaymentRequest(DynamicObject payBillEntity) {
|
|
|
+ try {
|
|
|
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
|
|
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
|
|
+ Document doc = dBuilder.newDocument();
|
|
|
+
|
|
|
+ Element rootElement = doc.createElement("Message");
|
|
|
+ doc.appendChild(rootElement);
|
|
|
+
|
|
|
+ Element body = doc.createElement("Body");
|
|
|
+ rootElement.appendChild(body);
|
|
|
+
|
|
|
+
|
|
|
+ createElement(doc, body, "transcode", "BTSQO001");
|
|
|
+ createElement(doc, body, "ochannelcode", "JF");//发起渠道
|
|
|
+ createElement(doc, body, "ochanneldate", payBillEntity.getString("nckd_fqqdrq"));//发起渠道日期
|
|
|
+
|
|
|
+ String channelserno = payBillEntity.get("billno")+"-"+payBillEntity.getInt("nckd_bbh");
|
|
|
+ createElement(doc, body, "ochannelserno", channelserno);//发起渠道流水
|
|
|
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
|
|
+ Transformer transformer = transformerFactory.newTransformer();
|
|
|
+
|
|
|
+ // 指定编码格式为GBK
|
|
|
+ transformer.setOutputProperty(OutputKeys.ENCODING, "GBK");
|
|
|
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
|
|
+
|
|
|
+
|
|
|
+ DOMSource source = new DOMSource(doc);
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ StreamResult result = new StreamResult(writer);
|
|
|
+ transformer.transform(source, result);
|
|
|
+
|
|
|
+ return writer.toString();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
public static String createSinglePaymentRequest(DynamicObject payBillEntity) {
|
|
|
try {
|
|
|
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
|
@@ -47,8 +85,8 @@ public class PayBillToolUtil {
|
|
|
|
|
|
|
|
|
createElement(doc, body, "transcode", "BTSCO001");
|
|
|
- createElement(doc, body, "trxcode", "jfgx");//渠道交易代码
|
|
|
- createElement(doc, body, "channelcode", "经费共享");//发起渠道
|
|
|
+ createElement(doc, body, "trxcode", "JF01");//渠道交易代码
|
|
|
+ createElement(doc, body, "channelcode", "JF");//发起渠道
|
|
|
Calendar currentdate = Calendar.getInstance();
|
|
|
createElement(doc, body, "channeldate", TypeUtils.date2String(currentdate.getTime(),"yyyyMMdd"));//发起渠道日期
|
|
|
|
|
@@ -188,7 +226,7 @@ public class PayBillToolUtil {
|
|
|
errMsg.append("错误号:").append("XXXXXXX");
|
|
|
errMsg.append(",错误原因:").append("接口无法连通,未获取到返回结果");
|
|
|
errMsg.append("\r\n");
|
|
|
- }else if(cbsReturnJson.getJSONObject("Message")==null){
|
|
|
+ }else if(cbsReturnJson.get("Message")==null){
|
|
|
isSuccess = false;
|
|
|
errMsg.append("单据号:").append(billNum).append(",推送支付前置失败,");
|
|
|
errMsg.append("错误号:").append("DDDDDD1");
|
|
@@ -266,6 +304,34 @@ public class PayBillToolUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void saveupdatelog(DynamicObject payBillEntity,String qqbw,String fhbw){
|
|
|
+ try {
|
|
|
+ DynamicObject logInfo = new DynamicObject( EntityMetadataCache.getDataEntityType("nckd_zfcxjkrz"));
|
|
|
+ String channelserno = payBillEntity.get("billno")+"-"+payBillEntity.getInt("nckd_bbh");
|
|
|
+ logInfo.set("number",channelserno);
|
|
|
+ logInfo.set("name",payBillEntity.get("billno")+"查询状态日志");
|
|
|
+ logInfo.set("status","A");
|
|
|
+ logInfo.set("enable","1");
|
|
|
+ Calendar currentdate = Calendar.getInstance();
|
|
|
+ logInfo.set("nckd_redate",currentdate.getTime());
|
|
|
+ logInfo.set("nckd_billno",payBillEntity.get("billno"));
|
|
|
+ logInfo.set("nckd_payid",payBillEntity.getPkValue()+"");
|
|
|
+ logInfo.set("nckd_qqbw_tag",qqbw);
|
|
|
+ logInfo.set("nckd_fhbw_tag",fhbw);
|
|
|
+ logInfo.set("nckd_redate",new Date());
|
|
|
+
|
|
|
+ logInfo.set("nckd_djlx","1");
|
|
|
+ OperationServiceHelper.executeOperate("save","nckd_zfcxjkrz",new DynamicObject[]{logInfo});
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("保存日志报错"+e.getMessage());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public static JSONObject socketService(String serverName,String port,String xmlData){
|
|
@@ -302,4 +368,40 @@ public class PayBillToolUtil {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ public static JSONObject socketServiceQuery(String serverName,String port,String xmlData,String transcode){
|
|
|
+ try {
|
|
|
+ Socket client = new Socket(serverName,TypeUtils.nullToInt(port));
|
|
|
+ int messageLength = xmlData.getBytes("GBK").length;
|
|
|
+ String header = String.format("%08dXML"+transcode+"%%%%%%%%%%%%%%%%%%%%%%%%%%", messageLength);
|
|
|
+ String fullMessage = header + xmlData;
|
|
|
+ OutputStream outToServer = client.getOutputStream();
|
|
|
+
|
|
|
+ PrintWriter out = new PrintWriter(new OutputStreamWriter(outToServer, "GBK"), true);
|
|
|
+ out.println(fullMessage);
|
|
|
+
|
|
|
+ InputStream inFromServer = client.getInputStream();
|
|
|
+ BufferedReader in = new BufferedReader(new InputStreamReader(inFromServer, "GBK"));
|
|
|
+ StringBuilder responseBuilder = new StringBuilder();
|
|
|
+ String line;
|
|
|
+ while ((line = in.readLine()) != null) {
|
|
|
+ responseBuilder.append(line);
|
|
|
+ }
|
|
|
+ String responseJson = responseBuilder.toString();
|
|
|
+ if(responseJson.indexOf("<?xml")>0){
|
|
|
+ int index = responseJson.indexOf("<?xml");
|
|
|
+ responseJson = responseJson.substring(index);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject jsonObject = XML.toJSONObject(responseJson);
|
|
|
+ client.close();
|
|
|
+ return jsonObject;
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info(e.getMessage());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|