| | |
| | | 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 RedissonClient redissonClient; |
| | | @Autowired |
| | | private IOpenCityService openCityService; |
| | | |
| | |
| | | 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("抢单失败,请稍后重试"); |
| | | } |
| | | // RLock lock = redissonClient.getLock("grabOrder:" + orderId); |
| | | // if(!lock.tryLock()){ |
| | | // return ResultUtil.error("抢单失败,请稍后重试"); |
| | | // } |
| | | try { |
| | | if(1 == orderType){ |
| | | return orderPrivateCarService.grabOrder(orderId, uid); |
| | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | }finally { |
| | | lock.unlock(); |
| | | // lock.unlock(); |
| | | } |
| | | } |
| | | switch (orderType){ |