From 0423dcc11fe7bfcfc107198bbe4cbe34d77ace6f Mon Sep 17 00:00:00 2001
From: kongdeqiang <kongdeqiang960204@163.com>
Date: 星期二, 12 十二月 2023 16:36:21 +0800
Subject: [PATCH] 提交更新

---
 src/main/java/com/boying/controller/phone/YCPayController.java |  570 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 549 insertions(+), 21 deletions(-)

diff --git a/src/main/java/com/boying/controller/phone/YCPayController.java b/src/main/java/com/boying/controller/phone/YCPayController.java
index 8d18b3b..6d91a67 100644
--- a/src/main/java/com/boying/controller/phone/YCPayController.java
+++ b/src/main/java/com/boying/controller/phone/YCPayController.java
@@ -1,23 +1,41 @@
 package com.boying.controller.phone;
 
+import cn.hutool.http.Header;
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.boying.common.R;
+import com.boying.common.ReturnData;
 import com.boying.common.SystemConfigProperties;
 import com.boying.entity.*;
 import com.boying.service.*;
+import com.boying.util.DateUtilOther;
+import com.boying.util.HTTPEntityUtil;
+import com.google.gson.Gson;
 import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.Files;
 import java.text.SimpleDateFormat;
+import java.time.Duration;
+import java.time.LocalDateTime;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author kdq
@@ -31,11 +49,15 @@
 @RequiredArgsConstructor
 public class YCPayController {
     private final OutParkService outParkService;
+    private final ParkService parkService;
     private final OrderRecordService orderRecordService;
     private final TicketService ticketService;
     private final TicketBlackService ticketBlackService;
+
     private final SystemConfigProperties systemConfigProperties;
     private final WhiteListService whiteListService;
+    private final EnterParkService enterParkService;
+    private final WXService wxService;
 
     /**
      * 鏌ヨ璁㈠崟鎺ュ彛
@@ -44,7 +66,13 @@
      */
     @GetMapping("/getByQueryId")
     public Object getByQueryId(Long queryId){
+        if(queryId == null){
+            return R.failed("鍙傛暟涓虹┖");
+        }
         OutPark byId = outParkService.getById(queryId);
+        if(byId.getTime() > 0){
+            byId.setTimeStr(DateUtilOther.millisToDayHrMinSec(new Double(byId.getTime()).longValue()));
+        }
         return R.ok(byId,"璇锋眰鎴愬姛");
     }
 
@@ -53,6 +81,7 @@
      */
     @PostMapping("park")
     public Object park(Long id){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
         OutPark outPark =  outParkService.getById(id);
         if(outPark.getPrice()==0){
             updateOutPark(outPark.getId(),"03");
@@ -69,24 +98,292 @@
                 updateOutPark(outPark.getId(),"03");
                 return R.failed("鏈鍋滆溅鏃犻渶鏀粯璐圭敤!");
             }else{
-                if(w.getParkId()!=null){
-                    if(w.getEndTime()!=null){
-                        if(w.getParkId().equals(outPark.getParkId())&&System.currentTimeMillis()<w.getEndTime().getTime()){
-                            updateOutPark(outPark.getId(),"03");
-                            return R.failed("鏈鍋滆溅鏃犻渶鏀粯璐圭敤!");
+                if(StringUtils.isNotBlank(w.getParkIds())){
+                    if(w.getParkIds().contains(outPark.getParkId()+"")){
+                        if(w.getEndTime()!=null){
+                            if(System.currentTimeMillis()<w.getEndTime().getTime()){
+                                updateOutPark(outPark.getId(),"03");
+                                return R.failed("鏈鍋滆溅鏃犻渶鏀粯璐圭敤!");
+                            }
                         }
                     }
+
                 }
             }
         }
-        if(outPark.getStatus() == 0){
-            return R.ok("璺宠浆閭偍鏀粯", "https://hbfs.govpay.ccb.com/online/fssm?fee=130000000001&PyfScnCgycd=01&pyfTpcd=3&BNo="+outPark.getPayCode());
-        }else if(outPark.getStatus() == 1){
+        if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 0){
+            String logs = sdf.format(new Date())+" 杞︾墝鍙蜂负锛�"+outPark.getCarNo()+",鐢宠缂磋垂2------銆媆n";
+            writeTxt(logs);
+           // "http://wxtest.smeia.cn/h5/static/router.html?rurl=router&router=psbc&appid=CUP16522400671&params={\"payMode\":\"B\",\"payItemNo\":\"41301106100124\",\"userNo\":"+id+"}"
+            return R.ok("璺宠浆閭偍鏀粯","https://openpayment.psbc.com/h5/static/router.html?rurl=router&router=psbc&appid=CUP14094502391&params={\"payMode\":\"B\",\"payItemNo\":\"41304508000500\",\"userNo\":"+id+"}");
+          //  return R.ok("璺宠浆閭偍鏀粯","http://wxtest.smeia.cn/h5/static/router.html?rurl=router&router=psbc&appid=CUP16522400671&params={\"payMode\":\"B\",\"payItemNo\":\"41301106100124\",\"userNo\":"+id+"}");
+        }else if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 1){
             return R.failed("宸茬即璐�");
+        }
+
+        if(StringUtils.isBlank(outPark.getPayCode())){
+            String logs = sdf.format(new Date())+" 杞︾墝鍙蜂负锛�"+outPark.getCarNo()+",鐢宠缂磋垂------銆媆n";
+            writeTxt(logs);
+            List<EnterPark> byCarNo = enterParkService.findByCarNo(outPark.getCarNo(),outPark.getParkId());
+            if(byCarNo.size()>0){
+                EnterPark enterPark = byCarNo.get(0);
+                if(enterPark != null && enterPark.getIsPay() == 1){
+                    if(outPark.getPrice()==enterPark.getPrice()){
+                        return R.failed("宸茬即璐�");
+                    }else {
+                        outPark.setPrice(outPark.getPrice()-enterPark.getPrice());
+                        outParkService.updateById(outPark);
+                    }
+                }
+            }
+            addOrderRecord(outPark);
+            return R.ok("璺宠浆閭偍鏀粯","https://openpayment.psbc.com/h5/static/router.html?rurl=router&router=psbc&appid=CUP14094502391&params={\"payMode\":\"B\",\"payItemNo\":\"41304508000500\",\"userNo\":"+id+"}");
         }else {
-            return R.failed("绯荤粺寮傚父");
+            return R.failed("鍑洪敊");
         }
     }
+
+
+    /**
+     * 鍒ゆ柇鏄惁缂磋垂
+     */
+    @PostMapping("parkXT")
+    public Object parkXT(Long id){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
+        OutPark outPark =  outParkService.getById(id);
+        System.out.println("id:"+id);
+        if(id == null){
+            return R.failed("鏈壘鍒版暟鎹紝璇风◢鍚庨噸鏂扮偣鍑�");
+        }
+        if(outPark.getPrice()==0){
+            updateOutPark(outPark.getId(),"03");
+            return R.failed("鏈鍋滆溅鏃犻渶鏀粯璐圭敤");
+        }
+
+        //鍒ゆ柇鏄惁鍦ㄧ櫧鍚嶅崟
+        QueryWrapper<WhiteList> wrapper = new QueryWrapper<>();
+        wrapper.lambda()
+                .eq(WhiteList::getCarNo,outPark.getCarNo());
+        List<WhiteList> all = whiteListService.list(wrapper);
+        for(WhiteList w : all){
+            if(w.getType()==0){
+                updateOutPark(outPark.getId(),"03");
+                return R.failed("鏈鍋滆溅鏃犻渶鏀粯璐圭敤!");
+            }else{
+                if(StringUtils.isNotBlank(w.getParkIds())){
+                    if(w.getParkIds().contains(outPark.getParkId()+"")){
+                        if(w.getEndTime()!=null){
+                            if(System.currentTimeMillis()<w.getEndTime().getTime()){
+                                updateOutPark(outPark.getId(),"03");
+                                return R.failed("鏈鍋滆溅鏃犻渶鏀粯璐圭敤!");
+                            }
+                        }
+                    }
+
+                }
+            }
+        }
+        if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 0){
+            String logs = sdf.format(new Date())+" 杞︾墝鍙蜂负锛�"+outPark.getCarNo()+",鐢宠缂磋垂2------銆媆n";
+            writeTxt(logs);
+            return R.ok(null,"璺宠浆閭㈠彴閾惰鏀粯");
+        }else if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 1){
+            return R.failed("宸茬即璐�");
+        }
+
+        if(StringUtils.isBlank(outPark.getPayCode())){
+            String logs = sdf.format(new Date())+" 杞︾墝鍙蜂负锛�"+outPark.getCarNo()+",鐢宠缂磋垂------銆媆n";
+            writeTxt(logs);
+            List<EnterPark> byCarNo = enterParkService.findByCarNo(outPark.getCarNo(),outPark.getParkId());
+            if(byCarNo.size()>0){
+                EnterPark enterPark = byCarNo.get(0);
+                if(enterPark != null && enterPark.getIsPay() == 1){
+                    if(outPark.getPrice()==enterPark.getPrice()){
+                        return R.failed("宸茬即璐�");
+                    }else {
+                        outPark.setPrice(outPark.getPrice()-enterPark.getPrice());
+                        outParkService.updateById(outPark);
+                    }
+                }
+            }
+            addOrderRecord(outPark);
+            return R.ok(null,"璺宠浆閭㈠彴閾惰鏀粯");
+        }else {
+            return R.failed("鍑洪敊");
+        }
+    }
+
+    /**
+     * 闃块噷缂磋垂
+     */
+    @PostMapping("payByAli")
+    public Object payByAli(Long id){
+        OutPark outPark =  outParkService.getById(id);
+        String xtyhpay = systemConfigProperties.getXTYHPAY();
+        LocalDateTime date3 = LocalDateTime.now();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        String format = sdf.format(new Date());
+        Map<String,Object> map = new HashMap<>();
+        map.put("encoding","UTF-8");
+        map.put("signMethod","01");
+        map.put("sdkAppId",systemConfigProperties.getXTYHMERID());
+        map.put("txnType","1007");
+        map.put("txnSubType","100702");
+        map.put("txnAccType","03");
+        map.put("aesWay","01");
+        map.put("merId",systemConfigProperties.getXTYHMERID());
+        map.put("merName",systemConfigProperties.getXTYHMERNAME());
+        map.put("backEndUrl",systemConfigProperties.getXTYHRESULT());
+        map.put("txnOrderId",outPark.getId()+""+format);
+        map.put("txnOrderTime",format);
+        map.put("txnOrderBody",outPark.getCarNo()+"娉婅溅缂磋垂");
+        map.put("txnAmt",Math.round(outPark.getPrice() * 100)+"");
+        map.put("txnCcyType","156");
+        if(outPark.getPayTime() != null){
+            LocalDateTime date4 = outPark.getPayTime();
+            Duration duration = Duration.between(date3, date4);
+            long l = duration.toMinutes();
+            if(l<3){
+                map.put("preTxnSsn",outPark.getCode2());
+            }
+        }
+
+        Map<String, String> stringStringMap = wxService.addSign(map);
+        map.put("certId",stringStringMap.get("certId"));
+        map.put("signAture",stringStringMap.get("signAture"));
+        Gson gson =new Gson();
+        String str = gson.toJson(map);
+        System.out.println("璇锋眰鎶ユ枃锛�"+str);
+        writeTxt2(outPark.getId()+"ALipay璇锋眰: "+str);
+
+        String body = HttpRequest.post(xtyhpay)
+                .header(Header.CONTENT_TYPE, "application/json")
+                .body(str)
+                .timeout(15000)
+                .execute()
+                .body();
+        System.out.println(outPark.getId()+"鍝嶅簲鎶ユ枃锛�"+body);
+
+        writeTxt2(outPark.getId()+"ALipay鍝嶅簲: "+body);
+        JSONObject map1 = JSON.parseObject(body);
+        String respCode = (String)map1.get("respCode");
+        if(respCode.equals("0000")){
+            String respTxnSsn = (String)map1.get("respTxnSsn");
+            String respData = (String)map1.get("respData");
+            String respTxnTime = (String)map1.get("respTxnTime");
+            Map map2 = gson.fromJson(respData, Map.class);
+            String qrCode = (String)map2.get("qrCode");
+            outPark.setCode2(respTxnSsn);
+            outPark.setQrCode(qrCode);
+            outPark.setPayTime(LocalDateTime.now());
+            outPark.setTxnOrderId(outPark.getId()+""+format);
+            outPark.setTxnOrderTime(format);
+            outPark.setRespTxnTime(respTxnTime);
+            outParkService.updateById(outPark);
+            return R.ok(null,qrCode);
+        }
+        String respMsg = (String)map1.get("respMsg");
+        return R.failed(respCode+":"+respMsg);
+    }
+
+    /**
+     * 鑾峰彇寰俊openid
+     */
+    @PostMapping("getOpenId")
+    public Object park(Long id,String code){
+        OutPark outPark =  outParkService.getById(id);
+        String openIdByCode = wxService.getOpenIdByCode(code);
+        writeTxt2(outPark.getId()+"鑾峰彇openid涓猴細"+openIdByCode);
+        return payByWX(id,openIdByCode);
+    }
+
+    /**
+     * 寰俊缂磋垂
+     */
+    @PostMapping("payByWX")
+    public Object payByWX(Long id,String openId){
+        System.out.println("寮�濮嬫敮浠�");
+        OutPark outPark =  outParkService.getById(id);
+        String xtyhpay = systemConfigProperties.getXTYHPAY();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        String format = sdf.format(new Date());
+        LocalDateTime date3 = LocalDateTime.now();
+        Map<String,Object> map = new HashMap<>();
+        map.put("encoding","UTF-8");
+        map.put("signMethod","01");
+        map.put("sdkAppId",systemConfigProperties.getXTYHMERID());
+        map.put("txnType","1006");
+        map.put("txnSubType","100603");
+        map.put("txnAccType","02");
+        map.put("secMerAppId",systemConfigProperties.getXTYHAPPID());
+        map.put("txnSubOpenid",openId);
+        map.put("txnProductId",outPark.getId()+"");
+        map.put("aesWay","01");
+        map.put("merId",systemConfigProperties.getXTYHMERID());
+        map.put("merName",systemConfigProperties.getXTYHMERNAME());
+        map.put("backEndUrl",systemConfigProperties.getXTYHRESULT());
+        map.put("txnOrderId",outPark.getId()+""+format);
+        map.put("txnOrderTime",format);
+        map.put("txnOrderBody",outPark.getCarNo()+"娉婅溅缂磋垂");
+        map.put("txnAmt",Math.round(outPark.getPrice() * 100)+"");
+        map.put("txnCcyType","156");
+        if(outPark.getPayTime() != null){
+            LocalDateTime date4 = outPark.getPayTime();
+            Duration duration = Duration.between(date3, date4);
+            long l = duration.toMinutes();
+            if(l<3){
+                map.put("preTxnSsn",outPark.getCode2());
+            }
+        }
+        Map<String, String> stringStringMap = wxService.addSign(map);
+        map.put("certId",stringStringMap.get("certId"));
+        map.put("signAture",stringStringMap.get("signAture"));
+        Gson gson =new Gson();
+        String str = gson.toJson(map);
+        System.out.println("璇锋眰鎶ユ枃锛�"+str);
+        writeTxt2(outPark.getId()+"WXpay璇锋眰: "+str);
+
+        String body = HttpRequest.post(xtyhpay)
+                .header(Header.CONTENT_TYPE, "application/json")
+                .body(str)
+                .timeout(15000)
+                .execute()
+                .body();
+        System.out.println(outPark.getId()+"鍝嶅簲鎶ユ枃锛�"+body);
+
+        writeTxt2(outPark.getId()+"WXpay鍝嶅簲: "+body);
+        JSONObject map1 = JSON.parseObject(body);
+        String respCode = (String)map1.get("respCode");
+        if(respCode.equals("0000")){
+            String respTxnSsn = (String)map1.get("respTxnSsn");
+            String respTxnTime = (String)map1.get("respTxnTime");
+            String respData = (String)map1.get("respData");
+            Map map2 = gson.fromJson(respData, Map.class);
+            String appId = (String)map2.get("appId");
+            String timeStamp = (String)map2.get("timeStamp");
+            String nonceStr = (String)map2.get("nonceStr");
+            String signType = (String)map2.get("signType");
+            String package1 = (String)map2.get("package");
+            String paySign = (String)map2.get("paySign");
+            Map<String,String> resultMap = new HashMap<>();
+            resultMap.put("appId",appId);
+            resultMap.put("timeStamp",timeStamp);
+            resultMap.put("nonceStr",nonceStr);
+            resultMap.put("signType",signType);
+            resultMap.put("package",package1);
+            resultMap.put("paySign",paySign);
+            outPark.setCode2(respTxnSsn);
+            outPark.setPayTime(LocalDateTime.now());
+            outPark.setTxnOrderId(outPark.getId()+""+format);
+            outPark.setTxnOrderTime(format);
+            outPark.setRespTxnTime(respTxnTime);
+            outParkService.updateById(outPark);
+            return R.ok(resultMap,null);
+        }
+        String respMsg = (String)map1.get("respMsg");
+        return R.failed(respCode+":"+respMsg);
+    }
+
 
     /**
      * 鏀粯鍥炶皟鎺ュ彛
@@ -96,40 +393,190 @@
     @GetMapping("/result")
     public Object result(Long queryId,int success,int msg){
         OutPark byId = outParkService.getById(queryId);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
         if(byId == null){
             return R.failed("鏈煡璇㈠埌璁㈠崟");
         }else {
             //淇敼璁㈠崟鐘舵�� 0鎴愬姛
             if(success==0){
                 updateOrderRecord(queryId,"03");
-                return R.ok(null,"璇锋眰鎴愬姛");
+                String logs = sdf.format(new Date())+" 杞︾墝鍙蜂负锛�"+byId.getCarNo()+",缂磋垂鎴愬姛------銆媆n";
+                writeTxt(logs);
+                List<EnterPark> byCarNo = enterParkService.findByCarNo(byId.getCarNo(),byId.getParkId());
+                if(byCarNo.size()>0){
+                    EnterPark enterPark = byCarNo.get(0);
+                    enterPark.setIsPay(1);
+                    enterParkService.updateById(enterPark);
+                }
+                return R.ok(null,"鍥炶皟鎴愬姛");
             }else {
-                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
                 String logs = sdf.format(new Date())+" 鍑哄満id涓猴細"+queryId+",缂磋垂澶辫触------銆媆n";
                 logs += "鍥炴墽鍘熷洜锛�"+msg+",\n";
                 writeTxt(logs);
             }
         }
-        return R.ok(byId,"璇锋眰鎴愬姛");
+        return R.ok(byId,"鍥炶皟鎴愬姛");
     }
+
+
+    /**
+     * 閭㈠彴閾惰鏀粯鍥炶皟鎺ュ彛
+     * @param
+     * @return
+     */
+    @PostMapping("/getResult")
+    public Object getResult(HttpServletRequest request){
+        System.out.println("getResult鏀跺埌璁块棶");
+        String respCode = request.getParameter("respCode");
+        String respTxnSsn = request.getParameter("respTxnSsn");
+//        String respCode = map.get("respCode");
+//        String respTxnSsn = map.get("respTxnSsn");
+        System.out.println(respCode+":"+respTxnSsn);
+        if(respCode != null){
+            if(respCode.equals("0000")){
+                //浜ゆ槗鎴愬姛,鏍规嵁娴佹按鍙锋煡璇㈠嚭鍦鸿褰�
+                OutPark byPayCode = outParkService.findByPayCode(respTxnSsn);
+                writeTxt2(byPayCode.getId()+"鏀跺埌鍥炴墽\n");
+                if(byPayCode == null){
+                    return R.failed("鏈煡璇㈠埌璁㈠崟");
+                }else {
+                    updateOrderRecord((long)byPayCode.getId(),"03");
+                    List<EnterPark> byCarNo = enterParkService.findByCarNo(byPayCode.getCarNo(),byPayCode.getParkId());
+                    if(byCarNo.size()>0){
+                        EnterPark enterPark = byCarNo.get(0);
+                        enterPark.setIsPay(1);
+                        enterParkService.updateById(enterPark);
+                    }
+                    return R.ok(null,"鍥炶皟鎴愬姛");
+                }
+            }else if(respCode.equals("0002") || respCode.equals("0003") || respCode.equals("0003") || respCode.equals("0012")){
+                //浜ゆ槗鎴愬姛锛岃秴鏃讹紝鏈槑锛岀◢鍚庡彂璧锋煡璇�
+            }else if(respCode.equals("0011")){
+                //浜ゆ槗
+            }
+        }else {
+            return R.failed("鏈帴鏀跺埌鍏ュ弬");
+        }
+        return R.failed(null,"璇锋眰澶辫触");
+    }
+
 
     /**
      * 瀵硅处鎺ュ彛
-     * @param checkDate,tranDate,fileName
+     * @param
      * @return
      */
-    @GetMapping("/checkbill")
-    public Object checkbill(String checkDate,String tranDate,String fileName){
+    @PostMapping ("/checkbill")
+    public Object checkbill(@RequestBody Map params){
+        String checkDate = (String) params.get("checkDate");
+        String tranDate = (String) params.get("tranDate");
+        String fileName = (String) params.get("fileName");
         checkDate=checkDate.replaceAll("-","");
-        String name = "E:\\Bank_PSBC_"+checkDate+".txt";
+        String name = "E:\\ycCheckBill\\Bank_PSBC_"+checkDate+".txt";
         File file = new File(name);
         Boolean aBoolean = judeFileExists(file);
         if(aBoolean){
-            return R.ok();
+            return R.ok(null,"鏌ヨ鏂囦欢鎴愬姛");
         }else {
             return R.failed(null,"鏂囦欢涓嶅瓨鍦�");
         }
     }
+
+    /**
+     * 閭㈠彴閾惰瀵硅处鎺ュ彛
+     * @param
+     * @return
+     */
+    @PostMapping ("/checkbillXTYH")
+    public Object checkbillXTYH(String date){
+        String xtyhpay = systemConfigProperties.getXTYHPAY();
+        Map<String,Object> map = new HashMap<>();
+        map.put("encoding","UTF-8");
+        map.put("signMethod","01");
+        map.put("txnType","4001");
+        map.put("txnSubType","400102");
+        map.put("billType","00");
+        map.put("billDate",date);
+        map.put("merId","8202309110000001");
+
+        Map<String, String> stringStringMap = wxService.addSign(map);
+        map.put("certId",stringStringMap.get("certId"));
+        map.put("signAture",stringStringMap.get("signAture"));
+        Gson gson =new Gson();
+        String str = gson.toJson(map);
+        System.out.println("璇锋眰鎶ユ枃锛�"+str);
+        writeTxt2(date+"瀵硅处璇锋眰: "+str);
+
+        String body = HttpRequest.post(xtyhpay)
+                .header(Header.CONTENT_TYPE, "application/json")
+                .body(str)
+                .timeout(15000)
+                .execute()
+                .body();
+
+        writeTxt2(date+"瀵硅处鍝嶅簲: "+body);
+        JSONObject map1 = JSON.parseObject(body);
+        String respCode = (String)map1.get("respCode");
+        if(respCode.equals("0000")){
+            String billDownloadUrl = (String)map1.get("billDownloadUrl");
+            String respData = (String)map1.get("respData");
+            return R.ok(null,billDownloadUrl);
+        }
+        String respMsg = (String)map1.get("respMsg");
+        return R.failed(respCode+":"+respMsg);
+    }
+
+    /**
+     * 浜ゆ槗鐘舵�佹煡璇�
+     * @param
+     * @return
+     */
+    @PostMapping ("/searchPayStatus")
+    public Object searchPayStatus(String txnOrderId,String txnOrderTime){
+        OutPark outPark = outParkService.findByOrderId(txnOrderId);
+        if(outPark == null){
+            return R.failed("鏈壘鍒拌璁㈠崟");
+        }
+        String xtyhpay = systemConfigProperties.getXTYHPAY();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        Map<String,Object> map = new HashMap<>();
+        map.put("encoding","UTF-8");
+        map.put("signMethod","01");
+        map.put("sdkAppId","8202309110000001");
+        map.put("txnType","1009");
+        map.put("txnSubType","100900");
+        map.put("merId","8202309110000001");
+        map.put("origTxnOrderId",txnOrderId);
+        map.put("origTxnOrderTime",txnOrderTime);
+
+        Map<String, String> stringStringMap = wxService.addSign(map);
+        map.put("certId",stringStringMap.get("certId"));
+        map.put("signAture",stringStringMap.get("signAture"));
+        Gson gson =new Gson();
+        String str = gson.toJson(map);
+        System.out.println("璇锋眰鎶ユ枃锛�"+str);
+        writeTxt2(txnOrderId+"鐘舵�佹煡璇㈣姹�: "+str);
+
+        String body = HttpRequest.post(xtyhpay)
+                .header(Header.CONTENT_TYPE, "application/json")
+                .body(str)
+                .timeout(15000)
+                .execute()
+                .body();
+        System.out.println(txnOrderId+"鐘舵�佹煡璇㈠搷搴旀姤鏂囷細"+body);
+
+        writeTxt2(txnOrderId+"鐘舵�佹煡璇㈠搷搴�: "+body);
+        JSONObject map1 = JSON.parseObject(body);
+        String respCode = (String)map1.get("respCode");
+        if(respCode.equals("0000")){
+            result((long)outPark.getId(),0,0);
+            return R.ok(null,"鏌ヨ鎴愬姛");
+        }
+        String respMsg = (String)map1.get("respMsg");
+        return R.failed(respCode+":"+respMsg);
+    }
+
+
 
 
 
@@ -147,6 +594,8 @@
             }
             if(status.equals("03")){
                 orderRecord.setStatus(1);
+                //娴嬭瘯鐜锛屾殏鏃舵妸寮�绁ㄨ缃负2
+                orderRecord.setTicketStatus(2);
             }
             if(status.equals("04")||status.equals("05")||status.equals("06")){
                 orderRecord.setStatus(2);
@@ -220,6 +669,52 @@
         }
     }
 
+    //鎻掑叆鍋滆溅璁㈠崟璁板綍
+    public void addOrderRecord(OutPark outPark){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
+        String logs = sdf.format(new Date())+" 杞︾墝鍙蜂负锛�"+outPark.getCarNo()+",鍒涘缓璁㈠崟------銆媆n";
+        writeTxt(logs);
+        outPark.setPayCode(outPark.getId()+"");
+        List<EnterPark> byCarNo = enterParkService.findByCarNo(outPark.getCarNo(),outPark.getParkId());
+        outParkService.updateById(outPark);
+        Park park = parkService.getById(outPark.getParkId());
+        OrderRecord orderRecord = new OrderRecord();
+        if(byCarNo.size() >0){
+            EnterPark enterPark = byCarNo.get(0);
+            if(enterPark != null && enterPark.getImgId() != null){
+                orderRecord.setImgInId(enterPark.getImgId());
+            }
+        }
+        orderRecord.setAddress(park.getName());
+        orderRecord.setCarNo(outPark.getCarNo());
+        orderRecord.setCode(outPark.getCode());
+        orderRecord.setCode2(outPark.getCode2());
+        orderRecord.setMoney(outPark.getPrice());
+        orderRecord.setQueryId(outPark.getId());
+        orderRecord.setType(1);
+        orderRecord.setTicketStatus(0);
+        orderRecord.setPayCode(outPark.getPayCode());
+        if(outPark.getImgId() != null){
+            orderRecord.setImgOutId(outPark.getImgId());
+        }
+        orderRecordService.saveOrUpdate(orderRecord);
+    }
+
+    //鎻掑叆鎵ф硶璁㈠崟璁板綍
+    public void addOrderRecord2(Ticket ticket){
+        OrderRecord orderRecord = new OrderRecord();
+        orderRecord.setAddress(ticket.getAddress());
+        orderRecord.setCarNo(ticket.getCarNo());
+        orderRecord.setCode(ticket.getCode());
+        orderRecord.setMoney(ticket.getMoney());
+        orderRecord.setQueryId(ticket.getId());
+        orderRecord.setType(0);
+        orderRecord.setPayCode(ticket.getPayCode());
+        orderRecordService.saveOrUpdate(orderRecord);
+    }
+
+
+
     private void writeTxt( String txt)
     {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
@@ -236,4 +731,37 @@
             System.out.println("鎵撳嵃閿欒");
         }
     }
+
+    private void writeTxt2( String txt)
+    {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+        try
+        {
+            FileWriter f = new FileWriter(systemConfigProperties.getLogPath()+"閭㈠彴閾惰鏀粯鏃ュ織"+sdf.format(new Date())+".txt",true);
+            BufferedWriter bw=new BufferedWriter(f);
+            bw.write(txt);
+            bw.newLine();
+            bw.close();
+        }
+        catch(Exception e)
+        {
+            System.out.println("鎵撳嵃閿欒");
+        }
+    }
+
+    public static void main(String[] args) {
+        Path path = Paths.get("E:\\ycCheckBill\\Bank_PSBC_20350421.txt");
+        try {
+            List<String>  lines = Files.readAllLines(path);
+            String s = lines.get(0);
+            String[] split = s.split("\\|");
+
+
+            for (String line : lines) {
+                System.out.println(line);
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
 }

--
Gitblit v1.9.1