From ab361e724c5c4185d96397af0619398c7fe2f195 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期一, 10 七月 2023 16:15:55 +0800
Subject: [PATCH] 修改

---
 src/main/java/com/boying/controller/phone/YCPayController.java |  129 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 107 insertions(+), 22 deletions(-)

diff --git a/src/main/java/com/boying/controller/phone/YCPayController.java b/src/main/java/com/boying/controller/phone/YCPayController.java
index 53481b7..f31113e 100644
--- a/src/main/java/com/boying/controller/phone/YCPayController.java
+++ b/src/main/java/com/boying/controller/phone/YCPayController.java
@@ -8,17 +8,19 @@
 import com.boying.service.*;
 import com.boying.util.DateUtilOther;
 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.web.bind.annotation.*;
 
 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.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author kdq
@@ -32,11 +34,13 @@
 @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;
 
     /**
      * 鏌ヨ璁㈠崟鎺ュ彛
@@ -60,6 +64,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");
@@ -76,25 +81,36 @@
                 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());
-           // return R.ok("璺宠浆閭偍鏀粯", "http://wxtest.smeia.cn/h5/?appid=CUP11234601101&params={\"payMode\":\"B\",\"payItemNo\":\"41301106100124\",\"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(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);
+            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("鍑洪敊");
         }
     }
 
@@ -106,15 +122,17 @@
     @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");
+                String logs = sdf.format(new Date())+" 杞︾墝鍙蜂负锛�"+byId.getCarNo()+",缂磋垂鎴愬姛------銆媆n";
+                writeTxt(logs);
                 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);
@@ -125,17 +143,20 @@
 
     /**
      * 瀵硅处鎺ュ彛
-     * @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,"鏂囦欢涓嶅瓨鍦�");
         }
@@ -157,6 +178,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);
@@ -230,6 +253,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()+"");
+        outParkService.updateById(outPark);
+        Park park = parkService.getById(outPark.getParkId());
+        OrderRecord orderRecord = new OrderRecord();
+        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());
+        }
+        List<EnterPark> byCarNo = enterParkService.findByCarNo(outPark.getCarNo(),outPark.getParkId());
+        if(byCarNo.size() >0){
+            EnterPark enterPark = byCarNo.get(0);
+            if(enterPark != null && enterPark.getImgId() != null){
+                orderRecord.setImgInId(enterPark.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");
@@ -246,4 +315,20 @@
             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