| | |
| | | private ITDriverServiceService tDriverServiceService; |
| | | |
| | | @Autowired |
| | | private IDriverWorkService driverWorkService; |
| | | |
| | | @Autowired |
| | | private ITCarService tCarService; |
| | | |
| | | @Autowired |
| | | private ITCarServiceService tCarServiceService; |
| | | |
| | | @Autowired |
| | | private ITOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | @Autowired |
| | | private ITOrderTaxiService orderTaxiService; |
| | | |
| | | @Autowired |
| | | private ITOrderCrossCityService orderCrossCityService; |
| | | |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | |
| | | if (commissionError != null) { |
| | | return commissionError; |
| | | } |
| | | tCompany.setIsNeedFerry(2); |
| | | tCompany.setType(2); //2:分公司 |
| | | tCompany.setState(0); //0:正常 |
| | | tCompany.setFlag("1"); |
| | |
| | | if (commissionError != null) { |
| | | return commissionError; |
| | | } |
| | | tCompany.setIsNeedFerry(2); |
| | | User user = userService.selectById(userId); |
| | | if(null != user && ToolUtil.isNotEmpty(password)){ |
| | | user.setPassword(ShiroKit.md5(password, user.getSalt())); |
| | |
| | | // ========== 级联更新逻辑 ========== |
| | | TCompany oldCompany = tCompanyService.selectById(tCompany.getId()); |
| | | if (oldCompany != null && oldCompany.getType() == 2) { |
| | | String unfinishedOrderError = validateCancelledServiceUnfinishedOrders(oldCompany, tCompany, true); |
| | | if (unfinishedOrderError != null) { |
| | | return unfinishedOrderError; |
| | | String driverServiceError = validateCancelledServiceDriverUsage(oldCompany, tCompany, true); |
| | | if (driverServiceError != null) { |
| | | return driverServiceError; |
| | | } |
| | | // 1. 检测并级联更新经营业务 |
| | | cascadeUpdateBusinessScope(oldCompany, tCompany); |
| | |
| | | if (commissionError != null) { |
| | | return commissionError; |
| | | } |
| | | tCompany.setIsNeedFerry(2); |
| | | TCompany oldCompany = tCompanyService.selectById(tCompany.getId()); |
| | | String unfinishedOrderError = validateCancelledServiceUnfinishedOrders(oldCompany, tCompany, false); |
| | | if (unfinishedOrderError != null) { |
| | | return unfinishedOrderError; |
| | | String driverServiceError = validateCancelledServiceDriverUsage(oldCompany, tCompany, false); |
| | | if (driverServiceError != null) { |
| | | return driverServiceError; |
| | | } |
| | | tCompany.setUpdateTime(new Date()); |
| | | // tCompany.setVersion(tCompany.getVersion() + 1); |
| | |
| | | if (commissionError != null) { |
| | | return commissionError; |
| | | } |
| | | tCompany.setIsNeedFerry(2); |
| | | tCompany.setType(3); //2:分公司 |
| | | if (ShiroKit.getUser().getRoleType() == 2) { |
| | | tCompany.setSuperiorId(ShiroKit.getUser().getObjectId()); |
| | |
| | | return false; |
| | | } |
| | | |
| | | private String validateCancelledServiceUnfinishedOrders(TCompany oldCompany, TCompany newCompany, boolean includeFranchisee) { |
| | | private String validateCancelledServiceDriverUsage(TCompany oldCompany, TCompany newCompany, boolean includeFranchisee) { |
| | | if (oldCompany == null || newCompany == null) { |
| | | return null; |
| | | } |
| | |
| | | if (driverIds.isEmpty()) { |
| | | return null; |
| | | } |
| | | if (cancelledTypes.contains(1) && hasUnfinishedPrivateCarOrder(driverIds)) { |
| | | return "当前公司内司机存在快车未完成订单,无法变动"; |
| | | for (Integer cancelledType : cancelledTypes) { |
| | | if (hasDriverWorkingService(driverIds, cancelledType)) { |
| | | return "当前公司内存在司机正在使用" + getServiceName(cancelledType) + "业务,无法变动"; |
| | | } |
| | | if (cancelledTypes.contains(2) && hasUnfinishedTaxiOrder(driverIds)) { |
| | | return "当前公司内司机存在出租车未完成订单,无法变动"; |
| | | } |
| | | if (cancelledTypes.contains(3) && hasUnfinishedCrossCityOrder(driverIds)) { |
| | | return "当前公司内司机存在跨城出行未完成订单,无法变动"; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean hasUnfinishedPrivateCarOrder(List<Integer> driverIds) { |
| | | return orderPrivateCarService.selectCount(new EntityWrapper<TOrderPrivateCar>() |
| | | .eq("isDelete", 1) |
| | | private boolean hasDriverWorkingService(List<Integer> driverIds, Integer serviceType) { |
| | | if (driverIds == null || driverIds.isEmpty() || serviceType == null) { |
| | | return false; |
| | | } |
| | | return driverWorkService.selectCount(new EntityWrapper<DriverWork>() |
| | | .in("driverId", driverIds) |
| | | .notIn("state", 8, 9, 10, 12)) > 0; |
| | | .eq("state", 1) |
| | | .like("type", String.valueOf(serviceType))) > 0; |
| | | } |
| | | |
| | | private boolean hasUnfinishedTaxiOrder(List<Integer> driverIds) { |
| | | return orderTaxiService.selectCount(new EntityWrapper<TOrderTaxi>() |
| | | .eq("isDelete", 1) |
| | | .in("driverId", driverIds) |
| | | .notIn("state", 8, 9, 10, 12)) > 0; |
| | | private String getServiceName(Integer serviceType) { |
| | | if (Integer.valueOf(1).equals(serviceType)) { |
| | | return "快车"; |
| | | } |
| | | |
| | | private boolean hasUnfinishedCrossCityOrder(List<Integer> driverIds) { |
| | | return orderCrossCityService.selectCount(new EntityWrapper<TOrderCrossCity>() |
| | | .eq("isDelete", 1) |
| | | .in("driverId", driverIds) |
| | | .notIn("state", 8, 9, 10, 12)) > 0; |
| | | if (Integer.valueOf(2).equals(serviceType)) { |
| | | return "出租车"; |
| | | } |
| | | if (Integer.valueOf(3).equals(serviceType)) { |
| | | return "跨城出行"; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |