From f52cfc92db48d9a215d7f728ce4000de1cdd6ae2 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Tue, 10 Sep 2024 09:55:31 +0800
Subject: [PATCH] 增加会员升级日志打印

---
 src/main/java/cc/mrbird/febs/pay/service/impl/NBYHServiceImpl.java |  105 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 66 insertions(+), 39 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/pay/service/impl/NBYHServiceImpl.java b/src/main/java/cc/mrbird/febs/pay/service/impl/NBYHServiceImpl.java
index d3509a0..674137a 100644
--- a/src/main/java/cc/mrbird/febs/pay/service/impl/NBYHServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/pay/service/impl/NBYHServiceImpl.java
@@ -1,20 +1,22 @@
 package cc.mrbird.febs.pay.service.impl;
 
+import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
+import cc.mrbird.febs.common.utils.RedisUtils;
+import cc.mrbird.febs.mall.entity.DataDictionaryCustom;
 import cc.mrbird.febs.mall.entity.MallMemberBank;
 import cc.mrbird.febs.mall.entity.MallMemberWithdraw;
 import cc.mrbird.febs.mall.entity.MallMemberWithdrawMsg;
-import cc.mrbird.febs.mall.mapper.MallMemberBankMapper;
-import cc.mrbird.febs.mall.mapper.MallMemberWithdrawMapper;
-import cc.mrbird.febs.mall.mapper.MallMemberWithdrawMsgMapper;
-import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper;
+import cc.mrbird.febs.mall.mapper.*;
 import cc.mrbird.febs.pay.model.NBYHResponse;
 import cc.mrbird.febs.pay.service.NBYHService;
 import cn.hutool.core.util.ObjectUtil;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.io.*;
 import java.math.BigDecimal;
 import java.net.*;
@@ -25,6 +27,7 @@
 
 @Slf4j
 @Service
+@RequiredArgsConstructor
 public class NBYHServiceImpl implements NBYHService {
     /**
      * 登录报文原文
@@ -37,7 +40,8 @@
     private static final String TRADE_MESSAGE_SEARCH = "<opReq><serialNo>${serialNo}</serialNo><reqTime>${reqTime}</reqTime><ReqParam><JYXH>${serialNoOld}</JYXH></ReqParam></opReq>";
     private static final String TRADE_MESSAGE_SINGLE = "<opReq><serialNo>${serialNo}</serialNo><reqTime>${reqTime}</reqTime><ReqParam><FKZH>${FKZH}</FKZH><SKZH>${SKZH}</SKZH><SKHM>${SKHM}</SKHM><JYJE>${JYJE}</JYJE><YOTU>${YOTU}</YOTU></ReqParam></opReq>";
 //    private static final String TRADE_MESSAGE_SINGLE = "<opReq><serialNo>${serialNo}</serialNo><reqTime>${reqTime}</reqTime><ReqParam><FKZH>82260120102022631</FKZH><SKZH>78040122000059277</SKZH><SKHM>792311957</SKHM><JYJE>0.01</JYJE><YOTU>银企接口测试</YOTU></ReqParam></opReq>";
-    private static final String TRADE_MESSAGE = "<opReq><serialNo>${serialNo}</serialNo><reqTime>${reqTime}</reqTime><ReqParam><FKZH>${FKZH}</FKZH><SKZH>${SKZH}</SKZH><SKHM>${SKHM}</SKHM><SKYH>${SKYH}</SKYH><SKSH>${SKSH}</SKSH><SKSI>${SKSI}</SKSI><JYJE>${JYJE}</JYJE><YOTU>${YOTU}</YOTU><SKHH>${SKHH}</SKHH></ReqParam></opReq>";
+//    private static final String TRADE_MESSAGE = "<opReq><serialNo>${serialNo}</serialNo><reqTime>${reqTime}</reqTime><ReqParam><FKZH>${FKZH}</FKZH><SKZH>${SKZH}</SKZH><SKHM>${SKHM}</SKHM><SKYH>${SKYH}</SKYH><SKSH>${SKSH}</SKSH><SKSI>${SKSI}</SKSI><JYJE>${JYJE}</JYJE><YOTU>${YOTU}</YOTU><SKHH>${SKHH}</SKHH></ReqParam></opReq>";
+    private static final String TRADE_MESSAGE = "<opReq><serialNo>${serialNo}</serialNo><reqTime>${reqTime}</reqTime><ReqParam><FKZH>${FKZH}</FKZH><SKZH>${SKZH}</SKZH><SKHM>${SKHM}</SKHM><SKYH>${SKYH}</SKYH><SKSH>${SKSH}</SKSH><SKSI>${SKSI}</SKSI><JYJE>${JYJE}</JYJE><YOTU>${YOTU}</YOTU></ReqParam></opReq>";
 //	private static final String TRADE_MESSAGE = "<opReq><serialNo>${serialNo}</serialNo><reqTime>${reqTime}</reqTime><ReqParam><FKZH>82260120102022631</FKZH><SKZH>6228481060643871117</SKZH><SKHM>王苏平</SKHM><SKYH>中国农业银行舟山市定海支行营业中心</SKYH><SKSH>浙江省</SKSH><SKSI>舟山市</SKSI><JYJE>0.01</JYJE><BIZH>01</BIZH><ZZLX>02</ZZLX><ZZLB>0</ZZLB><YOTU>银企接口测试</YOTU><SKHH>103342040518</SKHH></ReqParam></opReq>";
     /**
      *
@@ -107,15 +111,14 @@
      * 接收报文url
      */
 //    private static final String URL = "http://127.0.0.1:9080/directlink/httpAccess";
-//    private static final String URL = "http://220.168.79.89:9080/directlink/httpAccess";
-    private static final String URL = "http://747f9407.r3.cpolar.top/directlink/httpAccess";
-//    private static final String URL = "http://1d6d-220-168-79-89.ngrok.io/directlink/httpAccess";
+    private static final String URL = "http://n5z7ej.natappfree.cc/directlink/httpAccess";
+
+    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
     /**
      * 签名ip
      */
 //    private static final String VERIFY_IP = "127.0.0.1";
-    private static final String VERIFY_IP = "3b425db8.r10.cpolar.top";
-//    private static final String VERIFY_IP = "747f9407.r3.cpolar.top";
+    private static final String VERIFY_IP = "server.natappfree.cc";
     /**
      * 付款账号
      */
@@ -123,7 +126,8 @@
     /**
      * 签名端口
      */
-    private static final int VERIFY_PORT = 8010;
+    private static final int VERIFY_PORT = 39296;
+//    private static final int VERIFY_PORT = 8010;
 
     /**
      * cookies
@@ -153,23 +157,15 @@
     public static void main(String[] args) {
         try {
 
-            InetAddress addr = InetAddress.getByName(VERIFY_IP);
-            String hostName = addr.getHostName();
-//            Socket socket = new Socket(hostName, VERIFY_PORT);
-            String hostAddress = addr.getHostAddress();
-            SocketAddress address = new InetSocketAddress(VERIFY_IP, 8010);
 
-            Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
-            Socket socket = new Socket(proxy);
-            int port = socket.getPort();
+
+            InetAddress addr = InetAddress.getByName(VERIFY_IP);
+            Socket socket = new Socket(addr, VERIFY_PORT);
+
             System.out.println("发送登录请求:"+addr);
-			System.out.println("发送登录请求:"+address);
-			System.out.println("发送登录请求:"+hostName);
-			System.out.println("发送登录请求:"+port);
+            System.out.println("发送登录请求:"+socket.getKeepAlive());
 //			System.out.println("发送登录请求:");
 //			test.executeServerHttpService("srv001_signOn");
-//            System.out.println("\n发送转账结果查询请求:");
-//            executeServerHttpService("srv008_transferResultInfoQuery","转账结果查询","2023032910585227466");
 //			System.out.println("\n发送跨行转账请求:");
 //			test.executeServerHttpService("srv007_singleOuterTransfer","跨行转账",null);
 //			System.out.println("\n发送行内转账请求:");
@@ -180,11 +176,11 @@
     }
 
 
-    @Autowired
+    @Resource
     private MallMemberWithdrawMapper mallMemberWithdrawMapper;
-    @Autowired
+    @Resource
     private MallMemberWithdrawMsgMapper mallMemberWithdrawMsgMapper;
-    @Autowired
+    @Resource
     private MallMemberBankMapper mallMemberBankMapper;
 
     @Override
@@ -383,10 +379,19 @@
      * @throws Exception
      */
     @SuppressWarnings("rawtypes")
-    public static String executeServerHttpService(String requestData) throws Exception {
+    public String executeServerHttpService(String requestData) throws Exception {
 //    public static void executeServerHttpService(String serviceId, String serviceName, String serialNo,String requestData) throws Exception {
         // 处理交易的url
-        java.net.URL url = new URL(URL);
+        DataDictionaryCustom urlDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.BANK_TRANS_URL.getType(),
+                DataDictionaryEnum.BANK_TRANS_URL.getCode()
+        );
+        StringBuffer urlSb = new StringBuffer();
+        urlSb.append("http://");
+        urlSb.append(urlDic.getValue());
+        urlSb.append("/directlink/httpAccess");
+        java.net.URL url = new URL(urlSb.toString());
+//        java.net.URL url = new URL(URL);
         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
         if (cookies != null) {
             // 如果已登录,设置coikie
@@ -521,7 +526,7 @@
      * @throws FileNotFoundException
      * @throws IOException
      */
-    public static String getRequestDataForWithDraw(String serviceId, String serviceName,MallMemberWithdraw mallMemberWithdraw,MallMemberBank mallMemberBank)
+    public String getRequestDataForWithDraw(String serviceId, String serviceName,MallMemberWithdraw mallMemberWithdraw,MallMemberBank mallMemberBank)
             throws FileNotFoundException, IOException {
         StringBuffer buf = new StringBuffer();
         // 报文编码格式utf-8
@@ -533,6 +538,18 @@
         buf.append(serviceId);
         buf.append("</serviceId>");
         String reqData = "";
+        DataDictionaryCustom fkzhDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.BANK_TRANS_FKZH.getType(),
+                DataDictionaryEnum.BANK_TRANS_FKZH.getCode()
+        );
+        DataDictionaryCustom customerIdDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.BANK_TRANS_customerId.getType(),
+                DataDictionaryEnum.BANK_TRANS_customerId.getCode()
+        );
+        DataDictionaryCustom softwareIdDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.BANK_TRANS_softwareId.getType(),
+                DataDictionaryEnum.BANK_TRANS_softwareId.getCode()
+        );
         if (serviceId.equals("srv001_signOn")) {
             reqData = SIGN_MESSAGE;
         } else if (serviceId.equals("srv006_singleInnerTransfer")) {
@@ -552,7 +569,7 @@
              * </opReq>
              * *
              */
-            reqData = reqData.replaceFirst("\\$\\{FKZH\\}", FKZH);
+            reqData = reqData.replaceFirst("\\$\\{FKZH\\}", fkzhDic.getValue());
             reqData = reqData.replaceFirst("\\$\\{SKZH\\}", mallMemberBank.getBankNo());
             reqData = reqData.replaceFirst("\\$\\{SKHM\\}", mallMemberBank.getName());
             if(mallMemberWithdraw.getRemark().equals("凭证提现")){
@@ -587,7 +604,7 @@
              */
             reqData = TRADE_MESSAGE;
 
-            reqData = reqData.replaceFirst("\\$\\{FKZH\\}", FKZH);
+            reqData = reqData.replaceFirst("\\$\\{FKZH\\}", fkzhDic.getValue());
             reqData = reqData.replaceFirst("\\$\\{SKZH\\}", mallMemberBank.getBankNo());
             reqData = reqData.replaceFirst("\\$\\{SKHM\\}", mallMemberBank.getName());
             reqData = reqData.replaceFirst("\\$\\{SKYH\\}", mallMemberBank.getBankName()+mallMemberBank.getSubbranchName());
@@ -601,7 +618,7 @@
                         mallMemberWithdraw.getAmount().subtract(mallMemberWithdraw.getAmountFee()).setScale(2, BigDecimal.ROUND_DOWN).toString());
             }
             reqData = reqData.replaceFirst("\\$\\{YOTU\\}", "跨行汇款");
-            reqData = reqData.replaceFirst("\\$\\{SKHH\\}", mallMemberBank.getSkhh());
+//            reqData = reqData.replaceFirst("\\$\\{SKHH\\}", mallMemberBank.getSkhh());
         }else if (serviceId.equals("srv008_transferResultInfoQuery")) {
             reqData = TRADE_MESSAGE_SEARCH;
             //原订单流水号
@@ -619,7 +636,7 @@
              * <opReq><serialNo>${serialNo}</serialNo><reqTime>${reqTime}</reqTime><ReqParam><ZHHA>${ZHHA}</ZHHA></ReqParam></opReq>
              */
             //原订单流水号
-            reqData = reqData.replaceFirst("\\$\\{ZHHA\\}", FKZH);
+            reqData = reqData.replaceFirst("\\$\\{ZHHA\\}", fkzhDic.getValue());
         }
 //		String serialNo = String.valueOf(Math.round(Math.random() * 10000))
 //				+ System.currentTimeMillis();
@@ -638,10 +655,10 @@
             e.printStackTrace();
         }
         buf.append("<customerId>");
-        buf.append(customerId);
+        buf.append(customerIdDic.getValue());
         buf.append("</customerId>");
         buf.append("<softwareId>");
-        buf.append(softwareId);
+        buf.append(softwareIdDic.getValue());
         buf.append("</softwareId>");
         buf.append("<functionId>");
         buf.append(serviceId.substring(0, 6));
@@ -668,7 +685,7 @@
      * @return
      * @throws UnsupportedEncodingException
      */
-    public static String signData(String orignalData)
+    public String signData(String orignalData)
             throws UnsupportedEncodingException {
         InetAddress addr = null;
         Socket socket = null;
@@ -680,9 +697,19 @@
                 + "<origin_data_len>" + orignalData.getBytes("GBK").length
                 + "</origin_data_len>\n" + "<origin_data>" + orignalData
                 + "</origin_data>\n" + "</msg_body>\n" + "</msg>";
+
+        DataDictionaryCustom VERIFY_IPDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.BANK_TRANS_VERIFY_IP.getType(),
+                DataDictionaryEnum.BANK_TRANS_VERIFY_IP.getCode()
+        );DataDictionaryCustom VERIFY_PORT_Dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.BANK_TRANS_VERIFY_PORT.getType(),
+                DataDictionaryEnum.BANK_TRANS_VERIFY_PORT.getCode()
+        );
         try {
-            addr = InetAddress.getByName(VERIFY_IP);
-            socket = new Socket(addr, VERIFY_PORT);
+            addr = InetAddress.getByName(VERIFY_IPDic.getValue());
+            socket = new Socket(addr, Integer.parseInt(VERIFY_PORT_Dic.getValue()));
+//            InetAddress localHost = addr.getLocalHost();
+//            socket = new Socket(localHost, VERIFY_PORT);
             // 发送
             BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(
                     socket.getOutputStream(),"GBK"));

--
Gitblit v1.9.1