diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
index 4b6cb8ca6..1cb1b1523 100644
--- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
+++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
@@ -23,4 +23,7 @@ public interface ErrorCodeConstants {
ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1003004000, "优惠劵模板不存在");
ErrorCode COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL = new ErrorCode(1003004001, "发放数量不能小于已领取数量({})");
+ // ========== 优惠劵模板 1003005000 ==========
+ ErrorCode COUPON_NOT_EXISTS = new ErrorCode(1003005000, "优惠劵不存在");
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/pom.xml b/yudao-module-mall/yudao-module-promotion-biz/pom.xml
index e8b764019..266cb1511 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/pom.xml
+++ b/yudao-module-mall/yudao-module-promotion-biz/pom.xml
@@ -29,6 +29,11 @@
yudao-module-product-api
${revision}
+
+ cn.iocoder.boot
+ yudao-module-member-api
+ ${revision}
+
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java
new file mode 100755
index 000000000..b781bc0f5
--- /dev/null
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java
@@ -0,0 +1,67 @@
+package cn.iocoder.yudao.module.promotion.controller.admin.coupon;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
+import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
+import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
+import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponPageItemRespVO;
+import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponPageReqVO;
+import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
+import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
+import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.Map;
+import java.util.Set;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
+
+@Api(tags = "管理后台 - 优惠劵")
+@RestController
+@RequestMapping("/promotion/coupon")
+@Validated
+public class CouponController {
+
+ @Resource
+ private CouponService couponService;
+ @Resource
+ private MemberUserApi memberUserApi;
+
+// @GetMapping("/get")
+// @ApiOperation("获得优惠劵")
+// @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+// @PreAuthorize("@ss.hasPermission('promotion:coupon:query')")
+// public CommonResult getCoupon(@RequestParam("id") Long id) {
+// CouponDO coupon = couponService.getCoupon(id);
+// return success(CouponConvert.INSTANCE.convert(coupon));
+// }
+
+ @GetMapping("/page")
+ @ApiOperation("获得优惠劵分页")
+ @PreAuthorize("@ss.hasPermission('promotion:coupon:query')")
+ public CommonResult> getCouponPage(@Valid CouponPageReqVO pageVO) {
+ PageResult pageResult = couponService.getCouponPage(pageVO);
+ PageResult pageResulVO = CouponConvert.INSTANCE.convertPage(pageResult);
+ if (CollUtil.isEmpty(pageResulVO.getList())) {
+ return success(pageResulVO);
+ }
+ // 读取用户信息,进行拼接
+ Set userIds = convertSet(pageResult.getList(), CouponDO::getUserId);
+ Map userMap = memberUserApi.getUserMap(userIds);
+ pageResulVO.getList().forEach(itemRespVO -> MapUtils.findAndThen(userMap, itemRespVO.getUserId(),
+ userRespDTO -> itemRespVO.setNickname(userRespDTO.getNickname())));
+ return success(pageResulVO);
+ }
+
+}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponBaseVO.java
new file mode 100755
index 000000000..feabb6fc4
--- /dev/null
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponBaseVO.java
@@ -0,0 +1,103 @@
+package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo;
+
+import cn.iocoder.yudao.framework.common.validation.InEnum;
+import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
+import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
+
+/**
+* 优惠劵 Base VO,提供给添加、修改、详细的子 VO 使用
+* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+*/
+@Data
+public class CouponBaseVO {
+
+ // ========== 基本信息 BEGIN ==========
+ @ApiModelProperty(value = "优惠劵模板编号", required = true, example = "1024")
+ @NotNull(message = "优惠劵模板编号不能为空")
+ private Integer templateId;
+
+ @ApiModelProperty(value = "优惠劵名", required = true, example = "春节送送送")
+ @NotNull(message = "优惠劵名不能为空")
+ private String name;
+
+ @ApiModelProperty(value = "优惠码状态", required = true, example = "1", notes = "参见 CouponStatusEnum 枚举")
+ private Integer status;
+
+ // ========== 基本信息 END ==========
+
+ // ========== 领取情况 BEGIN ==========
+ @ApiModelProperty(value = "用户编号", required = true, example = "1")
+ @NotNull(message = "用户编号不能为空")
+ private Long userId;
+
+ @ApiModelProperty(value = "领取方式", required = true, example = "1", notes = "参见 CouponTakeTypeEnum 枚举类")
+ @NotNull(message = "领取方式不能为空")
+ private Integer takeType;
+ // ========== 领取情况 END ==========
+
+ // ========== 使用规则 BEGIN ==========
+ @ApiModelProperty(value = "是否设置满多少金额可用", required = true, example = "100", notes = "单位:分;0 - 不限制")
+ @NotNull(message = "是否设置满多少金额可用不能为空")
+ private Integer usePrice;
+
+ @ApiModelProperty(value = "固定日期 - 生效开始时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
+ private Date validStartTime;
+
+ @ApiModelProperty(value = "固定日期 - 生效结束时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
+ private Date validEndTime;
+
+ @ApiModelProperty(value = "商品范围", required = true, example = "1", notes = "参见 PromotionProductScopeEnum 枚举类")
+ @NotNull(message = "商品范围不能为空")
+ @InEnum(PromotionProductScopeEnum.class)
+ private Integer productScope;
+
+ @ApiModelProperty(value = "商品 SPU 编号的数组", example = "1,3")
+ private List productSpuIds;
+ // ========== 使用规则 END ==========
+
+ // ========== 使用效果 BEGIN ==========
+ @ApiModelProperty(value = "优惠类型", required = true, example = "1", notes = "参见 PromotionDiscountTypeEnum 枚举")
+ @NotNull(message = "优惠类型不能为空")
+ @InEnum(PromotionDiscountTypeEnum.class)
+ private Integer discountType;
+
+ @ApiModelProperty(value = "折扣百分比", example = "80", notes = "例如说,80% 为 80")
+ private Integer discountPercent;
+
+ @ApiModelProperty(value = "优惠金额", example = "10", notes = "单位:分")
+ @Min(value = 0, message = "优惠金额需要大于等于 0")
+ private Integer discountPrice;
+
+ @ApiModelProperty(value = "折扣上限", example = "100", notes = "单位:分,仅在 discountType 为 PERCENT 使用")
+ private Integer discountLimitPrice;
+ // ========== 使用效果 END ==========
+
+ // ========== 使用情况 BEGIN ==========
+
+ @ApiModelProperty(value = "使用订单号", example = "4096")
+ private Long useOrderId;
+
+ @ApiModelProperty(value = "使用时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
+ private Date useTime;
+
+ // ========== 使用情况 END ==========
+
+}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponPageItemRespVO.java
new file mode 100755
index 000000000..976df7972
--- /dev/null
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponPageItemRespVO.java
@@ -0,0 +1,18 @@
+package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@ApiModel("管理后台 - 优惠劵分页的每一项 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CouponPageItemRespVO extends CouponRespVO {
+
+ @ApiModelProperty(value = "用户昵称", example = "老芋艿")
+ private String nickname;
+
+}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponPageReqVO.java
new file mode 100755
index 000000000..192dc5dba
--- /dev/null
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponPageReqVO.java
@@ -0,0 +1,31 @@
+package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 优惠劵分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CouponPageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "优惠劵模板编号", example = "2048")
+ private Long templateId;
+
+ @ApiModelProperty(value = "创建时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date[] createTime;
+
+ @ApiModelProperty(value = "用户昵称", example = "芋艿", notes = "模糊匹配")
+ private String nickname;
+
+}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponRespVO.java
new file mode 100755
index 000000000..0832766ec
--- /dev/null
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponRespVO.java
@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Date;
+
+@ApiModel("管理后台 - 优惠劵 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CouponRespVO extends CouponBaseVO {
+
+ @ApiModelProperty(value = "优惠劵编号", required = true, example = "1024")
+ private Long id;
+
+ @ApiModelProperty(value = "创建时间", required = true)
+ private Date createTime;
+
+}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java
new file mode 100755
index 000000000..3d715c772
--- /dev/null
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.promotion.convert.coupon;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponPageItemRespVO;
+import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+/**
+ * 优惠劵 Convert
+ *
+ * @author 芋道源码
+ */
+@Mapper
+public interface CouponConvert {
+
+ CouponConvert INSTANCE = Mappers.getMapper(CouponConvert.class);
+
+ PageResult convertPage(PageResult page);
+
+}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java
new file mode 100755
index 000000000..8dc85db60
--- /dev/null
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java
@@ -0,0 +1,28 @@
+package cn.iocoder.yudao.module.promotion.dal.mysql.coupon;
+
+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.coupon.vo.CouponPageReqVO;
+import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.Collection;
+
+/**
+ * 优惠劵 Mapper
+ *
+ * @author 芋道源码
+ */
+@Mapper
+public interface CouponMapper extends BaseMapperX {
+
+ default PageResult selectPage(CouponPageReqVO reqVO, Collection userIds) {
+ return selectPage(reqVO, new LambdaQueryWrapperX()
+ .eqIfPresent(CouponDO::getTemplateId, reqVO.getTemplateId())
+ .inIfPresent(CouponDO::getUserId, userIds)
+ .betweenIfPresent(CouponDO::getCreateTime, reqVO.getCreateTime())
+ .orderByDesc(CouponDO::getId));
+ }
+
+}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java
index 7fdac901d..009a3f35e 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java
@@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.promotion.service.coupon;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponPageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
/**
@@ -21,4 +23,12 @@ public interface CouponService {
*/
CouponDO validCoupon(Long id, Long userId);
+ /**
+ * 获得优惠劵分页
+ *
+ * @param pageReqVO 分页查询
+ * @return 优惠劵分页
+ */
+ PageResult getCouponPage(CouponPageReqVO pageReqVO);
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
index 067bd84bc..550b0c63e 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
@@ -1,9 +1,20 @@
package cn.iocoder.yudao.module.promotion.service.coupon;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
+import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
+import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponPageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
+import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
+import javax.annotation.Resource;
+import java.util.Set;
+
/**
* 优惠劵 Service 实现类
*
@@ -13,9 +24,30 @@ import org.springframework.validation.annotation.Validated;
@Validated
public class CouponServiceImpl implements CouponService {
+ @Resource
+ private MemberUserApi memberUserApi;
+ @Resource
+ private CouponMapper couponMapper;
+
// TODO 芋艿:待实现
@Override
public CouponDO validCoupon(Long id, Long userId) {
return null;
}
+
+ @Override
+ public PageResult getCouponPage(CouponPageReqVO pageReqVO) {
+ // 获得用户编号
+ Set userIds = null;
+ if (StrUtil.isNotEmpty(pageReqVO.getNickname())) {
+ userIds = CollectionUtils.convertSet(memberUserApi.getUserListByNickname(pageReqVO.getNickname()),
+ UserRespDTO::getId);
+ if (CollUtil.isEmpty(userIds)) {
+ return PageResult.empty();
+ }
+ }
+ // 分页查询
+ return couponMapper.selectPage(pageReqVO, userIds);
+ }
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java
index 96b0a2350..e1aba4417 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java
@@ -7,10 +7,7 @@ import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
-import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
-import cn.iocoder.yudao.module.promotion.enums.common.PromotionLevelEnum;
-import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
-import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
+import cn.iocoder.yudao.module.promotion.enums.common.*;
import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
import cn.iocoder.yudao.module.promotion.service.discount.DiscountService;
import cn.iocoder.yudao.module.promotion.service.reward.RewardService;
@@ -374,13 +371,11 @@ public class PriceServiceTest extends BaseMockitoUnitTest {
when(productSkuApi.getSkuList(eq(asSet(10L, 20L, 30L)))).thenReturn(asList(productSku01, productSku02, productSku03));
// mock 方法(优惠劵 Coupon 信息)
CouponDO coupon = randomPojo(CouponDO.class, o -> o.setId(1024L).setName("程序员节")
- .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setSpuIds(asList(1L, 2L))
- .setPriceAvailable(350).setPreferentialType(2).setPercentOff(50).setDiscountPriceLimit(70));
+ .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L))
+ .setUsePrice(350).setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType())
+ .setDiscountPercent(50).setDiscountLimitPrice(70));
when(couponService.validCoupon(eq(1024L), eq(calculateReqDTO.getUserId()))).thenReturn(coupon);
- // 200 + 150; 350
- //
-
// 调用
PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO);
// 断言 Order 部分
diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java
index c6c37f935..235ebb2c4 100644
--- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java
+++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java
@@ -2,6 +2,12 @@ package cn.iocoder.yudao.module.member.api.user;
import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
+
/**
* 会员用户的 API 接口
*
@@ -17,4 +23,30 @@ public interface MemberUserApi {
*/
UserRespDTO getUser(Long id);
+ /**
+ * 获得会员用户信息们
+ *
+ * @param ids 用户编号的数组
+ * @return 用户信息们
+ */
+ List getUsers(Collection ids);
+
+ /**
+ * 获得会员用户 Map
+ *
+ * @param ids 用户编号的数组
+ * @return 会员用户 Map
+ */
+ default Map getUserMap(Collection ids) {
+ return convertMap(getUsers(ids), UserRespDTO::getId);
+ }
+
+ /**
+ * 基于用户昵称,模糊匹配用户列表
+ *
+ * @param nickname 用户昵称,模糊匹配
+ * @return 用户信息的列表
+ */
+ List getUserListByNickname(String nickname);
+
}
diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/UserInfoDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/UserInfoDTO.java
deleted file mode 100644
index a814edad0..000000000
--- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/UserInfoDTO.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package cn.iocoder.yudao.module.member.api.user.dto;
-
-import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
-import lombok.Data;
-
-import java.util.Date;
-
-/**
- * 用户信息 Response DTO
- *
- * @author 芋道源码
- */
-@Data
-public class UserInfoDTO {
-
- /**
- * 用户ID
- */
- private Long id;
- /**
- * 用户昵称
- */
- private String nickname;
- /**
- * 用户头像
- */
- private String avatar;
- /**
- * 帐号状态
- *
- * 枚举 {@link CommonStatusEnum}
- */
- private Integer status;
-
- /**
- * 手机
- */
- private String mobile;
- /**
- * 注册 IP
- */
- private String registerIp;
- /**
- * 最后登录IP
- */
- private String loginIp;
- /**
- * 最后登录时间
- */
- private Date loginDate;
-
-}
diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java
index 35e7b51ce..0c3e616a0 100644
--- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java
+++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java
@@ -8,6 +8,8 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
+import java.util.Collection;
+import java.util.List;
/**
* 会员用户的 API 实现类
@@ -27,4 +29,14 @@ public class MemberUserApiImpl implements MemberUserApi {
return UserConvert.INSTANCE.convert2(user);
}
+ @Override
+ public List getUsers(Collection ids) {
+ return UserConvert.INSTANCE.convertList2(userService.getUserList(ids));
+ }
+
+ @Override
+ public List getUserListByNickname(String nickname) {
+ return UserConvert.INSTANCE.convertList2(userService.getUserListByNickname(nickname));
+ }
+
}
diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/UserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/UserController.java
deleted file mode 100644
index 795c8162c..000000000
--- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/UserController.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package cn.iocoder.yudao.module.member.controller.admin.user;
-
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.module.member.api.user.dto.UserInfoDTO;
-import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
-import cn.iocoder.yudao.module.member.convert.user.UserConvert;
-import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
-import cn.iocoder.yudao.module.member.service.user.MemberUserService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-
-import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-/**
- * @author Banging
- */
-@Slf4j
-@Api("用户管理")
-@RestController(value = "memberUserController")
-@RequestMapping("/user")
-public class UserController {
-
- @Resource
- private MemberUserService userService;
-
- @ApiOperation(value = "用户信息获取",notes = "用户基本信息的获取")
- @GetMapping("/{tel}")
- public CommonResult getUserInfo(@PathVariable String tel){
- MemberUserDO user = userService.getUserByMobile(tel);
- return CommonResult.success(UserConvert.INSTANCE.convertInfo(user));
- }
-}
diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/UserConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/UserConvert.java
index 6be0d6b41..c2128c104 100644
--- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/UserConvert.java
+++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/UserConvert.java
@@ -1,12 +1,13 @@
package cn.iocoder.yudao.module.member.convert.user;
-import cn.iocoder.yudao.module.member.api.user.dto.UserInfoDTO;
import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
+import java.util.List;
+
@Mapper
public interface UserConvert {
@@ -15,5 +16,7 @@ public interface UserConvert {
AppUserInfoRespVO convert(MemberUserDO bean);
UserRespDTO convert2(MemberUserDO bean);
- UserInfoDTO convertInfo(MemberUserDO bean);
+
+ List convertList2(List list);
+
}
diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java
index 9ba09a111..5e63aae36 100644
--- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java
+++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java
@@ -1,9 +1,12 @@
package cn.iocoder.yudao.module.member.dal.mysql.user;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import org.apache.ibatis.annotations.Mapper;
+import java.util.List;
+
/**
* 会员 User Mapper
*
@@ -16,4 +19,9 @@ public interface MemberUserMapper extends BaseMapperX {
return selectOne(MemberUserDO::getMobile, mobile);
}
+ default List selectListByNicknameLike(String nickname) {
+ return selectList(new LambdaQueryWrapperX()
+ .likeIfPresent(MemberUserDO::getNickname, nickname));
+ }
+
}
diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java
index 3b63c8d71..da3b4fd4a 100644
--- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java
+++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java
@@ -5,6 +5,8 @@ import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserUpdateMobile
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import java.io.InputStream;
+import java.util.Collection;
+import java.util.List;
/**
* 会员用户 Service 接口
@@ -21,6 +23,15 @@ public interface MemberUserService {
*/
MemberUserDO getUserByMobile(String mobile);
+ /**
+ * 基于用户昵称,模糊匹配用户列表
+ *
+ * @param nickname 用户昵称,模糊匹配
+ * @return 用户信息的列表
+ */
+ List getUserListByNickname(String nickname);
+
+
/**
* 基于手机号创建用户。
* 如果用户已经存在,则直接进行返回
@@ -47,6 +58,14 @@ public interface MemberUserService {
*/
MemberUserDO getUser(Long id);
+ /**
+ * 通过用户 ID 查询用户们
+ *
+ * @param ids 用户 ID
+ * @return 用户对象信息数组
+ */
+ List getUserList(Collection ids);
+
/**
* 修改用户昵称
* @param userId 用户id
diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java
index ff91b0781..58c77fa68 100644
--- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java
+++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java
@@ -19,7 +19,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.InputStream;
+import java.util.Collection;
import java.util.Date;
+import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
@@ -51,6 +53,11 @@ public class MemberUserServiceImpl implements MemberUserService {
return memberUserMapper.selectByMobile(mobile);
}
+ @Override
+ public List getUserListByNickname(String nickname) {
+ return memberUserMapper.selectListByNicknameLike(nickname);
+ }
+
@Override
public MemberUserDO createUserIfAbsent(String mobile, String registerIp) {
// 用户已经存在
@@ -86,6 +93,11 @@ public class MemberUserServiceImpl implements MemberUserService {
return memberUserMapper.selectById(id);
}
+ @Override
+ public List getUserList(Collection ids) {
+ return memberUserMapper.selectBatchIds(ids);
+ }
+
@Override
public void updateUserNickname(Long userId, String nickname) {
MemberUserDO user = this.checkUserExists(userId);