diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java index 481ced4b4..c65fe335e 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java @@ -1,14 +1,19 @@ package cn.iocoder.yudao.module.promotion.controller.app.coupon; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO; import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -25,4 +30,33 @@ public class AppCouponController { return success(1L); } + // TODO 芋艿:待实现 + @GetMapping("/page") + @Operation(summary = "优惠劵列表", description = "我的优惠劵") + public CommonResult> takeCoupon(AppCouponPageReqVO pageReqVO) { + List list = new ArrayList<>(); + Random random = new Random(); + for (int i = 0; i < 10; i++) { + AppCouponRespVO vo = new AppCouponRespVO(); + vo.setId(i + 1L); + vo.setName("优惠劵" + (i + 1)); + vo.setStatus(pageReqVO.getStatus()); + vo.setUsePrice(random.nextInt(100) * 100); + vo.setValidStartTime(LocalDateTime.now().plusDays(random.nextInt(10))); + vo.setValidEndTime(LocalDateTime.now().plusDays(random.nextInt(20) + 10)); + vo.setDiscountType(random.nextInt(2) + 1); + if (vo.getDiscountType() == 1) { + vo.setDiscountPercent(null); + vo.setDiscountPrice(random.nextInt(50) * 100); + vo.setDiscountLimitPrice(null); + } else { + vo.setDiscountPercent(random.nextInt(90) + 10); + vo.setDiscountPrice(null); + vo.setDiscountLimitPrice(random.nextInt(200) * 100); + } + list.add(vo); + } + return success(new PageResult<>(list, 20L)); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java index 7446b04b0..c4d81de2c 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java @@ -34,14 +34,15 @@ public class AppCouponTemplateController { // TODO 芋艿:待实现 @GetMapping("/list") - @Operation(summary = "获得优惠劵模版列表") // 目前主要给商品详情使用 + @Operation(summary = "获得优惠劵模版列表") @Parameters({ - @Parameter(name = "spuId", description = "商品 SPU 编号", required = true), + @Parameter(name = "spuId", description = "商品 SPU 编号"), // 目前主要给商品详情使用 @Parameter(name = "useType", description = "使用类型"), @Parameter(name = "count", description = "数量", required = true) }) - public CommonResult> getCouponTemplateList(@RequestParam("spuId") Long spuId, - @RequestParam(value = "useType", required = false) Integer useType) { + public CommonResult> getCouponTemplateList(@RequestParam(value = "spuId", required = false) Long spuId, + @RequestParam(value = "useType", required = false) Integer useType, + @RequestParam(value = "count", required = false, defaultValue = "10") Integer count) { List list = new ArrayList<>(); Random random = new Random(); for (int i = 0; i < 10; i++) { diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java new file mode 100644 index 000000000..5bd057f37 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; + +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; + +@Schema(description = "用户 App - 优惠劵分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class AppCouponPageReqVO extends PageParam { + + @Schema(description = "优惠劵状态", example = "1") + private Integer status; + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java new file mode 100755 index 000000000..2147f43a0 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.Min; +import java.time.LocalDateTime; + +@Schema(description = "用户 App - 优惠劵 Response VO") +@Data +public class AppCouponRespVO { + + @Schema(description = "优惠劵编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long id; + + @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") + private String name; + + @Schema(description = "优惠劵状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 参见 CouponStatusEnum 枚举 + private Integer status; + + @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") + // 单位:分;0 - 不限制 + private Integer usePrice; + + @Schema(description = "固定日期 - 生效开始时间") + private LocalDateTime validStartTime; + + @Schema(description = "固定日期 - 生效结束时间") + private LocalDateTime validEndTime; + + @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer discountType; + + @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 + private Integer discountPercent; + + @Schema(description = "优惠金额", example = "10") + @Min(value = 0, message = "优惠金额需要大于等于 0") + private Integer discountPrice; + + @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 + private Integer discountLimitPrice; + +} diff --git a/yudao-module-member/yudao-module-member-biz/pom.xml b/yudao-module-member/yudao-module-member-biz/pom.xml index 839ac3a88..f36c5d084 100644 --- a/yudao-module-member/yudao-module-member-biz/pom.xml +++ b/yudao-module-member/yudao-module-member-biz/pom.xml @@ -84,6 +84,11 @@ + + cn.iocoder.boot + yudao-spring-boot-starter-biz-ip + + diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java index 841947b64..076ce36ff 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.member.controller.app.address.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; // TODO 芋艿:example 缺失 @@ -31,6 +30,6 @@ public class AppAddressBaseVO { @Schema(description = "是否默认地址", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "是否默认地址不能为空") - private Boolean defaulted; + private Boolean defaultStatus; } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java index 72ceeecd8..d3e2f9ffd 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressRespVO.java @@ -1,7 +1,9 @@ package cn.iocoder.yudao.module.member.controller.app.address.vo; + import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; @Schema(description = "用户 APP - 用户收件地址 Response VO") @Data @@ -9,10 +11,10 @@ import java.time.LocalDateTime; @ToString(callSuper = true) public class AppAddressRespVO extends AppAddressBaseVO { - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Long id; - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; + @Schema(description = "地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海上海市普陀区") + private String areaName; } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java index aae8d405b..19b58d807 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressUpdateReqVO.java @@ -9,7 +9,7 @@ import javax.validation.constraints.*; @ToString(callSuper = true) public class AppAddressUpdateReqVO extends AppAddressBaseVO { - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @NotNull(message = "编号不能为空") private Long id; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java index a93d79ec1..8e62de604 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java @@ -1,12 +1,14 @@ package cn.iocoder.yudao.module.member.convert.address; -import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressCreateReqVO; import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressRespVO; import cn.iocoder.yudao.module.member.controller.app.address.vo.AppAddressUpdateReqVO; import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Named; import org.mapstruct.factory.Mappers; import java.util.List; @@ -25,12 +27,16 @@ public interface AddressConvert { MemberAddressDO convert(AppAddressUpdateReqVO bean); + @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") AppAddressRespVO convert(MemberAddressDO bean); List convertList(List list); - PageResult convertPage(PageResult page); - AddressRespDTO convert02(MemberAddressDO bean); + @Named("convertAreaIdToAreaName") + default String convertAreaIdToAreaName(Integer areaId) { + return AreaUtils.format(areaId); + } + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java index 743849421..5c34ce4ac 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/MemberAddressDO.java @@ -49,6 +49,6 @@ public class MemberAddressDO extends BaseDO { * * true - 默认收件地址 */ - private Boolean defaulted; + private Boolean defaultStatus; } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/AddressMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/AddressMapper.java index 13ca89ef9..db824f6f5 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/AddressMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/address/AddressMapper.java @@ -16,7 +16,7 @@ public interface AddressMapper extends BaseMapperX { default List selectListByUserIdAndDefaulted(Long userId, Boolean defaulted) { return selectList(new LambdaQueryWrapperX().eq(MemberAddressDO::getUserId, userId) - .eqIfPresent(MemberAddressDO::getDefaulted, defaulted)); + .eqIfPresent(MemberAddressDO::getDefaultStatus, defaulted)); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java index 488e7d32c..2689177ea 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/address/AddressServiceImpl.java @@ -32,9 +32,9 @@ public class AddressServiceImpl implements AddressService { @Transactional(rollbackFor = Exception.class) public Long createAddress(Long userId, AppAddressCreateReqVO createReqVO) { // 如果添加的是默认收件地址,则将原默认地址修改为非默认 - if (Boolean.TRUE.equals(createReqVO.getDefaulted())) { + if (Boolean.TRUE.equals(createReqVO.getDefaultStatus())) { List addresses = addressMapper.selectListByUserIdAndDefaulted(userId, true); - addresses.forEach(address -> addressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaulted(false))); + addresses.forEach(address -> addressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false))); } // 插入 @@ -52,10 +52,10 @@ public class AddressServiceImpl implements AddressService { validAddressExists(userId, updateReqVO.getId()); // 如果修改的是默认收件地址,则将原默认地址修改为非默认 - if (Boolean.TRUE.equals(updateReqVO.getDefaulted())) { + if (Boolean.TRUE.equals(updateReqVO.getDefaultStatus())) { List addresses = addressMapper.selectListByUserIdAndDefaulted(userId, true); addresses.stream().filter(u -> !u.getId().equals(updateReqVO.getId())) // 排除自己 - .forEach(address -> addressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaulted(false))); + .forEach(address -> addressMapper.updateById(new MemberAddressDO().setId(address.getId()).setDefaultStatus(false))); } // 更新 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/AppAreaController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/AppAreaController.java new file mode 100644 index 000000000..98260a34d --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/AppAreaController.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.system.controller.app.ip; + +import cn.hutool.core.lang.Assert; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.ip.core.Area; +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; +import cn.iocoder.yudao.module.system.controller.app.ip.vo.AppAreaNodeRespVO; +import cn.iocoder.yudao.module.system.convert.ip.AreaConvert; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +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 java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "用户 App - 地区") +@RestController +@RequestMapping("/system/area") +@Validated +public class AppAreaController { + + @GetMapping("/tree") + @Operation(summary = "获得地区树") + public CommonResult> getAreaTree() { + Area area = AreaUtils.getArea(Area.ID_CHINA); + Assert.notNull(area, "获取不到中国"); + return success(AreaConvert.INSTANCE.convertList3(area.getChildren())); + } + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/vo/AppAreaNodeRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/vo/AppAreaNodeRespVO.java new file mode 100644 index 000000000..f6ca4a82b --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/ip/vo/AppAreaNodeRespVO.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.system.controller.app.ip.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Schema(description = "用户 App - 地区节点 Response VO") +@Data +public class AppAreaNodeRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110000") + private Integer id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "北京") + private String name; + + /** + * 子节点 + */ + private List children; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java index 18609edb1..4ffa374e7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/ip/AreaConvert.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.ip.core.Area; import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO; import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeSimpleRespVO; +import cn.iocoder.yudao.module.system.controller.app.ip.vo.AppAreaNodeRespVO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -27,4 +28,6 @@ public interface AreaConvert { return Objects.equals(AreaTypeEnum.DISTRICT.getType(), type); } + List convertList3(List list); + }