| | |
| | | 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; |
| | |
| | | return R.ok(userCouponVo); |
| | | } |
| | | @PostMapping("/inner/appUserCoupon/useUserCoupon") |
| | | public R useUserCoupon(@RequestBody UseUserCouponDto dto) { |
| | | 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()); |
| | | } |
| | | |
| | | |
| | |
| | | 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); |
| | | |
| | | } |
| | |
| | | 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); |
| | | |
| | | /** |
| | | * 获取历史订单列表 |
| | |
| | | } |
| | | |
| | | @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")); |
| | |
| | | XpOrder order = this.getById(dto.getOrderId()); |
| | | order.setStatus(9); |
| | | order.setAppUserId(null); |
| | | baseMapper.updateById(order); |
| | | |
| | | |
| | | if(order.getCouponId()!=null){ |
| | | UseUserCouponDto useUserCouponDto = new UseUserCouponDto(); |
| | | useUserCouponDto.setUserCouponId(order.getCouponId()); |
| | | xpAppUserCouponClient.useUserCoupon(useUserCouponDto); |
| | | } |
| | | 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(); |
| | | } |
| | | |