|
@@ -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;
|
|
|
+ }
|
|
|
+}
|