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