zhibing.pu
2024-08-27 8f39e870ca9519d8a8190c038d15a030149de98e
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.google.api.client.http.UrlEncodedParser;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService;
import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity;
@@ -27,8 +28,12 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.http.client.utils.URLEncodedUtils;
import org.bouncycastle.util.encoders.UrlBase64Encoder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -36,6 +41,9 @@
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -110,6 +118,14 @@
    
    @Resource
    private UserActivityDiscount1Mapper userActivityDiscount1Mapper;
    @Resource
    private RedisUtil redisUtil;
    /**
     * 获取正在进行中的订单
@@ -201,6 +217,9 @@
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            UserInfo userInfo = userInfoService.selectById(uid);
            userInfo.setLanguage(language);
            userInfoService.updateById(userInfo);
            List<Map<String, Object>> list = null;
            switch (type){
                case 1:
@@ -253,10 +272,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);//专车
@@ -639,7 +658,31 @@
    })
    public ResultUtil queryTrack_(Integer orderId, Integer orderType){
        try {
            List<Map<String, Object>> list = orderPositionService.queryTrack(orderId, orderType);
            List<Map<String, Object>> list = new ArrayList<>();
                    switch (orderType){
                case 1:
                    OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
                    Map<String, Object> map = new HashMap<>();
                    map.put("lon", orderPrivateCar.getStartLon());
                    map.put("lat", orderPrivateCar.getStartLat());
                    list.add(map);
                    map = new HashMap<>();
                    map.put("lon", orderPrivateCar.getEndLon());
                    map.put("lat", orderPrivateCar.getEndLat());
                    list.add(map);
                    break;
                case 4:
                    OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId);
                    Map<String, Object> map1 = new HashMap<>();
                    map1.put("lon", orderLogistics.getStartLon());
                    map1.put("lat", orderLogistics.getStartLat());
                    list.add(map1);
                    map1 = new HashMap<>();
                    map1.put("lon", orderLogistics.getEndLon());
                    map1.put("lat", orderLogistics.getEndLat());
                    list.add(map1);
                    break;
            }
            return ResultUtil.success(list);
        }catch (Exception e){
            e.printStackTrace();
@@ -814,9 +857,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();
@@ -889,6 +933,24 @@
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            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);
@@ -909,8 +971,9 @@
            return ResultUtil.runErr();
        }
    }
    /**
     * 取消订单退款回调
     * @param request
@@ -1705,14 +1768,41 @@
            switch (orderType){
                case 1:
                    OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
                    payMoney = orderPrivateCar.getPayMoney();
                    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())"));
                        if(query2.getDistance()*1000>orderPrivateCar.getMileage() && query2.getOrderNum()>orderNum){
                            Double special = query2.getSpecial();
                            if(null != special){
                                double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
                                payMoney = v;
                            }
                        }
                    }
                    break;
                case 4:
                    OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId);
                    payMoney = orderLogistics.getPayMoney();
                    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.getLogistics();
                            if(null != special){
                                double v = new BigDecimal(orderMoney1).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
                                payMoney = v;
                            }
                        }
                    }
                    break;
            }
            Double aDouble = userRedPacketRecordService.queryRemainingAmount(uid);
            Map<String, Object> map = new HashMap<>();
            map.put("redTotal", aDouble);
@@ -1721,7 +1811,7 @@
                map.put("deductionAmount", 0D);
                return ResultUtil.success(map);
            }
            Double deductionAmount = new BigDecimal(payMoney).multiply(redEnvelopePaymentSettings.getDeductionRatio().divide(new BigDecimal(100))).doubleValue();
            Double deductionAmount = new BigDecimal(payMoney).multiply(redEnvelopePaymentSettings.getDeductionRatio().divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
            map.put("deductionAmount", deductionAmount);
            return ResultUtil.success(map);
        }catch (Exception e){
@@ -1729,4 +1819,26 @@
            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);
            return ResultUtil.success(randomCode);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
}