From d45f3f7467e76477e8babbefd5844975bdff7af1 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 28 十一月 2024 15:45:58 +0800 Subject: [PATCH] 修改bug --- UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java | 105 ++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 85 insertions(+), 20 deletions(-) diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java index 43aa8b6..a3e2d80 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.google.api.client.http.UrlEncodedParser; +import com.stylefeng.guns.core.util.MD5Util; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService; import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; @@ -31,6 +32,8 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.http.client.utils.URLEncodedUtils; import org.bouncycastle.util.encoders.UrlBase64Encoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.util.StringUtils; @@ -55,6 +58,8 @@ @RestController @RequestMapping("") public class OrderController { + + private Logger log = LoggerFactory.getLogger(OrderController.class); @Autowired private IOrderTaxiService orderTaxiService; @@ -118,6 +123,14 @@ @Resource private UserActivityDiscount1Mapper userActivityDiscount1Mapper; + + @Resource + private RedisUtil redisUtil; + + + + + /** * 获取正在进行中的订单 @@ -264,10 +277,10 @@ for (Map<String, Object> map : maps) { Integer orderType = Integer.valueOf(map.get("orderType").toString()); if(1 == orderType){ - map.put("name", language == 1 ? "打车订单取消" : language == 2 ? "Ride order cancelled" : "Commande de trajet annulée"); + map.put("name", language == 1 ? "打车订单取消" : language == 2 ? "Ride order cancelled" : "Commande de course annulée"); } if(4 == orderType){ - map.put("name", language == 1 ? "包裹订单取消" : language == 2 ? "Parcel order cancellation" : "Annulation de commande de livraison"); + map.put("name", language == 1 ? "包裹订单取消" : language == 2 ? "Delivery order cancelled" : "Commande de livraison annulée"); } } List<Map<String, Object>> list = orderPrivateCarService.queryMyTravelRecord(language, uid);//专车 @@ -849,9 +862,10 @@ @ApiImplicitParam(value = "终点经度", name = "elon", required = true, dataType = "double"), @ApiImplicitParam(value = "终点纬度", name = "elat", required = true, dataType = "double") }) - public ResultUtil<BaseWarpper> queryExpectedTime(Double slon, Double slat, Double elon, Double elat){ + public ResultUtil<BaseWarpper> queryExpectedTime(Double slon, Double slat, Double elon, Double elat, HttpServletRequest request){ try { - return orderService.queryExpectedTime(slon, slat, elon, elat); + Integer uid = userInfoService.getUserIdFormRedis(request); + return orderService.queryExpectedTime(uid, slon, slat, elon, elat); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); @@ -924,20 +938,24 @@ if(null == uid){ return ResultUtil.tokenErr(); } - reason = reason.replaceAll("& #40;", "(") - .replaceAll("& #41;", ")") - .replaceAll("& #40;", "(") - .replaceAll("& #41;", ")") - .replaceAll("& #39;", "'") - .replaceAll("& lt;", "<") - .replaceAll("& gt;", ">"); - remark = remark.replaceAll("& #40;", "(") - .replaceAll("& #41;", ")") - .replaceAll("& #40;", "(") - .replaceAll("& #41;", ")") - .replaceAll("& #39;", "'") - .replaceAll("& lt;", "<") - .replaceAll("& gt;", ">"); + if(ToolUtil.isNotEmpty(reason)){ + reason = reason.replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #39;", "'") + .replaceAll("& lt;", "<") + .replaceAll("& gt;", ">"); + } + if(ToolUtil.isNotEmpty(remark)){ + remark = remark.replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #40;", "(") + .replaceAll("& #41;", ")") + .replaceAll("& #39;", "'") + .replaceAll("& lt;", "<") + .replaceAll("& gt;", ">"); + } switch (orderType){ case 1: return orderPrivateCarService.addCancle(id, reason, remark, uid, lon, lat, address, language); @@ -1027,6 +1045,13 @@ if(null == uid){ return ResultUtil.tokenErr(); } + String format = String.format("uid=%s&id=%s&orderType=%s&payType=%s&type=%s", uid, id, orderType, payType, type); + String key = MD5Util.encrypt(format); + String value = redisUtil.getValue(key); + if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ + return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); + } + redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); switch (orderType){ case 1: return orderPrivateCarService.cancleOrderPrivateCar(id, payType, bankCardId, cancleId, type, language); @@ -1248,6 +1273,14 @@ if(null == uid){ return ResultUtil.tokenErr(); } + String format = String.format("uid=%s&payType=%s&orderId=%s&orderType=%s", uid, payType, orderId, orderType); + String key = MD5Util.encrypt(format); + String value = redisUtil.getValue(key); + if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ + return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); + } + redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); + switch (orderType){ case 1: return orderPrivateCarService.payPrivateCarOrder(payType, bankCardId, orderId, couponId, redDeduction, type, language); @@ -1400,6 +1433,7 @@ @ResponseBody @PostMapping("/base/wxCancelOrderTaxi") public CallbackResponse wxCancelOrderTaxi(@RequestBody CallbackRequest callbackRequest){ + log.info("取消订单支付回调结果:{}", JSON.toJSONString(callbackRequest)); CallbackResponse callbackResponse = new CallbackResponse(); try { /** @@ -1451,6 +1485,7 @@ }catch (Exception e){ e.printStackTrace(); } + log.info("取消订单支付回调处理结束:{}", JSON.toJSONString(callbackResponse)); return callbackResponse; } @@ -1502,6 +1537,7 @@ @ResponseBody @PostMapping("/base/wxPayOrderTaxi") public CallbackResponse wxPayOrderTaxi(@RequestBody CallbackRequest callbackRequest){ + log.info("订单完成支付回调结果:{}", JSON.toJSONString(callbackRequest)); CallbackResponse callbackResponse = new CallbackResponse(); try { /** @@ -1556,6 +1592,7 @@ }catch (Exception e){ e.printStackTrace(); } + log.info("订单完成支付回调处理结束:{}", JSON.toJSONString(callbackResponse)); return callbackResponse; } @@ -1752,11 +1789,13 @@ return ResultUtil.tokenErr(); } Double payMoney = 0D; - Integer companyId = 1; switch (orderType){ case 1: OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); Double orderMoney = orderPrivateCar.getOrderMoney(); + if(null == orderMoney){ + orderMoney = 0D; + } UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(orderPrivateCar.getCompanyId()); if(null != query2){ Integer orderNum=orderPrivateCarService.selectCount(new EntityWrapper<OrderPrivateCar>().eq("userId", uid).eq("activityId",query2.getId()).last(" and to_days(getoffTime) = to_days(now())")); @@ -1772,11 +1811,14 @@ case 4: OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); Double orderMoney1 = orderLogistics.getOrderMoney(); + if(null == orderMoney1){ + orderMoney1 = 0D; + } UserActivityDiscount1 query1 = userActivityDiscount1Mapper.query(orderLogistics.getCompanyId()); if(null != query1){ Integer orderNum=orderLogisticsService.selectCount(new EntityWrapper<OrderLogistics>().eq("userId", uid).eq("activityId",query1.getId()).last(" and to_days(getoffTime) = to_days(now())")); if(query1.getDistance()*1000>orderLogistics.getMileage() && query1.getOrderNum()>orderNum){ - Double special = query1.getSpecial(); + Double special = query1.getLogistics(); if(null != special){ double v = new BigDecimal(orderMoney1).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); payMoney = v; @@ -1801,4 +1843,27 @@ return ResultUtil.runErr(); } } + + + @ResponseBody + @PostMapping("/api/order/getNewTripId") + @ApiOperation(value = "获取google预定tripid【2.0】", tags = {"用户端-首页"}, notes = "") + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") + }) + public ResultUtil<String> getNewTripId(HttpServletRequest request){ + try { + Integer uid = userInfoService.getUserIdFormRedis(request); + if(null == uid){ + return ResultUtil.tokenErr(); + } + String randomCode = UUIDUtil.getRandomCode(); + redisUtil.setStrValue("trip" + uid, randomCode); + log.warn("生成tripId:{} {}", System.currentTimeMillis(), randomCode); + return ResultUtil.success(randomCode); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtil.runErr(); + } + } } -- Gitblit v1.7.1