mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-25 00:31:53 +08:00
【代码评审】商城:积分商城的 review
This commit is contained in:
parent
3ccf8c7a5c
commit
e99a6e4ec8
@ -1,48 +0,0 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城商品分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PointProductPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "积分商城活动 id", example = "29388")
|
||||
private Long activityId;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", example = "8112")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", example = "2736")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "可兑换数量", example = "3926")
|
||||
private Integer maxCount;
|
||||
|
||||
@Schema(description = "兑换积分")
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", example = "15860")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "兑换类型", example = "2")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "积分商城商品状态", example = "2")
|
||||
private Integer activityStatus;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.mysql.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointProductDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -19,18 +16,6 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface PointProductMapper extends BaseMapperX<PointProductDO> {
|
||||
|
||||
default PageResult<PointProductDO> selectPage(PointProductPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PointProductDO>()
|
||||
.eqIfPresent(PointProductDO::getActivityId, reqVO.getActivityId())
|
||||
.eqIfPresent(PointProductDO::getSpuId, reqVO.getSpuId())
|
||||
.eqIfPresent(PointProductDO::getSkuId, reqVO.getSkuId())
|
||||
.eqIfPresent(PointProductDO::getPoint, reqVO.getPoint())
|
||||
.eqIfPresent(PointProductDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(PointProductDO::getActivityStatus, reqVO.getActivityStatus())
|
||||
.betweenIfPresent(PointProductDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(PointProductDO::getId));
|
||||
}
|
||||
|
||||
default List<PointProductDO> selectListByActivityId(Collection<Long> activityIds) {
|
||||
return selectList(PointProductDO::getActivityId, activityIds);
|
||||
}
|
||||
|
@ -51,12 +51,6 @@ public class PointActivityServiceImpl implements PointActivityService {
|
||||
@Resource
|
||||
private ProductSkuApi productSkuApi;
|
||||
|
||||
private static List<PointProductDO> buildPointProductDO(PointActivityDO pointActivity, List<PointProductSaveReqVO> products) {
|
||||
return BeanUtils.toBean(products, PointProductDO.class, product -> {
|
||||
product.setActivityId(pointActivity.getId()).setActivityStatus(pointActivity.getStatus());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createPointActivity(PointActivitySaveReqVO createReqVO) {
|
||||
// 1.1 校验商品是否存在
|
||||
@ -72,10 +66,14 @@ public class PointActivityServiceImpl implements PointActivityService {
|
||||
pointActivityMapper.insert(pointActivity);
|
||||
// 2.2 插入积分商城活动商品
|
||||
pointProductMapper.insertBatch(buildPointProductDO(pointActivity, createReqVO.getProducts()));
|
||||
// 返回
|
||||
return pointActivity.getId();
|
||||
}
|
||||
|
||||
private static List<PointProductDO> buildPointProductDO(PointActivityDO pointActivity, List<PointProductSaveReqVO> products) {
|
||||
return BeanUtils.toBean(products, PointProductDO.class, product ->
|
||||
product.setActivityId(pointActivity.getId()).setActivityStatus(pointActivity.getStatus()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePointActivity(PointActivitySaveReqVO updateReqVO) {
|
||||
// 1.1 校验存在
|
||||
|
Loading…
Reference in New Issue
Block a user