cp多用户及心动值改造
This commit is contained in:
parent
f2e5087b22
commit
bbc48bb206
@ -119,7 +119,7 @@ public interface UserCpClientApi {
|
||||
@RequestParam("userIdTwo") Long userIdTwo);
|
||||
|
||||
@GetMapping("/getCpUserId")
|
||||
ResultResponse<Long> getCpUserId(@RequestParam("userId") Long userId);
|
||||
ResultResponse<List<Long>> getCpUserId(@RequestParam("userId") Long userId);
|
||||
|
||||
@GetMapping("/listLatestCp")
|
||||
ResultResponse<List<CpRelationshipDTO>> listLatestCp(@RequestParam("sysOrigin") String sysOrigin,
|
||||
|
||||
@ -20,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户cp关系 前端控制器.
|
||||
@ -38,27 +40,6 @@ public class CpRelationshipRestController extends BaseController {
|
||||
|
||||
private final UserCpRelationService userCpRelationService;
|
||||
|
||||
/**
|
||||
* 获取cp对象.
|
||||
*
|
||||
* @eo.name 获取cp对象.
|
||||
* @eo.url /
|
||||
* @eo.method get
|
||||
* @eo.request-type formdata
|
||||
*/
|
||||
@GetMapping
|
||||
public CpUserProfileCO getCpUser(@Validated UserIdCmd cmd) {
|
||||
return userCpRelationService.getCpUser(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cp对象V4.
|
||||
*/
|
||||
@GetMapping("/v4")
|
||||
public CpCabinUserProfileCO getCpUserV4(@Validated UserIdCommonCmd cmd) {
|
||||
return userCpRelationService.getCpUserV4(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的-cp对象.
|
||||
*
|
||||
@ -68,7 +49,7 @@ public class CpRelationshipRestController extends BaseController {
|
||||
* @eo.request-type formdata
|
||||
*/
|
||||
@GetMapping("/pair")
|
||||
public CpPairUserProfileCO getCpPairUserProfileCO(AppExtCommand cmd) {
|
||||
public List<CpPairUserProfileCO> getCpPairUserProfileCO(AppExtCommand cmd) {
|
||||
return userCpRelationService.getCpPairUserProfileCO(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -115,12 +115,13 @@ public class WeekCpUserGiftQueryExe {
|
||||
|
||||
private ActivityCpUserRankingCO getThisUser(AppExtCommand cmd) {
|
||||
|
||||
Long cpUserId = cpRelationshipService.getCpUserId(cmd.getReqUserId());
|
||||
if (Objects.isNull(cpUserId)) {
|
||||
List<Long> cpUserIdList = cpRelationshipService.getCpUserId(cmd.getReqUserId());
|
||||
if (cpUserIdList.isEmpty()) {
|
||||
return new ActivityCpUserRankingCO();
|
||||
}
|
||||
|
||||
WeekCpValueCount thisUser = weekCpValueCountService.getUserThisWeekCount(
|
||||
Long cpUserId = cpUserIdList.get(0);
|
||||
WeekCpValueCount thisUser = weekCpValueCountService.getUserThisWeekCount(
|
||||
cmd.getReqSysOrigin().getOrigin(),
|
||||
cmd.getReqUserId(), cpUserId);
|
||||
if (Objects.isNull(thisUser)) {
|
||||
|
||||
@ -71,7 +71,7 @@ public class BlessingsGiftGiveCmdExe {
|
||||
|
||||
// 接受人必须是CP
|
||||
ResponseAssert.isTrue(UserErrorEnum.NOT_CP_ERROR,
|
||||
cpRelationshipService.existsCp(cmd.getAccepts().get(0).getAcceptUserId()));
|
||||
cpRelationshipService.existsCp(cmd.getReqUserId(), cmd.getAccepts().get(0).getAcceptUserId()));
|
||||
|
||||
// 付钱
|
||||
WalletReceiptResDTO receipt = consumeCandy(cmd, giftConfig);
|
||||
|
||||
@ -4,6 +4,7 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
|
||||
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
||||
import com.red.circle.other.infra.database.rds.service.user.user.CpValueService;
|
||||
import com.red.circle.tool.core.date.DateUtils;
|
||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpPairUserProfileCO;
|
||||
@ -15,6 +16,8 @@ import com.red.circle.other.inner.asserts.user.UserErrorCode;
|
||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.red.circle.tool.core.date.LocalDateTimeUtils;
|
||||
@ -33,25 +36,31 @@ public class UserCpPairUserProfileQryExe {
|
||||
private final CpRelationshipService cpRelationshipService;
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||
private final CpValueService cpValueService;
|
||||
private final TaskMqMessage taskMqMessage;
|
||||
|
||||
public CpPairUserProfileCO execute(AppExtCommand cmd) {
|
||||
public List<CpPairUserProfileCO> execute(AppExtCommand cmd) {
|
||||
|
||||
UserProfile meUser = userProfileGateway.getByUserId(cmd.requiredReqUserId());
|
||||
ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, meUser);
|
||||
|
||||
CpRelationship cpRelationship = cpRelationshipService.getByUserId(cmd.requiredReqUserId());
|
||||
if (Objects.isNull(cpRelationship)) {
|
||||
return new CpPairUserProfileCO()
|
||||
.setMeUserProfile(userProfileAppConvertor.toUserProfileDTO((meUser)));
|
||||
List<CpRelationship> cpRelationshipList = cpRelationshipService.getByUserId(cmd.requiredReqUserId());
|
||||
if (cpRelationshipList.isEmpty()) {
|
||||
return List.of(
|
||||
new CpPairUserProfileCO()
|
||||
.setMeUserProfile(userProfileAppConvertor.toUserProfileDTO((meUser)))
|
||||
);
|
||||
}
|
||||
|
||||
return new CpPairUserProfileCO()
|
||||
.setMeUserProfile(userProfileAppConvertor.toUserProfileDTO((meUser)))
|
||||
.setCpUserProfile(getUserProfile(cpRelationship.getCpUserId()))
|
||||
.setDays(DateUtils.toDurationDays(cpRelationship.getCreateTime(), DateUtils.now()))
|
||||
.setFirstDay(cpRelationship.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().toString())
|
||||
;
|
||||
return cpRelationshipList.stream()
|
||||
.map(cpRelationship -> new CpPairUserProfileCO()
|
||||
.setMeUserProfile(userProfileAppConvertor.toUserProfileDTO((meUser)))
|
||||
.setCpUserProfile(getUserProfile(cpRelationship.getCpUserId()))
|
||||
.setCpValue(cpValueService.getCpVal(cpRelationship.getCpValId()))
|
||||
.setDays(DateUtils.toDurationDays(cpRelationship.getCreateTime(), DateUtils.now()))
|
||||
.setFirstDay(cpRelationship.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().toString()))
|
||||
.sorted(Comparator.comparing(CpPairUserProfileCO::getCpValue).reversed())
|
||||
.toList();
|
||||
}
|
||||
|
||||
private UserProfileDTO getUserProfile(Long cpUserId) {
|
||||
|
||||
@ -34,12 +34,11 @@ public class UserCpRelationQryExe {
|
||||
private final UserCpValueCacheService userCpValueCacheService;
|
||||
|
||||
public CpUserProfileCO execute(UserIdCmd cmd) {
|
||||
return Optional.ofNullable(cpRelationshipService.getByUserId(cmd.getUserId()))
|
||||
return Optional.ofNullable(cpRelationshipService.getByUserId(cmd.getReqUserId(), cmd.getUserId()))
|
||||
.map(cpRelationship -> new CpUserProfileCO()
|
||||
.setUserProfile(getUserProfile(cpRelationship.getCpUserId()))
|
||||
.setDays(DateUtils.toDurationDays(cpRelationship.getCreateTime(), DateUtils.now()))
|
||||
.setFirstDay(cpRelationship.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().toString())
|
||||
// .setLevel(getLevel(cpRelationship.getUserId(), cpRelationship.getCpUserId()))
|
||||
)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public class UserCpRelationQueryV4Exe {
|
||||
|
||||
public CpCabinUserProfileCO execute(UserIdCommonCmd cmd) {
|
||||
|
||||
CpRelationship cpRelationship = cpRelationshipService.getByUserId(cmd.getUserId());
|
||||
CpRelationship cpRelationship = cpRelationshipService.getByUserId(cmd.getReqUserId(), cmd.getUserId());
|
||||
if (Objects.isNull(cpRelationship)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -474,14 +474,7 @@ public class GiveGiftsListener implements MessageListener {
|
||||
|
||||
private List<GiftAcceptUser> getRegionGiftAcceptUser(GiveAwayGiftBatchEvent event,
|
||||
List<Long> anchorUserIds, GiftValue giftValue) {
|
||||
//如果系统为朝拜则需要处理代理分成,取消代理分成
|
||||
if (event.getSysOrigin().name().equals("YOLO")) {
|
||||
return getRegionGiftAcceptUserRestsYolo(event, anchorUserIds, giftValue);
|
||||
} else if (event.getSysOrigin().name().equals(SysOriginPlatformEnum.TWO_FUN.getSysOrigin())||event.getSysOrigin().name().equals(SysOriginPlatformEnum.TARAB.getSysOrigin())) {
|
||||
return getRegionGiftAcceptUserRestsTwoFun(event, anchorUserIds, giftValue);
|
||||
} else {
|
||||
return getRegionGiftAcceptUserRests(event, anchorUserIds, giftValue);
|
||||
}
|
||||
return getRegionGiftAcceptUserRests(event, anchorUserIds, giftValue);
|
||||
}
|
||||
|
||||
|
||||
@ -489,7 +482,7 @@ public class GiveGiftsListener implements MessageListener {
|
||||
* 分区.
|
||||
*/
|
||||
private List<GiftAcceptUser> getRegionGiftAcceptUserRests(GiveAwayGiftBatchEvent event,
|
||||
List<Long> anchorUserIds, GiftValue giftValue) {
|
||||
List<Long> anchorUserIds, GiftValue giftValue) {
|
||||
|
||||
log.info("getRegionGiftAcceptUserRests: {} anchorUserIds:{} giftValue:{}", JSON.toJSONString(event), anchorUserIds, JSON.toJSONString(giftValue));
|
||||
|
||||
@ -497,12 +490,12 @@ public class GiveGiftsListener implements MessageListener {
|
||||
RegionConfig sendRegion = getUserRegion(event.getSendUserId());
|
||||
|
||||
// 幸运礼物比例
|
||||
BigDecimal luckyGiftRatio = gameLuckyGiftCommon.getLuckyGiftTargetRatio(
|
||||
event.getSysOrigin().name());
|
||||
BigDecimal luckyGiftRatio = gameLuckyGiftCommon.getLuckyGiftTargetRatio(event.getSysOrigin().name());
|
||||
|
||||
// 赠送礼物给自己返还金币比例
|
||||
BigDecimal sendAssistRatio =
|
||||
event.checkLuckyGift() ? luckyGiftRatio : getAssistGiftToOwnGoldRatio(sendRegion.getId());
|
||||
BigDecimal sendAssistRatio = event.checkLuckyGift()
|
||||
? luckyGiftRatio
|
||||
: getAssistGiftToOwnGoldRatio(sendRegion.getId());
|
||||
|
||||
Map<Long, TeamMember> teamMemberMap = teamMemberService.mapByMemberIds(anchorUserIds);
|
||||
|
||||
@ -510,208 +503,40 @@ public class GiveGiftsListener implements MessageListener {
|
||||
|
||||
// 接受人区域与金币比例
|
||||
RegionConfig acceptRegion = getUserRegion(accept.getAcceptUserId());
|
||||
|
||||
// 检查是否为冲突区域
|
||||
Boolean isConflicts = !Objects.equals(
|
||||
userRegionGateway.checkBusinessRegionCode(sendRegion.getRegionCode(), acceptRegion.getRegionCode()),
|
||||
Boolean.TRUE
|
||||
);
|
||||
|
||||
// 初始化接收金额和目标金额
|
||||
BigDecimal acceptAmount = BigDecimal.ZERO;
|
||||
BigDecimal targetAmount = BigDecimal.ZERO;
|
||||
BigDecimal acceptAssistRatio = BigDecimal.ZERO;
|
||||
|
||||
// 接收金额
|
||||
BigDecimal acceptAmount = BigDecimal.ZERO;
|
||||
// 接收目标
|
||||
BigDecimal targetAmount = BigDecimal.ZERO;
|
||||
|
||||
// 不是冲突区域则不清零目标
|
||||
Boolean isConflicts = !Objects.equals(
|
||||
userRegionGateway.checkBusinessRegionCode(sendRegion.getRegionCode(),
|
||||
acceptRegion.getRegionCode()), Boolean.TRUE);
|
||||
if (Boolean.FALSE.equals(isConflicts)) {
|
||||
|
||||
// 幸运礼物 不计算金额,GiftPrizeAcceptStrategy不发送
|
||||
// 非冲突区域才计算金额
|
||||
if (!isConflicts) {
|
||||
if (event.checkLuckyGift()) {
|
||||
|
||||
// 幸运礼物目标 = 礼物价值 * 比例
|
||||
// 幸运礼物
|
||||
acceptAssistRatio = luckyGiftRatio;
|
||||
targetAmount = giftValue.getGiftValue().multiply(luckyGiftRatio).setScale(0, RoundingMode.DOWN);
|
||||
acceptAmount = targetAmount;
|
||||
|
||||
// 赠送礼物给别人返还金币比例
|
||||
acceptAssistRatio = luckyGiftRatio;
|
||||
|
||||
}
|
||||
|
||||
if (!event.checkLuckyGift()) {
|
||||
// 赠送礼物给别人返还金币比例
|
||||
acceptAssistRatio = getAssistGiftToOtherGoldRatio(acceptRegion.getId());
|
||||
|
||||
// 发送人是普通用户
|
||||
BigDecimal sendAssistRatioNormal = null;
|
||||
if (userRegionGateway.isOrdinaryUser(event.getSendUserId())) {
|
||||
acceptAssistRatio = getAssistGiftToOtherGoldRatioNormal(acceptRegion.getId());
|
||||
sendAssistRatioNormal = getAssistGiftToOwnGoldRatioNormal(acceptRegion.getId());
|
||||
|
||||
}
|
||||
|
||||
// 普通礼物,接受人可获得金额
|
||||
acceptAmount = enumConfigCacheService.giftGoldRatioFormula(Objects.equals(event.getSendUserId(), accept.getAcceptUserId())
|
||||
? (sendAssistRatioNormal != null ? sendAssistRatioNormal : sendAssistRatio)
|
||||
: acceptAssistRatio, giftValue.getGiftValue());
|
||||
|
||||
BigDecimal assistGiftTargetRatio = getAssistGiftTargetRatio(acceptRegion.getId());
|
||||
|
||||
// 普通礼物,接受人可获得目标
|
||||
targetAmount = giftValue.getGiftValue().multiply(assistGiftTargetRatio).setScale(0, RoundingMode.DOWN);;
|
||||
}
|
||||
}
|
||||
// 获得主播的账单ID.
|
||||
Boolean isAnchor = anchorUserIds.contains(accept.getAcceptUserId());
|
||||
return new GiftAcceptUser()
|
||||
.setAcceptUserId(accept.getAcceptUserId())
|
||||
.setAnchor(isAnchor)
|
||||
.setReceiptId(0L)
|
||||
.setRegionIdStr(sendRegion.getId() + "-" + acceptRegion.getId())
|
||||
.setRegion(sendRegion.getRegionName() + "-" + acceptRegion.getRegionName())
|
||||
.setRegionEq(Objects.equals(sendRegion.getId(), acceptRegion.getId()))
|
||||
.setAcceptAmount(acceptAmount)
|
||||
.setTargetAmount(targetAmount)
|
||||
.setPercentage(acceptAssistRatio)
|
||||
.setSelfPercentage(Boolean.TRUE.equals(isConflicts) ? BigDecimal.ZERO : sendAssistRatio)
|
||||
.setCountTargetAmount(Boolean.FALSE)
|
||||
.setCountBillId(getTeamBillId(teamMemberMap.get(accept.getAcceptUserId()), isAnchor))
|
||||
.setSeatIndex(accept.getSeatIndex());
|
||||
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
private List<GiftAcceptUser> getRegionGiftAcceptUserRestsYolo(GiveAwayGiftBatchEvent event,
|
||||
List<Long> anchorUserIds, GiftValue giftValue) {
|
||||
|
||||
// 发送人区域与金币比例
|
||||
RegionConfig sendRegion = getUserRegion(event.getSendUserId());
|
||||
|
||||
BigDecimal sendGifts = getAssistGiftToOwnGoldRatio(sendRegion.getId());
|
||||
|
||||
// 幸运礼物比例
|
||||
BigDecimal luckyGiftRatio = sendGifts.multiply(BigDecimal.valueOf(0.1));
|
||||
|
||||
// 赠送礼物给自己返还金币比例
|
||||
BigDecimal sendAssistRatio =
|
||||
event.checkLuckyGift() ? luckyGiftRatio : sendGifts;
|
||||
|
||||
Map<Long, TeamMember> teamMemberMap = teamMemberService.mapByMemberIds(anchorUserIds);
|
||||
|
||||
return event.getAccepts().stream().map(accept -> {
|
||||
|
||||
// 接受人区域与金币比例
|
||||
RegionConfig acceptRegion = getUserRegion(accept.getAcceptUserId());
|
||||
|
||||
BigDecimal acceptAssistRatio =
|
||||
event.checkLuckyGift() ?
|
||||
getAssistGiftToOtherGoldRatio(acceptRegion.getId()).multiply(BigDecimal.valueOf(0.1)) : getAssistGiftToOtherGoldRatio(acceptRegion.getId());
|
||||
// 接收金额
|
||||
BigDecimal acceptAmount = BigDecimal.ZERO;
|
||||
// 接收目标
|
||||
BigDecimal targetAmount = BigDecimal.ZERO;
|
||||
|
||||
// 不是冲突区域则不清零目标
|
||||
Boolean isConflicts = !Objects.equals(
|
||||
userRegionGateway.checkBusinessRegionCode(sendRegion.getRegionCode(),
|
||||
acceptRegion.getRegionCode()), Boolean.TRUE);
|
||||
if (Boolean.FALSE.equals(isConflicts)) {
|
||||
|
||||
// 普通礼物,接受人可获得金额
|
||||
acceptAmount = enumConfigCacheService.giftGoldRatioFormula(
|
||||
Objects.equals(event.getSendUserId(), accept.getAcceptUserId())
|
||||
? sendAssistRatio : acceptAssistRatio, giftValue.getGiftValue());
|
||||
|
||||
// 普通礼物,接受人可获得目标
|
||||
targetAmount = giftValue.getGiftValue();
|
||||
|
||||
}
|
||||
// 获得主播的账单ID.
|
||||
Boolean isAnchor = anchorUserIds.contains(accept.getAcceptUserId());
|
||||
return new GiftAcceptUser()
|
||||
.setAcceptUserId(accept.getAcceptUserId())
|
||||
.setAnchor(isAnchor)
|
||||
.setReceiptId(0L)
|
||||
.setRegionIdStr(sendRegion.getId() + "-" + acceptRegion.getId())
|
||||
.setRegion(sendRegion.getRegionName() + "-" + acceptRegion.getRegionName())
|
||||
.setRegionEq(Objects.equals(sendRegion.getId(), acceptRegion.getId()))
|
||||
.setAcceptAmount(acceptAmount)
|
||||
.setTargetAmount(targetAmount)
|
||||
.setPercentage(acceptAssistRatio)
|
||||
.setSelfPercentage(Boolean.TRUE.equals(isConflicts) ? BigDecimal.ZERO : sendAssistRatio)
|
||||
.setCountTargetAmount(Boolean.FALSE)
|
||||
.setCountBillId(getTeamBillId(teamMemberMap.get(accept.getAcceptUserId()), isAnchor))
|
||||
.setSeatIndex(accept.getSeatIndex());
|
||||
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 【TWO_FUN钻石政策】需求:主播代理,收礼不返回金币.
|
||||
*/
|
||||
private List<GiftAcceptUser> getRegionGiftAcceptUserRestsTwoFun(GiveAwayGiftBatchEvent event,
|
||||
List<Long> anchorUserIds, GiftValue giftValue) {
|
||||
|
||||
// 发送人区域与金币比例
|
||||
RegionConfig sendRegion = getUserRegion(event.getSendUserId());
|
||||
TeamPolicyManager teamPolicyManager = teamPolicyManagerService.getReleaseByRegionAndType(sendRegion.getSysOrigin(), sendRegion.getId(), TeamPolicyTypeEnum.SALARY_DIAMOND.name());
|
||||
|
||||
// 幸运礼物比例
|
||||
BigDecimal luckyGiftRatio = gameLuckyGiftCommon.getLuckyGiftTargetRatio(
|
||||
event.getSysOrigin().name());
|
||||
|
||||
// 赠送礼物给自己返还金币比例
|
||||
BigDecimal sendAssistRatio =
|
||||
event.checkLuckyGift() ? luckyGiftRatio : getAssistGiftToOwnGoldRatio(sendRegion.getId());
|
||||
|
||||
Map<Long, TeamMember> teamMemberMap = teamMemberService.mapByMemberIds(anchorUserIds);
|
||||
|
||||
return event.getAccepts().stream().map(accept -> {
|
||||
|
||||
// 接受人区域与金币比例
|
||||
RegionConfig acceptRegion = getUserRegion(accept.getAcceptUserId());
|
||||
BigDecimal acceptAssistRatio = BigDecimal.ZERO;
|
||||
|
||||
// 接收金额
|
||||
BigDecimal acceptAmount = BigDecimal.ZERO;
|
||||
// 接收目标
|
||||
BigDecimal targetAmount = BigDecimal.ZERO;
|
||||
|
||||
// 不是冲突区域则不清零目标
|
||||
Boolean isConflicts = !Objects.equals(
|
||||
userRegionGateway.checkBusinessRegionCode(sendRegion.getRegionCode(),
|
||||
acceptRegion.getRegionCode()), Boolean.TRUE);
|
||||
if (Boolean.FALSE.equals(isConflicts)) {
|
||||
|
||||
// 幸运礼物
|
||||
if (event.checkLuckyGift()) {
|
||||
|
||||
// 幸运礼物目标 = 礼物价值 * 比例
|
||||
targetAmount = giftValue.getGiftValue().multiply(luckyGiftRatio)
|
||||
.setScale(0, RoundingMode.DOWN);
|
||||
acceptAmount = targetAmount;
|
||||
|
||||
// 赠送礼物给别人返还金币比例
|
||||
acceptAssistRatio = luckyGiftRatio;
|
||||
|
||||
} else {
|
||||
// 普通礼物
|
||||
acceptAssistRatio = calculateAcceptAssistRatio(event, acceptRegion);
|
||||
BigDecimal effectiveSendRatio = calculateEffectiveSendRatio(event, sendRegion, sendAssistRatio, acceptRegion, accept);
|
||||
|
||||
// 赠送礼物给别人返还金币比例
|
||||
acceptAssistRatio = getAssistGiftToOtherGoldRatio(acceptRegion.getId());
|
||||
|
||||
// 普通礼物,接受人可获得金额
|
||||
acceptAmount = enumConfigCacheService.giftGoldRatioFormula(
|
||||
Objects.equals(event.getSendUserId(), accept.getAcceptUserId())
|
||||
? sendAssistRatio : acceptAssistRatio, giftValue.getGiftValue());
|
||||
|
||||
// 普通礼物,接受人可获得目标
|
||||
targetAmount = giftValue.getGiftValue();
|
||||
acceptAmount = enumConfigCacheService.giftGoldRatioFormula(effectiveSendRatio, giftValue.getGiftValue());
|
||||
targetAmount = giftValue.getGiftValue()
|
||||
.multiply(getAssistGiftTargetRatio(acceptRegion.getId()))
|
||||
.setScale(0, RoundingMode.DOWN);
|
||||
}
|
||||
}
|
||||
// 获得主播的账单ID.
|
||||
|
||||
// 获得主播的账单ID
|
||||
Boolean isAnchor = anchorUserIds.contains(accept.getAcceptUserId());
|
||||
if(isAnchor && Objects.nonNull(teamPolicyManager)) {
|
||||
log.warn("地区有钻石政策主播不分金币:" + teamPolicyManager);
|
||||
acceptAmount = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
return new GiftAcceptUser()
|
||||
.setAcceptUserId(accept.getAcceptUserId())
|
||||
.setAnchor(isAnchor)
|
||||
@ -731,21 +556,30 @@ public class GiveGiftsListener implements MessageListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 朝拜礼物配比处理
|
||||
*
|
||||
* @param event
|
||||
* @param anchorUserIds
|
||||
* @param giftValue
|
||||
* @return
|
||||
* 计算接收方助力比例.
|
||||
*/
|
||||
private List<GiftAcceptUser> getRegionGiftAcceptUserYolo(GiveAwayGiftBatchEvent event,
|
||||
List<Long> anchorUserIds, GiftValue giftValue) {
|
||||
List<GiftAcceptUser> giftAcceptUsers = getRegionGiftAcceptUserRestsYolo(event, anchorUserIds, giftValue);
|
||||
if (CollectionUtils.isNotEmpty(giftAcceptUsers) && giftAcceptUsers.get(0).getAnchor()) {
|
||||
giftAcceptUsers.addAll(getProxyGiftCalculation(event, anchorUserIds, giftValue));
|
||||
private BigDecimal calculateAcceptAssistRatio(GiveAwayGiftBatchEvent event, RegionConfig acceptRegion) {
|
||||
if (userRegionGateway.isOrdinaryUser(event.getSendUserId())) {
|
||||
return getAssistGiftToOtherGoldRatioNormal(acceptRegion.getId());
|
||||
}
|
||||
return giftAcceptUsers;
|
||||
return getAssistGiftToOtherGoldRatio(acceptRegion.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算有效发送比例.
|
||||
*/
|
||||
private BigDecimal calculateEffectiveSendRatio(GiveAwayGiftBatchEvent event, RegionConfig sendRegion,
|
||||
BigDecimal sendAssistRatio, RegionConfig acceptRegion,
|
||||
GiveAwayGiftRoomAccepts accept) {
|
||||
// 送给自己
|
||||
if (Objects.equals(event.getSendUserId(), accept.getAcceptUserId())) {
|
||||
if (userRegionGateway.isOrdinaryUser(event.getSendUserId())) {
|
||||
return getAssistGiftToOwnGoldRatioNormal(sendRegion.getId());
|
||||
}
|
||||
return sendAssistRatio;
|
||||
}
|
||||
// 送给别人
|
||||
return calculateAcceptAssistRatio(event, acceptRegion);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -326,9 +326,8 @@ public class GiftCountStrategy implements GiftStrategy {
|
||||
return;
|
||||
}
|
||||
|
||||
CpRelationship cpRelationship = cpRelationshipService.getByUserId(
|
||||
runningWater.getAcceptUsers().get(0).getAcceptUserId());
|
||||
//log.warn("cpRelationship:{}", cpRelationship);
|
||||
CpRelationship cpRelationship = cpRelationshipService.getByUserId(runningWater.getUserId(),
|
||||
runningWater.getAcceptUsers().get(0).getAcceptUserId());
|
||||
if (Objects.isNull(cpRelationship)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -315,52 +315,50 @@ public class RankCountStrategy implements GiftStrategy {
|
||||
}
|
||||
|
||||
private void countCpValue(GiftGiveRunningWater runningWater) {
|
||||
log.warn("cptesttest runningWater:{}", JacksonUtils.toJson(runningWater));
|
||||
CpRelationship cpRelationship = cpRelationshipService.getByUserId(
|
||||
runningWater.getUserId());
|
||||
log.warn("cptesttest countCpValue1:{}", JacksonUtils.toJson(cpRelationship));
|
||||
if (Objects.isNull(cpRelationship)) {
|
||||
return;
|
||||
}
|
||||
CpRelationship relationship = cpRelationshipService.getByUserId(
|
||||
cpRelationship.getCpUserId());
|
||||
log.warn("cptesttest countCpValue2:{}", JacksonUtils.toJson(relationship));
|
||||
if (Objects.isNull(relationship)) {
|
||||
List<CpRelationship> cpRelationshipList = cpRelationshipService.getByUserId(runningWater.getUserId());
|
||||
if (cpRelationshipList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Long> acceptUserIds = runningWater.getAcceptUsers().stream()
|
||||
.map(GiftAcceptUser::getAcceptUserId)
|
||||
.toList();
|
||||
log.warn("cptesttest countCpValue3:{},{}", JacksonUtils.toJson(acceptUserIds),cpRelationship.getCpUserId());
|
||||
if (!acceptUserIds.contains(cpRelationship.getCpUserId())) {
|
||||
return;
|
||||
}
|
||||
Set<Long> acceptUserIds = runningWater.getAcceptUsers().stream()
|
||||
.map(GiftAcceptUser::getAcceptUserId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
BigDecimal acceptAmount = runningWater.getGiftValue().getGiftValue();
|
||||
cpValueService.incrValue(cpRelationship.getCpValId(), acceptAmount);
|
||||
log.warn("cptesttest countCpValue4:{},{}", cpRelationship.getCpValId(),acceptAmount);
|
||||
|
||||
List<Long> cpUserIdList = cpRelationshipList.stream().map(CpRelationship::getCpUserId).toList();
|
||||
if (acceptUserIds.stream().noneMatch(cpUserIdList::contains)) {
|
||||
return;
|
||||
}
|
||||
|
||||
cpRelationshipList.stream()
|
||||
.filter(cp -> acceptUserIds.contains(cp.getCpUserId()))
|
||||
.forEach(cp -> {
|
||||
cpValueService.incrValue(cp.getCpValId(), acceptAmount);
|
||||
|
||||
// 累计cp总额
|
||||
userCpValueCacheService.incr(cp.getUserId(),
|
||||
cp.getCpUserId(),
|
||||
acceptAmount.longValue());
|
||||
});
|
||||
|
||||
// 更新cp用户赠送的礼物价值
|
||||
cpRelationshipService.updateAccountByUserId(cpRelationship.getUserId(),
|
||||
cpRelationship.getAmount().add(acceptAmount));
|
||||
// cpRelationshipService.updateAccountByUserId(cpRelationship.getUserId(),
|
||||
// cpRelationship.getAmount().add(acceptAmount));
|
||||
|
||||
// 根据两个cp用户谁赠送的多确定区域
|
||||
String userRegionCode =
|
||||
cpRelationship.getAmount().add(acceptAmount).compareTo(relationship.getAmount()) >= 0
|
||||
? userRegionGateway.getRegionCode(cpRelationship.getUserId()) :
|
||||
userRegionGateway.getRegionCode(relationship.getUserId());
|
||||
// String userRegionCode =
|
||||
// cpRelationship.getAmount().add(acceptAmount).compareTo(relationship.getAmount()) >= 0
|
||||
// ? userRegionGateway.getRegionCode(cpRelationship.getUserId()) :
|
||||
// userRegionGateway.getRegionCode(relationship.getUserId());
|
||||
|
||||
weekCpValueCountService.incrThisWeekQuantity(runningWater.getSysOrigin(),
|
||||
/*weekCpValueCountService.incrThisWeekQuantity(runningWater.getSysOrigin(),
|
||||
userRegionCode,
|
||||
cpRelationship.getUserId(),
|
||||
cpRelationship.getCpUserId(),
|
||||
acceptAmount.longValue());
|
||||
acceptAmount.longValue());*/
|
||||
|
||||
|
||||
// 累计cp总额
|
||||
userCpValueCacheService.incr(cpRelationship.getUserId(),
|
||||
cpRelationship.getCpUserId(),
|
||||
acceptAmount.longValue());
|
||||
}
|
||||
|
||||
private boolean isWeekStar(GiftValue giftValue) {
|
||||
|
||||
@ -79,7 +79,7 @@ public class ActivityCorrectionDataManager {
|
||||
log.warn("correctionActivityData:CHARM_RANK_MONTH-完成");
|
||||
|
||||
// cp
|
||||
CpRelationship cpRelationship = cpRelationshipService.getByUserId(userId);
|
||||
CpRelationship cpRelationship = cpRelationshipService.getByUserId(userId, null);
|
||||
if (Objects.nonNull(cpRelationship)) {
|
||||
|
||||
BigDecimal cpVal = cpValueService.getCpVal(cpRelationship.getCpValId());
|
||||
|
||||
@ -20,6 +20,8 @@ import com.red.circle.other.app.util.DistributedLockUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户cp关系实现.
|
||||
*
|
||||
@ -44,7 +46,7 @@ public class UserCpRelationServiceImpl implements UserCpRelationService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpPairUserProfileCO getCpPairUserProfileCO(AppExtCommand cmd) {
|
||||
public List<CpPairUserProfileCO> getCpPairUserProfileCO(AppExtCommand cmd) {
|
||||
return userCpPairUserProfileQryExe.execute(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ public class CpBlessRecordAndUpReadExe {
|
||||
.build();
|
||||
}
|
||||
|
||||
CpRelationship relationship = cpRelationshipService.getByUserId(cmd.getUserId());
|
||||
CpRelationship relationship = cpRelationshipService.getByUserId(cmd.getReqUserId(), cmd.getUserId());
|
||||
if (Objects.isNull(relationship)) {
|
||||
return UserCpCabinUnreadCO.builder()
|
||||
.topClassRecords(Lists.newArrayList())
|
||||
|
||||
@ -9,6 +9,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* cp用户资料
|
||||
*
|
||||
@ -30,6 +32,11 @@ public class CpPairUserProfileCO extends ClientObject {
|
||||
*/
|
||||
private UserProfileDTO cpUserProfile;
|
||||
|
||||
/**
|
||||
* 心动值
|
||||
*/
|
||||
private BigDecimal cpValue;
|
||||
|
||||
/**
|
||||
* 组建天数.
|
||||
*/
|
||||
|
||||
@ -10,6 +10,8 @@ import com.red.circle.other.app.dto.cmd.user.relation.cp.CpApplyCmd;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CpApplyDismissCmd;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.ProcessApplyCmd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户cp关系.
|
||||
*
|
||||
@ -19,7 +21,7 @@ public interface UserCpRelationService {
|
||||
|
||||
CpUserProfileCO getCpUser(UserIdCmd cmd);
|
||||
|
||||
CpPairUserProfileCO getCpPairUserProfileCO(AppExtCommand cmd);
|
||||
List<CpPairUserProfileCO> getCpPairUserProfileCO(AppExtCommand cmd);
|
||||
|
||||
void sendApply(CpApplyCmd cmd);
|
||||
|
||||
|
||||
@ -26,14 +26,6 @@ public interface CpRelationshipService extends BaseService<CpRelationship> {
|
||||
*/
|
||||
List<CpRelationship> listLatestCp(String sysOrigin, Set<Long> excludeUserId, Integer size);
|
||||
|
||||
/**
|
||||
* 是否存在cp.
|
||||
*
|
||||
* @param userIds 用户id
|
||||
* @return true 存在,false 不存在
|
||||
*/
|
||||
boolean existsCp(Long userIds);
|
||||
|
||||
/**
|
||||
* 是否互为cp.
|
||||
*/
|
||||
@ -45,23 +37,17 @@ public interface CpRelationshipService extends BaseService<CpRelationship> {
|
||||
* @param userId 用户id
|
||||
* @return cp id
|
||||
*/
|
||||
Long getCpUserId(Long userId);
|
||||
List<Long> getCpUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取cp信息集合
|
||||
*/
|
||||
List<CpRelationship> getByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取cp信息.
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return cp id
|
||||
*/
|
||||
CpRelationship getByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取cp信息.
|
||||
*
|
||||
* @param cpUserId 用户id
|
||||
* @return cp id
|
||||
*/
|
||||
CpRelationship getByCpUserId(Long cpUserId);
|
||||
CpRelationship getByUserId(Long userId, Long cpUserId);
|
||||
|
||||
/**
|
||||
* 获取cpValId
|
||||
|
||||
@ -44,15 +44,6 @@ public class CpRelationshipServiceImpl extends
|
||||
return cpRelationshipDAO.listLatestCpExcludeUserId(sysOrigin, excludeUserId, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsCp(Long userId) {
|
||||
return Optional.ofNullable(
|
||||
query().select(CpRelationship::getId)
|
||||
.eq(CpRelationship::getUserId, userId)
|
||||
.eq(CpRelationship::getStatus, CpRelationshipStatus.NORMAL.name())
|
||||
.last(PageConstant.LIMIT_ONE).getOne()
|
||||
).map(cpRelationship -> Objects.nonNull(cpRelationship.getId())).orElse(Boolean.FALSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsCp(Long userId, Long cpUserId) {
|
||||
@ -70,30 +61,33 @@ public class CpRelationshipServiceImpl extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCpUserId(Long userId) {
|
||||
return Optional.ofNullable(
|
||||
query().select(CpRelationship::getCpUserId).eq(CpRelationship::getUserId, userId)
|
||||
.last(PageConstant.LIMIT_ONE).getOne()
|
||||
).map(CpRelationship::getCpUserId).orElse(null);
|
||||
public List<Long> getCpUserId(Long userId) {
|
||||
return query().select(CpRelationship::getCpUserId)
|
||||
.eq(CpRelationship::getUserId, userId)
|
||||
.list()
|
||||
.stream().map(CpRelationship::getCpUserId)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpRelationship getByUserId(Long userId) {
|
||||
return Optional.ofNullable(query()
|
||||
.eq(CpRelationship::getUserId, userId)
|
||||
.eq(CpRelationship::getStatus, CpRelationshipStatus.NORMAL.name())
|
||||
.last(PageConstant.LIMIT_ONE)
|
||||
.getOne()
|
||||
).orElse(null);
|
||||
public List<CpRelationship> getByUserId(Long userId) {
|
||||
return query()
|
||||
.eq(CpRelationship::getUserId, userId)
|
||||
.eq(CpRelationship::getStatus, CpRelationshipStatus.NORMAL.name())
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpRelationship getByCpUserId(Long cpUserId) {
|
||||
return Optional.ofNullable(query()
|
||||
.eq(CpRelationship::getCpUserId, cpUserId)
|
||||
.last(PageConstant.LIMIT_ONE)
|
||||
.getOne()
|
||||
).orElse(null);
|
||||
public CpRelationship getByUserId(Long userId, Long cpUserId) {
|
||||
return query()
|
||||
.eq(CpRelationship::getStatus, CpRelationshipStatus.NORMAL.name())
|
||||
.and(where -> where
|
||||
.nested(w -> w.eq(CpRelationship::getUserId, userId).eq(CpRelationship::getCpUserId, cpUserId))
|
||||
.or()
|
||||
.nested(w -> w.eq(CpRelationship::getUserId, cpUserId).eq(CpRelationship::getCpUserId, userId))
|
||||
)
|
||||
.last(PageConstant.LIMIT_ONE)
|
||||
.getOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -130,7 +130,7 @@ public class UserCpClientEndpoint implements UserCpClientApi {
|
||||
|
||||
|
||||
@Override
|
||||
public ResultResponse<Long> getCpUserId(Long userId) {
|
||||
public ResultResponse<List<Long>> getCpUserId(Long userId) {
|
||||
return ResultResponse.success(userCpWeekClientService.getCpUserId(userId));
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ public interface UserCpWeekClientService {
|
||||
* @param userId 用户id
|
||||
* @return cp id
|
||||
*/
|
||||
Long getCpUserId(Long userId);
|
||||
List<Long> getCpUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取最近cp.
|
||||
|
||||
@ -47,8 +47,8 @@ public class UserCpClientServiceImpl implements UserCpClientService {
|
||||
|
||||
@Override
|
||||
public CpRelationshipDTO getByUserId(Long userId) {
|
||||
return userCpInnerConvertor.toCpRelationshipDTO(
|
||||
cpRelationshipService.getByUserId(userId));
|
||||
List<CpRelationship> cpRelationships = cpRelationshipService.getByUserId(userId);
|
||||
return userCpInnerConvertor.toCpRelationshipDTO(cpRelationships.isEmpty() ? null : cpRelationships.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -74,7 +74,7 @@ public class UserCpWeekClientServiceImpl implements UserCpWeekClientService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCpUserId(Long userId) {
|
||||
public List<Long> getCpUserId(Long userId) {
|
||||
return cpRelationshipService.getCpUserId(userId);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user