diff --git a/mobile-web/src/config/env.js b/mobile-web/src/config/env.js index c8859f77d..a8e7df4aa 100644 --- a/mobile-web/src/config/env.js +++ b/mobile-web/src/config/env.js @@ -1,12 +1,12 @@ /** * 配置编译环境和线上环境之间的切换 - * + * * baseUrl: 域名地址 * routerMode: 路由模式 * dataSources:数据源 */ -let baseUrl = ''; +let baseUrl = ''; let routerMode = 'hash'; let dataSources='local';//local=本地,其他值代表非本地 @@ -20,11 +20,11 @@ if (!process.env.NODE_ENV || process.env.NODE_ENV == 'development') { // baseUrl = 'http://127.0.0.1'; // baseUrl = 'http://180.167.213.26:18099'; -dataSources = 'remote'; -// dataSources = 'local'; +// dataSources = 'remote'; +dataSources = 'local'; export { baseUrl, routerMode, dataSources, -} \ No newline at end of file +} diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponController.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponController.java index 589564ebb..7bb9f199f 100644 --- a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponController.java +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponController.java @@ -35,7 +35,10 @@ public class AdminsCouponController { @GetMapping("/template/page") @ApiOperation(value = "优惠劵(码)模板分页") @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "类型", example = "参考 CouponTemplateTypeEnum 枚举"), @ApiImplicitParam(name = "title", value = "标题,模糊匹配", example = "活动 A"), + @ApiImplicitParam(name = "status", value = "状态", example = "参考 CouponTemplateStatusEnum 枚举"), + @ApiImplicitParam(name = "preferentialType", value = "优惠类型", example = "参考 CouponTemplatePreferentialTypeEnum 枚举"), @ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"), @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"), }) diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/users/UsersCouponController.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/users/UsersCouponController.java index fcf5eb157..ba8011eac 100644 --- a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/users/UsersCouponController.java +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/users/UsersCouponController.java @@ -3,9 +3,12 @@ package cn.iocoder.mall.promotion.application.controller.users; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.promotion.api.CouponService; import cn.iocoder.mall.promotion.api.bo.CouponCardBO; +import cn.iocoder.mall.promotion.api.bo.CouponCardPageBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; +import cn.iocoder.mall.promotion.api.dto.CouponCardPageDTO; import cn.iocoder.mall.promotion.application.convert.CouponCardConvert; import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert; +import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardPageVO; import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardVO; import cn.iocoder.mall.promotion.application.vo.users.UsersCouponTemplateVO; import cn.iocoder.mall.user.sdk.annotation.PermitAll; @@ -13,6 +16,7 @@ import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder; import com.alibaba.dubbo.config.annotation.Reference; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -37,6 +41,22 @@ public class UsersCouponController { // ========== 优惠劵 ========== + @GetMapping("/card/page") + @ApiOperation(value = "优惠劵分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = "status", value = "状态", example = "参考 CouponCardStatusEnum 枚举"), + @ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"), + }) + public CommonResult cardPage(@RequestParam(value = "status", required = false) Integer status, + @RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo, + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { + CommonResult result = couponService.getCouponCardPage(new CouponCardPageDTO() + .setStatus(status).setUserId(UserSecurityContextHolder.getContext().getUserId()) + .setPageNo(pageNo).setPageSize(pageSize)); + return CouponCardConvert.INSTANCE.convert2(result); + } + @PostMapping("/card/add") @ApiOperation(value = "领取优惠劵") @ApiImplicitParam(name = "templateId", value = "优惠劵(码)模板编号", required = true, example = "10") diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/convert/CouponCardConvert.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/convert/CouponCardConvert.java index 3ec4d00f2..2a676dba7 100644 --- a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/convert/CouponCardConvert.java +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/convert/CouponCardConvert.java @@ -2,6 +2,8 @@ package cn.iocoder.mall.promotion.application.convert; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.promotion.api.bo.CouponCardBO; +import cn.iocoder.mall.promotion.api.bo.CouponCardPageBO; +import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardPageVO; import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardVO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; @@ -14,6 +16,10 @@ public interface CouponCardConvert { @Mappings({}) CommonResult convert(CommonResult result); + + @Mappings({}) + CommonResult convert2(CommonResult result); + // // @Mappings({}) // List convertList2(List banners); diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/users/UsersCouponCardPageVO.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/users/UsersCouponCardPageVO.java new file mode 100644 index 000000000..cd12eca5d --- /dev/null +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/users/UsersCouponCardPageVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.mall.promotion.application.vo.users; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; + +@ApiModel("优惠劵分页 VO") +@Data +@Accessors(chain = true) +public class UsersCouponCardPageVO { + + @ApiModelProperty(value = "优惠劵数组") + private List list; + @ApiModelProperty(value = "优惠劵总数") + private Integer total; + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java index 2c867cd4f..7101a8db5 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java @@ -3,6 +3,7 @@ package cn.iocoder.mall.promotion.api; import cn.iocoder.common.framework.validator.InEnum; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.promotion.api.bo.CouponCardBO; +import cn.iocoder.mall.promotion.api.bo.CouponCardPageBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO; import cn.iocoder.mall.promotion.api.constant.CouponTemplateStatusEnum; @@ -61,6 +62,8 @@ public interface CouponService { // ========== 优惠劵 ========== + CommonResult getCouponCardPage(CouponCardPageDTO couponCardPageDTO); + /** * 基于优惠劵模板,领取优惠劵 * diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCardPageBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCardPageBO.java new file mode 100644 index 000000000..44150c24a --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCardPageBO.java @@ -0,0 +1,24 @@ +package cn.iocoder.mall.promotion.api.bo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * 优惠劵分页 BO + */ +@Data +@Accessors(chain = true) +public class CouponCardPageBO { + + /** + * 优惠劵数组 + */ + private List list; + /** + * 总量 + */ + private Integer total; + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardPageDTO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardPageDTO.java new file mode 100644 index 000000000..8b76b3290 --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardPageDTO.java @@ -0,0 +1,29 @@ +package cn.iocoder.mall.promotion.api.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * 优惠劵分页 DTO + */ +@Data +@Accessors(chain = true) +public class CouponCardPageDTO { + + /** + * 用户编号 + */ + private Integer userId; + /** + * 状态 + */ + private Integer status; + + @NotNull(message = "页码不能为空") + private Integer pageNo; + @NotNull(message = "每页条数不能为空") + private Integer pageSize; + +} diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dao/CouponCardMapper.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dao/CouponCardMapper.java index 78df37962..af4b697ec 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dao/CouponCardMapper.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dao/CouponCardMapper.java @@ -11,9 +11,13 @@ public interface CouponCardMapper { CouponCardDO selectById(@Param("id") Integer id); - List selectListByPage(@Param("status") Integer status); + List selectListByPage(@Param("userId") Integer userId, + @Param("status") Integer status, + @Param("offset") Integer offset, + @Param("limit") Integer limit); - Integer selectCountByPage(@Param("status") Integer status); + Integer selectCountByPage(@Param("userId") Integer userId, + @Param("status") Integer status); int selectCountByUserIdAndTemplateId(@Param("userId") Integer userId, @Param("templateId") Integer templateId); diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java index 490057175..96098ffa1 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java @@ -6,6 +6,7 @@ import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.promotion.api.CouponService; import cn.iocoder.mall.promotion.api.bo.CouponCardBO; +import cn.iocoder.mall.promotion.api.bo.CouponCardPageBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO; import cn.iocoder.mall.promotion.api.constant.*; @@ -176,6 +177,20 @@ public class CouponServiceImpl implements CouponService { // ========== 优惠劵 ========== + @Override + public CommonResult getCouponCardPage(CouponCardPageDTO couponCardPageDTO) { + CouponCardPageBO pageBO = new CouponCardPageBO(); + // 查询分页数据 + int offset = (couponCardPageDTO.getPageNo() - 1) * couponCardPageDTO.getPageSize(); + pageBO.setList(CouponCardConvert.INSTANCE.convertToBO(couponCardMapper.selectListByPage( + couponCardPageDTO.getUserId(), couponCardPageDTO.getStatus(), + offset, couponCardPageDTO.getPageSize()))); + // 查询分页总数 + pageBO.setTotal(couponCardMapper.selectCountByPage( + couponCardPageDTO.getUserId(), couponCardPageDTO.getStatus())); + return CommonResult.success(pageBO); + } + @Override @Transactional public CommonResult addCouponCard(Integer userId, Integer couponTemplateId) { diff --git a/promotion/promotion-service-impl/src/main/resources/mapper/CouponCardMapper.xml b/promotion/promotion-service-impl/src/main/resources/mapper/CouponCardMapper.xml index 670822568..2242bbb67 100644 --- a/promotion/promotion-service-impl/src/main/resources/mapper/CouponCardMapper.xml +++ b/promotion/promotion-service-impl/src/main/resources/mapper/CouponCardMapper.xml @@ -38,6 +38,9 @@ FROM coupon_card + + AND user_id = #{userId} + AND status = #{status} @@ -50,6 +53,9 @@ COUNT(1) FROM coupon_card + + AND user_id = #{userId} + AND status = #{status}