| | |
| | | import com.stylefeng.guns.modular.system.dao.CarServiceMapper; |
| | | import com.stylefeng.guns.modular.system.dao.RegionMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SystemPriceMapper; |
| | | import com.stylefeng.guns.modular.system.dao.UserInfoMapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import org.gavaghan.geodesy.Ellipsoid; |
| | | import org.gavaghan.geodesy.GeodeticCalculator; |
| | | import org.gavaghan.geodesy.GeodeticCurve; |
| | | import org.gavaghan.geodesy.GlobalCoordinates; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.util.*; |
| | | |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ICompanyService companyService; |
| | | |
| | | |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | | |
| | | |
| | | @Autowired |
| | | private ICarService carService; |
| | | |
| | | |
| | | @Resource |
| | | private CarServiceMapper carServiceMapper; |
| | | |
| | | @Resource |
| | | private UserInfoMapper userInfoMapper; |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private TDriverPromotionActivityService driverPromotionActivityService; |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | |
| | | /** |
| | | * 获取司机端首页订单列表 |
| | | * @param state 1=服务中,2=待服务(30分钟定义预约) |
| | | * |
| | | * @param state 1=服务中,2=待服务(30分钟定义预约) |
| | | * @param driverId |
| | | * @return |
| | | * @throws Exception |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { |
| | | public ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(null == orderPrivateCar){ |
| | | return ResultUtil.error("订单已被抢了"); |
| | |
| | | new EntityWrapper<OrderTaxi>() |
| | | .eq("type", 2) |
| | | .eq("userId", orderPrivateCar.getUserId()) |
| | | .ne("state", 1) |
| | | .notIn("state", 1,11) |
| | | .eq("crossCityOrderId", orderPrivateCar.getCrossCityOrderId()) |
| | | .eq("place", orderPrivateCar.getPlace()) |
| | | ); |
| | |
| | | if(orderPrivateCar.getState() == 10){ |
| | | return ResultUtil.error("订单已取消"); |
| | | } |
| | | if(orderPrivateCar.getState() != 1){ |
| | | if(orderPrivateCar.getState() != 1 && orderPrivateCar.getState() != 11){ |
| | | return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | } |
| | | |
| | | Integer oldDriverId = null; |
| | | if(orderPrivateCar.getState()==11){ |
| | | oldDriverId= orderPrivateCar.getDriverId(); |
| | | } |
| | | |
| | | Driver driver = driverService.selectById(uid); |
| | | if(orderPrivateCar.getType() == 3){ |
| | | //批量订单 |
| | |
| | | orderPrivateCar.setSnatchOrderTime(new Date()); |
| | | |
| | | //调用高德创建轨迹 |
| | | String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | String track = gdFalconUtil.createTrack(s); |
| | | orderPrivateCar.setTrackId(track); |
| | | // String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | // String track = gdFalconUtil.createTrack(s); |
| | | // orderPrivateCar.setTrackId(track); |
| | | |
| | | //调用移动的小号接口 |
| | | Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); |
| | | if(String.valueOf(map.get("code")).equals("200")){ |
| | | orderPrivateCar.setTelX(map.get("telX")); |
| | | orderPrivateCar.setBindId(map.get("bindId")); |
| | | } |
| | | // Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderPrivateCar.setTelX(map.get("telX")); |
| | | // orderPrivateCar.setBindId(map.get("bindId")); |
| | | // } |
| | | |
| | | |
| | | |
| | | // 是否推广订单 |
| | | Integer promotion = isPromotion(uid); |
| | | orderPrivateCar.setPromotion(promotion); |
| | | |
| | | this.updateById(orderPrivateCar); |
| | | |
| | |
| | | } |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | Integer finalOldDriverId = oldDriverId; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState()); |
| | | pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState()); |
| | | if(orderPrivateCar.getType() == 2){ |
| | | pushUtil.pushFerryOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, 2); |
| | | if(finalOldDriverId !=null){ |
| | | pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState()); |
| | | pushUtil.pushOrderReassign(orderPrivateCar.getUserId(),1 , orderPrivateCar.getId(), 1); |
| | | pushUtil.pushOrderReassign(finalOldDriverId,2, orderPrivateCar.getId(), 1); |
| | | }else { |
| | | pushUtil.pushOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState()); |
| | | pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState()); |
| | | if(orderPrivateCar.getType() == 2){ |
| | | pushUtil.pushFerryOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, 2); |
| | | } |
| | | } |
| | | |
| | | } |
| | | }).start(); |
| | | |
| | |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已成功抢得快车订单,请及时联系客户!", orderPrivateCar.getDriverId(), 1); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderPrivateCar.getUserId(), 1); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){ |
| | | |
| | | if(pushMinistryOfTransport){ |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //上传数据 |
| | | pushMinistryOfTransportUtil.orderCreate(orderId); |
| | | pushMinistryOfTransportUtil.orderMatch(orderId); |
| | | } |
| | | } |
| | | }).start(); |
| | | }).start(); |
| | | } |
| | | |
| | | |
| | | return ResultUtil.success(orderPrivateCar.getId()); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | private Integer isPromotion(Integer userId){ |
| | | UserInfo userInfo = userInfoMapper.selectById(userId); |
| | | if(userInfo.getBindDriverId()!=null && userInfo.getBindExpireDate().getTime()<=System.currentTimeMillis()){ |
| | | String registAreaCode = userInfo.getRegistAreaCode(); |
| | | TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>().eq("districtCode", registAreaCode).ge("startTime", new Date()).lt("endTime", new Date()).last("AND FIND_IN_SET(" + 1 + ", bizType) limit 1")); |
| | | if(tDriverPromotionActivity!=null){ |
| | | return 2; |
| | | } |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | /** |
| | | * 获取订单详情页(服务中的页面) |
| | | * @param orderId |
| | |
| | | if(order!=null){ |
| | | orders.addAll(order); |
| | | } |
| | | String value = redisUtil.getValue("DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | order = this.baseMapper.queryOrderInfo(orderId,5,value.split(",")[0],value.split(",")[1]); |
| | | if(order!=null){ |
| | | orders.addAll(order); |
| | |
| | | if(order!=null){ |
| | | orders.addAll(order); |
| | | } |
| | | String value = redisUtil.getValue("DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | order = this.baseMapper.queryOrderInfo(orderPrivateCar.getPid(),5,value.split(",")[0],value.split(",")[1]); |
| | | if(order!=null){ |
| | | orders.addAll(order); |