Pu Zhibing
2025-04-28 c399be7463c16b3787b3e591d3006628a11ab858
DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -454,57 +454,13 @@
                orderTaxi.setGetoffLat(lat);
                orderTaxi.setGetoffAddress(address);
                orderTaxi.setGetoffTime(new Date());
                if(orderTaxi.getPayManner()==3){
                    orderTaxi.setState(9);
                    Driver driver = driverService.selectById(orderTaxi.getDriverId());
                    Company company = companyService.selectById(driver.getFranchiseeId());
                    if(Objects.isNull(company)){
                        company = companyService.selectById(driver.getCompanyId());
                    }
                    TransactionDetails transactionDetails = new TransactionDetails();
                    driver.setBalance(driver.getBalance() - company.getFixedDeduction());
                    transactionDetails.setMoney(company.getFixedDeduction());
                    // 新增扣除使用费记录
                    transactionDetails.setUserId(driver.getId());
                    transactionDetails.setInsertTime(new Date());
                    transactionDetails.setRemark("软件使用费");
                    transactionDetails.setState(2);
                    transactionDetails.setType(1);
                    transactionDetails.setUserType(2);
                    transactionDetails.setOrderType(6);
                    transactionDetails.setOrderId(orderTaxi.getId());
                    transactionDetailsMapper.insert(transactionDetails);
                    driverService.updateById(driver);
                }else {
                    orderTaxi.setState(6);
                }
                orderTaxi.setEndServiceTime(new Date());
//                List<TUseMoney> money = useMoneyMapper.selectList(null);
//                Driver driver = driverService.selectById(orderTaxi.getDriverId());
//                Company company = companyService.selectById(driver.getCompanyId());
//                TransactionDetails transactionDetails = new TransactionDetails();
//                if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){
//                    double v = company.getPercentageDeduction() / 100;
//                    v = v * orderTaxi.getOrderMoney();
//                    driver.setBalance(driver.getBalance() - v);
//                    transactionDetails.setMoney(v);
//                }else {
//                    driver.setBalance(driver.getBalance() - company.getFixedDeduction());
//                    transactionDetails.setMoney(company.getFixedDeduction());
//                }
//                // 新增扣除使用费记录
//                transactionDetails.setUserId(driver.getId());
//                transactionDetails.setInsertTime(new Date());
//                transactionDetails.setRemark("软件使用费");
//                transactionDetails.setState(2);
//                transactionDetails.setType(1);
//                transactionDetails.setUserType(2);
//                transactionDetails.setOrderType(6);
//                transactionDetails.setOrderId(orderTaxi.getId());
//                transactionDetailsMapper.insert(transactionDetails);
//                driverService.updateById(driver);
                orderTaxi.setState(6);
                //回滚司机状态为空闲
                Driver driver = driverService.selectById(orderTaxi.getDriverId());
                driver.setState(2);
                driverService.updateById(driver);
                pushUtil.removeTask(orderId, 2);//删除定时任务,结束推送数据
                systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderTaxi.getUserId());
                break;
@@ -512,11 +468,12 @@
        this.updateById(orderTaxi);
        // TODO: 2020/6/5 推送状态
        OrderTaxi finalOrderTaxi = orderTaxi;
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushOrderState(1, orderTaxi.getUserId(), orderTaxi.getId(), 2, orderTaxi.getState());
                pushUtil.pushOrderState(2, orderTaxi.getDriverId(), orderTaxi.getId(), 2, orderTaxi.getState());
                pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 2, finalOrderTaxi.getState());
                pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 2, finalOrderTaxi.getState());
            }
        }).start();
        return ResultUtil.success();
@@ -536,22 +493,72 @@
    @Override
    public ResultUtil confirmFees(Integer orderId, Integer type, Double travelFee, Double parkingFee, Double crossingFee) throws Exception {
        OrderTaxi orderTaxi = this.selectById(orderId);
        orderTaxi.setPayManner(type);
        if(type == 2){//其他支付,不需要操作,直接完成订单
            orderTaxi = this.setMoney1(orderTaxi, travelFee, parkingFee, crossingFee);
            orderTaxi.setState(7);
        }else if (type == 1){
        if(2 == type && orderTaxi.getPayManner()==3){
            orderTaxi.setState(9);
            Driver driver = driverService.selectById(orderTaxi.getDriverId());
            Company company = companyService.selectById(driver.getFranchiseeId());
            if(Objects.isNull(company)){
                company = companyService.selectById(driver.getCompanyId());
            }
            TransactionDetails transactionDetails = new TransactionDetails();
            driver.setBalance(driver.getBalance() - company.getFixedDeduction());
            transactionDetails.setMoney(company.getFixedDeduction());
            // 新增扣除使用费记录
            transactionDetails.setUserId(driver.getId());
            transactionDetails.setInsertTime(new Date());
            transactionDetails.setRemark("软件使用费");
            transactionDetails.setState(2);
            transactionDetails.setType(1);
            transactionDetails.setUserType(2);
            transactionDetails.setOrderType(6);
            transactionDetails.setOrderId(orderTaxi.getId());
            transactionDetailsMapper.insert(transactionDetails);
            driverService.updateById(driver);
        }
        //打表计费,直接订单完成支付,
        if(2 == type && orderTaxi.getPayManner()==2){
            orderTaxi = this.setMoney2(orderTaxi, parkingFee, crossingFee);
            orderTaxi.setState(7);
        }else {
            //在线上计费的基础上随机加0.01-1的金额
            Double orderMoney = orderTaxi.getOrderMoney() + (new BigDecimal(Math.random()).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());
            orderTaxi.setState(8);
            orderTaxi.setOrderMoney(orderMoney);
            orderTaxi.setPayMoney(orderMoney);
            Driver driver = driverService.selectById(orderTaxi.getDriverId());
            Company company = companyService.selectById(driver.getFranchiseeId());
            if(Objects.isNull(company)){
                company = companyService.selectById(driver.getCompanyId());
            }
            TransactionDetails transactionDetails = new TransactionDetails();
            Double meterPrintingFee = company.getMeterPrintingFee();
            Double laveBusinessMoney = driver.getLaveBusinessMoney();
            Double laveActivityMoney = driver.getLaveActivityMoney();
            if(null != laveBusinessMoney && laveBusinessMoney.compareTo(meterPrintingFee) >= 0){
                driver.setLaveBusinessMoney(new BigDecimal(laveBusinessMoney).subtract(new BigDecimal(meterPrintingFee)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            }else if(null != laveActivityMoney && laveActivityMoney.compareTo(meterPrintingFee) >= 0){
                driver.setLaveActivityMoney(new BigDecimal(laveActivityMoney).subtract(new BigDecimal(meterPrintingFee)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            }
            driver.setBalance(driver.getBalance() - meterPrintingFee);
            transactionDetails.setMoney(meterPrintingFee);
            // 新增扣除使用费记录
            transactionDetails.setUserId(driver.getId());
            transactionDetails.setInsertTime(new Date());
            transactionDetails.setRemark("软件使用费");
            transactionDetails.setState(2);
            transactionDetails.setType(1);
            transactionDetails.setUserType(2);
            transactionDetails.setOrderType(6);
            transactionDetails.setOrderId(orderTaxi.getId());
            transactionDetailsMapper.insert(transactionDetails);
            driverService.updateById(driver);
        }
        //线上计费,计算费用后修改为待支付
        if(1 == type && orderTaxi.getPayManner()==1){
            orderTaxi = this.setMoney2(orderTaxi, crossingFee, crossingFee);
            orderTaxi.setState(7);
        }
        this.updateById(orderTaxi);
        //回滚司机状态为空闲
        Driver driver = driverService.selectById(orderTaxi.getDriverId());
        driver.setState(2);
        driverService.updateById(driver);
        OrderTaxi finalOrderTaxi = orderTaxi;
        new Thread(new Runnable() {