kongdeqiang
2023-07-10 85f5baee0e3d255860395278dcb5cbb5cc766023
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
@@ -38,6 +40,7 @@
    private final TicketBlackService ticketBlackService;
    private final SystemConfigProperties systemConfigProperties;
    private final WhiteListService whiteListService;
    private final EnterParkService enterParkService;
    /**
     * 查询订单接口
@@ -61,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");
@@ -91,14 +95,20 @@
            }
        }
        if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 0){
            return R.ok("跳转邮储支付", "http://wxtest.smeia.cn/h5/static/router.html?rurl=router&router=psbc&appid=CUP16522400671&params={\"payMode\":\"B\",\"payItemNo\":\"41301106100124\",\"userNo\":"+id+"}");
            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("跳转邮储支付", "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+"}");
        }else {
            return R.failed("出错");
        }
@@ -112,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);
@@ -131,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,"文件不存在");
        }
@@ -163,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);
@@ -238,8 +255,11 @@
    //插入停车订单记录
    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.saveOrUpdate(outPark);
        outParkService.updateById(outPark);
        Park park = parkService.getById(outPark.getParkId());
        OrderRecord orderRecord = new OrderRecord();
        orderRecord.setAddress(park.getName());
@@ -251,6 +271,16 @@
        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);
    }
@@ -285,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);
        }
    }
}