luodangjia
2024-07-17 736ab0090700c75af37b8a3456b01609e4e2d329
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -47,6 +47,7 @@
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
@@ -198,6 +199,15 @@
    
    @Autowired
    private IUserActivityRedenvelopeService userActivityRedenvelopeService;
    @Autowired
    private FleetEngineUtil fleetEngineUtil;
    @Resource
    private CarModelMapper carModelMapper;
    @Autowired
    private ICarService carService;
@@ -681,7 +691,31 @@
    
        orderLogistics.setIsReassign(1);
        orderLogistics.setIsDelete(1);
        orderLogistics.setTripId(UUIDUtil.getRandomCode());
        this.insert(orderLogistics);
        String vehicleId = null;
        if(null != orderLogistics.getDriverId()){
            Driver driver = driverService.selectById(orderLogistics.getDriverId());
            Car car = carMapper.selectById(driver.getCarId());
            if(!StringUtils.hasLength(car.getVehicleId())){
                car.setVehicleId(UUIDUtil.getRandomCode());
                carMapper.updateById(car);
            }
            //查询车辆信息,没有则创建信息
            String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
            if(ToolUtil.isEmpty(vehicles)){
                CarModel carModel = carModelMapper.selectById(car.getCarModelId());
                fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
            }
        }
        //创建行程数据
        fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(),
                orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
    
        if(orderSource == 2){//扫码下单
            new Thread(new Runnable() {
@@ -802,6 +836,7 @@
        BaseWarpper baseWarpper = new BaseWarpper();
        baseWarpper.setState(orderLogistics.getState());
        baseWarpper.setId(orderLogistics.getId());
        baseWarpper.setContent(orderLogistics.getTripId());
        return ResultUtil.success(baseWarpper);
    }
    
@@ -836,7 +871,7 @@
        if(null != couponId){
            //TODO 待翻译
            if(null != redDeduction && 1 == redDeduction){
                return ResultUtil.error(language == 1 ? "优惠券和红包不能同时使用" : language == 2 ? "" : "", "");
                return ResultUtil.error(language == 1 ? "优惠券和红包不能同时使用" : language == 2 ? "Coupons and lucky-promo cannot be used at the same time." : "Les coupons et les bonus ne peuvent pas être utilisés en même temps", "");
            }
            userCouponRecord = userCouponRecordService.selectById(couponId);
            if(userCouponRecord.getCompanyId() != orderLogistics.getCompanyId()){
@@ -1100,6 +1135,13 @@
                    title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                    Element xcf_chinese = document.getElementById("xcf_chinese");
                    xcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element bcj_chinese = document.getElementById("bcj_chinese");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_chinese_div = document.getElementById("bcj_chinese_div");
                        bcj_chinese_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_chinese = document.getElementById("yhq_chinese");
                        yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
@@ -1160,6 +1202,13 @@
                    title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip ");
                    Element xcf_english = document.getElementById("xcf_english");
                    xcf_english.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element bcj_english = document.getElementById("bcj_english");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_english.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_english_div = document.getElementById("bcj_english_div");
                        bcj_english_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_english = document.getElementById("yhq_english");
                        yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
@@ -1220,6 +1269,13 @@
                    title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le ");
                    Element xcf_french = document.getElementById("xcf_french");
                    xcf_french.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element bcj_french = document.getElementById("bcj_french");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_french.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_french_div = document.getElementById("bcj_french_div");
                        bcj_french_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_french = document.getElementById("yhq_french");
                        yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
@@ -1503,6 +1559,13 @@
                    title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                    Element xcf_chinese = document.getElementById("xcf_chinese");
                    xcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element bcj_chinese = document.getElementById("bcj_chinese");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_chinese_div = document.getElementById("bcj_chinese_div");
                        bcj_chinese_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_chinese = document.getElementById("yhq_chinese");
                        yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
@@ -1563,6 +1626,13 @@
                    title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip ");
                    Element xcf_english = document.getElementById("xcf_english");
                    xcf_english.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element bcj_english = document.getElementById("bcj_english");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_english.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_english_div = document.getElementById("bcj_english_div");
                        bcj_english_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_english = document.getElementById("yhq_english");
                        yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
@@ -1623,6 +1693,13 @@
                    title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le ");
                    Element xcf_french = document.getElementById("xcf_french");
                    xcf_french.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element bcj_french = document.getElementById("bcj_french");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_french.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_french_div = document.getElementById("bcj_french_div");
                        bcj_french_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_french = document.getElementById("yhq_french");
                        yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
@@ -2008,6 +2085,13 @@
                    title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                    Element xcf_chinese = document.getElementById("xcf_chinese");
                    xcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element bcj_chinese = document.getElementById("bcj_chinese");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_chinese_div = document.getElementById("bcj_chinese_div");
                        bcj_chinese_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_chinese = document.getElementById("yhq_chinese");
                        yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
@@ -2068,6 +2152,13 @@
                    title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip ");
                    Element xcf_english = document.getElementById("xcf_english");
                    xcf_english.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element bcj_english = document.getElementById("bcj_english");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_english.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_english_div = document.getElementById("bcj_english_div");
                        bcj_english_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_english = document.getElementById("yhq_english");
                        yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
@@ -2128,6 +2219,13 @@
                    title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le ");
                    Element xcf_french = document.getElementById("xcf_french");
                    xcf_french.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element bcj_french = document.getElementById("bcj_french");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_french.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_french_div = document.getElementById("bcj_french_div");
                        bcj_french_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_french = document.getElementById("yhq_french");
                        yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
@@ -2469,7 +2567,10 @@
            driver.setState(2);
            driverService.updateById(driver);
        }
        //修改行程信息
        fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null);
        //添加消息
        systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功取消包裹订单,谢谢使用!" : language == 2 ? "You've cancelled the delivery order successfully, thank you for using I-GO "
                : "Vous avez annulé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1);
@@ -2560,6 +2661,26 @@
        }
        if(state == 11){
            map.put("state", map.get("oldState"));
        }
        if(Integer.valueOf(String.valueOf(map.get("state"))) != 8 && Integer.valueOf(String.valueOf(map.get("state"))) != 9){
            map.put("redPacketMoney", null);
            map.put("couponMoney", null);
        }
        if(Integer.valueOf(String.valueOf(map.get("state"))) == 7){
            UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(Integer.valueOf(String.valueOf(map.get("companyId"))));
            if(null != query2){
                Integer orderNum=this.selectCount(new EntityWrapper<OrderLogistics>().eq("userId",orderLogistics.getUserId()).eq("activityId",query2.getId()).last(" and to_days(getoffTime) = to_days(now())"));
                if(query2.getDistance()*1000>orderLogistics.getMileage() && query2.getOrderNum()>orderNum){
                    Double special = query2.getSpecial();
                    orderLogistics.setDiscount(special);
                    Double orderMoney = orderLogistics.getOrderMoney();
                    double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
                    if(orderMoney.compareTo(v) > 0){
                        map.put("discountMoney",orderMoney - v);
                    }
                }
            }
        }
        Map<String, String> geocode = gdMapGeocodingUtil.geocode(map.get("startLon").toString(), map.get("startLat").toString());
        map.put("startCity", geocode.get("city"));
@@ -2927,7 +3048,6 @@
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(new Date());
            calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + Integer.valueOf(String.valueOf(query.get("effective"))));
            userRedPacketRecord.setExpirationTime(calendar.getTime());
            userRedPacketRecord.setInsertTime(new Date());
            userRedPacketRecord.setCompanyId(Integer.valueOf(String.valueOf(query.get("companyId"))));
            userRedPacketRecord.setState(0);
@@ -2980,7 +3100,7 @@
                    Element user_chinese = document.getElementById("user_chinese");
                    user_chinese.text("您好 " + userInfo.getNickName() + ",");
                    Element time_chinese = document.getElementById("time_chinese");
                    time_chinese.text("此活动有效期在 " + DateUtil.conversionFormat(language, sdf.format(query.getInsertTime())) + " 至 " + DateUtil.conversionFormat(language, sdf.format(query.getExpirationTime())) + ",详情请查看I-GO平台");
                    time_chinese.text("此活动有效期在 " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " 至 " + DateUtil.conversionFormat(language, sdf.format(id.getEnable())) + ",详情请查看I-GO平台");
                }
                if(2 == language){
                    document.getElementById("chinese").remove();
@@ -2989,7 +3109,7 @@
                    Element user_english = document.getElementById("user_english");
                    user_english.text("Hello " + userInfo.getNickName() + ",");
                    Element time_english = document.getElementById("time_english");
                    time_english.text("You could use it from " + DateUtil.conversionFormat(language, sdf.format(query.getInsertTime())) + " to " + DateUtil.conversionFormat(language, sdf.format(query.getExpirationTime())) + ",check more details on the app.");
                    time_english.text("You could use it from " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " to " + DateUtil.conversionFormat(language, sdf.format(id.getEnable())) + ",check more details on the app.");
                }
                if(3 == language){
                    document.getElementById("chinese").remove();
@@ -2998,7 +3118,7 @@
                    Element user_french = document.getElementById("user_french");
                    user_french.text("Bonjour " + userInfo.getNickName() + ",");
                    Element time_french = document.getElementById("time_french");
                    time_french.text("Cette promotion est valable du " + DateUtil.conversionFormat(language, sdf.format(query.getInsertTime())) + " au " + DateUtil.conversionFormat(language, sdf.format(query.getExpirationTime())) + ". Veuillez consulter la plateforme i-go pour plus de détails.");
                    time_french.text("Cette promotion est valable du " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " au " + DateUtil.conversionFormat(language, sdf.format(id.getEnable())) + ". Veuillez consulter la plateforme i-go pour plus de détails.");
                }
                
                EmailUtil.send(userInfo.getEmail(), language == 1 ? "红包活动" : language == 2 ? "Lucky-promo activities" : "Activités bonus",  document.html());