新增家族成员总榜接口
This commit is contained in:
parent
72e94d5991
commit
085f9aeba9
@ -29,6 +29,7 @@ import com.red.circle.other.infra.database.rds.service.family.FamilyLevelExpServ
|
||||
import com.red.circle.other.infra.database.rds.service.family.FamilyMemberInfoService;
|
||||
import com.red.circle.other.infra.database.rds.service.family.FamilyMemberWeekExpService;
|
||||
import com.red.circle.other.infra.database.rds.service.family.FamilyMonthExpService;
|
||||
import com.red.circle.other.infra.database.rds.service.family.FamilyMemberTotalExpService;
|
||||
import com.red.circle.other.infra.database.rds.service.family.FamilyWeekExpService;
|
||||
import com.red.circle.other.infra.database.rds.service.gift.GiftConfigService;
|
||||
import com.red.circle.other.infra.database.rds.service.props.PropsBackpackService;
|
||||
@ -86,6 +87,7 @@ public class FamilyCommon {
|
||||
private final FamilyLevelConfigService familyLevelConfigService;
|
||||
private final BadgePictureConfigService badgePictureConfigService;
|
||||
private final FamilyMemberWeekExpService familyMemberWeekExpService;
|
||||
private final FamilyMemberTotalExpService familyMemberTotalExpService;
|
||||
private final RedisService redisService;
|
||||
|
||||
|
||||
@ -415,16 +417,15 @@ public class FamilyCommon {
|
||||
}
|
||||
|
||||
/**
|
||||
* 累加经验值(家族月榜,家族周榜,家族成员周经验值)
|
||||
* 累加经验值(家族成员总榜、家族周榜、家族成员周经验值)
|
||||
*
|
||||
* @param member 成员
|
||||
* @param exp 经验值
|
||||
*/
|
||||
private void expAccumulate(FamilyMemberInfo member, Long exp, String regionId) {
|
||||
familyMemberTotalExpService.incrMemberTotalExp(member.getSysOrigin(), member.getFamilyId(), member.getMemberUserId(), exp);
|
||||
familyWeekExpService.incrThisWeekExp(member.getSysOrigin(), member.getFamilyId(), regionId, exp);
|
||||
familyMemberWeekExpService.incrExp(member.getSysOrigin(), member.getFamilyId(),member.getMemberUserId(), exp);
|
||||
|
||||
// familyMonthExpService.incrThisMonthExp(member.getSysOrigin(), member.getFamilyId(), regionId, exp);
|
||||
familyMemberWeekExpService.incrExp(member.getSysOrigin(), member.getFamilyId(), member.getMemberUserId(), exp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.red.circle.other.infra.database.rds.dao.family;
|
||||
|
||||
import com.red.circle.framework.mybatis.dao.BaseDAO;
|
||||
import com.red.circle.other.infra.database.rds.entity.family.FamilyMemberTotalExp;
|
||||
|
||||
/**
|
||||
* 家族成员总榜 DAO
|
||||
*/
|
||||
public interface FamilyMemberTotalExpDAO extends BaseDAO<FamilyMemberTotalExp> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.red.circle.other.infra.database.rds.entity.family;
|
||||
|
||||
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 com.red.circle.framework.mybatis.entity.TimestampBaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 家族成员总榜
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("family_member_total_exp")
|
||||
public class FamilyMemberTotalExp extends TimestampBaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键标识
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 来源系统
|
||||
*/
|
||||
@TableField("sys_origin")
|
||||
private String sysOrigin;
|
||||
|
||||
/**
|
||||
* 家族ID
|
||||
*/
|
||||
@TableField("family_id")
|
||||
private Long familyId;
|
||||
|
||||
/**
|
||||
* 家族成员用户ID
|
||||
*/
|
||||
@TableField("family_member_id")
|
||||
private Long familyMemberId;
|
||||
|
||||
/**
|
||||
* 家族成员总贡献值
|
||||
*/
|
||||
@TableField("exp")
|
||||
private Long exp;
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.red.circle.other.infra.database.rds.service.family;
|
||||
|
||||
import com.red.circle.framework.mybatis.service.BaseService;
|
||||
import com.red.circle.other.infra.database.rds.entity.family.FamilyMemberTotalExp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 家族成员总榜 服务类
|
||||
*/
|
||||
public interface FamilyMemberTotalExpService extends BaseService<FamilyMemberTotalExp> {
|
||||
|
||||
/**
|
||||
* 添加成员总榜经验
|
||||
*/
|
||||
void incrMemberTotalExp(String sysOrigin, Long familyId, Long memberId, Long exp);
|
||||
|
||||
/**
|
||||
* 查询家族成员总榜经验
|
||||
*/
|
||||
List<FamilyMemberTotalExp> listMemberTotalByFamilyId(Long familyId);
|
||||
|
||||
/**
|
||||
* 获取成员总榜经验
|
||||
*/
|
||||
FamilyMemberTotalExp getMemberTotalExp(Long familyId, Long memberId);
|
||||
|
||||
/**
|
||||
* 删除家族成员总榜数据
|
||||
*/
|
||||
void deleteByFamilyId(Long familyId);
|
||||
|
||||
/**
|
||||
* 删除成员总榜数据
|
||||
*/
|
||||
void deleteByMemberId(Long familyId, Long memberId);
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
package com.red.circle.other.infra.database.rds.service.family.impl;
|
||||
|
||||
import com.red.circle.framework.mybatis.constant.PageConstant;
|
||||
import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import com.red.circle.other.infra.database.rds.dao.family.FamilyMemberTotalExpDAO;
|
||||
import com.red.circle.other.infra.database.rds.entity.family.FamilyMemberTotalExp;
|
||||
import com.red.circle.other.infra.database.rds.service.family.FamilyMemberTotalExpService;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.text.StringUtils;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 家族成员总榜 服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class FamilyMemberTotalExpServiceImpl extends
|
||||
BaseServiceImpl<FamilyMemberTotalExpDAO, FamilyMemberTotalExp> implements FamilyMemberTotalExpService {
|
||||
|
||||
@Override
|
||||
public void incrMemberTotalExp(String sysOrigin, Long familyId, Long memberId, Long exp) {
|
||||
if (StringUtils.isBlank(sysOrigin) || Objects.isNull(familyId) || Objects.isNull(memberId) || exp <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
FamilyMemberTotalExp existsMember = query()
|
||||
.select(FamilyMemberTotalExp::getId)
|
||||
.eq(FamilyMemberTotalExp::getFamilyId, familyId)
|
||||
.eq(FamilyMemberTotalExp::getFamilyMemberId, memberId)
|
||||
.eq(FamilyMemberTotalExp::getSysOrigin, sysOrigin)
|
||||
.last(PageConstant.LIMIT_ONE)
|
||||
.getOne();
|
||||
|
||||
if (Objects.isNull(existsMember) || Objects.isNull(existsMember.getId())) {
|
||||
try {
|
||||
super.save(new FamilyMemberTotalExp()
|
||||
.setSysOrigin(sysOrigin)
|
||||
.setFamilyId(familyId)
|
||||
.setFamilyMemberId(memberId)
|
||||
.setExp(exp)
|
||||
);
|
||||
} catch (Exception e) {
|
||||
update()
|
||||
.setSql("exp=exp+" + exp)
|
||||
.eq(FamilyMemberTotalExp::getFamilyId, familyId)
|
||||
.eq(FamilyMemberTotalExp::getFamilyMemberId, memberId)
|
||||
.eq(FamilyMemberTotalExp::getSysOrigin, sysOrigin)
|
||||
.execute();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
update()
|
||||
.setSql("exp=exp+" + exp)
|
||||
.eq(FamilyMemberTotalExp::getId, existsMember.getId())
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FamilyMemberTotalExp> listMemberTotalByFamilyId(Long familyId) {
|
||||
return Optional.ofNullable(
|
||||
query()
|
||||
.eq(FamilyMemberTotalExp::getFamilyId, familyId)
|
||||
.orderByDesc(FamilyMemberTotalExp::getExp)
|
||||
.list())
|
||||
.orElse(CollectionUtils.newArrayList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public FamilyMemberTotalExp getMemberTotalExp(Long familyId, Long memberId) {
|
||||
return query()
|
||||
.eq(FamilyMemberTotalExp::getFamilyId, familyId)
|
||||
.eq(FamilyMemberTotalExp::getFamilyMemberId, memberId)
|
||||
.last(PageConstant.LIMIT_ONE)
|
||||
.getOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByFamilyId(Long familyId) {
|
||||
if (Objects.isNull(familyId)) {
|
||||
return;
|
||||
}
|
||||
delete().eq(FamilyMemberTotalExp::getFamilyId, familyId).execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByMemberId(Long familyId, Long memberId) {
|
||||
if (Objects.isNull(familyId) || Objects.isNull(memberId)) {
|
||||
return;
|
||||
}
|
||||
delete()
|
||||
.eq(FamilyMemberTotalExp::getFamilyId, familyId)
|
||||
.eq(FamilyMemberTotalExp::getFamilyMemberId, memberId)
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
@ -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.red.circle.other.infra.database.rds.dao.family.FamilyMemberTotalExpDAO">
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user