|
|
@ -1,9 +1,6 @@ |
|
|
package cc.hiver.base.controller.manage; |
|
|
package cc.hiver.base.controller.manage; |
|
|
|
|
|
|
|
|
import cc.hiver.base.async.AddMessage; |
|
|
|
|
|
import cc.hiver.core.common.annotation.ClearAndReloadCache; |
|
|
import cc.hiver.core.common.annotation.ClearAndReloadCache; |
|
|
import cc.hiver.core.common.constant.CommonConstant; |
|
|
|
|
|
import cc.hiver.core.common.constant.UserConstant; |
|
|
|
|
|
import cc.hiver.core.common.redis.RedisTemplateHelper; |
|
|
import cc.hiver.core.common.redis.RedisTemplateHelper; |
|
|
import cc.hiver.core.common.utils.*; |
|
|
import cc.hiver.core.common.utils.*; |
|
|
import cc.hiver.core.common.vo.PageVo; |
|
|
import cc.hiver.core.common.vo.PageVo; |
|
|
@ -12,32 +9,21 @@ import cc.hiver.core.common.vo.SearchVo; |
|
|
import cc.hiver.core.dao.mapper.DeleteMapper; |
|
|
import cc.hiver.core.dao.mapper.DeleteMapper; |
|
|
import cc.hiver.core.entity.*; |
|
|
import cc.hiver.core.entity.*; |
|
|
import cc.hiver.core.service.*; |
|
|
import cc.hiver.core.service.*; |
|
|
import cc.hiver.core.service.mybatis.IUserRoleService; |
|
|
|
|
|
import cc.hiver.core.vo.RoleDTO; |
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import io.swagger.annotations.ApiParam; |
|
|
import io.swagger.annotations.ApiParam; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.hibernate.annotations.Cache; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.cache.annotation.CacheConfig; |
|
|
import org.springframework.cache.annotation.CacheConfig; |
|
|
import org.springframework.cache.annotation.CacheEvict; |
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
import org.springframework.data.domain.Page; |
|
|
import org.springframework.data.domain.Page; |
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
import javax.persistence.EntityManager; |
|
|
import javax.persistence.EntityManager; |
|
|
import javax.persistence.PersistenceContext; |
|
|
import javax.persistence.PersistenceContext; |
|
|
import javax.validation.Valid; |
|
|
import javax.validation.Valid; |
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
|
import java.net.URLDecoder; |
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用户管理接口 |
|
|
* 用户管理接口 |
|
|
@ -57,6 +43,9 @@ public class OrderController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private OrderService orderService; |
|
|
private OrderService orderService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private WorkerService workerService; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private DeleteMapper deleteMapper; |
|
|
private DeleteMapper deleteMapper; |
|
|
|
|
|
|
|
|
@ -75,7 +64,7 @@ public class OrderController { |
|
|
*/ |
|
|
*/ |
|
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET) |
|
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET) |
|
|
@ApiOperation(value = "多条件分页获取订单列表") |
|
|
@ApiOperation(value = "多条件分页获取订单列表") |
|
|
@Cacheable(cacheNames = "get method") |
|
|
//@Cacheable(cacheNames = ORDER)
|
|
|
public Result<Page<OrderXd>> getByCondition(OrderXd order, |
|
|
public Result<Page<OrderXd>> getByCondition(OrderXd order, |
|
|
SearchVo searchVo, |
|
|
SearchVo searchVo, |
|
|
PageVo pageVo) { |
|
|
PageVo pageVo) { |
|
|
@ -123,19 +112,18 @@ public class OrderController { |
|
|
* 2.正常状态下,判定当前抢单工押金余额是否充足,不足时需要将当前扛包工状态自动修正为不可接单状态,同时当前订单无法抢购。 |
|
|
* 2.正常状态下,判定当前抢单工押金余额是否充足,不足时需要将当前扛包工状态自动修正为不可接单状态,同时当前订单无法抢购。 |
|
|
* 3.正常抢单情况下,需要在redis中设置抢单后的剩余押金金额,要存在抢单锁机制,实时更新余额 |
|
|
* 3.正常抢单情况下,需要在redis中设置抢单后的剩余押金金额,要存在抢单锁机制,实时更新余额 |
|
|
* |
|
|
* |
|
|
* 计划暂定使用延时双删策略,尽量保证最终一致性,但不是强一致性: |
|
|
* 一:计划暂定使用延时双删策略,尽量保证最终一致性,但不是强一致性: |
|
|
* 先进行缓存清除,再执行update,最后(延迟N秒)再执行缓存清除。 |
|
|
* 先进行缓存清除,再执行update,最后(延迟N秒)再执行缓存清除。 |
|
|
* (延迟N秒)的时间要大于一次写操作的时间,一般为3-5秒。 |
|
|
* (延迟N秒)的时间要大于一次写操作的时间,一般为3-5秒。 |
|
|
* 原因:如果延迟时间小于写入redis的时间,会导致请求1清除了缓存,但是请求2缓存还未写入的尴尬。。。 |
|
|
* 原因:如果延迟时间小于写入redis的时间,会导致请求1清除了缓存,但是请求2缓存还未写入的尴尬。。。 |
|
|
* ps:一般写入的时间会远小于5秒 |
|
|
* ps:一般写入的时间会远小于5秒 |
|
|
|
|
|
* 二:抢单过程需要进行分布式锁ID进行锁定,用于抢单,上述一是为了保证数据的最终一致性。 |
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
@RequestMapping(value = "/rush/order/{orderId}", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/rush/order/{orderId}", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "抢单接口", notes = "需要通过下单编号获取订单信息后进行绑定") |
|
|
@ApiOperation(value = "抢单接口", notes = "需要通过下单编号获取订单信息后进行绑定") |
|
|
@ClearAndReloadCache(name = ORDER) |
|
|
@ClearAndReloadCache(name = ORDER) |
|
|
public Result rush(OrderXd u, |
|
|
public Result rush(OrderXd u) { |
|
|
@RequestParam(required = false) String[] roleIds) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orderService.update(u); |
|
|
orderService.update(u); |
|
|
|
|
|
|
|
|
@ -178,4 +166,22 @@ public class OrderController { |
|
|
return new ResultUtil<Page<OrderXd>>().setData(page); |
|
|
return new ResultUtil<Page<OrderXd>>().setData(page); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 待抢单的订单类型 |
|
|
|
|
|
* |
|
|
|
|
|
* 该方法用于返回app端要抢单的展示列表信息 |
|
|
|
|
|
* 1.需要根据订单工所在区域进行查询显示是否为所在区域订单信息 |
|
|
|
|
|
* 2.显示的订单信息为未被抢单的订单信息 |
|
|
|
|
|
* |
|
|
|
|
|
* key值定义暂定以区域为类型进行查询 |
|
|
|
|
|
* |
|
|
|
|
|
* */ |
|
|
|
|
|
@RequestMapping(value = "/app/getAll", method = RequestMethod.POST) |
|
|
|
|
|
@ApiOperation(value = "获取全部订单列表") |
|
|
|
|
|
@Cacheable(value="AllOrder",key="'Pending'") |
|
|
|
|
|
public Result<List<OrderXd>> getAll(@RequestBody OrderXd orderxd) { |
|
|
|
|
|
List<OrderXd> list = orderService.findByCondition(orderxd); |
|
|
|
|
|
return new ResultUtil<List<OrderXd>>().setData(list); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|