| | |
| | | package com.stylefeng.guns.modular.crossCity.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.SpringContextHolder; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.dao.LineShiftMapper; |
| | | import com.stylefeng.guns.modular.crossCity.model.LineShift; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.ILineShiftDriverService; |
| | | import com.stylefeng.guns.modular.crossCity.server.ILineSiteService; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.OrderCrossCityInfoWrapper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.OrderCrossCityWarpper; |
| | | import com.stylefeng.guns.modular.crossCity.warpper.OrderWarpper; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.Reassign; |
| | | import com.stylefeng.guns.modular.system.model.TDriverLine; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IReassignService; |
| | | import com.stylefeng.guns.modular.system.service.TDriverLineService; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.SystemException; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import com.stylefeng.guns.modular.system.warpper.DriverInfoWarpper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Api |
| | |
| | | |
| | | @Autowired |
| | | private IReassignService reassignService; |
| | | |
| | | @Autowired |
| | | private LineShiftMapper lineShiftMapper; |
| | | |
| | | @Autowired |
| | | private TDriverLineService driverLineService; |
| | | // |
| | | // @Autowired |
| | | // private ICBCPayUtil icbcPayUtil; |
| | |
| | | * @param request |
| | | * @return |
| | | */ |
| | | // @ResponseBody |
| | | // @PostMapping("/api/orderCrossCity/reassignOrderCrossCityReassign") |
| | | // @ApiOperation(value = "提交改派申请(跨城)", tags = {"司机端-服务中"}, notes = "") |
| | | // @ApiImplicitParams({ |
| | | // @ApiImplicitParam(value = "订单id(多个以逗号分隔)", name = "orderIds", required = true, dataType = "string"), |
| | | // @ApiImplicitParam(value = "改派支付方式(1=微信,2=支付宝,3=余额)", name = "payType", required = false, dataType = "int"), |
| | | // @ApiImplicitParam(value = "改派原因", name = "reason", required = true, dataType = "string"), |
| | | // @ApiImplicitParam(value = "备注", name = "remark", required = false, dataType = "string"), |
| | | // @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | // }) |
| | | // public ResultUtil reassignOrderCrossCityReassign(Reassign reassign, String orderIds, HttpServletRequest request){ |
| | | // try { |
| | | // Integer uid = driverService.getUserIdFormRedis(request); |
| | | // if(null == uid){ |
| | | // return ResultUtil.tokenErr(); |
| | | // } |
| | | // return reassignService.saveData_(reassign, orderIds, uid, null); |
| | | // }catch (SystemException s){ |
| | | // return ResultUtil.error(s.getMsg()); |
| | | // } catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | // } |
| | | @ResponseBody |
| | | @PostMapping("/api/orderCrossCity/reassignOrderCrossCityReassign") |
| | | @ApiOperation(value = "提交改派申请(跨城)", tags = {"司机端-服务中"}, notes = "") |
| | |
| | | @ApiImplicitParam(value = "改派支付方式(1=微信,2=支付宝,3=余额)", name = "payType", required = false, dataType = "int"), |
| | | @ApiImplicitParam(value = "改派原因", name = "reason", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "备注", name = "remark", required = false, dataType = "string"), |
| | | @ApiImplicitParam(value = "改派司机id", name = "newDriverId", required = false, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil reassignOrderCrossCityReassign(Reassign reassign, String orderIds, HttpServletRequest request){ |
| | | public ResultUtil reassignOrderCrossCityReassign(Reassign reassign, String orderIds,Integer newDriverId, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return reassignService.saveData_(reassign, orderIds, uid, null); |
| | | return reassignService.saveData_(reassign, orderIds, uid, null,newDriverId); |
| | | }catch (SystemException s){ |
| | | return ResultUtil.error(s.getMsg()); |
| | | } catch (Exception e){ |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | //获取同线路下的司机 |
| | | @ResponseBody |
| | | @PostMapping("/api/orderCrossCity/querySameLineDriver") |
| | | @ApiOperation(value = "获取同线路下的司机", tags = {"司机端-服务中"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id(多个以逗号分隔)", name = "orderIds", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil< List<DriverInfoWarpper>> querySameLineDriver(String orderIds, HttpServletRequest request){ |
| | | try { |
| | | Integer driverId = driverService.getUserIdFormRedis(request); |
| | | if(null == driverId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | //获取线路id |
| | | String[] split = orderIds.split(","); |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(split[0]); |
| | | Integer lineId = orderCrossCity.getLineId(); |
| | | //查出该线路的司机 |
| | | EntityWrapper<TDriverLine> driverLineWrapper = new EntityWrapper<>(); |
| | | driverLineWrapper.eq("lineId", lineId); |
| | | List<TDriverLine> tDriverLines = driverLineService.selectList(driverLineWrapper); |
| | | List<Integer> driverIds = tDriverLines.stream() |
| | | .map(TDriverLine::getDriverid) |
| | | .filter(id -> !id.equals(driverId)) // 去掉当前司机 |
| | | .distinct() // 去重 |
| | | .collect(Collectors.toList()); |
| | | //获取司机及车辆信息 |
| | | List<Map<String, Object>> maps = driverService.queryDriversByIds(driverIds); |
| | | List<DriverInfoWarpper> driverInfoWarppers = new ArrayList<>(); |
| | | for (Map<String, Object> map : maps) { |
| | | DriverInfoWarpper driverInfoWarpper = DriverInfoWarpper.getDriverInfoWarpper(map); |
| | | driverInfoWarppers.add(driverInfoWarpper); |
| | | } |
| | | |
| | | return ResultUtil.success(driverInfoWarppers); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取已完成订单明细 |
| | |
| | | * @throws Exception |
| | | */ |
| | | List<OrderCrossCity> queryMaturity() throws Exception; |
| | | |
| | | String getOrderNum(Integer driverId, Integer lineShiftDriverId) throws Exception; |
| | | |
| | | /** |
| | | * 抢单操作 |
| | | * @param orderId |
| | | * @param uid |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception; |
| | | } |
| | |
| | | @Autowired |
| | | private GeodesyUtil geodesyUtil; |
| | | |
| | | @Autowired |
| | | private ICarService carService; |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public synchronized String getOrderNum(Integer driverId, Integer lineShiftDriverId) throws Exception{ |
| | | List<OrderCrossCity> orderCrossCities = orderCrossCityMapper.queryOrders(driverId, lineShiftDriverId, Arrays.asList(2, 3, 4, 7)); |
| | | if(orderCrossCities.size() > 0){ |
| | |
| | | size++; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 抢单操作 |
| | | * @param orderId |
| | | * @param uid |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { |
| | | OrderCrossCity orderCrossCity = selectById(orderId); |
| | | |
| | | if(orderCrossCity.getState() == 9){ |
| | | return ResultUtil.error("订单已取消"); |
| | | } |
| | | if(orderCrossCity.getState() != 1){ |
| | | return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | orderCrossCity.setDriverId(uid); |
| | | orderCrossCity.setCarId(driver.getCarId()); |
| | | orderCrossCity.setCompanyId(driver.getFranchiseeId() != null && driver.getFranchiseeId() != 0 ? driver.getFranchiseeId() : ( |
| | | driver.getCompanyId() != null && driver.getCompanyId() != 0 ? driver.getCompanyId() : 1)); |
| | | orderCrossCity.setState(2); |
| | | orderCrossCity.setSnatchOrderTime(new Date()); |
| | | |
| | | //调用高德创建轨迹 |
| | | String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | String track = gdFalconUtil.createTrack(s); |
| | | orderCrossCity.setTrackId(track); |
| | | |
| | | //调用移动的小号接口 |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderCrossCity.getStartLon().toString(), orderCrossCity.getStartLat().toString()); |
| | | Region region = regionMapper.query(geocode.get("districtCode")); |
| | | Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderCrossCity.getPassengersPhone(), driver.getPhone(), Integer.valueOf(region.getCitycode().substring(1))); |
| | | if(String.valueOf(map.get("code")).equals("200")){ |
| | | orderCrossCity.setTelX(map.get("telX")); |
| | | orderCrossCity.setBindId(map.get("bindId")); |
| | | } |
| | | |
| | | this.updateById(orderCrossCity); |
| | | |
| | | //修改司机为服务中 |
| | | if (driver.getState() == 2) { |
| | | driver.setState(3); |
| | | |
| | | } |
| | | |
| | | //TODO:补充订单、支付明细信息 |
| | | // 处理公司和司机收入(原支付方法中删除的逻辑移到这里) |
| | | 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 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()); |
| | | |
| | | 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()); |
| | | driverService.updateById(driver); |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, orderCrossCity.getUserId(), orderCrossCity.getId(), 1, orderCrossCity.getState()); |
| | | pushUtil.pushOrderState(2, orderCrossCity.getDriverId(), orderCrossCity.getId(), 1, orderCrossCity.getState()); |
| | | // if(orderCrossCity.getType() == 2){ |
| | | // pushUtil.pushFerryOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, 2); |
| | | // } |
| | | } |
| | | }).start(); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushDriverPosition(orderId, 1); |
| | | } |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已成功抢得跨城订单,请及时联系客户!", orderCrossCity.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderCrossCity.getUserId()); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){ |
| | | //上传数据 |
| | | pushMinistryOfTransportUtil.orderCreate(orderId); |
| | | pushMinistryOfTransportUtil.orderMatch(orderId); |
| | | } |
| | | } |
| | | }).start(); |
| | | //发送短信 |
| | | try{ |
| | | Car car = carService.selectById(orderCrossCity.getCarId()); |
| | | SMSUtil.send(orderCrossCity.getPassengersPhone(), "您的订单已被司机" + driver.getName() + "接单,联系电话" + driver.getPhone() + "车牌号" + car.getCarLicensePlate() + "请耐心等待。", "2431012312845"); |
| | | // String sData = aLiSendSms.sendSms(orderPrivateCar.getPassengersPhone(), "SMS_476900230", "{\"code1\":\"" + driver.getName() + "\",\"code2\":\"" + driver.getPhone() + "\",\"code3\":\"" + car.getCarLicensePlate() + "\"}"); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | Driver queryByTaxiAptitudeCard(@Param("taxiAptitudeCard") String taxiAptitudeCard); |
| | | |
| | | /** |
| | | * 根据司机ID列表查询对应司机的信息 |
| | | * @param driverIds 司机ID列表(如 [1,2,3]) |
| | | * @return 列表中每个司机的信息Map |
| | | */ |
| | | List<Map<String, Object>> queryDriversByIds(@Param("driverIds") List<Integer> driverIds); |
| | | |
| | | } |
| | |
| | | from t_driver where flag != 3 and authState = 2 and taxiAptitudeCard = #{taxiAptitudeCard} |
| | | </select> |
| | | |
| | | |
| | | <select id="queryDriversByIds" resultType="map"> |
| | | select |
| | | a.id as id, |
| | | a.headImgUrl as avatar, |
| | | a.sex as sex, |
| | | a.`name` as `name`, |
| | | a.phone as phone, |
| | | a.balance as balance, |
| | | a.laveActivityMoney as laveActivityMoney, |
| | | a.activityMoney as activityMoney, |
| | | a.businessMoney as businessMoney, |
| | | a.laveBusinessMoney as laveBusinessMoney, |
| | | a.taxiAptitudeCard as taxiAptitudeCard, |
| | | DATE_FORMAT(a.networkCarlssueDate, '%Y-%m-%d') as networkCarlssueDate, |
| | | a.driverContactAddress_ as driverContactAddress_, |
| | | a.idCard as idCard, |
| | | a.appletsOpenId as appletsOpenId, |
| | | a.idCardImgUrl1 as idCardImgUrl1, |
| | | a.idCardImgUrl2 as idCardImgUrl2, |
| | | DATE_FORMAT(a.getDriverLicenseDate, '%Y-%m-%d') as getDriverLicenseDate, |
| | | (select GROUP_CONCAT(type Separator ',') from t_driver_service where driverId = a.id) as `type`, |
| | | a.placeOfPractice as placeOfPractice, |
| | | a.driveCardImgUrl as driveCardImgUrl, |
| | | a.networkCarlssueImg as networkCarlssueImg, |
| | | a.placeOfEmployment as placeOfEmployment, |
| | | (select `name` from t_company where 1 = 1 and if(a.companyId is null or a.companyId = 0, id = 1, if(a.franchiseeId is null or a.franchiseeId = 0, id = a.companyId, id = a.franchiseeId))) as company, |
| | | b.carLicensePlate as licensePlate, |
| | | b.carColor as carColor, |
| | | CONCAT(d.`name`, c.`name`) as brand, |
| | | ( |
| | | (select count(id) from t_order_private_car where driverId = a.id and state in (7, 8, 9)) + |
| | | (select count(id) from t_order_taxi where driverId = a.id and state in (7, 8, 9)) + |
| | | (select count(id) from t_order_cross_city where driverId = a.id and state in (6, 8, 9)) + |
| | | (select count(id) from t_order_logistics where driverId = a.id and state in (6, 9)) |
| | | ) as orderNum, |
| | | ((select sum(fraction) from t_order_evaluate where driverId = a.id) / (select count(fraction) from t_order_evaluate where driverId = a.id)) as score |
| | | from t_driver a |
| | | left join t_car b on (a.carId = b.id) |
| | | left join t_car_model c on (b.carModelId = c.id) |
| | | left join t_car_brand d on (c.brandId = d.id) |
| | | where a.id in |
| | | <foreach collection="driverIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | Driver generateCode(Driver userInfo); |
| | | String generateQrCodeTemp(); |
| | | |
| | | /** |
| | | * 根据司机ID列表查询对应司机的信息 |
| | | * @param driverIds 司机ID列表(如 [1,2,3]) |
| | | * @return 列表中每个司机的信息Map |
| | | */ |
| | | List<Map<String, Object>> queryDriversByIds( List<Integer> driverIds); |
| | | |
| | | } |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil saveData_(Reassign reassign, String orderIds, Integer uid, Integer type) throws Exception; |
| | | ResultUtil saveData_(Reassign reassign, String orderIds, Integer uid, Integer type,Integer newDriverId) throws Exception; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryDriversByIds(List<Integer> driverIds) { |
| | | return driverMapper.queryDriversByIds( driverIds); |
| | | } |
| | | |
| | | /** |
| | | * 获取编号 |
| | | * @return |
| | |
| | | case 2://出租 |
| | | return orderTaxiService.grabOrder(orderId, uid); |
| | | case 3://城际 |
| | | return ResultUtil.success();//不作任何操作,跨城默认选择的司机 |
| | | return orderCrossCityService.grabOrder(orderId, uid); |
| | | case 4://同城小件 |
| | | return orderLogisticsService.grabOrder(orderId, uid); |
| | | case 5://跨城小件 |
| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.api.OrderController; |
| | | import com.stylefeng.guns.modular.crossCity.dao.LineShiftDriverMapper; |
| | | import com.stylefeng.guns.modular.crossCity.model.LineShiftDriver; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; |
| | |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.CarModelMapper; |
| | | import com.stylefeng.guns.modular.system.dao.DispatchMapper; |
| | | import com.stylefeng.guns.modular.system.dao.ReassignMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper; |
| | |
| | | import org.springframework.transaction.annotation.Isolation; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | | |
| | | @Autowired |
| | | private IReassignService reassignService; |
| | | |
| | | @Resource |
| | | private LineShiftDriverMapper lineShiftDriverMapper; |
| | | |
| | | @Autowired |
| | | private OrderController orderController; |
| | | |
| | | @Resource |
| | | private CarModelMapper carModelMapper; |
| | | |
| | | @Autowired |
| | | private ICarService carService; |
| | | |
| | | |
| | | /** |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil saveData_(Reassign reassign, String orderIds, Integer uid, Integer type) throws Exception { |
| | | public ResultUtil saveData_(Reassign reassign, String orderIds, Integer uid, Integer type,Integer newDriverId) throws Exception { |
| | | type = null == type ? 2 : type;//现目前微信只支持小程序支付 |
| | | String content = reassign.getRemark(); |
| | | if(ToolUtil.isNotEmpty(content)){ |
| | |
| | | ids += reassign.getId() + ","; |
| | | } |
| | | ids = ids.substring(0, ids.length() - 1); |
| | | systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid); |
| | | |
| | | |
| | | if(newDriverId == null) { |
| | | systemNoticeService.addSystemNotice(2, "您的改派申请已成功提交,我们会尽快为你处理!", uid); |
| | | //开始支付 |
| | | if(null != reassign.getPayType()){ |
| | | if(reassign.getPayType() == 1){//微信支付 |
| | |
| | | } |
| | | } |
| | | } |
| | | return resultUtil; |
| | | }else { |
| | | //开始支付 |
| | | if (null != reassign.getPayType()) { |
| | | if (reassign.getPayType() == 1) {//微信支付 |
| | | String[] split1 = ids.split(","); |
| | | // Map<String, String> map = icbcPayUtil.placeAnOrder(ids + "_3", 9, 5, uid.toString(), "改派订单", totalMoney, callbackPath + "/base/wxReassign", "", type, driver.getAppletsOpenId()); |
| | | // if(map.get("code").equals("200")){ |
| | | // for(String id : split1){ |
| | | // paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 1, aDouble, map.get("order_id"), 1);//添加预支付数据 |
| | | // } |
| | | // resultUtil = ResultUtil.success(map.get("data")); |
| | | // }else{ |
| | | // resultUtil = ResultUtil.error(map.get("msg"), ""); |
| | | // } |
| | | } |
| | | if (reassign.getPayType() == 2) {//支付宝 |
| | | String[] split1 = ids.split(","); |
| | | // Map<String, String> map = icbcPayUtil.placeAnOrder(ids + "_3", 10, 5, uid.toString(), "改派订单", totalMoney, callbackPath + "/base/aliReassign", "", 2, ""); |
| | | // if(map.get("code").equals("200")){ |
| | | // for(String id : split1){ |
| | | // paymentRecordService.saveData(1, uid, 2, Integer.valueOf(id), 3, 2, aDouble, map.get("order_id"), 1);//添加预支付数据 |
| | | // } |
| | | // resultUtil = ResultUtil.success(map.get("data")); |
| | | // }else{ |
| | | // resultUtil = ResultUtil.error(map.get("msg"), ""); |
| | | // } |
| | | } |
| | | if (reassign.getPayType() == 3) {//余额 |
| | | for (String id : split) { |
| | | Reassign query = reassignMapper.query(uid, null, Integer.valueOf(id), 3, 1); |
| | | query.setState(2); |
| | | query.setPayTime(new Date()); |
| | | reassignMapper.updateById(query); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(uid, "司机改派支付", aDouble, 2, 1, 2, 3, Integer.valueOf(id)); |
| | | } |
| | | Double balance = driver.getBalance(); |
| | | if (null == balance || balance < totalMoney) { |
| | | throw new SystemException("账户余额不足"); |
| | | } |
| | | driver.setBalance(new BigDecimal(balance).subtract(new BigDecimal(totalMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | |
| | | //修改改派通知状态 |
| | | for (String id : split) { |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(id); |
| | | orderCrossCity.setOldState(orderCrossCity.getState()); |
| | | orderCrossCity.setState(11); |
| | | orderCrossCity.setReassignNotice(2); |
| | | orderCrossCityService.updateById(orderCrossCity); |
| | | |
| | | //添加已收入明细 |
| | | incomeService.saveData(1, orderCrossCity.getCompanyId(), 4, orderCrossCity.getId(), 3, reassign.getMoney()); |
| | | } |
| | | systemNoticeService.addSystemNotice(2, "您已使用余额成功支付改派申请费用!", uid); |
| | | //开始推送调度单 |
| | | // Map<String, String> map = new HashMap<>(); |
| | | // map.put("orderId", reassign.getOrderId().toString()); |
| | | // map.put("orderType", reassign.getOrderType().toString()); |
| | | // List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1); |
| | | // for (Dispatch dispatch : dispatches) { |
| | | // jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId()); |
| | | // } |
| | | |
| | | //将所有改派单都给新的司机 |
| | | String[] split1 = ids.split(","); |
| | | for (String s : split1) { |
| | | selectCrossDriver(Integer.valueOf(s), newDriverId); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | return resultUtil; |
| | | } |
| | | /** |
| | | * 跨城出行订单改派司机 |
| | | */ |
| | | |
| | | public Object selectCrossDriver(@RequestParam Integer reassign, @RequestParam Integer driverId) { |
| | | //修改原司机信息 |
| | | //修改订单 |
| | | Reassign tReassign = reassignService.selectById(reassign); |
| | | OrderCrossCity tOrderCrossCity = orderCrossCityService.selectById(tReassign.getOrderId()); |
| | | Driver oldDriver = driverService.selectById(tReassign.getOriginalDriverId()); |
| | | LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(tOrderCrossCity.getLineShiftDriverId()); |
| | | lineShiftDriver.setLaveSeat(lineShiftDriver.getLaveSeat() + tOrderCrossCity.getPeopleNumber() > lineShiftDriver.getTotalSeat() ? |
| | | lineShiftDriver.getTotalSeat() : lineShiftDriver.getLaveSeat() + tOrderCrossCity.getPeopleNumber()); |
| | | String seat = ""; |
| | | String[] split = tOrderCrossCity.getSeatNumber().split(","); |
| | | for(String s : split){ |
| | | seat += s + ","; |
| | | } |
| | | seat = lineShiftDriver.getLaveSeatNumber() + "," + seat.substring(0, seat.length() - 1); |
| | | |
| | | //总和大于总座位数的情况 |
| | | if(lineShiftDriver.getLaveSeat() + tOrderCrossCity.getPeopleNumber() > lineShiftDriver.getTotalSeat()){ |
| | | seat = ""; |
| | | for(int i = 1; i <= lineShiftDriver.getTotalSeat(); i++){ |
| | | seat += i + ","; |
| | | } |
| | | seat = seat.substring(0, seat.length() - 1); |
| | | } |
| | | lineShiftDriver.setLaveSeatNumber(seat); |
| | | lineShiftDriverMapper.updateById(lineShiftDriver); |
| | | if(lineShiftDriver.getLaveSeat() >= lineShiftDriver.getTotalSeat()){ |
| | | oldDriver.setState(2); |
| | | driverService.updateById(oldDriver); |
| | | } |
| | | |
| | | //修改新司机数据 |
| | | List<LineShiftDriver> query = lineShiftDriverMapper.queryByDriver(lineShiftDriver.getLineShiftId(), driverId, tOrderCrossCity.getTravelTime()); |
| | | LineShiftDriver lineShiftDriver1 = null; |
| | | |
| | | if(query.size() == 0){ |
| | | // return ResultUtil.error("司机没有预约班次"); |
| | | CarModel carModel = carModelMapper.selectById(carService.selectById(driverService.selectById(driverId).getCarId()).getCarModelId()); |
| | | |
| | | LineShiftDriver lineShiftDriver0 = new LineShiftDriver(); |
| | | lineShiftDriver0.setLineShiftId(lineShiftDriver.getLineShiftId()); |
| | | lineShiftDriver0.setDriverId(driverId); |
| | | lineShiftDriver0.setDay(lineShiftDriver.getDay()); |
| | | lineShiftDriver0.setTotalSeat(carModel.getSeat() - 1); |
| | | lineShiftDriver0.setLaveSeat(carModel.getSeat() - 1); |
| | | lineShiftDriver0.setInserTime(new Date()); |
| | | String seatNumber = ""; |
| | | for(int i = 1; i < carModel.getSeat(); i++){ |
| | | seatNumber += i + ","; |
| | | } |
| | | lineShiftDriver0.setLaveSeatNumber(seatNumber.substring(0, seatNumber.length() - 1)); |
| | | |
| | | Integer insert = lineShiftDriverMapper.insert(lineShiftDriver0); |
| | | lineShiftDriver1 = lineShiftDriver0; |
| | | |
| | | }else { |
| | | lineShiftDriver1 = query.get(0); |
| | | |
| | | } |
| | | if(lineShiftDriver1.getLaveSeat() < tOrderCrossCity.getPeopleNumber()){ |
| | | return ResultUtil.runErr("司机车辆剩余座位数不足"); |
| | | } |
| | | lineShiftDriver1.setLaveSeat(lineShiftDriver1.getLaveSeat() - tOrderCrossCity.getPeopleNumber()); |
| | | String[] split1 = lineShiftDriver1.getLaveSeatNumber().split(","); |
| | | String seat1 = "";//使用 |
| | | String seat2 = "";//未使用 |
| | | for(int i = 0; i < tOrderCrossCity.getPeopleNumber(); i++){ |
| | | seat1 += split1[i] + ","; |
| | | } |
| | | for(int i = tOrderCrossCity.getPeopleNumber(); i < split1.length; i++){ |
| | | seat2 += split1[i] + ","; |
| | | } |
| | | lineShiftDriver1.setLaveSeatNumber(seat2); |
| | | lineShiftDriverMapper.updateById(lineShiftDriver1); |
| | | Driver driver = driverService.selectById(driverId); |
| | | // if(driver.getState() == 1){ |
| | | // return ResultUtil.error("司机还未上班呢"); |
| | | // } |
| | | // if(driver.getState() == 2){ |
| | | // driver.setState(3); |
| | | // } |
| | | |
| | | //修改订单数据 |
| | | tOrderCrossCity.setDriverId(driverId); |
| | | tOrderCrossCity.setCarId(driver.getCarId()); |
| | | tOrderCrossCity.setSeatNumber(seat1); |
| | | tOrderCrossCity.setState(tOrderCrossCity.getOldState()); |
| | | tOrderCrossCity.setLineShiftDriverId(lineShiftDriver1.getId()); |
| | | tOrderCrossCity.setOldState(null); |
| | | tOrderCrossCity.setIsReassign(2); |
| | | try { |
| | | tOrderCrossCity.setOrderNum(orderCrossCityService.getOrderNum(driverId, tOrderCrossCity.getLineShiftDriverId())); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | orderCrossCityService.updateAllColumnById(tOrderCrossCity); |
| | | |
| | | //修改专车改派订单 |
| | | tReassign.setNowDriverId(driverId); |
| | | tReassign.setNowCarId(driver.getCarId()); |
| | | tReassign.setState(3); |
| | | tReassign.setCompleteTime(new Date()); |
| | | reassignService.updateById(tReassign); |
| | | |
| | | //修改收入明细,转给新司机(因为是先支付金额) |
| | | List<Income> incomes = incomeService.selectList(new EntityWrapper<Income>().eq("userType", 2).eq("objectId", oldDriver.getId()).eq("type", 2).eq("incomeId", tReassign.getOrderId()).eq("orderType", 3)); |
| | | if(incomes.size() > 0){ |
| | | Income income = incomes.get(0); |
| | | income.setObjectId(driverId); |
| | | incomeService.updateById(income); |
| | | |
| | | oldDriver.setBusinessMoney(oldDriver.getBusinessMoney() - income.getMoney()); |
| | | oldDriver.setLaveBusinessMoney(oldDriver.getLaveBusinessMoney() - income.getMoney()); |
| | | oldDriver.setBalance(oldDriver.getBalance()-income.getMoney()); |
| | | |
| | | driver.setBusinessMoney(driver.getBusinessMoney() + income.getMoney()); |
| | | driver.setLaveBusinessMoney(driver.getLaveBusinessMoney() + income.getMoney()); |
| | | driver.setBalance(driver.getBalance()+income.getMoney()); |
| | | |
| | | } |
| | | driverService.updateById(oldDriver); |
| | | driverService.updateById(driver); |
| | | //增加推送 |
| | | // Map<String,String> map = new HashMap<>(); |
| | | // map.put("orderId", tOrderCrossCity.getId().toString()); |
| | | // map.put("orderType", "3"); |
| | | String result = orderController.pushOrderState(tOrderCrossCity.getId(), 3); |
| | | // String result = HttpRequestUtil.postRequest(PushURL.order_push_url, map); |
| | | System.out.println("跨城出行改派:【orderId="+tOrderCrossCity.getId().toString()+"】,调用接口:"+result); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | left join t_car_brand d on (c.brandId = d.id) |
| | | where a.id = #{id} |
| | | </select> |
| | | |
| | | <select id="queryDriversByLineAndCarModel" resultType="Driver"> |
| | | select |
| | | id as id, |
| | | account as account, |
| | | jobNumber as jobNumber, |
| | | phone as phone, |
| | | password as password, |
| | | name as name, |
| | | sex as sex, |
| | | idCard as idCard, |
| | | companyId as companyId, |
| | | franchiseeId as franchiseeId, |
| | | headImgUrl as headImgUrl, |
| | | faceImgUrl as faceImgUrl, |
| | | idCardImgUrl1 as idCardImgUrl1, |
| | | idCardImgUrl2 as idCardImgUrl2, |
| | | placeOfEmployment as placeOfEmployment, |
| | | birthday as birthday, |
| | | bankCardNumber as bankCardNumber, |
| | | driverNationality as driverNationality, |
| | | driverNation as driverNation, |
| | | driverMaritalStatus as driverMaritalStatus, |
| | | driverLanguageLevel as driverLanguageLevel, |
| | | driverEducation as driverEducation, |
| | | driverCensus as driverCensus, |
| | | driverAddress as driverAddress, |
| | | driverContactAddress as driverContactAddress, |
| | | driverAge as driverAge, |
| | | driveCard as driveCard, |
| | | driveCardImgUrl as driveCardImgUrl, |
| | | driverType as driverType, |
| | | getDriverLicenseDate as getDriverLicenseDate, |
| | | driverLicenseOn as driverLicenseOn, |
| | | driverLicenseOff as driverLicenseOff, |
| | | taxiDriver as taxiDriver, |
| | | taxiAptitudeCard as taxiAptitudeCard, |
| | | networkCarlssueImg as networkCarlssueImg, |
| | | networkCarlssueOrganization as networkCarlssueOrganization, |
| | | networkCarlssueDate as networkCarlssueDate, |
| | | getNetworkCarProofDate as getNetworkCarProofDate, |
| | | networkCarProofOn as networkCarProofOn, |
| | | networkCarProofOff as networkCarProofOff, |
| | | registerDate as registerDate, |
| | | fullTimeDriver as fullTimeDriver, |
| | | inDriverBlacklist as inDriverBlacklist, |
| | | commercialType as commercialType, |
| | | contractCompany as contractCompany, |
| | | contractOn as contractOn, |
| | | contractOff as contractOff, |
| | | emergencyContact as emergencyContact, |
| | | emergencyContactPhone as emergencyContactPhone, |
| | | emergencyContactAddress as emergencyContactAddress, |
| | | remark as remark, |
| | | isPlatCar as isPlatCar, |
| | | carId as carId, |
| | | authState as authState, |
| | | state as state, |
| | | addType as addType, |
| | | balance as balance, |
| | | flag as flag, |
| | | insertTime as insertTime, |
| | | insertUser as insertUser, |
| | | updateTime as updateTime, |
| | | updateUser as updateUser |
| | | from t_driver |
| | | where flag != 3 and state = 2 and authState = 2 |
| | | and id in |
| | | ( |
| | | select driverId from t_driver_work where startTime < now() and state = 1 and `type` like CONCAT('%', #{type}, '%') |
| | | ) |
| | | and id in (select driverId from t_driver_orders where `type` = 3) |
| | | and carId in (select carId from t_car_service where `type` = 3 |
| | | <if test="null != serverCarModelId"> |
| | | and serverCarModelId = #{serverCarModelId} |
| | | </if> |
| | | ) |
| | | </select> |
| | | </mapper> |