Merge remote-tracking branch 'origin/master'
| | |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | |
| | | return R.ok(userCouponVo); |
| | | } |
| | | @PostMapping("/inner/appUserCoupon/useUserCoupon") |
| | | public R useUserCoupon(@RequestBody UseUserCouponDto dto) { |
| | | XpAppUserCoupon appUserCoupon = xpAppUserCouponService.getById(dto.getUserId()); |
| | | public R<BigDecimal> useUserCoupon(@RequestBody UseUserCouponDto dto) { |
| | | XpAppUserCoupon appUserCoupon = xpAppUserCouponService.getById(dto.getUserCouponId()); |
| | | appUserCoupon.setStatus(2); |
| | | appUserCoupon.setUseTime(LocalDateTime.now()); |
| | | appUserCoupon.setAppUserId(null); |
| | | xpAppUserCouponService.updateById(appUserCoupon); |
| | | return R.ok(); |
| | | return R.ok(appUserCoupon.getMoney()); |
| | | } |
| | | |
| | | |
| | |
| | | xpAppUserCoupon.setMoney(xpCoupon.getAmount()); |
| | | xpAppUserCoupon.setCouponId(dto.getCouponId()); |
| | | xpAppUserCoupon.setAppUserId(uid); |
| | | xpAppUserCoupon.setExpirationTime(LocalDateTime.now().plusDays(100)); |
| | | xpAppUserCoupon.setExpirationTime(LocalDateTime.now().plusDays(7)); |
| | | xpAppUserCoupon.setStatus(1); |
| | | xpAppUserCoupon.setCouponType(xpCoupon.getCouponType()); |
| | | xpAppUserCoupon.setPhone(phone); |
| | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * 小程序用户Feign客户端 |
| | | * |
| | |
| | | @PostMapping("/inner/appUserCoupon/getUserCoupon") |
| | | R<UserCouponVo> getUserCoupon(@RequestBody GetUserCouponDto dto); |
| | | @PostMapping("/inner/appUserCoupon/useUserCoupon") |
| | | R useUserCoupon(@RequestBody UseUserCouponDto dto); |
| | | R<BigDecimal> useUserCoupon(@RequestBody UseUserCouponDto dto); |
| | | |
| | | } |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime expirationTime; |
| | | |
| | | @ApiModelProperty(value = "使用时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime useTime; |
| | | |
| | | @ApiModelProperty(value = "状态(1=未使用,2=已使用,3=已过期)") |
| | | private Integer status; |
| | | |
| | |
| | | if (userCouponVo != null) { |
| | | if(userCouponVo.getMoney()>fareVo.getOriginalFare()){ |
| | | fareVo.setDiscountAmount(fareVo.getOriginalFare()); |
| | | fareVo.setFinalFare(0.0); |
| | | fareVo.setFinalFare(0.00); |
| | | }else { |
| | | fareVo.setDiscountAmount(userCouponVo.getMoney()); |
| | | fareVo.setFinalFare(fareVo.getOriginalFare() - fareVo.getDiscountAmount()); |
| | | } |
| | | if(fareVo.getFinalFare()>0){ |
| | | fareVo.setSystemDiscount(fareVo.getFinalFare()); |
| | | fareVo.setFinalFare(0.0); |
| | | fareVo.setFinalFare(0.00); |
| | | } |
| | | fareVo.setCouponId(userCouponVo.getId()); |
| | | } else { |
| | | fareVo.setDiscountAmount(0.0); |
| | | fareVo.setDiscountAmount(0.00); |
| | | fareVo.setFinalFare(fareVo.getOriginalFare()); |
| | | fareVo.setSystemDiscount(fareVo.getFinalFare()); |
| | | fareVo.setFinalFare(0.0); |
| | | fareVo.setFinalFare(0.00); |
| | | } |
| | | |
| | | // 10. 检查等待时间 |
| | |
| | | |
| | | // 12. 设置费用信息 |
| | | fareVo.setFinalFareStr(new BigDecimal(fareVo.getFinalFare()).setScale(2, RoundingMode.HALF_UP).toString()); |
| | | if("0.00".equals(fareVo.getFinalFareStr())){ |
| | | fareVo.setFinalFareStr("0.0"); |
| | | } |
| | | fareVo.setOriginalFare(new BigDecimal(fareVo.getOriginalFare()).setScale(2,RoundingMode.HALF_UP).doubleValue()); |
| | | fareVo.setSystemDiscount(new BigDecimal(fareVo.getSystemDiscount() == null ? 0 : fareVo.getSystemDiscount()).setScale(2,RoundingMode.HALF_UP).doubleValue()); |
| | | routeAndFareVo.setFareEstimate(fareVo); |
| | |
| | | @ApiOperation(value = "获取历史下单成功起点10条数据列表", tags = {"小程序-获取历史下单成功起点10条数据列表"}) |
| | | @GetMapping("/base/v1/mini-program/history/startPoints") |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<List<XpHistoryStartPointsVo>> getHistoryStartPoints(double lon, double lat, HttpServletRequest request) { |
| | | public R<List<XpHistoryStartPointsVo>> getHistoryStartPoints(double lon, double lat,Long electronicAreaId, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpOrderService.getHistoryStartPoints(uid, lon, lat)); |
| | | return R.ok(xpOrderService.getHistoryStartPoints(uid, lon, lat,electronicAreaId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "获取历史下单成功终点10条数据列表", tags = {"小程序-获取历史下单成功终点10条数据列表"}) |
| | | @GetMapping("/base/v1/mini-program/history/endPoints") |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<List<XpHistoryEndPointsVo>> getHistoryEndPoints(double lon, double lat, HttpServletRequest request) { |
| | | public R<List<XpHistoryEndPointsVo>> getHistoryEndPoints(double lon, double lat,Long electronicAreaId, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpOrderService.getHistoryEndPoints(uid, lon, lat)); |
| | | return R.ok(xpOrderService.getHistoryEndPoints(uid, lon, lat,electronicAreaId)); |
| | | } |
| | | |
| | | |
| | |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<XpHistoryStartPointsVo> getHistoryStartPoints(String uid,double lon,double lat); |
| | | List<XpHistoryStartPointsVo> getHistoryStartPoints(String uid,double lon,double lat,Long electronicAreaId); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<XpHistoryEndPointsVo> getHistoryEndPoints(String uid, double lon, double lat); |
| | | List<XpHistoryEndPointsVo> getHistoryEndPoints(String uid, double lon, double lat,Long electronicAreaId); |
| | | |
| | | /** |
| | | * 获取历史订单列表 |
| | |
| | | // 更新订单状态为已完成(10) |
| | | this.lambdaUpdate().set(XpOrder::getStatus, 10) |
| | | .eq(XpOrder::getId, order.getId()).update(); |
| | | |
| | | |
| | | // 消息推送 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", order.getId().toString()); |
| | | content.put("status", OrderStatusEnum.COMPLETED.getCode()); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", com.alibaba.fastjson2.JSONObject.toJSONString(content)); |
| | | params.put("timestamp", new Date().getTime() + ""); |
| | | String message = JSONObject.toJSONString(params); |
| | | SendMessageDTO sendMessageDTO = new SendMessageDTO(); |
| | | sendMessageDTO.setMessage(message); |
| | | sendMessageDTO.setAppUserId(String.valueOf(order.getAppUserId())); |
| | | xpPushMessageClient.sendStatus(sendMessageDTO); |
| | | log.info("运营人员取消订单成功,推送乘客消息完成"); |
| | | log.info("订单关闭成功,订单ID: {}, 操作人: {}", order.getId(), SecurityUtils.getUsername()); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<XpHistoryStartPointsVo> getHistoryStartPoints(String uid, double lon, double lat) { |
| | | public List<XpHistoryStartPointsVo> getHistoryStartPoints(String uid, double lon, double lat,Long electronicAreaId) { |
| | | // |
| | | List<XpOrder> xpOrders = this.baseMapper.getHistoryStartPoints(Long.valueOf(uid)); |
| | | // selectList(new LambdaQueryWrapper<XpOrder>().eq(XpOrder::getAppUserId, Long.parseLong(uid)).orderByDesc(BaseModel::getCreateTime).last("LIMIT 10")); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<XpHistoryEndPointsVo> getHistoryEndPoints(String uid, double lon, double lat) { |
| | | public List<XpHistoryEndPointsVo> getHistoryEndPoints(String uid, double lon, double lat,Long electronicAreaId) { |
| | | // |
| | | List<XpOrder> xpOrders = this.baseMapper.getHistoryEndPoints(Long.valueOf(uid)); |
| | | // selectList(new LambdaQueryWrapper<XpOrder>().eq(XpOrder::getAppUserId, Long.parseLong(uid)).orderByDesc(BaseModel::getCreateTime).last("LIMIT 10")); |
| | |
| | | } |
| | | String durationAndMileage = key.split("\\|")[2]; |
| | | startDetail.setDuration(Double.valueOf(durationAndMileage.split("&")[0])); |
| | | startDetail.setMileage(new BigDecimal(durationAndMileage.split("&")[1])); |
| | | startDetail.setMileage(new BigDecimal(durationAndMileage.split("&")[1]).multiply(BigDecimal.valueOf(1000))); |
| | | start.add(startDetail); |
| | | } |
| | | // 封装里程费 |
| | |
| | | // 封装时长费 |
| | | FareBreakdownDetailVo timeDetail = new FareBreakdownDetailVo(); |
| | | if (key.contains("时长费")) { |
| | | timeDetail.setType(startDetail.getType()); |
| | | if(key.contains("普通时段")){ |
| | | timeDetail.setType(1); |
| | | } |
| | | if(key.contains("夜间行驶")){ |
| | | timeDetail.setType(2); |
| | | } |
| | | if(key.contains("高峰")){ |
| | | timeDetail.setType(3); |
| | | } |
| | | if(key.contains("节假")){ |
| | | timeDetail.setType(4); |
| | | } |
| | | |
| | | timeDetail.setMoney(stringBigDecimalEntry.getValue()); |
| | | timeDetail.setDuration(Double.valueOf(key.split("&")[1])); |
| | | duration.add(timeDetail); |
| | |
| | | if (key.contains("远途费")) { |
| | | longDetail.setType(startDetail.getType()); |
| | | longDetail.setMoney(stringBigDecimalEntry.getValue()); |
| | | longDetail.setMileage(new BigDecimal(key.split("&")[1])); |
| | | // longDetail.setMileage(new BigDecimal(key.split("&")[1])); |
| | | longDistance.add(longDetail); |
| | | } |
| | | } |
| | |
| | | XpOrder order = this.getById(dto.getOrderId()); |
| | | order.setStatus(9); |
| | | order.setAppUserId(null); |
| | | |
| | | |
| | | if(order.getCouponId()!=null){ |
| | | UseUserCouponDto useUserCouponDto = new UseUserCouponDto(); |
| | | useUserCouponDto.setUserCouponId(order.getCouponId()); |
| | | R<BigDecimal> decimalR = xpAppUserCouponClient.useUserCoupon(useUserCouponDto); |
| | | if(decimalR.getCode()==200){ |
| | | order.setCouponMoney(decimalR.getData()); |
| | | if(order.getCouponMoney().compareTo(order.getOrderMoney())>0){ |
| | | order.setPayMoney(BigDecimal.ZERO); |
| | | order.setCouponMoney(order.getOrderMoney()); |
| | | }else { |
| | | order.setPayMoney(order.getOrderMoney().subtract(decimalR.getData())); |
| | | } |
| | | } |
| | | |
| | | } |
| | | baseMapper.updateById(order); |
| | | return R.ok(); |
| | | } |
| | |
| | | // 模拟总里程 25.0 km,以触发多级远途加价 |
| | | double totalMillige = 2.984; |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.set(2026, Calendar.APRIL, 11, 15, 58, 15); |
| | | cal.set(2026, Calendar.APRIL, 11, 15, 57, 50); |
| | | orderTime = cal.getTime(); |
| | | // 模拟 GPS 轨迹点 |
| | | List<GpsPoint> points = createMockGpsPoints(orderTime); |
| | |
| | | public long getLocatetime() { return locatetime; } |
| | | } |
| | | |
| | | private static PricingConfig setupMockConfig() { |
| | | private static PricingConfig setupMockConfig() { |
| | | PricingConfig config = new PricingConfig(); |
| | | config.peaks.add(new PricingRule("高峰期", "04:00", "05:00", 15, 1, 10, 4, 4)); |
| | | config.peaks.add(new PricingRule("高峰期", "15:00", "16:00", 15, 1, 10, 4, 4)); |
| | | config.night = new PricingRule("夜间行驶", "20:04", "23:00", 15, 1, 10, 3, 3); |
| | | config.holiday = new PricingRule("节假日", "00:00", "23:59", 20, 1, 10, 4, 4); |
| | | config.normals.add(new PricingRule("普通时段", "00:00", "23:59", 10.0, 1, 10.0, 3, 3)); |
| | | config.peaks.add(new PricingRule("高峰期", "04:00", "05:00", 15, 1, 1, 4, 4)); |
| | | config.peaks.add(new PricingRule("高峰期", "15:00", "16:00", 15, 1, 1, 4, 4)); |
| | | config.night = new PricingRule("夜间行驶", "20:04", "23:00", 15, 1, 1, 3, 3); |
| | | config.holiday = new PricingRule("节假日", "00:00", "23:59", 20, 1, 1, 4, 4); |
| | | config.normals.add(new PricingRule("普通时段", "00:00", "23:59", 10.0, 1, 1, 3, 3)); |
| | | |
| | | // --- 远途加价区间配置 (关键修改) --- |
| | | // 1. 超过 num1(12) 不足 num2(20), 加收 num3(1.2) |