| | |
| | | import com.stylefeng.guns.modular.system.model.OrderPosition; |
| | | 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; |
| | |
| | | |
| | | @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); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | //调用移动的小号接口 |
| | | 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; |