| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.system.dao.TOrderTransferMapper; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.TOrderTransfer; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.ISystemNoticeService; |
| | | import com.stylefeng.guns.modular.system.service.ITOrderTransferService; |
| | | import com.stylefeng.guns.modular.system.util.GDFalconUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushMinistryOfTransportUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | */ |
| | | @Service |
| | | public class TOrderTransferServiceImpl extends ServiceImpl<TOrderTransferMapper, TOrderTransfer> implements ITOrderTransferService { |
| | | @Resource |
| | | private TOrderTransferMapper orderTransferMapper; |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | @Autowired |
| | | private GDFalconUtil gdFalconUtil; |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | | @Autowired |
| | | private PushMinistryOfTransportUtil pushMinistryOfTransportUtil; |
| | | |
| | | @Autowired |
| | | private ISystemNoticeService systemNoticeService; |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | | @Override |
| | | public Map<String, Object> queryPushOrder(Integer orderId) throws Exception { |
| | | return orderTransferMapper.queryPushOrder(orderId); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getTransferOrderList(Page<Map<String, Object>> page, String beginTime, String endTime, Integer roleType, Integer nowUserId, String orderNum, Integer orderSource, String userName, String userPhone, String passengers, String passengersPhone, Integer serverCarModelId, String driver, Integer state) { |
| | | return this.baseMapper.getTransferOrderList(page, beginTime, endTime, roleType, nowUserId, orderNum, orderSource, userName, userPhone, passengers, passengersPhone, serverCarModelId, driver, state); |
| | | } |
| | | |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { |
| | | TOrderTransfer orderPrivateCar = this.selectById(orderId); |
| | | //处理摆渡车的情况 |
| | | if(orderPrivateCar.getType() == 2){ |
| | | //查看用户下的摆渡车是否已被人抢了 |
| | | // List<OrderPrivateCar> list = this.selectList( |
| | | // new EntityWrapper<OrderPrivateCar>() |
| | | // .eq("type", 2) |
| | | // .eq("userId", orderPrivateCar.getUserId()) |
| | | // .ne("state", 1) |
| | | // .eq("crossCityOrderId", orderPrivateCar.getCrossCityOrderId()) |
| | | // .eq("place", orderPrivateCar.getPlace()) |
| | | // ); |
| | | // List<OrderTaxi> list1 = orderTaxiService.selectList( |
| | | // new EntityWrapper<OrderTaxi>() |
| | | // .eq("type", 2) |
| | | // .eq("userId", orderPrivateCar.getUserId()) |
| | | // .ne("state", 1) |
| | | // .eq("crossCityOrderId", orderPrivateCar.getCrossCityOrderId()) |
| | | // .eq("place", orderPrivateCar.getPlace()) |
| | | // ); |
| | | // if(list.size() > 0 || list1.size() > 0){ |
| | | // return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | // } |
| | | } |
| | | |
| | | if(orderPrivateCar.getState() == 9){ |
| | | return ResultUtil.error("订单已取消"); |
| | | } |
| | | if(orderPrivateCar.getState() != 1){ |
| | | return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | orderPrivateCar.setDriverId(uid); |
| | | orderPrivateCar.setCarId(driver.getCarId()); |
| | | orderPrivateCar.setCompanyId(driver.getFranchiseeId() != null && driver.getFranchiseeId() != 0 ? driver.getFranchiseeId() : ( |
| | | driver.getCompanyId() != null && driver.getCompanyId() != 0 ? driver.getCompanyId() : 1)); |
| | | orderPrivateCar.setState(2); |
| | | orderPrivateCar.setSnatchOrderTime(new Date()); |
| | | |
| | | //调用高德创建轨迹 |
| | | String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | String track = gdFalconUtil.createTrack(s); |
| | | orderPrivateCar.setTrackId(track); |
| | | |
| | | //调用移动的小号接口 |
| | | // Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString()); |
| | | // Region region = regionMapper.query(geocode.get("districtCode")); |
| | | // Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), Integer.valueOf(region.getCitycode().substring(1))); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderPrivateCar.setTelX(map.get("telX")); |
| | | // orderPrivateCar.setBindId(map.get("bindId")); |
| | | // } |
| | | |
| | | //处理摆渡车的情况 |
| | | if(orderPrivateCar.getType() == 2){ |
| | | // //查看用户下的摆渡车是否已被人抢了 |
| | | // List<OrderPrivateCar> list = this.selectList( |
| | | // new EntityWrapper<OrderPrivateCar>() |
| | | // .eq("type", 2) |
| | | // .eq("userId", orderPrivateCar.getUserId()) |
| | | // .ne("state", 1) |
| | | // .eq("crossCityOrderId", orderPrivateCar.getCrossCityOrderId()) |
| | | // .eq("place", orderPrivateCar.getPlace()) |
| | | // ); |
| | | // List<OrderTaxi> list1 = orderTaxiService.selectList( |
| | | // new EntityWrapper<OrderTaxi>() |
| | | // .eq("type", 2) |
| | | // .eq("userId", orderPrivateCar.getUserId()) |
| | | // .ne("state", 1) |
| | | // .eq("crossCityOrderId", orderPrivateCar.getCrossCityOrderId()) |
| | | // .eq("place", orderPrivateCar.getPlace()) |
| | | // ); |
| | | // for(OrderPrivateCar orderPrivateCar1 : list){ |
| | | // orderPrivateCar1.setState(10); |
| | | // this.updateById(orderPrivateCar1); |
| | | // } |
| | | // for(OrderTaxi orderTaxi : list1){ |
| | | // orderTaxi.setState(10); |
| | | // orderTaxiService.updateById(orderTaxi); |
| | | // } |
| | | } |
| | | |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | //如果是预约单,则不修改司机为服务中 |
| | | if(orderPrivateCar.getOrderType() != 2 || (orderPrivateCar.getOrderType() == 2 && orderPrivateCar.getTravelTime().getTime() < System.currentTimeMillis() + 600000)){ |
| | | //修改司机为服务中 |
| | | driver.setState(3); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 7, orderPrivateCar.getState()); |
| | | pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 7, orderPrivateCar.getState()); |
| | | if(orderPrivateCar.getType() == 2){ |
| | | pushUtil.pushFerryOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, 2); |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushDriverPosition(orderId, 7); |
| | | } |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已成功抢得专车订单,请及时联系客户!", orderPrivateCar.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderPrivateCar.getUserId()); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){ |
| | | //上传数据 |
| | | pushMinistryOfTransportUtil.orderCreate(orderId); |
| | | pushMinistryOfTransportUtil.orderMatch(orderId); |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getTransferOrderDetailById(Integer orderId) { |
| | | return this.baseMapper.getTransferOrderDetailById(orderId); |
| | | } |