zhibing.pu
2024-04-12 a075cdd2f76fae321ecf95dce363141ade30f0f1
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity;
import com.stylefeng.guns.modular.crossCity.server.impl.OrderCrossCityServiceImpl;
import com.stylefeng.guns.modular.smallLogistics.dao.OrderLogisticsMapper;
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics;
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogisticsSpread;
@@ -25,6 +26,7 @@
import com.stylefeng.guns.modular.system.util.Tingg.model.Results;
import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils;
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.model.PaymentRecord;
import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService;
import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService;
@@ -35,7 +37,13 @@
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.io.File;
@@ -141,6 +149,12 @@
    @Autowired
    private IPhoneService phoneService;
    @Autowired
    private ICancleOrderService cancleOrderService;
    @Autowired
    private RestTemplate internalRestTemplate;
@@ -561,7 +575,7 @@
        }
        //折扣
        if(null != orderLogistics.getActivityId()){
            orderMoney = orderMoney - orderLogistics.getDiscount();
            orderMoney = orderMoney - orderLogistics.getDiscountMoney();
        }
        orderMoney=new BigDecimal(orderMoney).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
@@ -1091,7 +1105,7 @@
    @Override
    public ResultUtil addCancle(Integer id, String reason, String remark, Integer uid, Integer language) throws Exception {
    public ResultUtil addCancle(Integer id, String reason, String remark, Integer uid, Double lon, Double lat, String address, Integer language) throws Exception {
        if(ToolUtil.isNotEmpty(remark)){
            if(ToolUtil.isNotEmpty(remark)){
                List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null);
@@ -1107,133 +1121,57 @@
        if(null == orderLogistics){
            return ResultUtil.error(language == 1 ? "取消订单失败,订单信息有误" : language == 2 ? "Failed to cancel order, order-information error." : "Échec de l’annulation de la commande, erreur d’information de commande.");
        }
        if(orderLogistics.getState() > 5 && orderLogistics.getState() != 7 && orderLogistics.getState() != 11){
        if(orderLogistics.getState() > 5 && orderLogistics.getState() != 11){
            return ResultUtil.error(language == 1 ? "取消订单失败,不合法的操作" : language == 2 ? "Failed to cancel order, illegal operation." : "Échec de l’annulation de la commande, opération illégale.");
        }
        if(orderLogistics.getState() == 7){
            OrderCancel orderCancel = new OrderCancel();
            orderCancel.setOrderId(id);
            orderCancel.setOrderType(orderLogistics.getType());
            orderCancel.setReason(reason);
            orderCancel.setRemark(remark);
            orderCancel.setState(2);
            orderCancel.setInsertTime(new Date());
            orderCancel.setUserType(1);
            orderCancelService.insert(orderCancel);
        if(null == orderLogistics.getDriverId()){//没有接单的情况
            integer = orderCancelService.saveData(id, 4, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, null, 2, 1, uid);
            orderLogistics.setState(10);
            this.updateById(orderLogistics);
            return ResultUtil.success();
        }
        //回退支付金额
        if(null != orderLogistics.getPayType() && orderLogistics.getPayType() == 1) {//微信
            OrderCancel orderCancel = new OrderCancel();
            orderCancel.setOrderId(id);
            orderCancel.setOrderType(orderLogistics.getType());
            orderCancel.setReason(reason);
            orderCancel.setRemark(remark);
            orderCancel.setState(1);
            orderCancel.setInsertTime(new Date());
            orderCancel.setUserType(1);
            orderCancelService.insert(orderCancel);
            orderLogistics.setState(10);
            this.updateById(orderLogistics);
            //调用回退接口
            PaymentRecord query = paymentRecordService.query(1, orderLogistics.getUserId(), 1, orderLogistics.getId(), orderLogistics.getType(), 1, 2);
            if(null == query){
                return ResultUtil.error("支付数据异常,无法完成退款");
        }else {
            BaseWarpper data = queryCancleAmount(id, language).getData();
            Double amount = data.getAmount();
            if(0 == amount){
                integer = orderCancelService.saveData(id, 4, reason, remark, null, null, 2, 1, uid);
                if(5 == orderLogistics.getState()){
                    orderLogistics.setState(6);
                    orderLogistics.setGetoffLon(lon);
                    orderLogistics.setGetoffLat(lat);
                    orderLogistics.setGetoffAddress(address);
                    orderLogistics.setGetoffTime(new Date());
                    orderLogistics.setEndServiceTime(new Date());
                }else{
                    orderLogistics.setState(10);
                }
                this.updateById(orderLogistics);
            }else{
                if(5 == orderLogistics.getState()){
                    orderLogistics.setGetoffLon(lon);
                    orderLogistics.setGetoffLat(lat);
                    orderLogistics.setGetoffAddress(address);
                    orderLogistics.setGetoffTime(new Date());
                    orderLogistics.setEndServiceTime(new Date());
                }
                orderLogistics.setOldState(orderLogistics.getState());
                orderLogistics.setState(12);
                this.updateById(orderLogistics);
                integer = orderCancelService.saveData(id, 4, reason, remark, null, amount, 1, 1, uid);
            }
            UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
            String payerTransactionID = sdf.format(new Date()) + orderCancel.getId();
            PayoutResponse payoutResponse = tinggPayoutUtil.sendPayout(userInfo.getPhoneOperator(), "+" + userInfo.getPhone(), payerTransactionID, query.getAmount().doubleValue(), callbackPath + "/base/orderCancelRefundCallback", "取消订单退款");
            AuthStatus authStatus = payoutResponse.getAuthStatus();
            Results results = payoutResponse.getResults().get(0);
            String statusCode = results.getStatusCode();
            if(!"131".equals(authStatus.getAuthStatusCode())){
                return ResultUtil.error(authStatus.getAuthStatusDescription());
            }
            if(!"139".equals(statusCode)){
                return ResultUtil.error(results.getStatusDescription());
            }
        }
        if(null != orderLogistics.getPayType() && orderLogistics.getPayType() == 2){//支付宝
            OrderCancel orderCancel = new OrderCancel();
            orderCancel.setOrderId(id);
            orderCancel.setOrderType(orderLogistics.getType());
            orderCancel.setReason(reason);
            orderCancel.setRemark(remark);
            orderCancel.setState(1);
            orderCancel.setInsertTime(new Date());
            orderCancel.setUserType(1);
            orderCancelService.insert(orderCancel);
            orderLogistics.setState(10);
            this.updateById(orderLogistics);
            integer = orderCancel.getId();
            //调用回退接口
            PaymentRecord query = paymentRecordService.query(1, orderLogistics.getUserId(), 1, orderLogistics.getId(), orderLogistics.getType(), 2, 2);
            if(null == query){
                return ResultUtil.error("支付数据异常,无法完成退款");
            }
            UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
            String payerTransactionID = sdf.format(new Date()) + orderCancel.getId();
            PayoutResponse payoutResponse = tinggPayoutUtil.sendPayout(userInfo.getPhoneOperator(), "+" + userInfo.getPhone(), payerTransactionID, query.getAmount().doubleValue(), callbackPath + "/base/orderCancelRefundCallback", "取消订单退款");
            AuthStatus authStatus = payoutResponse.getAuthStatus();
            Results results = payoutResponse.getResults().get(0);
            String statusCode = results.getStatusCode();
            if(!"131".equals(authStatus.getAuthStatusCode())){
                return ResultUtil.error(authStatus.getAuthStatusDescription());
            }
            if(!"139".equals(statusCode)){
                return ResultUtil.error(results.getStatusDescription());
            }
        }
        if(null != orderLogistics.getPayType() && orderLogistics.getPayType() == 3){//余额
            UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
            userInfo.setBalance(userInfo.getBalance() + orderLogistics.getPayMoney());
            OrderCancel orderCancel = new OrderCancel();
            orderCancel.setOrderId(id);
            orderCancel.setOrderType(orderLogistics.getType());
            orderCancel.setReason(reason);
            orderCancel.setRemark(remark);
            orderCancel.setState(2);
            orderCancel.setInsertTime(new Date());
            orderCancel.setUserType(1);
            orderCancelService.insert(orderCancel);
            userInfoService.updateById(userInfo);
            orderLogistics.setState(10);
            this.updateById(orderLogistics);
            integer = orderCancel.getId();
            //添加交易明细
            transactionDetailsService.saveData(orderLogistics.getUserId(), "包裹取消退款", orderLogistics.getPayMoney(), 1, 1, 1, 4, orderLogistics.getId());
        }
        if(null != orderLogistics.getPayType() && orderLogistics.getPayType() == 4){//现金
//            UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
//            userInfo.setBalance(userInfo.getBalance() + orderLogistics.getPayMoney());
//            userInfoService.updateById(userInfo);
            OrderCancel orderCancel = new OrderCancel();
            orderCancel.setOrderId(id);
            orderCancel.setOrderType(orderLogistics.getType());
            orderCancel.setReason(reason);
            orderCancel.setRemark(remark);
            orderCancel.setState(2);
            orderCancel.setInsertTime(new Date());
            orderCancel.setUserType(1);
            orderCancelService.insert(orderCancel);
            orderLogistics.setState(10);
            this.updateById(orderLogistics);
            integer = orderCancel.getId();
            //添加交易明细
            transactionDetailsService.saveData(orderLogistics.getUserId(), "包裹取消退款", orderLogistics.getPayMoney(), 1, 1, 1, 4, orderLogistics.getId());
            this.deleteTask(id);//删除定时任务
            new Thread(new Runnable() {
                @Override
                public void run() {
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0);
                    System.err.println("推送取消操作---------------------");
                }
            }).start();
            //修改司机为空闲
            Driver driver = driverService.selectById(orderLogistics.getDriverId());
            driver.setState(2);
            driverService.updateById(driver);
        }
        if(null != orderLogistics.getDriverId()){
@@ -1366,4 +1304,296 @@
        list.addAll(list1);
        return list;
    }
    /**
     * 获取取消需要支付的金额
     * @param id
     * @param language
     * @return
     * @throws Exception
     */
    @Override
    public ResultUtil<BaseWarpper> queryCancleAmount(Integer id, Integer language) throws Exception {
        OrderLogistics orderLogistics = this.selectById(id);
        if(null == orderLogistics){
            return ResultUtil.error(language == 1 ? "获取数据失败,订单信息有误" : language == 2 ? "Failed to obtain data, order-information error." : "Impossible d’obtenir les données, erreur d’information de commande. ");
        }
        BaseWarpper baseWarpper = new BaseWarpper();
        double amount = 0;
        CancleOrder query = cancleOrderService.query(orderLogistics.getCompanyId());
        if(null == query || null == orderLogistics.getDriverId()){
            baseWarpper.setAmount(amount);
            return ResultUtil.success(baseWarpper);
        }
        JSONObject object = JSON.parseObject(query.getContent());
        long t = object.getInteger("driverTimeout") * 60000L;
        //司机超时未到达起点,免费取消
        if(orderLogistics.getState() < 3 && orderLogistics.getSnatchOrderTime().getTime() + t < System.currentTimeMillis()){
            baseWarpper.setAmount(amount);
            return ResultUtil.success(baseWarpper);
        }
        JSONObject order = object.getJSONObject("order");
        long m = order.getInteger("orderAcceptanceTime") * 60000L;
        //超过免费时间,计算费用
        if(orderLogistics.getSnatchOrderTime().getTime() + m < System.currentTimeMillis()){
            BigDecimal money = order.getBigDecimal("money");
            if(null != orderLogistics.getSetOutTime()){
                //里程费
                BigDecimal mileageFee = order.getBigDecimal("mileageFee").multiply(new BigDecimal(orderLogistics.getMileage() / 1000));
                //时长费
                int s = Double.valueOf((System.currentTimeMillis() - orderLogistics.getSetOutTime().getTime()) / 60000).intValue();
                BigDecimal durationFee = order.getBigDecimal("durationFee").multiply(new BigDecimal(s));
                money = money.add(durationFee).add(mileageFee);
            }
            amount = money.setScale(2, RoundingMode.HALF_EVEN).doubleValue();
        }
        baseWarpper.setAmount(amount);
        return ResultUtil.success(baseWarpper);
    }
    /**
     * 删除定时任务
     * @param orderId
     */
    @Override
    public void deleteTask(Integer orderId){
        //发送验证码短信
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("orderId", orderId + "");
        params.add("orderType", "4");
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://driver-server/base/netty/deleteTask", requestEntity, String.class);
        JSONObject jsonObject = JSON.parseObject(s, JSONObject.class);
        if(jsonObject.getIntValue("code") != 200){
            System.err.println("调用driver-server出错了");
        }
    }
    /**
     * 取消订单操作
     * @param id
     * @return
     * @throws Exception
     */
    @Override
    public ResultUtil cancleOrderPrivateCar(Integer id, Integer payType, Integer bankCardId, Integer cancleId, Integer type, Integer language) throws Exception {
        OrderLogistics orderLogistics = this.selectById(id);
        Integer uid = orderLogistics.getUserId();
        UserInfo userInfo = userInfoService.selectById(uid);
        ResultUtil resultUtil = ResultUtil.success("");
        if(null == orderLogistics){
            return ResultUtil.error(language == 1 ? "取消订单失败,订单信息有误" : language == 2 ? "Failed to cancel order, order-information error." : "Échec de l’annulation de la commande, erreur d’information de commande.", "");
        }
        if(orderLogistics.getState() != 13){
            return ResultUtil.error(language == 1 ? "取消订单失败,不合法的操作" : language == 2 ? "Failed to cancel order, illegal operation." : "Échec de l’annulation de la commande, opération illégale.", "");
        }
        OrderCancel orderCancel = null;
        if(null == cancleId || cancleId==0){
            orderCancel = orderCancelService.query(id, 4, null, null, 1);
        }else{
            orderCancel = orderCancelService.selectById(cancleId);
        }
        Double amount = queryCancleAmount(id, language).getData().getAmount();
        if(0 < amount){
            if(payType == 1){//手机支付
                orderCancel.setPayType(1);
                orderCancelService.updateById(orderCancel);
                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
                String merchantTransactionId = sdf.format(new Date()) + "4" + language + id;
                CheckoutRequest checkoutRequest = new CheckoutRequest();
                checkoutRequest.setMsisdn(Long.valueOf(userInfo.getPhone()));
                checkoutRequest.setCustomerEmail(userInfo.getEmail());
                checkoutRequest.setAccountNumber(userInfo.getPhone());
                checkoutRequest.setCustomerFirstName(userInfo.getFirstName());
                checkoutRequest.setCustomerLastName(userInfo.getLastName());
                checkoutRequest.setRequestAmount(amount);
                checkoutRequest.setMerchantTransactionId(merchantTransactionId);
                checkoutRequest.setRequestDescription("Cancel a trip");
                checkoutRequest.setCallbackUrl(callbackPath + "/base/wxCancelOrderTaxi");
                checkoutRequest.setPendingRedirectUrl("");
                checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html");
                checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html");
                resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest);
                if(resultUtil.getCode()==200){
                    paymentRecordService.saveData(1, null, null, id, 4, 1, amount, null, 1);//添加预支付数据
                }
            }
            if(payType == 2){//银行卡支付
                orderCancel.setPayType(2);
                orderCancelService.updateById(orderCancel);
                BankCard bankCard = bankCardService.selectById(bankCardId);
                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
                String merchantTransactionId = sdf.format(new Date()) + "4" + id;
                CheckoutRequest checkoutRequest = new CheckoutRequest();
                checkoutRequest.setMsisdn(Long.valueOf(bankCard.getCode()));
                checkoutRequest.setCustomerEmail(userInfo.getEmail());
                checkoutRequest.setAccountNumber(bankCard.getCode());
                checkoutRequest.setCustomerFirstName(bankCard.getFirstName());
                checkoutRequest.setCustomerLastName(bankCard.getLastName());
                checkoutRequest.setRequestAmount(amount);
                checkoutRequest.setMerchantTransactionId(merchantTransactionId);
                checkoutRequest.setRequestDescription("Cancel a trip");
                checkoutRequest.setCallbackUrl(callbackPath + "/base/wxCancelOrderTaxi");
                checkoutRequest.setPendingRedirectUrl("");
                checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html");
                checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html");
                resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest);
                if(resultUtil.getCode()==200){
                    paymentRecordService.saveData(1, null, null, id, 4, 2, amount, null, 1);//添加预支付数据
                }
            }
            if(payType == 3){//余额支付
                if(userInfo.getBalance() != null && userInfo.getBalance() < amount){
                    return ResultUtil.error((language == 1 ? "账户余额不足" : language == 2 ? "Insufficient balance" : "Solde insuffisant"), "");
                }
                userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(amount)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                //添加交易明细
                transactionDetailsService.saveData(uid, "取消订单", amount, 2, 1, 1, 4, id);
                userInfoService.updateById(userInfo);
                //解除小号绑定
                if(orderLogistics.getBindId() != null){
                    ChinaMobileUtil.midAxbUnBindSend(orderLogistics.getBindId(),orderLogistics.getTelX());
                }
                if(5 == orderLogistics.getOldState()){
                    orderLogistics.setState(6);
                }else{
                    orderLogistics.setState(10);
                }
                orderLogistics.setTelX("");
                orderLogistics.setBindId("");
                this.updateById(orderLogistics);
                orderCancel.setState(2);
                orderCancel.setPayType(3);
                orderCancelService.updateById(orderCancel);
                if(null != orderLogistics.getDriverId()){
                    BigDecimal c =new BigDecimal(amount);//司机收入
                    incomeService.saveData(2, orderLogistics.getDriverId(), 3, orderLogistics.getId(), 4, c.doubleValue());
                    Driver driver = driverService.selectById(orderLogistics.getDriverId());
                    driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                    driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                    driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                    driverService.updateById(driver);
                    this.deleteTask(id);//删除定时任务
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0);
                }
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0);
                //添加消息
                systemNoticeService.addSystemNotice(1, language == 1 ? "您已使用余额成功支付取消订单费用,谢谢使用!" : language == 2
                        ? "You've paid for cancellation fee with the balance successfully, thank you for using I-GO"
                        : "Vous avez utilisé avec succès votre solde pour payer les frais d’annulation, merci d’utiliser I-GO", orderLogistics.getUserId(), 1);
            }
        }
        return resultUtil;
    }
    /**
     * 取消订单支付后的处理
     * @param id            订单=id
     * @param order_id      工行支付单号
     * @throws Exception
     */
    @Override
    public void payCancelOrderPrivateCar(Integer id, String order_id, Integer language) throws Exception {
        OrderLogistics orderLogistics = this.selectById(id);
        PaymentRecord query = paymentRecordService.query(1, null, null, Integer.valueOf(id), 4, null, 1);
        if(null != query){
            //添加交易明细
            transactionDetailsService.saveData(orderLogistics.getUserId(), "取消订单", query.getAmount(), 2, 1, 1, 4, query.getOrderId());
            //解除小号绑定
            if(orderLogistics.getBindId() != null){
                ChinaMobileUtil.midAxbUnBindSend(orderLogistics.getBindId(),orderLogistics.getTelX());
            }
            if(5 == orderLogistics.getOldState()){
                orderLogistics.setState(6);
            }else{
                orderLogistics.setState(10);
            }
            orderLogistics.setBindId("");
            orderLogistics.setTelX("");
            this.updateById(orderLogistics);
            query.setState(2);
            query.setCode(order_id);
            paymentRecordService.updateById(query);
            OrderCancel query1 = orderCancelService.query(query.getOrderId(), query.getOrderType(), query.getAmount(), query.getPayType(), 1);
            if (null != query1){
                query1.setState(2);
                orderCancelService.updateById(query1);
            }
            if(null != orderLogistics.getDriverId()){
                BigDecimal c =new BigDecimal(query.getAmount());//司机收入
                incomeService.saveData(2, orderLogistics.getDriverId(), 3, orderLogistics.getId(), 4, c.doubleValue());
                Driver driver = driverService.selectById(orderLogistics.getDriverId());
                driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                driverService.updateById(driver);
                this.deleteTask(orderLogistics.getId());//删除定时任务
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0);
            }
            pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0);
            //添加消息
            systemNoticeService.addSystemNotice(1, language == 1 ? "您已使用余额成功支付取消订单费用,谢谢使用!" : language == 2
                    ? "You've paid for cancellation fee with the balance successfully, thank you for using I-GO"
                    : "Vous avez utilisé avec succès votre solde pour payer les frais d’annulation, merci d’utiliser I-GO", orderLogistics.getUserId(), 1);
        }else{
            System.err.println("预支付数据异常(orderId = "  + id + ")");
        }
    }
    /**
     * 修改目的地
     * @param orderId
     * @param endLon
     * @param endLat
     * @param endAddress
     */
    @Override
    public void updateEndAddress(Integer orderId, String endLon, String endLat, String endAddress) {
        OrderLogistics orderLogistics = this.selectById(orderId);
        if(null != orderLogistics.getDriverId()){
            orderLogistics.setDestination(endAddress);
            orderLogistics.setDestinationLat(endLat);
            orderLogistics.setDestinationLon(endLon);
            this.updateById(orderLogistics);
            pushUtil.pushModifyAddress(2, orderLogistics.getDriverId(), orderId, 1, 1);
        }else{
            orderLogistics.setEndAddress(endAddress);
            orderLogistics.setEndLat(Double.valueOf(endLat));
            orderLogistics.setEndLon(Double.valueOf(endLon));
            this.updateById(orderLogistics);
        }
    }
}