refactor(myInvitation): 调整邀请功能模块
parent
e813ee9dff
commit
1b7b096f50
|
@ -10,6 +10,7 @@ import com.mcwl.myInvitation.service.InvitationService;
|
|||
import com.mcwl.myInvitation.domain.vo.EarningsDisplayVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -17,6 +18,10 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -60,9 +65,11 @@ public class InvitationController {
|
|||
* @return 邀请列表
|
||||
*/
|
||||
|
||||
@GetMapping("/list/{userId}")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "获取邀请列表")
|
||||
public R<List<Invitation>> list(@PathVariable Long userId) {
|
||||
public R<List<Invitation>> list(@Valid
|
||||
@NotNull(message = "用户id不能为空")
|
||||
@ApiParam("用户id") Long userId) {
|
||||
List<Invitation> list = invitationService.lambdaQuery()
|
||||
.eq(Invitation::getUserId, userId)
|
||||
.list();
|
||||
|
@ -86,7 +93,7 @@ public class InvitationController {
|
|||
// 获取我的团员
|
||||
List<EarningsDisplayDto> earningsDisplay = invitationService.getEarningsDisplay(userId);
|
||||
if (earningsDisplay == null || earningsDisplay.isEmpty()) {
|
||||
return R.fail("暂无收益");
|
||||
return R.ok(new EarningsDisplayVO(totalAmount, Collections.emptyList()));
|
||||
}
|
||||
|
||||
earningsDisplayVO.setTotalAmount(totalAmount);
|
||||
|
|
|
@ -142,12 +142,11 @@ mall:
|
|||
alipayCertPath: cert/pro/alipayCertPublicKey_RSA2.crt
|
||||
# 线上支付宝根证书路径
|
||||
alipayRootCertPath: cert/pro/alipayRootCert.crt
|
||||
# 线上支付宝公钥
|
||||
notifyUrl: https://253d7236.r27.cpolar.top/ali/pay/notify
|
||||
notifyUrl: https://36072a51.r27.cpolar.top/ali/pay/notify
|
||||
# 线上支付宝网关
|
||||
gatewayUrl: https://openapi.alipay.com/gateway.do
|
||||
# 绑定回调
|
||||
bindUrl: https://4b0ca615.r27.cpolar.top/ali/pay/callback
|
||||
bindUrl: https://36072a51.r27.cpolar.top/ali/pay/callback
|
||||
|
||||
huawei:
|
||||
obs:
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.mcwl.common.exception.ErrorCodeException;
|
|||
import com.mcwl.common.exception.ServiceException;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.common.utils.html.EscapeUtil;
|
||||
import io.lettuce.core.RedisCommandTimeoutException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
@ -27,8 +28,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
* @author mcwl
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler
|
||||
{
|
||||
public class GlobalExceptionHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
|
||||
|
@ -38,20 +38,28 @@ public class GlobalExceptionHandler
|
|||
@ExceptionHandler(ErrorCodeException.class)
|
||||
public AjaxResult UserDefinedException(ErrorCodeException e) {
|
||||
System.out.println("StringUtils.isNull(e.getCode()):" + StringUtils.isNull(e.getCode()));
|
||||
if (StringUtils.isNull(e.getCode()))
|
||||
{
|
||||
if (StringUtils.isNull(e.getCode())) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
return AjaxResult.error(e.getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限校验异常
|
||||
*/
|
||||
@ExceptionHandler(RedisCommandTimeoutException.class)
|
||||
public AjaxResult commandTimeoutException(AccessDeniedException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("连接超时{},{}", requestURI, e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.ERROR, "连接超时");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 权限校验异常
|
||||
*/
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request)
|
||||
{
|
||||
public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
|
||||
|
@ -62,8 +70,7 @@ public class GlobalExceptionHandler
|
|||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
|
||||
HttpServletRequest request)
|
||||
{
|
||||
HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||
return AjaxResult.error(e.getMessage());
|
||||
|
@ -73,8 +80,7 @@ public class GlobalExceptionHandler
|
|||
* 业务异常
|
||||
*/
|
||||
@ExceptionHandler(ServiceException.class)
|
||||
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request)
|
||||
{
|
||||
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
|
||||
log.error(e.getMessage(), e);
|
||||
Integer code = e.getCode();
|
||||
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
||||
|
@ -84,8 +90,7 @@ public class GlobalExceptionHandler
|
|||
* 请求路径中缺少必需的路径变量
|
||||
*/
|
||||
@ExceptionHandler(MissingPathVariableException.class)
|
||||
public AjaxResult handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request)
|
||||
{
|
||||
public AjaxResult handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(String.format("请求路径中缺少必需的路径变量[%s]", e.getVariableName()));
|
||||
|
@ -95,12 +100,10 @@ public class GlobalExceptionHandler
|
|||
* 请求参数类型不匹配
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||
public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request)
|
||||
{
|
||||
public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
String value = Convert.toStr(e.getValue());
|
||||
if (StringUtils.isNotEmpty(value))
|
||||
{
|
||||
if (StringUtils.isNotEmpty(value)) {
|
||||
value = EscapeUtil.clean(value);
|
||||
}
|
||||
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
|
||||
|
@ -111,8 +114,7 @@ public class GlobalExceptionHandler
|
|||
* 拦截未知的运行时异常
|
||||
*/
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request)
|
||||
{
|
||||
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
|
@ -122,8 +124,7 @@ public class GlobalExceptionHandler
|
|||
* 系统异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public AjaxResult handleException(Exception e, HttpServletRequest request)
|
||||
{
|
||||
public AjaxResult handleException(Exception e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return AjaxResult.error(e.getMessage());
|
||||
|
@ -133,8 +134,7 @@ public class GlobalExceptionHandler
|
|||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
public AjaxResult handleBindException(BindException e)
|
||||
{
|
||||
public AjaxResult handleBindException(BindException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getAllErrors().get(0).getDefaultMessage();
|
||||
return AjaxResult.error(message);
|
||||
|
@ -144,8 +144,7 @@ public class GlobalExceptionHandler
|
|||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e)
|
||||
{
|
||||
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
||||
return AjaxResult.error(message);
|
||||
|
@ -155,8 +154,7 @@ public class GlobalExceptionHandler
|
|||
* 演示模式异常
|
||||
*/
|
||||
@ExceptionHandler(DemoModeException.class)
|
||||
public AjaxResult handleDemoModeException(DemoModeException e)
|
||||
{
|
||||
public AjaxResult handleDemoModeException(DemoModeException e) {
|
||||
return AjaxResult.error("演示模式,不允许操作");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.mcwl.common.exception.ServiceException;
|
||||
import io.lettuce.core.RedisCommandTimeoutException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
package com.mcwl.myInvitation.domain.dto;
|
||||
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "被邀请者信息")
|
||||
public class EarningsDisplayDto {
|
||||
|
||||
private SysUser user;
|
||||
@ApiModelProperty("被邀请人")
|
||||
private SysUserDto user;
|
||||
|
||||
@ApiModelProperty("购买商品数")
|
||||
private Integer count;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.mcwl.myInvitation.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 被邀请用户
|
||||
*/
|
||||
@Data
|
||||
public class SysUserDto {
|
||||
private Long userId;
|
||||
private String userName;
|
||||
private String avatar;
|
||||
}
|
|
@ -2,20 +2,29 @@ package com.mcwl.myInvitation.domain.vo;
|
|||
|
||||
import com.mcwl.myInvitation.domain.dto.EarningsDisplay;
|
||||
import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "邀请人收益展示")
|
||||
public class EarningsDisplayVO {
|
||||
|
||||
/**
|
||||
* 总金额
|
||||
* 收益总额
|
||||
*/
|
||||
@ApiModelProperty("收益总额")
|
||||
private Double totalAmount;
|
||||
|
||||
/**
|
||||
* 提成列表
|
||||
* 邀请列表
|
||||
*/
|
||||
@ApiModelProperty("邀请列表")
|
||||
private List<EarningsDisplayDto> earningsDisplayList;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.mcwl.myInvitation.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.common.utils.ShareCodeUtils;
|
||||
import com.mcwl.myInvitation.domain.Invitation;
|
||||
import com.mcwl.myInvitation.domain.dto.EarningsDisplay;
|
||||
import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto;
|
||||
import com.mcwl.myInvitation.domain.dto.SysUserDto;
|
||||
import com.mcwl.myInvitation.mapper.InvitationMapper;
|
||||
import com.mcwl.myInvitation.service.ConsumeService;
|
||||
import com.mcwl.myInvitation.service.InvitationService;
|
||||
|
@ -45,7 +48,8 @@ public class InvitationServiceImpl extends ServiceImpl<InvitationMapper, Invitat
|
|||
List<EarningsDisplayDto> list = new ArrayList<>();
|
||||
earningsDisplay.forEach(item -> {
|
||||
EarningsDisplayDto edd = new EarningsDisplayDto();
|
||||
edd.setUser(sysUserService.selectUserById(item.getUserId()));
|
||||
SysUser sysUser = sysUserService.selectUserById(item.getUserId());
|
||||
edd.setUser(BeanUtil.copyProperties(sysUser, SysUserDto.class));
|
||||
edd.setCount(item.getCount());
|
||||
list.add(edd);
|
||||
});
|
||||
|
|
|
@ -209,6 +209,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
} else if (OrderTypeEnum.MEMBER.getName().equals(suffix)) {
|
||||
Long promotionId = redisCache.getCacheObject(params.get("out_trade_no") + "promotionId");
|
||||
memberHandler(orderTrade, promotionId);
|
||||
redisCache.deleteObject(params.get("out_trade_no") + "promotionId");
|
||||
} else if (OrderTypeEnum.WALLET.getName().equals(suffix)) {
|
||||
walletHandler(orderTrade, params);
|
||||
} else {
|
||||
|
@ -218,7 +219,6 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
this.orderHandler(orderTrade, params);
|
||||
// 删除redis缓存
|
||||
redisCache.deleteObject(orderTrade.getCode());
|
||||
redisCache.deleteObject(params.get("out_trade_no") + "promotionId");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ public class SysUserAttentionServiceImpl extends ServiceImpl<SysUserAttentionMap
|
|||
userId = SecurityUtils.getUserIdMax();
|
||||
}
|
||||
|
||||
PageHelper.clearPage();
|
||||
|
||||
// 粉丝数
|
||||
Long userBeanNum = sysUserAttentionMapper.selectBean(userId);
|
||||
|
|
Loading…
Reference in New Issue