mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
trade:砍价记录的详情 100%
This commit is contained in:
parent
5f57cc6247
commit
8e7b295d24
@ -92,40 +92,28 @@ public class AppBargainRecordController {
|
||||
// 1. 查询砍价记录 + 砍价活动
|
||||
Assert.isTrue(id != null || activityId != null, "砍价记录编号和活动编号不能同时为空");
|
||||
BargainRecordDO record = id != null ? bargainRecordService.getBargainRecord(id)
|
||||
: bargainRecordService.getInProgressBargainRecord(getLoginUserId(), activityId);
|
||||
: bargainRecordService.getLastBargainRecord(getLoginUserId(), activityId);
|
||||
if (activityId == null || record != null) {
|
||||
activityId = record.getActivityId();
|
||||
}
|
||||
// 2. 查询助力记录
|
||||
Integer helpAction = getHelpAction(record, activityId);
|
||||
Long userId = getLoginUserId();
|
||||
Integer helpAction = getHelpAction(userId, record, activityId);
|
||||
// 3. 如果是自己的订单,则查询订单信息
|
||||
TradeOrderRespDTO order = record != null && record.getOrderId() != null && record.getUserId().equals(getLoginUserId())
|
||||
? tradeOrderApi.getOrder(record.getOrderId()) : null;
|
||||
// TODO 继续查询别的字段
|
||||
|
||||
// 拼接返回
|
||||
return success(BargainRecordConvert.INSTANCE.convert02(record, helpAction));
|
||||
//
|
||||
// AppBargainRecordDetailRespVO detail = new AppBargainRecordDetailRespVO();
|
||||
// detail.setId(1L);
|
||||
// detail.setUserId(1L);
|
||||
// detail.setSpuId(1L);
|
||||
// detail.setSkuId(1L);
|
||||
// detail.setPrice(500);
|
||||
// detail.setActivityId(1L);
|
||||
// detail.setBargainPrice(150);
|
||||
// detail.setPrice(200);
|
||||
// detail.setPayPrice(180);
|
||||
// detail.setStatus(1);
|
||||
// detail.setExpireTime(LocalDateTimeUtils.addTime(Duration.ofDays(2)));
|
||||
// return success(detail);
|
||||
return success(BargainRecordConvert.INSTANCE.convert02(record, helpAction, order));
|
||||
}
|
||||
|
||||
private Integer getHelpAction(BargainRecordDO record, Long activityId) {
|
||||
private Integer getHelpAction(Long userId, BargainRecordDO record, Long activityId) {
|
||||
// 0.1 如果没有活动,无法帮砍
|
||||
if (activityId == null) {
|
||||
return null;
|
||||
}
|
||||
// 0.2 如果是自己的砍价记录,无法帮砍
|
||||
Long userId = getLoginUserId();
|
||||
if (record != null && record.getUserId().equals(userId)) {
|
||||
return null;
|
||||
}
|
||||
@ -141,7 +129,7 @@ public class AppBargainRecordController {
|
||||
&& bargainHelpService.getBargainHelpCountByActivity(activityId, userId) >= activity.getBargainCount()) {
|
||||
return AppBargainRecordDetailRespVO.HELP_ACTION_FULL;
|
||||
}
|
||||
|
||||
// 3. 允许助力
|
||||
return AppBargainRecordDetailRespVO.HELP_ACTION_NONE;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityD
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
@ -83,6 +84,9 @@ public interface BargainRecordConvert {
|
||||
return summary;
|
||||
}
|
||||
|
||||
AppBargainRecordDetailRespVO convert02(BargainRecordDO record, Integer helpAction);
|
||||
@Mapping(source = "record.id", target = "id")
|
||||
@Mapping(source = "record.userId", target = "userId")
|
||||
@Mapping(source = "record.status", target = "status")
|
||||
AppBargainRecordDetailRespVO convert02(BargainRecordDO record, Integer helpAction, TradeOrderRespDTO order);
|
||||
|
||||
}
|
||||
|
@ -42,6 +42,14 @@ public interface BargainRecordMapper extends BaseMapperX<BargainRecordDO> {
|
||||
.eq(BargainRecordDO::getStatus, status));
|
||||
}
|
||||
|
||||
default BargainRecordDO selectLastByUserIdAndActivityId(Long userId, Long activityId) {
|
||||
return selectOne(new LambdaQueryWrapper<>(BargainRecordDO.class)
|
||||
.eq(BargainRecordDO::getUserId, userId)
|
||||
.eq(BargainRecordDO::getActivityId, activityId)
|
||||
.orderByDesc(BargainRecordDO::getId)
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
|
||||
default Long selectCountByUserIdAndActivityIdAndStatus(
|
||||
Long userId, Long activityId, Integer status) {
|
||||
return selectCount(new LambdaQueryWrapper<>(BargainRecordDO.class)
|
||||
|
@ -74,15 +74,13 @@ public interface BargainRecordService {
|
||||
BargainRecordDO getBargainRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户当前正在【砍价中】+ 指定活动的砍价记录
|
||||
*
|
||||
* 因为一个用户,在一个砍价活动,【砍价中】只存在一条
|
||||
* 获得用户在当前砍价活动中的最后一条砍价记录
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param activityId 砍价记录编号
|
||||
* @return 砍价记录
|
||||
*/
|
||||
BargainRecordDO getInProgressBargainRecord(Long userId, Long activityId);
|
||||
BargainRecordDO getLastBargainRecord(Long userId, Long activityId);
|
||||
|
||||
/**
|
||||
* 获得砍价人数 Map
|
||||
|
@ -115,10 +115,8 @@ public class BargainRecordServiceImpl implements BargainRecordService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BargainRecordDO getInProgressBargainRecord(Long userId, Long activityId) {
|
||||
List<BargainRecordDO> list = bargainRecordMapper.selectListByUserIdAndActivityIdAndStatus(
|
||||
userId, activityId, BargainRecordStatusEnum.IN_PROGRESS.getStatus());
|
||||
return CollUtil.getFirst(list);
|
||||
public BargainRecordDO getLastBargainRecord(Long userId, Long activityId) {
|
||||
return bargainRecordMapper.selectLastByUserIdAndActivityId(userId, activityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,14 @@ public interface TradeOrderApi {
|
||||
*/
|
||||
List<TradeOrderRespDTO> getOrderList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得订单
|
||||
*
|
||||
* @param id 订单编号
|
||||
* @return 订单
|
||||
*/
|
||||
TradeOrderRespDTO getOrder(Long id);
|
||||
|
||||
// TODO 芋艿:看看是不是可以删除掉;
|
||||
/**
|
||||
* 获取订单状态
|
||||
|
@ -34,6 +34,11 @@ public class TradeOrderApiImpl implements TradeOrderApi {
|
||||
return TradeOrderConvert.INSTANCE.convertList04(tradeOrderQueryService.getOrderList(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TradeOrderRespDTO getOrder(Long id) {
|
||||
return TradeOrderConvert.INSTANCE.convert(tradeOrderQueryService.getOrder(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getOrderStatus(Long id) {
|
||||
TradeOrderDO order = tradeOrderQueryService.getOrder(id);
|
||||
|
@ -38,6 +38,7 @@ import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.Named;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -261,6 +262,7 @@ public interface TradeOrderConvert {
|
||||
return bo;
|
||||
}
|
||||
|
||||
@Named("convertList04")
|
||||
List<TradeOrderRespDTO> convertList04(List<TradeOrderDO> list);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user