| | |
| | | import com.supersavedriving.user.modular.system.util.MallBook.model.*; |
| | | import com.supersavedriving.user.modular.system.util.MallBook.util.Transfer; |
| | | import com.supersavedriving.user.modular.system.util.MallBook.util.TrhRequest; |
| | | import com.supersavedriving.user.modular.system.util.juhe.WeatherUtil; |
| | | import com.supersavedriving.user.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.user.modular.system.warpper.*; |
| | | import io.swagger.models.auth.In; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.net.InetAddress; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | | // @Autowired |
| | | // private RedissonClient redissonClient; |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | |
| | | */ |
| | | @Override |
| | | public ResultUtil travelOrder(Integer uid, TravelOrder travelOrder) throws Exception { |
| | | RLock lock1 = redissonClient.getLock("travelOrder:" + uid); |
| | | boolean lock2 = lock1.tryLock(5, TimeUnit.SECONDS); |
| | | if(!lock2){ |
| | | return ResultUtil.error("系统繁忙,请稍后重试"); |
| | | } |
| | | // RLock lock1 = redissonClient.getLock("travelOrder:" + uid); |
| | | // boolean lock2 = lock1.tryLock(5, 10, TimeUnit.SECONDS); |
| | | // if(!lock2){ |
| | | // return ResultUtil.error("系统繁忙,请稍后重试"); |
| | | // } |
| | | try { |
| | | List<Integer> state = Arrays.asList(101, 102, 103, 104, 105, 106, 107, 201, 401); |
| | | Order order = this.selectOne(new EntityWrapper<Order>().eq("userId", uid).eq("status", 1).in("state", state)); |
| | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | }finally { |
| | | lock1.unlock(); |
| | | // lock1.unlock(); |
| | | } |
| | | return ResultUtil.error("系统异常"); |
| | | } |