拼团和秒杀次数整合到get-detail接口 #41
@ -60,7 +60,7 @@ steps: # 定义流水线执行步骤,这些步骤将顺序执行
|
|||||||
|
|
||||||
port: 22 # 远程连接端口
|
port: 22 # 远程连接端口
|
||||||
|
|
||||||
command_timeout: 10m # 远程执行命令超时时间
|
command_timeout: 30m # 远程执行命令超时时间
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# - ls
|
# - ls
|
||||||
|
@ -41,6 +41,7 @@ import java.util.List;
|
|||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
|
import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
@Tag(name = "用户 APP - 拼团活动")
|
@Tag(name = "用户 APP - 拼团活动")
|
||||||
@RestController
|
@RestController
|
||||||
@ -134,16 +135,15 @@ public class AppCombinationActivityController {
|
|||||||
|
|
||||||
// 2. 获取活动商品
|
// 2. 获取活动商品
|
||||||
List<CombinationProductDO> products = activityService.getCombinationProductsByActivityId(activity.getId());
|
List<CombinationProductDO> products = activityService.getCombinationProductsByActivityId(activity.getId());
|
||||||
return success(CombinationActivityConvert.INSTANCE.convert3(activity, products));
|
AppCombinationActivityDetailRespVO appCombinationActivityDetailRespVO = CombinationActivityConvert.INSTANCE.convert3(activity, products);
|
||||||
}
|
// 3.获取已购买数量
|
||||||
@GetMapping("/getPurchaseTimes")
|
if (getLoginUserId() != null) {
|
||||||
@Operation(summary = "获得剩余拼团购买次数")
|
int seckillProductCount = tradeOrderApi.getCombinationProductCount(getLoginUserId(), id);
|
||||||
public CommonResult<Integer> getSeckillActivityPage(AppCombinationActivityPurchasesTimesReqVO reqVO) {
|
// 总次数减去下单过的次数 得到剩余次数
|
||||||
// 1. 获取总限购数量
|
appCombinationActivityDetailRespVO.setRemainingPurchases(Math.max(activity.getTotalLimitCount() - seckillProductCount, 0));
|
||||||
CombinationActivityDO combinationActivity = activityService.getCombinationActivity(reqVO.getActivityId());
|
} else {
|
||||||
// 2. 获取已购买数量
|
appCombinationActivityDetailRespVO.setRemainingPurchases(0);
|
||||||
int seckillProductCount = tradeOrderApi.getCombinationProductCount(reqVO.getUserId(), reqVO.getActivityId());
|
}
|
||||||
// 3. 总次数减去下单过的次数 得到剩余次数
|
return success(appCombinationActivityDetailRespVO);
|
||||||
return success(Math.max(combinationActivity.getTotalLimitCount() - seckillProductCount, 0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,9 @@ public class AppCombinationActivityDetailRespVO {
|
|||||||
@Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private List<Product> products;
|
private List<Product> products;
|
||||||
|
|
||||||
|
@Schema(description = "剩余购买次数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private Integer remainingPurchases;
|
||||||
|
|
||||||
@Schema(description = "商品信息")
|
@Schema(description = "商品信息")
|
||||||
@Data
|
@Data
|
||||||
public static class Product {
|
public static class Product {
|
||||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
@ -49,6 +50,7 @@ import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsync
|
|||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst;
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween;
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.TIME_FORMAT_ERROR;
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.TIME_FORMAT_ERROR;
|
||||||
|
|
||||||
@Tag(name = "用户 App - 秒杀活动")
|
@Tag(name = "用户 App - 秒杀活动")
|
||||||
@ -85,6 +87,9 @@ public class AppSeckillActivityController {
|
|||||||
@Resource
|
@Resource
|
||||||
private TradeOrderApi tradeOrderApi;
|
private TradeOrderApi tradeOrderApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberUserApi memberUserApi;
|
||||||
|
|
||||||
@GetMapping("/get-now")
|
@GetMapping("/get-now")
|
||||||
@Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用")
|
@Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用")
|
||||||
public CommonResult<AppSeckillActivityNowRespVO> getNowSeckillActivity() {
|
public CommonResult<AppSeckillActivityNowRespVO> getNowSeckillActivity() {
|
||||||
@ -216,17 +221,17 @@ public class AppSeckillActivityController {
|
|||||||
|
|
||||||
// 4. 拼接数据
|
// 4. 拼接数据
|
||||||
List<SeckillProductDO> productList = activityService.getSeckillProductListByActivityId(activity.getId());
|
List<SeckillProductDO> productList = activityService.getSeckillProductListByActivityId(activity.getId());
|
||||||
return success(SeckillActivityConvert.INSTANCE.convert3(activity, productList, startTime, endTime));
|
AppSeckillActivityDetailRespVO appSeckillActivityDetailRespVO = SeckillActivityConvert.INSTANCE.convert3(activity, productList, startTime, endTime);
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/getPurchaseTimes")
|
// 5.获取已购买数量
|
||||||
@Operation(summary = "获得剩余秒杀购买次数")
|
if (getLoginUserId() != null) {
|
||||||
public CommonResult<Integer> getSeckillActivityPage(AppSeckillPurchasesTimesReqVO reqVO) {
|
int seckillProductCount = tradeOrderApi.getSeckillProductCount(getLoginUserId(), id);
|
||||||
// 1. 获取总限购数量
|
// 总次数减去下单过的次数 得到剩余次数
|
||||||
SeckillActivityDO seckillActivity = activityService.getSeckillActivity(reqVO.getActivityId());
|
appSeckillActivityDetailRespVO.setRemainingPurchases(Math.max(activity.getTotalLimitCount() - seckillProductCount, 0));
|
||||||
// 2. 获取已购买数量
|
} else {
|
||||||
int seckillProductCount = tradeOrderApi.getSeckillProductCount(reqVO.getUserId(), reqVO.getActivityId());
|
appSeckillActivityDetailRespVO.setRemainingPurchases(0);
|
||||||
// 3. 总次数减去下单过的次数 得到剩余次数
|
}
|
||||||
return success(Math.max(seckillActivity.getTotalLimitCount() - seckillProductCount, 0));
|
|
||||||
|
return success(appSeckillActivityDetailRespVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,9 @@ public class AppSeckillActivityDetailRespVO {
|
|||||||
@Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private List<Product> products;
|
private List<Product> products;
|
||||||
|
|
||||||
|
@Schema(description = "剩余购买次数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private Integer remainingPurchases;
|
||||||
|
|
||||||
@Schema(description = "商品信息")
|
@Schema(description = "商品信息")
|
||||||
@Data
|
@Data
|
||||||
public static class Product {
|
public static class Product {
|
||||||
|
Loading…
Reference in New Issue
Block a user