mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 01:01:52 +08:00
code review:营销文章
This commit is contained in:
parent
64b842ed94
commit
453f69931f
@ -46,7 +46,7 @@ public class AppActivityController {
|
||||
@Parameter(name = "spuId", description = "商品编号", required = true)
|
||||
public CommonResult<List<AppActivityRespVO>> getActivityListBySpuId(@RequestParam("spuId") Long spuId) {
|
||||
// 每种活动,只返回一个
|
||||
return success(getAppActivityRespVOList(Collections.singletonList(spuId)));
|
||||
return success(getAppActivityList(Collections.singletonList(spuId)));
|
||||
}
|
||||
|
||||
@GetMapping("/list-by-spu-ids")
|
||||
@ -57,16 +57,17 @@ public class AppActivityController {
|
||||
return success(MapUtil.empty());
|
||||
}
|
||||
// 每种活动,只返回一个;key 为 SPU 编号
|
||||
return success(convertMultiMap(getAppActivityRespVOList(spuIds), AppActivityRespVO::getSpuId));
|
||||
return success(convertMultiMap(getAppActivityList(spuIds), AppActivityRespVO::getSpuId));
|
||||
}
|
||||
|
||||
private List<AppActivityRespVO> getAppActivityRespVOList(Collection<Long> spuIds) {
|
||||
private List<AppActivityRespVO> getAppActivityList(Collection<Long> spuIds) {
|
||||
if (CollUtil.isEmpty(spuIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<AppActivityRespVO> activityList = new ArrayList<>();
|
||||
// 拼团活动-获取开启的且开始的且没有结束的活动
|
||||
|
||||
// 1. 拼团活动 - 获取开启的且开始的且没有结束的活动
|
||||
List<CombinationActivityDO> combinationActivities = combinationActivityService.getCombinationActivityBySpuIdsAndStatusAndDateTimeLt(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
|
||||
if (CollUtil.isNotEmpty(combinationActivities)) {
|
||||
@ -76,7 +77,8 @@ public class AppActivityController {
|
||||
.setSpuId(item.getSpuId()).setStartTime(item.getStartTime()).setEndTime(item.getEndTime()));
|
||||
});
|
||||
}
|
||||
// 秒杀活动-获取开启的且开始的且没有结束的活动
|
||||
|
||||
// 2. 秒杀活动 - 获取开启的且开始的且没有结束的活动
|
||||
List<SeckillActivityDO> seckillActivities = seckillActivityService.getSeckillActivityBySpuIdsAndStatusAndDateTimeLt(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
|
||||
if (CollUtil.isNotEmpty(seckillActivities)) {
|
||||
@ -86,7 +88,8 @@ public class AppActivityController {
|
||||
.setSpuId(item.getSpuId()).setStartTime(item.getStartTime()).setEndTime(item.getEndTime()));
|
||||
});
|
||||
}
|
||||
// 砍价活动-获取开启的且开始的且没有结束的活动
|
||||
|
||||
// 3. 砍价活动 - 获取开启的且开始的且没有结束的活动
|
||||
List<BargainActivityDO> bargainActivities = bargainActivityService.getBargainActivityBySpuIdsAndStatusAndDateTimeLt(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
|
||||
if (CollUtil.isNotEmpty(bargainActivities)) {
|
||||
|
@ -32,7 +32,7 @@ public class AppArticleCategoryController {
|
||||
public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() {
|
||||
List<ArticleCategoryDO> categoryList = articleCategoryService.getArticleCategoryListByStatus(
|
||||
CommonStatusEnum.ENABLE.getStatus());
|
||||
categoryList.sort(Comparator.comparing(ArticleCategoryDO::getSort).reversed()); // 按 sort 降序排列
|
||||
categoryList.sort(Comparator.comparing(ArticleCategoryDO::getSort)); // 按 sort 降序排列
|
||||
return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList));
|
||||
}
|
||||
|
||||
|
@ -56,10 +56,12 @@ public class AppArticleController {
|
||||
return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id)));
|
||||
}
|
||||
|
||||
// TODO @puhui999:add-browse-count 噢;前端 uniapp 也要接下;就是打开文章的时候,调用下这个接口;
|
||||
@PutMapping("/add-browseCount")
|
||||
@Operation(summary = "增加文章浏览量")
|
||||
@Parameter(name = "id", description = "文章编号", example = "1024")
|
||||
public CommonResult<Boolean> addBrowseCount(@RequestParam("id") Long id) {
|
||||
// TODO @puhui999:addArticleBrowseCount
|
||||
articleService.addBrowseCount(id);
|
||||
return success(true);
|
||||
}
|
||||
|
@ -204,9 +204,6 @@ public interface CombinationActivityConvert {
|
||||
return respVO;
|
||||
}
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
CombinationRecordDO convert5(CombinationRecordDO headRecord);
|
||||
|
||||
/**
|
||||
* 转换生成虚拟成团虚拟记录
|
||||
*
|
||||
@ -214,21 +211,19 @@ public interface CombinationActivityConvert {
|
||||
* @return 虚拟记录列表
|
||||
*/
|
||||
default List<CombinationRecordDO> convertVirtualRecordList(CombinationRecordDO headRecord) {
|
||||
List<CombinationRecordDO> createRecords = new ArrayList<>();
|
||||
// 计算需要创建的虚拟成团记录数量
|
||||
int count = headRecord.getUserSize() - headRecord.getUserCount();
|
||||
List<CombinationRecordDO> createRecords = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
// 基础信息和团长保持一致
|
||||
CombinationRecordDO newRecord = convert5(headRecord);
|
||||
// 虚拟信息
|
||||
newRecord.setCount(0);
|
||||
newRecord.setUserId(0L);
|
||||
newRecord.setNickname("");
|
||||
newRecord.setAvatar("");
|
||||
newRecord.setOrderId(0L);
|
||||
newRecord.setCount(0) // 会单独更新下,在后续的 Service 逻辑里
|
||||
.setUserId(0L).setNickname("").setAvatar("").setOrderId(0L);
|
||||
createRecords.add(newRecord);
|
||||
}
|
||||
return createRecords;
|
||||
}
|
||||
@Mapping(target = "id", ignore = true)
|
||||
CombinationRecordDO convert5(CombinationRecordDO headRecord);
|
||||
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
|
||||
.groupBy("spu_id"));
|
||||
}
|
||||
|
||||
// TODO @puhui999:是不是只要 endTime 小于就可以啦;
|
||||
/**
|
||||
* 获取指定活动编号的活动列表且
|
||||
* 开始时间和结束时间小于给定时间 dateTime 的活动列表
|
||||
|
@ -10,7 +10,6 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryD
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -112,12 +111,10 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addBrowseCount(Long id) {
|
||||
// 校验文章是否存在
|
||||
validateArticleExists(id);
|
||||
|
||||
// 增加浏览次数 TODO 先简单做,用户规模不大,只 +1
|
||||
// 增加浏览次数
|
||||
articleMapper.updateBrowseCount(id);
|
||||
}
|
||||
|
||||
|
@ -369,6 +369,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
keyValue.setValue(keyValue.getValue() + 1);
|
||||
}
|
||||
} catch (Exception ignored) { // 处理异常继续循环
|
||||
// TODO @puhui999:拼团过期 or 虚拟成团 可以改成 expireCombinationRecord;因为找方法更容易一些;
|
||||
log.error("[拼团过期 or 虚拟成团][record({}) 处理异常,请进行处理!record 数据是:{}]",
|
||||
record.getId(), JsonUtils.toJsonString(record));
|
||||
}
|
||||
@ -383,10 +384,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleExpireRecord(CombinationRecordDO headRecord) {
|
||||
// 1.更新拼团记录
|
||||
// 1. 更新拼团记录
|
||||
List<CombinationRecordDO> headAndRecords = updateBatchCombinationRecords(headRecord,
|
||||
CombinationRecordStatusEnum.FAILED);
|
||||
// 2.订单取消
|
||||
// 2. 订单取消
|
||||
headAndRecords.forEach(item -> tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId()));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user