Browse Source

CCBMISPOS

lighter 3 weeks ago
parent
commit
f2bb21317e

+ 87 - 0
src/main/java/thyyxxk/webserver/api/ccbmispos/CcbMisPosApi.java

@@ -0,0 +1,87 @@
+package thyyxxk.webserver.api.ccbmispos;
+
+import com.ccb.wlpt.RequestProcess;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.config.envionment.CcbMisConfig;
+
+import java.util.Objects;
+
+@Slf4j
+@RestController
+@RequestMapping("/api/ccbmispos")
+public class CcbMisPosApi {
+    private volatile boolean initialized = false;
+    private final CcbMisConfig cfg;
+
+    @Autowired
+    public CcbMisPosApi(CcbMisConfig cfg) {
+        this.cfg = cfg;
+    }
+
+    @PassToken
+    @GetMapping("/initFileCert")
+    public String initFileCert() {
+        log.info("initFileCert:{}", cfg);
+        String initResult = RequestProcess.initFileCert(cfg.getMchId(), cfg.getUserid(),
+                cfg.getCertFile(), cfg.getCertPassword(), cfg.getConfigFile());
+        if (Objects.equals(initResult, "")) {
+            initResult = "INIT SUCCESS";
+            initialized = true;
+        } else {
+            initialized = false;
+            initResult = "INIT FAILED:" + initResult;
+        }
+        log.info("initResult:{}", initResult);
+        return initResult;
+    }
+
+    @PassToken
+    @GetMapping("/removeFileCert")
+    public String removeFileCert() {
+        RequestProcess.removeFileCert(cfg.getMchId(), cfg.getUserid());
+        return "OK";
+    }
+
+    @PassToken
+    @GetMapping("/downloadTradeList")
+    public String downloadTradeList() {
+        if (!initialized) {
+            String initResult = initFileCert();
+            if (!Objects.equals(initResult, "INIT SUCCESS")) {
+                return initResult;
+            }
+        }
+        String xml = "<?xml version=\"1.0\" encoding=\"GB2312\" standalone=\"yes\" ?>  \n" +
+                "<TX>   \n" +
+                "  <REQUEST_SN>" + System.currentTimeMillis() + "000</REQUEST_SN>  \n" +
+                "  <CUST_ID>"+cfg.getMchId() +"</CUST_ID>  \n" +
+                "  <USER_ID>"+cfg.getUserid()+"</USER_ID>  \n" +
+                "  <PASSWORD>"+cfg.getUserPassword()+"</PASSWORD>  \n" +
+                "  <TX_CODE>5W1005</TX_CODE>  \n" +
+                "  <LANGUAGE>CN</LANGUAGE>  \n" +
+                "  <TX_INFO>  \n" +
+                "    <DATE>20250715</DATE>  \n" +
+                "    <KIND>1</KIND>  \n" +
+                "    <FILETYPE>1</FILETYPE>  \n" +
+                "    <TYPE>0</TYPE>  \n" +
+                "    <NORDERBY>1</NORDERBY>  \n" +
+                "    <POS_CODE></POS_CODE>  \n" +
+                "    <ORDER></ORDER>  \n" +
+                "    <STATUS>1</STATUS>  \n" +
+                "    <BILL_FLAG>1</BILL_FLAG>  \n" +
+                "    <Mrch_No></Mrch_No>  \n" +
+                "    <GROUP_FLAG>0</GROUP_FLAG>  \n" +
+                "    <TXN_TPCD>1</TXN_TPCD>  \n" +
+                "  </TX_INFO>\n" +
+                "</TX> \n";
+        log.info("入参:\r\n{}", xml);
+        String result =  RequestProcess.sendRequest(cfg.getServiceUrl(), xml);
+        log.info("出参:\r\n{}", result);
+        return result;
+    }
+}

+ 20 - 0
src/main/java/thyyxxk/webserver/config/envionment/CcbMisConfig.java

@@ -0,0 +1,20 @@
+package thyyxxk.webserver.config.envionment;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@Data
+@ConfigurationProperties(prefix = "thyy.mispos")
+@NoArgsConstructor
+public class CcbMisConfig {
+    private String mchId;
+    private String userid;
+    private String userPassword;
+    private String configFile;
+    private String certFile;
+    private String certPassword;
+    private String serviceUrl;
+}