| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.util.GpsCoordinateUtils; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.crossCity.server.impl.OrderCrossCityServiceImpl; |
| | |
| | | import com.stylefeng.guns.modular.system.warpper.OrderServerWarpper; |
| | | import com.stylefeng.guns.modular.taxi.dao.OrderTaxiMapper; |
| | | import com.stylefeng.guns.modular.taxi.dao.TPhoneMapper; |
| | | import com.stylefeng.guns.modular.taxi.dao.TransactionDetailsMapper; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.model.PaymentRecord; |
| | | import com.stylefeng.guns.modular.taxi.model.TPhone; |
| | | import com.stylefeng.guns.modular.taxi.model.TransactionDetails; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService; |
| | | import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService; |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private TPhoneMapper tPhoneMapper; |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public synchronized ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid) throws Exception { |
| | | public synchronized ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid,String areaCode) throws Exception { |
| | | System.out.println("出租车==========================================="+orderTaxi); |
| | | //定义用户所属公司 |
| | | UserInfo userInfo1 = userInfoService.selectById(uid); |
| | | if (userInfo1.getIsBlack()==1){ |
| | |
| | | placeOrderWay = 3; |
| | | break; |
| | | } |
| | | Company company = companyService.selectById(orderTaxi.getCompanyId()); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveDataTaxi(uid, "取消订单", query.getMoney(), 2, 1, 1, 2, id,placeOrderWay); |
| | | transactionDetailsService.saveDataTaxi(uid, "取消订单", query.getMoney(), 2, 1, 1, 2, id,placeOrderWay,company.getId()); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | //解除小号绑定 |
| | |
| | | userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | |
| | | SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId()); |
| | | userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分 |
| | | // userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分 |
| | | Integer placeOrderWay = null; |
| | | switch (orderTaxi.getOrderSource()){ |
| | | case 2: |
| | |
| | | break; |
| | | } |
| | | //添加交易明细 |
| | | transactionDetailsService.saveDataTaxi(uid, "完成订单", orderMoney, 2, 1, 1, 2, orderId,placeOrderWay); |
| | | // transactionDetailsService.saveDataTaxi(uid, "完成订单", orderMoney, 2, 1, 1, 2, orderId,placeOrderWay); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | orderTaxi.setState(8); |
| | |
| | | } |
| | | |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderTaxi.getCompanyId()); |
| | | Double taxi = company.getTaxiMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsTaxiFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(taxi); |
| | | 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); |
| | | c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue()); |
| | | incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue()); |
| | | // Company company = companyService.selectById(orderTaxi.getCompanyId()); |
| | | // Double taxi = company.getTaxiMoney(); |
| | | // BigDecimal d = null;//企业收入 |
| | | // BigDecimal c = null;//司机收入 |
| | | // if(company.getIsTaxiFixedOrProportional() == 2){//固定 |
| | | // d = new BigDecimal(taxi); |
| | | // 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); |
| | | // c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | // } |
| | | // incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue()); |
| | | // incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderTaxi.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()); |
| | | // 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()); |
| | | Company company = companyService.selectById(driver.getFranchiseeId()); |
| | | if(Objects.isNull(company)){ |
| | | company = companyService.selectById(driver.getCompanyId()); |
| | | } |
| | | // 司机收入 |
| | | double moneyTwo; |
| | | // 平台收入 |
| | | double money; |
| | | if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){ |
| | | double v = company.getPercentageDeduction() / 100; |
| | | money = v * orderTaxi.getOrderMoney(); |
| | | moneyTwo = orderTaxi.getOrderMoney()-money; |
| | | }else { |
| | | money = company.getFixedDeduction(); |
| | | moneyTwo = orderTaxi.getOrderMoney()-money; |
| | | } |
| | | driver.setBalance(driver.getBalance() + moneyTwo); |
| | | // 新增扣除使用费记录 |
| | | transactionDetailsService.saveDataTaxi(driver.getId(), "软件使用费", money, 2, 1, 2, 6, orderTaxi.getId(),placeOrderWay,company.getId()); |
| | | // 司机订单收入 |
| | | transactionDetailsService.saveDataTaxi(driver.getId(), "完成订单", moneyTwo, 1, 1, 2, 2, orderTaxi.getId(),placeOrderWay,company.getId()); |
| | | |
| | | driverService.updateById(driver); |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | |
| | | value = map.get("lon") + "," + map.get("lat"); |
| | | } |
| | | } |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getStartLon() + "," + orderTaxi.getStartLat(), 1); |
| | | // todo 注意 因更换地图为百度 两者lon和lat位置互换了 |
| | | String[] split = value.split(","); |
| | | value = split[1] + "," + split[0]; |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getStartLat() + "," + orderTaxi.getStartLon(), 1); |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if(null == distance){ |
| | |
| | | orderServerWarpper.setOrderId(orderTaxi.getId()); |
| | | orderServerWarpper.setOrderType(2); |
| | | orderServerWarpper.setState(orderTaxi.getState()); |
| | | orderServerWarpper.setLon(null != value ? value.split(",")[0] : "0.0"); |
| | | orderServerWarpper.setLat(null != value ? value.split(",")[1] : "0.0"); |
| | | orderServerWarpper.setLon(null != value ? value.split(",")[1] : "0.0"); |
| | | orderServerWarpper.setLat(null != value ? value.split(",")[0] : "0.0"); |
| | | value = value == null ? "0.0,0.0" : value; |
| | | double[] doubles = GpsCoordinateUtils.calBD09toGCJ02(Double.parseDouble(value.split(",")[1]), Double.parseDouble(value.split(",")[0])); |
| | | orderServerWarpper.setNextLongitude(String.valueOf(doubles[0])); |
| | | orderServerWarpper.setNextLatitude(String.valueOf(doubles[1])); |
| | | // 起点地址转换 |
| | | doubles = GpsCoordinateUtils.calBD09toGCJ02(orderTaxi.getStartLat(), orderTaxi.getStartLon()); |
| | | orderServerWarpper.setStartLat(String.valueOf(doubles[0])); |
| | | orderServerWarpper.setStartLon(String.valueOf(doubles[1])); |
| | | // 终点地址转换 |
| | | doubles = GpsCoordinateUtils.calBD09toGCJ02(orderTaxi.getEndLat(), orderTaxi.getEndLon()); |
| | | orderServerWarpper.setEndLat(String.valueOf(doubles[0])); |
| | | orderServerWarpper.setEndLon(String.valueOf(doubles[1])); |
| | | orderServerWarpper.setReassignNotice(orderTaxi.getReassignNotice()); |
| | | if(orderTaxi.getState() == 2 || orderTaxi.getState() == 3){//前往预约地 |
| | | orderServerWarpper.setReservationMileage(d); |
| | |
| | | orderServerWarpper.setLaveTime("0"); |
| | | } |
| | | if(orderTaxi.getState() == 5 || orderTaxi.getState() == 6){//服务中 |
| | | distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getEndLon() + "," + orderTaxi.getEndLat(), 1); |
| | | distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getEndLat() + "," + orderTaxi.getEndLon(), 1); |
| | | 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),2, RoundingMode.HALF_UP).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60),2, RoundingMode.HALF_UP) + ""; |
| | | } |
| | | orderServerWarpper.setReservationMileage("0"); |
| | | orderServerWarpper.setReservationTime("0"); |
| | |
| | | placeOrderWay = 3; |
| | | break; |
| | | } |
| | | //添加交易明细 |
| | | transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "完成订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay); |
| | | // Company company = companyService.selectById(orderTaxi.getCompanyId()); |
| | | // //添加交易明细 |
| | | // transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "完成订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay,company.getId()); |
| | | orderTaxi.setState(8); |
| | | orderTaxi.setPayType(type); |
| | | orderTaxi.setPayMoney(query.getAmount()); |
| | | this.updateById(orderTaxi); |
| | | |
| | | UserInfo userInfo = userInfoService.selectById(orderTaxi.getUserId()); |
| | | SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId()); |
| | | userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分 |
| | | userInfoService.updateById(userInfo); |
| | | // UserInfo userInfo = userInfoService.selectById(orderTaxi.getUserId()); |
| | | // SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId()); |
| | | // userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分 |
| | | // userInfoService.updateById(userInfo); |
| | | |
| | | //处理优惠券和红包 |
| | | if(null != orderTaxi.getCouponId()){ |
| | |
| | | paymentRecordService.updateById(query); |
| | | |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderTaxi.getCompanyId()); |
| | | Double taxi = company.getTaxiMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsTaxiFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(taxi); |
| | | 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); |
| | | c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue()); |
| | | incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue()); |
| | | // Company company = companyService.selectById(orderTaxi.getCompanyId()); |
| | | // Double taxi = company.getTaxiMoney(); |
| | | // BigDecimal d = null;//企业收入 |
| | | // BigDecimal c = null;//司机收入 |
| | | // if(company.getIsTaxiFixedOrProportional() == 2){//固定 |
| | | // d = new BigDecimal(taxi); |
| | | // 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); |
| | | // c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | // } |
| | | // incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue()); |
| | | // incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderTaxi.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()); |
| | | // 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()); |
| | | Company company = companyService.selectById(driver.getFranchiseeId()); |
| | | if(Objects.isNull(company)){ |
| | | company = companyService.selectById(driver.getCompanyId()); |
| | | } |
| | | // 司机收入 |
| | | double moneyTwo; |
| | | // 平台收入 |
| | | double money; |
| | | if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){ |
| | | double v = company.getPercentageDeduction() / 100; |
| | | money = v * orderTaxi.getOrderMoney(); |
| | | moneyTwo = orderTaxi.getOrderMoney()-money; |
| | | }else { |
| | | money = company.getFixedDeduction(); |
| | | moneyTwo = orderTaxi.getOrderMoney()-money; |
| | | } |
| | | driver.setBalance(driver.getBalance() + moneyTwo); |
| | | // 新增扣除使用费记录 |
| | | transactionDetailsService.saveDataTaxi(driver.getId(), "软件使用费", money, 2, 1, 2, 6, orderTaxi.getId(),placeOrderWay,company.getId()); |
| | | // 司机订单收入 |
| | | transactionDetailsService.saveDataTaxi(driver.getId(), "完成订单", moneyTwo, 1, 1, 2, 2, orderTaxi.getId(),placeOrderWay,company.getId()); |
| | | |
| | | driverService.updateById(driver); |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | |
| | | placeOrderWay = 3; |
| | | break; |
| | | } |
| | | Company company = companyService.selectById(orderTaxi.getCompanyId()); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "取消订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay); |
| | | transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "取消订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay,company.getId()); |
| | | orderTaxi.setState(10); |
| | | //解除小号绑定 |
| | | if(orderTaxi.getBindId() != null){ |