From 0dbcef10ee43cdab704ecf5e81fec50e884569e5 Mon Sep 17 00:00:00 2001 From: kongdeqiang <kongdeqiang960204@163.com> Date: 星期三, 16 十月 2024 15:14:18 +0800 Subject: [PATCH] fix:更新手机号入场 --- src/main/java/com/boying/controller/phone/YCPayController.java | 141 ++++++++++++++++++++++++++++++++++------------ 1 files changed, 104 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/boying/controller/phone/YCPayController.java b/src/main/java/com/boying/controller/phone/YCPayController.java index c48444d..a19093c 100644 --- a/src/main/java/com/boying/controller/phone/YCPayController.java +++ b/src/main/java/com/boying/controller/phone/YCPayController.java @@ -2,7 +2,6 @@ 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; @@ -13,14 +12,15 @@ 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.data.redis.core.StringRedisTemplate; 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; @@ -36,6 +36,7 @@ import java.util.List; import java.util.Map; + /** * @author kdq * @version 1.0.0 @@ -48,14 +49,19 @@ @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; + private final StringRedisTemplate redisTemplate; + /** * 鏌ヨ璁㈠崟鎺ュ彛 @@ -141,6 +147,37 @@ } } + /** + * 鍒ゆ柇鏀粯绔槸鍚﹀凡缁忔敮浠樿繃 + * @param id + * @return + */ + @PostMapping("parkJudg") + public Object parkJudg(Long id){ + if(id == null){ + return R.failed("鏈壘鍒版暟鎹紝璇风◢鍚庨噸鏂扮偣鍑�"); + } + OutPark outPark = outParkService.getById(id); + if(outPark == null){ + return R.failed("鏈壘鍒版暟鎹紝璇风◢鍚庨噸鏂扮偣鍑�"); + } + if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 0){ + return R.ok(1,"璁㈠崟宸叉彁浜ゆ敮浠樿姹�"); + } + if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 1){ + return R.failed(0,"璁㈠崟宸茬即璐�"); + } + if(StringUtils.isBlank(outPark.getPayCode())){ + OutPark by10min = outParkService.findBy10min(outPark.getCarNo(), outPark.getParkId(), outPark.getCreateTime(),outPark.getId()); + if(by10min !=null){ + return R.ok(1,"璁㈠崟宸叉彁浜ゆ敮浠樿姹�"); + }else { + return R.ok(0,"璇锋彁浜ゆ敮浠�"); + } + } + return R.failed(0,"璇锋彁浜ゆ敮浠�"); + } + /** * 鍒ゆ柇鏄惁缂磋垂 @@ -149,11 +186,14 @@ 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() @@ -180,6 +220,9 @@ 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("宸茬即璐�"); @@ -197,6 +240,9 @@ }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); } } } @@ -220,14 +266,14 @@ 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()+"娉婅溅缂磋垂"); @@ -267,13 +313,15 @@ 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"); @@ -296,6 +344,7 @@ */ @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"); @@ -304,17 +353,17 @@ 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()+"娉婅溅缂磋垂"); @@ -365,12 +414,14 @@ 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"); @@ -428,18 +479,31 @@ 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")){ //浜ゆ槗鎴愬姛锛岃秴鏃讹紝鏈槑锛岀◢鍚庡彂璧锋煡璇� @@ -644,10 +708,13 @@ //鏇存柊鍑哄満 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); + //缂撳瓨鍦╮edis閲� + String jsonValue = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue); } } } -- Gitblit v1.9.1