init
This commit is contained in:
@@ -140,7 +140,7 @@ public class CaiLoginManager {
|
||||
}
|
||||
String key = LockManager.getDealInviteLockKey(inviteId);
|
||||
RLock lock = redissonClient.getLock(key);
|
||||
if(!lock.isLocked()){
|
||||
if(lock.isLocked()){
|
||||
log.warn("点击太快了,等一等,dealInviteId");
|
||||
return;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class CaiLoginManager {
|
||||
UserInfo userInfo = userInfoService.getById(user.getId());
|
||||
UserInfo update = new UserInfo();
|
||||
update.setUserId(user.getId());
|
||||
update.setLoginCount(userInfo.getLoginCount()+1);
|
||||
update.setLoginCount(userInfo.getLoginCount()==null?0:userInfo.getLoginCount()+1);
|
||||
update.setLastLoginIp(ip);
|
||||
update.setLastLoginTime(LocalDateTime.now());
|
||||
update.setLastLocation(address);
|
||||
@@ -239,7 +239,7 @@ public class CaiLoginManager {
|
||||
String usercode = userCodeGenService.getCodeGen();
|
||||
User add = new User();
|
||||
add.setUsercode(usercode);
|
||||
add.setNickname("蜜瓜"+usercode);
|
||||
add.setNickname("用户"+usercode);
|
||||
add.setType(0);
|
||||
add.setPassword(BCrypt.hashpw(user.getPassword()));
|
||||
add.setMobile(user.getUsername());
|
||||
|
||||
@@ -3,19 +3,25 @@ package com.ruoyi.cai.auth;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@Data
|
||||
@Schema(description = "注册模型")
|
||||
public class CaiRegisterUser {
|
||||
@Schema(description = "手机号登录名")
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
private String username;
|
||||
@Schema(description = "密码")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
private String password;
|
||||
@Schema(description = "密码确认")
|
||||
@NotEmpty(message = "密码确认不能为空")
|
||||
private String passwordCheck;
|
||||
@Schema(description = "验证码")
|
||||
@NotEmpty(message = "验证码不能为空")
|
||||
private String code;
|
||||
@Schema(description = "邀请人ID")
|
||||
private Long inviteId;
|
||||
@Schema(description = "性别")
|
||||
private Integer gender;
|
||||
private Integer gender = 0;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,15 @@ package com.ruoyi.cai.auth;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@Data
|
||||
@Schema(description = "登陆入参模型")
|
||||
public class LoginCaiUser {
|
||||
@Schema(description = "用户")
|
||||
@NotEmpty(message = "登录名不能为空")
|
||||
private String username;
|
||||
@Schema(description = "密码")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
private String password;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ package com.ruoyi.cai.auth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@Data
|
||||
public class RegisterCode {
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
private String mobile;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public class RedisConstant {
|
||||
public static final String DYNAMIC_TOTAL_CACHE_REDIS = REDIS_P + "synamicTotal:%s:%s";
|
||||
public static final String CODE_REDIS = REDIS_P + "code:%s:%s";
|
||||
public static final String USER_GREET_TOTAL_REDIS = REDIS_P + "userGreetTotal:%s:%s";
|
||||
|
||||
public static final String USER_GREET_SEND_TIME_REDIS = REDIS_P + "userGreetSendTime:%s";
|
||||
public static final String BLACK_REDIS = REDIS_P + "black:%s";
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SmsVerifyController extends BaseController {
|
||||
@SaCheckPermission("cai:smsVerify:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SmsVerify> list(SmsVerify bo, PageQuery pageQuery) {
|
||||
Page<SmsVerify> page = smsVerifyService.page(pageQuery.build(), Wrappers.lambdaQuery(bo));
|
||||
Page<SmsVerify> page = smsVerifyService.page(pageQuery.build(), Wrappers.lambdaQuery(bo).orderByDesc(SmsVerify::getCreateTime));
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,17 @@ package com.ruoyi.cai.controller.app;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.ruoyi.cai.auth.*;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.enums.CodeEnum;
|
||||
import com.ruoyi.cai.manager.CodeManager;
|
||||
import com.ruoyi.cai.service.SmsVerifyService;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -21,16 +25,19 @@ import java.util.Map;
|
||||
@RequestMapping("/api/auth")
|
||||
@SaIgnore
|
||||
@Tag(name = "权限相关接口,免鉴权")
|
||||
@Validated
|
||||
public class AuthAppController {
|
||||
|
||||
@Autowired
|
||||
private CaiLoginManager caiLoginManager;
|
||||
@Autowired
|
||||
private SmsVerifyService smsVerifyService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("/register")
|
||||
@Operation(summary = "注册")
|
||||
public R<Map<String, Object>> register(@RequestBody CaiRegisterUser caiUser){
|
||||
public R<Map<String, Object>> register(@Validated @RequestBody CaiRegisterUser caiUser){
|
||||
String token = caiLoginManager.register(caiUser);
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
ajax.put("token",token);
|
||||
@@ -39,21 +46,25 @@ public class AuthAppController {
|
||||
|
||||
@PostMapping("/register/code")
|
||||
@Operation(summary = "获取注册验证码")
|
||||
public R<Map<String,String>> registerCode(@RequestBody RegisterCode code){
|
||||
public R<Map<String,String>> registerCode(@Validated @RequestBody RegisterCode code){
|
||||
smsVerifyService.put(CodeEnum.REGISTER,code.getMobile());
|
||||
return R.ok("发送成功");
|
||||
}
|
||||
|
||||
@PostMapping("/resetPassword/code")
|
||||
@Operation(summary = "获取重置密码验证码")
|
||||
public R<Map<String,String>> resetPasswordCode(@RequestBody RegisterCode code){
|
||||
public R<Map<String,String>> resetPasswordCode(@Validated @RequestBody RegisterCode code){
|
||||
User user = userService.getByUsername(code.getMobile());
|
||||
if(user == null){
|
||||
throw new ServiceException("用户不存在");
|
||||
}
|
||||
smsVerifyService.put(CodeEnum.RESET_PASSWORD,code.getMobile());
|
||||
return R.ok("发送成功");
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
@Operation(summary = "登陆")
|
||||
public R<Map<String,Object>> login(@RequestBody LoginCaiUser loginBody){
|
||||
public R<Map<String,Object>> login(@Validated @RequestBody LoginCaiUser loginBody){
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
String token = caiLoginManager.login(loginBody.getUsername(), loginBody.getPassword());
|
||||
ajax.put("token",token);
|
||||
@@ -61,10 +72,10 @@ public class AuthAppController {
|
||||
}
|
||||
|
||||
@PostMapping("/resetPassword")
|
||||
@Operation(summary = "获取充值密码验证码")
|
||||
@Operation(summary = "重置密码")
|
||||
public R<Boolean> resetPassword(@RequestBody ResetPasswordReq code){
|
||||
caiLoginManager.resetPassword(code);
|
||||
return R.ok("发送成功");
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ public class SettingAppController {
|
||||
@Autowired
|
||||
private ReportCateService reportCateService;
|
||||
@Autowired
|
||||
private CitysService citysService;
|
||||
@Autowired
|
||||
private GiftService giftService;
|
||||
|
||||
@GetMapping("/goods")
|
||||
@@ -57,12 +55,6 @@ public class SettingAppController {
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/city")
|
||||
@Operation(summary = "城市")
|
||||
public R<Map<Long,String>> city(){
|
||||
return R.ok(citysService.all());
|
||||
}
|
||||
|
||||
@GetMapping("/gift")
|
||||
@Operation(summary = "礼物配置")
|
||||
public R<List<GiftVo>> gift(){
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.ruoyi.common.helper.LoginHelper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,7 +34,7 @@ public class UserAppController {
|
||||
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "修改当前用户信息")
|
||||
public R<Boolean> userUpdate(@RequestBody UserUpdateReq res){
|
||||
public R<Boolean> userUpdate(@Validated @RequestBody UserUpdateReq res){
|
||||
return R.ok(currentUserManager.userUpdate(res));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class UserBlackAppController {
|
||||
}
|
||||
|
||||
@PostMapping("black")
|
||||
@Operation(summary = "拉黑操作 如果已经给拉黑则放开")
|
||||
@Operation(summary = "拉黑操作")
|
||||
public R<Boolean> black(@RequestBody BlackQuery query){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
boolean b = userBlacklistService.black(userId,query.getBlackUserId(),query.getActionType());
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.ruoyi.common.utils.BeanConvertUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,9 +40,10 @@ public class UserGreetAppController {
|
||||
return R.ok(BeanConvertUtil.convertListTo(userGreet,UserGreetVo::new));
|
||||
}
|
||||
|
||||
@GetMapping("/add")
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增群打招呼")
|
||||
public R<Void> add(@RequestBody UserGreetAddReq req){
|
||||
public R<Void> add(@Validated @RequestBody UserGreetAddReq req){
|
||||
req.setUserId(LoginHelper.getUserId());
|
||||
userGreetService.addUserGreet(req);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -5,14 +5,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.AccountBankcard;
|
||||
import com.ruoyi.cai.domain.AccountCash;
|
||||
import com.ruoyi.cai.domain.AccountRecharge;
|
||||
import com.ruoyi.cai.domain.RechargeOrder;
|
||||
import com.ruoyi.cai.dto.app.query.AccountAliBankCardRes;
|
||||
import com.ruoyi.cai.dto.app.query.WithdrawReq;
|
||||
import com.ruoyi.cai.dto.app.vo.AccountCashVo;
|
||||
import com.ruoyi.cai.dto.app.vo.AccountRechargeVo;
|
||||
import com.ruoyi.cai.dto.app.vo.RechargeOrderVo;
|
||||
import com.ruoyi.cai.dto.app.vo.user.UserAccountVo;
|
||||
import com.ruoyi.cai.manager.CurrentUserManager;
|
||||
import com.ruoyi.cai.pay.PayStatusEnum;
|
||||
import com.ruoyi.cai.service.AccountCashService;
|
||||
import com.ruoyi.cai.service.AccountRechargeService;
|
||||
import com.ruoyi.cai.service.RechargeOrderService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
@@ -32,7 +34,7 @@ public class WalletController {
|
||||
@Autowired
|
||||
private AccountCashService accountCashService;
|
||||
@Autowired
|
||||
private AccountRechargeService accountRechargeService;
|
||||
private RechargeOrderService rechargeOrderService;
|
||||
|
||||
@GetMapping("/account")
|
||||
@Operation(summary = "快速获取当前用户账号余额信息")
|
||||
@@ -64,12 +66,14 @@ public class WalletController {
|
||||
|
||||
@GetMapping("/recharge/log")
|
||||
@Operation(summary = "充值记录-分页")
|
||||
public TableDataInfo<AccountRechargeVo> rechargeLog(PageQuery query){
|
||||
public TableDataInfo<RechargeOrderVo> rechargeLog(PageQuery query){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Page<AccountRecharge> page = accountRechargeService.page(query.build(), Wrappers.lambdaQuery(AccountRecharge.class)
|
||||
.eq(AccountRecharge::getUserId, userId)
|
||||
.orderByDesc(AccountRecharge::getCreateTime));
|
||||
return TableDataInfo.build(page,AccountRechargeVo::new);
|
||||
Page<RechargeOrder> page = rechargeOrderService.page(query.build(), Wrappers.lambdaQuery(RechargeOrder.class)
|
||||
.eq(RechargeOrder::getUserId, userId)
|
||||
.eq(RechargeOrder::getAdmin,false)
|
||||
.eq(RechargeOrder::getPayStatus, PayStatusEnum.PAY.getCode())
|
||||
.orderByDesc(RechargeOrder::getCreateTime));
|
||||
return TableDataInfo.build(page, RechargeOrderVo::new);
|
||||
}
|
||||
|
||||
@GetMapping("/cash/log")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.cai.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@@ -51,14 +52,17 @@ public class Gift implements Serializable {
|
||||
/**
|
||||
* 礼物描述
|
||||
*/
|
||||
@TableField("`desc`")
|
||||
private String desc;
|
||||
/**
|
||||
* 是否隐藏 0 不隐藏,可见 1 隐藏
|
||||
*/
|
||||
@TableField("`hide`")
|
||||
private Integer hide;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("`sort`")
|
||||
private Integer sort;
|
||||
/**
|
||||
* 状态 0 可用 1 不可用
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ruoyi.cai.dto.app.query;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@Schema(description = "赠送守护入参")
|
||||
public class GiveGuardReq {
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.ruoyi.cai.dto.app.query;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class IdRes {
|
||||
@Schema(description = "id")
|
||||
@NotNull(message = "参数异常")
|
||||
private Long id;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.cai.dto.app.query;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@@ -14,7 +15,7 @@ public class UserUpdateReq {
|
||||
@Schema(description = "昵称")
|
||||
private String nickname;
|
||||
@Schema(description = "生日")
|
||||
private LocalDateTime birthday;
|
||||
private LocalDate birthday;
|
||||
@Schema(description = "性别")
|
||||
private Integer gender;
|
||||
@Schema(description = "头像")
|
||||
|
||||
@@ -3,11 +3,15 @@ package com.ruoyi.cai.dto.app.query.user;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@Schema(description = "新增群达招呼")
|
||||
public class UserGreetAddReq {
|
||||
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
|
||||
private Long userId;
|
||||
@Schema(description = "内容")
|
||||
@NotEmpty(message = "打招呼内容不能为空")
|
||||
private String title;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class AccountCashVo {
|
||||
*
|
||||
*/
|
||||
@Schema(description = "ID")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.ruoyi.cai.dto.app.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Schema(description = "充值记录")
|
||||
public class AccountRechargeVo {
|
||||
@Schema(description = "ID")
|
||||
private Long id;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Schema(description = "用户Id")
|
||||
private Long userId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Schema(description = "充值ID")
|
||||
private Long goodsId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Schema(description = "订单编号")
|
||||
private String orderNo;
|
||||
/**
|
||||
* 订单名
|
||||
*/
|
||||
@Schema(description = "订单名称")
|
||||
private String orderName;
|
||||
/**
|
||||
* 充值类型 0 手工充值 1 线上充值
|
||||
*/
|
||||
@Schema(description = "充值类型")
|
||||
private Integer rechargeType;
|
||||
/**
|
||||
* 充值金额
|
||||
*/
|
||||
@Schema(description = "充值金额")
|
||||
private BigDecimal rechargeMoney;
|
||||
/**
|
||||
* 充值的紫贝
|
||||
*/
|
||||
@Schema(description = "紫贝数量")
|
||||
private Integer coinNum;
|
||||
/**
|
||||
* 充值平台类型
|
||||
*/
|
||||
@Schema(description = "平台")
|
||||
private Long platformType;
|
||||
/**
|
||||
* 充值平台名称
|
||||
*/
|
||||
@Schema(description = "平台名称")
|
||||
private String platformName;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String payNo;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String operateIp;
|
||||
/**
|
||||
* 类型: 0积分(默认),1会员
|
||||
*/
|
||||
@Schema(description = "0-充值 1-会员")
|
||||
private Integer type;
|
||||
@Schema(description = "充值时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -8,6 +8,9 @@ import java.math.BigDecimal;
|
||||
@Data
|
||||
@Schema(description = "主播列表信息")
|
||||
public class AnchorListVo {
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private String userId;
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
|
||||
@@ -37,16 +37,9 @@ public class DynamicVo {
|
||||
*/
|
||||
@Schema(description = "是否有附件 0 没有 1 有")
|
||||
private Integer isAttach;
|
||||
/**
|
||||
* 状态 0 审核中 1可用 2 不可用
|
||||
*/
|
||||
@Schema(description = "状态 0 审核中 1可用 2 不可用")
|
||||
private Integer status;
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
@Schema(description = "排序字段")
|
||||
private Long sort;
|
||||
|
||||
@Schema(description = "审核状态")
|
||||
private Integer auditStatus;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@@ -1,30 +1,38 @@
|
||||
package com.ruoyi.cai.dto.app.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.print.attribute.standard.Media;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class GiftVo implements Serializable {
|
||||
private Integer id;
|
||||
@Schema(description = "礼物ID")
|
||||
private Long id;
|
||||
/**
|
||||
* 类型 0 普通礼物 1svga礼物
|
||||
*/
|
||||
@Schema(hidden = true)
|
||||
private Integer type;
|
||||
/**
|
||||
* 礼物名称
|
||||
*/
|
||||
@Schema(description = "礼物名称")
|
||||
private String name;
|
||||
/**
|
||||
* 礼物价格
|
||||
*/
|
||||
@Schema(description = "礼物价格")
|
||||
private Long price;
|
||||
/**
|
||||
* 礼物图片地址
|
||||
*/
|
||||
@Schema(description = "图片")
|
||||
private String img;
|
||||
/**
|
||||
* svga地址
|
||||
*/
|
||||
@Schema(description = "礼物SVGA")
|
||||
private String svga;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ruoyi.cai.dto.app.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Schema(description = "充值记录")
|
||||
public class RechargeOrderVo {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(description = "商品ID")
|
||||
private Long rechargeId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称")
|
||||
private String rechargeName;
|
||||
/**
|
||||
* 充值紫贝
|
||||
*/
|
||||
@Schema(description = "充值紫贝")
|
||||
private Long rechargeCoin;
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
@Schema(description = "价格")
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号")
|
||||
private String orderNo;
|
||||
@Schema(description = "状态 0-待支付 1-已支付 2-已退款 10-无需支付")
|
||||
private Integer payStatus;
|
||||
|
||||
@Schema(description = "充值时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -19,6 +19,6 @@ public class UserGiftIndexVo {
|
||||
@Schema(description = "礼物价格")
|
||||
private String price;
|
||||
@Schema(description = "礼物数量")
|
||||
private Long count;
|
||||
private Long giftCount;
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,4 @@ public class UserAccountVo {
|
||||
@Schema(description = "收益的紫贝")
|
||||
private Long incomeCoin;
|
||||
|
||||
@Schema(description = "总数量")
|
||||
private Long totalCoin;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import lombok.Data;
|
||||
@Data
|
||||
public class UserBaseVo {
|
||||
|
||||
@Schema(description = "用户Id")
|
||||
private Long userId;
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
@@ -24,7 +26,7 @@ public class UserBaseVo {
|
||||
@Schema(description = "城市ID")
|
||||
private Integer cityId;
|
||||
@Schema(description = "城市")
|
||||
private Integer city;
|
||||
private String city;
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
|
||||
@@ -17,12 +17,12 @@ public class UserGreetVo {
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Schema(description = "标题")
|
||||
@Schema(description = "内容")
|
||||
private String title;
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
@Schema(description = "审核状态 1 审核中, 2 审核通过, 3 审核不通过")
|
||||
private Integer status;
|
||||
private Integer auditStatus;
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
@Schema(description = "用户列表返回")
|
||||
public class UserListVo extends UserBaseVo {
|
||||
@Schema(description = "绑定时间")
|
||||
@Schema(description = "最后活跃时间")
|
||||
private LocalDateTime bindTime;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class UserStarOrVisitorList {
|
||||
public class UserStarOrVisitorList extends UserBaseVo {
|
||||
|
||||
private LocalDateTime happenTime;
|
||||
|
||||
|
||||
@@ -52,8 +52,9 @@ public class CurrentUserManager {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
User user = userService.getById(userId);
|
||||
CurrentUserInfoVo res = BeanConvertUtil.convertTo(user, CurrentUserInfoVo::new);
|
||||
res.setUserId(userId);
|
||||
Anchor anchor = anchorService.getByUserId(userId);
|
||||
res.setOpenVideoStatus(anchor.getOpenVideoStatus());
|
||||
res.setOpenVideoStatus(anchor == null ? 1 : anchor.getOpenVideoStatus());
|
||||
UserCount userCount = userCountService.getByUserId(userId);
|
||||
res.setUserCount(BeanConvertUtil.convertTo(userCount, UserCountVo::new));
|
||||
Account account = accountService.getByUserId(userId);
|
||||
|
||||
@@ -14,12 +14,12 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
public interface AccountMapper extends BaseMapper<Account> {
|
||||
|
||||
long decrCoin(@Param("userId") Long userId, @Param("coin") Long coin);
|
||||
boolean decrCoin(@Param("userId") Long userId, @Param("coin") Long coin);
|
||||
|
||||
long incsCoin(@Param("userId") Long userId, @Param("coin") Long coin);
|
||||
boolean incsCoin(@Param("userId") Long userId, @Param("coin") Long coin);
|
||||
|
||||
void incsIncomeCoin(@Param("userId") Long userId, @Param("incomeCoin") Long incomeCoin);
|
||||
long decrIncomeCoin(@Param("userId") Long userId, @Param("incomeCoin") Long incomeCoin);
|
||||
boolean incsIncomeCoin(@Param("userId") Long userId, @Param("incomeCoin") Long incomeCoin);
|
||||
boolean decrIncomeCoin(@Param("userId") Long userId, @Param("incomeCoin") Long incomeCoin);
|
||||
|
||||
Page<AccountAdminVo> pageAdmin(@Param("build") Page<Object> build, @Param("bo") AccountAdminVo bo);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.ruoyi.cai.util.NumCaUtil;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -55,18 +56,18 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
throw new ServiceException("余额不足");
|
||||
}
|
||||
boolean flag = false;
|
||||
long coin = account.getCoin();
|
||||
long incomeCoin = 0;
|
||||
long coin = -amount; // 消费余额
|
||||
long incomeCoin = 0; // 消费收益
|
||||
long diff = account.getCoin() - amount;
|
||||
// 充值币够用
|
||||
if(diff > 0){
|
||||
long l = baseMapper.decrCoin(userId, coin);
|
||||
flag = l > 0;
|
||||
flag = baseMapper.decrCoin(userId, -coin);
|
||||
} else { // 充值币不够用
|
||||
coin = -account.getCoin();
|
||||
incomeCoin = diff;
|
||||
long decrCoin = baseMapper.decrCoin(userId, account.getCoin());
|
||||
long decrIncomeCoin = baseMapper.decrIncomeCoin(userId, -diff);
|
||||
if(decrCoin > 0 && decrIncomeCoin > 0){
|
||||
boolean decrCoin = baseMapper.decrCoin(userId, -coin);
|
||||
boolean decrIncomeCoin = baseMapper.decrIncomeCoin(userId, -diff);
|
||||
if(decrCoin && decrIncomeCoin){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
@@ -88,8 +89,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
if(incomeCoin != 0){
|
||||
accountChangeLogService.saveLogNoAdmin(userId,consumeLog.getSourceUsercode(), RechargeTypeEnum.COIN_INCOME,businessEnum.getSourceEnum(),incomeCoin,consumeLog.getTraceId());
|
||||
}
|
||||
// 记录接收方的流水
|
||||
if(targetUserId != null){
|
||||
accountChangeLogService.saveLogNoAdmin(targetUserId,consumeLog.getTargetUsercode(), RechargeTypeEnum.COIN_INCOME,businessEnum.getTargetEnum(),incomeCoin,consumeLog.getTraceId());
|
||||
accountChangeLogService.saveLogNoAdmin(targetUserId,consumeLog.getTargetUsercode(), RechargeTypeEnum.COIN_INCOME,businessEnum.getTargetEnum(),consumeLog.getAnchorAmount(),consumeLog.getTraceId());
|
||||
}
|
||||
// 获取分销的比例和用户
|
||||
consumeLogService.calculateInitFenxiao(consumeLog);
|
||||
@@ -108,8 +110,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
if(account.getIncomeCoin() < incomeCoin){
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
long incs = baseMapper.decrIncomeCoin(userId, incomeCoin);
|
||||
if(incs <= 0){
|
||||
boolean incs = baseMapper.decrIncomeCoin(userId, incomeCoin);
|
||||
if(!incs){
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
accountChangeLogService.saveLogNoAdmin(user.getId(),user.getUsercode(), RechargeTypeEnum.COIN_INCOME,AccountBusinessEnum.WITHDRAW.getSourceEnum(),incomeCoin,traceId);
|
||||
|
||||
@@ -114,6 +114,7 @@ public class ConsumeLogServiceImpl extends ServiceImpl<ConsumeLogMapper, Consume
|
||||
consumeLog.setOneAmount(NumCaUtil.coin(consumeLog.getAmount(),consumeLog.getOneRate()));
|
||||
}
|
||||
}
|
||||
consumeLog.setCalculateStatus(true);
|
||||
return consumeLog;
|
||||
}
|
||||
Long targetUserId = consumeLog.getTargetUserId();
|
||||
@@ -166,6 +167,7 @@ public class ConsumeLogServiceImpl extends ServiceImpl<ConsumeLogMapper, Consume
|
||||
}
|
||||
}
|
||||
}
|
||||
consumeLog.setCalculateStatus(true);
|
||||
return consumeLog;
|
||||
}
|
||||
|
||||
|
||||
@@ -153,11 +153,11 @@ public class RechargeOrderServiceImpl extends ServiceImpl<RechargeOrderMapper,Re
|
||||
if(account.getCoin() < -dto.getRechargeCoin()){
|
||||
throw new ServiceException("调整后余额为负数,无法调整");
|
||||
}
|
||||
long l = accountMapper.decrCoin(userId, -dto.getRechargeCoin());
|
||||
accountChangeLogService.saveLogAdmin(user.getId(),user.getUsercode(),RechargeTypeEnum.COIN, AccountChangeEnum.SYSTEM_COIN_DECR,dto.getRechargeCoin(),traceId);
|
||||
if(l == 0){
|
||||
throw new ServiceException("调整后余额为负数,无法调整");
|
||||
boolean l = accountMapper.decrCoin(userId, -dto.getRechargeCoin());
|
||||
if(!l){
|
||||
throw new ServiceException("调整后收益为负数,无法调整");
|
||||
}
|
||||
accountChangeLogService.saveLogAdmin(user.getId(),user.getUsercode(),RechargeTypeEnum.COIN, AccountChangeEnum.SYSTEM_COIN_DECR,dto.getRechargeCoin(),traceId);
|
||||
}
|
||||
}else{
|
||||
if(dto.getRechargeCoin() > 0){
|
||||
@@ -167,11 +167,11 @@ public class RechargeOrderServiceImpl extends ServiceImpl<RechargeOrderMapper,Re
|
||||
if(account.getIncomeCoin() < -dto.getRechargeCoin()){
|
||||
throw new ServiceException("调整后收益为负数,无法调整");
|
||||
}
|
||||
long l = accountMapper.decrIncomeCoin(userId, -dto.getRechargeCoin());
|
||||
accountChangeLogService.saveLogAdmin(user.getId(),user.getUsercode(),RechargeTypeEnum.COIN_INCOME, AccountChangeEnum.SYSTEM_INCOME_COIN_DECR,dto.getRechargeCoin(),traceId);
|
||||
if(l == 0){
|
||||
boolean l = accountMapper.decrIncomeCoin(userId, -dto.getRechargeCoin());
|
||||
if(!l){
|
||||
throw new ServiceException("调整后收益为负数,无法调整");
|
||||
}
|
||||
accountChangeLogService.saveLogAdmin(user.getId(),user.getUsercode(),RechargeTypeEnum.COIN_INCOME, AccountChangeEnum.SYSTEM_INCOME_COIN_DECR,dto.getRechargeCoin(),traceId);
|
||||
}
|
||||
}
|
||||
return order;
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.domain.UserGreet;
|
||||
import com.ruoyi.cai.dto.admin.vo.UserGreetAdminVo;
|
||||
import com.ruoyi.cai.dto.app.query.user.UserGreetAddReq;
|
||||
import com.ruoyi.cai.enums.AuditStatusEnum;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import com.ruoyi.cai.manager.LockManager;
|
||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||
@@ -102,12 +103,12 @@ public class UserGreetServiceImpl extends ServiceImpl<UserGreetMapper,UserGreet>
|
||||
if(userGreet == null || !userGreet.getUserId().equals(userId)){
|
||||
throw new ServiceException("请选择打招呼内容");
|
||||
}
|
||||
if(userGreet.getAuditStatus() != 1){
|
||||
if(AuditStatusEnum.SUCCESS.getCode().equals(userGreet.getAuditStatus())){
|
||||
throw new ServiceException("内容未通过审核");
|
||||
}
|
||||
String lockKey = LockManager.getSendGreetLock(userId);
|
||||
RLock lock = redissonClient.getLock(lockKey);
|
||||
if(!lock.isLocked()){
|
||||
if(lock.isLocked()){
|
||||
throw new ServiceException("操作太频繁");
|
||||
}
|
||||
try {
|
||||
@@ -118,8 +119,8 @@ public class UserGreetServiceImpl extends ServiceImpl<UserGreetMapper,UserGreet>
|
||||
if(val != null && Long.parseLong(val) > max){
|
||||
throw new ServiceException("您今天打招呼的次数已经用完了");
|
||||
}
|
||||
String sendGreetLock = LockManager.getSendGreetLock(userId);
|
||||
String lastTime = stringRedisTemplate.opsForValue().getAndExpire(sendGreetLock, 1, TimeUnit.DAYS);
|
||||
String sendGreetCount = String.format(RedisConstant.USER_GREET_SEND_TIME_REDIS,userId);
|
||||
String lastTime = stringRedisTemplate.opsForValue().get(sendGreetCount);
|
||||
if(StringUtils.isNotBlank(lastTime)){
|
||||
Integer inter = systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.GREET_INTERVAL_MIN);
|
||||
long jiange = Long.parseLong(lastTime) - DateUtil.currentSeconds();
|
||||
@@ -140,7 +141,7 @@ public class UserGreetServiceImpl extends ServiceImpl<UserGreetMapper,UserGreet>
|
||||
if(!r.isSuccess()){
|
||||
throw new ServiceException("发送失败");
|
||||
}
|
||||
stringRedisTemplate.opsForValue().set(sendGreetLock,DateUtil.currentSeconds()+"",1,TimeUnit.DAYS);
|
||||
stringRedisTemplate.opsForValue().set(sendGreetCount,DateUtil.currentSeconds()+"",1,TimeUnit.DAYS);
|
||||
stringRedisTemplate.opsForValue().increment(numKey);
|
||||
stringRedisTemplate.expire(numKey,1,TimeUnit.DAYS);
|
||||
}finally {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
|
||||
InviteCountDTO inviteCount = baseMapper.countInviteAndReward(userId);
|
||||
vo.setTotalInvite(inviteCount.getTotalInvite());
|
||||
vo.setTotalReward(inviteCount.getTotalReward());
|
||||
return null;
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,14 +3,17 @@ package com.ruoyi.cai.service.impl;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.domain.UserVisitor;
|
||||
import com.ruoyi.cai.dto.app.query.StarOrVisitorReq;
|
||||
import com.ruoyi.cai.dto.app.query.VisitorQuery;
|
||||
import com.ruoyi.cai.dto.app.vo.user.UserStarOrVisitorList;
|
||||
import com.ruoyi.cai.mapper.UserVisitorMapper;
|
||||
import com.ruoyi.cai.service.UserCountService;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import com.ruoyi.cai.service.UserVisitorService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -29,8 +32,15 @@ import java.time.LocalDateTime;
|
||||
public class UserVisitorServiceImpl extends ServiceImpl<UserVisitorMapper, UserVisitor> implements UserVisitorService {
|
||||
@Autowired
|
||||
private UserCountService userCountService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Override
|
||||
public boolean visitor(StarOrVisitorReq starOrVisitorReq) {
|
||||
User user = userService.getById(starOrVisitorReq.getToUserId());
|
||||
if(user == null){
|
||||
log.error("用户不存在");
|
||||
return false;
|
||||
}
|
||||
Long fromUserId = LoginHelper.getUserId();
|
||||
UserVisitor userVisitor = this.getOne(Wrappers.lambdaQuery(UserVisitor.class)
|
||||
.eq(UserVisitor::getVisitorId, fromUserId)
|
||||
@@ -49,6 +59,9 @@ public class UserVisitorServiceImpl extends ServiceImpl<UserVisitorMapper, UserV
|
||||
|
||||
@Override
|
||||
public Page<UserStarOrVisitorList> pageApp(PageQuery pageQuery, VisitorQuery query) {
|
||||
if(query.getType() == null || (query.getType() != 1 && query.getType() != 2)){
|
||||
throw new ServiceException("参数异常");
|
||||
}
|
||||
query.setUserId(LoginHelper.getUserId());
|
||||
return baseMapper.pageApp(pageQuery.build(),query);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user