1. 会员用户,增加 point 积分字段
2. 增加获得优惠劵、收藏数量的 API 接口
This commit is contained in:
parent
a4e2cacc46
commit
94a32d34b2
@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
@ -84,8 +83,15 @@ public class AppFavoriteController {
|
||||
@Operation(summary = "检查是否收藏过商品")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> isFavoriteExists(AppFavoriteReqVO reqVO) {
|
||||
ProductFavoriteDO favoriteDO = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId());
|
||||
return success(Objects.nonNull(favoriteDO));
|
||||
ProductFavoriteDO favorite = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId());
|
||||
return success(favorite != null);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get-count")
|
||||
@Operation(summary = "获得商品收藏数量")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> getFavoriteCount() {
|
||||
return success(productFavoriteService.getFavoriteCount(getLoginUserId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,4 +21,8 @@ public interface ProductFavoriteMapper extends BaseMapperX<ProductFavoriteDO> {
|
||||
.orderByDesc(ProductFavoriteDO::getId));
|
||||
}
|
||||
|
||||
default Long selectCountByUserId(Long userId) {
|
||||
return selectCount(ProductFavoriteDO::getUserId, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public interface ProductFavoriteService {
|
||||
/**
|
||||
* 创建商品收藏
|
||||
*
|
||||
* @param userId 用户 id
|
||||
* @param userId 用户编号
|
||||
* @param spuId SPU 编号
|
||||
*/
|
||||
Long createFavorite(Long userId, Long spuId);
|
||||
@ -24,7 +24,7 @@ public interface ProductFavoriteService {
|
||||
/**
|
||||
* 取消商品收藏
|
||||
*
|
||||
* @param userId 用户 id
|
||||
* @param userId 用户编号
|
||||
* @param spuId SPU 编号
|
||||
*/
|
||||
void deleteFavorite(Long userId, Long spuId);
|
||||
@ -32,7 +32,7 @@ public interface ProductFavoriteService {
|
||||
/**
|
||||
* 分页查询用户收藏列表
|
||||
*
|
||||
* @param userId 用户 id
|
||||
* @param userId 用户编号
|
||||
* @param reqVO 请求 vo
|
||||
*/
|
||||
PageResult<ProductFavoriteDO> getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO);
|
||||
@ -40,9 +40,17 @@ public interface ProductFavoriteService {
|
||||
/**
|
||||
* 获取收藏过商品
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param userId 用户编号
|
||||
* @param spuId SPU 编号
|
||||
*/
|
||||
ProductFavoriteDO getFavorite(Long userId, Long spuId);
|
||||
|
||||
/**
|
||||
* 获取用户收藏数量
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 数量
|
||||
*/
|
||||
Long getFavoriteCount(Long userId);
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.FAVORITE_EXISTS;
|
||||
@ -31,7 +30,7 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
|
||||
@Override
|
||||
public Long createFavorite(Long userId, Long spuId) {
|
||||
ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
|
||||
if (Objects.nonNull(favorite)) {
|
||||
if (favorite != null) {
|
||||
throw exception(FAVORITE_EXISTS);
|
||||
}
|
||||
|
||||
@ -43,7 +42,7 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
|
||||
@Override
|
||||
public void deleteFavorite(Long userId, Long spuId) {
|
||||
ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
|
||||
if (Objects.isNull(favorite)) {
|
||||
if (favorite == null) {
|
||||
throw exception(FAVORITE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@ -60,4 +59,9 @@ public class ProductFavoriteServiceImpl implements ProductFavoriteService {
|
||||
return productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getFavoriteCount(Long userId) {
|
||||
return productFavoriteMapper.selectCountByUserId(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,9 @@ import java.util.Arrays;
|
||||
@Getter
|
||||
public enum DecoratePageEnum implements IntArrayValuable {
|
||||
|
||||
INDEX(1, "首页");
|
||||
INDEX(1, "首页"),
|
||||
MY(2, "个人中心"),
|
||||
;
|
||||
|
||||
private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray();
|
||||
|
||||
|
@ -2,22 +2,26 @@ 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.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchRespVO;
|
||||
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 cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
|
||||
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.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
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;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "用户 App - 优惠劵")
|
||||
@RestController
|
||||
@ -25,6 +29,9 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@Validated
|
||||
public class AppCouponController {
|
||||
|
||||
@Resource
|
||||
private CouponService couponService;
|
||||
|
||||
// TODO 芋艿:待实现
|
||||
@PostMapping("/take")
|
||||
@Operation(summary = "领取优惠劵")
|
||||
@ -93,4 +100,11 @@ public class AppCouponController {
|
||||
return success(new PageResult<>(list, 20L));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get-unused-count")
|
||||
@Operation(summary = "获得未使用的优惠劵数量")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> getUnusedCouponCount() {
|
||||
return success(couponService.getUnusedCouponCount(getLoginUserId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,4 +49,10 @@ public interface CouponMapper extends BaseMapperX<CouponDO> {
|
||||
.eq(CouponDO::getId, id).eq(CouponDO::getStatus, status));
|
||||
}
|
||||
|
||||
default Long selectCountByUserIdAndStatus(Long userId, Integer status) {
|
||||
return selectCount(new LambdaQueryWrapperX<CouponDO>()
|
||||
.eq(CouponDO::getUserId, userId)
|
||||
.eq(CouponDO::getStatus, status));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -67,4 +67,12 @@ public interface CouponService {
|
||||
*/
|
||||
List<CouponDO> getCouponList(Long userId, Integer status);
|
||||
|
||||
/**
|
||||
* 获得未使用的优惠劵数量
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 未使用的优惠劵数量
|
||||
*/
|
||||
Long getUnusedCouponCount(Long userId);
|
||||
|
||||
}
|
||||
|
@ -120,4 +120,9 @@ public class CouponServiceImpl implements CouponService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getUnusedCouponCount(Long userId) {
|
||||
return couponMapper.selectCountByUserIdAndStatus(userId, CouponStatusEnum.UNUSED.getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static cn.hutool.core.util.ArrayUtil.firstMatch;
|
||||
|
||||
@ -55,6 +56,18 @@ public enum TradeAfterSaleStatusEnum implements IntArrayValuable {
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeAfterSaleStatusEnum::getStatus).toArray();
|
||||
|
||||
/**
|
||||
* 进行中的售后状态
|
||||
*
|
||||
* 不包括已经结束的状态
|
||||
*/
|
||||
public static final Collection<Integer> APPLYING_STATUSES = Arrays.asList(
|
||||
APPLY.getStatus(),
|
||||
SELLER_AGREE.getStatus(),
|
||||
BUYER_DELIVERY.getStatus(),
|
||||
WAIT_REFUND.getStatus()
|
||||
);
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
|
@ -50,6 +50,12 @@ public class AppTradeAfterSaleController {
|
||||
return success(TradeAfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id)));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get-applying-count")
|
||||
@Operation(summary = "获得进行中的售后订单数量")
|
||||
public CommonResult<Long> getApplyingAfterSaleCount() {
|
||||
return success(afterSaleService.getApplyingAfterSaleCount(getLoginUserId()));
|
||||
}
|
||||
|
||||
// TODO 芋艿:待实现
|
||||
@GetMapping(value = "/get-reason-list")
|
||||
@Operation(summary = "获得售后原因")
|
||||
|
@ -9,6 +9,8 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Mapper
|
||||
public interface TradeAfterSaleMapper extends BaseMapperX<TradeAfterSaleDO> {
|
||||
|
||||
@ -40,4 +42,10 @@ public interface TradeAfterSaleMapper extends BaseMapperX<TradeAfterSaleDO> {
|
||||
TradeAfterSaleDO::getUserId, userId);
|
||||
}
|
||||
|
||||
default Long selectCountByUserIdAndStatus(Long userId, Collection<Integer> statuses) {
|
||||
return selectCount(new LambdaQueryWrapperX<TradeAfterSaleDO>()
|
||||
.eq(TradeAfterSaleDO::getUserId, userId)
|
||||
.in(TradeAfterSaleDO::getStatus, statuses));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -108,4 +108,12 @@ public interface TradeAfterSaleService {
|
||||
*/
|
||||
void cancelAfterSale(Long userId, Long id);
|
||||
|
||||
/**
|
||||
* 【会员】获得正在进行中的售后订单数量
|
||||
*
|
||||
* @param userId
|
||||
* @return 数量
|
||||
*/
|
||||
Long getApplyingAfterSaleCount(Long userId);
|
||||
|
||||
}
|
||||
|
@ -398,6 +398,11 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
||||
TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), TradeOrderItemAfterSaleStatusEnum.NONE.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getApplyingAfterSaleCount(Long userId) {
|
||||
return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, TradeAfterSaleStatusEnum.APPLYING_STATUSES);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void createAfterSaleLog(Long userId, Integer userType, TradeAfterSaleDO afterSale,
|
||||
Integer beforeStatus, Integer afterStatus) {
|
||||
|
@ -27,7 +27,7 @@ import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_IS_EMP
|
||||
@RequestMapping("/member/user")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AppUserController {
|
||||
public class AppMemberUserController {
|
||||
|
||||
@Resource
|
||||
private MemberUserService userService;
|
@ -14,9 +14,13 @@ public class AppUserInfoRespVO {
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "/infra/file/get/35a12e57-4297-4faa-bf7d-7ed2f211c952")
|
||||
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.png")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "用户手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
private Integer point;
|
||||
|
||||
}
|
||||
|
@ -102,6 +102,11 @@ public class MemberUserDO extends TenantBaseDO {
|
||||
|
||||
// ========== 其它信息 ==========
|
||||
|
||||
/**
|
||||
* 积分
|
||||
*/
|
||||
private Integer point;
|
||||
|
||||
// TODO 积分、成长值、会员等级等等
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user