cp关系名变更

This commit is contained in:
2025-04-08 17:46:13 +08:00
parent 691a85b6f4
commit d96de5fcd0
19 changed files with 413 additions and 32 deletions

View File

@@ -24,14 +24,13 @@ import com.accompany.business.service.guild.GuildDressUpService;
import com.accompany.business.service.guild.GuildMemberService;
import com.accompany.business.service.level.LevelService;
import com.accompany.business.service.lucky.Lucky24RecordService;
import com.accompany.business.service.relation.RelationUserServiceImpl;
import com.accompany.business.service.relation.impl.RelationUserServiceImpl;
import com.accompany.business.service.room.RoomManageService;
import com.accompany.business.service.room.RoomReciveRankingService;
import com.accompany.business.service.room.RoomSendRankingService;
import com.accompany.business.service.room.RoomService;
import com.accompany.business.service.user.UsersService;
import com.accompany.business.vo.RoomVo;
import com.accompany.common.constant.AppEnum;
import com.accompany.common.constant.EmailConstant;
import com.accompany.common.device.DeviceInfo;
import com.accompany.common.redis.RedisKey;
@@ -49,7 +48,6 @@ import com.accompany.core.service.account.AccountService;
import com.accompany.core.service.common.JedisService;
import com.accompany.core.service.region.RegionService;
import com.accompany.core.vo.UserLevelVo;
import com.accompany.email.config.AwsSesConfig;
import com.accompany.email.service.EmailService;
import com.accompany.payment.apple.ApplePublisher;
import com.accompany.payment.iospay.JWTTranscationInfoPayload;
@@ -68,24 +66,9 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.MessagingException;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProviderChain;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sesv2.model.Body;
import software.amazon.awssdk.services.sesv2.model.Content;
import software.amazon.awssdk.services.sesv2.model.Destination;
import software.amazon.awssdk.services.sesv2.model.EmailContent;
import software.amazon.awssdk.services.sesv2.model.Message;
import software.amazon.awssdk.services.sesv2.model.SendEmailRequest;
import software.amazon.awssdk.services.sesv2.model.SesV2Exception;
import software.amazon.awssdk.services.sesv2.SesV2Client;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;

View File

@@ -939,6 +939,11 @@ public enum BusiStatus {
EMAIL_CODE_IP_TO_OFTEN(3019, "獲取邮件验证码過於頻繁"),
EMAIL_VERIFY_CODE_ERROR(3020, "邮件驗證碼校驗失敗"),
EMAIL_HAD_BOUND_BY_OTHER(3021, "邮箱已经绑定其他帐号"),
CP_NAME_CHANGE_APPLY(20512, "您已经提交更换申请,请耐心等待。"),
CP_NAME_CHANGE_LOVER_APPLY(20512, "对方已经发起了关系变更请求。"),
CP_NAME_CHANGE_EXIST_NOT_EXPIRE(20512, "你需要30天才能更换状态。"),
CP_NAME_CHANGE_APPLY_EXPIRE(20512, "该消息已经失效。"),
CP_CANCEL(20512, "关系已解除,变更申请自动失效。"),
;
private final int value;

View File

@@ -416,6 +416,10 @@ public class Constant {
public static int COMMON_DEFINED = 116; //通用消息
public static int COMMON_DEFINED_OPERATE = 1160; //通用聊天信息
public static int CP = 117; //CP
public static int CP_NAME_CHANGE = 1170; //更换CP名称聊天推送
public static int CP_NAME_CHANGE_AUDIT = 1171; //更换CP名称聊天操做推送
}
/**

View File

@@ -9,9 +9,20 @@ public interface RelationConstant {
*/
String CP_GIFT_CONFIG = "cp_gift_config";
interface RelatinType {
interface RelatinType {//
int CP = 1; //CP
}
interface RelatinNameType {//基于cp下的名称
int CP = 1; //CP
int brother = 2; //兄弟
int sister = 3; //闺蜜
int friend = 4; //好友
}
interface RelatinLevel {
int ONE = 1; //CP
int TWO = 2; //CP
@@ -25,6 +36,25 @@ public interface RelationConstant {
byte NORMAL = 1; //正常
}
/**
* 申请改名状态
*/
interface ApplyStatus {
byte APPLY = 0; //申请
byte AGREE = 1; //对方同意
byte REJECT = 2; //对方同意
}
/**
* 按钮状态
*/
interface ClickFlag {//默认状态0,申请发送后1,申请通过2
byte NORMAL = 0;
byte SENDED = 1;
byte PASS = 2;
}
enum RelationRedisKey implements BaseRedisKey {
relation,
/**

View File

@@ -0,0 +1,67 @@
package com.accompany.business.model.relation;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.Data;
/**
* 关系名更改申请表实体类
*
* @author
* @since 2025-04-08
*/
@Data
public class RelationNameChangeRecord implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 用户UID申请人
*/
private Long uid;
/**
* 情侣UID
*/
private Long loverUid;
/**
* 关系类型.1-CP
*/
private Integer relationType;
/**
* 关系名称类型CP = 1; brother = 2;sister = 3; friend = 4;
*/
private Integer relationNameType;
/**
* 新关系名称类型
*/
private Integer newRelationNameType;
/**
* 0-申请, 1-对方同意
*/
private Byte applyStatus;
/**
* 申请过期时间
*/
private Date expireTime;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@@ -43,6 +43,11 @@ public class RelationUser implements Serializable {
* 关系类型.1-CP
*/
private Integer relationType;
/**
* 关系类型名称CP = 1; brother = 2;sister = 3; friend = 4;
*/
private Integer relationNameType;
/**
* 关系等级
*/

View File

@@ -9,4 +9,5 @@ public class RelationCpVO {
private String cpAvatar;
private String cpNick;
private Long cpUid;
private Integer relationNameType;
}

View File

@@ -33,4 +33,5 @@ public class RelationUserVO extends RelationUser {
private Boolean showCpAnim;
private Long cancelGoldNum = 7000L;
private Boolean clickFlag = Boolean.TRUE;//默认状态true
}

View File

@@ -0,0 +1,14 @@
package com.accompany.business.mybatismapper.relation;
import com.accompany.business.model.relation.RelationNameChangeRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 关系名更改申请表 Mapper 接口
*
* @author
* @since 2025-04-08
*/
public interface RelationNameChangeRecordMapper extends BaseMapper<RelationNameChangeRecord> {
}

View File

@@ -105,4 +105,18 @@ public class BaseSendService {
params.setTo(targetUid.toString());
sendSysMsgService.sendMsg(params);
}
public void sendMsg(String senderUid, Long targetUid, int first, int second, Object object){
NeteaseSendMsgParam params = new NeteaseSendMsgParam();
params.setFrom(senderUid);
params.setOpe(0);
params.setType(Constant.DefineProtocol.CUSTOM_MESS_DEFINE);
Attach attach = new Attach();
attach.setFirst(first);
attach.setSecond(second);
attach.setData(object);
params.setAttach(attach);
params.setTo(targetUid.toString());
sendSysMsgService.sendMsg(params);
}
}

View File

@@ -0,0 +1,20 @@
package com.accompany.business.service.relation;
import com.accompany.business.model.relation.RelationNameChangeRecord;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Date;
/**
* 关系名更改申请表 服务类
*
* @author
* @since 2025-04-08
*/
public interface RelationNameChangeRecordService extends IService<RelationNameChangeRecord> {
RelationNameChangeRecord getApplyRecord(Long uid, Long loverUid, Integer relationNameType, Integer newRelationNameType);
Long applyRecordCount(Long uid, Long loverUid);
RelationNameChangeRecord getValidRecord(Long uid, Long loverUid);
RelationNameChangeRecord addRecord(Long uid, Long loverUid, Integer relationType, Integer relationNameType, Integer newRelationNameType, Date createTime, Date expireTime);
}

View File

@@ -6,6 +6,7 @@ import com.accompany.business.vo.relation.RelationCpVO;
import com.accompany.business.vo.relation.RelationUserVO;
import com.accompany.common.result.BusiResult;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@@ -30,6 +31,10 @@ public interface RelationUserService extends IService<RelationUser> {
BusiResult cancelCp(Long uid, Long loverUid, Long goldNum);
BusiResult nameChange(Long uid, Long loverUid, Integer relationNameType);
BusiResult nameChangeAudit(Long uid, Long recordId, Byte status);
/**
* 个人主页cp详细信息
* @param uid

View File

@@ -1,7 +1,8 @@
package com.accompany.business.service.relation;
package com.accompany.business.service.relation.impl;
import com.accompany.business.model.relation.RelationCancelRecord;
import com.accompany.business.mybatismapper.relation.RelationCancelRecordMapper;
import com.accompany.business.service.relation.RelationCancelRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

View File

@@ -1,8 +1,9 @@
package com.accompany.business.service.relation;
package com.accompany.business.service.relation.impl;
import com.accompany.business.constant.relation.RelationConstant;
import com.accompany.business.model.relation.RelationInfo;
import com.accompany.business.mybatismapper.relation.RelationInfoMapper;
import com.accompany.business.service.relation.RelationInfoService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.CollectionUtils;

View File

@@ -0,0 +1,70 @@
package com.accompany.business.service.relation.impl;
import com.accompany.business.constant.relation.RelationConstant;
import com.accompany.business.model.relation.RelationNameChangeRecord;
import com.accompany.business.mybatismapper.relation.RelationNameChangeRecordMapper;
import com.accompany.business.service.relation.RelationNameChangeRecordService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* 关系名更改申请表 服务实现类
*
* @author
* @since 2025-04-08
*/
@Service
public class RelationNameChangeRecordServiceImpl extends ServiceImpl<RelationNameChangeRecordMapper, RelationNameChangeRecord> implements RelationNameChangeRecordService {
@Override
public RelationNameChangeRecord getApplyRecord(Long uid, Long loverUid, Integer relationNameType, Integer newRelationNameType) {
LambdaQueryWrapper<RelationNameChangeRecord> wrapper = Wrappers.lambdaQuery();
wrapper.eq(RelationNameChangeRecord::getUid, uid)
.eq(RelationNameChangeRecord::getLoverUid, loverUid)
.eq(RelationNameChangeRecord::getRelationNameType, relationNameType)
.eq(RelationNameChangeRecord::getNewRelationNameType, newRelationNameType)
.eq(RelationNameChangeRecord::getApplyStatus, RelationConstant.ApplyStatus.APPLY)
.gt(RelationNameChangeRecord::getExpireTime, new Date());
return getOne(wrapper, false);
}
@Override
public Long applyRecordCount(Long uid, Long loverUid) {
LambdaQueryWrapper<RelationNameChangeRecord> wrapper = Wrappers.lambdaQuery();
wrapper.eq(RelationNameChangeRecord::getUid, uid)
.eq(RelationNameChangeRecord::getLoverUid, loverUid)
.eq(RelationNameChangeRecord::getApplyStatus, RelationConstant.ApplyStatus.APPLY)
.gt(RelationNameChangeRecord::getExpireTime, new Date());
return baseMapper.selectCount(wrapper);
}
@Override
public RelationNameChangeRecord getValidRecord(Long uid, Long loverUid) {
LambdaQueryWrapper<RelationNameChangeRecord> wrapper = Wrappers.lambdaQuery();
wrapper.eq(RelationNameChangeRecord::getUid, uid)
.eq(RelationNameChangeRecord::getLoverUid, loverUid)
.eq(RelationNameChangeRecord::getApplyStatus, RelationConstant.ApplyStatus.AGREE)
.orderByDesc(RelationNameChangeRecord::getCreateTime);
return getOne(wrapper, false);
}
@Override
public RelationNameChangeRecord addRecord(Long uid, Long loverUid, Integer relationType, Integer relationNameType, Integer newRelationNameType, Date createTime, Date expireTime) {
RelationNameChangeRecord record = new RelationNameChangeRecord();
record.setUid(uid);
record.setLoverUid(loverUid);
record.setRelationType(relationType);
record.setRelationNameType(relationNameType);
record.setNewRelationNameType(newRelationNameType);
record.setApplyStatus(RelationConstant.ApplyStatus.APPLY);
record.setCreateTime(createTime);
record.setExpireTime(expireTime);
int insert = baseMapper.insert(record);
return record;
}
}

View File

@@ -1,4 +1,4 @@
package com.accompany.business.service.relation;
package com.accompany.business.service.relation.impl;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
@@ -8,6 +8,7 @@ import com.accompany.business.model.Gift;
import com.accompany.business.model.UserPurse;
import com.accompany.business.model.relation.RelationCancelRecord;
import com.accompany.business.model.relation.RelationInfo;
import com.accompany.business.model.relation.RelationNameChangeRecord;
import com.accompany.business.model.relation.RelationUser;
import com.accompany.business.model.user.UserSetting;
import com.accompany.business.mybatismapper.relation.RelationUserMapper;
@@ -15,7 +16,10 @@ import com.accompany.business.service.BaseSendService;
import com.accompany.business.service.activity.h5.ActivityOfCpService;
import com.accompany.business.service.gift.GiftService;
import com.accompany.business.service.purse.UserPurseService;
import com.accompany.business.service.record.BillRecordService;
import com.accompany.business.service.relation.RelationCancelRecordService;
import com.accompany.business.service.relation.RelationInfoService;
import com.accompany.business.service.relation.RelationNameChangeRecordService;
import com.accompany.business.service.relation.RelationUserService;
import com.accompany.business.service.user.UserSettingService;
import com.accompany.business.service.user.UsersService;
import com.accompany.business.vo.relation.CPGiftScreenDTO;
@@ -47,6 +51,7 @@ import org.redisson.client.codec.StringCodec;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.TimeUnit;
@@ -55,6 +60,7 @@ import java.util.stream.Collectors;
import static com.accompany.business.constant.relation.RelationConstant.CP_GIFT_CONFIG;
import static com.accompany.business.constant.relation.RelationConstant.RelationRedisKey.relation;
import static com.accompany.common.constant.Constant.DefMsgType.*;
import static com.accompany.common.status.BusiStatus.*;
/**
* 情侣记录表 服务实现类
@@ -79,8 +85,6 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
@Autowired
private UserPurseService userPurseService;
@Autowired
private BillRecordService billRecordService;
@Autowired
private RedissonClient redissonClient;
@Autowired
private UserSettingService userSettingService;
@@ -88,6 +92,8 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
private RelationCancelRecordService relationCancelRecordService;
@Autowired
private ActivityOfCpService activityOfCpService;
@Autowired
private RelationNameChangeRecordService relationNameChangeRecordService;
public void calCpInfo(GiftMessage message) {
Long sendUid = message.getSendUid();
@@ -199,7 +205,8 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
@Override
public List<RelationUserVO> getCPList(Long uid, Integer page, Integer pageSize) {
LambdaQueryWrapper<RelationUser> wrapper = Wrappers.lambdaQuery();
wrapper.select(RelationUser::getUid, RelationUser::getLoverUid, RelationUser::getRelationLevel, RelationUser::getIntimacy, RelationUser::getCreateTime)
wrapper.select(RelationUser::getUid, RelationUser::getLoverUid, RelationUser::getRelationNameType,
RelationUser::getRelationLevel, RelationUser::getIntimacy, RelationUser::getCreateTime)
.eq(RelationUser::getRelationStatus, RelationConstant.RelationStatus.NORMAL)
.eq(RelationUser::getUid, uid)
.eq(RelationUser::getRelationType, RelationConstant.RelatinType.CP)
@@ -228,6 +235,7 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
} else {
loversRecordVO.setCpAvatar(sysConfService.getSysConfValueById(Constant.SysConfId.users_default_avatar));
}
loversRecordVO.setRelationNameType(record.getRelationNameType());
loversRecordVO.setCpLevel(record.getRelationLevel());
loversRecordVO.setCpDay((int)DateUtil.between(record.getCreateTime(), today, DateUnit.DAY));
loversRecordVO.setCurrentExp(record.getIntimacy().longValue());
@@ -237,6 +245,11 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
loversRecordVO.setCancelGoldNum(loverConfig.getCancelCpGoldNum());
Integer maxCpLevel = loverConfig.getMaxCpLevel();
loversRecordVO.setMaxCpLevel(maxCpLevel);
//to-do优化查询
Long applyRecordCount = relationNameChangeRecordService.applyRecordCount(record.getUid(), record.getLoverUid());
loversRecordVO.setClickFlag(applyRecordCount <= 0);
loversRecordVO.setMaxCpLevel(maxCpLevel);
resultList.add(loversRecordVO);
}
return resultList;
@@ -245,7 +258,7 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
@Override
public List<RelationCpVO> getAllCPList(Long uid) {
LambdaQueryWrapper<RelationUser> wrapper = Wrappers.lambdaQuery();
wrapper.select(RelationUser::getUid, RelationUser::getLoverUid, RelationUser::getRelationLevel, RelationUser::getIntimacy)
wrapper.select(RelationUser::getUid, RelationUser::getLoverUid, RelationUser::getRelationNameType, RelationUser::getRelationLevel, RelationUser::getIntimacy)
.eq(RelationUser::getRelationStatus, RelationConstant.RelationStatus.NORMAL)
.eq(RelationUser::getUid, uid)
.eq(RelationUser::getRelationType, RelationConstant.RelatinType.CP)
@@ -265,6 +278,7 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
if (users == null) {
continue;
}
loversRecordVO.setRelationNameType(record.getRelationNameType());
loversRecordVO.setCpAvatar(users.getAvatar());
loversRecordVO.setCpNick(users.getNick());
loversRecordVO.setCpErbanNo(users.getErbanNo());
@@ -277,7 +291,8 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
@Override
public List<RelationUser> getOrgCPList(Long uid, Integer page, Integer pageSize) {
LambdaQueryWrapper<RelationUser> wrapper = Wrappers.lambdaQuery();
wrapper.select(RelationUser::getUid, RelationUser::getLoverUid, RelationUser::getRelationLevel, RelationUser::getIntimacy, RelationUser::getCreateTime)
wrapper.select(RelationUser::getUid, RelationUser::getLoverUid, RelationUser::getRelationNameType,
RelationUser::getRelationLevel, RelationUser::getIntimacy, RelationUser::getCreateTime)
.eq(RelationUser::getRelationStatus, RelationConstant.RelationStatus.NORMAL)
.eq(RelationUser::getUid, uid)
.eq(RelationUser::getRelationType, RelationConstant.RelatinType.CP)
@@ -353,7 +368,7 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
}
private boolean addCpRecord(Long uid, Long loverUid, Double plusCpValue, Integer plusLevel, Date startDate, Integer sendFlag) {
RelationUser cpRecord = this.cpRecord(uid, loverUid);
RelationUser cpRecord = this.cpRecord(uid, loverUid,RelationConstant.RelatinType.CP);
if (cpRecord != null) {
return baseMapper.updateCpValue(uid, loverUid, plusCpValue, plusLevel, startDate, sendFlag) > 0;
} else {
@@ -367,6 +382,7 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
cpRecord.setRelationLevel(plusLevel);
cpRecord.setRelationStatus(RelationConstant.RelationStatus.NORMAL);
cpRecord.setRelationType(RelationConstant.RelatinType.CP);
cpRecord.setRelationNameType(RelationConstant.RelatinNameType.CP);
cpRecord.setCreateTime(new Date());
try {
return save(cpRecord);
@@ -378,10 +394,11 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
}
}
private RelationUser cpRecord(Long uid, Long loverUid) {
private RelationUser cpRecord(Long uid, Long loverUid, Integer relationType) {
LambdaQueryWrapper<RelationUser> wrapper = Wrappers.lambdaQuery();
wrapper.eq(RelationUser::getUid, uid)
.eq(RelationUser::getLoverUid, loverUid);
.eq(RelationUser::getLoverUid, loverUid)
.eq(RelationUser::getRelationType, relationType);
return getOne(wrapper, false);
}
@@ -434,6 +451,134 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
return BusiResult.success();
}
@Transactional
@Override
public BusiResult nameChange(Long uid, Long loverUid, Integer newRelationNameType) {
RelationUser relationUser = this.cpRecord(uid, loverUid, RelationConstant.RelatinType.CP);
RelationUser loverUser = this.cpRecord(loverUid, uid, RelationConstant.RelatinType.CP);
if (relationUser == null || loverUser == null) {
throw new ServiceException(BusiStatus.SERVERERROR);
}
if (relationUser.getRelationNameType().equals(newRelationNameType) || loverUser.getRelationNameType().equals(newRelationNameType)) {
throw new ServiceException(BusiStatus.SERVERERROR);
}
Integer relationNameType = relationUser.getRelationNameType();
Date now = new Date();
this.validApply(uid, loverUid, relationNameType, newRelationNameType, now);
RelationNameChangeRecord record = relationNameChangeRecordService.addRecord(uid, loverUid, relationUser.getRelationType(), relationNameType, newRelationNameType, now, DateUtil.offsetHour(now, 48));
if (record.getId() == null) {
throw new ServiceException(BusiStatus.SERVERERROR);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("recordId", record.getId());
jsonObject.put("relationNameType", newRelationNameType);
baseSendService.sendMsg(uid.toString(), loverUid, CP, CP_NAME_CHANGE, jsonObject);
return BusiResult.success();
}
@Transactional
@Override
public BusiResult nameChangeAudit(Long uid, Long recordId, Byte status) {
RelationNameChangeRecord nameChangeRecord = relationNameChangeRecordService.getById(recordId);
if (nameChangeRecord == null || !nameChangeRecord.getLoverUid().equals(uid)) {
throw new ServiceException(SERVERBUSY);
}
Date now = new Date();
if (nameChangeRecord.getExpireTime().before(now)) {
throw new ServiceException(CP_NAME_CHANGE_APPLY_EXPIRE);
}
if (nameChangeRecord.getApplyStatus() == RelationConstant.ApplyStatus.AGREE
|| nameChangeRecord.getApplyStatus() == RelationConstant.ApplyStatus.REJECT) {
return BusiResult.success();
}
Long applyUid = nameChangeRecord.getUid();
Long loverUid = nameChangeRecord.getLoverUid();
RelationUser relationUser = this.cpRecord(applyUid, loverUid, RelationConstant.RelatinType.CP);
RelationUser mineUser = this.cpRecord(loverUid, applyUid, RelationConstant.RelatinType.CP);
if (relationUser == null || relationUser.getRelationStatus() == RelationConstant.RelationStatus.CANCEL
|| mineUser.getRelationStatus() == RelationConstant.RelationStatus.CANCEL) {
throw new ServiceException(CP_CANCEL);
}
if (RelationConstant.ApplyStatus.REJECT == status) {
nameChangeRecord.setApplyStatus(RelationConstant.ApplyStatus.REJECT);
nameChangeRecord.setUpdateTime(now);
relationNameChangeRecordService.updateById(nameChangeRecord);
} else if (RelationConstant.ApplyStatus.AGREE == status) {
nameChangeRecord.setApplyStatus(RelationConstant.ApplyStatus.AGREE);
nameChangeRecord.setUpdateTime(now);
relationNameChangeRecordService.updateById(nameChangeRecord);
relationUser.setRelationNameType(nameChangeRecord.getNewRelationNameType());
relationUser.setUpdateTime(now);
mineUser.setRelationNameType(nameChangeRecord.getNewRelationNameType());
mineUser.setUpdateTime(now);
baseMapper.updateById(relationUser);
baseMapper.updateById(mineUser);
}
JSONObject jsonObject = new JSONObject();
Users user = usersService.getUsersByUid(applyUid);
Users loverUser = usersService.getUsersByUid(loverUid);
jsonObject.put("status", status);
jsonObject.put("avatar", user.getAvatar());
jsonObject.put("LoverAvatar", loverUser.getAvatar());
jsonObject.put("relationNameType", nameChangeRecord.getNewRelationNameType());
baseSendService.sendMsg(uid.toString(), applyUid, CP, CP_NAME_CHANGE_AUDIT, jsonObject);
return BusiResult.success();
}
/**
* 申请发送后置灰点击toast您已经提交更换申请请耐心等待
* 申请通过置灰点击toast你需要30天才能更换状态
* 1 双方同时发起申请
* 若A提交申请在B点击变更关系按钮的时候提示用户对方已经发起了关系变更请求
* 2 申请过程中原关系解除对方点击"通过/拒绝"时校验关系是否存在
* 若关系已解除自动终止流程toast关系已解除变更申请自动失效
* 3 关系变更冷却期每次成功变更关系之后需要等待30天之后才能再次更换变更关系
* @param uid
* @param loverUid
* @param relationNameType
* @param newRelationNameType
* @param now
*/
private void validApply(Long uid, Long loverUid, Integer relationNameType, Integer newRelationNameType, Date now) {
RelationNameChangeRecord applyRecord = relationNameChangeRecordService.getApplyRecord(uid, loverUid, relationNameType, newRelationNameType);
if (applyRecord != null) {
throw new ServiceException(CP_NAME_CHANGE_APPLY);
}
applyRecord = relationNameChangeRecordService.getApplyRecord(loverUid, uid, relationNameType, newRelationNameType);
if (applyRecord != null) {
throw new ServiceException(CP_NAME_CHANGE_LOVER_APPLY);
}
RelationNameChangeRecord validRecord = relationNameChangeRecordService.getValidRecord(uid, loverUid);
int beginApplyDays = 30;//每次成功变更关系之后需要等待30天之后才能再次更换变更关系
if (validRecord != null) {
Date beginApplyDate = DateUtil.offsetDay(validRecord.getCreateTime(), beginApplyDays);
if (beginApplyDate.after(now)) {
throw new ServiceException(CP_NAME_CHANGE_EXIST_NOT_EXPIRE);
}
}
validRecord = relationNameChangeRecordService.getValidRecord(loverUid, uid);
if (validRecord != null) {//每次成功变更关系之后需要等待30天之后才能再次更换变更关系
Date beginApplyDate = DateUtil.offsetDay(validRecord.getCreateTime(), beginApplyDays);
if (beginApplyDate.after(now)) {
throw new ServiceException(CP_NAME_CHANGE_EXIST_NOT_EXPIRE);
}
}
}
@Override
public RelationUserVO getOneCP(Long uid) {
List<RelationUserVO> cpList = this.getCPList(uid, 1, 1);

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.accompany.business.mybatismapper.relation.RelationNameChangeRecordMapper">
</mapper>

View File

@@ -80,7 +80,7 @@ public class GiftV2Controller extends BaseController {
String msg,
Integer giftSource) {
Long uid = getUid();
logger.info("sendV5 param==>>> uid:{},targetUids:{},roomUid:{},giftId:{},giftNum:{},sendType:{},giftSource:{}",
logger.info("sendV5 param==>>> uid:43883{},targetUids:{},roomUid:{},giftId:{},giftNum:{},sendType:{},giftSource:{}",
uid, targetUids, roomUid, giftId, giftNum, sendType, giftSource);
if (giftNum <= 0 || targetUids == null || targetUids.length < 1) {
return BusiResult.fail(BusiStatus.PARAMETERILLEGAL);

View File

@@ -39,6 +39,16 @@ public class RelationController {
return relationUserService.cancelCp(uid, loverUid, goldNum);
}
@PostMapping("/nameChange")
public BusiResult nameChange(@RequestParam Long uid, @RequestParam Long loverUid, Integer relationNameType) {
return relationUserService.nameChange(uid, loverUid, relationNameType);
}
@PostMapping("/nameChangeAudit")
public BusiResult nameChangeAudit(Long recordId, @RequestHeader(PUB_UID) Long uid, Byte status) {
return relationUserService.nameChangeAudit(uid, recordId, status);
}
@PostMapping("/calCpInfo")
public void calCpInfo(@RequestBody GiftMessage giftMessage) {
relationUserService.calCpInfo(giftMessage);