秒杀活动主键类型切换
This commit is contained in:
@@ -59,7 +59,7 @@ public class ShopFlashSaleActivityController extends BaseController {
|
|||||||
// @PreAuthorize("hasAuthority('shop:shopFlashSaleActivity:list')")
|
// @PreAuthorize("hasAuthority('shop:shopFlashSaleActivity:list')")
|
||||||
@Operation(summary = "根据id查询秒杀活动")
|
@Operation(summary = "根据id查询秒杀活动")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ApiResult<ShopFlashSaleActivity> get(@PathVariable("id") Long id) {
|
public ApiResult<ShopFlashSaleActivity> get(@PathVariable("id") Integer id) {
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
return success(shopFlashSaleActivityService.getByIdRel(id));
|
return success(shopFlashSaleActivityService.getByIdRel(id));
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ public class ShopFlashSaleActivityController extends BaseController {
|
|||||||
@OperationLog
|
@OperationLog
|
||||||
@Operation(summary = "开启/关闭秒杀活动状态")
|
@Operation(summary = "开启/关闭秒杀活动状态")
|
||||||
@PutMapping("/updateStatus")
|
@PutMapping("/updateStatus")
|
||||||
public ApiResult<?> updateStatus(@RequestParam("id") Long id) {
|
public ApiResult<?> updateStatus(@RequestParam("id") Integer id) {
|
||||||
return success(shopFlashSaleActivityService.updateStatus(id));
|
return success(shopFlashSaleActivityService.updateStatus(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ public class ShopFlashSaleActivityController extends BaseController {
|
|||||||
@Parameter(name = "id", description = "活动ID", required = true, example = "1"),
|
@Parameter(name = "id", description = "活动ID", required = true, example = "1"),
|
||||||
@Parameter(name = "sortNumber", description = "排序", required = true, example = "2")
|
@Parameter(name = "sortNumber", description = "排序", required = true, example = "2")
|
||||||
})
|
})
|
||||||
public ApiResult<?> updateSortNumber(@RequestParam("id") Long id, @RequestParam("sortNumber") Integer sortNumber) {
|
public ApiResult<?> updateSortNumber(@RequestParam("id") Integer id, @RequestParam("sortNumber") Integer sortNumber) {
|
||||||
return success(shopFlashSaleActivityService.updateSortNumber(id, sortNumber));
|
return success(shopFlashSaleActivityService.updateSortNumber(id, sortNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public interface ShopFlashSaleActivityService extends IService<ShopFlashSaleActi
|
|||||||
* @param id 秒杀活动编号
|
* @param id 秒杀活动编号
|
||||||
* @return ShopFlashSaleActivity
|
* @return ShopFlashSaleActivity
|
||||||
*/
|
*/
|
||||||
ShopFlashSaleActivity getByIdRel(Long id);
|
ShopFlashSaleActivity getByIdRel(Integer id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询个人可参与的活动数据
|
* 查询个人可参与的活动数据
|
||||||
@@ -52,7 +52,7 @@ public interface ShopFlashSaleActivityService extends IService<ShopFlashSaleActi
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean updateStatus(Long id);
|
Boolean updateStatus(Integer id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改秒杀活动排序
|
* 修改秒杀活动排序
|
||||||
@@ -60,6 +60,6 @@ public interface ShopFlashSaleActivityService extends IService<ShopFlashSaleActi
|
|||||||
* @param sortNumber
|
* @param sortNumber
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean updateSortNumber(Long id, Integer sortNumber);
|
Boolean updateSortNumber(Integer id, Integer sortNumber);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class ShopFlashSaleActivityServiceImpl extends ServiceImpl<ShopFlashSaleA
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShopFlashSaleActivity getByIdRel(Long id) {
|
public ShopFlashSaleActivity getByIdRel(Integer id) {
|
||||||
ShopFlashSaleActivityParam param = new ShopFlashSaleActivityParam();
|
ShopFlashSaleActivityParam param = new ShopFlashSaleActivityParam();
|
||||||
param.setId(id);
|
param.setId(id);
|
||||||
return param.getOne(baseMapper.selectListRel(param));
|
return param.getOne(baseMapper.selectListRel(param));
|
||||||
@@ -100,10 +100,10 @@ public class ShopFlashSaleActivityServiceImpl extends ServiceImpl<ShopFlashSaleA
|
|||||||
LambdaQueryChainWrapper<ShopFlashSaleActivity> activityWrapper = lambdaQuery().eq(ShopFlashSaleActivity::getStatus, 0).gt(ShopFlashSaleActivity::getStock, 0).eq(ShopFlashSaleActivity::getTenantId, tenantId)
|
LambdaQueryChainWrapper<ShopFlashSaleActivity> activityWrapper = lambdaQuery().eq(ShopFlashSaleActivity::getStatus, 0).gt(ShopFlashSaleActivity::getStock, 0).eq(ShopFlashSaleActivity::getTenantId, tenantId)
|
||||||
.apply("NOW() BETWEEN start_time AND end_time");
|
.apply("NOW() BETWEEN start_time AND end_time");
|
||||||
|
|
||||||
Map<Long, Integer> activityMap = new HashMap<>();
|
Map<Integer, Integer> activityMap = new HashMap<>();
|
||||||
if(!newUser){
|
if(!newUser){
|
||||||
//查询当前用户是否有下过秒杀活动订单数据【判断下单数量是否超过限制】
|
//查询当前用户是否有下过秒杀活动订单数据【判断下单数量是否超过限制】
|
||||||
List<Long> activityIdList = activityWrapper.list().stream().map(ShopFlashSaleActivity::getId).collect(Collectors.toList());
|
List<Integer> activityIdList = activityWrapper.list().stream().map(ShopFlashSaleActivity::getId).collect(Collectors.toList());
|
||||||
LambdaQueryWrapper<ShopOrder> shopOrderWrapper = new LambdaQueryWrapper<ShopOrder>().select(ShopOrder::getOrderId, ShopOrder::getActivityId, ShopOrder::getTotalNum)
|
LambdaQueryWrapper<ShopOrder> shopOrderWrapper = new LambdaQueryWrapper<ShopOrder>().select(ShopOrder::getOrderId, ShopOrder::getActivityId, ShopOrder::getTotalNum)
|
||||||
.eq(ShopOrder::getUserId, loginUser.getUserId()).in(ShopOrder::getActivityId, activityIdList).in(ShopOrder::getOrderStatus, Arrays.asList(0, 1));
|
.eq(ShopOrder::getUserId, loginUser.getUserId()).in(ShopOrder::getActivityId, activityIdList).in(ShopOrder::getOrderStatus, Arrays.asList(0, 1));
|
||||||
activityMap = shopOrderMapper.selectList(shopOrderWrapper).stream().collect(Collectors.groupingBy(ShopOrder::getActivityId, Collectors.summingInt(ShopOrder::getTotalNum)));
|
activityMap = shopOrderMapper.selectList(shopOrderWrapper).stream().collect(Collectors.groupingBy(ShopOrder::getActivityId, Collectors.summingInt(ShopOrder::getTotalNum)));
|
||||||
@@ -143,7 +143,7 @@ public class ShopFlashSaleActivityServiceImpl extends ServiceImpl<ShopFlashSaleA
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateStatus(Long id) {
|
public Boolean updateStatus(Integer id) {
|
||||||
ShopFlashSaleActivity saleActivity = baseMapper.selectById(id);
|
ShopFlashSaleActivity saleActivity = baseMapper.selectById(id);
|
||||||
if(saleActivity != null){
|
if(saleActivity != null){
|
||||||
if (saleActivity.getStatus() == 0){
|
if (saleActivity.getStatus() == 0){
|
||||||
@@ -164,7 +164,7 @@ public class ShopFlashSaleActivityServiceImpl extends ServiceImpl<ShopFlashSaleA
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateSortNumber(Long id, Integer sortNumber) {
|
public Boolean updateSortNumber(Integer id, Integer sortNumber) {
|
||||||
ShopFlashSaleActivity saleActivity = baseMapper.selectById(id);
|
ShopFlashSaleActivity saleActivity = baseMapper.selectById(id);
|
||||||
if(saleActivity != null){
|
if(saleActivity != null){
|
||||||
saleActivity.setSortNumber(sortNumber);
|
saleActivity.setSortNumber(sortNumber);
|
||||||
|
|||||||
Reference in New Issue
Block a user