puzhibing
2023-02-11 ea719b0443b8ccbc6d17349796936664ff3261d0
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -40,6 +40,8 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.*;
@Service
@@ -174,7 +176,7 @@
    public synchronized ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid) throws Exception {
        //定义用户所属公司
        UserInfo userInfo1 = userInfoService.selectById(uid);
        Company query = companyCityService.query(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat()));
        Company query = companyCityService.query1(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat()));
        if(null == query){
            return ResultUtil.error("出发点暂未开通");
        }
@@ -233,7 +235,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);//待接单
@@ -483,17 +485,17 @@
     * @throws Exception
     */
    @Override
    public ResultUtil cancleOrderTaxi(Integer id, Integer payType, Integer cancleId, Integer type) throws Exception {
    public ResultUtil cancleOrderTaxi(Integer id, Integer payType, Integer cancleId, Integer type, Integer language) throws Exception {
        OrderTaxi orderTaxi = this.selectById(id);
        Integer uid = orderTaxi.getUserId();
        UserInfo userInfo = userInfoService.selectById(uid);
        ResultUtil resultUtil = ResultUtil.success("");
        if(null == orderTaxi){
            return ResultUtil.error("取消订单失败,订单信息有误", "");
            return ResultUtil.error((language == 1 ? "订单信息有误" : language == 2 ? "Incorrect order information" : "Informations de commande incorrectes"), "");
        }
        if(orderTaxi.getState() != 12){
            return ResultUtil.error("取消订单失败,不合法的操作", "");
            return ResultUtil.error((language == 1 ? "订单取消失败" : language == 2 ? "Order cancellation failure" : "Annulation de commande échouée"), "");
        }
        OrderCancel orderCancel = null;
        if(null == cancleId){
@@ -516,7 +518,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());
@@ -624,18 +626,18 @@
     * @throws Exception
     */
    @Override
    public ResultUtil payTaxiOrder(Integer payType, Integer orderId, Integer couponId, Integer type) throws Exception {
    public ResultUtil payTaxiOrder(Integer payType, Integer orderId, Integer couponId, Integer type, Integer language) throws Exception {
        OrderTaxi orderTaxi = this.selectById(orderId);
        if(orderTaxi.getState() == 8 || orderTaxi.getState() == 9){
            return ResultUtil.error("订单已完成支付,不允许重复支付", "");
            return ResultUtil.error("订单已完成支付,不允许重复支付");
        }
        if(orderTaxi.getState() != 7){
            return ResultUtil.error("订单不在待支付状态,不允许支付", "");
            return ResultUtil.error("订单不在待支付状态,不允许支付");
        }
        Integer uid = orderTaxi.getUserId();
        Double orderMoney = orderTaxi.getOrderMoney();
        UserInfo userInfo = userInfoService.selectById(uid);
        ResultUtil resultUtil = ResultUtil.success(new HashMap<>());
        ResultUtil resultUtil = ResultUtil.success();
        orderTaxi.setCouponMoney(0D);//初始化历史数据
        orderTaxi.setCouponId(null);
@@ -644,19 +646,19 @@
        if(null != couponId){
            userCouponRecord = userCouponRecordService.selectById(couponId);
            if(userCouponRecord.getCompanyId() != orderTaxi.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() != 2){
                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();
            orderTaxi.setCouponMoney(userCouponRecord.getMoney());
@@ -692,7 +694,7 @@
        }
        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());
@@ -730,7 +732,7 @@
                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
            }
            if(company.getIsTaxiFixedOrProportional() == 1){//比例
                d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
                d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
            }
            incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
@@ -956,8 +958,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(orderTaxi.getId());
@@ -979,8 +981,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");
@@ -1151,7 +1153,7 @@
                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
            }
            if(company.getIsTaxiFixedOrProportional() == 1){//比例
                d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
                d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
            }
            incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
@@ -1262,7 +1264,7 @@
                    if(ToolUtil.isNotEmpty(vehicle)){
                        integers = JSON.parseArray(vehicle).toJavaList(Integer.class);
                    }
                    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++){
                        PushOrder pushOrder = pushOrderService.querys(i, 2, query.getId()).get(0);