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