| | |
| | | import com.boying.util.HTTPEntityUtil; |
| | | import com.google.gson.Gson; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | @RequiredArgsConstructor |
| | | public class YCPayController { |
| | | private final OutParkService outParkService; |
| | | private final PayLogService payLogService; |
| | | 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; |
| | | private final OutParkLogService outParkLogService; |
| | | |
| | | /** |
| | | * 查询订单接口 |
| | |
| | | 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("本次停车无需支付费用"); |
| | |
| | | if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 0){ |
| | | String logs = sdf.format(new Date())+" 车牌号为:"+outPark.getCarNo()+",申请缴费2------》\n"; |
| | | writeTxt(logs); |
| | | OutParkLog byOutPark = outParkLogService.getByOutPark(outPark.getCarNo(), outPark.getId()); |
| | | byOutPark.setPayStartTime(LocalDateTime.now()); |
| | | outParkLogService.saveOrUpdate(byOutPark); |
| | | return R.ok(null,"跳转邢台银行支付"); |
| | | }else if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 1){ |
| | | return R.failed("已缴费"); |
| | |
| | | }else { |
| | | outPark.setPrice(outPark.getPrice()-enterPark.getPrice()); |
| | | outParkService.updateById(outPark); |
| | | OutParkLog byOutPark = outParkLogService.getByOutPark(outPark.getCarNo(), outPark.getId()); |
| | | byOutPark.setPayStartTime(LocalDateTime.now()); |
| | | outParkLogService.saveOrUpdate(byOutPark); |
| | | } |
| | | } |
| | | } |
| | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("encoding","UTF-8"); |
| | | map.put("signMethod","01"); |
| | | map.put("sdkAppId","8202309110000001"); |
| | | map.put("sdkAppId",systemConfigProperties.getXTYHMERID()); |
| | | map.put("txnType","1007"); |
| | | map.put("txnSubType","100702"); |
| | | map.put("txnAccType","03"); |
| | | map.put("aesWay","01"); |
| | | map.put("merId","8202309110000001"); |
| | | map.put("merName","邯郸市峰峰矿区滏源建设发展有限公司"); |
| | | map.put("backEndUrl","http://39.96.92.240:8089/ffzf/api/getResult"); |
| | | 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()+"泊车缴费"); |
| | |
| | | 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); |
| | | PayLog payLog = new PayLog(); |
| | | payLog.setOutParkId(outPark.getId()); |
| | | payLog.setCode2(respTxnSsn); |
| | | payLog.setQrCode(qrCode); |
| | | payLog.setPayTime(LocalDateTime.now()); |
| | | payLog.setTxnOrderId(outPark.getId()+""+format); |
| | | payLog.setTxnOrderTime(format); |
| | | payLog.setRespTxnTime(respTxnTime); |
| | | payLogService.save(payLog); |
| | | return R.ok(null,qrCode); |
| | | } |
| | | String respMsg = (String)map1.get("respMsg"); |
| | |
| | | */ |
| | | @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"); |
| | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("encoding","UTF-8"); |
| | | map.put("signMethod","01"); |
| | | map.put("sdkAppId","8202309110000001"); |
| | | map.put("sdkAppId",systemConfigProperties.getXTYHMERID()); |
| | | map.put("txnType","1006"); |
| | | map.put("txnSubType","100603"); |
| | | map.put("txnAccType","02"); |
| | | map.put("secMerAppId","wx46e756aed958f895"); |
| | | map.put("secMerAppId",systemConfigProperties.getXTYHAPPID()); |
| | | map.put("txnSubOpenid",openId); |
| | | map.put("txnProductId",outPark.getId()+""); |
| | | map.put("aesWay","01"); |
| | | map.put("merId","8202309110000001"); |
| | | map.put("merName","邯郸市峰峰矿区滏源建设发展有限公司"); |
| | | map.put("backEndUrl","http://39.96.92.240:8089/ffzf/api/getResult"); |
| | | 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()+"泊车缴费"); |
| | |
| | | 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); |
| | | PayLog payLog = new PayLog(); |
| | | payLog.setOutParkId(outPark.getId()); |
| | | payLog.setCode2(respTxnSsn); |
| | | payLog.setPayTime(LocalDateTime.now()); |
| | | payLog.setTxnOrderId(outPark.getId()+""+format); |
| | | payLog.setTxnOrderTime(format); |
| | | payLog.setRespTxnTime(respTxnTime); |
| | | payLogService.save(payLog); |
| | | return R.ok(resultMap,null); |
| | | } |
| | | String respMsg = (String)map1.get("respMsg"); |
| | |
| | | if(respCode != null){ |
| | | if(respCode.equals("0000")){ |
| | | //交易成功,根据流水号查询出场记录 |
| | | OutPark byPayCode = outParkService.findByPayCode(respTxnSsn); |
| | | if(byPayCode == null){ |
| | | return R.failed("未查询到订单"); |
| | | PayLog payLog = payLogService.findByPayCode(respTxnSsn); |
| | | if(payLog == 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); |
| | | OutPark byPayCode = outParkService.getById(payLog.getOutParkId()); |
| | | writeTxt2(byPayCode.getId()+"收到回执\n"); |
| | | if(byPayCode == null){ |
| | | return R.failed("未查询到订单"); |
| | | }else { |
| | | if(byPayCode.getStatus() == 1){ |
| | | return R.ok(null,"订单已支付"); |
| | | }else { |
| | | OutParkLog byOutPark = outParkLogService.getByOutPark(byPayCode.getCarNo(), byPayCode.getId()); |
| | | byOutPark.setPayEndTime(LocalDateTime.now()); |
| | | outParkLogService.saveOrUpdate(byOutPark); |
| | | 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,"回调成功"); |
| | | } |
| | | } |
| | | return R.ok(null,"回调成功"); |
| | | } |
| | | }else if(respCode.equals("0002") || respCode.equals("0003") || respCode.equals("0003") || respCode.equals("0012")){ |
| | | //交易成功,超时,未明,稍后发起查询 |
| | |
| | | //更新出场 |
| | | public void updateOutPark(Integer outParkId, String status){ |
| | | OutPark outPark = outParkService.getById(outParkId); |
| | | if(outPark!=null){ |
| | | if(outPark!=null && outPark.getEnterTime() !=null){ |
| | | if(status.equals("03")){ |
| | | outPark.setStatus(1); |
| | | outParkService.saveOrUpdate(outPark); |