| | |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.PhoneMapper; |
| | | import com.stylefeng.guns.modular.system.dao.RegionMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SysReformistMapper; |
| | | import com.stylefeng.guns.modular.system.model.AdditionalFee; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.OrderPosition; |
| | | import com.stylefeng.guns.modular.system.model.Region; |
| | | import com.stylefeng.guns.modular.system.service.IAdditionalFeeService; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IOpenCityService; |
| | | import com.stylefeng.guns.modular.system.service.IOrderService; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import com.stylefeng.guns.modular.system.warpper.OrderListWarpper; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | |
| | | @Autowired |
| | | private TaskUtil taskUtil; |
| | | |
| | | |
| | | @Autowired |
| | | private ChinaMobileUtil chinaMobileUtil; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderCrossCityService orderCrossCityService; |
| | | |
| | | |
| | | @Autowired |
| | | private IOrderLogisticsService orderLogisticsService; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IAdditionalFeeService additionalFeeService; |
| | | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | | @Autowired |
| | | private IOpenCityService openCityService; |
| | | |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer orderType, Integer uid) throws Exception { |
| | | public ResultUtil grabOrder(Integer orderId, Integer orderType, Integer uid) throws Exception { |
| | | //专车和出租是批量下单,所以这里需要将两种类型的抢单操作通过一个锁来一起控制 |
| | | if(1 == orderType || 2 == orderType){ |
| | | RLock lock = redissonClient.getLock("grabOrder:" + orderId); |
| | | if(!lock.tryLock()){ |
| | | return ResultUtil.error("抢单失败,请稍后重试"); |
| | | } |
| | | try { |
| | | if(1 == orderType){ |
| | | return orderPrivateCarService.grabOrder(orderId, uid); |
| | | } |
| | | if(2 == orderType){ |
| | | return orderTaxiService.grabOrder(orderId, uid); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | }finally { |
| | | lock.unlock(); |
| | | } |
| | | } |
| | | switch (orderType){ |
| | | case 1://专车 |
| | | return orderPrivateCarService.grabOrder(orderId, uid); |
| | | case 2://出租 |
| | | return orderTaxiService.grabOrder(orderId, uid); |
| | | case 3://城际 |
| | | return ResultUtil.success();//不作任何操作,跨城默认选择的司机 |
| | | case 4://同城小件 |
| | |
| | | */ |
| | | @Override |
| | | public Double queryReassignMoney(Integer orderId, Integer orderType) throws Exception { |
| | | Integer companyId = null; |
| | | Integer openCityId = null; |
| | | switch (orderType){ |
| | | case 1://专车 |
| | | companyId = orderPrivateCarService.selectById(orderId).getCompanyId(); |
| | | OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); |
| | | openCityId = openCityService.openCity1(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString()).getId(); |
| | | break; |
| | | case 2://出租 |
| | | companyId = orderTaxiService.selectById(orderId).getCompanyId(); |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(orderId); |
| | | openCityId = openCityService.openCity1(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString()).getId(); |
| | | break; |
| | | case 3://城际 |
| | | companyId = orderCrossCityService.selectById(orderId).getCompanyId(); |
| | | OrderCrossCity orderCrossCity = orderCrossCityService.selectById(orderId); |
| | | openCityId = openCityService.openCity1(orderCrossCity.getStartLon().toString(), orderCrossCity.getStartLat().toString()).getId(); |
| | | break; |
| | | case 4://同城小件 |
| | | companyId = orderLogisticsService.selectById(orderId).getCompanyId(); |
| | | OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId); |
| | | openCityId = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString()).getId(); |
| | | break; |
| | | case 5://跨城小件 |
| | | companyId = orderLogisticsService.selectById(orderId).getCompanyId(); |
| | | OrderLogistics orderLogistics1 = orderLogisticsService.selectById(orderId); |
| | | openCityId = openCityService.openCity1(orderLogistics1.getStartLon().toString(), orderLogistics1.getStartLat().toString()).getId(); |
| | | |
| | | break; |
| | | case 6: |
| | | break; |
| | | } |
| | | return sysReformistMapper.queryMoney(companyId); |
| | | return sysReformistMapper.queryMoney(openCityId); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Integer muoth = Long.valueOf((orderTaxi.getTravelTime().getTime() - System.currentTimeMillis()) / (1000 * 60)).intValue(); |
| | | //发送短信提醒 |
| | | aLiSendSms.sendSms(driver.getPhone(), "SMS_229613325", "{\"data\":\"" + orderTaxi.getStartAddress() + "\",\"data1\":\"" + orderTaxi.getEndAddress() + "\",\"data2\":\"" + muoth + "\"}"); |
| | | // aLiSendSms.sendSms(driver.getPhone(), "SMS_229613325", "{\"data\":\"" + orderTaxi.getStartAddress() + "\",\"data1\":\"" + orderTaxi.getEndAddress() + "\",\"data2\":\"" + muoth + "\"}"); |
| | | } |
| | | //专车 |
| | | List<OrderPrivateCar> list1 = orderPrivateCarService.queryMaturity(); |
| | |
| | | |
| | | Integer muoth = Long.valueOf((orderPrivateCar.getTravelTime().getTime() - System.currentTimeMillis()) / (1000 * 60)).intValue(); |
| | | //发送短信提醒 |
| | | aLiSendSms.sendSms(driver.getPhone(), "SMS_229613325", "{\"data\":\"" + orderPrivateCar.getStartAddress() + "\",\"data1\":\"" + orderPrivateCar.getEndAddress() + "\",\"data2\":\"" + muoth + "\"}"); |
| | | // aLiSendSms.sendSms(driver.getPhone(), "SMS_229613325", "{\"data\":\"" + orderPrivateCar.getStartAddress() + "\",\"data1\":\"" + orderPrivateCar.getEndAddress() + "\",\"data2\":\"" + muoth + "\"}"); |
| | | } |
| | | //跨城 |
| | | List<OrderCrossCity> orderCrossCities = orderCrossCityService.queryMaturity(); |
| | |
| | | |
| | | Integer muoth = Long.valueOf((orderCrossCity.getTravelTime().getTime() - System.currentTimeMillis()) / (1000 * 60)).intValue(); |
| | | //发送短信提醒 |
| | | aLiSendSms.sendSms(driver.getPhone(), "SMS_229613325", "{\"data\":\"" + orderCrossCity.getStartAddress() + "\",\"data1\":\"" + orderCrossCity.getEndAddress() + "\",\"data2\":\"" + muoth + "\"}"); |
| | | // aLiSendSms.sendSms(driver.getPhone(), "SMS_229613325", "{\"data\":\"" + orderCrossCity.getStartAddress() + "\",\"data1\":\"" + orderCrossCity.getEndAddress() + "\",\"data2\":\"" + muoth + "\"}"); |
| | | } |
| | | //小件物流 |
| | | List<OrderLogistics> orderLogistics = orderLogisticsService.queryMaturity(); |
| | |
| | | |
| | | Integer muoth = Long.valueOf((orderLogistics1.getTravelTime().getTime() - System.currentTimeMillis()) / (1000 * 60)).intValue(); |
| | | //发送短信提醒 |
| | | aLiSendSms.sendSms(driver.getPhone(), "SMS_229613325", "{\"data\":\"" + orderLogistics1.getStartAddress() + "\",\"data1\":\"" + orderLogistics1.getEndAddress() + "\",\"data2\":\"" + muoth + "\"}"); |
| | | // aLiSendSms.sendSms(driver.getPhone(), "SMS_229613325", "{\"data\":\"" + orderLogistics1.getStartAddress() + "\",\"data1\":\"" + orderLogistics1.getEndAddress() + "\",\"data2\":\"" + muoth + "\"}"); |
| | | } |
| | | if(drivers.size() > 0){ |
| | | driverService.updateBatchById(drivers);//批量修改状态为服务中 |
| | |
| | | } |
| | | //调用移动的小号接口 |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | 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")); |
| | | // } |
| | | orderPrivateCarService.updateById(orderPrivateCar); |
| | | } |
| | | break; |
| | |
| | | } |
| | | //调用移动的小号接口 |
| | | Driver driver = driverService.selectById(orderTaxi.getDriverId()); |
| | | Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderTaxi.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); |
| | | if(String.valueOf(map.get("code")).equals("200")){ |
| | | orderTaxi.setTelX(map.get("telX")); |
| | | orderTaxi.setBindId(map.get("bindId")); |
| | | } |
| | | // Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderTaxi.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderTaxi.setTelX(map.get("telX")); |
| | | // orderTaxi.setBindId(map.get("bindId")); |
| | | // } |
| | | orderTaxiService.updateById(orderTaxi); |
| | | } |
| | | break; |
| | |
| | | } |
| | | //调用移动的小号接口 |
| | | Driver driver = driverService.selectById(orderCrossCity.getDriverId()); |
| | | Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderCrossCity.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); |
| | | if(String.valueOf(map.get("code")).equals("200")){ |
| | | orderCrossCity.setTelX(map.get("telX")); |
| | | orderCrossCity.setBindId(map.get("bindId")); |
| | | } |
| | | // Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderCrossCity.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderCrossCity.setTelX(map.get("telX")); |
| | | // orderCrossCity.setBindId(map.get("bindId")); |
| | | // } |
| | | orderCrossCityService.updateById(orderCrossCity); |
| | | } |
| | | break; |
| | |
| | | state = orderTaxi.getState(); |
| | | |
| | | //司机手动确认收款,删除限制司机6分钟不能接单的标识 |
| | | String vehicle = redisUtil.getValue("VEHICLE"); |
| | | String vehicle = (String) redisTemplate.opsForValue().get("VEHICLE"); |
| | | if(ToolUtil.isNotEmpty(vehicle)){ |
| | | JSONArray jsonArray = JSON.parseArray(vehicle); |
| | | for(int i = 0; i < jsonArray.size(); i++){ |
| | |
| | | break; |
| | | } |
| | | } |
| | | redisUtil.setStrValue("VEHICLE", jsonArray.toJSONString()); |
| | | redisTemplate.opsForValue().set("VEHICLE", jsonArray.toJSONString()); |
| | | } |
| | | break; |
| | | } |