获取用户推荐信息
This commit is contained in:
@ -0,0 +1,27 @@
|
|||||||
|
package com.sczx.user.controller;
|
||||||
|
|
||||||
|
import com.sczx.user.common.Result;
|
||||||
|
import com.sczx.user.dto.BaseUserReferralDTO;
|
||||||
|
import com.sczx.user.service.IUserReferralService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Api(value = "用户推荐", tags = "用户推荐")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/referral")
|
||||||
|
public class UserReferralController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IUserReferralService userReferralService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取用户推荐信息", notes = "获取用户推荐信息")
|
||||||
|
@GetMapping("/getUserReferralByUserId")
|
||||||
|
public Result<BaseUserReferralDTO> getUserReferralByUserId(@RequestParam("userId") Long userId) {
|
||||||
|
return Result.ok(userReferralService.getUserReferral(userId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.sczx.user.convert;
|
||||||
|
|
||||||
|
import com.sczx.user.dto.BaseUserReferralDTO;
|
||||||
|
import com.sczx.user.po.BaseUserReferralPO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BaseUserReferralConvert {
|
||||||
|
BaseUserReferralConvert INSTANCE = Mappers.getMapper(BaseUserReferralConvert.class);
|
||||||
|
BaseUserReferralDTO po2Dto(BaseUserReferralPO po);
|
||||||
|
BaseUserReferralPO dto2Po(BaseUserReferralDTO dto);
|
||||||
|
}
|
||||||
57
src/main/java/com/sczx/user/dto/BaseUserReferralDTO.java
Normal file
57
src/main/java/com/sczx/user/dto/BaseUserReferralDTO.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package com.sczx.user.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户引荐信息
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-19 23:47:42
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "BaseUserReferralDTO对象", description = "用户引荐信息")
|
||||||
|
public class BaseUserReferralDTO{
|
||||||
|
|
||||||
|
@ApiModelProperty("id主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("被引荐人id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("被引荐人手机号")
|
||||||
|
private String userPhoneNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("引荐人id")
|
||||||
|
private Long referralUserId;
|
||||||
|
|
||||||
|
@ApiModelProperty("引荐人手机号")
|
||||||
|
private String referralUserPhoneNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("奖励截止日期")
|
||||||
|
private LocalDate awardDeadline;
|
||||||
|
|
||||||
|
@ApiModelProperty("奖励比例")
|
||||||
|
private BigDecimal awardRate;
|
||||||
|
|
||||||
|
@ApiModelProperty("引荐订单")
|
||||||
|
private String referralOrderNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.sczx.user.service;
|
||||||
|
|
||||||
|
import com.sczx.user.dto.BaseUserReferralDTO;
|
||||||
|
|
||||||
|
public interface IUserReferralService {
|
||||||
|
BaseUserReferralDTO getUserReferral(Long userId);
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package com.sczx.user.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.sczx.user.convert.BaseUserReferralConvert;
|
||||||
|
import com.sczx.user.dto.BaseUserReferralDTO;
|
||||||
|
import com.sczx.user.po.BaseUserReferralPO;
|
||||||
|
import com.sczx.user.repository.BaseUserReferralRepo;
|
||||||
|
import com.sczx.user.service.IUserReferralService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class UserReferralServiceImpl implements IUserReferralService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BaseUserReferralRepo baseUserReferralRepo;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseUserReferralDTO getUserReferral(Long userId) {
|
||||||
|
LambdaQueryWrapper<BaseUserReferralPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(BaseUserReferralPO::getUserId, userId).orderByDesc(BaseUserReferralPO::getCreateTime).last(" limit 1");
|
||||||
|
BaseUserReferralPO baseUserReferralPO = baseUserReferralRepo.getOne(queryWrapper);
|
||||||
|
return BaseUserReferralConvert.INSTANCE.po2Dto(baseUserReferralPO);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user