@@ -14,23 +14,26 @@ import com.accompany.common.status.BusiStatus;
import com.accompany.core.exception.ServiceException ;
import com.accompany.core.model.PartitionInfo ;
import com.accompany.core.model.Users ;
import com.accompany.core.service.SysConfService ;
import com.accompany.core.service.partition.PartitionInfoService ;
import com.accompany.payment.service.RechargeUserService ;
import com.accompany.payment.vo.RechargeUserVo ;
import com.alibaba.fastjson.JSONObject ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.collections.CollectionUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.util.CollectionUtils ;
import javax.annotation.Resource ;
import java.math.BigDecimal ;
import java.util.* ;
import java.util.concurrent.CountDownLatch ;
import java.util.concurrent.ThreadPoolExecutor ;
import java.util.concurrent.TimeUnit ;
import java.util.stream.Collectors ;
import static com.accompany.common.constant.Constant.SysConfId.GUILD_USD_PROD_TAB_SHOW_CONFIG ;
@Slf4j
@Service
public class GuildUsdChannelService {
@@ -57,6 +60,8 @@ public class GuildUsdChannelService {
private GuildUsdWithdrawAccountService guildUsdWithdrawAccountService ;
@Autowired
private GuildUsdToRechargeUserLimitService guildUsdToRechargeUserLimitService ;
@Autowired
private SysConfService sysConfService ;
public GuildMemberDiamondWithdrawVo getDiamondWithDrawVo ( Long uid ) {
GuildMember guildMember = guildMemberService . getVaildGuildMemberByUid ( uid ) ;
@@ -86,6 +91,9 @@ public class GuildUsdChannelService {
vo . setGuildId ( guild . getId ( ) ) ;
vo . setUid ( uid ) ;
UserPurse userPurse = userPurseService . queryUserPurse ( uid ) ;
vo . setGuildUsdNum ( userPurse . getGuildUsd ( ) ) ;
CountDownLatch cdl = new CountDownLatch ( 3 ) ;
bizExecutor . execute ( ( ) - > {
@@ -93,9 +101,6 @@ public class GuildUsdChannelService {
SimpleUserVo guildOwner = usersService . getSimpleUserByUid ( guild . getOwnerUid ( ) ) ;
vo . setGuildOwner ( guildOwner ) ;
UserPurse userPurse = userPurseService . queryUserPurse ( uid ) ;
vo . setGuildUsdNum ( userPurse . getGuildUsd ( ) ) ;
List < GuildMemberUsdWithdrawAccountVo > withdrawAccount = guildUsdWithdrawAccountService . listUserAccountVo ( uid ) ;
vo . setWithdrawAccountList ( withdrawAccount ) ;
} catch ( Exception e ) {
@@ -126,6 +131,8 @@ public class GuildUsdChannelService {
bizExecutor . execute ( ( ) - > {
try {
List < GuildUsdProdTabVo > tabVoList = buildTabByRoleType ( uid , guildMember . getPartitionId ( ) , guildMember . getRoleType ( ) ) ;
fitlerTabPro ( vo . getGuildUsdNum ( ) , guild , tabVoList ) ;
vo . setTypeTab ( tabVoList ) ;
} catch ( Exception e ) {
log . error ( " [getUsdOperateTabVo] tabVoList 获取异常 " , e ) ;
@@ -209,4 +216,61 @@ public class GuildUsdChannelService {
return rechargeUserVoList . stream ( ) . sorted ( Comparator . comparing ( RechargeUserVo : : getStarLevelSeq ) . reversed ( ) )
. collect ( Collectors . toList ( ) ) ;
}
private List < GuildUsdProdTabShowConfigVo > getTabShowConfig ( Integer partitionId ) {
String sysConfValueById = sysConfService . getSysConfValueById ( GUILD_USD_PROD_TAB_SHOW_CONFIG ) ;
if ( StringUtils . isNotEmpty ( sysConfValueById ) ) {
GuildUsdProdTabShowConfigVo configVo = JSONObject . parseObject ( sysConfValueById , GuildUsdProdTabShowConfigVo . class ) ;
return configVo . getByPartitionId ( partitionId ) ;
}
return Collections . emptyList ( ) ;
}
/**
* 屏蔽对应类型对应国家下, 钱包usd小于最低档位的转账方式,
* @param guildUsdNum
* @param guild
* @param tabVoList
*/
private void fitlerTabPro ( Double guildUsdNum , Guild guild , List < GuildUsdProdTabVo > tabVoList ) {
if ( CollectionUtils . isEmpty ( tabVoList ) | | guild . getRegionId ( ) = = null ) {
return ;
}
List < GuildUsdProdTabShowConfigVo > tabShowConfig = getTabShowConfig ( guild . getPartitionId ( ) ) ;
if ( CollectionUtils . isEmpty ( tabShowConfig ) ) {
return ;
}
for ( GuildUsdProdTabVo tabVo : tabVoList ) {
List < GuildUsdProdChannelVo > channelList = tabVo . getChannelList ( ) ;
if ( CollectionUtils . isEmpty ( channelList ) ) {
continue ;
}
for ( GuildUsdProdTabShowConfigVo configVo : tabShowConfig ) {
if ( ! tabVo . getTabKey ( ) . equals ( configVo . getTabKey ( ) ) ) {
continue ;
}
List < Integer > limitRegionIds = configVo . getLimitRegionIds ( ) ;
if ( CollectionUtils . isEmpty ( limitRegionIds ) | | ! limitRegionIds . contains ( guild . getRegionId ( ) ) ) {
continue ;
}
Iterator < GuildUsdProdChannelVo > iterator = channelList . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
GuildUsdProdChannelVo next = iterator . next ( ) ;
List < GuildUsdProd > prodList = next . getProdList ( ) ;
if ( next . getType ( ) ! = configVo . getType ( ) . intValue ( ) | | CollectionUtils . isEmpty ( prodList ) ) {
continue ;
}
GuildUsdProd usdProd = prodList . get ( 0 ) ;
if ( guildUsdNum < usdProd . getGuildUsdNum ( ) . doubleValue ( ) ) {
iterator . remove ( ) ;
}
}
}
}
}
}