puzhibing
2023-02-11 ea719b0443b8ccbc6d17349796936664ff3261d0
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/OrderCrossCityServiceImpl.java
@@ -257,15 +257,15 @@
     * @throws Exception
     */
    @Override
    public ResultUtil payCrossCityOrder(Integer payType, Integer orderId, Integer couponId, Integer type) throws Exception {
    public ResultUtil payCrossCityOrder(Integer payType, Integer orderId, Integer couponId, Integer type, Integer language) throws Exception {
        OrderCrossCity orderCrossCity = this.selectById(orderId);
        if(orderCrossCity.getState() != 7){
            return ResultUtil.error("订单已完成支付,不允许重复支付", "");
            return ResultUtil.error("订单已完成支付,不允许重复支付");
        }
        Integer uid = orderCrossCity.getUserId();
        Double orderMoney = orderCrossCity.getOrderMoney();
        UserInfo userInfo = userInfoService.selectById(uid);
        ResultUtil resultUtil = ResultUtil.success(new HashMap<>());
        ResultUtil resultUtil = ResultUtil.success();
        orderCrossCity.setCouponMoney(0D);//初始化历史数据
        orderCrossCity.setCouponId(null);
@@ -274,19 +274,19 @@
        if(null != couponId){
            userCouponRecord = userCouponRecordService.selectById(couponId);
            if(userCouponRecord.getCompanyId() != orderCrossCity.getCompanyId()){
                return ResultUtil.error("优惠券不能用于此订单", "");
                return ResultUtil.error("优惠券不能用于此订单");
            }
            if(userCouponRecord.getState() == 2){
                return ResultUtil.error("优惠券已使用", "");
                return ResultUtil.error("优惠券已使用");
            }
            if(userCouponRecord.getState() == 3){
                return ResultUtil.error("优惠券已过期", "");
                return ResultUtil.error("优惠券已过期");
            }
            if(userCouponRecord.getCouponUseType() != 0 && userCouponRecord.getCouponUseType() != 3){
                return ResultUtil.error("优惠券不能用于此类型订单", "");
                return ResultUtil.error("优惠券不能用于此类型订单");
            }
            if(userCouponRecord.getCouponType() == 2 && orderMoney.compareTo(userCouponRecord.getFullMoney()) < 0){
                return ResultUtil.error("优惠券不能用于此订单", "");
                return ResultUtil.error("优惠券不能用于此订单");
            }
            orderMoney = orderMoney - userCouponRecord.getMoney();
            orderCrossCity.setCouponMoney(userCouponRecord.getMoney());
@@ -319,7 +319,7 @@
                paymentRecordService.saveData(1, null, null, orderId, 3, 1, orderMoney, null, 1);//添加预支付数据
                resultUtil = resultUtil;
            }else{
                resultUtil = ResultUtil.error("获取支付信息失败", "");
                resultUtil = ResultUtil.error("获取支付信息失败");
            }
        }
        if(payType == 2){//支付宝支付
@@ -328,12 +328,12 @@
                paymentRecordService.saveData(1, null, null, orderId, 3, 2, orderMoney, null, 1);//添加预支付数据
                resultUtil = resultUtil;
            }else{
                resultUtil = ResultUtil.error("获取支付信息失败", "");
                resultUtil = ResultUtil.error("获取支付信息失败");
            }
        }
        if(payType == 3){//余额支付
            if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){
                return ResultUtil.error("余额不足,无法完成支付", "");
                return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient account balance" : "Solde de compte insuffisant");
            }
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
@@ -364,7 +364,7 @@
            //添加已收入明细
            Line line = lineService.selectById(orderCrossCity.getLineId());
            Double speMoney = Double.valueOf(line.getRakeRate());
            BigDecimal d = new BigDecimal(orderCrossCity.getOrderMoney()).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);//企业收入
            BigDecimal d = new BigDecimal(orderCrossCity.getOrderMoney()).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));//企业收入
            BigDecimal c = new BigDecimal(orderCrossCity.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);//司机收入
            incomeService.saveData(1, orderCrossCity.getCompanyId(), 2, orderCrossCity.getId(), 3, d.doubleValue());
            incomeService.saveData(2, orderCrossCity.getDriverId(), 2, orderCrossCity.getId(), 3, c.doubleValue());
@@ -438,7 +438,7 @@
            //添加已收入明细
            Line line = lineService.selectById(orderCrossCity.getLineId());
            Double speMoney = Double.valueOf(line.getRakeRate());
            BigDecimal d = new BigDecimal(orderCrossCity.getOrderMoney()).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);//企业收入
            BigDecimal d = new BigDecimal(orderCrossCity.getOrderMoney()).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));//企业收入
            BigDecimal c = new BigDecimal(orderCrossCity.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);//司机收入
            incomeService.saveData(1, orderCrossCity.getCompanyId(), 2, orderCrossCity.getId(), 3, d.doubleValue());
            incomeService.saveData(2, orderCrossCity.getDriverId(), 2, orderCrossCity.getId(), 3, c.doubleValue());
@@ -752,7 +752,7 @@
     * @throws Exception
     */
    @Override
    public ResultUtil cancleOrderCrossCity(Integer id, Integer payType, Integer cancleId, Integer type) throws Exception {
    public ResultUtil cancleOrderCrossCity(Integer id, Integer payType, Integer cancleId, Integer type, Integer language) throws Exception {
        OrderCrossCity orderCrossCity = this.selectById(id);
        Integer uid = orderCrossCity.getUserId();
        UserInfo userInfo = userInfoService.selectById(uid);
@@ -797,7 +797,7 @@
            }
            if(payType == 3){//余额支付
                if(userInfo.getBalance() != null && userInfo.getBalance() < query.getMoney()){
                    return ResultUtil.error("余额不足,无法完成支付", "");
                    return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient account balance" : "Solde de compte insuffisant");
                }
                userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(query.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
@@ -1298,8 +1298,8 @@
        if(null == distance){
            System.err.println("查询距离出错了");
        }else{
            d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
            t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60)).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + "";
            d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString();
            t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + "";
        }
        OrderServerWarpper orderServerWarpper = new OrderServerWarpper();
        orderServerWarpper.setOrderId(orderCrossCity.getId());
@@ -1321,8 +1321,8 @@
            if(null == distance){
                System.err.println("查询距离出错了");
            }else{
                d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
                t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60)).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + "";
                d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString();
                t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + "";
            }
            orderServerWarpper.setReservationMileage("0");
            orderServerWarpper.setReservationTime("0");
@@ -1414,7 +1414,7 @@
        //定义用户所属公司
        OrderTaxi orderTaxi = new OrderTaxi();
        UserInfo userInfo1 = userInfoService.selectById(uid);
        Company query = companyCityService.query(startLon, startLat);
        Company query = companyCityService.query1(startLon, startLat);
        if(null == query){
            return ResultUtil.error("出发点暂未开通");
        }
@@ -1468,7 +1468,7 @@
            if(ToolUtil.isEmpty(userInfo.getPhone())){
                return ResultUtil.error("请先绑定手机号码");
            }
            orderTaxi.setPassengers(userInfo.getName());
            orderTaxi.setPassengers(userInfo.getFirstName() + "." + userInfo.getLastName());
            orderTaxi.setPassengersPhone(userInfo.getPhone());
        }
        orderTaxi.setState(1);//待接单
@@ -1540,7 +1540,7 @@
            if(ToolUtil.isEmpty(userInfo.getPhone())){
                return ResultUtil.error("请先绑定手机号码");
            }
            orderPrivateCar.setPassengers(userInfo.getName());
            orderPrivateCar.setPassengers(userInfo.getFirstName() + "." + userInfo.getLastName());
            orderPrivateCar.setPassengersPhone(userInfo.getPhone());
        }
        orderPrivateCar.setState(1);
@@ -1584,7 +1584,7 @@
                        if(orderType == 1){//专车
                            OrderPrivateCar orderPrivateCar = orderPrivateCarMapper.selectById(orderId);
                            OrderPrivateCarServiceImpl.orderIds.add(orderPrivateCar.getId());//添加记录,防止调用接口重复提醒无人接单
                            Company query = companyCityService.query(String.valueOf(orderPrivateCar.getStartLon()), String.valueOf(orderPrivateCar.getStartLat()));//获取起点所属分公司
                            Company query = companyCityService.query1(String.valueOf(orderPrivateCar.getStartLon()), String.valueOf(orderPrivateCar.getStartLat()));//获取起点所属分公司
                            List<PushOrder> querys = pushOrderService.querys(null, 1, query.getId());//获取需要推送的次数
                            for(int i = 1; i <= querys.size(); i++){
                                //订单被抢后的处理
@@ -1653,7 +1653,7 @@
                        if(orderType == 2){//出租车
                            OrderTaxi orderTaxi = orderTaxiMapper.selectById(orderId);
                            OrderTaxiServiceImpl.orderIds.add(orderTaxi.getId());//添加记录,防止调用接口重复提醒无人接单
                            Company query = companyCityService.query(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat()));//获取起点所属分公司
                            Company query = companyCityService.query1(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat()));//获取起点所属分公司
                            List<PushOrder> querys = pushOrderService.querys(null, 2, query.getId());//获取需要推送的次数
                            for(int i = 1; i <= querys.size(); i++){
                                //处理订单被抢