| | |
| | | import javax.persistence.criteria.Root; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import java.io.BufferedWriter; |
| | | import java.io.FileWriter; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | @PostMapping("result") |
| | | public String result(HttpServletRequest request,String payKey,String payerTypeCode,String payerNum,String payCode,Double amt,String status,String errorInfo,String sign,String signType) throws Exception{ |
| | | System.out.println(payCode+"-------"+status); |
| | | String s = "payCode===="+payCode+",\n"; |
| | | try { |
| | | s += "开始走回调接口------>"; |
| | | writeTxt(s); |
| | | updateOrderRecord(payCode,status); |
| | | }catch (Exception e){ |
| | | |
| | | s += "更新订单记录出异常------>"; |
| | | writeTxt(s); |
| | | } |
| | | return "success"; |
| | | } |
| | | |
| | | //更新订单记录 |
| | | public void updateOrderRecord(String payCode,String status){ |
| | | String s = "更新订单记录:payCode===="+payCode+",status==="+status+",\n"; |
| | | Specification<OrderRecord> specification = new Specification<OrderRecord>() { |
| | | @Override |
| | | public Predicate toPredicate(Root<OrderRecord> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
| | |
| | | } |
| | | }; |
| | | List<OrderRecord> all = orderRecordService.findAll(specification); |
| | | s += "查询到订单记录为:"+all.size()+"条,\n"; |
| | | if(all.size()==1){ |
| | | OrderRecord orderRecord = all.get(0); |
| | | s += "查询到订单为:"+orderRecord.getId()+",\n"; |
| | | if(status.equals("01")){ |
| | | orderRecord.setStatus(0); |
| | | } |
| | |
| | | if(orderRecord.getType()==0){ |
| | | updateTicket(orderRecord.getQueryId(),status); |
| | | }else{ |
| | | s += "修改出场表:"+orderRecord.getQueryId()+",status==="+status+",\n"; |
| | | writeTxt(s); |
| | | updateOutPark(orderRecord.getQueryId(),status); |
| | | } |
| | | } |
| | | writeTxt(s); |
| | | } |
| | | |
| | | //更新罚单的状态 |
| | |
| | | // } |
| | | |
| | | public void updateOutPark(Long outParkId,String status){ |
| | | String s = "开始修改出场表-----》,\n"; |
| | | s+= "outparkId==="+outParkId+",status==="+status+",\n"; |
| | | writeTxt(s); |
| | | OutPark outPark = (OutPark) outParkService.findById(outParkId); |
| | | if(outPark!=null){ |
| | | s += "找到出场数据:"+outPark.getId()+",\n"; |
| | | writeTxt(s); |
| | | if(status.equals("03")){ |
| | | s += "出场数据修改----》"; |
| | | writeTxt(s); |
| | | outPark.setStatus(1); |
| | | outParkService.save(outPark); |
| | | } |
| | | } |
| | | s += "未找到出场数据-----》"; |
| | | writeTxt(s); |
| | | } |
| | | |
| | | //删除进停车场的数据 |
| | |
| | | //生成电子缴款码 |
| | | @PostMapping("park") |
| | | public Object park(Long id){ |
| | | String logs = "开始缴费流程------》"; |
| | | logs += "出场id为:"+id+",\n"; |
| | | OutPark outPark = (OutPark) outParkService.findById(id); |
| | | if(outPark.getPrice()==0){ |
| | | updateOutPark(outPark.getId(),"03"); |
| | | logs += "支付金额为0,\n"; |
| | | writeTxt(logs); |
| | | return error("本次停车无需支付费用"); |
| | | } |
| | | |
| | |
| | | List<WhiteList> all = whiteListService.findAll(specification); |
| | | for(WhiteList w : all){ |
| | | if(w.getType()==0){ |
| | | logs+=outPark.getCarNo()+"在白名单,\n"; |
| | | updateOutPark(outPark.getId(),"03"); |
| | | writeTxt(logs); |
| | | return error("本次停车无需支付费用!"); |
| | | }else{ |
| | | if(w.getParkId()!=null){ |
| | | if(w.getEndTime()!=null){ |
| | | if(w.getParkId()==outPark.getParkId()&&new Date().getTime()<w.getEndTime().getTime()){ |
| | | logs+=outPark.getCarNo()+"在特殊规则白名单,\n"; |
| | | updateOutPark(outPark.getId(),"03"); |
| | | writeTxt(logs); |
| | | return error("本次停车无需支付费用!"); |
| | | } |
| | | } |
| | |
| | | sbf.append("&signType=MD5"); |
| | | String s1 = httpsRequest(ip+"/pay/inpay","POST",sbf.toString()); |
| | | if(s1.equals("error")){ |
| | | logs += "生成执法电子缴款码失败,请联系管理员,\n"; |
| | | writeTxt(logs); |
| | | return error("生成执法电子缴款码失败,请联系管理员"); |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(s1); |
| | |
| | | if(eInfo.equals("此订单已过期")){ |
| | | outPark.setCode(System.currentTimeMillis()+""); |
| | | outParkService.save(outPark); |
| | | logs += "此订单已过期,\n"; |
| | | writeTxt(logs); |
| | | return park(id); |
| | | }else{ |
| | | logs += "此订单有异常错误,\n"; |
| | | writeTxt(logs); |
| | | return error(eInfo); |
| | | } |
| | | }else{ |
| | | String payCode = jsonObject.get("payCode").toString(); |
| | | logs += "payCode: "+payCode+",\n"; |
| | | outPark.setPayCode(payCode); |
| | | outParkService.save(outPark); |
| | | |
| | | writeTxt(logs); |
| | | addOrderRecord(outPark); |
| | | return success("生成停车电子缴款码","https://hbfs.govpay.ccb.com/online/fssm?fee=130000000001&PyfScnCgycd=01&pyfTpcd=3&BNo="+payCode); |
| | | } |
| | |
| | | orderRecordService.save(orderRecord); |
| | | } |
| | | |
| | | |
| | | private void writeTxt( 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("打印错误"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |