xiaoyong931011
2023-08-10 18b681e553980b20bc9b5b3a113167f33b83a7b3
数据修改
27 files modified
1 files added
4999 ■■■■ changed files
src/main/java/cc/mrbird/febs/dapp/contract/andao/AndaoContractMain.java 2 ●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/controller/ApiDappMemberController.java 98 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/controller/MemberMoneyFlowController.java 2 ●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/controller/ViewController.java 58 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/entity/DappAccountMoneyChangeEntity.java 6 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/entity/TeamLevelPerk.java 6 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/enumerate/DataDictionaryEnum.java 6 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/enumerate/FundFlowEnum.java 36 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/mapper/DappFundFlowDao.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/mapper/DappMemberDao.java 3 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/mapper/MallAchieveRecordMapper.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/DappMemberService.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/DappSystemService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/DappWalletService.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/AdminOperationServiceImpl.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/BscUsdtContractEvent.java 2 ●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java 444 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java 2893 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java 1044 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/vo/DappMemberInfoVo.java 51 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/vo/TeamChildListVo.java 40 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/vo/TeamListVo.java 14 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/job/BnbTransferJob.java 43 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/job/ProfitDailyJob.java 128 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/websocket/WsAuthInterceptor.java 2 ●●● patch | view | raw | blame | history
src/main/resources/mapper/dapp/DappFundFlowDao.xml 9 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/dapp/DappMemberDao.xml 24 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/dapp/MallAchieveRecordMapper.xml 49 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/contract/andao/AndaoContractMain.java
@@ -147,7 +147,7 @@
                // TODO 业务操作逻辑代码
                System.out.println("from:"+from+",amount:"+amount+",regFlow:"+regFlow);
                chainProducer.sendContractAnDao(Long.parseLong(regFlow));
//                chainProducer.sendContractAnDao(Long.parseLong(regFlow));
                //投注人
//                DappMemberEntity dappMemberEntity = dappMemberDao.selectByAddress(from, "BSC");
//                if(ObjectUtil.isNotEmpty(dappMemberEntity)){
src/main/java/cc/mrbird/febs/dapp/controller/ApiDappMemberController.java
@@ -43,16 +43,6 @@
    private final DappMemberService dappMemberService;
    private final RedisUtils redisUtils;
    @ApiOperation(value = "获取账户信息接口", notes = "获取账号信息接口")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = WalletInfoVo.class)
    })
    @PostMapping(value = "/walletInfo")
    public FebsResponse walletInfo() {
        WalletInfoVo walletInfoVo = dappWalletService.walletInfo();
        return new FebsResponse().success().data(walletInfoVo);
    }
    @ApiOperation(value = "获取用户信息", notes = "获取用户信息")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = DappMemberInfoVo.class)
@@ -62,37 +52,23 @@
        return dappMemberService.getMemberInfo();
    }
    @ApiOperation(value = "获取流水总的信息", notes = "获取流水总的信息")
    @ApiOperation(value = "我的团队", notes = "我的团队")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = FundFlowInfoVo.class)
            @ApiResponse(code = 200, message = "success", response = TeamListVo.class)
    })
    @PostMapping(value = "/fundFlowInfo")
    public FebsResponse fundFlowInfo() {
        return dappMemberService.getFundFlowInfo();
    @PostMapping(value = "/teamList")
    public FebsResponse team() {
        return new FebsResponse().success().data(dappMemberService.findTeamList());
    }
    @ApiOperation(value = "获取用户购买节点信息", notes = "获取用户购买节点信息")
    @ApiOperation(value = "记录列表", notes = "记录列表")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = DappMemberNodeVo.class)
            @ApiResponse(code = 200, message = "success", response = DappFundFlowVo.class)
    })
    @PostMapping(value = "/memberNode")
    public FebsResponse memberNode() {
        return dappMemberService.getMemberNode();
    }
    @ApiOperation(value = "获取节点信息", notes = "获取节点信息")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = DappNodeOrderVo.class)
    })
    @PostMapping(value = "/nodeInfo")
    public FebsResponse nodeInfo() {
        return dappMemberService.getNodeInfo();
    }
    @ApiOperation(value = "转账", notes = "转账")
    @PostMapping(value = "/transfer")
    public FebsResponse transfer(@RequestBody TransferDto transferDto) {
        return new FebsResponse().success().data(dappWalletService.transfer(transferDto));
    @PostMapping(value = "/recordInPage")
    public FebsResponse recordInPage(@RequestBody RecordInPageDto recordInPageDto) {
//        return new FebsResponse().success().data(dappWalletService.recordInPage(recordInPageDto));
        return new FebsResponse().success().data(dappWalletService.getRecordVoInPage(recordInPageDto));
    }
    @ApiOperation(value = "买入A币", notes = "买入A币")
@@ -101,15 +77,6 @@
//        return new FebsResponse().success().message("合约更新中");
        return new FebsResponse().success().data(dappWalletService.transferA(transferADto));
    }
    @ApiOperation(value = "A币K线", notes = "A币K线")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = AKLineVo.class)
    })
    @PostMapping(value = "/aKLine")
    public FebsResponse aKLine(@RequestBody AKLineDto aKLineDto) {
        return new FebsResponse().success().data(dappMemberService.aKLine(aKLineDto));
    }
    @ApiOperation(value = "兑换AUSDT", notes = "兑换AUSDT")
@@ -139,40 +106,12 @@
        return new FebsResponse().success().data("success");
    }
    @ApiOperation(value = "记录列表", notes = "记录列表")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = DappFundFlowVo.class)
    })
    @PostMapping(value = "/recordInPage")
    public FebsResponse recordInPage(@RequestBody RecordInPageDto recordInPageDto) {
//        return new FebsResponse().success().data(dappWalletService.recordInPage(recordInPageDto));
        return new FebsResponse().success().data(dappWalletService.getRecordVoInPage(recordInPageDto));
    }
    @ApiOperation(value = "提现", notes = "提现")
    @PostMapping(value = "/withdraw")
    public FebsResponse withdraw(@RequestBody @Valid WithdrawDto withdrawDto) {
//        return new FebsResponse().success().message("合约更新中");
        dappWalletService.withdraw(withdrawDto);
        return new FebsResponse().success().message("success");
    }
    @ApiOperation(value = "我的团队", notes = "我的团队")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = TeamListVo.class)
    })
    @PostMapping(value = "/team")
    public FebsResponse team() {
        return new FebsResponse().success().data(dappMemberService.findTeamList());
    }
    @ApiOperation(value = "我的推广码", notes = "我的推广码")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = MyInviteInfoVo.class)
    })
    @PostMapping(value = "/inviteInfo")
    public FebsResponse inviteInfo() {
        return new FebsResponse().success().data(dappMemberService.findInviteInfo());
    }
    @ApiOperation(value = "动能信息", notes = "动能信息")
@@ -184,26 +123,11 @@
        return new FebsResponse().success().data(dappMemberService.findRunListInfo());
    }
//    @ApiOperation(value = "我的团队", notes = "我的团队")
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "success", response = TeamListVo.class)
//    })
//    @PostMapping(value = "/team")
//    public FebsResponse team() {
//        return new FebsResponse().success().data(dappMemberService.findTeamList());
//    }
    @PostMapping(value = "/logout")
    public FebsResponse logout() {
        DappMemberEntity member = LoginUserUtil.getAppUser();
        redisUtils.hdel(AppContants.REDIS_KEY_SIGN, member.getAddress());
        redisUtils.hdel(AppContants.REDIS_KEY_MEMBER_INFO, member.getAddress());
        return new FebsResponse().success();
    }
    @ApiOperation(value = "计算手续费", notes = "计算手续费")
    @PostMapping(value = "/calPrice")
    public FebsResponse calPrice(@RequestBody PriceDto priceDto) {
        return new FebsResponse().success().data(dappWalletService.calPrice(priceDto));
    }
}
src/main/java/cc/mrbird/febs/dapp/controller/MemberMoneyFlowController.java
@@ -61,7 +61,7 @@
        if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == dappFundFlowEntity.getStatus()){
            return new FebsResponse().fail().message("已转账,无法再次操作");
        }
        chainProducer.sendBnbTransferMsg(id);
//        chainProducer.sendBnbTransferMsg(id);
        return new FebsResponse().success().message("操作成功,请稍后查看");
    }
}
src/main/java/cc/mrbird/febs/dapp/controller/ViewController.java
@@ -135,35 +135,35 @@
    @RequiresPermissions("fee:setting:view")
    public String systemFeeSet(Model model) {
        AdminSystemFeeVo adminSystemFeeVo = new AdminSystemFeeVo();
        DataDictionaryCustom rebateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.REBATE_PERCENT.getType(), DataDictionaryEnum.REBATE_PERCENT.getCode());
        if (ObjectUtil.isNotEmpty(rebateDic)) {
            String value = rebateDic.getValue() == null ? "0" : rebateDic.getValue();
            adminSystemFeeVo.setRebatePercent(value);
        }
        DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode());
        if (ObjectUtil.isNotEmpty(memberFeeDic)) {
            String value = memberFeeDic.getValue() == null ? "0" : memberFeeDic.getValue();
            adminSystemFeeVo.setMemberFee(value);
        }
        DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getType(), DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getCode());
        if (ObjectUtil.isNotEmpty(serviceFeeDic)) {
            String value = serviceFeeDic.getValue() == null ? "0" : serviceFeeDic.getValue();
            adminSystemFeeVo.setServiceFee(value);
        }
        DataDictionaryCustom symbolPrice = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode());
        if (ObjectUtil.isNotEmpty(symbolPrice)) {
            String value = symbolPrice.getValue() == null ? "0" : symbolPrice.getValue();
            adminSystemFeeVo.setSymbolPrice(value);
        }
        DataDictionaryCustom directProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.DIRECT_PROFIT.getType(), DataDictionaryEnum.DIRECT_PROFIT.getCode());
        if (ObjectUtil.isNotEmpty(directProfitDic)) {
            String value = directProfitDic.getValue() == null ? "0" : directProfitDic.getValue();
            adminSystemFeeVo.setDirectProfit(value);
        }
        model.addAttribute("systemFee", adminSystemFeeVo);
//        DataDictionaryCustom rebateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.REBATE_PERCENT.getType(), DataDictionaryEnum.REBATE_PERCENT.getCode());
//        if (ObjectUtil.isNotEmpty(rebateDic)) {
//            String value = rebateDic.getValue() == null ? "0" : rebateDic.getValue();
//            adminSystemFeeVo.setRebatePercent(value);
//        }
//        DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode());
//        if (ObjectUtil.isNotEmpty(memberFeeDic)) {
//            String value = memberFeeDic.getValue() == null ? "0" : memberFeeDic.getValue();
//            adminSystemFeeVo.setMemberFee(value);
//        }
//        DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getType(), DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getCode());
//        if (ObjectUtil.isNotEmpty(serviceFeeDic)) {
//            String value = serviceFeeDic.getValue() == null ? "0" : serviceFeeDic.getValue();
//            adminSystemFeeVo.setServiceFee(value);
//        }
//
//        DataDictionaryCustom symbolPrice = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode());
//        if (ObjectUtil.isNotEmpty(symbolPrice)) {
//            String value = symbolPrice.getValue() == null ? "0" : symbolPrice.getValue();
//            adminSystemFeeVo.setSymbolPrice(value);
//        }
//
//        DataDictionaryCustom directProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                DataDictionaryEnum.DIRECT_PROFIT.getType(), DataDictionaryEnum.DIRECT_PROFIT.getCode());
//        if (ObjectUtil.isNotEmpty(directProfitDic)) {
//            String value = directProfitDic.getValue() == null ? "0" : directProfitDic.getValue();
//            adminSystemFeeVo.setDirectProfit(value);
//        }
//        model.addAttribute("systemFee", adminSystemFeeVo);
        return FebsUtil.view("dapp/system-fee-set");
    }
src/main/java/cc/mrbird/febs/dapp/entity/DappAccountMoneyChangeEntity.java
@@ -29,11 +29,11 @@
    }
    private Long memberId;
    //原有积分
    private BigDecimal preAmount;
    //预期
    private BigDecimal amount;
    //实际
    private BigDecimal afterAmount;
    private String content;
src/main/java/cc/mrbird/febs/dapp/entity/TeamLevelPerk.java
@@ -7,8 +7,8 @@
/**
 *  {"shareMinPercent":"0.00004","shareMaxPercent":"0.01","smallAchieve":"20000","teamPercent":"0.15","orderSalePercent":"0","lastAgentCnt":"0","buyMaxAmount","3000"}
 *  {"shareMinPercent":"0.00005","shareMaxPercent":"0.012","smallAchieve":"60000","teamPercent":"0.3","orderSalePercent":"0","lastAgentCnt":"2","buyMaxAmount","3000"}
 *  {"shareMinPercent":"0.00006","shareMaxPercent":"0.014","smallAchieve":"200000","teamPercent":"0.45","orderSalePercent":"0","lastAgentCnt":"2","buyMaxAmount","3000"}
 *  {"shareMinPercent":"0.00007","shareMaxPercent":"0.016","smallAchieve":"600000","teamPercent":"0.60","orderSalePercent":"0","lastAgentCnt":"2","buyMaxAmount","3000"}
 *  {"shareMinPercent":"0.00006","shareMaxPercent":"0.014","smallAchieve":"200000","teamPercent":"0.45","orderSalePercent":"0","lastAgentCnt":"3","buyMaxAmount","3000"}
 *  {"shareMinPercent":"0.00007","shareMaxPercent":"0.016","smallAchieve":"600000","teamPercent":"0.60","orderSalePercent":"0","lastAgentCnt":"3","buyMaxAmount","3000"}
 *  {"shareMinPercent":"0.00008","shareMaxPercent":"0.018","smallAchieve":"2000000","teamPercent":"0.75","orderSalePercent":"0.02","lastAgentCnt":"2","buyMaxAmount","3000"}
 *  {"shareMinPercent":"0.00009","shareMaxPercent":"0.020","smallAchieve":"6000000","teamPercent":"0.90","orderSalePercent":"0.02","lastAgentCnt":"2","buyMaxAmount","3000"}
 *  {"shareMinPercent":"0.0001","shareMaxPercent":"0.022","smallAchieve":"20000000","teamPercent":"1","orderSalePercent":"0.02","lastAgentCnt":"2","buyMaxAmount","3000"}
@@ -44,6 +44,6 @@
    /**
     * 购买上限
     */
    private Integer buyMaxAmount;
    private BigDecimal buyMaxAmount;
}
src/main/java/cc/mrbird/febs/dapp/enumerate/DataDictionaryEnum.java
@@ -5,7 +5,11 @@
@Getter
public enum DataDictionaryEnum {
    /**
     *  商城入单的10%入底池
     *  普通会员购买上线
     */
    MEMBER_BUY_MAX_AMOUNT("MEMBER_BUY_MAX_AMOUNT","MEMBER_BUY_MAX_AMOUNT"),
    /**
     *  团队加速平级10%
     */
    TEAM_PERK_LEVEL_EQUALS("TEAM_PERK_LEVEL_EQUALS","TEAM_PERK_LEVEL_EQUALS"),
    /**
src/main/java/cc/mrbird/febs/dapp/enumerate/FundFlowEnum.java
@@ -7,25 +7,43 @@
 */
@Getter
public enum FundFlowEnum {
    //团队静态收益
    //实际增加余额
    ADD_AMOUNT_REAL("ADD_AMOUNT_REAL", 22),
    //实际减少赠送积分
    REDUCE_SCORE_REAL("REDUCE_SCORE_REAL", 21),
    //共享区加速V7
    SHARE_PERK_V7("SHARE_PERK_V7", 20),
    //共享区加速V6
    SHARE_PERK_V6("SHARE_PERK_V6", 19),
    //共享区加速V5
    SHARE_PERK_V5("SHARE_PERK_V5", 18),
    //共享区加速V4
    SHARE_PERK_V4("SHARE_PERK_V4", 17),
    //共享区加速V3
    SHARE_PERK_V3("SHARE_PERK_V3", 16),
    //共享区加速V2
    SHARE_PERK_V2("SHARE_PERK_V2", 15),
    //共享区加速V1
    SHARE_PERK_V1("SHARE_PERK_V1", 14),
    //团队静态收益V7
    TEAM_PERK_V7("TEAM_PERK_V7", 13),
    //团队静态收益
    //团队静态收益V6
    TEAM_PERK_V6("TEAM_PERK_V6", 12),
    //团队静态收益
    //团队静态收益V5
    TEAM_PERK_V5("TEAM_PERK_V5", 11),
    //团队静态收益
    //团队静态收益V4
    TEAM_PERK_V4("TEAM_PERK_V4", 10),
    //团队静态收益
    //团队静态收益V3
    TEAM_PERK_V3("TEAM_PERK_V3", 9),
    //团队静态收益
    //团队静态收益V2
    TEAM_PERK_V2("TEAM_PERK_V2", 8),
    //团队静态收益
    //团队静态收益V1
    TEAM_PERK_V1("TEAM_PERK_V1", 7),
    //直推
    DIRECT_AMOUNT("DIRECT_AMOUNT", 6),
    //增加余额
    //预期增加余额
    ADD_AMOUNT("ADD_AMOUNT", 5),
    //减少赠送积分
    //预期减少赠送积分
    REDUCE_SCORE("REDUCE_SCORE", 4),
    //静态补贴
    STATIC_RELEASE("STATIC_RELEASE", 3),
src/main/java/cc/mrbird/febs/dapp/mapper/DappFundFlowDao.java
@@ -58,4 +58,6 @@
    IPage<AdminMallMoneyFlowVo> selectOrderMoneyFlowInPage(Page<AdminMallMoneyFlowVo> page, @Param("record")MallOrderInfo mallOrder);
    List<DappFundFlowEntity> selectListByMemberIdAndTypeAndDate(@Param("memberId")Long memberId, @Param("type")int code, @Param("dateStr") DateTime now);
    List<DappFundFlowEntity> selectListByTypeAndDate(@Param("type")int code, @Param("dateStr") DateTime now);
}
src/main/java/cc/mrbird/febs/dapp/mapper/DappMemberDao.java
@@ -52,6 +52,8 @@
    List<DappMemberEntity> selectMemberInfoByRefererId(@Param("refererId")String inviteId);
    List<DappMemberEntity> selectAllMemberInfoByRefererId(@Param("inviteId")String inviteId);
    Integer selectCountByAccountTypeAndRefererId(@Param("accountType")String code, @Param("refererId")String inviteId);
    IPage<AdminTeamInfoVo> findTeamInfoListInPage(Page<AdminTeamInfoVo> page, @Param("record")DappMemberEntity dappMemberEntity);
@@ -97,5 +99,4 @@
    List<DappMemberEntity> selectChildAgentList(@Param("inviteId")String inviteId, @Param("accountType")String accountType);
    List<MallMember> selectMemberByInviteIds(List<String> referrerIdList);
}
src/main/java/cc/mrbird/febs/dapp/mapper/MallAchieveRecordMapper.java
@@ -1,6 +1,8 @@
package cc.mrbird.febs.dapp.mapper;
import cc.mrbird.febs.dapp.entity.MallAchieveRecord;
import cc.mrbird.febs.dapp.vo.TeamChildListVo;
import cc.mrbird.febs.dapp.vo.TeamListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
@@ -24,4 +26,14 @@
    List<MallAchieveRecord> selectListByDate(@Param("date")Date profitDate);
    List<MallAchieveRecord> selectListByMemberId(@Param("memberId")Long memberId);
    BigDecimal selectAchieveTotalByMemberIdAndCreateTime(@Param("memberId")Long id, @Param("date")Date createTime);
    BigDecimal selectAchieveTotalByCreateTime(@Param("date")Date createTime);
    BigDecimal selectAchieveByMemberId(@Param("inviteId") String inviteId, @Param("type") Integer type);
    List<TeamChildListVo> selectTeamListByInviteId(@Param("inviteId")String inviteId);
    List<MallAchieveRecord> selectCountByInvitedId(@Param("inviteId") String inviteId, @Param("type") Integer type);
}
src/main/java/cc/mrbird/febs/dapp/service/DappMemberService.java
@@ -53,23 +53,9 @@
    IPage<AdminTeamInfoVo> getTeamInfo(DappMemberEntity dappMemberEntity, QueryRequest request);
    /**
     * 获取节点信息
     * @return
     */
    FebsResponse getNodeInfo();
    FebsResponse getMemberNode();
    FebsResponse getMemberInfo();
    IPage<DappMemberNodeVo> getMemberNodeInfo(DappMemberEntity dappMemberEntity, QueryRequest request);
    String aKLine(AKLineDto aKLineDto);
    MyInviteInfoVo findInviteInfo();
    FebsResponse getFundFlowInfo();
    FebsResponse insideWithYes(Long id);
src/main/java/cc/mrbird/febs/dapp/service/DappSystemService.java
@@ -117,4 +117,5 @@
    void teamStaticPerk();
    void updateAchieve();
}
src/main/java/cc/mrbird/febs/dapp/service/DappWalletService.java
@@ -18,7 +18,6 @@
public interface DappWalletService {
    WalletInfoVo walletInfo();
    List<DappFundFlowEntity> recordInPage(RecordInPageDto recordInPageDto);
@@ -28,11 +27,6 @@
    IPage<DappWalletMineEntity> walletMineInPage(DappWalletMineEntity walletMine, QueryRequest request);
    IPage<DappAccountMoneyChangeEntity> accountMoneyChangeInPage(DappAccountMoneyChangeEntity change, QueryRequest request);
    Long transfer(TransferDto transferDto);
    BigDecimal calPrice(PriceDto priceDto);
    void withdraw(WithdrawDto withdrawDto);
src/main/java/cc/mrbird/febs/dapp/service/impl/AdminOperationServiceImpl.java
@@ -56,7 +56,7 @@
        dappFundFlowEntity.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE);
        dappFundFlowDao.updateById(dappFundFlowEntity);
        chainProducer.sendFeeDistributeMsg(dappFundFlowEntity.getId());
//        chainProducer.sendFeeDistributeMsg(dappFundFlowEntity.getId());
        return new FebsResponse().success();
    }
@@ -85,7 +85,7 @@
        dappWalletService.updateWalletCoinWithLock(memberCoinWithdrawEntity.getAmount(), memberCoinWithdrawEntity.getMemberId(), 1);
        dappWalletService.updateWalletMineWithLock(memberCoinWithdrawEntity.getFeeAmount(), memberCoinWithdrawEntity.getMemberId(), 1);
        DappFundFlowEntity feeFlow = new DappFundFlowEntity(memberCoinWithdrawEntity.getMemberId(), memberCoinWithdrawEntity.getFeeAmount(), 7, 2, null, null);
        DappFundFlowEntity feeFlow = new DappFundFlowEntity();
        dappFundFlowDao.insert(feeFlow);
        return new FebsResponse().success();
    }
src/main/java/cc/mrbird/febs/dapp/service/impl/BscUsdtContractEvent.java
@@ -101,7 +101,7 @@
            fundFlow.setStatus(2);
            dappFundFlowDao.updateById(fundFlow);
            chainProducer.sendAchieveTreeMsg(fundFlow.getMemberId());
//            chainProducer.sendAchieveTreeMsg(fundFlow.getMemberId());
        }
    }
}
src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java
@@ -1,6 +1,5 @@
package cc.mrbird.febs.dapp.service.impl;
import cc.mrbird.febs.common.configure.i18n.MessageSourceUtils;
import cc.mrbird.febs.common.contants.AppContants;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
@@ -25,6 +24,7 @@
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -67,6 +67,7 @@
    private final MallGoodsMapper mallGoodsMapper;
    private final MallOrderInfoMapper mallOrderInfoMapper;
    private final MallOrderItemMapper mallOrderItemMapper;
    private final MallAchieveRecordMapper mallAchieveRecordMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -147,18 +148,7 @@
            int nodeType = 0;
            //
            if (!"asdf4321".equals(connectDto.getInviteId())) {
                DappMemberEntity left = dappMemberDao.selectInviteLeft(connectDto.getInviteId());
                DappMemberEntity right = dappMemberDao.selectInviteRight(connectDto.getInviteId());
                if(ObjectUtil.isEmpty(left) && ObjectUtil.isEmpty(right)){
                    throw new FebsException("recommender is not exist");
                }
                if(ObjectUtil.isEmpty(left)){
                    nodeType = 2;
                }else{
                    nodeType = 1;
                }
                String inviteId = ObjectUtil.isEmpty(left) ? right.getInviteId() : left.getInviteId();
                DappMemberEntity parent = dappMemberDao.selectByAddress(inviteId, null);
                DappMemberEntity parent = dappMemberDao.selectByAddress(connectDto.getInviteId(), null);
                if (parent == null) {
                    throw new FebsException("recommender is not exist");
                }
@@ -388,91 +378,106 @@
    @Override
    public TeamListVo findTeamList() {
        DappMemberEntity member = LoginUserUtil.getAppUser();
        TeamListVo teamListVo = new TeamListVo();
        List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId());
        teamListVo.setDirectCnt(CollUtil.isEmpty(childs) ? 0 : childs.size());
        //团队业绩
        BigDecimal teamIncomeMax = BigDecimal.ZERO;
        if(CollUtil.isNotEmpty(childs)){
            // 直推用户
            List<String> childsInviteIds = childs.stream().map(DappMemberEntity::getInviteId).collect(Collectors.toList());
            for(String inviteId : childsInviteIds){
                BigDecimal totalIncomeMember = dappMemberDao.selectAllAchieveByInviteId(inviteId);
                teamIncomeMax = teamIncomeMax.add(totalIncomeMember);
        Long memberId = LoginUserUtil.getAppUser().getId();
        DappMemberEntity dappMemberEntity = this.baseMapper.selectById(memberId);
        TeamListVo myTeamVo = new TeamListVo();
        myTeamVo.setMyAchieve(mallAchieveRecordMapper.selectAchieveByMemberId(dappMemberEntity.getInviteId(), 1));
        myTeamVo.setMyTeamAchieve(mallAchieveRecordMapper.selectAchieveByMemberId(dappMemberEntity.getInviteId(), 2));
        List<DappMemberEntity> child = dappMemberDao.selectAllMemberInfoByRefererId(dappMemberEntity.getInviteId());
        myTeamVo.setMyTeamCnt(CollUtil.isEmpty(child) ? 0 : child.size());
        List<TeamChildListVo> list = mallAchieveRecordMapper.selectTeamListByInviteId(dappMemberEntity.getInviteId());
        if(CollUtil.isNotEmpty(list)){
            for(TeamChildListVo teamChildListVo : list){
                List<DappMemberEntity> childDirect = dappMemberDao.selectAllMemberInfoByRefererId(teamChildListVo.getInviteId());
                teamChildListVo.setCnt(CollUtil.isEmpty(childDirect) ? 0 : childDirect.size());
                List<MallAchieveRecord> memberAchieveList = mallAchieveRecordMapper.selectCountByInvitedId(teamChildListVo.getInviteId(), 1);
                if(CollUtil.isEmpty(memberAchieveList)){
                    teamChildListVo.setAchieveState(2);
                }else{
                    teamChildListVo.setAchieveState(1);
                }
                List<MallAchieveRecord> mallAchieveRecords = mallAchieveRecordMapper.selectCountByInvitedId(teamChildListVo.getInviteId(), 2);
                if(CollUtil.isEmpty(mallAchieveRecords)){
                    teamChildListVo.setRealAchieve(BigDecimal.ZERO);
                    teamChildListVo.setOrderCnt(0);
                }else{
                    BigDecimal reduce = mallAchieveRecords.stream().map(MallAchieveRecord::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
                    teamChildListVo.setRealAchieve(reduce);
                    teamChildListVo.setOrderCnt(mallAchieveRecords.size());
                }
            }
            teamIncomeMax = teamIncomeMax.setScale(4,BigDecimal.ROUND_DOWN);
        }
        teamListVo.setAchieve(teamIncomeMax);
        return teamListVo;
        return myTeamVo;
    }
    @Override
    public void setSystemFee(AdminSystemFeeVo adminSystemFeeVo) {
        String rebatePercent = adminSystemFeeVo.getRebatePercent();
        DataDictionaryCustom rebateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.REBATE_PERCENT.getType(), DataDictionaryEnum.REBATE_PERCENT.getCode());
        rebateDic.setValue(rebatePercent);
        dataDictionaryCustomMapper.updateById(rebateDic);
        String serviceFee = adminSystemFeeVo.getServiceFee();
        DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getType(), DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getCode());
        serviceFeeDic.setValue(serviceFee);
        dataDictionaryCustomMapper.updateById(serviceFeeDic);
        String memberFee = adminSystemFeeVo.getMemberFee();
        DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode());
        memberFeeDic.setValue(memberFee);
        dataDictionaryCustomMapper.updateById(memberFeeDic);
        String symbolPrice = adminSystemFeeVo.getSymbolPrice();
        DataDictionaryCustom symbolPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode());
        symbolPriceDic.setValue(symbolPrice);
        dataDictionaryCustomMapper.updateById(symbolPriceDic);
        String directProfit = adminSystemFeeVo.getDirectProfit();
        DataDictionaryCustom directProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.DIRECT_PROFIT.getType(), DataDictionaryEnum.DIRECT_PROFIT.getCode());
        directProfitDic.setValue(directProfit);
        dataDictionaryCustomMapper.updateById(directProfitDic);
//        String rebatePercent = adminSystemFeeVo.getRebatePercent();
//        DataDictionaryCustom rebateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.REBATE_PERCENT.getType(), DataDictionaryEnum.REBATE_PERCENT.getCode());
//        rebateDic.setValue(rebatePercent);
//        dataDictionaryCustomMapper.updateById(rebateDic);
//
//        String serviceFee = adminSystemFeeVo.getServiceFee();
//        DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getType(), DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getCode());
//        serviceFeeDic.setValue(serviceFee);
//        dataDictionaryCustomMapper.updateById(serviceFeeDic);
//
//        String memberFee = adminSystemFeeVo.getMemberFee();
//        DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode());
//        memberFeeDic.setValue(memberFee);
//        dataDictionaryCustomMapper.updateById(memberFeeDic);
//
//        String symbolPrice = adminSystemFeeVo.getSymbolPrice();
//        DataDictionaryCustom symbolPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode());
//        symbolPriceDic.setValue(symbolPrice);
//        dataDictionaryCustomMapper.updateById(symbolPriceDic);
//
//        String directProfit = adminSystemFeeVo.getDirectProfit();
//        DataDictionaryCustom directProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                DataDictionaryEnum.DIRECT_PROFIT.getType(), DataDictionaryEnum.DIRECT_PROFIT.getCode());
//        directProfitDic.setValue(directProfit);
//        dataDictionaryCustomMapper.updateById(directProfitDic);
    }
    @Override
    public ApiRunListInfoVo findRunListInfo() {
        ApiRunListInfoVo apiRunListInfoVo = new ApiRunListInfoVo();
        //获取当前是第几轮队列
        String redisKey = "QUEUE_COUNT";
        String memberOutCount = redisUtils.getString(redisKey);
        DataDictionaryCustom queueCountSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.QUEUE_COUNT.getType(), DataDictionaryEnum.QUEUE_COUNT.getCode());
        String queueCount = queueCountSet.getValue();
        if(StrUtil.isBlank(memberOutCount)|| !queueCount.equals(memberOutCount)){
            redisUtils.set(redisKey,queueCount,0L);
            memberOutCount = queueCount;
        }
        //出局条件的人数
        /**
         * 初始大小 5+4*0
         * 1  1,2,3,4,5  1出局 5+4*0
         * 2  2,3,4,5,1(复投),7,8,9,10  2出局 5+4*1
         * 3  3,4,5,1(复投),7,8,9,10,2(复投),12,13,14,15 3出局 5+4*2
         * 4  4,5,1(复投),7,8,9,10,2(复投),12,13,14,15,3(复投),17,18,19,20  4出局 5+4*3
         */
        Integer memberCount = Integer.parseInt(memberOutCount) * 4 + 5;
        //判断当前是否符合出局条件
        QueryWrapper<DappSystemProfit> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("state",DappSystemProfit.STATE_IN);
        //实际投资人数
        Integer selectCount = dappSystemProfitDao.selectCount(objectQueryWrapper);
        int runPercentNum = memberCount - selectCount;
        runPercentNum = 5-runPercentNum > 0 ? 5-runPercentNum : 1;
        apiRunListInfoVo.setRunPercent(new BigDecimal(runPercentNum).multiply(new BigDecimal(0.4)).setScale(BigDecimal.ROUND_DOWN,1));
//        BigDecimal runPercent = new BigDecimal(selectCount).divide(new BigDecimal(memberCount), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100));
//        apiRunListInfoVo.setRunPercent(runPercent);
        //实际投资人数小于出局条件人数
        //符合则出局 实际投资人数等于出局条件人数
        DappSystemProfit dappSystemProfitIn = dappSystemProfitDao.selectSystemProfitInByState(DappSystemProfit.STATE_IN);
        apiRunListInfoVo.setLuckyMemberNext(ObjectUtil.isEmpty(dappSystemProfitIn) ? 0L : dappSystemProfitIn.getId());
        DappSystemProfit dappSystemProfitOut = dappSystemProfitDao.selectSystemProfitOutByState(DappSystemProfit.STATE_OUT);
        apiRunListInfoVo.setLuckyMember(ObjectUtil.isEmpty(dappSystemProfitOut) ? 0L : dappSystemProfitOut.getId());
//        //获取当前是第几轮队列
//        String redisKey = "QUEUE_COUNT";
//        String memberOutCount = redisUtils.getString(redisKey);
//        DataDictionaryCustom queueCountSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.QUEUE_COUNT.getType(), DataDictionaryEnum.QUEUE_COUNT.getCode());
//        String queueCount = queueCountSet.getValue();
//        if(StrUtil.isBlank(memberOutCount)|| !queueCount.equals(memberOutCount)){
//            redisUtils.set(redisKey,queueCount,0L);
//            memberOutCount = queueCount;
//        }
//        //出局条件的人数
//        /**
//         * 初始大小 5+4*0
//         * 1  1,2,3,4,5  1出局 5+4*0
//         * 2  2,3,4,5,1(复投),7,8,9,10  2出局 5+4*1
//         * 3  3,4,5,1(复投),7,8,9,10,2(复投),12,13,14,15 3出局 5+4*2
//         * 4  4,5,1(复投),7,8,9,10,2(复投),12,13,14,15,3(复投),17,18,19,20  4出局 5+4*3
//         */
//        Integer memberCount = Integer.parseInt(memberOutCount) * 4 + 5;
//        //判断当前是否符合出局条件
//        QueryWrapper<DappSystemProfit> objectQueryWrapper = new QueryWrapper<>();
//        objectQueryWrapper.eq("state",DappSystemProfit.STATE_IN);
//        //实际投资人数
//        Integer selectCount = dappSystemProfitDao.selectCount(objectQueryWrapper);
//        int runPercentNum = memberCount - selectCount;
//        runPercentNum = 5-runPercentNum > 0 ? 5-runPercentNum : 1;
//        apiRunListInfoVo.setRunPercent(new BigDecimal(runPercentNum).multiply(new BigDecimal(0.4)).setScale(BigDecimal.ROUND_DOWN,1));
////        BigDecimal runPercent = new BigDecimal(selectCount).divide(new BigDecimal(memberCount), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100));
////        apiRunListInfoVo.setRunPercent(runPercent);
//        //实际投资人数小于出局条件人数
//        //符合则出局 实际投资人数等于出局条件人数
//        DappSystemProfit dappSystemProfitIn = dappSystemProfitDao.selectSystemProfitInByState(DappSystemProfit.STATE_IN);
//        apiRunListInfoVo.setLuckyMemberNext(ObjectUtil.isEmpty(dappSystemProfitIn) ? 0L : dappSystemProfitIn.getId());
//        DappSystemProfit dappSystemProfitOut = dappSystemProfitDao.selectSystemProfitOutByState(DappSystemProfit.STATE_OUT);
//        apiRunListInfoVo.setLuckyMember(ObjectUtil.isEmpty(dappSystemProfitOut) ? 0L : dappSystemProfitOut.getId());
        return apiRunListInfoVo;
    }
@@ -513,19 +518,6 @@
    }
    @Override
    public FebsResponse getNodeInfo() {
        List<DappNodeOrderVo> dappNodeOrderVos = dappNodeOrderMapper.selectNodeOrderList();
        return new FebsResponse().success().data(dappNodeOrderVos);
    }
    @Override
    public FebsResponse getMemberNode() {
        DappMemberEntity member = LoginUserUtil.getAppUser();
        List<DappMemberNodeVo> dappMemberNodeVos = dappMemberNodeMapper.selectListByMemberId(member.getId());
        return new FebsResponse().success().data(dappMemberNodeVos);
    }
    @Override
    public FebsResponse getMemberInfo() {
        DappMemberEntity member = LoginUserUtil.getAppUser();
        DappMemberInfoVo dappMemberInfoVo = dappMemberDao.selectByMemberId(member.getId());
@@ -534,79 +526,11 @@
            dappMemberInfoVo.setAccountType(levelDescription);
        }
        BigDecimal amountPerkTotal = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(member.getId(),
                FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode(), 2);
        dappMemberInfoVo.setAmountPerkTotal(amountPerkTotal);
        DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(member.getId());
        dappMemberInfoVo.setAmount(ObjectUtil.isEmpty(dappWalletCoinEntity) ? BigDecimal.ZERO : dappWalletCoinEntity.getTotalAmount());
        DataDictionaryCustom ausdPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.TRANSFER_A_AUSD_PERCENT.getType(),
                PoolEnum.TRANSFER_A_AUSD_PERCENT.getCode()
        );
        BigDecimal ausdPercent = new BigDecimal(ausdPercentDic.getValue());
        dappMemberInfoVo.setAusdtFee(ausdPercent);
        DataDictionaryCustom aroundFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getType(),
                PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getCode()
        );
        BigDecimal aroundFee = new BigDecimal(aroundFeeDic.getValue());
        dappMemberInfoVo.setAroundFee(aroundFee);
        //ausd价格
        DataDictionaryCustom ausdPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.TRANSFER_A_AUSD_PRICE.getType(),
                PoolEnum.TRANSFER_A_AUSD_PRICE.getCode()
        );
        dappMemberInfoVo.setAusdPrice(ObjectUtil.isEmpty(ausdPriceDic) ? new BigDecimal("1") : new BigDecimal(ausdPriceDic.getValue()).setScale(4,BigDecimal.ROUND_DOWN));
        //资产到闪兑的手续费比例
        DataDictionaryCustom mineToCoinFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.WALLET_MINE_TO_COIN_PERCENT.getType(),
                PoolEnum.WALLET_MINE_TO_COIN_PERCENT.getCode()
        );
        dappMemberInfoVo.setMineToCoinFee(ObjectUtil.isEmpty(mineToCoinFeeDic) ? new BigDecimal("0.03") : new BigDecimal(mineToCoinFeeDic.getValue()));
        //提现手续费比例
        DataDictionaryCustom coinOutFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.WALLET_COIN_TO_USDT_PERCENT.getType(),
                PoolEnum.WALLET_COIN_TO_USDT_PERCENT.getCode()
        );
        dappMemberInfoVo.setCoinOutFee(ObjectUtil.isEmpty(coinOutFeeDic) ? new BigDecimal("0.01") : new BigDecimal(coinOutFeeDic.getValue()));
        //A币的价格
        DataDictionaryCustom coinAPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_PRICE.getType(),
                PoolEnum.COIN_A_PRICE.getCode()
        );
        dappMemberInfoVo.setCoinAPrice((ObjectUtil.isEmpty(coinAPriceDic) ? new BigDecimal("1") : new BigDecimal(coinAPriceDic.getValue()))
                .setScale(12,BigDecimal.ROUND_DOWN));
        /**
         * 今日涨幅
         */
        //最新的一条记录
        DappAKlineEntity dappAKlineNow = dappAKlineMapper.selectOneByType();
        BigDecimal closePriceNow = dappAKlineNow.getClosePrice();
        //拿日线的最后一条数据
        DappAKlineEntity dappAKlineStart = dappAKlineMapper.selectDayByType();
        BigDecimal closePriceStart = dappAKlineStart.getClosePrice();
        BigDecimal subtract = closePriceNow.subtract(closePriceStart);
        BigDecimal bigDecimal = subtract.divide(closePriceStart, 4, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN);
        dappMemberInfoVo.setTodayIncrease(bigDecimal);
        /**
         * 全网剩余ANDAO总量,燃烧ANDAO总量
         */
        DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_CNT.getType(),
                PoolEnum.COIN_A_CNT.getCode()
        );
        dappMemberInfoVo.setAndaoNum(
                ObjectUtil.isEmpty(coinACntDic) ?
                new BigDecimal("0") :
                new BigDecimal(coinACntDic.getValue()).setScale(2,BigDecimal.ROUND_DOWN)
        );
        BigDecimal bigDecimal1 = dappFundFlowDao.selectSumAmountByType(FundFlowEnum.A_COIN_FIRE.getCode());
        dappMemberInfoVo.setFireAndaoNum(bigDecimal1.setScale(2,BigDecimal.ROUND_DOWN));
        DappWalletMineEntity dappWalletMineEntity = dappWalletMineDao.selectByMemberId(member.getId());
        dappMemberInfoVo.setScore(ObjectUtil.isEmpty(dappWalletMineEntity) ? BigDecimal.ZERO : dappWalletMineEntity.getTotalAmount());
        return new FebsResponse().success().data(dappMemberInfoVo);
    }
@@ -624,145 +548,13 @@
    }
    @Override
    public String aKLine(AKLineDto aKLineDto) {
        int type = aKLineDto.getType();
        String redisKey = null;
        if(1 == type){
            redisKey = AppContants.K_LINE_HOUR;
        }else if(2 == type){
            redisKey = AppContants.K_LINE_DAY;
        }else if(3 == type){
            redisKey = AppContants.K_LINE_WEEK;
        }else if(4 == type){
            redisKey = AppContants.K_LINE_MONTH;
        }else{
            redisKey = AppContants.K_LINE_NOW;
        }
        Object o = redisUtils.get(redisKey);
        if(ObjectUtil.isNotEmpty(o)){
            return redisUtils.get(redisKey).toString();
        }
        return null;
    }
    @Override
    public MyInviteInfoVo findInviteInfo() {
        MyInviteInfoVo myInviteInfoVo = new MyInviteInfoVo();
        DappMemberEntity member = LoginUserUtil.getAppUser();
        Long memberId = member.getId();
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
        myInviteInfoVo.setMemberAddress(dappMemberEntity.getAddress());
        DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId);
        if(ObjectUtil.isEmpty(dappUsdtPerkEntity)){
            dappUsdtPerkEntity = new DappUsdtPerkEntity();
            dappUsdtPerkEntity.setMemberId(memberId);
            dappUsdtPerkEntityMapper.insert(dappUsdtPerkEntity);
        }
        myInviteInfoVo.setMemberAchieve(dappUsdtPerkEntity.getAchieveAmount());
        String refererId = dappMemberEntity.getRefererId();
        DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(refererId);
        myInviteInfoVo.setReferenceAddress(ObjectUtil.isEmpty(parentMember) ? "-" : parentMember.getAddress());
        HashMap<String, BigDecimal> maxMinAchieve = getMaxMinAchieve(memberId);
        myInviteInfoVo.setMaxAchieve(maxMinAchieve.get(AppContants.MAXACHIEVE));
        myInviteInfoVo.setMinAchieve(maxMinAchieve.get(AppContants.MINACHIEVE));
        List<MyInviteChildInfoVo> myInviteChildInfoVos = new ArrayList<>();
        List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId());
        if(CollUtil.isNotEmpty(childs)){
            for(DappMemberEntity child : childs){
                MyInviteChildInfoVo myInviteChildInfoVo = new MyInviteChildInfoVo();
                myInviteChildInfoVo.setAddress(child.getAddress());
                myInviteChildInfoVo.setAccountType(child.getAccountType());
                DappUsdtPerkEntity childUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(child.getId());
//                BigDecimal achieveAmountByMemberId = dappUsdtPerkEntityMapper.selectAchieveAmountByMemberId(child.getId());
                if(ObjectUtil.isEmpty(childUsdtPerkEntity)){
                    childUsdtPerkEntity = new DappUsdtPerkEntity();
                    childUsdtPerkEntity.setMemberId(child.getId());
                    dappUsdtPerkEntityMapper.insert(childUsdtPerkEntity);
                }
                myInviteChildInfoVo.setMemberAchieve(ObjectUtil.isEmpty(childUsdtPerkEntity.getAchieveAmount()) ? BigDecimal.ZERO : childUsdtPerkEntity.getAchieveAmount());
                HashMap<String, BigDecimal> childMaxMinAchieve = getMaxMinAchieve(child.getId());
                myInviteChildInfoVo.setMaxAchieve(childMaxMinAchieve.get(AppContants.MAXACHIEVE));
                myInviteChildInfoVo.setMinAchieve(childMaxMinAchieve.get(AppContants.MINACHIEVE));
                myInviteChildInfoVos.add(myInviteChildInfoVo);
            }
        }
        myInviteInfoVo.setMyInviteChildInfoVos(myInviteChildInfoVos);
        return myInviteInfoVo;
    }
    @Override
    public FebsResponse getFundFlowInfo() {
        DappMemberEntity member = LoginUserUtil.getAppUser();
        Long memberId = member.getId();
        FundFlowInfoVo fundFlowInfoVo = new FundFlowInfoVo();
        BigDecimal myDonateCnt = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(member.getId(),
                FundFlowEnum.BUY_A_COIN.getCode(), 2);
        fundFlowInfoVo.setMyDonateCnt(myDonateCnt.abs());
        fundFlowInfoVo.setMyDonateCntNum(FundFlowEnum.BUY_A_COIN.getCode());
        BigDecimal amountPerkTotal = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(member.getId(),
                FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode(), 2);
        fundFlowInfoVo.setAmountPerkTotal(amountPerkTotal.abs());
        fundFlowInfoVo.setAmountPerkTotalNum(FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode());
        DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId);
        fundFlowInfoVo.setAmountPerkAva(ObjectUtil.isEmpty(dappUsdtPerkEntity) ? BigDecimal.ZERO : dappUsdtPerkEntity.getAmount());
        BigDecimal directAmount = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,
                FundFlowEnum.DIRECT_A_PERCENT.getCode(), 2);
        fundFlowInfoVo.setDirectAmount(directAmount);
        fundFlowInfoVo.setDirectAmountNum(FundFlowEnum.DIRECT_A_PERCENT.getCode());
        BigDecimal staticAmount = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,
                FundFlowEnum.POOL_MEMBER_A_CNT.getCode(), 2);
        fundFlowInfoVo.setStaticAmount(staticAmount);
        fundFlowInfoVo.setStaticAmountNum(FundFlowEnum.POOL_MEMBER_A_CNT.getCode());
        BigDecimal nodeAmount = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,
                FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(), 2);
        fundFlowInfoVo.setNodeAmount(nodeAmount);
        fundFlowInfoVo.setNodeAmountNum(FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode());
        BigDecimal levelEqualAmount = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,
                FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode(), 2);
        fundFlowInfoVo.setLevelEqualAmount(levelEqualAmount);
        fundFlowInfoVo.setLevelEqualAmountNum(FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode());
        BigDecimal levelAmount = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,
                FundFlowEnum.LEVEL_A_PERCENT_CNT_MEMBER.getCode(), 2);
        fundFlowInfoVo.setLevelAmount(levelAmount);
        fundFlowInfoVo.setLevelAmountNum(FundFlowEnum.LEVEL_A_PERCENT_CNT_MEMBER.getCode());
        BigDecimal daoThreeAmount = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,
                FundFlowEnum.DAO_3_NODE_PERK.getCode(), 2);
        fundFlowInfoVo.setDaoThreeAmount(daoThreeAmount);
        fundFlowInfoVo.setDaoThreeAmountNum(FundFlowEnum.DAO_3_NODE_PERK.getCode());
        BigDecimal daoFourAmount = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,
                FundFlowEnum.DAO_4_NODE_PERK.getCode(), 2);
        fundFlowInfoVo.setDaoFourAmount(daoFourAmount);
        fundFlowInfoVo.setDaoFourAmountNum(FundFlowEnum.DAO_4_NODE_PERK.getCode());
        BigDecimal daoFiveAmount = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,
                FundFlowEnum.DAO_5_NODE_PERK.getCode(), 2);
        fundFlowInfoVo.setDaoFiveAmount(daoFiveAmount);
        fundFlowInfoVo.setDaoFiveAmountNum(FundFlowEnum.DAO_5_NODE_PERK.getCode());
        return new FebsResponse().success().data(fundFlowInfoVo);
    }
    @Override
    public FebsResponse insideWithYes(Long id) {
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(id);
        if(ObjectUtil.isEmpty(dappMemberEntity)) {
            return new FebsResponse().fail().message("会员信息不存在");
        }
        dappMemberEntity.setNodeType(1);
        dappMemberEntity.setAccountType(MemberLevelEnum.NODE_5.getType());
//        dappMemberEntity.setAccountType(MemberLevelEnum.NODE_5.getType());
        dappMemberDao.updateById(dappMemberEntity);
        return new FebsResponse().success();
    }
@@ -904,13 +696,50 @@
        if (ObjectUtil.isEmpty(orderInfo)) {
            throw new FebsException("订单异常");
        }
        if (MallOrderInfo.STATUS_WAIT != orderInfo.getStatus()) {
            throw new FebsException("只能支付待支付的订单");
        }
        /**
         * 限制用户的购买总量
         */
        //实际可购买数量
        BigDecimal achieveAva = BigDecimal.ZERO;
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
        String accountType = dappMemberEntity.getAccountType();
        //普通会员的购买上线
        if(MemberLevelEnum.MEMBER.getType().equals(accountType)){
            DataDictionaryCustom memberBuyMaxAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                    DataDictionaryEnum.MEMBER_BUY_MAX_AMOUNT.getType(),
                    DataDictionaryEnum.MEMBER_BUY_MAX_AMOUNT.getCode()
            );
            achieveAva = new BigDecimal(ObjectUtil.isEmpty(memberBuyMaxAmountDic) ? "1000" : memberBuyMaxAmountDic.getValue());
        }else{
            DataDictionaryCustom memberBuyMaxAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                    "TEAM_LEVEL",accountType
            );
            if(ObjectUtil.isEmpty(memberBuyMaxAmountDic)){
                achieveAva = new BigDecimal("1000");
            }else{
                TeamLevelPerk adminAgentInfo = JSONObject.parseObject(memberBuyMaxAmountDic.getValue(), TeamLevelPerk.class);
                BigDecimal buyMaxAmount = adminAgentInfo.getBuyMaxAmount();
                achieveAva = buyMaxAmount;
            }
        }
        List<MallAchieveRecord> mallAchieveRecords = mallAchieveRecordMapper.selectListByMemberId(dappMemberEntity.getId());
        if(CollUtil.isNotEmpty(mallAchieveRecords)){
            BigDecimal reduce = mallAchieveRecords.stream().map(MallAchieveRecord::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
            achieveAva = achieveAva.subtract(reduce);
        }
        if(BigDecimal.ZERO.compareTo(achieveAva) >= 0){
            throw new FebsException("用户无法购买");
        }
        BigDecimal totalAmount = orderInfo.getAmount();
        if(achieveAva.compareTo(totalAmount) < 0){
            throw new FebsException("用户最多购买"+achieveAva.setScale(2,BigDecimal.ROUND_DOWN)+"USDT");
        }
        DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(member.getId());
        BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount();
        BigDecimal totalAmount = orderInfo.getAmount();
        if(totalAmount.compareTo(availableAmount) > 0){
            throw new FebsException("余额不足");
        }
@@ -937,7 +766,6 @@
        /**
         * 支付成功,消费后成有效账户后可分享(有效用户可推广)
         */
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
        if(2 == dappMemberEntity.getActiveStatus()){
            dappMemberEntity.setActiveStatus(1);
            dappMemberDao.updateById(dappMemberEntity);
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
@@ -98,7 +98,7 @@
            BigDecimal directProfit = TreeConstants.PUT_IN_AMOUNT.multiply(new BigDecimal("0.1"));
            dappWalletService.updateWalletCoinWithLock(directProfit, parent.getId(), 1);
            DappFundFlowEntity fundFlow = new DappFundFlowEntity(parent.getId(), directProfit, 3, 2, null, null);
            DappFundFlowEntity fundFlow = new DappFundFlowEntity();
            dappFundFlowDao.insert(fundFlow);
        }
@@ -128,11 +128,11 @@
                dappWalletService.updateWalletCoinWithLock(amount, member.getId(), 1);
                DappFundFlowEntity matrixProfitFlow = new DappFundFlowEntity(memberId, amount, 2, 2, null, null);
                DappFundFlowEntity matrixProfitFlow = new DappFundFlowEntity();
                dappFundFlowDao.insert(matrixProfitFlow);
            }
            DappFundFlowEntity rePutInFlow = new DappFundFlowEntity(memberId, TreeConstants.PUT_IN_AMOUNT.negate(), 1, 2, null, null);
            DappFundFlowEntity rePutInFlow = new DappFundFlowEntity();
            dappFundFlowDao.insert(rePutInFlow);
        }
    }
@@ -161,7 +161,7 @@
            list.forEach(item -> {
                dappWalletService.updateWalletCoinWithLock(preAmount, item.getMidNode(), 1);
                DappFundFlowEntity flow = new DappFundFlowEntity(item.getMidNode(), preAmount, 8, 2, null, null);
                DappFundFlowEntity flow = new DappFundFlowEntity();
                dappFundFlowDao.insert(flow);
            });
        }
@@ -186,186 +186,186 @@
            return;
        }
        DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode());
        if (memberFeeDic == null) {
            log.info("未设置手续费返利比例");
            return;
        }
        List<DappMemberEntity> memberList = dappMemberDao.selectMemberListNeedProfit();
        if (CollUtil.isEmpty(memberList)) {
            return;
        }
        BigDecimal feeReturnRatio = new BigDecimal(memberFeeDic.getValue());
        int size = memberList.size();
        BigDecimal totalProfit = fundFlow.getFee().multiply(feeReturnRatio.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN));
        BigDecimal perProfit = totalProfit.divide(BigDecimal.valueOf(size), 8, RoundingMode.HALF_DOWN);
        memberList.forEach(item -> {
            dappWalletService.updateWalletMineWithLock(perProfit, item.getId(), 1);
            DappFundFlowEntity profitFlow = new DappFundFlowEntity(item.getId(), perProfit, 12, 2, null, null);
            dappFundFlowDao.insert(profitFlow);
        });
//        DataDictionaryCustom memberFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MEMBER_FEE.getType(), DataDictionaryEnum.MEMBER_FEE.getCode());
//        if (memberFeeDic == null) {
//            log.info("未设置手续费返利比例");
//            return;
//        }
//        List<DappMemberEntity> memberList = dappMemberDao.selectMemberListNeedProfit();
//        if (CollUtil.isEmpty(memberList)) {
//            return;
//        }
//
//        BigDecimal feeReturnRatio = new BigDecimal(memberFeeDic.getValue());
//        int size = memberList.size();
//        BigDecimal totalProfit = fundFlow.getFee().multiply(feeReturnRatio.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN));
//        BigDecimal perProfit = totalProfit.divide(BigDecimal.valueOf(size), 8, RoundingMode.HALF_DOWN);
//
//        memberList.forEach(item -> {
//            dappWalletService.updateWalletMineWithLock(perProfit, item.getId(), 1);
//
//            DappFundFlowEntity profitFlow = new DappFundFlowEntity(item.getId(), perProfit, 12, 2, null, null);
//            dappFundFlowDao.insert(profitFlow);
//        });
    }
    @Override
    public void levelProfit(Long id) {
        DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectById(id);
        if(ObjectUtil.isEmpty(dappSystemProfit)){
            return;
        }
        Integer levelProfitState = dappSystemProfit.getLevelProfit();
        if(DappSystemProfit.ENUM_YES == levelProfitState){
            return;
        }
        Long memberId = dappSystemProfit.getMemberId();
        //获取用户的上级用户信息
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
        if(ObjectUtil.isEmpty(dappMemberEntity)){
            return;
        }
        String refererIds = dappMemberEntity.getRefererIds();
        if(StrUtil.isEmpty(refererIds)){
            return;
        }
        DataDictionaryCustom levelProfitSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.LEVEL_PROFIT.getType(), DataDictionaryEnum.LEVEL_PROFIT.getCode());
        BigDecimal levelProfit = new BigDecimal(StrUtil.isEmpty(levelProfitSet.getValue()) ? "0.3" : levelProfitSet.getValue());
        //投入金额减去技术方收益
        DataDictionaryCustom systemProfitSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYSTEM_PROFIT.getType(), DataDictionaryEnum.SYSTEM_PROFIT.getCode());
        BigDecimal systemProfit = new BigDecimal(StrUtil.isEmpty(systemProfitSet.getValue()) ? "0.05" : systemProfitSet.getValue());
        BigDecimal amount = dappSystemProfit.getAmount().subtract(systemProfit);
        //层级奖励总奖金
        BigDecimal levelProfitTotal = amount.multiply(levelProfit);
        //实发层级奖励 -- 如果还有剩余给技术方
        BigDecimal systemProfitTotal = BigDecimal.ZERO;
        //返回十层
        List<String> refererIdList = StrUtil.split(refererIds, ',');
        //i:计数层数,同时i也为对应层数应推广的人数,当达到对应的直推人数时,才能获取对应层级奖励
        if(CollUtil.isEmpty(refererIdList)){
            return;
        }
        //层级奖励最大循环次数
        int maxLevel = 10;
        if(maxLevel > refererIdList.size()){
            maxLevel = refererIdList.size();
        }
        for(int i = 0;i < maxLevel; i++){
            if(systemProfitTotal.compareTo(levelProfitTotal) < 0){
                String inviteId = refererIdList.get(i);
                //获取每层用户的直推人数,判断能否获得这个层级的层级奖励
                DappMemberEntity refererMember = dappMemberDao.selectMemberInfoByInviteId(inviteId);
                //获取直推用户数量
                QueryWrapper<DappMemberEntity> objectQueryWrapper = new QueryWrapper<>();
                objectQueryWrapper.eq("referer_id",refererMember.getInviteId());
                Integer selectCount = dappMemberDao.selectCount(objectQueryWrapper);
                if(i >= selectCount){
                    continue;
                }
                //获取对应层级奖励
                BigDecimal profit = LevelProfitEnum.YI.getProfit(i+1);
                String accountType = refererMember.getAccountType();
                //根据会员的等级类型,获取对应的百分比收益
                DataDictionaryCustom memberLevelSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode("MEMBER_LEVEL", accountType);
                BigDecimal memberLevel = new BigDecimal(memberLevelSet.getValue());
//                BigDecimal memberLevelProfit = levelProfitTotal.multiply(profit).multiply(memberLevel);
                BigDecimal memberLevelProfit = profit.multiply(memberLevel);
                DappFundFlowEntity fundFlow = new DappFundFlowEntity(refererMember.getId(), memberLevelProfit, 4, 1, BigDecimal.ZERO,null,dappSystemProfit.getId());
                dappFundFlowDao.insert(fundFlow);
                //发送转币消息
                chainProducer.sendBnbTransferMsg(fundFlow.getId());
                systemProfitTotal = systemProfitTotal.add(memberLevelProfit);
            }
        }
        //如果还有剩余给技术方
        if(levelProfitTotal.compareTo(systemProfitTotal) > 0){
            BigDecimal avaProfit = levelProfitTotal.subtract(systemProfitTotal);
            DappFundFlowEntity fundFlow = new DappFundFlowEntity(2L, avaProfit, 5, 1, BigDecimal.ZERO,null,dappSystemProfit.getId());
            dappFundFlowDao.insert(fundFlow);
            //发送转币消息
            chainProducer.sendBnbTransferMsg(fundFlow.getId());
        }
        dappSystemProfitDao.updateLevelProfitById(DappSystemProfit.ENUM_YES,dappSystemProfit.getId());
//        DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectById(id);
//        if(ObjectUtil.isEmpty(dappSystemProfit)){
//            return;
//        }
//        Integer levelProfitState = dappSystemProfit.getLevelProfit();
//
//        if(DappSystemProfit.ENUM_YES == levelProfitState){
//            return;
//        }
//        Long memberId = dappSystemProfit.getMemberId();
//        //获取用户的上级用户信息
//        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
//        if(ObjectUtil.isEmpty(dappMemberEntity)){
//            return;
//        }
//        String refererIds = dappMemberEntity.getRefererIds();
//        if(StrUtil.isEmpty(refererIds)){
//            return;
//        }
//        DataDictionaryCustom levelProfitSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.LEVEL_PROFIT.getType(), DataDictionaryEnum.LEVEL_PROFIT.getCode());
//        BigDecimal levelProfit = new BigDecimal(StrUtil.isEmpty(levelProfitSet.getValue()) ? "0.3" : levelProfitSet.getValue());
//        //投入金额减去技术方收益
//        DataDictionaryCustom systemProfitSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYSTEM_PROFIT.getType(), DataDictionaryEnum.SYSTEM_PROFIT.getCode());
//        BigDecimal systemProfit = new BigDecimal(StrUtil.isEmpty(systemProfitSet.getValue()) ? "0.05" : systemProfitSet.getValue());
//        BigDecimal amount = dappSystemProfit.getAmount().subtract(systemProfit);
//        //层级奖励总奖金
//        BigDecimal levelProfitTotal = amount.multiply(levelProfit);
//        //实发层级奖励 -- 如果还有剩余给技术方
//        BigDecimal systemProfitTotal = BigDecimal.ZERO;
//        //返回十层
//        List<String> refererIdList = StrUtil.split(refererIds, ',');
//        //i:计数层数,同时i也为对应层数应推广的人数,当达到对应的直推人数时,才能获取对应层级奖励
//        if(CollUtil.isEmpty(refererIdList)){
//            return;
//        }
//        //层级奖励最大循环次数
//        int maxLevel = 10;
//        if(maxLevel > refererIdList.size()){
//            maxLevel = refererIdList.size();
//        }
//        for(int i = 0;i < maxLevel; i++){
//            if(systemProfitTotal.compareTo(levelProfitTotal) < 0){
//                String inviteId = refererIdList.get(i);
//                //获取每层用户的直推人数,判断能否获得这个层级的层级奖励
//                DappMemberEntity refererMember = dappMemberDao.selectMemberInfoByInviteId(inviteId);
//                //获取直推用户数量
//                QueryWrapper<DappMemberEntity> objectQueryWrapper = new QueryWrapper<>();
//                objectQueryWrapper.eq("referer_id",refererMember.getInviteId());
//                Integer selectCount = dappMemberDao.selectCount(objectQueryWrapper);
//                if(i >= selectCount){
//                    continue;
//                }
//                //获取对应层级奖励
//                BigDecimal profit = LevelProfitEnum.YI.getProfit(i+1);
//                String accountType = refererMember.getAccountType();
//                //根据会员的等级类型,获取对应的百分比收益
//                DataDictionaryCustom memberLevelSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode("MEMBER_LEVEL", accountType);
//                BigDecimal memberLevel = new BigDecimal(memberLevelSet.getValue());
//
////                BigDecimal memberLevelProfit = levelProfitTotal.multiply(profit).multiply(memberLevel);
//
//                BigDecimal memberLevelProfit = profit.multiply(memberLevel);
//
//                DappFundFlowEntity fundFlow = new DappFundFlowEntity(refererMember.getId(), memberLevelProfit, 4, 1, BigDecimal.ZERO,null,dappSystemProfit.getId());
//                dappFundFlowDao.insert(fundFlow);
//                //发送转币消息
//                chainProducer.sendBnbTransferMsg(fundFlow.getId());
//                systemProfitTotal = systemProfitTotal.add(memberLevelProfit);
//            }
//        }
//        //如果还有剩余给技术方
//        if(levelProfitTotal.compareTo(systemProfitTotal) > 0){
//            BigDecimal avaProfit = levelProfitTotal.subtract(systemProfitTotal);
//            DappFundFlowEntity fundFlow = new DappFundFlowEntity(2L, avaProfit, 5, 1, BigDecimal.ZERO,null,dappSystemProfit.getId());
//            dappFundFlowDao.insert(fundFlow);
//            //发送转币消息
//            chainProducer.sendBnbTransferMsg(fundFlow.getId());
//        }
//
//        dappSystemProfitDao.updateLevelProfitById(DappSystemProfit.ENUM_YES,dappSystemProfit.getId());
    }
    @Override
    public void memberOut(Long id) {
        //验证是否已经加入动能队列
        DappSystemProfit systemProfit = dappSystemProfitDao.selectById(id);
        if(ObjectUtil.isEmpty(systemProfit)){
            return;
        }
        //获取当前是第几轮队列
        String redisKey = "QUEUE_COUNT";
        String memberOutCount = redisUtils.getString(redisKey);
        DataDictionaryCustom queueCountSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.QUEUE_COUNT.getType(), DataDictionaryEnum.QUEUE_COUNT.getCode());
        String queueCount = queueCountSet.getValue();
        if(StrUtil.isBlank(memberOutCount) || !queueCount.equals(memberOutCount)){
            redisUtils.set(redisKey,queueCount,0L);
            memberOutCount = queueCount;
        }
        //出局条件的人数
        /**
         * 初始大小 5+4*0
         * 1  1,2,3,4,5  1出局 5+4*0
         * 2  2,3,4,5,1(复投),7,8,9,10  2出局 5+4*1
         * 3  3,4,5,1(复投),7,8,9,10,2(复投),12,13,14,15 3出局 5+4*2
         * 4  4,5,1(复投),7,8,9,10,2(复投),12,13,14,15,3(复投),17,18,19,20  4出局 5+4*3
         */
        Integer memberCount = Integer.parseInt(memberOutCount) * 4 + 5;
        //判断当前是否符合出局条件
        QueryWrapper<DappSystemProfit> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("state",DappSystemProfit.STATE_IN);
        //实际投资人数
        Integer selectCount = dappSystemProfitDao.selectCount(objectQueryWrapper);
        //实际投资人数小于出局条件人数
        if(selectCount < memberCount){
            return;
        }
        //符合则出局 实际投资人数等于出局条件人数
        DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectSystemProfitByState(DappSystemProfit.STATE_IN);
        if(ObjectUtil.isEmpty(dappSystemProfit)){
            return;
        }
        //符合则出局,轮数+1
        Integer realCount = (Integer.parseInt(queueCount) + 1);
        queueCountSet.setValue(realCount.toString());
        dataDictionaryCustomMapper.updateById(queueCountSet);
        redisUtils.set(redisKey,realCount,0L);
        DappSystemProfit dappSystemProfitNow = dappSystemProfitDao.selectByIdForUpdate(dappSystemProfit.getId(),DappSystemProfit.STATE_IN);
        dappSystemProfitDao.updateStateById(DappSystemProfit.STATE_OUT,dappSystemProfitNow.getId());
        // 直接拿走0.95ge
        DataDictionaryCustom investAmountProfitSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.INVEST_AMOUNT_PROFIT.getType(), DataDictionaryEnum.INVEST_AMOUNT_PROFIT.getCode());
        BigDecimal investAmountProfit = new BigDecimal(investAmountProfitSet.getValue());
        DappFundFlowEntity fundFlowOut = new DappFundFlowEntity(dappSystemProfitNow.getMemberId(), investAmountProfit, 7, 1, BigDecimal.ZERO, null,dappSystemProfitNow.getId());
        dappFundFlowDao.insert(fundFlowOut);
        //发送转币消息
        chainProducer.sendBnbTransferMsg(fundFlowOut.getId());
        //复投 成功{type: 1, txHash: result.transactionHash, id: res.data, flag: 'success', buyType: 2}
        DataDictionaryCustom investAmountSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.INVEST_AMOUNT.getType(), DataDictionaryEnum.INVEST_AMOUNT.getCode());
        BigDecimal investAmount = new BigDecimal(investAmountSet.getValue());
        //todo 直接运行转账
        String txHash = "复投";
        DappFundFlowEntity fundFlow = new DappFundFlowEntity(dappSystemProfitNow.getMemberId(), investAmount, 6, 1, BigDecimal.ZERO, txHash);
        dappFundFlowDao.insert(fundFlow);
        TransferDto transferDto = new TransferDto();
        transferDto.setType(1);
        transferDto.setTxHash(txHash);
        transferDto.setBuyType(2);
        transferDto.setId(fundFlow.getId());
        transferDto.setFlag("success");
        transferDto.setAmount(investAmount);
        transferDto.setMemberId(dappSystemProfitNow.getMemberId());
        dappWalletService.transferAgain(transferDto);
//        DappSystemProfit systemProfit = dappSystemProfitDao.selectById(id);
//        if(ObjectUtil.isEmpty(systemProfit)){
//            return;
//        }
//        //获取当前是第几轮队列
//        String redisKey = "QUEUE_COUNT";
//        String memberOutCount = redisUtils.getString(redisKey);
//        DataDictionaryCustom queueCountSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.QUEUE_COUNT.getType(), DataDictionaryEnum.QUEUE_COUNT.getCode());
//        String queueCount = queueCountSet.getValue();
//        if(StrUtil.isBlank(memberOutCount) || !queueCount.equals(memberOutCount)){
//            redisUtils.set(redisKey,queueCount,0L);
//            memberOutCount = queueCount;
//        }
//        //出局条件的人数
//        /**
//         * 初始大小 5+4*0
//         * 1  1,2,3,4,5  1出局 5+4*0
//         * 2  2,3,4,5,1(复投),7,8,9,10  2出局 5+4*1
//         * 3  3,4,5,1(复投),7,8,9,10,2(复投),12,13,14,15 3出局 5+4*2
//         * 4  4,5,1(复投),7,8,9,10,2(复投),12,13,14,15,3(复投),17,18,19,20  4出局 5+4*3
//         */
//        Integer memberCount = Integer.parseInt(memberOutCount) * 4 + 5;
//        //判断当前是否符合出局条件
//        QueryWrapper<DappSystemProfit> objectQueryWrapper = new QueryWrapper<>();
//        objectQueryWrapper.eq("state",DappSystemProfit.STATE_IN);
//        //实际投资人数
//        Integer selectCount = dappSystemProfitDao.selectCount(objectQueryWrapper);
//        //实际投资人数小于出局条件人数
//        if(selectCount < memberCount){
//            return;
//        }
//        //符合则出局 实际投资人数等于出局条件人数
//        DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectSystemProfitByState(DappSystemProfit.STATE_IN);
//        if(ObjectUtil.isEmpty(dappSystemProfit)){
//            return;
//        }
//        //符合则出局,轮数+1
//        Integer realCount = (Integer.parseInt(queueCount) + 1);
//        queueCountSet.setValue(realCount.toString());
//        dataDictionaryCustomMapper.updateById(queueCountSet);
//        redisUtils.set(redisKey,realCount,0L);
//
//        DappSystemProfit dappSystemProfitNow = dappSystemProfitDao.selectByIdForUpdate(dappSystemProfit.getId(),DappSystemProfit.STATE_IN);
//        dappSystemProfitDao.updateStateById(DappSystemProfit.STATE_OUT,dappSystemProfitNow.getId());
//
//        // 直接拿走0.95ge
//
//        DataDictionaryCustom investAmountProfitSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.INVEST_AMOUNT_PROFIT.getType(), DataDictionaryEnum.INVEST_AMOUNT_PROFIT.getCode());
//        BigDecimal investAmountProfit = new BigDecimal(investAmountProfitSet.getValue());
//        DappFundFlowEntity fundFlowOut = new DappFundFlowEntity(dappSystemProfitNow.getMemberId(), investAmountProfit, 7, 1, BigDecimal.ZERO, null,dappSystemProfitNow.getId());
//        dappFundFlowDao.insert(fundFlowOut);
//        //发送转币消息
//        chainProducer.sendBnbTransferMsg(fundFlowOut.getId());
//        //复投 成功{type: 1, txHash: result.transactionHash, id: res.data, flag: 'success', buyType: 2}
//        DataDictionaryCustom investAmountSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.INVEST_AMOUNT.getType(), DataDictionaryEnum.INVEST_AMOUNT.getCode());
//        BigDecimal investAmount = new BigDecimal(investAmountSet.getValue());
//        //todo 直接运行转账
//        String txHash = "复投";
//        DappFundFlowEntity fundFlow = new DappFundFlowEntity(dappSystemProfitNow.getMemberId(), investAmount, 6, 1, BigDecimal.ZERO, txHash);
//        dappFundFlowDao.insert(fundFlow);
//
//        TransferDto transferDto = new TransferDto();
//        transferDto.setType(1);
//        transferDto.setTxHash(txHash);
//        transferDto.setBuyType(2);
//        transferDto.setId(fundFlow.getId());
//        transferDto.setFlag("success");
//        transferDto.setAmount(investAmount);
//        transferDto.setMemberId(dappSystemProfitNow.getMemberId());
//        dappWalletService.transferAgain(transferDto);
    }
    @Override
@@ -411,62 +411,62 @@
    @Override
    public void agentUp(Long id) {
        //根据邀请码获取用户信息
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(id);
        if(ObjectUtil.isEmpty(dappMemberEntity)){
            return;
        }
        //所有上级(不包含直属上级)
        String refererIds = dappMemberEntity.getRefererIds();
        List<String> refererIdList = StrUtil.split(refererIds, ',');
        if(CollUtil.isNotEmpty(refererIdList)){
            for(String inviteIdStr : refererIdList){
                DappMemberEntity dappMemberEntityUp = dappMemberDao.selectMemberInfoByInviteId(inviteIdStr);
                if(ObjectUtil.isEmpty(dappMemberEntityUp)){
                    continue;
                }
                String accountType = dappMemberEntityUp.getAccountType();
                if(DataDictionaryEnum.BIG_BOSS.getCode().equals(accountType)){
                    continue;
                }
                //当前为BOSS,且直推中有两个BOSS以上,则升级BIG_BOSS
                if(DataDictionaryEnum.BOSS.getCode().equals(accountType)){
                    Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(DataDictionaryEnum.BOSS.getCode(),dappMemberEntityUp.getInviteId());
                    if(2 <= bossCount){
                        dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BIG_BOSS.getCode(),dappMemberEntityUp.getId());
                    }
                    continue;
                }
                //当前为AGENT,且直推中有两个以上,则升级BOSS
                if(DataDictionaryEnum.AGENT.getCode().equals(accountType)){
                    Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(null,dappMemberEntityUp.getInviteId());
                    if(2 <= bossCount){
                        dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BOSS.getCode(),dappMemberEntityUp.getId());
                    }
                    continue;
                }
            }
        }
        //直属上级
        String accountType = dappMemberEntity.getAccountType();
        if(DataDictionaryEnum.BIG_BOSS.getCode().equals(accountType)){
            return;
        }
        //当前为BOSS,且直推中有两个BOSS以上,则升级BIG_BOSS
        if(DataDictionaryEnum.BOSS.getCode().equals(accountType)){
            Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(DataDictionaryEnum.BOSS.getCode(),dappMemberEntity.getInviteId());
            if(2 <= bossCount){
                dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BIG_BOSS.getCode(),dappMemberEntity.getId());
            }
            return;
        }
        //当前为AGENT,且直推中有两个以上,则升级BOSS
        if(DataDictionaryEnum.AGENT.getCode().equals(accountType)){
            Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(null,dappMemberEntity.getInviteId());
            if(2 <= bossCount){
                dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BOSS.getCode(),dappMemberEntity.getId());
            }
            return;
        }
//        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(id);
//        if(ObjectUtil.isEmpty(dappMemberEntity)){
//            return;
//        }
//        //所有上级(不包含直属上级)
//        String refererIds = dappMemberEntity.getRefererIds();
//        List<String> refererIdList = StrUtil.split(refererIds, ',');
//        if(CollUtil.isNotEmpty(refererIdList)){
//            for(String inviteIdStr : refererIdList){
//                DappMemberEntity dappMemberEntityUp = dappMemberDao.selectMemberInfoByInviteId(inviteIdStr);
//                if(ObjectUtil.isEmpty(dappMemberEntityUp)){
//                    continue;
//                }
//                String accountType = dappMemberEntityUp.getAccountType();
//                if(DataDictionaryEnum.BIG_BOSS.getCode().equals(accountType)){
//                    continue;
//                }
//                //当前为BOSS,且直推中有两个BOSS以上,则升级BIG_BOSS
//                if(DataDictionaryEnum.BOSS.getCode().equals(accountType)){
//                    Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(DataDictionaryEnum.BOSS.getCode(),dappMemberEntityUp.getInviteId());
//                    if(2 <= bossCount){
//                        dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BIG_BOSS.getCode(),dappMemberEntityUp.getId());
//                    }
//                    continue;
//                }
//                //当前为AGENT,且直推中有两个以上,则升级BOSS
//                if(DataDictionaryEnum.AGENT.getCode().equals(accountType)){
//                    Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(null,dappMemberEntityUp.getInviteId());
//                    if(2 <= bossCount){
//                        dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BOSS.getCode(),dappMemberEntityUp.getId());
//                    }
//                    continue;
//                }
//            }
//        }
//        //直属上级
//        String accountType = dappMemberEntity.getAccountType();
//        if(DataDictionaryEnum.BIG_BOSS.getCode().equals(accountType)){
//            return;
//        }
//        //当前为BOSS,且直推中有两个BOSS以上,则升级BIG_BOSS
//        if(DataDictionaryEnum.BOSS.getCode().equals(accountType)){
//            Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(DataDictionaryEnum.BOSS.getCode(),dappMemberEntity.getInviteId());
//            if(2 <= bossCount){
//                dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BIG_BOSS.getCode(),dappMemberEntity.getId());
//            }
//            return;
//        }
//        //当前为AGENT,且直推中有两个以上,则升级BOSS
//        if(DataDictionaryEnum.AGENT.getCode().equals(accountType)){
//            Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(null,dappMemberEntity.getInviteId());
//            if(2 <= bossCount){
//                dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BOSS.getCode(),dappMemberEntity.getId());
//            }
//            return;
//        }
    }
    @Override
@@ -503,406 +503,406 @@
    @Override
    public void AntACoinInMsg(Long id) {
        /**
         * 获取对应的流水记录
         */
        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(id);
        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
            return;
        }
        Long memberId = dappFundFlowEntity.getMemberId();
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
        if(ObjectUtil.isEmpty(dappMemberEntity)){
            return;
        }
        /**
         * 会员充值金额
         */
        BigDecimal amount = dappFundFlowEntity.getAmount();
        /**
         * A币的当前价格
         */
        DataDictionaryCustom coinAPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_PRICE.getType(),
                PoolEnum.COIN_A_PRICE.getCode()
        );
        BigDecimal coinAPrice = new BigDecimal(StrUtil.isEmpty(coinAPriceDic.getValue()) ? "0" : coinAPriceDic.getValue()).setScale(12,BigDecimal.ROUND_DOWN);
        /**
         * 会员充值USDT买入A币记录的ID
         */
        Long chergeRecordId = dappFundFlowEntity.getSystemProfitId();
        DappChargeUsdtEntity dappChargeUsdtEntity = dappChargeUsdtMapper.selectById(chergeRecordId);
        if(2 != dappChargeUsdtEntity.getStatus()){
            return;
        }
        if(StrUtil.isEmpty(dappChargeUsdtEntity.getMemberHash())){
            return;
        }
        /**
         * 金本位的三倍额度,增加业绩,增加对应的NFT的值
         */
        DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId);
        if(ObjectUtil.isEmpty(dappUsdtPerkEntity)){
            dappUsdtPerkEntity = new DappUsdtPerkEntity();
            dappUsdtPerkEntity.setAmount(amount.multiply(new BigDecimal(3)));
            dappUsdtPerkEntity.setNftDevote(amount);
            dappUsdtPerkEntity.setMemberId(memberId);
            dappUsdtPerkEntityMapper.insert(dappUsdtPerkEntity);
        }
        //金本位的三倍额度
        BigDecimal amountPerk = dappUsdtPerkEntity.getAmount();
        amountPerk = amountPerk.add(amount.multiply(new BigDecimal(3)));
        dappUsdtPerkEntity.setAmount(amountPerk);
        //生成一条金本位的三倍额度的资金流水记录
        DappFundFlowEntity amountPerkFundFlow = new DappFundFlowEntity(
                memberId,
                amount.multiply(new BigDecimal(3)),
                FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(amountPerkFundFlow);
        //增加业绩
        BigDecimal achieveAmount = dappUsdtPerkEntity.getAchieveAmount();
        achieveAmount = achieveAmount.add(amount);
        dappUsdtPerkEntity.setAchieveAmount(achieveAmount);
        //增加对应的NFT的值
        BigDecimal nftDevote = dappUsdtPerkEntity.getNftDevote();
        nftDevote = nftDevote.add(amount);
        dappUsdtPerkEntity.setNftDevote(nftDevote);
        dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity);
        /**
         * 90%进入A币底池 10%进入B币LP薄饼底池
         */
        DataDictionaryCustom usdtAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.USDT_A_PERCENT.getType(),
                PoolEnum.USDT_A_PERCENT.getCode()
        );
        BigDecimal usdtAPercent = new BigDecimal(StrUtil.isEmpty(usdtAPercentDic.getValue()) ? "0.7" : usdtAPercentDic.getValue());
        BigDecimal usdtAAmount = amount.multiply(usdtAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        //生成一条进行中的70%进入A币底池的资金流水记录
        DappFundFlowEntity fundFlowToA = new DappFundFlowEntity(
                1L,
                usdtAAmount,
                FundFlowEnum.USDT_IN_A_POOL.getCode(),
                1,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(fundFlowToA);
        //90%进入A币底池
        chainProducer.sendAntACoinInAPoolMsg(fundFlowToA.getId());
        BigDecimal usdtWAmount = amount.multiply(new BigDecimal(0.2)).setScale(4, BigDecimal.ROUND_DOWN);
        //生成一条进行中的20%进入A币底池的资金流水记录
        DappFundFlowEntity fundFlowToW = new DappFundFlowEntity(
                1L,
                usdtWAmount,
                FundFlowEnum.USDT_IN_W_POOL.getCode(),
                1,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(fundFlowToW);
        DataDictionaryCustom usdtBPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.USDT_B_PERCENT.getType(),
                PoolEnum.USDT_B_PERCENT.getCode()
        );
        BigDecimal usdtBPercent = new BigDecimal(StrUtil.isEmpty(usdtBPercentDic.getValue()) ? "0.1" : usdtBPercentDic.getValue());
        BigDecimal usdtBAmount = amount.multiply(usdtBPercent).setScale(4, BigDecimal.ROUND_DOWN);
        //生成一条进行中的10%进入B币底池的资金流水记录
        DappFundFlowEntity fundFlowToB = new DappFundFlowEntity(
                1L,
                usdtBAmount,
                FundFlowEnum.USDT_IN_B_POOL.getCode(),
                1,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(fundFlowToB);
        //10%进入B币LP薄饼底池
        chainProducer.sendAntACoinInBPoolMsg(fundFlowToB.getId());
        /**
         * 1.90%底池的USDT做成100%溢价,铸造出70%金本位价值的A币。
         */
        DataDictionaryCustom produceAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.PRODUCE_A_PERCENT.getType(),
                PoolEnum.PRODUCE_A_PERCENT.getCode()
        );
        BigDecimal produceAPercent = new BigDecimal(StrUtil.isEmpty(produceAPercentDic.getValue()) ? "0.7" : produceAPercentDic.getValue());
        //购买数量
        BigDecimal totalCnt = amount.divide(coinAPrice, 4, BigDecimal.ROUND_DOWN);
        /**
         * 铸造出70%金本位价值的A币。实际产生数量
         */
        BigDecimal realCnt = totalCnt.multiply(produceAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        dappChargeUsdtEntity.setTotalCnt(totalCnt);
        dappChargeUsdtEntity.setRealCnt(realCnt);
        dappChargeUsdtMapper.updateById(dappChargeUsdtEntity);
        /**
         * 重新计算A币的价格
         */
        DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_CNT.getType(),
                PoolEnum.COIN_A_CNT.getCode()
        );
        //A币币本位底池-A币的数量
        BigDecimal coinACntDicCnt = new BigDecimal(coinACntDic.getValue());
        coinACntDicCnt = coinACntDicCnt.add(realCnt);
        coinACntDic.setValue(coinACntDicCnt.toString());
        dataDictionaryCustomMapper.updateById(coinACntDic);
        DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_USDT_PRICE.getType(),
                PoolEnum.COIN_A_USDT_PRICE.getCode()
        );
        //A币金本位底池-usdt数量
        BigDecimal coinAUsdtPriceDicCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
        coinAUsdtPriceDicCnt = coinAUsdtPriceDicCnt.add(amount);
        coinAUsdtPriceDic.setValue(coinAUsdtPriceDicCnt.toString());
        dataDictionaryCustomMapper.updateById(coinAUsdtPriceDic);
        BigDecimal divide = coinAUsdtPriceDicCnt.divide(coinACntDicCnt, 12, BigDecimal.ROUND_DOWN);
        coinAPriceDic.setValue(divide.toString());
        dataDictionaryCustomMapper.updateById(coinAPriceDic);
        chainProducer.sendAntKLineMsg(0);
        /**
         * A币的分配 walletMine
         * 【70%换算100%分配】
         * 50%客户秒到
         * 20%全网加权分红(按20%释放递减)
         * 10%直推
         * 5%节点
         * 5%基金会
         * 10%级差奖
         */
        /**
         * 50%客户秒到
         */
        DataDictionaryCustom memberGetAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.MEMBER_GET_A_PERCENT.getType(),
                PoolEnum.MEMBER_GET_A_PERCENT.getCode()
        );
        BigDecimal memberGetAPercent = new BigDecimal(StrUtil.isEmpty(memberGetAPercentDic.getValue()) ? "0.5" : memberGetAPercentDic.getValue());
        BigDecimal memberGetACnt = realCnt.multiply(memberGetAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        BigDecimal fundFlowToMemberFlag = this.getAndUpdateMemberPerk(dappFundFlowEntity.getMemberId(), memberGetACnt);
        if(fundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){
            //生成一条50%客户秒到的资金流水记录
            DappFundFlowEntity fundFlowToMember = new DappFundFlowEntity(
                    dappFundFlowEntity.getMemberId(),
                    fundFlowToMemberFlag,
                    FundFlowEnum.MEMBER_GET_A_CNT.getCode(),
                    2,
                    BigDecimal.ZERO,
                    null,
                    chergeRecordId);
            dappFundFlowDao.insert(fundFlowToMember);
            //用户的A币账户增加memberGetACnt数量
            dappWalletService.updateWalletMineWithLock(fundFlowToMemberFlag,dappFundFlowEntity.getMemberId(),1);
        }
        /**
         * 20%全网加权分红(按20%释放递减)进入加权分红底池
         */
        DataDictionaryCustom poolAllMemberAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getType(),
                PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getCode()
        );
        BigDecimal poolAllMemberAPercent = new BigDecimal(StrUtil.isEmpty(poolAllMemberAPercentDic.getValue()) ? "0.2" : poolAllMemberAPercentDic.getValue());
        BigDecimal poolAllMemberAPercentCnt = realCnt.multiply(poolAllMemberAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        DataDictionaryCustom poolAllMemberACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.POOL_ALL_MEMBER_A_CNT.getType(),
                PoolEnum.POOL_ALL_MEMBER_A_CNT.getCode()
        );
        BigDecimal poolAllMemberACnt = new BigDecimal(StrUtil.isEmpty(poolAllMemberACntDic.getValue()) ? "0" : poolAllMemberACntDic.getValue());
        poolAllMemberACnt = poolAllMemberACnt.add(poolAllMemberAPercentCnt);
        poolAllMemberACntDic.setValue(poolAllMemberACnt.toString());
        dataDictionaryCustomMapper.updateById(poolAllMemberACntDic);
        //生成一条20%全网加权分红(按20%释放递减)进入加权分红底池的资金流水记录
        DappFundFlowEntity poolAllMemberAFundFlow = new DappFundFlowEntity(
                1L,
                poolAllMemberAPercentCnt,
                FundFlowEnum.POOL_ALL_MEMBER_A_CNT.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(poolAllMemberAFundFlow);
//        BigDecimal poolAllMemberAPercentCntAva = nodePoolPerk(poolAllMemberAPercentCnt, MemberLevelEnum.MEMBER.getType(), FundFlowEnum.POOL_MEMBER_A_CNT.getCode());
        /**
         * 20%全网加权平分,按照个人投资占比全网的比例去平分
         */
        chainProducer.sendAllMemberPerkAvaMsg(poolAllMemberAFundFlow.getId());
//        BigDecimal poolAllMemberAPercentCntAva = allMemberPerk(poolAllMemberAPercentCnt, FundFlowEnum.POOL_MEMBER_A_CNT.getCode());
//        DappFundFlowEntity poolAllMemberAFundFlowAva = new DappFundFlowEntity(
//                1L,
//                poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva),
//                FundFlowEnum.POOL_MEMBER_A_CNT.getCode(),
//        /**
//         * 获取对应的流水记录
//         */
//        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(id);
//        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
//            return;
//        }
//        Long memberId = dappFundFlowEntity.getMemberId();
//        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
//        if(ObjectUtil.isEmpty(dappMemberEntity)){
//            return;
//        }
//        /**
//         * 会员充值金额
//         */
//        BigDecimal amount = dappFundFlowEntity.getAmount();
//        /**
//         * A币的当前价格
//         */
//        DataDictionaryCustom coinAPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.COIN_A_PRICE.getType(),
//                PoolEnum.COIN_A_PRICE.getCode()
//        );
//        BigDecimal coinAPrice = new BigDecimal(StrUtil.isEmpty(coinAPriceDic.getValue()) ? "0" : coinAPriceDic.getValue()).setScale(12,BigDecimal.ROUND_DOWN);
//        /**
//         * 会员充值USDT买入A币记录的ID
//         */
//        Long chergeRecordId = dappFundFlowEntity.getSystemProfitId();
//        DappChargeUsdtEntity dappChargeUsdtEntity = dappChargeUsdtMapper.selectById(chergeRecordId);
//        if(2 != dappChargeUsdtEntity.getStatus()){
//            return;
//        }
//        if(StrUtil.isEmpty(dappChargeUsdtEntity.getMemberHash())){
//            return;
//        }
//        /**
//         * 金本位的三倍额度,增加业绩,增加对应的NFT的值
//         */
//        DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId);
//        if(ObjectUtil.isEmpty(dappUsdtPerkEntity)){
//            dappUsdtPerkEntity = new DappUsdtPerkEntity();
//            dappUsdtPerkEntity.setAmount(amount.multiply(new BigDecimal(3)));
//            dappUsdtPerkEntity.setNftDevote(amount);
//            dappUsdtPerkEntity.setMemberId(memberId);
//            dappUsdtPerkEntityMapper.insert(dappUsdtPerkEntity);
//        }
//        //金本位的三倍额度
//        BigDecimal amountPerk = dappUsdtPerkEntity.getAmount();
//        amountPerk = amountPerk.add(amount.multiply(new BigDecimal(3)));
//        dappUsdtPerkEntity.setAmount(amountPerk);
//        //生成一条金本位的三倍额度的资金流水记录
//        DappFundFlowEntity amountPerkFundFlow = new DappFundFlowEntity(
//                memberId,
//                amount.multiply(new BigDecimal(3)),
//                FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(poolAllMemberAFundFlowAva);
//        dappWalletService.updateWalletMineWithLock(poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva),
//                1L,1);
        /**
         * 10%直推
         */
        DataDictionaryCustom directAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.DIRECT_A_PERCENT.getType(),
                PoolEnum.DIRECT_A_PERCENT.getCode()
        );
        BigDecimal directAPercent = new BigDecimal(StrUtil.isEmpty(directAPercentDic.getValue()) ? "0.1" : directAPercentDic.getValue());
        BigDecimal directAPercentCnt = realCnt.multiply(directAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        String refererId = dappMemberEntity.getRefererId();
        DappMemberEntity directMemberEntity = dappMemberDao.selectMemberInfoByInviteId(refererId);
        if(ObjectUtil.isNotEmpty(directMemberEntity)){
            /**
             *推荐用户入单可享有贡献值.例.推荐100获得100贡献值
             */
            DappUsdtPerkEntity directDappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(directMemberEntity.getId());
            if(ObjectUtil.isEmpty(directDappUsdtPerkEntity)){
                directDappUsdtPerkEntity = new DappUsdtPerkEntity();
                directDappUsdtPerkEntity.setNftDevote(amount);
                directDappUsdtPerkEntity.setMemberId(directMemberEntity.getId());
                dappUsdtPerkEntityMapper.insert(directDappUsdtPerkEntity);
            }
            BigDecimal directNftDevote = directDappUsdtPerkEntity.getNftDevote();
            directNftDevote = directNftDevote.add(amount);
            directDappUsdtPerkEntity.setNftDevote(directNftDevote);
            dappUsdtPerkEntityMapper.updateById(directDappUsdtPerkEntity);
            BigDecimal directAPercentFundFlowToMemberFlag = this.getAndUpdateMemberPerk(directMemberEntity.getId(), directAPercentCnt);
            if(directAPercentFundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){
                //生成一条10%直推的资金流水记录
                DappFundFlowEntity directAPercentFundFlowToMember = new DappFundFlowEntity(
                        directMemberEntity.getId(),
                        directAPercentFundFlowToMemberFlag,
                        FundFlowEnum.DIRECT_A_PERCENT.getCode(),
                        2,
                        BigDecimal.ZERO,
                        null,
                        chergeRecordId);
                dappFundFlowDao.insert(directAPercentFundFlowToMember);
                //用户的A币账户增加directAPercentCnt数量
                dappWalletService.updateWalletMineWithLock(directAPercentFundFlowToMemberFlag,directMemberEntity.getId(),1);
            }
            if(directAPercentCnt.compareTo(directAPercentFundFlowToMemberFlag) > 0){
                DappFundFlowEntity directAPercentFundFlowToMemberAva = new DappFundFlowEntity(
                        1L,
                        directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag),
                        FundFlowEnum.DIRECT_A_PERCENT.getCode(),
                        2,
                        BigDecimal.ZERO,
                        null,
                        chergeRecordId);
                dappFundFlowDao.insert(directAPercentFundFlowToMemberAva);
                dappWalletService.updateWalletMineWithLock(directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag),
                        AppContants.YL_MEMBER_ID,1);
            }
        }
        /**
         * 5%节点
         */
        DataDictionaryCustom nodeAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_A_PERCENT.getType(),
                PoolEnum.NODE_A_PERCENT.getCode()
        );
        BigDecimal nodeAPercent = new BigDecimal(StrUtil.isEmpty(nodeAPercentDic.getValue()) ? "0.05" : nodeAPercentDic.getValue());
        BigDecimal nodeAPercentCnt = realCnt.multiply(nodeAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        //生成一条5%节点的资金流水记录
        DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity(
                1L,
                nodeAPercentCnt,
                FundFlowEnum.NODE_A_PERCENT.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(nodeAPercentFundFlow);
//        chainProducer.sendAntACoinInNodeMsg(nodeAPercentFundFlow.getId());
        DataDictionaryCustom nodeAPercentPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_A_PERCENT_POOL.getType(),
                PoolEnum.NODE_A_PERCENT_POOL.getCode()
        );
        BigDecimal nodeAPercentPoolDicCnt = new BigDecimal(StrUtil.isEmpty(nodeAPercentPoolDic.getValue()) ? "0" : nodeAPercentPoolDic.getValue());
        nodeAPercentPoolDicCnt = nodeAPercentPoolDicCnt.add(nodeAPercentCnt);
        nodeAPercentPoolDic.setValue(nodeAPercentPoolDicCnt.toString());
        dataDictionaryCustomMapper.updateById(nodeAPercentPoolDic);
        BigDecimal nodeAPercentCntAva = superNodePoolPerk(nodeAPercentCnt, NodeCodeEnum.SUPER_NODE.getCode(), FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode());
        if(nodeAPercentCnt.compareTo(nodeAPercentCntAva) > 0){
            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
                    1L,
                    nodeAPercentCnt.subtract(nodeAPercentCntAva),
                    FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(),
                    2,
                    BigDecimal.ZERO,
                    null,
                    chergeRecordId);
            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
            dappWalletService.updateWalletMineWithLock(nodeAPercentCnt.subtract(nodeAPercentCntAva),
                    AppContants.YL_MEMBER_ID,1);
        }
        /**
         * 5%基金会
         */
        DataDictionaryCustom foundationAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.FOUNDATION_A_PERCENT.getType(),
                PoolEnum.FOUNDATION_A_PERCENT.getCode()
        );
        BigDecimal foundationAPercent = new BigDecimal(StrUtil.isEmpty(foundationAPercentDic.getValue()) ? "0.05" : foundationAPercentDic.getValue());
        BigDecimal foundationAPercentCnt = realCnt.multiply(foundationAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        //生成一条5%基金会的资金流水记录
        DappFundFlowEntity foundationAPercentFundFlow = new DappFundFlowEntity(
                295L,
                foundationAPercentCnt,
                FundFlowEnum.FOUNDATION_A_PERCENT.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(foundationAPercentFundFlow);
        //用户的A币账户增加memberGetACnt数量
        dappWalletService.updateWalletMineWithLock(foundationAPercentCnt,295L,1);
        /**
         * 10%级差奖
         */
        DataDictionaryCustom levelAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.LEVEL_A_PERCENT.getType(),
                PoolEnum.LEVEL_A_PERCENT.getCode()
        );
        BigDecimal levelAPercent = new BigDecimal(StrUtil.isEmpty(levelAPercentDic.getValue()) ? "0.1" : levelAPercentDic.getValue());
        BigDecimal levelAPercentCnt = realCnt.multiply(levelAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        //生成一条10%级差奖进入10%级差奖底池的资金流水记录
        DappFundFlowEntity levelAPercentCntFundFlow = new DappFundFlowEntity(
                1L,
                levelAPercentCnt,
                FundFlowEnum.LEVEL_A_PERCENT_CNT.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(levelAPercentCntFundFlow);
        chainProducer.sendAntACoinInLevelMsg(levelAPercentCntFundFlow.getId());
        /**
         * 更新用户为有效用户
         */
        dappMemberDao.updateMemberActiveStatus(1,memberId);
//        dappFundFlowDao.insert(amountPerkFundFlow);
//
//        //增加业绩
//        BigDecimal achieveAmount = dappUsdtPerkEntity.getAchieveAmount();
//        achieveAmount = achieveAmount.add(amount);
//        dappUsdtPerkEntity.setAchieveAmount(achieveAmount);
//        //增加对应的NFT的值
//        BigDecimal nftDevote = dappUsdtPerkEntity.getNftDevote();
//        nftDevote = nftDevote.add(amount);
//        dappUsdtPerkEntity.setNftDevote(nftDevote);
//        dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity);
//        /**
//         * 90%进入A币底池 10%进入B币LP薄饼底池
//         */
//        DataDictionaryCustom usdtAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.USDT_A_PERCENT.getType(),
//                PoolEnum.USDT_A_PERCENT.getCode()
//        );
//        BigDecimal usdtAPercent = new BigDecimal(StrUtil.isEmpty(usdtAPercentDic.getValue()) ? "0.7" : usdtAPercentDic.getValue());
//        BigDecimal usdtAAmount = amount.multiply(usdtAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        //生成一条进行中的70%进入A币底池的资金流水记录
//        DappFundFlowEntity fundFlowToA = new DappFundFlowEntity(
//                1L,
//                usdtAAmount,
//                FundFlowEnum.USDT_IN_A_POOL.getCode(),
//                1,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(fundFlowToA);
//        //90%进入A币底池
//        chainProducer.sendAntACoinInAPoolMsg(fundFlowToA.getId());
//
//        BigDecimal usdtWAmount = amount.multiply(new BigDecimal(0.2)).setScale(4, BigDecimal.ROUND_DOWN);
//        //生成一条进行中的20%进入A币底池的资金流水记录
//        DappFundFlowEntity fundFlowToW = new DappFundFlowEntity(
//                1L,
//                usdtWAmount,
//                FundFlowEnum.USDT_IN_W_POOL.getCode(),
//                1,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(fundFlowToW);
//
//        DataDictionaryCustom usdtBPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.USDT_B_PERCENT.getType(),
//                PoolEnum.USDT_B_PERCENT.getCode()
//        );
//        BigDecimal usdtBPercent = new BigDecimal(StrUtil.isEmpty(usdtBPercentDic.getValue()) ? "0.1" : usdtBPercentDic.getValue());
//        BigDecimal usdtBAmount = amount.multiply(usdtBPercent).setScale(4, BigDecimal.ROUND_DOWN);
//        //生成一条进行中的10%进入B币底池的资金流水记录
//        DappFundFlowEntity fundFlowToB = new DappFundFlowEntity(
//                1L,
//                usdtBAmount,
//                FundFlowEnum.USDT_IN_B_POOL.getCode(),
//                1,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(fundFlowToB);
//        //10%进入B币LP薄饼底池
//        chainProducer.sendAntACoinInBPoolMsg(fundFlowToB.getId());
//        /**
//         * 1.90%底池的USDT做成100%溢价,铸造出70%金本位价值的A币。
//         */
//        DataDictionaryCustom produceAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.PRODUCE_A_PERCENT.getType(),
//                PoolEnum.PRODUCE_A_PERCENT.getCode()
//        );
//        BigDecimal produceAPercent = new BigDecimal(StrUtil.isEmpty(produceAPercentDic.getValue()) ? "0.7" : produceAPercentDic.getValue());
//        //购买数量
//        BigDecimal totalCnt = amount.divide(coinAPrice, 4, BigDecimal.ROUND_DOWN);
//        /**
//         * 铸造出70%金本位价值的A币。实际产生数量
//         */
//        BigDecimal realCnt = totalCnt.multiply(produceAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//        dappChargeUsdtEntity.setTotalCnt(totalCnt);
//        dappChargeUsdtEntity.setRealCnt(realCnt);
//        dappChargeUsdtMapper.updateById(dappChargeUsdtEntity);
//        /**
//         * 重新计算A币的价格
//         */
//        DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.COIN_A_CNT.getType(),
//                PoolEnum.COIN_A_CNT.getCode()
//        );
//        //A币币本位底池-A币的数量
//        BigDecimal coinACntDicCnt = new BigDecimal(coinACntDic.getValue());
//        coinACntDicCnt = coinACntDicCnt.add(realCnt);
//        coinACntDic.setValue(coinACntDicCnt.toString());
//        dataDictionaryCustomMapper.updateById(coinACntDic);
//
//        DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.COIN_A_USDT_PRICE.getType(),
//                PoolEnum.COIN_A_USDT_PRICE.getCode()
//        );
//        //A币金本位底池-usdt数量
//        BigDecimal coinAUsdtPriceDicCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
//        coinAUsdtPriceDicCnt = coinAUsdtPriceDicCnt.add(amount);
//        coinAUsdtPriceDic.setValue(coinAUsdtPriceDicCnt.toString());
//        dataDictionaryCustomMapper.updateById(coinAUsdtPriceDic);
//
//        BigDecimal divide = coinAUsdtPriceDicCnt.divide(coinACntDicCnt, 12, BigDecimal.ROUND_DOWN);
//        coinAPriceDic.setValue(divide.toString());
//        dataDictionaryCustomMapper.updateById(coinAPriceDic);
//
//        chainProducer.sendAntKLineMsg(0);
//        /**
//         * A币的分配 walletMine
//         * 【70%换算100%分配】
//         * 50%客户秒到
//         * 20%全网加权分红(按20%释放递减)
//         * 10%直推
//         * 5%节点
//         * 5%基金会
//         * 10%级差奖
//         */
//        /**
//         * 50%客户秒到
//         */
//        DataDictionaryCustom memberGetAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.MEMBER_GET_A_PERCENT.getType(),
//                PoolEnum.MEMBER_GET_A_PERCENT.getCode()
//        );
//        BigDecimal memberGetAPercent = new BigDecimal(StrUtil.isEmpty(memberGetAPercentDic.getValue()) ? "0.5" : memberGetAPercentDic.getValue());
//        BigDecimal memberGetACnt = realCnt.multiply(memberGetAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        BigDecimal fundFlowToMemberFlag = this.getAndUpdateMemberPerk(dappFundFlowEntity.getMemberId(), memberGetACnt);
//        if(fundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){
//            //生成一条50%客户秒到的资金流水记录
//            DappFundFlowEntity fundFlowToMember = new DappFundFlowEntity(
//                    dappFundFlowEntity.getMemberId(),
//                    fundFlowToMemberFlag,
//                    FundFlowEnum.MEMBER_GET_A_CNT.getCode(),
//                    2,
//                    BigDecimal.ZERO,
//                    null,
//                    chergeRecordId);
//            dappFundFlowDao.insert(fundFlowToMember);
//            //用户的A币账户增加memberGetACnt数量
//            dappWalletService.updateWalletMineWithLock(fundFlowToMemberFlag,dappFundFlowEntity.getMemberId(),1);
//        }
//        /**
//         * 20%全网加权分红(按20%释放递减)进入加权分红底池
//         */
//        DataDictionaryCustom poolAllMemberAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getType(),
//                PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getCode()
//        );
//        BigDecimal poolAllMemberAPercent = new BigDecimal(StrUtil.isEmpty(poolAllMemberAPercentDic.getValue()) ? "0.2" : poolAllMemberAPercentDic.getValue());
//        BigDecimal poolAllMemberAPercentCnt = realCnt.multiply(poolAllMemberAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        DataDictionaryCustom poolAllMemberACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.POOL_ALL_MEMBER_A_CNT.getType(),
//                PoolEnum.POOL_ALL_MEMBER_A_CNT.getCode()
//        );
//        BigDecimal poolAllMemberACnt = new BigDecimal(StrUtil.isEmpty(poolAllMemberACntDic.getValue()) ? "0" : poolAllMemberACntDic.getValue());
//        poolAllMemberACnt = poolAllMemberACnt.add(poolAllMemberAPercentCnt);
//        poolAllMemberACntDic.setValue(poolAllMemberACnt.toString());
//        dataDictionaryCustomMapper.updateById(poolAllMemberACntDic);
//        //生成一条20%全网加权分红(按20%释放递减)进入加权分红底池的资金流水记录
//        DappFundFlowEntity poolAllMemberAFundFlow = new DappFundFlowEntity(
//                1L,
//                poolAllMemberAPercentCnt,
//                FundFlowEnum.POOL_ALL_MEMBER_A_CNT.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(poolAllMemberAFundFlow);
//
////        BigDecimal poolAllMemberAPercentCntAva = nodePoolPerk(poolAllMemberAPercentCnt, MemberLevelEnum.MEMBER.getType(), FundFlowEnum.POOL_MEMBER_A_CNT.getCode());
//        /**
//         * 20%全网加权平分,按照个人投资占比全网的比例去平分
//         */
//        chainProducer.sendAllMemberPerkAvaMsg(poolAllMemberAFundFlow.getId());
////        BigDecimal poolAllMemberAPercentCntAva = allMemberPerk(poolAllMemberAPercentCnt, FundFlowEnum.POOL_MEMBER_A_CNT.getCode());
////        DappFundFlowEntity poolAllMemberAFundFlowAva = new DappFundFlowEntity(
////                1L,
////                poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva),
////                FundFlowEnum.POOL_MEMBER_A_CNT.getCode(),
////                2,
////                BigDecimal.ZERO,
////                null,
////                chergeRecordId);
////        dappFundFlowDao.insert(poolAllMemberAFundFlowAva);
////        dappWalletService.updateWalletMineWithLock(poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva),
////                1L,1);
//
//        /**
//         * 10%直推
//         */
//        DataDictionaryCustom directAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.DIRECT_A_PERCENT.getType(),
//                PoolEnum.DIRECT_A_PERCENT.getCode()
//        );
//        BigDecimal directAPercent = new BigDecimal(StrUtil.isEmpty(directAPercentDic.getValue()) ? "0.1" : directAPercentDic.getValue());
//        BigDecimal directAPercentCnt = realCnt.multiply(directAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        String refererId = dappMemberEntity.getRefererId();
//        DappMemberEntity directMemberEntity = dappMemberDao.selectMemberInfoByInviteId(refererId);
//        if(ObjectUtil.isNotEmpty(directMemberEntity)){
//            /**
//             *推荐用户入单可享有贡献值.例.推荐100获得100贡献值
//             */
//            DappUsdtPerkEntity directDappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(directMemberEntity.getId());
//            if(ObjectUtil.isEmpty(directDappUsdtPerkEntity)){
//                directDappUsdtPerkEntity = new DappUsdtPerkEntity();
//                directDappUsdtPerkEntity.setNftDevote(amount);
//                directDappUsdtPerkEntity.setMemberId(directMemberEntity.getId());
//                dappUsdtPerkEntityMapper.insert(directDappUsdtPerkEntity);
//            }
//
//            BigDecimal directNftDevote = directDappUsdtPerkEntity.getNftDevote();
//            directNftDevote = directNftDevote.add(amount);
//            directDappUsdtPerkEntity.setNftDevote(directNftDevote);
//            dappUsdtPerkEntityMapper.updateById(directDappUsdtPerkEntity);
//
//            BigDecimal directAPercentFundFlowToMemberFlag = this.getAndUpdateMemberPerk(directMemberEntity.getId(), directAPercentCnt);
//            if(directAPercentFundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){
//                //生成一条10%直推的资金流水记录
//                DappFundFlowEntity directAPercentFundFlowToMember = new DappFundFlowEntity(
//                        directMemberEntity.getId(),
//                        directAPercentFundFlowToMemberFlag,
//                        FundFlowEnum.DIRECT_A_PERCENT.getCode(),
//                        2,
//                        BigDecimal.ZERO,
//                        null,
//                        chergeRecordId);
//                dappFundFlowDao.insert(directAPercentFundFlowToMember);
//                //用户的A币账户增加directAPercentCnt数量
//                dappWalletService.updateWalletMineWithLock(directAPercentFundFlowToMemberFlag,directMemberEntity.getId(),1);
//            }
//            if(directAPercentCnt.compareTo(directAPercentFundFlowToMemberFlag) > 0){
//                DappFundFlowEntity directAPercentFundFlowToMemberAva = new DappFundFlowEntity(
//                        1L,
//                        directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag),
//                        FundFlowEnum.DIRECT_A_PERCENT.getCode(),
//                        2,
//                        BigDecimal.ZERO,
//                        null,
//                        chergeRecordId);
//                dappFundFlowDao.insert(directAPercentFundFlowToMemberAva);
//                dappWalletService.updateWalletMineWithLock(directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag),
//                        AppContants.YL_MEMBER_ID,1);
//            }
//        }
//        /**
//         * 5%节点
//         */
//        DataDictionaryCustom nodeAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_A_PERCENT.getType(),
//                PoolEnum.NODE_A_PERCENT.getCode()
//        );
//        BigDecimal nodeAPercent = new BigDecimal(StrUtil.isEmpty(nodeAPercentDic.getValue()) ? "0.05" : nodeAPercentDic.getValue());
//        BigDecimal nodeAPercentCnt = realCnt.multiply(nodeAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//        //生成一条5%节点的资金流水记录
//        DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity(
//                1L,
//                nodeAPercentCnt,
//                FundFlowEnum.NODE_A_PERCENT.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(nodeAPercentFundFlow);
////        chainProducer.sendAntACoinInNodeMsg(nodeAPercentFundFlow.getId());
//        DataDictionaryCustom nodeAPercentPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_A_PERCENT_POOL.getType(),
//                PoolEnum.NODE_A_PERCENT_POOL.getCode()
//        );
//        BigDecimal nodeAPercentPoolDicCnt = new BigDecimal(StrUtil.isEmpty(nodeAPercentPoolDic.getValue()) ? "0" : nodeAPercentPoolDic.getValue());
//        nodeAPercentPoolDicCnt = nodeAPercentPoolDicCnt.add(nodeAPercentCnt);
//        nodeAPercentPoolDic.setValue(nodeAPercentPoolDicCnt.toString());
//        dataDictionaryCustomMapper.updateById(nodeAPercentPoolDic);
//
//        BigDecimal nodeAPercentCntAva = superNodePoolPerk(nodeAPercentCnt, NodeCodeEnum.SUPER_NODE.getCode(), FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode());
//
//        if(nodeAPercentCnt.compareTo(nodeAPercentCntAva) > 0){
//            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
//                    1L,
//                    nodeAPercentCnt.subtract(nodeAPercentCntAva),
//                    FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(),
//                    2,
//                    BigDecimal.ZERO,
//                    null,
//                    chergeRecordId);
//            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
//            dappWalletService.updateWalletMineWithLock(nodeAPercentCnt.subtract(nodeAPercentCntAva),
//                    AppContants.YL_MEMBER_ID,1);
//        }
//        /**
//         * 5%基金会
//         */
//        DataDictionaryCustom foundationAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.FOUNDATION_A_PERCENT.getType(),
//                PoolEnum.FOUNDATION_A_PERCENT.getCode()
//        );
//        BigDecimal foundationAPercent = new BigDecimal(StrUtil.isEmpty(foundationAPercentDic.getValue()) ? "0.05" : foundationAPercentDic.getValue());
//        BigDecimal foundationAPercentCnt = realCnt.multiply(foundationAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        //生成一条5%基金会的资金流水记录
//        DappFundFlowEntity foundationAPercentFundFlow = new DappFundFlowEntity(
//                295L,
//                foundationAPercentCnt,
//                FundFlowEnum.FOUNDATION_A_PERCENT.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(foundationAPercentFundFlow);
//        //用户的A币账户增加memberGetACnt数量
//        dappWalletService.updateWalletMineWithLock(foundationAPercentCnt,295L,1);
//        /**
//         * 10%级差奖
//         */
//        DataDictionaryCustom levelAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.LEVEL_A_PERCENT.getType(),
//                PoolEnum.LEVEL_A_PERCENT.getCode()
//        );
//        BigDecimal levelAPercent = new BigDecimal(StrUtil.isEmpty(levelAPercentDic.getValue()) ? "0.1" : levelAPercentDic.getValue());
//        BigDecimal levelAPercentCnt = realCnt.multiply(levelAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        //生成一条10%级差奖进入10%级差奖底池的资金流水记录
//        DappFundFlowEntity levelAPercentCntFundFlow = new DappFundFlowEntity(
//                1L,
//                levelAPercentCnt,
//                FundFlowEnum.LEVEL_A_PERCENT_CNT.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(levelAPercentCntFundFlow);
//        chainProducer.sendAntACoinInLevelMsg(levelAPercentCntFundFlow.getId());
//
//        /**
//         * 更新用户为有效用户
//         */
//        dappMemberDao.updateMemberActiveStatus(1,memberId);
    }
@@ -1028,45 +1028,45 @@
    @Override
    public void antACoinInNodeMsg(Long id) {
        /**
         * 全网节点99名.享受全网5%分红
         */
        log.info("{}",id);
        //获取对应的流水记录
        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(id);
        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
            return;
        }
        //金额
        BigDecimal amount = dappFundFlowEntity.getAmount();
        /**
         * 获取全网的超级节点个数
         */
        List<DappMemberNodeEntity> dappMemberNodeEntities = dappMemberNodeMapper.selectNodeByNodeCode(NodeCodeEnum.SUPER_NODE.getCode());
        if(CollUtil.isNotEmpty(dappMemberNodeEntities)){
            BigDecimal divide = amount.divide(new BigDecimal(dappMemberNodeEntities.size()), 4, BigDecimal.ROUND_DOWN);
            for(DappMemberNodeEntity dappMemberNodeEntity : dappMemberNodeEntities){
                Long memberId = dappMemberNodeEntity.getMemberId();
                DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity(
                        memberId,
                        divide,
                        FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(),
                        2,
                        BigDecimal.ZERO,
                        null,
                        dappFundFlowEntity.getSystemProfitId());
                dappFundFlowDao.insert(nodeAPercentFundFlow);
                //用户的A币账户增加divide数量
                dappWalletService.updateWalletMineWithLock(divide,memberId,1);
            }
            dappFundFlowEntity.setFromHash("已分成"+dappMemberNodeEntities.size()+"人");
        }else{
            dappFundFlowEntity.setFromHash("已分成0人");
            dappWalletService.updateWalletMineWithLock(amount,1L,1);
        }
        dappFundFlowEntity.setStatus(2);
        dappFundFlowDao.updateById(dappFundFlowEntity);
//        /**
//         * 全网节点99名.享受全网5%分红
//         */
//        log.info("{}",id);
//        //获取对应的流水记录
//        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(id);
//        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
//            return;
//        }
//        //金额
//        BigDecimal amount = dappFundFlowEntity.getAmount();
//        /**
//         * 获取全网的超级节点个数
//         */
//        List<DappMemberNodeEntity> dappMemberNodeEntities = dappMemberNodeMapper.selectNodeByNodeCode(NodeCodeEnum.SUPER_NODE.getCode());
//        if(CollUtil.isNotEmpty(dappMemberNodeEntities)){
//            BigDecimal divide = amount.divide(new BigDecimal(dappMemberNodeEntities.size()), 4, BigDecimal.ROUND_DOWN);
//            for(DappMemberNodeEntity dappMemberNodeEntity : dappMemberNodeEntities){
//                Long memberId = dappMemberNodeEntity.getMemberId();
//
//                DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity(
//                        memberId,
//                        divide,
//                        FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(),
//                        2,
//                        BigDecimal.ZERO,
//                        null,
//                        dappFundFlowEntity.getSystemProfitId());
//                dappFundFlowDao.insert(nodeAPercentFundFlow);
//                //用户的A币账户增加divide数量
//                dappWalletService.updateWalletMineWithLock(divide,memberId,1);
//            }
//            dappFundFlowEntity.setFromHash("已分成"+dappMemberNodeEntities.size()+"人");
//        }else{
//            dappFundFlowEntity.setFromHash("已分成0人");
//            dappWalletService.updateWalletMineWithLock(amount,1L,1);
//        }
//        dappFundFlowEntity.setStatus(2);
//        dappFundFlowDao.updateById(dappFundFlowEntity);
    }
    @Override
@@ -1081,266 +1081,266 @@
         *
         * DAO5直推DAO5平级拿一代,视为平级奖,享受原有DAO5一个点,额外再加一个点分红。享受双份收益,合计2%加权分红
         */
        log.info("{}",id);
        //获取对应的流水记录
        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(id);
        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
            return;
        }
        /**
         * 极差总金额
         */
        BigDecimal amountTC = dappFundFlowEntity.getAmount();
        Long systemProfitId = dappFundFlowEntity.getSystemProfitId();
        DappChargeUsdtEntity dappChargeUsdtEntity = dappChargeUsdtMapper.selectById(systemProfitId);
        Long memberId = dappChargeUsdtEntity.getMemberId();
        DappMemberEntity mallMember = dappMemberDao.selectById(memberId);
        /**
         * 团队下不同代理级别获取不用的比例新增业绩补贴
         */
        if(StrUtil.isNotEmpty(mallMember.getRefererIds())){
            String referrerIds = mallMember.getRefererIds();
            List<String> referrerIdList = StrUtil.splitTrim(referrerIds, ",");
            if(CollUtil.isNotEmpty(referrerIdList)){
                List<DappMemberEntity> mallMemberTeamPerk = dappMemberDao.selectByInviteIds(referrerIdList);
                if(CollUtil.isNotEmpty(mallMemberTeamPerk)){
                    //初始级别
                    String levelNormal = MemberLevelEnum.NODE_1.getType();
                    //初始团队新增业绩补贴
                    BigDecimal teamIncomePerkNormal = BigDecimal.ZERO;
                    //补贴总数
                    BigDecimal teamIncomePerkTotal = BigDecimal.ZERO;
                    for(DappMemberEntity teamPerkMember : mallMemberTeamPerk){
                        String level = teamPerkMember.getAccountType();
                        //比较两个级别的大小,level大于levelNormal返回1
                        int compareMin = MemberLevelEnum.NODE_1.compareLevel(level, levelNormal);
                        int compareMax = MemberLevelEnum.NODE_1.compareLevel(MemberLevelEnum.NODE_5.getType(), level);
                        if(compareMin >= 1 && compareMax >= 1){
                            Long teamPerkMemberId = teamPerkMember.getId();
                            DataDictionaryCustom teamPerkMemberDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                                    "NODE_PERK", level);
                            NodePerk nodePerk = JSONObject.parseObject(teamPerkMemberDic.getValue(), NodePerk.class);
                            BigDecimal teamIncomePerk = nodePerk.getTeamIncomePerk();
                            //极差
                            teamIncomePerk = teamIncomePerk.subtract(teamIncomePerkNormal);
                            BigDecimal teamIncomePerkAmount = amountTC.multiply(teamIncomePerk).setScale(4, BigDecimal.ROUND_DOWN);
                            BigDecimal nodeAPercentFundFlowFlag = this.getAndUpdateMemberPerk(teamPerkMemberId, teamIncomePerkAmount);
                            if(nodeAPercentFundFlowFlag.compareTo(BigDecimal.ZERO) > 0){
                                DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity(
                                        teamPerkMemberId,
                                        nodeAPercentFundFlowFlag,
                                        FundFlowEnum.LEVEL_A_PERCENT_CNT_MEMBER.getCode(),
                                        2,
                                        BigDecimal.ZERO,
                                        null,
                                        dappFundFlowEntity.getSystemProfitId());
                                dappFundFlowDao.insert(nodeAPercentFundFlow);
                                //用户的A币账户增加divide数量
                                dappWalletService.updateWalletMineWithLock(nodeAPercentFundFlowFlag,teamPerkMemberId,1);
                                //累加补贴总数
                                teamIncomePerkTotal = teamIncomePerkTotal.add(nodeAPercentFundFlowFlag);
                            }
                            //初始级别变成当前遍历的会员的级别
                            levelNormal = level;
                            //初始新增业绩补贴比例变成当前会员级别的补贴比例
                            teamIncomePerkNormal = nodePerk.getTeamIncomePerk();
                        }
                    }
                    //更新总数据
                    dappFundFlowEntity.setFromHash("已分成"+teamIncomePerkTotal.setScale(4,BigDecimal.ROUND_DOWN));
                    dappFundFlowEntity.setStatus(2);
                    dappFundFlowDao.updateById(dappFundFlowEntity);
                    BigDecimal subtract = amountTC.subtract(teamIncomePerkTotal);
                    //用户的A币账户增加divide数量
//                    if(amountTC.compareTo(teamIncomePerkTotal) > 0){
//                        DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
//                                1L,
//                                subtract,
//                                FundFlowEnum.LEVEL_A_PERCENT_CNT_MEMBER.getCode(),
//                                2,
//                                BigDecimal.ZERO,
//                                null,
//                                systemProfitId);
//                        dappFundFlowDao.insert(nodeAPercentFundFlowAva);
//                        dappWalletService.updateWalletMineWithLock(subtract,
//                                1L,1);
//        log.info("{}",id);
//        //获取对应的流水记录
//        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(id);
//        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
//            return;
//        }
//        /**
//         * 极差总金额
//         */
//        BigDecimal amountTC = dappFundFlowEntity.getAmount();
//
//        Long systemProfitId = dappFundFlowEntity.getSystemProfitId();
//        DappChargeUsdtEntity dappChargeUsdtEntity = dappChargeUsdtMapper.selectById(systemProfitId);
//        Long memberId = dappChargeUsdtEntity.getMemberId();
//        DappMemberEntity mallMember = dappMemberDao.selectById(memberId);
//
//        /**
//         * 团队下不同代理级别获取不用的比例新增业绩补贴
//         */
//        if(StrUtil.isNotEmpty(mallMember.getRefererIds())){
//
//            String referrerIds = mallMember.getRefererIds();
//            List<String> referrerIdList = StrUtil.splitTrim(referrerIds, ",");
//            if(CollUtil.isNotEmpty(referrerIdList)){
//                List<DappMemberEntity> mallMemberTeamPerk = dappMemberDao.selectByInviteIds(referrerIdList);
//
//                if(CollUtil.isNotEmpty(mallMemberTeamPerk)){
//                    //初始级别
//                    String levelNormal = MemberLevelEnum.NODE_1.getType();
//                    //初始团队新增业绩补贴
//                    BigDecimal teamIncomePerkNormal = BigDecimal.ZERO;
//                    //补贴总数
//                    BigDecimal teamIncomePerkTotal = BigDecimal.ZERO;
//
//                    for(DappMemberEntity teamPerkMember : mallMemberTeamPerk){
//                        String level = teamPerkMember.getAccountType();
//                        //比较两个级别的大小,level大于levelNormal返回1
//                        int compareMin = MemberLevelEnum.NODE_1.compareLevel(level, levelNormal);
//                        int compareMax = MemberLevelEnum.NODE_1.compareLevel(MemberLevelEnum.NODE_5.getType(), level);
//                        if(compareMin >= 1 && compareMax >= 1){
//                            Long teamPerkMemberId = teamPerkMember.getId();
//                            DataDictionaryCustom teamPerkMemberDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                                    "NODE_PERK", level);
//
//                            NodePerk nodePerk = JSONObject.parseObject(teamPerkMemberDic.getValue(), NodePerk.class);
//                            BigDecimal teamIncomePerk = nodePerk.getTeamIncomePerk();
//                            //极差
//                            teamIncomePerk = teamIncomePerk.subtract(teamIncomePerkNormal);
//
//                            BigDecimal teamIncomePerkAmount = amountTC.multiply(teamIncomePerk).setScale(4, BigDecimal.ROUND_DOWN);
//
//                            BigDecimal nodeAPercentFundFlowFlag = this.getAndUpdateMemberPerk(teamPerkMemberId, teamIncomePerkAmount);
//                            if(nodeAPercentFundFlowFlag.compareTo(BigDecimal.ZERO) > 0){
//                                DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity(
//                                        teamPerkMemberId,
//                                        nodeAPercentFundFlowFlag,
//                                        FundFlowEnum.LEVEL_A_PERCENT_CNT_MEMBER.getCode(),
//                                        2,
//                                        BigDecimal.ZERO,
//                                        null,
//                                        dappFundFlowEntity.getSystemProfitId());
//                                dappFundFlowDao.insert(nodeAPercentFundFlow);
//                                //用户的A币账户增加divide数量
//                                dappWalletService.updateWalletMineWithLock(nodeAPercentFundFlowFlag,teamPerkMemberId,1);
//                                //累加补贴总数
//                                teamIncomePerkTotal = teamIncomePerkTotal.add(nodeAPercentFundFlowFlag);
//                            }
//
//                            //初始级别变成当前遍历的会员的级别
//                            levelNormal = level;
//                            //初始新增业绩补贴比例变成当前会员级别的补贴比例
//                            teamIncomePerkNormal = nodePerk.getTeamIncomePerk();
//                        }
//                    }
                }
            }
        }
        /**
         * 极差的dao3、dao4、dao5级别全网分红入自己的底池,每天按20%平分
         */
        //获取新增数量
        DataDictionaryCustom nodeThreeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_3.getType(),
                PoolEnum.NODE_3.getCode());
        NodePerk nodePerk = JSONObject.parseObject(nodeThreeDic.getValue(), NodePerk.class);
        BigDecimal averagePerk = nodePerk.getAveragePerk();
        BigDecimal averagePerkCnt = amountTC.multiply(averagePerk).setScale(4, BigDecimal.ROUND_DOWN);
        BigDecimal averagePerkCntAva = nodePoolPerk(averagePerkCnt, MemberLevelEnum.NODE_3.getType(), FundFlowEnum.DAO_3_NODE_PERK.getCode());
        //用户的A币账户增加divide数量
        if(averagePerkCnt.compareTo(averagePerkCntAva) > 0){
            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
                    1L,
                    averagePerkCnt.subtract(averagePerkCntAva),
                    FundFlowEnum.DAO_3_NODE_PERK.getCode(),
                    2,
                    BigDecimal.ZERO,
                    null,
                    systemProfitId);
            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
            dappWalletService.updateWalletMineWithLock(averagePerkCnt.subtract(averagePerkCntAva),
                    AppContants.YL_MEMBER_ID,1);
        }
        //生成流水记录
        DappFundFlowEntity nodeThreeFundFlow = new DappFundFlowEntity(
                1L,
                averagePerkCnt,
                FundFlowEnum.DAO_3_CNT_MEMBER.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                dappChargeUsdtEntity.getId());
        dappFundFlowDao.insert(nodeThreeFundFlow);
        //更新底池
        DataDictionaryCustom nodeThreePoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_3_POOL.getType(),
                PoolEnum.NODE_3_POOL.getCode());
        BigDecimal nodeThreePool = new BigDecimal(nodeThreePoolDic.getValue());
        nodeThreePool = nodeThreePool.add(averagePerkCnt).setScale(4,BigDecimal.ROUND_DOWN);
        nodeThreePoolDic.setValue(nodeThreePool.toString());
        dataDictionaryCustomMapper.updateById(nodeThreePoolDic);
        DataDictionaryCustom nodeFourDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_4.getType(),
                PoolEnum.NODE_4.getCode());
        NodePerk nodeFourDicPerk = JSONObject.parseObject(nodeFourDic.getValue(), NodePerk.class);
        BigDecimal averagePerkFour = nodeFourDicPerk.getAveragePerk();
        BigDecimal averagePerkFourCnt = amountTC.multiply(averagePerkFour).setScale(4, BigDecimal.ROUND_DOWN);
        BigDecimal averagePerkFourCntAva = nodePoolPerk(averagePerkFourCnt, MemberLevelEnum.NODE_4.getType(), FundFlowEnum.DAO_4_NODE_PERK.getCode());
        //用户的A币账户增加divide数量
        if(averagePerkFourCnt.compareTo(averagePerkFourCntAva) > 0){
            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
                    1L,
                    averagePerkFourCnt.subtract(averagePerkFourCntAva),
                    FundFlowEnum.DAO_4_NODE_PERK.getCode(),
                    2,
                    BigDecimal.ZERO,
                    null,
                    systemProfitId);
            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
            dappWalletService.updateWalletMineWithLock(averagePerkFourCnt.subtract(averagePerkFourCntAva),
                    AppContants.YL_MEMBER_ID,1);
        }
        DappFundFlowEntity nodeFourFundFlow = new DappFundFlowEntity(
                1L,
                averagePerkFourCnt,
                FundFlowEnum.DAO_4_CNT_MEMBER.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                dappChargeUsdtEntity.getId());
        dappFundFlowDao.insert(nodeFourFundFlow);
        DataDictionaryCustom nodeFourPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_4_POOL.getType(),
                PoolEnum.NODE_4_POOL.getCode());
        BigDecimal nodeFourPool = new BigDecimal(nodeFourPoolDic.getValue());
        nodeFourPool = nodeFourPool.add(averagePerkFourCnt).setScale(4,BigDecimal.ROUND_DOWN);
        nodeFourPoolDic.setValue(nodeFourPool.toString());
        dataDictionaryCustomMapper.updateById(nodeFourPoolDic);
        DataDictionaryCustom nodeFiveDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_5.getType(),
                PoolEnum.NODE_5.getCode());
        NodePerk nodeFiveDicPerk = JSONObject.parseObject(nodeFiveDic.getValue(), NodePerk.class);
        BigDecimal averagePerkFive = nodeFiveDicPerk.getAveragePerk();
        BigDecimal averagePerkFiveCnt = amountTC.multiply(averagePerkFive).setScale(4, BigDecimal.ROUND_DOWN);
        BigDecimal averagePerkFiveCntAva = nodePoolPerk(averagePerkFiveCnt, MemberLevelEnum.NODE_5.getType(), FundFlowEnum.DAO_5_NODE_PERK.getCode());
        //用户的A币账户增加divide数量
        if(averagePerkFiveCnt.compareTo(averagePerkFiveCntAva) > 0){
            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
                    1L,
                    averagePerkFiveCnt.subtract(averagePerkFiveCntAva),
                    FundFlowEnum.DAO_5_NODE_PERK.getCode(),
                    2,
                    BigDecimal.ZERO,
                    null,
                    systemProfitId);
            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
            dappWalletService.updateWalletMineWithLock(averagePerkFiveCnt.subtract(averagePerkFiveCntAva),
                    AppContants.YL_MEMBER_ID,1);
        }
        DappFundFlowEntity nodeFiveFundFlow = new DappFundFlowEntity(
                1L,
                averagePerkFiveCnt,
                FundFlowEnum.DAO_5_CNT_MEMBER.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                dappChargeUsdtEntity.getId());
        dappFundFlowDao.insert(nodeFiveFundFlow);
        DataDictionaryCustom nodeFivePoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_5_POOL.getType(),
                PoolEnum.NODE_5_POOL.getCode());
        BigDecimal nodeFivePool = new BigDecimal(nodeFivePoolDic.getValue());
        nodeFivePool = nodeFivePool.add(averagePerkFiveCnt).setScale(4,BigDecimal.ROUND_DOWN);
        nodeFivePoolDic.setValue(nodeFivePool.toString());
        dataDictionaryCustomMapper.updateById(nodeFivePoolDic);
        /**
         * DAO5直推DAO5平级拿一代,视为平级奖,享受原有DAO5一个点,额外再加一个点分红。享受双份收益,合计2%加权分红
         */
        DataDictionaryCustom nodeFiveEqualsDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_5_EQUALS.getType(),
                PoolEnum.NODE_5_EQUALS.getCode());
        BigDecimal nodeFiveEquals = new BigDecimal(nodeFiveEqualsDic.getValue());
        BigDecimal nodeFiveEqualsCnt = amountTC.multiply(nodeFiveEquals).setScale(4, BigDecimal.ROUND_DOWN);
        BigDecimal nodeFiveEqualsCntAva = nodePoolEqualsPerk(nodeFiveEqualsCnt, MemberLevelEnum.NODE_5.getType(), FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode());
        //用户的A币账户增加divide数量
        if(nodeFiveEqualsCnt.compareTo(nodeFiveEqualsCntAva) > 0){
            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
                    1L,
                    nodeFiveEqualsCnt.subtract(nodeFiveEqualsCntAva),
                    FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode(),
                    2,
                    BigDecimal.ZERO,
                    null,
                    systemProfitId);
            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
            dappWalletService.updateWalletMineWithLock(nodeFiveEqualsCnt.subtract(nodeFiveEqualsCntAva),
                    AppContants.YL_MEMBER_ID,1);
        }
        DappFundFlowEntity nodeFiveEqualsFundFlow = new DappFundFlowEntity(
                1L,
                nodeFiveEqualsCnt,
                FundFlowEnum.DAO_5_CNT_EQUALS_MEMBER.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                dappChargeUsdtEntity.getId());
        dappFundFlowDao.insert(nodeFiveEqualsFundFlow);
        DataDictionaryCustom nodeFiveEqualsPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_5_EQUALS_POOL.getType(),
                PoolEnum.NODE_5_EQUALS_POOL.getCode());
        BigDecimal nodeFiveEqualsPool = new BigDecimal(nodeFiveEqualsPoolDic.getValue());
        nodeFiveEqualsPool = nodeFiveEqualsPool.add(nodeFiveEqualsCnt).setScale(4,BigDecimal.ROUND_DOWN);
        nodeFiveEqualsPoolDic.setValue(nodeFiveEqualsPool.toString());
        dataDictionaryCustomMapper.updateById(nodeFiveEqualsPoolDic);
//                    //更新总数据
//                    dappFundFlowEntity.setFromHash("已分成"+teamIncomePerkTotal.setScale(4,BigDecimal.ROUND_DOWN));
//                    dappFundFlowEntity.setStatus(2);
//                    dappFundFlowDao.updateById(dappFundFlowEntity);
//                    BigDecimal subtract = amountTC.subtract(teamIncomePerkTotal);
//                    //用户的A币账户增加divide数量
////                    if(amountTC.compareTo(teamIncomePerkTotal) > 0){
////                        DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
////                                1L,
////                                subtract,
////                                FundFlowEnum.LEVEL_A_PERCENT_CNT_MEMBER.getCode(),
////                                2,
////                                BigDecimal.ZERO,
////                                null,
////                                systemProfitId);
////                        dappFundFlowDao.insert(nodeAPercentFundFlowAva);
////                        dappWalletService.updateWalletMineWithLock(subtract,
////                                1L,1);
////                    }
//                }
//            }
//        }
//        /**
//         * 极差的dao3、dao4、dao5级别全网分红入自己的底池,每天按20%平分
//         */
//        //获取新增数量
//        DataDictionaryCustom nodeThreeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_3.getType(),
//                PoolEnum.NODE_3.getCode());
//        NodePerk nodePerk = JSONObject.parseObject(nodeThreeDic.getValue(), NodePerk.class);
//        BigDecimal averagePerk = nodePerk.getAveragePerk();
//        BigDecimal averagePerkCnt = amountTC.multiply(averagePerk).setScale(4, BigDecimal.ROUND_DOWN);
//
//        BigDecimal averagePerkCntAva = nodePoolPerk(averagePerkCnt, MemberLevelEnum.NODE_3.getType(), FundFlowEnum.DAO_3_NODE_PERK.getCode());
//
//        //用户的A币账户增加divide数量
//        if(averagePerkCnt.compareTo(averagePerkCntAva) > 0){
//            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
//                    1L,
//                    averagePerkCnt.subtract(averagePerkCntAva),
//                    FundFlowEnum.DAO_3_NODE_PERK.getCode(),
//                    2,
//                    BigDecimal.ZERO,
//                    null,
//                    systemProfitId);
//            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
//            dappWalletService.updateWalletMineWithLock(averagePerkCnt.subtract(averagePerkCntAva),
//                    AppContants.YL_MEMBER_ID,1);
//        }
//        //生成流水记录
//        DappFundFlowEntity nodeThreeFundFlow = new DappFundFlowEntity(
//                1L,
//                averagePerkCnt,
//                FundFlowEnum.DAO_3_CNT_MEMBER.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                dappChargeUsdtEntity.getId());
//        dappFundFlowDao.insert(nodeThreeFundFlow);
//        //更新底池
//        DataDictionaryCustom nodeThreePoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_3_POOL.getType(),
//                PoolEnum.NODE_3_POOL.getCode());
//        BigDecimal nodeThreePool = new BigDecimal(nodeThreePoolDic.getValue());
//        nodeThreePool = nodeThreePool.add(averagePerkCnt).setScale(4,BigDecimal.ROUND_DOWN);
//        nodeThreePoolDic.setValue(nodeThreePool.toString());
//        dataDictionaryCustomMapper.updateById(nodeThreePoolDic);
//
//        DataDictionaryCustom nodeFourDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_4.getType(),
//                PoolEnum.NODE_4.getCode());
//        NodePerk nodeFourDicPerk = JSONObject.parseObject(nodeFourDic.getValue(), NodePerk.class);
//        BigDecimal averagePerkFour = nodeFourDicPerk.getAveragePerk();
//        BigDecimal averagePerkFourCnt = amountTC.multiply(averagePerkFour).setScale(4, BigDecimal.ROUND_DOWN);
//
//        BigDecimal averagePerkFourCntAva = nodePoolPerk(averagePerkFourCnt, MemberLevelEnum.NODE_4.getType(), FundFlowEnum.DAO_4_NODE_PERK.getCode());
//        //用户的A币账户增加divide数量
//        if(averagePerkFourCnt.compareTo(averagePerkFourCntAva) > 0){
//            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
//                    1L,
//                    averagePerkFourCnt.subtract(averagePerkFourCntAva),
//                    FundFlowEnum.DAO_4_NODE_PERK.getCode(),
//                    2,
//                    BigDecimal.ZERO,
//                    null,
//                    systemProfitId);
//            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
//            dappWalletService.updateWalletMineWithLock(averagePerkFourCnt.subtract(averagePerkFourCntAva),
//                    AppContants.YL_MEMBER_ID,1);
//        }
//        DappFundFlowEntity nodeFourFundFlow = new DappFundFlowEntity(
//                1L,
//                averagePerkFourCnt,
//                FundFlowEnum.DAO_4_CNT_MEMBER.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                dappChargeUsdtEntity.getId());
//        dappFundFlowDao.insert(nodeFourFundFlow);
//        DataDictionaryCustom nodeFourPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_4_POOL.getType(),
//                PoolEnum.NODE_4_POOL.getCode());
//        BigDecimal nodeFourPool = new BigDecimal(nodeFourPoolDic.getValue());
//        nodeFourPool = nodeFourPool.add(averagePerkFourCnt).setScale(4,BigDecimal.ROUND_DOWN);
//        nodeFourPoolDic.setValue(nodeFourPool.toString());
//        dataDictionaryCustomMapper.updateById(nodeFourPoolDic);
//
//        DataDictionaryCustom nodeFiveDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_5.getType(),
//                PoolEnum.NODE_5.getCode());
//        NodePerk nodeFiveDicPerk = JSONObject.parseObject(nodeFiveDic.getValue(), NodePerk.class);
//        BigDecimal averagePerkFive = nodeFiveDicPerk.getAveragePerk();
//        BigDecimal averagePerkFiveCnt = amountTC.multiply(averagePerkFive).setScale(4, BigDecimal.ROUND_DOWN);
//
//        BigDecimal averagePerkFiveCntAva = nodePoolPerk(averagePerkFiveCnt, MemberLevelEnum.NODE_5.getType(), FundFlowEnum.DAO_5_NODE_PERK.getCode());
//        //用户的A币账户增加divide数量
//        if(averagePerkFiveCnt.compareTo(averagePerkFiveCntAva) > 0){
//            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
//                    1L,
//                    averagePerkFiveCnt.subtract(averagePerkFiveCntAva),
//                    FundFlowEnum.DAO_5_NODE_PERK.getCode(),
//                    2,
//                    BigDecimal.ZERO,
//                    null,
//                    systemProfitId);
//            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
//            dappWalletService.updateWalletMineWithLock(averagePerkFiveCnt.subtract(averagePerkFiveCntAva),
//                    AppContants.YL_MEMBER_ID,1);
//        }
//        DappFundFlowEntity nodeFiveFundFlow = new DappFundFlowEntity(
//                1L,
//                averagePerkFiveCnt,
//                FundFlowEnum.DAO_5_CNT_MEMBER.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                dappChargeUsdtEntity.getId());
//        dappFundFlowDao.insert(nodeFiveFundFlow);
//        DataDictionaryCustom nodeFivePoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_5_POOL.getType(),
//                PoolEnum.NODE_5_POOL.getCode());
//        BigDecimal nodeFivePool = new BigDecimal(nodeFivePoolDic.getValue());
//        nodeFivePool = nodeFivePool.add(averagePerkFiveCnt).setScale(4,BigDecimal.ROUND_DOWN);
//        nodeFivePoolDic.setValue(nodeFivePool.toString());
//        dataDictionaryCustomMapper.updateById(nodeFivePoolDic);
//
//        /**
//         * DAO5直推DAO5平级拿一代,视为平级奖,享受原有DAO5一个点,额外再加一个点分红。享受双份收益,合计2%加权分红
//         */
//        DataDictionaryCustom nodeFiveEqualsDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_5_EQUALS.getType(),
//                PoolEnum.NODE_5_EQUALS.getCode());
//        BigDecimal nodeFiveEquals = new BigDecimal(nodeFiveEqualsDic.getValue());
//        BigDecimal nodeFiveEqualsCnt = amountTC.multiply(nodeFiveEquals).setScale(4, BigDecimal.ROUND_DOWN);
//
//        BigDecimal nodeFiveEqualsCntAva = nodePoolEqualsPerk(nodeFiveEqualsCnt, MemberLevelEnum.NODE_5.getType(), FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode());
//        //用户的A币账户增加divide数量
//        if(nodeFiveEqualsCnt.compareTo(nodeFiveEqualsCntAva) > 0){
//            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
//                    1L,
//                    nodeFiveEqualsCnt.subtract(nodeFiveEqualsCntAva),
//                    FundFlowEnum.DAO_5_NODE_EQUALS_PERK.getCode(),
//                    2,
//                    BigDecimal.ZERO,
//                    null,
//                    systemProfitId);
//            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
//            dappWalletService.updateWalletMineWithLock(nodeFiveEqualsCnt.subtract(nodeFiveEqualsCntAva),
//                    AppContants.YL_MEMBER_ID,1);
//        }
//        DappFundFlowEntity nodeFiveEqualsFundFlow = new DappFundFlowEntity(
//                1L,
//                nodeFiveEqualsCnt,
//                FundFlowEnum.DAO_5_CNT_EQUALS_MEMBER.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                dappChargeUsdtEntity.getId());
//        dappFundFlowDao.insert(nodeFiveEqualsFundFlow);
//        DataDictionaryCustom nodeFiveEqualsPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_5_EQUALS_POOL.getType(),
//                PoolEnum.NODE_5_EQUALS_POOL.getCode());
//        BigDecimal nodeFiveEqualsPool = new BigDecimal(nodeFiveEqualsPoolDic.getValue());
//        nodeFiveEqualsPool = nodeFiveEqualsPool.add(nodeFiveEqualsCnt).setScale(4,BigDecimal.ROUND_DOWN);
//        nodeFiveEqualsPoolDic.setValue(nodeFiveEqualsPool.toString());
//        dataDictionaryCustomMapper.updateById(nodeFiveEqualsPoolDic);
    }
    @Override
@@ -1611,140 +1611,140 @@
    @Override
    public void aCoinFire() {
        /**
         * A币技术做到资产钱包燃烧,闪兑钱包也要燃烧0.1%每小时
         */
        BigDecimal totalCnt = BigDecimal.ZERO;
        //闪兑钱包
        List<DappWalletCoinEntity> walletCoinEntities = dappWalletCoinDao.selectAmountThanZero();
        if(CollUtil.isNotEmpty(walletCoinEntities)){
            for(DappWalletCoinEntity dappWalletCoinEntity : walletCoinEntities){
                BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount();
                BigDecimal fireCnt = availableAmount.multiply(new BigDecimal("0.001")).setScale(4,BigDecimal.ROUND_DOWN);
                dappWalletService.updateWalletCoinWithLock(fireCnt,dappWalletCoinEntity.getMemberId(),2);
                totalCnt = totalCnt.add(fireCnt);
            }
        }
        //资产钱包
        List<DappWalletMineEntity> walletMineEntities = dappWalletMineDao.selectAmountThanZero();
        if(CollUtil.isNotEmpty(walletMineEntities)){
            for(DappWalletMineEntity dappWalletMineEntity : walletMineEntities){
                BigDecimal availableAmount = dappWalletMineEntity.getAvailableAmount();
                BigDecimal fireCnt = availableAmount.multiply(new BigDecimal("0.001")).setScale(4,BigDecimal.ROUND_DOWN);
                dappWalletService.updateWalletMineWithLock(fireCnt,dappWalletMineEntity.getMemberId(),2);
                totalCnt = totalCnt.add(fireCnt);
            }
        }
        if(BigDecimal.ZERO.compareTo(totalCnt) >= 0){
            return;
        }
        totalCnt = totalCnt.setScale(4,BigDecimal.ROUND_DOWN);
        /**
         * 插入每小时燃烧的资金流水
         */
        DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity(1L, totalCnt, FundFlowEnum.A_COIN_FIRE.getCode(), 2, BigDecimal.ZERO);
        dappFundFlowDao.insert(dappFundFlowEntity);
        /**
         * 更新A币的价格
         */
        DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_CNT.getType(),
                PoolEnum.COIN_A_CNT.getCode());
        BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue());
        coinACnt = coinACnt.subtract(totalCnt.multiply(new BigDecimal(0.8)));
        coinACntDic.setValue(coinACnt.toString());
        dataDictionaryCustomMapper.updateById(coinACntDic);
        DataDictionaryCustom coinAUsdtDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_USDT_PRICE.getType(),
                PoolEnum.COIN_A_USDT_PRICE.getCode());
        BigDecimal coinAUsdt = new BigDecimal(coinAUsdtDic.getValue());
        DataDictionaryCustom coinAPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_PRICE.getType(),
                PoolEnum.COIN_A_PRICE.getCode());
        BigDecimal coinAPrice = coinAUsdt.divide(coinACnt,12,BigDecimal.ROUND_DOWN);
        coinAPriceDic.setValue(coinAPrice.toString());
        dataDictionaryCustomMapper.updateById(coinAPriceDic);
        /**
         * 增加K线数据
         */
        DappAKlineEntity dappAKlineEntity = new DappAKlineEntity();
        dappAKlineEntity.setType(0);
        /**
         * 获取最新一条小时或者分钟的数据
         */
        DappAKlineEntity oldOne = dappAKlineMapper.selectOneByType();
        if(ObjectUtil.isNotEmpty(oldOne)){
            dappAKlineEntity.setOpenPrice(oldOne.getClosePrice());
            dappAKlineEntity.setLowestPrice(oldOne.getClosePrice());
        }else{
            dappAKlineEntity.setOpenPrice(coinAPrice);
            dappAKlineEntity.setLowestPrice(coinAPrice);
        }
        dappAKlineEntity.setHighestPrice(coinAPrice);
        dappAKlineEntity.setClosePrice(coinAPrice);
        dappAKlineMapper.insert(dappAKlineEntity);
        List<cn.hutool.json.JSONObject> objects = new ArrayList<>();
        List<AKLineLimitVo> akLineLimitVos = dappAKlineMapper.selectListByTypeAndLimit(0, AppContants.K_LINE_LIMIT);
        if(CollUtil.isNotEmpty(akLineLimitVos)) {
            Collections.reverse(akLineLimitVos);
            for (AKLineLimitVo akLineLimitVo : akLineLimitVos) {
                cn.hutool.json.JSONObject parseObj = JSONUtil.parseObj(akLineLimitVo);
                objects.add(parseObj);
            }
            redisUtils.del(AppContants.K_LINE_NOW);
            redisUtils.set(AppContants.K_LINE_NOW, objects.toString());
        }
//        /**
//         * A币技术做到资产钱包燃烧,闪兑钱包也要燃烧0.1%每小时
//         */
//        BigDecimal totalCnt = BigDecimal.ZERO;
//        //闪兑钱包
//        List<DappWalletCoinEntity> walletCoinEntities = dappWalletCoinDao.selectAmountThanZero();
//        if(CollUtil.isNotEmpty(walletCoinEntities)){
//            for(DappWalletCoinEntity dappWalletCoinEntity : walletCoinEntities){
//                BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount();
//                BigDecimal fireCnt = availableAmount.multiply(new BigDecimal("0.001")).setScale(4,BigDecimal.ROUND_DOWN);
//                dappWalletService.updateWalletCoinWithLock(fireCnt,dappWalletCoinEntity.getMemberId(),2);
//                totalCnt = totalCnt.add(fireCnt);
//            }
//        }
//        //资产钱包
//        List<DappWalletMineEntity> walletMineEntities = dappWalletMineDao.selectAmountThanZero();
//        if(CollUtil.isNotEmpty(walletMineEntities)){
//            for(DappWalletMineEntity dappWalletMineEntity : walletMineEntities){
//                BigDecimal availableAmount = dappWalletMineEntity.getAvailableAmount();
//                BigDecimal fireCnt = availableAmount.multiply(new BigDecimal("0.001")).setScale(4,BigDecimal.ROUND_DOWN);
//                dappWalletService.updateWalletMineWithLock(fireCnt,dappWalletMineEntity.getMemberId(),2);
//                totalCnt = totalCnt.add(fireCnt);
//            }
//        }
//        if(BigDecimal.ZERO.compareTo(totalCnt) >= 0){
//            return;
//        }
//
//        totalCnt = totalCnt.setScale(4,BigDecimal.ROUND_DOWN);
//        /**
//         * 插入每小时燃烧的资金流水
//         */
//        DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity(1L, totalCnt, FundFlowEnum.A_COIN_FIRE.getCode(), 2, BigDecimal.ZERO);
//        dappFundFlowDao.insert(dappFundFlowEntity);
//        /**
//         * 更新A币的价格
//         */
//        DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.COIN_A_CNT.getType(),
//                PoolEnum.COIN_A_CNT.getCode());
//        BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue());
//        coinACnt = coinACnt.subtract(totalCnt.multiply(new BigDecimal(0.8)));
//        coinACntDic.setValue(coinACnt.toString());
//        dataDictionaryCustomMapper.updateById(coinACntDic);
//
//        DataDictionaryCustom coinAUsdtDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.COIN_A_USDT_PRICE.getType(),
//                PoolEnum.COIN_A_USDT_PRICE.getCode());
//        BigDecimal coinAUsdt = new BigDecimal(coinAUsdtDic.getValue());
//
//        DataDictionaryCustom coinAPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.COIN_A_PRICE.getType(),
//                PoolEnum.COIN_A_PRICE.getCode());
//
//        BigDecimal coinAPrice = coinAUsdt.divide(coinACnt,12,BigDecimal.ROUND_DOWN);
//        coinAPriceDic.setValue(coinAPrice.toString());
//        dataDictionaryCustomMapper.updateById(coinAPriceDic);
//        /**
//         * 增加K线数据
//         */
//        DappAKlineEntity dappAKlineEntity = new DappAKlineEntity();
//        dappAKlineEntity.setType(0);
//        /**
//         * 获取最新一条小时或者分钟的数据
//         */
//        DappAKlineEntity oldOne = dappAKlineMapper.selectOneByType();
//        if(ObjectUtil.isNotEmpty(oldOne)){
//            dappAKlineEntity.setOpenPrice(oldOne.getClosePrice());
//            dappAKlineEntity.setLowestPrice(oldOne.getClosePrice());
//        }else{
//            dappAKlineEntity.setOpenPrice(coinAPrice);
//            dappAKlineEntity.setLowestPrice(coinAPrice);
//        }
//        dappAKlineEntity.setHighestPrice(coinAPrice);
//        dappAKlineEntity.setClosePrice(coinAPrice);
//        dappAKlineMapper.insert(dappAKlineEntity);
//
//
//        List<cn.hutool.json.JSONObject> objects = new ArrayList<>();
//        List<AKLineLimitVo> akLineLimitVos = dappAKlineMapper.selectListByTypeAndLimit(0, AppContants.K_LINE_LIMIT);
//        if(CollUtil.isNotEmpty(akLineLimitVos)) {
//            Collections.reverse(akLineLimitVos);
//            for (AKLineLimitVo akLineLimitVo : akLineLimitVos) {
//                cn.hutool.json.JSONObject parseObj = JSONUtil.parseObj(akLineLimitVo);
//                objects.add(parseObj);
//            }
//            redisUtils.del(AppContants.K_LINE_NOW);
//            redisUtils.set(AppContants.K_LINE_NOW, objects.toString());
//        }
    }
    @Override
    public void antMemberLevelMsg(Long memberId) {
        DappMemberEntity member = dappMemberDao.selectById(memberId);
        if(StrUtil.isBlank(member.getRefererIds())) {
            return;
        }
        List<String> ids = StrUtil.split(member.getRefererIds(), ',');
        List<DappMemberEntity> parentMembers = dappMemberDao.selectByInviteIds(ids);
        for (DappMemberEntity parent : parentMembers) {
            //DAO5不能再升级了
            if(parent.getAccountType().equals(MemberLevelEnum.NODE_5.getType())){
                continue;
            }
            /**
             * 升级到董事就无法升级了
             */
            String nextLevelName = MemberLevelEnum.MEMBER.getNextLevel(parent.getAccountType());
            int levelCode = MemberLevelEnum.MEMBER.getLevelCode(nextLevelName);
            DataDictionaryCustom newLevelDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode("NODE_PERK", nextLevelName);
            if(ObjectUtil.isEmpty(newLevelDic)){
                continue;
            }
            NodePerk nodeFiveDicPerk = JSONObject.parseObject(newLevelDic.getValue(), NodePerk.class);
            //需要判断小区业绩
            if( MemberLevelEnum.NODE_1.getType().equals(nextLevelName)){
                if (!directMemberCnt(parent, nodeFiveDicPerk)) {
                    continue;
                }
                if (!teamIncome(parent, nodeFiveDicPerk)) {
                    continue;
                }
            }else{
                if (!agentCntFinish(parent, nodeFiveDicPerk)) {
                    continue;
                }
            }
            parent.setAccountType(nextLevelName);
            dappMemberDao.updateById(parent);
        }
//        DappMemberEntity member = dappMemberDao.selectById(memberId);
//        if(StrUtil.isBlank(member.getRefererIds())) {
//            return;
//        }
//
//        List<String> ids = StrUtil.split(member.getRefererIds(), ',');
//        List<DappMemberEntity> parentMembers = dappMemberDao.selectByInviteIds(ids);
//        for (DappMemberEntity parent : parentMembers) {
//            //DAO5不能再升级了
//            if(parent.getAccountType().equals(MemberLevelEnum.NODE_5.getType())){
//                continue;
//            }
//            /**
//             * 升级到董事就无法升级了
//             */
//            String nextLevelName = MemberLevelEnum.MEMBER.getNextLevel(parent.getAccountType());
//            int levelCode = MemberLevelEnum.MEMBER.getLevelCode(nextLevelName);
//
//            DataDictionaryCustom newLevelDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode("NODE_PERK", nextLevelName);
//            if(ObjectUtil.isEmpty(newLevelDic)){
//                continue;
//            }
//            NodePerk nodeFiveDicPerk = JSONObject.parseObject(newLevelDic.getValue(), NodePerk.class);
//
//            //需要判断小区业绩
//            if( MemberLevelEnum.NODE_1.getType().equals(nextLevelName)){
//                if (!directMemberCnt(parent, nodeFiveDicPerk)) {
//                    continue;
//                }
//                if (!teamIncome(parent, nodeFiveDicPerk)) {
//                    continue;
//                }
//            }else{
//                if (!agentCntFinish(parent, nodeFiveDicPerk)) {
//                    continue;
//                }
//            }
//
//            parent.setAccountType(nextLevelName);
//            dappMemberDao.updateById(parent);
//        }
    }
    @Override
@@ -1788,7 +1788,7 @@
        dappAKlineEntity.setClosePrice(coinAPrice);
        dappAKlineMapper.insert(dappAKlineEntity);
        chainProducer.sendAntKLineMsg(1);
//        chainProducer.sendAntKLineMsg(1);
    }
    @Override
@@ -1828,7 +1828,7 @@
        dappAKlineEntity.setClosePrice(coinAPrice);
        dappAKlineMapper.insert(dappAKlineEntity);
        chainProducer.sendAntKLineMsg(2);
//        chainProducer.sendAntKLineMsg(2);
        //周
        String week = DateUtil.dayOfWeekEnum(DateUtil.date()).toChinese();
        if("星期日".equals(week)){
@@ -1873,7 +1873,7 @@
            dappAKlineEntityDay.setClosePrice(coinAPrice);
            dappAKlineMapper.insert(dappAKlineEntityDay);
            chainProducer.sendAntKLineMsg(3);
//            chainProducer.sendAntKLineMsg(3);
        }
        //月
        int month = DateUtil.dayOfMonth(DateUtil.date());
@@ -1908,7 +1908,7 @@
            dappAKlineEntityWeek.setClosePrice(coinAPrice);
            dappAKlineMapper.insert(dappAKlineEntityWeek);
            chainProducer.sendAntKLineMsg(4);
//            chainProducer.sendAntKLineMsg(4);
        }
    }
@@ -2015,24 +2015,24 @@
    @Override
    public void allMemberPerkAvaMsg(Long id) {
        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id);
        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
            return;
        }
        BigDecimal poolAllMemberAPercentCnt = dappFundFlowEntity.getAmount();
        BigDecimal poolAllMemberAPercentCntAva = allMemberPerk(poolAllMemberAPercentCnt, FundFlowEnum.POOL_MEMBER_A_CNT.getCode());
        DappFundFlowEntity poolAllMemberAFundFlowAva = new DappFundFlowEntity(
                1L,
                poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva),
                FundFlowEnum.POOL_MEMBER_A_CNT.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                dappFundFlowEntity.getSystemProfitId());
        dappFundFlowDao.insert(poolAllMemberAFundFlowAva);
        dappWalletService.updateWalletMineWithLock(poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva),
                AppContants.YL_MEMBER_ID,1);
//        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id);
//        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
//            return;
//        }
//
//        BigDecimal poolAllMemberAPercentCnt = dappFundFlowEntity.getAmount();
//        BigDecimal poolAllMemberAPercentCntAva = allMemberPerk(poolAllMemberAPercentCnt, FundFlowEnum.POOL_MEMBER_A_CNT.getCode());
//        DappFundFlowEntity poolAllMemberAFundFlowAva = new DappFundFlowEntity(
//                1L,
//                poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva),
//                FundFlowEnum.POOL_MEMBER_A_CNT.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                dappFundFlowEntity.getSystemProfitId());
//        dappFundFlowDao.insert(poolAllMemberAFundFlowAva);
//        dappWalletService.updateWalletMineWithLock(poolAllMemberAPercentCnt.subtract(poolAllMemberAPercentCntAva),
//                AppContants.YL_MEMBER_ID,1);
    }
    @Override
@@ -2080,14 +2080,14 @@
        flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE);
        dappFundFlowDao.updateById(flow);
        /**
         * 发送消息处理返利逻辑
         */
        chainProducer.sendAntACoinInContractMsg(flow.getId());
        /**
         * 发送消息处理代理升级
         */
        chainProducer.sendAntMemberLevelMsg(memberId);
//        /**
//         * 发送消息处理返利逻辑
//         */
//        chainProducer.sendAntACoinInContractMsg(flow.getId());
//        /**
//         * 发送消息处理代理升级
//         */
//        chainProducer.sendAntMemberLevelMsg(memberId);
    }
    @Override
@@ -2149,15 +2149,15 @@
        amountPerk = amountPerk.add(amount.multiply(new BigDecimal(3)));
        dappUsdtPerkEntity.setAmount(amountPerk);
        //生成一条金本位的三倍额度的资金流水记录
        DappFundFlowEntity amountPerkFundFlow = new DappFundFlowEntity(
                memberId,
                amount.multiply(new BigDecimal(3)),
                FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(amountPerkFundFlow);
//        DappFundFlowEntity amountPerkFundFlow = new DappFundFlowEntity(
//                memberId,
//                amount.multiply(new BigDecimal(3)),
//                FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(amountPerkFundFlow);
        //增加业绩
        BigDecimal achieveAmount = dappUsdtPerkEntity.getAchieveAmount();
@@ -2212,7 +2212,7 @@
        coinAPriceDic.setValue(divide.toString());
        dataDictionaryCustomMapper.updateById(coinAPriceDic);
        chainProducer.sendAntKLineMsg(0);
//        chainProducer.sendAntKLineMsg(0);
        /**
         * A币的分配 walletMine
         * 【70%换算100%分配】
@@ -2226,211 +2226,211 @@
        /**
         * 50%客户秒到
         */
        DataDictionaryCustom memberGetAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.MEMBER_GET_A_PERCENT.getType(),
                PoolEnum.MEMBER_GET_A_PERCENT.getCode()
        );
        BigDecimal memberGetAPercent = new BigDecimal(StrUtil.isEmpty(memberGetAPercentDic.getValue()) ? "0.5" : memberGetAPercentDic.getValue());
        BigDecimal memberGetACnt = realCnt.multiply(memberGetAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        BigDecimal fundFlowToMemberFlag = this.getAndUpdateMemberPerk(dappFundFlowEntity.getMemberId(), memberGetACnt);
        if(fundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){
            //生成一条50%客户秒到的资金流水记录
            DappFundFlowEntity fundFlowToMember = new DappFundFlowEntity(
                    dappFundFlowEntity.getMemberId(),
                    fundFlowToMemberFlag,
                    FundFlowEnum.MEMBER_GET_A_CNT.getCode(),
                    2,
                    BigDecimal.ZERO,
                    null,
                    chergeRecordId);
            dappFundFlowDao.insert(fundFlowToMember);
            //用户的A币账户增加memberGetACnt数量
            dappWalletService.updateWalletMineWithLock(fundFlowToMemberFlag,dappFundFlowEntity.getMemberId(),1);
        }
        /**
         * 20%全网加权分红(按20%释放递减)进入加权分红底池
         */
        DataDictionaryCustom poolAllMemberAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getType(),
                PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getCode()
        );
        BigDecimal poolAllMemberAPercent = new BigDecimal(StrUtil.isEmpty(poolAllMemberAPercentDic.getValue()) ? "0.2" : poolAllMemberAPercentDic.getValue());
        BigDecimal poolAllMemberAPercentCnt = realCnt.multiply(poolAllMemberAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        DataDictionaryCustom poolAllMemberACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.POOL_ALL_MEMBER_A_CNT.getType(),
                PoolEnum.POOL_ALL_MEMBER_A_CNT.getCode()
        );
        BigDecimal poolAllMemberACnt = new BigDecimal(StrUtil.isEmpty(poolAllMemberACntDic.getValue()) ? "0" : poolAllMemberACntDic.getValue());
        poolAllMemberACnt = poolAllMemberACnt.add(poolAllMemberAPercentCnt);
        poolAllMemberACntDic.setValue(poolAllMemberACnt.toString());
        dataDictionaryCustomMapper.updateById(poolAllMemberACntDic);
        //生成一条20%全网加权分红(按20%释放递减)进入加权分红底池的资金流水记录
        DappFundFlowEntity poolAllMemberAFundFlow = new DappFundFlowEntity(
                1L,
                poolAllMemberAPercentCnt,
                FundFlowEnum.POOL_ALL_MEMBER_A_CNT.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(poolAllMemberAFundFlow);
        /**
         * 20%全网加权平分,按照个人投资占比全网的比例去平分
         */
        chainProducer.sendAllMemberPerkAvaMsg(poolAllMemberAFundFlow.getId());
        /**
         * 10%直推
         */
        DataDictionaryCustom directAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.DIRECT_A_PERCENT.getType(),
                PoolEnum.DIRECT_A_PERCENT.getCode()
        );
        BigDecimal directAPercent = new BigDecimal(StrUtil.isEmpty(directAPercentDic.getValue()) ? "0.1" : directAPercentDic.getValue());
        BigDecimal directAPercentCnt = realCnt.multiply(directAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        String refererId = dappMemberEntity.getRefererId();
        DappMemberEntity directMemberEntity = dappMemberDao.selectMemberInfoByInviteId(refererId);
        if(ObjectUtil.isNotEmpty(directMemberEntity)){
            /**
             *推荐用户入单可享有贡献值.例.推荐100获得100贡献值
             */
            DappUsdtPerkEntity directDappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(directMemberEntity.getId());
            if(ObjectUtil.isEmpty(directDappUsdtPerkEntity)){
                directDappUsdtPerkEntity = new DappUsdtPerkEntity();
                directDappUsdtPerkEntity.setNftDevote(amount);
                directDappUsdtPerkEntity.setMemberId(directMemberEntity.getId());
                dappUsdtPerkEntityMapper.insert(directDappUsdtPerkEntity);
            }
            BigDecimal directNftDevote = directDappUsdtPerkEntity.getNftDevote();
            directNftDevote = directNftDevote.add(amount);
            directDappUsdtPerkEntity.setNftDevote(directNftDevote);
            dappUsdtPerkEntityMapper.updateById(directDappUsdtPerkEntity);
            BigDecimal directAPercentFundFlowToMemberFlag = this.getAndUpdateMemberPerk(directMemberEntity.getId(), directAPercentCnt);
            if(directAPercentFundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){
                //生成一条10%直推的资金流水记录
                DappFundFlowEntity directAPercentFundFlowToMember = new DappFundFlowEntity(
                        directMemberEntity.getId(),
                        directAPercentFundFlowToMemberFlag,
                        FundFlowEnum.DIRECT_A_PERCENT.getCode(),
                        2,
                        BigDecimal.ZERO,
                        null,
                        chergeRecordId);
                dappFundFlowDao.insert(directAPercentFundFlowToMember);
                //用户的A币账户增加directAPercentCnt数量
                dappWalletService.updateWalletMineWithLock(directAPercentFundFlowToMemberFlag,directMemberEntity.getId(),1);
            }
            if(directAPercentCnt.compareTo(directAPercentFundFlowToMemberFlag) > 0){
                DappFundFlowEntity directAPercentFundFlowToMemberAva = new DappFundFlowEntity(
                        1L,
                        directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag),
                        FundFlowEnum.DIRECT_A_PERCENT.getCode(),
                        2,
                        BigDecimal.ZERO,
                        null,
                        chergeRecordId);
                dappFundFlowDao.insert(directAPercentFundFlowToMemberAva);
                dappWalletService.updateWalletMineWithLock(directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag),
                        AppContants.YL_MEMBER_ID,1);
            }
        }
        /**
         * 5%节点
         */
        DataDictionaryCustom nodeAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_A_PERCENT.getType(),
                PoolEnum.NODE_A_PERCENT.getCode()
        );
        BigDecimal nodeAPercent = new BigDecimal(StrUtil.isEmpty(nodeAPercentDic.getValue()) ? "0.05" : nodeAPercentDic.getValue());
        BigDecimal nodeAPercentCnt = realCnt.multiply(nodeAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        //生成一条5%节点的资金流水记录
        DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity(
                1L,
                nodeAPercentCnt,
                FundFlowEnum.NODE_A_PERCENT.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(nodeAPercentFundFlow);
//        chainProducer.sendAntACoinInNodeMsg(nodeAPercentFundFlow.getId());
        DataDictionaryCustom nodeAPercentPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.NODE_A_PERCENT_POOL.getType(),
                PoolEnum.NODE_A_PERCENT_POOL.getCode()
        );
        BigDecimal nodeAPercentPoolDicCnt = new BigDecimal(StrUtil.isEmpty(nodeAPercentPoolDic.getValue()) ? "0" : nodeAPercentPoolDic.getValue());
        nodeAPercentPoolDicCnt = nodeAPercentPoolDicCnt.add(nodeAPercentCnt);
        nodeAPercentPoolDic.setValue(nodeAPercentPoolDicCnt.toString());
        dataDictionaryCustomMapper.updateById(nodeAPercentPoolDic);
        BigDecimal nodeAPercentCntAva = superNodePoolPerk(nodeAPercentCnt, NodeCodeEnum.SUPER_NODE.getCode(), FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode());
        if(nodeAPercentCnt.compareTo(nodeAPercentCntAva) > 0){
            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
                    1L,
                    nodeAPercentCnt.subtract(nodeAPercentCntAva),
                    FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(),
                    2,
                    BigDecimal.ZERO,
                    null,
                    chergeRecordId);
            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
            dappWalletService.updateWalletMineWithLock(nodeAPercentCnt.subtract(nodeAPercentCntAva),
                    AppContants.YL_MEMBER_ID,1);
        }
        /**
         * 5%基金会
         */
        DataDictionaryCustom foundationAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.FOUNDATION_A_PERCENT.getType(),
                PoolEnum.FOUNDATION_A_PERCENT.getCode()
        );
        BigDecimal foundationAPercent = new BigDecimal(StrUtil.isEmpty(foundationAPercentDic.getValue()) ? "0.05" : foundationAPercentDic.getValue());
        BigDecimal foundationAPercentCnt = realCnt.multiply(foundationAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        //生成一条5%基金会的资金流水记录
        DappFundFlowEntity foundationAPercentFundFlow = new DappFundFlowEntity(
                295L,
                foundationAPercentCnt,
                FundFlowEnum.FOUNDATION_A_PERCENT.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(foundationAPercentFundFlow);
        //用户的A币账户增加memberGetACnt数量
        dappWalletService.updateWalletMineWithLock(foundationAPercentCnt,295L,1);
        /**
         * 10%级差奖
         */
        DataDictionaryCustom levelAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.LEVEL_A_PERCENT.getType(),
                PoolEnum.LEVEL_A_PERCENT.getCode()
        );
        BigDecimal levelAPercent = new BigDecimal(StrUtil.isEmpty(levelAPercentDic.getValue()) ? "0.1" : levelAPercentDic.getValue());
        BigDecimal levelAPercentCnt = realCnt.multiply(levelAPercent).setScale(4, BigDecimal.ROUND_DOWN);
        //生成一条10%级差奖进入10%级差奖底池的资金流水记录
        DappFundFlowEntity levelAPercentCntFundFlow = new DappFundFlowEntity(
                1L,
                levelAPercentCnt,
                FundFlowEnum.LEVEL_A_PERCENT_CNT.getCode(),
                2,
                BigDecimal.ZERO,
                null,
                chergeRecordId);
        dappFundFlowDao.insert(levelAPercentCntFundFlow);
        chainProducer.sendAntACoinInLevelMsg(levelAPercentCntFundFlow.getId());
        /**
         * 更新用户为有效用户
         */
        dappMemberDao.updateMemberActiveStatus(1,memberId);
//        DataDictionaryCustom memberGetAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.MEMBER_GET_A_PERCENT.getType(),
//                PoolEnum.MEMBER_GET_A_PERCENT.getCode()
//        );
//        BigDecimal memberGetAPercent = new BigDecimal(StrUtil.isEmpty(memberGetAPercentDic.getValue()) ? "0.5" : memberGetAPercentDic.getValue());
//        BigDecimal memberGetACnt = realCnt.multiply(memberGetAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        BigDecimal fundFlowToMemberFlag = this.getAndUpdateMemberPerk(dappFundFlowEntity.getMemberId(), memberGetACnt);
//        if(fundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){
//            //生成一条50%客户秒到的资金流水记录
//            DappFundFlowEntity fundFlowToMember = new DappFundFlowEntity(
//                    dappFundFlowEntity.getMemberId(),
//                    fundFlowToMemberFlag,
//                    FundFlowEnum.MEMBER_GET_A_CNT.getCode(),
//                    2,
//                    BigDecimal.ZERO,
//                    null,
//                    chergeRecordId);
//            dappFundFlowDao.insert(fundFlowToMember);
//            //用户的A币账户增加memberGetACnt数量
//            dappWalletService.updateWalletMineWithLock(fundFlowToMemberFlag,dappFundFlowEntity.getMemberId(),1);
//        }
//        /**
//         * 20%全网加权分红(按20%释放递减)进入加权分红底池
//         */
//        DataDictionaryCustom poolAllMemberAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getType(),
//                PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getCode()
//        );
//        BigDecimal poolAllMemberAPercent = new BigDecimal(StrUtil.isEmpty(poolAllMemberAPercentDic.getValue()) ? "0.2" : poolAllMemberAPercentDic.getValue());
//        BigDecimal poolAllMemberAPercentCnt = realCnt.multiply(poolAllMemberAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        DataDictionaryCustom poolAllMemberACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.POOL_ALL_MEMBER_A_CNT.getType(),
//                PoolEnum.POOL_ALL_MEMBER_A_CNT.getCode()
//        );
//        BigDecimal poolAllMemberACnt = new BigDecimal(StrUtil.isEmpty(poolAllMemberACntDic.getValue()) ? "0" : poolAllMemberACntDic.getValue());
//        poolAllMemberACnt = poolAllMemberACnt.add(poolAllMemberAPercentCnt);
//        poolAllMemberACntDic.setValue(poolAllMemberACnt.toString());
//        dataDictionaryCustomMapper.updateById(poolAllMemberACntDic);
//        //生成一条20%全网加权分红(按20%释放递减)进入加权分红底池的资金流水记录
//        DappFundFlowEntity poolAllMemberAFundFlow = new DappFundFlowEntity(
//                1L,
//                poolAllMemberAPercentCnt,
//                FundFlowEnum.POOL_ALL_MEMBER_A_CNT.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(poolAllMemberAFundFlow);
//
//        /**
//         * 20%全网加权平分,按照个人投资占比全网的比例去平分
//         */
//        chainProducer.sendAllMemberPerkAvaMsg(poolAllMemberAFundFlow.getId());
//        /**
//         * 10%直推
//         */
//        DataDictionaryCustom directAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.DIRECT_A_PERCENT.getType(),
//                PoolEnum.DIRECT_A_PERCENT.getCode()
//        );
//        BigDecimal directAPercent = new BigDecimal(StrUtil.isEmpty(directAPercentDic.getValue()) ? "0.1" : directAPercentDic.getValue());
//        BigDecimal directAPercentCnt = realCnt.multiply(directAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        String refererId = dappMemberEntity.getRefererId();
//        DappMemberEntity directMemberEntity = dappMemberDao.selectMemberInfoByInviteId(refererId);
//        if(ObjectUtil.isNotEmpty(directMemberEntity)){
//            /**
//             *推荐用户入单可享有贡献值.例.推荐100获得100贡献值
//             */
//            DappUsdtPerkEntity directDappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(directMemberEntity.getId());
//            if(ObjectUtil.isEmpty(directDappUsdtPerkEntity)){
//                directDappUsdtPerkEntity = new DappUsdtPerkEntity();
//                directDappUsdtPerkEntity.setNftDevote(amount);
//                directDappUsdtPerkEntity.setMemberId(directMemberEntity.getId());
//                dappUsdtPerkEntityMapper.insert(directDappUsdtPerkEntity);
//            }
//
//            BigDecimal directNftDevote = directDappUsdtPerkEntity.getNftDevote();
//            directNftDevote = directNftDevote.add(amount);
//            directDappUsdtPerkEntity.setNftDevote(directNftDevote);
//            dappUsdtPerkEntityMapper.updateById(directDappUsdtPerkEntity);
//
//            BigDecimal directAPercentFundFlowToMemberFlag = this.getAndUpdateMemberPerk(directMemberEntity.getId(), directAPercentCnt);
//            if(directAPercentFundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){
//                //生成一条10%直推的资金流水记录
//                DappFundFlowEntity directAPercentFundFlowToMember = new DappFundFlowEntity(
//                        directMemberEntity.getId(),
//                        directAPercentFundFlowToMemberFlag,
//                        FundFlowEnum.DIRECT_A_PERCENT.getCode(),
//                        2,
//                        BigDecimal.ZERO,
//                        null,
//                        chergeRecordId);
//                dappFundFlowDao.insert(directAPercentFundFlowToMember);
//                //用户的A币账户增加directAPercentCnt数量
//                dappWalletService.updateWalletMineWithLock(directAPercentFundFlowToMemberFlag,directMemberEntity.getId(),1);
//            }
//            if(directAPercentCnt.compareTo(directAPercentFundFlowToMemberFlag) > 0){
//                DappFundFlowEntity directAPercentFundFlowToMemberAva = new DappFundFlowEntity(
//                        1L,
//                        directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag),
//                        FundFlowEnum.DIRECT_A_PERCENT.getCode(),
//                        2,
//                        BigDecimal.ZERO,
//                        null,
//                        chergeRecordId);
//                dappFundFlowDao.insert(directAPercentFundFlowToMemberAva);
//                dappWalletService.updateWalletMineWithLock(directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag),
//                        AppContants.YL_MEMBER_ID,1);
//            }
//        }
//        /**
//         * 5%节点
//         */
//        DataDictionaryCustom nodeAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_A_PERCENT.getType(),
//                PoolEnum.NODE_A_PERCENT.getCode()
//        );
//        BigDecimal nodeAPercent = new BigDecimal(StrUtil.isEmpty(nodeAPercentDic.getValue()) ? "0.05" : nodeAPercentDic.getValue());
//        BigDecimal nodeAPercentCnt = realCnt.multiply(nodeAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//        //生成一条5%节点的资金流水记录
//        DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity(
//                1L,
//                nodeAPercentCnt,
//                FundFlowEnum.NODE_A_PERCENT.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(nodeAPercentFundFlow);
////        chainProducer.sendAntACoinInNodeMsg(nodeAPercentFundFlow.getId());
//        DataDictionaryCustom nodeAPercentPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.NODE_A_PERCENT_POOL.getType(),
//                PoolEnum.NODE_A_PERCENT_POOL.getCode()
//        );
//        BigDecimal nodeAPercentPoolDicCnt = new BigDecimal(StrUtil.isEmpty(nodeAPercentPoolDic.getValue()) ? "0" : nodeAPercentPoolDic.getValue());
//        nodeAPercentPoolDicCnt = nodeAPercentPoolDicCnt.add(nodeAPercentCnt);
//        nodeAPercentPoolDic.setValue(nodeAPercentPoolDicCnt.toString());
//        dataDictionaryCustomMapper.updateById(nodeAPercentPoolDic);
//
//        BigDecimal nodeAPercentCntAva = superNodePoolPerk(nodeAPercentCnt, NodeCodeEnum.SUPER_NODE.getCode(), FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode());
//
//        if(nodeAPercentCnt.compareTo(nodeAPercentCntAva) > 0){
//            DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity(
//                    1L,
//                    nodeAPercentCnt.subtract(nodeAPercentCntAva),
//                    FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(),
//                    2,
//                    BigDecimal.ZERO,
//                    null,
//                    chergeRecordId);
//            dappFundFlowDao.insert(nodeAPercentFundFlowAva);
//            dappWalletService.updateWalletMineWithLock(nodeAPercentCnt.subtract(nodeAPercentCntAva),
//                    AppContants.YL_MEMBER_ID,1);
//        }
//        /**
//         * 5%基金会
//         */
//        DataDictionaryCustom foundationAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.FOUNDATION_A_PERCENT.getType(),
//                PoolEnum.FOUNDATION_A_PERCENT.getCode()
//        );
//        BigDecimal foundationAPercent = new BigDecimal(StrUtil.isEmpty(foundationAPercentDic.getValue()) ? "0.05" : foundationAPercentDic.getValue());
//        BigDecimal foundationAPercentCnt = realCnt.multiply(foundationAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        //生成一条5%基金会的资金流水记录
//        DappFundFlowEntity foundationAPercentFundFlow = new DappFundFlowEntity(
//                295L,
//                foundationAPercentCnt,
//                FundFlowEnum.FOUNDATION_A_PERCENT.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(foundationAPercentFundFlow);
//        //用户的A币账户增加memberGetACnt数量
//        dappWalletService.updateWalletMineWithLock(foundationAPercentCnt,295L,1);
//        /**
//         * 10%级差奖
//         */
//        DataDictionaryCustom levelAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.LEVEL_A_PERCENT.getType(),
//                PoolEnum.LEVEL_A_PERCENT.getCode()
//        );
//        BigDecimal levelAPercent = new BigDecimal(StrUtil.isEmpty(levelAPercentDic.getValue()) ? "0.1" : levelAPercentDic.getValue());
//        BigDecimal levelAPercentCnt = realCnt.multiply(levelAPercent).setScale(4, BigDecimal.ROUND_DOWN);
//
//        //生成一条10%级差奖进入10%级差奖底池的资金流水记录
//        DappFundFlowEntity levelAPercentCntFundFlow = new DappFundFlowEntity(
//                1L,
//                levelAPercentCnt,
//                FundFlowEnum.LEVEL_A_PERCENT_CNT.getCode(),
//                2,
//                BigDecimal.ZERO,
//                null,
//                chergeRecordId);
//        dappFundFlowDao.insert(levelAPercentCntFundFlow);
//        chainProducer.sendAntACoinInLevelMsg(levelAPercentCntFundFlow.getId());
//
//        /**
//         * 更新用户为有效用户
//         */
//        dappMemberDao.updateMemberActiveStatus(1,memberId);
    }
@@ -2578,23 +2578,10 @@
            for(MallAchieveRecord mallAchieveRecord : mallAchieveRecords){
                //释放总额
                BigDecimal costAmount = mallAchieveRecord.getCostAmount();
                //剩余
                BigDecimal amount = mallAchieveRecord.getAmount();
                if(BigDecimal.ZERO.compareTo(amount) >= 0){
                    mallAchieveRecord.setIsNormal(2);
                    mallAchieveRecordMapper.updateById(mallAchieveRecord);
                    continue;
                }
                //每日释放金额
                BigDecimal eachDayPerk = costAmount.multiply(staticRelease).setScale(2,BigDecimal.ROUND_DOWN);
                if(eachDayPerk.compareTo(amount) >= 0){
                    eachDayPerk = amount;
                    mallAchieveRecord.setIsNormal(2);
                }
                DappMemberEntity mallAchieveMemberEntity = dappMemberDao.selectById(mallAchieveRecord.getMemberId());
                sendPerk(mallAchieveMemberEntity,eachDayPerk,mallAchieveRecord.getOrderId(),FundFlowEnum.STATIC_RELEASE.getCode());
                //实时更新用户等级
                chainProducer.sendAutoLevelUpTeamMsg(perkMemberId);
            }
        }
@@ -2627,7 +2614,7 @@
            //需要判断小区业绩
            if( MemberLevelEnum.V1.getType().equals(nextLevelName)){
                if (!teamAchieve(parent, teamLevelPerk)) {
                if (!teamAchieveOther(parent, teamLevelPerk)) {
                    continue;
                }
            }else{
@@ -2677,7 +2664,6 @@
    }
    /**
     * 团队业绩是否达标
     *  除去直属的最大的一个业绩团队,剩余的所有业绩之和
     */
    private boolean teamAchieveOther(DappMemberEntity member, TeamLevelPerk teamLevelPerk ) {
        BigDecimal teamIncome = teamLevelPerk.getSmallAchieve();
@@ -2756,13 +2742,37 @@
         * 直推消费分享:享受直接分享人每日消费金额释放的100%加速;
         */
        for(DappMemberEntity dappMemberEntity : dappMemberEntityList){
            Long memberId = dappMemberEntity.getId();
            String inviteId = dappMemberEntity.getInviteId();
            //该用户全部的直推用户
            List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectChildMemberDirectOrNot(inviteId, 1, 1);
            for(DappMemberEntity directMember : dappMemberEntities){
                if(1 != directMember.getActiveStatus()){
                    return;
                }
                Long directMemberId = directMember.getId();
                chainProducer.sendDirectPerkMsg(directMemberId);
                DataDictionaryCustom directReleaseDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                        DataDictionaryEnum.DIRECT_RELEASE.getType(),
                        DataDictionaryEnum.DIRECT_RELEASE.getCode()
                );
                if(ObjectUtil.isEmpty(directReleaseDic)){
                    return;
                }
                BigDecimal directRelease = new BigDecimal(directReleaseDic.getValue() == null ? "0" : directReleaseDic.getValue());
                if(BigDecimal.ZERO.compareTo(directRelease) >= 0){
                    return;
                }
                DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(dappMemberEntity.getRefererId());
                /**
                 * 获取用户前一天的所有返利记录
                 */
                List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByMemberIdAndTypeAndDate(directMemberId,
                        FundFlowEnum.STATIC_RELEASE.getCode(),DateUtil.offsetHour(DateUtil.date(),12));
                for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){
                    BigDecimal staticReleaseAmount = dappFundFlowEntity.getAmount();
                    BigDecimal directReleaseAmount = staticReleaseAmount.multiply(directRelease).setScale(2, BigDecimal.ROUND_DOWN);
                    sendPerk(parentMember,directReleaseAmount,dappFundFlowEntity.getSystemProfitId(),FundFlowEnum.DIRECT_AMOUNT.getCode());
                }
            }
        }
    }
@@ -2811,34 +2821,209 @@
        BigDecimal staticRelease = new BigDecimal(ObjectUtil.isEmpty(staticReleaseDic) ? "0.006" : staticReleaseDic.getValue());
        List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V1.getType());
        shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V1.getCode());
        teamStaticPerkMemberLevel(dappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V1.getCode());
        List<DappMemberEntity> v2DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V2.getType());
        shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V2.getCode());
        teamStaticPerkMemberLevel(v2DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V2.getCode());
        List<DappMemberEntity> v3DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V3.getType());
        shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V3.getCode());
        teamStaticPerkMemberLevel(v3DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V3.getCode());
        List<DappMemberEntity> v4DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V4.getType());
        shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V4.getCode());
        teamStaticPerkMemberLevel(v4DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V4.getCode());
        List<DappMemberEntity> v5DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V5.getType());
        shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V5.getCode());
        teamStaticPerkMemberLevel(v5DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V5.getCode());
        List<DappMemberEntity> v6DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V6.getType());
        shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V6.getCode());
        teamStaticPerkMemberLevel(v6DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V6.getCode());
        List<DappMemberEntity> v7DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V7.getType());
        shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V7.getCode());
        teamStaticPerkMemberLevel(v7DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V7.getCode());
    }
    public void shareStaticPerk(List<DappMemberEntity> dappMemberEntities,int code) {
    @Override
    public void updateAchieve() {
        /**
         * 每个人预期获得的总流水
         */
        List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByTypeAndDate(FundFlowEnum.ADD_AMOUNT.getCode(), DateUtil.date());
        if(CollUtil.isEmpty(dappFundFlowEntities)){
            return;
        }
        for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){
            Long memberId = dappFundFlowEntity.getMemberId();
            //当日预期总收益
            BigDecimal amount = dappFundFlowEntity.getAmount();
            if(BigDecimal.ZERO.compareTo(amount) >= 0){
                continue;
            }
            //当日预期总收益
            BigDecimal amountMagic = amount;
            List<MallAchieveRecord> mallAchieveRecords = mallAchieveRecordMapper.selectListByMemberId(memberId);
            if(CollUtil.isEmpty(mallAchieveRecords)){
                return;
            }
            //实际获取总收益
            BigDecimal localTotalAchieve = BigDecimal.ZERO;
            BigDecimal totalAchieve = mallAchieveRecords.stream().map(MallAchieveRecord::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
            //当日获取总收益大于总业绩
            if(amount.compareTo(totalAchieve) >= 0){
                for(MallAchieveRecord memberAchieve : mallAchieveRecords){
                    memberAchieve.setIsNormal(2);
                    memberAchieve.setAmount(BigDecimal.ZERO);
                    mallAchieveRecordMapper.updateById(memberAchieve);
                }
                localTotalAchieve = totalAchieve;
                amount = amount.subtract(totalAchieve);
            }else{
                /**
                 *
                 * amount 100 a1 100 a2 30 a3 10
                 * localTotalAchieve 100 100
                 * amount 0 0
                 *
                 */
                for(MallAchieveRecord memberAchieve : mallAchieveRecords){
                    BigDecimal achieveAmount = memberAchieve.getAmount();
                    if(amount.compareTo(achieveAmount) < 0){
                        memberAchieve.setAmount(achieveAmount.subtract(amount).setScale(2,BigDecimal.ROUND_DOWN));
                        mallAchieveRecordMapper.updateById(memberAchieve);
                        localTotalAchieve = localTotalAchieve.add(amount);
                        amount = BigDecimal.ZERO;
                        continue;
                    }else{
                        memberAchieve.setIsNormal(2);
                        memberAchieve.setAmount(BigDecimal.ZERO);
                        mallAchieveRecordMapper.updateById(memberAchieve);
                        localTotalAchieve = localTotalAchieve.add(achieveAmount);
                        amount = amount.subtract(achieveAmount);
                    }
                }
            }
            /**
             * 用户减少赠送积分
             */
            DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
            DappWalletMineEntity dappWalletMineEntity = dappWalletMineDao.selectByMemberId(memberId);
            BigDecimal totalScore = dappWalletMineEntity.getTotalAmount();
            BigDecimal availableScore = dappWalletMineEntity.getAvailableAmount();
            if(localTotalAchieve.compareTo(totalScore) >= 0){
                localTotalAchieve = totalScore;
                //当实际获取大于用户的赠送积分,将用户更新为未激活
                dappMemberEntity.setActiveStatus(2);
                dappMemberDao.updateById(dappMemberEntity);
            }
            DappAccountMoneyChangeEntity reduceScoreAMC = new DappAccountMoneyChangeEntity(
                    memberId,
                    totalScore,
                    amountMagic.negate(),
                    localTotalAchieve.negate(),
                    FundFlowEnum.REDUCE_SCORE.getCode(),
                    null);
            dappAccountMoneyChangeDao.insert(reduceScoreAMC);
            //插入积分流水
            DappFundFlowEntity scoreFlow = new DappFundFlowEntity(
                    memberId,
                    localTotalAchieve.negate(),
                    FundFlowEnum.REDUCE_SCORE_REAL.getCode(),
                    DappFundFlowEntity.WITHDRAW_STATUS_AGREE,
                    BigDecimal.ZERO);
            dappFundFlowDao.insert(scoreFlow);
            BigDecimal totalScoreRelease = totalScore.subtract(localTotalAchieve);
            BigDecimal availableScoreRelease = availableScore.subtract(localTotalAchieve);
            //更新积分账户
            dappWalletMineEntity.setTotalAmount(totalScoreRelease);
            dappWalletMineEntity.setAvailableAmount(availableScoreRelease);
            dappWalletMineDao.updateById(dappWalletMineEntity);
            //用户增加余额
            DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberId);
            BigDecimal totalAmount = dappWalletCoinEntity.getTotalAmount();
            BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount();
            DappAccountMoneyChangeEntity addAmountAMC = new DappAccountMoneyChangeEntity(
                    memberId,
                    totalAmount,
                    amountMagic,
                    localTotalAchieve,
                    FundFlowEnum.ADD_AMOUNT_REAL.getCode(),
                    null);
            dappAccountMoneyChangeDao.insert(addAmountAMC);
            //插入余额流水
            DappFundFlowEntity amountFlow = new DappFundFlowEntity(
                    memberId,
                    localTotalAchieve,
                    FundFlowEnum.ADD_AMOUNT_REAL.getCode(),
                    DappFundFlowEntity.WITHDRAW_STATUS_AGREE,
                    BigDecimal.ZERO);
            dappFundFlowDao.insert(amountFlow);
            BigDecimal totalAmountRelease = totalAmount.add(localTotalAchieve);
            BigDecimal availableAmountRelease = availableAmount.add(localTotalAchieve);
            //更新余额账户
            dappWalletCoinEntity.setTotalAmount(totalAmountRelease);
            dappWalletCoinEntity.setAvailableAmount(availableAmountRelease);
            dappWalletCoinDao.updateById(dappWalletCoinEntity);
            //实时更新用户等级
            chainProducer.sendAutoLevelUpTeamMsg(memberId);
        }
    }
    public void shareStaticPerk(List<DappMemberEntity> dappMemberEntities,
                                int code) {
        if(CollUtil.isEmpty(dappMemberEntities)){
            return;
        }
        for(DappMemberEntity dappMemberEntity : dappMemberEntities){
            /**
             * 每个人的第一次入单之后的业绩不一样
             */
            Date createTime = dappMemberEntity.getCreateTime();
            //下第一单之后的共享区全部业绩
            BigDecimal totalAchieve = mallAchieveRecordMapper.selectAchieveTotalByCreateTime(createTime);
            //个人总业绩
            BigDecimal totalMemberAchieve = mallAchieveRecordMapper.selectAchieveTotalByMemberIdAndCreateTime(dappMemberEntity.getId(), createTime);
            if(BigDecimal.ZERO.compareTo(totalAchieve) >= 0 || BigDecimal.ZERO.compareTo(totalMemberAchieve) >= 0){
                continue;
            }
            String accountType = dappMemberEntity.getAccountType();
            DataDictionaryCustom accountTypeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                    "TEAM_LEVEL", accountType
            );
            if(ObjectUtil.isEmpty(accountTypeDic)){
                continue;
            }
            TeamLevelPerk teamLevelPerk = JSONObject.parseObject(accountTypeDic.getValue(), TeamLevelPerk.class);
            BigDecimal shareMinPercent = teamLevelPerk.getShareMinPercent();
            BigDecimal sharePerk = totalAchieve.multiply(shareMinPercent).setScale(2,BigDecimal.ROUND_DOWN);
            BigDecimal shareMaxPercent = teamLevelPerk.getShareMaxPercent();
            BigDecimal maxSharePerk = totalMemberAchieve.multiply(shareMaxPercent).setScale(2,BigDecimal.ROUND_DOWN);
            if(BigDecimal.ZERO.compareTo(sharePerk) >= 0 || BigDecimal.ZERO.compareTo(maxSharePerk) >= 0){
                continue;
            }
            //共享区加速万分之2,上限1.2%(按本金计)
            if(sharePerk.compareTo(maxSharePerk) >= 0){
                sharePerk = maxSharePerk;
            }
            sendPerk(dappMemberEntity, sharePerk, dappMemberEntity.getId(), code);
        }
    }
@@ -2883,7 +3068,7 @@
                //V1加速团队静态收益的15%=每日静态的20000*6‰*15%=18元的额外释放加速
                BigDecimal cashAmount = teamIncomeMax.multiply(cashPercent).multiply(staticRelease).setScale(2, BigDecimal.ROUND_DOWN);
                BigDecimal bigDecimal = sendPerk(teamPerkMember, cashAmount, null, code);
                BigDecimal bigDecimal = sendPerk(teamPerkMember, cashAmount, teamPerkMember.getId(), code);
            }
        }
@@ -2892,49 +3077,10 @@
    private BigDecimal sendPerk(DappMemberEntity parentMember,BigDecimal directReleaseAmount,Long orderId
                ,Integer fundFlowEnumType){
        BigDecimal realScoreReduce = BigDecimal.ZERO;
        BigDecimal realScoreReduce = directReleaseAmount;
        if(BigDecimal.ZERO.compareTo(directReleaseAmount) >= 0){
            return realScoreReduce;
        }
        /**
         * 减少业绩
         */
        List<MallAchieveRecord> mallAchieveRecords = mallAchieveRecordMapper.selectListByMemberId(parentMember.getId());
        if(CollUtil.isEmpty(mallAchieveRecords)){
            return realScoreReduce;
        }
        BigDecimal totalAchieve = mallAchieveRecords.stream().map(MallAchieveRecord::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
        if(directReleaseAmount.compareTo(totalAchieve) >= 0){
            realScoreReduce = totalAchieve;
            for(MallAchieveRecord mallAchieveRecord : mallAchieveRecords){
                mallAchieveRecord.setAmount(BigDecimal.ZERO);
                mallAchieveRecord.setIsNormal(2);
                mallAchieveRecordMapper.updateById(mallAchieveRecord);
            }
        }
        /**
         * 用户减少赠送积分
         */
        DappWalletMineEntity dappWalletMineEntity = dappWalletMineDao.selectByMemberId(parentMember.getId());
        BigDecimal totalScore = dappWalletMineEntity.getTotalAmount();
        BigDecimal availableScore = dappWalletMineEntity.getAvailableAmount();
        if(BigDecimal.ZERO.compareTo(totalScore) >= 0){
            parentMember.setActiveStatus(2);
            dappMemberDao.updateById(parentMember);
            return realScoreReduce;
        }
        if(directReleaseAmount.compareTo(totalScore) > 0){
            realScoreReduce = totalScore;
        }else{
            realScoreReduce = directReleaseAmount;
        }
        BigDecimal totalScoreRelease = totalScore.subtract(realScoreReduce);
        BigDecimal availableScoreRelease = availableScore.subtract(realScoreReduce);
        //更新积分账户
        dappWalletMineEntity.setTotalAmount(totalScoreRelease);
        dappWalletMineEntity.setAvailableAmount(availableScoreRelease);
        dappWalletMineDao.updateById(dappWalletMineEntity);
        //插入积分流水
        DappFundFlowEntity scoreFlow = new DappFundFlowEntity(
                parentMember.getId(),
@@ -2944,15 +3090,6 @@
                BigDecimal.ZERO,
                orderId);
        dappFundFlowDao.insert(scoreFlow);
        DappAccountMoneyChangeEntity reduceScoreAMC = new DappAccountMoneyChangeEntity(
                parentMember.getId(),
                totalScore,
                realScoreReduce.negate(),
                totalScoreRelease,
                FundFlowEnum.REDUCE_SCORE.getCode(),
                orderId.toString());
        dappAccountMoneyChangeDao.insert(reduceScoreAMC);
        //生成一条静态补贴的流水
        DappFundFlowEntity realUsdtAmountFlow = new DappFundFlowEntity(
                parentMember.getId(),
@@ -2962,17 +3099,6 @@
                BigDecimal.ZERO,
                orderId);
        dappFundFlowDao.insert(realUsdtAmountFlow);
        //用户增加余额
        DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(parentMember.getId());
        BigDecimal totalAmount = dappWalletCoinEntity.getTotalAmount();
        BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount();
        BigDecimal totalAmountRelease = totalAmount.add(realScoreReduce);
        BigDecimal availableAmountRelease = availableAmount.add(realScoreReduce);
        //更新余额账户
        dappWalletCoinEntity.setTotalAmount(totalAmountRelease);
        dappWalletCoinEntity.setAvailableAmount(availableAmountRelease);
        dappWalletCoinDao.updateById(dappWalletCoinEntity);
        //插入余额流水
        DappFundFlowEntity amountFlow = new DappFundFlowEntity(
                parentMember.getId(),
@@ -2982,15 +3108,6 @@
                BigDecimal.ZERO,
                orderId);
        dappFundFlowDao.insert(amountFlow);
        DappAccountMoneyChangeEntity addAmountAMC = new DappAccountMoneyChangeEntity(
                parentMember.getId(),
                totalAmount,
                realScoreReduce,
                totalAmountRelease,
                FundFlowEnum.ADD_AMOUNT.getCode(),
                orderId.toString());
        dappAccountMoneyChangeDao.insert(addAmountAMC);
        return realScoreReduce;
    }
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
@@ -75,47 +75,6 @@
    private final DappUsdtPerkEntityMapper dappUsdtPerkEntityMapper;
    @Override
    public WalletInfoVo walletInfo() {
        DappMemberEntity member = LoginUserUtil.getAppUser();
        DappMemberEntity memberInfo = dappMemberDao.selectById(member.getId());
        WalletInfoVo walletInfo = new WalletInfoVo();
        List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, 1);
        DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId());
        DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId());
        DappMineDataEntity mineData = dappSystemDao.selectMineDataForOne();
        walletInfo.setDirectCnt(direct.size());
        walletInfo.setInviteId(member.getActiveStatus() == 1 ? member.getInviteId() : "-");
        walletInfo.setBalance(walletCoin.getAvailableAmount());
        walletInfo.setHasBuy(memberInfo.getActiveStatus());
        walletInfo.setOutCnt(memberInfo.getOutCnt());
        walletInfo.setProfit(dappFundFlowDao.selectProfitAmountByMemberId(member.getId()));
        walletInfo.setTfcBalance(walletMine.getAvailableAmount());
        walletInfo.setSafePool(mineData.getSafePool());
        walletInfo.setAccountType(memberInfo.getAccountType());
        DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectByMemberIdAndState(memberInfo.getId(),DappSystemProfit.STATE_IN);
        walletInfo.setSystemProfitId(ObjectUtil.isEmpty(dappSystemProfit) ? 0L : dappSystemProfit.getId());
        BigDecimal directProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberInfo.getId(),3,2);
        walletInfo.setDirectProfit(directProfit);
        BigDecimal levelProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberInfo.getId(),4,2);
        walletInfo.setLevelProfit(levelProfit);
        BigDecimal luckyProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberInfo.getId(),7,2);
        walletInfo.setLuckyProfit(luckyProfit);
        if(DataDictionaryEnum.BIG_BOSS.getCode().equals(memberInfo.getAccountType())){
            walletInfo.setRunPercent(new BigDecimal(100));
        }else{
            walletInfo.setRunPercent(new BigDecimal(90));
        }
        //获取会员节点信息
        List<DappMemberNodeVo> dappMemberNodeVos = dappMemberNodeMapper.selectListByMemberId(member.getId());
        walletInfo.setDappMemberNodeVos(dappMemberNodeVos);
        return walletInfo;
    }
    @Override
    public List<DappFundFlowEntity> recordInPage(RecordInPageDto recordInPageDto) {
        Page<DappFundFlowEntity> page = new Page<>(recordInPageDto.getPageNum(), recordInPageDto.getPageSize());
@@ -155,206 +114,6 @@
        return dappAccountMoneyChangeDao.selectInPage(change, page);
    }
    /**
     * // 第一次{amount: val, fee: 0, txHash: '', type: 1, buyType: 2}
     *       // 成功{type: 1, txHash: result.transactionHash, id: res.data, flag: 'success', buyType: 2}
     *       // 失败{type: 1, id: res.data, flag: 'fail', buyType: 2}
     */
    @Override
    public Long transfer(TransferDto transferDto) {
        DappMemberEntity member = LoginUserUtil.getAppUser();
        String upgrade = redisUtils.getString("APP_UPGRADE");
        if ("upgrade".equals(upgrade)) {
            throw new FebsException("功能升级中");
        }
//        if (transferDto.getType() != 2) {
//            member = dappMemberDao.selectById(member.getId());
//            if (member.getActiveStatus() == 1) {
//                throw new FebsException("Do not repeat purchase");
//            }
//        }
        /**
         * buyType=1,余额购买
         */
        if (transferDto.getBuyType() == 1) {
            DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId());
            if (transferDto.getAmount().compareTo(walletCoin.getAvailableAmount()) > 0) {
                throw new FebsException("Balance Not Enough");
            }
            updateWalletCoinWithLock(transferDto.getAmount(), member.getId(), 2);
            DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), transferDto.getAmount().negate(), 1, 2, transferDto.getFee(), transferDto.getTxHash());
            dappFundFlowDao.insert(fundFlow);
//            chainProducer.sendAchieveTreeMsg(member.getId());
        } else {
            /**
             * buyType=2,钱包购买
             */
            int type = FundFlowEnum.BUY_NODE.getCode();
            // 1-认购 2-充值tfc
            if (transferDto.getType() == 2) {
                type = 6;
            }
            /**
             * 第一次请求,生成一条资金流水ID,并且返回。
             */
            if (transferDto.getId() == null) {
                /**
                 * 验证节点的价格是否和入参价格一致
                 */
                String nodeCode = transferDto.getNodeCode();
                DappNodeOrderEntity dappNodeOrderEntity = dappNodeOrderMapper.selectNodeOrderByNodeCodeForupdate(nodeCode);
                BigDecimal price = dappNodeOrderEntity.getPrice();
                BigDecimal amount = transferDto.getAmount();
                if(price.compareTo(amount) != 0){
                    throw new FebsException("刷新后重试");
//                    throw new FebsException("Refresh and try again");
                }
                Integer surplusCnt = dappNodeOrderEntity.getSurplusCnt();
                if(0 >= surplusCnt){
                    throw new FebsException("该节点剩余数量为0。");
                }
                /**
                 * 超级节点只允许购买一次
                 */
                if(NodeCodeEnum.SUPER_NODE.getCode().equals(nodeCode)){
                    DappMemberNodeEntity superNode = dappMemberNodeMapper.selectNodeByMemberIdAndNodeCode(
                            member.getId(), NodeCodeEnum.SUPER_NODE.getCode());
                    if(ObjectUtil.isNotEmpty(superNode)){
                        throw new FebsException("超级节点只能购买一次");
                    }
                }
                DappFundFlowEntity fundFlowOld = dappFundFlowDao.selectBymemberIdAndType(member.getId(),type,DappFundFlowEntity.WITHDRAW_STATUS_ING);
                if(ObjectUtil.isNotEmpty(fundFlowOld)){
                    //网络问题导致第二次提交前,未成功就关闭了页面
                    if (fundFlowOld.getStatus() == 1 && StrUtil.isEmpty(fundFlowOld.getFromHash())) {
                        dappFundFlowDao.deleteById(fundFlowOld.getId());
                        throw new FebsException("Refresh and try again");
                    }
                }
                DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), transferDto.getAmount(), type, 1, transferDto.getFee(), transferDto.getTxHash(),transferDto.getNodeCode());
                dappFundFlowDao.insert(fundFlow);
                return fundFlow.getId();
            }
            if ("success".equals(transferDto.getFlag())) {
                DappFundFlowEntity flow = dappFundFlowDao.selectById(transferDto.getId());
                if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == flow.getStatus()){
                    throw new FebsException("请勿重复提交");
//                    throw new FebsException("Do not repeat purchase");
                }
                /**
                 * 生成会员节点表记录
                 */
                String nodeCode = transferDto.getNodeCode();
                DappNodeOrderEntity dappNodeOrderEntity = dappNodeOrderMapper.selectNodeOrderByNodeCodeForupdate(nodeCode);
                DappMemberNodeEntity dappMemberNodeEntityNew = new DappMemberNodeEntity(
                        member.getId(),
                        dappNodeOrderEntity.getId(),
                        dappNodeOrderEntity.getNodeCode(),
                        transferDto.getAmount()
                );
                dappMemberNodeMapper.insert(dappMemberNodeEntityNew);
                Integer surplusCnt = dappNodeOrderEntity.getSurplusCnt();
                surplusCnt = surplusCnt - 1;
                dappNodeOrderEntity.setSurplusCnt(surplusCnt);
                dappNodeOrderMapper.updateById(dappNodeOrderEntity);
                /**
                 * 流水关联用户购买节点记录
                 */
                flow.setSystemProfitId(dappMemberNodeEntityNew.getId());
                /**
                 * 链上转账的hash值
                 */
                flow.setFromHash(transferDto.getTxHash());
                flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE);
                dappFundFlowDao.updateById(flow);
                /**
                 * 升级账号类型为对应的节点名称
                 */
//                dappMemberDao.updateMemberAccountType(dappNodeOrderEntity.getNodeName(),member.getId());
                /**
                 * 更新账号的状态为已激活-即已经购买节点
                 */
//                dappMemberDao.updateMemberActiveStatus(1,member.getId());
                /**
                 * 直推奖励
                 */
                DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
                String refererId = dappMemberEntity.getRefererId();
                DappMemberEntity refererMember = dappMemberDao.selectMemberInfoByInviteId(refererId);
                DataDictionaryCustom directProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                        DataDictionaryEnum.DIRECT_PROFIT.getType(),
                        DataDictionaryEnum.DIRECT_PROFIT.getCode());
                BigDecimal directProfitPercent = new BigDecimal(StrUtil.isEmpty(directProfitDic.getValue()) ? "0.1" : directProfitDic.getValue());
                BigDecimal amount = transferDto.getAmount();
                BigDecimal directProfit = amount.multiply(directProfitPercent).setScale(6,BigDecimal.ROUND_DOWN);
                //生成直推奖励的流水
                DappFundFlowEntity fundFlow = new DappFundFlowEntity(
                        refererMember.getId(),
                        directProfit,
                        2,
                        1,
                        BigDecimal.ZERO,
                        null,
                        dappMemberNodeEntityNew.getId());
                dappFundFlowDao.insert(fundFlow);
                /**
                 * 发送转币消息
                 */
                chainProducer.sendBnbTransferMsg(fundFlow.getId());
                BigDecimal subtract = amount.subtract(directProfit);
                //剩余的钱给分走
                DappFundFlowEntity fundFlowEntityProject = new DappFundFlowEntity(
                        4L,
                        subtract,
                        3,
                        1,
                        BigDecimal.ZERO,
                        null,
                        dappMemberNodeEntityNew.getId());
                dappFundFlowDao.insert(fundFlowEntityProject);
                /**
                 * 发送转币消息
                 */
                chainProducer.sendBnbTransferMsg(fundFlowEntityProject.getId());
            } else {
                DappFundFlowEntity flow = dappFundFlowDao.selectById(transferDto.getId());
                if (flow.getStatus() == 1) {
                    dappFundFlowDao.deleteById(transferDto.getId());
                }
            }
        }
        return null;
    }
    @Override
    public BigDecimal calPrice(PriceDto priceDto) {
//        String priceStr = redisUtils.getString(AppContants.REDIS_KEY_TFC_NEW_PRICE);
        DataDictionaryCustom symbolPrice = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode());
        DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getType(), DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getCode());
        BigDecimal amount = priceDto.getAmount();
        if (priceDto.getAmount() == null) {
            amount = BigDecimal.ZERO;
        }
        return amount.multiply(new BigDecimal(serviceFeeDic.getValue()).divide(BigDecimal.valueOf(100), 8, RoundingMode.HALF_DOWN)).divide(new BigDecimal(symbolPrice.getValue()), 2, RoundingMode.HALF_UP);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void withdraw(WithdrawDto withdrawDto) {
@@ -363,115 +122,115 @@
         * 提币需要*当前a币价格,转换成USDT
         * A币卖币规则,卖出100%销毁,30%回流底池溢价
         */
        DappMemberEntity member = LoginUserUtil.getAppUser();
//        DappMemberEntity member = LoginUserUtil.getAppUser();
//
//        DataDictionaryCustom systemStateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.SYSTEM.getType(),
//                PoolEnum.SYSTEM.getCode()
//        );
//        String value = systemStateDic.getValue();
//        if("STOP".equals(value)){
//            throw new FebsException("Not yet open");
//        }
//        //提币数量
//        BigDecimal amount = withdrawDto.getAmount();
//        if(BigDecimal.ZERO.compareTo(amount) >= 0){
//            throw new FebsException("输入正确的数量");
//        }
//        DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId());
//        if (walletCoin.getAvailableAmount().compareTo(withdrawDto.getAmount()) < 0) {
//            throw new FebsException("可提现的数量不足");
//        }
//        DataDictionaryCustom aCoinPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.COIN_A_PRICE.getType(),
//                PoolEnum.COIN_A_PRICE.getCode()
//        );
//        BigDecimal coinAPrice = new BigDecimal(aCoinPriceDic.getValue());
//        //预计提现的USDT数量 = 币的数量 * 当前A币的价格
//        BigDecimal coinUsdtAmount = amount.multiply(coinAPrice);
//        /**
//         * 卖币可享有贡献值,鼓励卖币,例.卖出价值100U获得100贡献值
//         */
//        DappUsdtPerkEntity directDappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(member.getId());
//        if(ObjectUtil.isEmpty(directDappUsdtPerkEntity)){
//            directDappUsdtPerkEntity = new DappUsdtPerkEntity();
//            directDappUsdtPerkEntity.setNftDevote(coinUsdtAmount);
//            directDappUsdtPerkEntity.setMemberId(member.getId());
//            dappUsdtPerkEntityMapper.insert(directDappUsdtPerkEntity);
//        }
//
//        BigDecimal directNftDevote = directDappUsdtPerkEntity.getNftDevote();
//        directNftDevote = directNftDevote.add(coinUsdtAmount);
//        directDappUsdtPerkEntity.setNftDevote(directNftDevote);
//        dappUsdtPerkEntityMapper.updateById(directDappUsdtPerkEntity);
//
//        DataDictionaryCustom toUsdtPercentFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.WALLET_COIN_TO_USDT_PERCENT.getType(),
//                PoolEnum.WALLET_COIN_TO_USDT_PERCENT.getCode()
//        );
//        BigDecimal feePercent = new BigDecimal(toUsdtPercentFeeDic.getValue());
//        //手续费扣除USDT
//        BigDecimal feeUsdtAmount = coinUsdtAmount.multiply(feePercent).setScale(4,BigDecimal.ROUND_DOWN);
//        //实际提现USDT数量,先扣除1%的手续费后,只到账70%
//
//        DataDictionaryCustom outPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.WALLET_COIN_OUT_PERCENT.getType(),
//                PoolEnum.WALLET_COIN_OUT_PERCENT.getCode()
//        );
//        BigDecimal outPercent = new BigDecimal(outPercentDic.getValue());
//        BigDecimal realUsdtAmount = coinUsdtAmount.subtract(feeUsdtAmount).setScale(4,BigDecimal.ROUND_DOWN);
//        BigDecimal realUsdtAmountFee = realUsdtAmount.multiply(outPercent).setScale(4,BigDecimal.ROUND_DOWN);
//        realUsdtAmount = realUsdtAmount.subtract(realUsdtAmountFee);
//        //减少闪对钱包的币的数量
//        this.updateWalletCoinWithLock(amount, member.getId(), 2);
//        //增加流水
//        DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity(member.getId(), amount.negate(), FundFlowEnum.WALLET_COIN_TO_USDT.getCode(), 2, BigDecimal.ZERO);
//        dappFundFlowDao.insert(dappFundFlowEntity);
//        //增加流水
//        DappFundFlowEntity realUsdtAmountFlow = new DappFundFlowEntity(member.getId(), realUsdtAmount.negate(), FundFlowEnum.WALLET_COIN_TO_USDT_W.getCode(), 1, feeUsdtAmount);
//        dappFundFlowDao.insert(realUsdtAmountFlow);
//        //增加提现的记录
//        MemberCoinWithdrawEntity memberCoinWithdraw = new MemberCoinWithdrawEntity();
//        memberCoinWithdraw.setMemberId(member.getId());
//        memberCoinWithdraw.setAddress(member.getAddress());
//        memberCoinWithdraw.setAmount(realUsdtAmount);
//        memberCoinWithdraw.setFeeAmount(feeUsdtAmount);
//        memberCoinWithdraw.setStatus(MemberCoinWithdrawEntity.STATUS_YES);
//        memberCoinWithdraw.setSymbol("USDT");
//        memberCoinWithdraw.setFlowId(realUsdtAmountFlow.getId());
//        memberCoinWithdrawDao.insert(memberCoinWithdraw);
//        //发送提现消息
////        chainProducer.sendAntACoinOutMsg(realUsdtAmountFlow.getId());
//
//        /**
//         * A币卖币规则,卖出100%销毁,30%回流底池溢价
//         */
//        BigDecimal coinUsdtAmountFee = coinUsdtAmount.multiply(new BigDecimal(0.2)).setScale(4,BigDecimal.ROUND_DOWN);
////        coinUsdtAmount = coinUsdtAmount.multiply(outPercent).setScale(4,BigDecimal.ROUND_DOWN);
//        //金本位底池数量
//        DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.COIN_A_USDT_PRICE.getType(),
//                PoolEnum.COIN_A_USDT_PRICE.getCode()
//        );
//        BigDecimal coinAUsdtCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
//        coinAUsdtCnt = coinAUsdtCnt.subtract(coinUsdtAmount).add(coinUsdtAmountFee).setScale(4,BigDecimal.ROUND_DOWN);
//        coinAUsdtPriceDic.setValue(coinAUsdtCnt.toString());
//        dataDictionaryCustomMapper.updateById(coinAUsdtPriceDic);
//        //币本位底池数量
//        DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.COIN_A_CNT.getType(),
//                PoolEnum.COIN_A_CNT.getCode()
//        );
//        BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue());
//        coinACnt = coinACnt.subtract(amount).setScale(4,BigDecimal.ROUND_DOWN);
//        coinACntDic.setValue(coinACnt.toString());
//        dataDictionaryCustomMapper.updateById(coinACntDic);
//
//        coinAPrice = coinAUsdtCnt.divide(coinACnt,12,BigDecimal.ROUND_DOWN);
//        aCoinPriceDic.setValue(coinAPrice.toString());
//        dataDictionaryCustomMapper.updateById(aCoinPriceDic);
        DataDictionaryCustom systemStateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.SYSTEM.getType(),
                PoolEnum.SYSTEM.getCode()
        );
        String value = systemStateDic.getValue();
        if("STOP".equals(value)){
            throw new FebsException("Not yet open");
        }
        //提币数量
        BigDecimal amount = withdrawDto.getAmount();
        if(BigDecimal.ZERO.compareTo(amount) >= 0){
            throw new FebsException("输入正确的数量");
        }
        DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId());
        if (walletCoin.getAvailableAmount().compareTo(withdrawDto.getAmount()) < 0) {
            throw new FebsException("可提现的数量不足");
        }
        DataDictionaryCustom aCoinPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_PRICE.getType(),
                PoolEnum.COIN_A_PRICE.getCode()
        );
        BigDecimal coinAPrice = new BigDecimal(aCoinPriceDic.getValue());
        //预计提现的USDT数量 = 币的数量 * 当前A币的价格
        BigDecimal coinUsdtAmount = amount.multiply(coinAPrice);
        /**
         * 卖币可享有贡献值,鼓励卖币,例.卖出价值100U获得100贡献值
         */
        DappUsdtPerkEntity directDappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(member.getId());
        if(ObjectUtil.isEmpty(directDappUsdtPerkEntity)){
            directDappUsdtPerkEntity = new DappUsdtPerkEntity();
            directDappUsdtPerkEntity.setNftDevote(coinUsdtAmount);
            directDappUsdtPerkEntity.setMemberId(member.getId());
            dappUsdtPerkEntityMapper.insert(directDappUsdtPerkEntity);
        }
        BigDecimal directNftDevote = directDappUsdtPerkEntity.getNftDevote();
        directNftDevote = directNftDevote.add(coinUsdtAmount);
        directDappUsdtPerkEntity.setNftDevote(directNftDevote);
        dappUsdtPerkEntityMapper.updateById(directDappUsdtPerkEntity);
        DataDictionaryCustom toUsdtPercentFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.WALLET_COIN_TO_USDT_PERCENT.getType(),
                PoolEnum.WALLET_COIN_TO_USDT_PERCENT.getCode()
        );
        BigDecimal feePercent = new BigDecimal(toUsdtPercentFeeDic.getValue());
        //手续费扣除USDT
        BigDecimal feeUsdtAmount = coinUsdtAmount.multiply(feePercent).setScale(4,BigDecimal.ROUND_DOWN);
        //实际提现USDT数量,先扣除1%的手续费后,只到账70%
        DataDictionaryCustom outPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.WALLET_COIN_OUT_PERCENT.getType(),
                PoolEnum.WALLET_COIN_OUT_PERCENT.getCode()
        );
        BigDecimal outPercent = new BigDecimal(outPercentDic.getValue());
        BigDecimal realUsdtAmount = coinUsdtAmount.subtract(feeUsdtAmount).setScale(4,BigDecimal.ROUND_DOWN);
        BigDecimal realUsdtAmountFee = realUsdtAmount.multiply(outPercent).setScale(4,BigDecimal.ROUND_DOWN);
        realUsdtAmount = realUsdtAmount.subtract(realUsdtAmountFee);
        //减少闪对钱包的币的数量
        this.updateWalletCoinWithLock(amount, member.getId(), 2);
        //增加流水
        DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity(member.getId(), amount.negate(), FundFlowEnum.WALLET_COIN_TO_USDT.getCode(), 2, BigDecimal.ZERO);
        dappFundFlowDao.insert(dappFundFlowEntity);
        //增加流水
        DappFundFlowEntity realUsdtAmountFlow = new DappFundFlowEntity(member.getId(), realUsdtAmount.negate(), FundFlowEnum.WALLET_COIN_TO_USDT_W.getCode(), 1, feeUsdtAmount);
        dappFundFlowDao.insert(realUsdtAmountFlow);
        //增加提现的记录
        MemberCoinWithdrawEntity memberCoinWithdraw = new MemberCoinWithdrawEntity();
        memberCoinWithdraw.setMemberId(member.getId());
        memberCoinWithdraw.setAddress(member.getAddress());
        memberCoinWithdraw.setAmount(realUsdtAmount);
        memberCoinWithdraw.setFeeAmount(feeUsdtAmount);
        memberCoinWithdraw.setStatus(MemberCoinWithdrawEntity.STATUS_YES);
        memberCoinWithdraw.setSymbol("USDT");
        memberCoinWithdraw.setFlowId(realUsdtAmountFlow.getId());
        memberCoinWithdrawDao.insert(memberCoinWithdraw);
        //发送提现消息
        chainProducer.sendAntACoinOutMsg(realUsdtAmountFlow.getId());
        /**
         * A币卖币规则,卖出100%销毁,30%回流底池溢价
         */
        BigDecimal coinUsdtAmountFee = coinUsdtAmount.multiply(new BigDecimal(0.2)).setScale(4,BigDecimal.ROUND_DOWN);
//        coinUsdtAmount = coinUsdtAmount.multiply(outPercent).setScale(4,BigDecimal.ROUND_DOWN);
        //金本位底池数量
        DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_USDT_PRICE.getType(),
                PoolEnum.COIN_A_USDT_PRICE.getCode()
        );
        BigDecimal coinAUsdtCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
        coinAUsdtCnt = coinAUsdtCnt.subtract(coinUsdtAmount).add(coinUsdtAmountFee).setScale(4,BigDecimal.ROUND_DOWN);
        coinAUsdtPriceDic.setValue(coinAUsdtCnt.toString());
        dataDictionaryCustomMapper.updateById(coinAUsdtPriceDic);
        //币本位底池数量
        DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.COIN_A_CNT.getType(),
                PoolEnum.COIN_A_CNT.getCode()
        );
        BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue());
        coinACnt = coinACnt.subtract(amount).setScale(4,BigDecimal.ROUND_DOWN);
        coinACntDic.setValue(coinACnt.toString());
        dataDictionaryCustomMapper.updateById(coinACntDic);
        coinAPrice = coinAUsdtCnt.divide(coinACnt,12,BigDecimal.ROUND_DOWN);
        aCoinPriceDic.setValue(coinAPrice.toString());
        dataDictionaryCustomMapper.updateById(aCoinPriceDic);
        chainProducer.sendAntKLineMsg(0);
//        chainProducer.sendAntKLineMsg(0);
    }
    @Override
@@ -541,7 +300,7 @@
            if (i > 0) {
                isSuccess = true;
                DappFundFlowEntity frozenAmount = new DappFundFlowEntity(memberId, amount, 9, 2, null, null);
                DappFundFlowEntity frozenAmount = new DappFundFlowEntity();
                dappFundFlowDao.insert(frozenAmount);
            }
        }
@@ -565,10 +324,10 @@
            if (i > 0) {
                isSuccess = true;
                DappFundFlowEntity releaseFrozen = new DappFundFlowEntity(memberId, frozen, 10, 2, null, null);
                DappFundFlowEntity releaseFrozen = new DappFundFlowEntity();
                dappFundFlowDao.insert(releaseFrozen);
                DappFundFlowEntity releaseFrozenNegate = new DappFundFlowEntity(memberId, frozen.negate(), 9, 2, null, null);
                DappFundFlowEntity releaseFrozenNegate = new DappFundFlowEntity();
                dappFundFlowDao.insert(releaseFrozenNegate);
            }
        }
@@ -581,53 +340,53 @@
    @Override
    public void transferAgain(TransferDto transferDto) {
        Long memberId = transferDto.getMemberId();
        DappMemberEntity member = dappMemberDao.selectById(memberId);
        String upgrade = redisUtils.getString("APP_UPGRADE");
        if ("upgrade".equals(upgrade)) {
            throw new FebsException("功能升级中");
        }
        if ("success".equals(transferDto.getFlag())) {
            //是否已经加入动能
            DappSystemProfit dappSystemProfitIng = dappSystemProfitDao.selectByMemberIdAndState(member.getId(), DappSystemProfit.STATE_IN);
            if(ObjectUtil.isNotEmpty(dappSystemProfitIng)){
                return;
            }
            //插入一条会员入列记录,即加入动能队列
            DappSystemProfit dappSystemProfit = new DappSystemProfit(member.getId(), transferDto.getAmount());
            dappSystemProfitDao.insert(dappSystemProfit);
            DappFundFlowEntity flow = dappFundFlowDao.selectById(transferDto.getId());
            flow.setFromHash(transferDto.getTxHash());
            flow.setSystemProfitId(dappSystemProfit.getId());
            flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE);
            dappFundFlowDao.updateById(flow);
            //直接拿走0.05个BNB放入技术方
            DataDictionaryCustom systemProfit = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYSTEM_PROFIT.getType(), DataDictionaryEnum.SYSTEM_PROFIT.getCode());
            String systemProfitStr = StrUtil.isEmpty(systemProfit.getValue()) ? "0.05" : systemProfit.getValue();
            DappFundFlowEntity systemProfitFlow = new DappFundFlowEntity(1L, new BigDecimal(systemProfitStr), 2, 1, BigDecimal.ZERO, null,dappSystemProfit.getId());
            dappFundFlowDao.insert(systemProfitFlow);
            //发送转币消息
            chainProducer.sendBnbTransferMsg(systemProfitFlow.getId());
            //直接返利30%给直接上级
            DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
            String refererId = dappMemberEntity.getRefererId();
            DappMemberEntity refererMember = dappMemberDao.selectMemberInfoByInviteId(refererId);
            DataDictionaryCustom directProfitSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.DIRECT_PROFIT.getType(), DataDictionaryEnum.DIRECT_PROFIT.getCode());
            BigDecimal directProfitStr = new BigDecimal(StrUtil.isEmpty(directProfitSet.getValue()) ? "0.3" : directProfitSet.getValue());
            BigDecimal directProfit = (transferDto.getAmount().subtract(new BigDecimal(systemProfitStr))).multiply(directProfitStr).setScale(6,BigDecimal.ROUND_DOWN);
            DappFundFlowEntity fundFlow = new DappFundFlowEntity(refererMember.getId(), directProfit, 3, 1, BigDecimal.ZERO, null,dappSystemProfit.getId());
            dappFundFlowDao.insert(fundFlow);
            //发送转币消息
            chainProducer.sendBnbTransferMsg(fundFlow.getId());
            //层级奖励30%
            chainProducer.sendLevelProfitMsg(dappSystemProfit.getId());
            //发送一个消息,计算当前是否有人可以出局
            chainProducer.sendMemberOutMsg(dappSystemProfit.getId());
        }
//        Long memberId = transferDto.getMemberId();
//        DappMemberEntity member = dappMemberDao.selectById(memberId);
//        String upgrade = redisUtils.getString("APP_UPGRADE");
//        if ("upgrade".equals(upgrade)) {
//            throw new FebsException("功能升级中");
//        }
//        if ("success".equals(transferDto.getFlag())) {
//            //是否已经加入动能
//            DappSystemProfit dappSystemProfitIng = dappSystemProfitDao.selectByMemberIdAndState(member.getId(), DappSystemProfit.STATE_IN);
//            if(ObjectUtil.isNotEmpty(dappSystemProfitIng)){
//                return;
//            }
//            //插入一条会员入列记录,即加入动能队列
//            DappSystemProfit dappSystemProfit = new DappSystemProfit(member.getId(), transferDto.getAmount());
//            dappSystemProfitDao.insert(dappSystemProfit);
//            DappFundFlowEntity flow = dappFundFlowDao.selectById(transferDto.getId());
//            flow.setFromHash(transferDto.getTxHash());
//            flow.setSystemProfitId(dappSystemProfit.getId());
//            flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE);
//            dappFundFlowDao.updateById(flow);
//
//            //直接拿走0.05个BNB放入技术方
//            DataDictionaryCustom systemProfit = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYSTEM_PROFIT.getType(), DataDictionaryEnum.SYSTEM_PROFIT.getCode());
//            String systemProfitStr = StrUtil.isEmpty(systemProfit.getValue()) ? "0.05" : systemProfit.getValue();
//            DappFundFlowEntity systemProfitFlow = new DappFundFlowEntity(1L, new BigDecimal(systemProfitStr), 2, 1, BigDecimal.ZERO, null,dappSystemProfit.getId());
//            dappFundFlowDao.insert(systemProfitFlow);
//            //发送转币消息
//            chainProducer.sendBnbTransferMsg(systemProfitFlow.getId());
//            //直接返利30%给直接上级
//            DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
//            String refererId = dappMemberEntity.getRefererId();
//            DappMemberEntity refererMember = dappMemberDao.selectMemberInfoByInviteId(refererId);
//
//            DataDictionaryCustom directProfitSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.DIRECT_PROFIT.getType(), DataDictionaryEnum.DIRECT_PROFIT.getCode());
//            BigDecimal directProfitStr = new BigDecimal(StrUtil.isEmpty(directProfitSet.getValue()) ? "0.3" : directProfitSet.getValue());
//            BigDecimal directProfit = (transferDto.getAmount().subtract(new BigDecimal(systemProfitStr))).multiply(directProfitStr).setScale(6,BigDecimal.ROUND_DOWN);
//
//            DappFundFlowEntity fundFlow = new DappFundFlowEntity(refererMember.getId(), directProfit, 3, 1, BigDecimal.ZERO, null,dappSystemProfit.getId());
//            dappFundFlowDao.insert(fundFlow);
//            //发送转币消息
//            chainProducer.sendBnbTransferMsg(fundFlow.getId());
//            //层级奖励30%
//            chainProducer.sendLevelProfitMsg(dappSystemProfit.getId());
//            //发送一个消息,计算当前是否有人可以出局
//            chainProducer.sendMemberOutMsg(dappSystemProfit.getId());
//
//        }
    }
    public static void main(String[] args) {
@@ -678,27 +437,28 @@
         * buyType=1,余额购买
         */
        if (transferADto.getBuyType() == 1) {
            DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId());
            if (transferADto.getAmount().compareTo(walletCoin.getAvailableAmount()) > 0) {
                throw new FebsException("Balance Not Enough");
            }
            updateWalletCoinWithLock(transferADto.getAmount(), member.getId(), 2);
            DappFundFlowEntity fundFlow = new DappFundFlowEntity(
                    member.getId(),
                    transferADto.getAmount().negate(),
                    FundFlowEnum.BUY_A_COIN.getCode(),
                    2,
                    transferADto.getFee(),
                    transferADto.getTxHash());
            dappFundFlowDao.insert(fundFlow);
//            DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId());
//            if (transferADto.getAmount().compareTo(walletCoin.getAvailableAmount()) > 0) {
//                throw new FebsException("Balance Not Enough");
//            }
//
//            updateWalletCoinWithLock(transferADto.getAmount(), member.getId(), 2);
//
//            DappFundFlowEntity fundFlow = new DappFundFlowEntity(
//                    member.getId(),
//                    transferADto.getAmount().negate(),
//                    FundFlowEnum.BUY_A_COIN.getCode(),
//                    2,
//                    transferADto.getFee(),
//                    transferADto.getTxHash());
//            dappFundFlowDao.insert(fundFlow);
        } else {
            /**
             * buyType=2,钱包购买
             * 4:入金,买入A币
             */
            int type = FundFlowEnum.BUY_A_COIN.getCode();
//            int type = FundFlowEnum.BUY_A_COIN.getCode();
            int type = 4;
            // 1-认购 2-充值tfc
            if (transferADto.getType() == 2) {
                type = 6;
@@ -905,66 +665,66 @@
         * 4、增加闪对钱包
         * 5、增加流水
         */
        DappMemberEntity member = LoginUserUtil.getAppUser();
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
        BigDecimal aCoinCnt = mineToCoinDto.getACoinCnt();
        if(BigDecimal.ZERO.compareTo(aCoinCnt) >= 0){
            throw new FebsException("输入正确的数量");
        }
        DappWalletMineEntity dappWalletMineEntity = dappWalletMineDao.selectByMemberId(dappMemberEntity.getId());
        BigDecimal availableAmount = dappWalletMineEntity.getAvailableAmount();
        if(availableAmount.compareTo(aCoinCnt) < 0){
            throw new FebsException("数量不足");
        }
        //减少资产钱包
        this.updateWalletMineWithLock(aCoinCnt,dappMemberEntity.getId(),2);
        //插入资产闪对的流水
        DappFundFlowEntity aCoinCntFlow = new DappFundFlowEntity(
                dappMemberEntity.getId(),
                aCoinCnt.negate(),
                FundFlowEnum.WALLET_MINE_TO_COIN.getCode(),
                2,
                BigDecimal.ZERO);
        dappFundFlowDao.insert(aCoinCntFlow);
        //闪对钱包3% 手续费(扣币)
        DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.WALLET_MINE_TO_COIN_PERCENT.getType(),
                PoolEnum.WALLET_MINE_TO_COIN_PERCENT.getCode());
        BigDecimal feePercent = new BigDecimal(StrUtil.isEmpty(dic.getValue()) ? "0.03" : dic.getValue());
        //手续费
        BigDecimal feeCnt = aCoinCnt.multiply(feePercent).setScale(4,BigDecimal.ROUND_DOWN);
        //闪对钱包获取的
        BigDecimal aCoinCntReal = aCoinCnt.subtract(feeCnt).setScale(4, BigDecimal.ROUND_DOWN);
        //增加闪对钱包
        this.updateWalletCoinWithLock(aCoinCntReal,dappMemberEntity.getId(),1);
        //插入资产闪对的流水
        DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity(
                dappMemberEntity.getId(),
                aCoinCntReal,
                FundFlowEnum.WALLET_MINE_TO_COIN.getCode(),
                2,
                BigDecimal.ZERO);
        dappFundFlowDao.insert(dappFundFlowEntity);
        //插入资产闪对手续费的流水
        DappFundFlowEntity memberFeeflow = new DappFundFlowEntity(
                dappMemberEntity.getId(),
                feeCnt.negate(),
                FundFlowEnum.WALLET_MINE_TO_COIN_FEE.getCode(),
                2,
                BigDecimal.ZERO);
        dappFundFlowDao.insert(memberFeeflow);
        //插入资产闪对手续费的流水
        DappFundFlowEntity dappFundFlowEntityFee = new DappFundFlowEntity(
                295L,
                feeCnt,
                FundFlowEnum.WALLET_MINE_TO_COIN_FEE.getCode(),
                2,
                BigDecimal.ZERO);
        dappFundFlowDao.insert(dappFundFlowEntityFee);
        this.updateWalletMineWithLock(feeCnt,295L,1);
//        DappMemberEntity member = LoginUserUtil.getAppUser();
//        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
//
//        BigDecimal aCoinCnt = mineToCoinDto.getACoinCnt();
//        if(BigDecimal.ZERO.compareTo(aCoinCnt) >= 0){
//            throw new FebsException("输入正确的数量");
//        }
//
//        DappWalletMineEntity dappWalletMineEntity = dappWalletMineDao.selectByMemberId(dappMemberEntity.getId());
//        BigDecimal availableAmount = dappWalletMineEntity.getAvailableAmount();
//        if(availableAmount.compareTo(aCoinCnt) < 0){
//            throw new FebsException("数量不足");
//        }
//        //减少资产钱包
//        this.updateWalletMineWithLock(aCoinCnt,dappMemberEntity.getId(),2);
//        //插入资产闪对的流水
//        DappFundFlowEntity aCoinCntFlow = new DappFundFlowEntity(
//                dappMemberEntity.getId(),
//                aCoinCnt.negate(),
//                FundFlowEnum.WALLET_MINE_TO_COIN.getCode(),
//                2,
//                BigDecimal.ZERO);
//        dappFundFlowDao.insert(aCoinCntFlow);
//        //闪对钱包3% 手续费(扣币)
//        DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.WALLET_MINE_TO_COIN_PERCENT.getType(),
//                PoolEnum.WALLET_MINE_TO_COIN_PERCENT.getCode());
//        BigDecimal feePercent = new BigDecimal(StrUtil.isEmpty(dic.getValue()) ? "0.03" : dic.getValue());
//        //手续费
//        BigDecimal feeCnt = aCoinCnt.multiply(feePercent).setScale(4,BigDecimal.ROUND_DOWN);
//        //闪对钱包获取的
//        BigDecimal aCoinCntReal = aCoinCnt.subtract(feeCnt).setScale(4, BigDecimal.ROUND_DOWN);
//        //增加闪对钱包
//        this.updateWalletCoinWithLock(aCoinCntReal,dappMemberEntity.getId(),1);
//        //插入资产闪对的流水
//        DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity(
//                dappMemberEntity.getId(),
//                aCoinCntReal,
//                FundFlowEnum.WALLET_MINE_TO_COIN.getCode(),
//                2,
//                BigDecimal.ZERO);
//        dappFundFlowDao.insert(dappFundFlowEntity);
//
//        //插入资产闪对手续费的流水
//        DappFundFlowEntity memberFeeflow = new DappFundFlowEntity(
//                dappMemberEntity.getId(),
//                feeCnt.negate(),
//                FundFlowEnum.WALLET_MINE_TO_COIN_FEE.getCode(),
//                2,
//                BigDecimal.ZERO);
//        dappFundFlowDao.insert(memberFeeflow);
//        //插入资产闪对手续费的流水
//        DappFundFlowEntity dappFundFlowEntityFee = new DappFundFlowEntity(
//                295L,
//                feeCnt,
//                FundFlowEnum.WALLET_MINE_TO_COIN_FEE.getCode(),
//                2,
//                BigDecimal.ZERO);
//        dappFundFlowDao.insert(dappFundFlowEntityFee);
//        this.updateWalletMineWithLock(feeCnt,295L,1);
    }
    @Override
@@ -987,27 +747,27 @@
         * buyType=1,余额购买
         */
        if (transferAusdDto.getBuyType() == 1) {
            DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId());
            if (transferAusdDto.getAmount().compareTo(walletCoin.getAvailableAmount()) > 0) {
                throw new FebsException("Balance Not Enough");
            }
            updateWalletCoinWithLock(transferAusdDto.getAmount(), member.getId(), 2);
            DappFundFlowEntity fundFlow = new DappFundFlowEntity(
                    member.getId(),
                    transferAusdDto.getAmount().negate(),
                    FundFlowEnum.BUY_AUSD_COIN.getCode(),
                    2,
                    transferAusdDto.getFee(),
                    transferAusdDto.getTxHash());
            dappFundFlowDao.insert(fundFlow);
//            DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId());
//            if (transferAusdDto.getAmount().compareTo(walletCoin.getAvailableAmount()) > 0) {
//                throw new FebsException("Balance Not Enough");
//            }
//
//            updateWalletCoinWithLock(transferAusdDto.getAmount(), member.getId(), 2);
//
//            DappFundFlowEntity fundFlow = new DappFundFlowEntity(
//                    member.getId(),
//                    transferAusdDto.getAmount().negate(),
//                    FundFlowEnum.BUY_AUSD_COIN.getCode(),
//                    2,
//                    transferAusdDto.getFee(),
//                    transferAusdDto.getTxHash());
//            dappFundFlowDao.insert(fundFlow);
        } else {
            /**
             * buyType=2,钱包购买
             * 4:入金,买入A币
             */
            int type = FundFlowEnum.BUY_AUSD_COIN.getCode();
            int type = 4;
            // 1-认购 2-充值tfc
            if (transferAusdDto.getType() == 2) {
                type = 6;
@@ -1099,161 +859,161 @@
    @Override
    public void roundCoin(RoundCoinDto roundCoinDto) {
        DappMemberEntity member = LoginUserUtil.getAppUser();
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
        String address = roundCoinDto.getAddress();
        DappMemberEntity memberParent = dappMemberDao.selectByAddress(address, null);
        if(ObjectUtil.isEmpty(memberParent)){
            throw new FebsException("请输入正确的地址");
        }
        BigDecimal coinCnt = roundCoinDto.getCoinCnt();
        if(BigDecimal.ZERO.compareTo(coinCnt) >= 0){
            throw new FebsException("输入正确的数量");
        }
        DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntity.getId());
        BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount();
        if(availableAmount.compareTo(coinCnt) < 0){
            throw new FebsException("数量不足");
        }
        //减少闪兑钱包
        this.updateWalletCoinWithLock(coinCnt,dappMemberEntity.getId(),2);
        //插入资产闪对的流水
        DappFundFlowEntity aCoinCntFlow = new DappFundFlowEntity(
                dappMemberEntity.getId(),
                coinCnt.negate(),
                FundFlowEnum.ANDAO_MEMBER_TO_MENBER.getCode(),
                2,
                BigDecimal.ZERO,
                dappMemberEntity.getAddress(),
                memberParent.getAddress(),
                memberParent.getId());
        dappFundFlowDao.insert(aCoinCntFlow);
        //闪对钱包20% 手续费(扣币)
        DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getType(),
                PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getCode());
        BigDecimal feePercent = new BigDecimal(StrUtil.isEmpty(dic.getValue()) ? "0.2" : dic.getValue());
        //手续费
        BigDecimal feeCnt = coinCnt.multiply(feePercent).setScale(4,BigDecimal.ROUND_DOWN);
        if(AppContants.YL_MEMBER_ID.equals(member.getId())
        || AppContants.YL_MEMBER_ID_TWO.equals(member.getId())){
            feeCnt = BigDecimal.ZERO;
        }
        //闪对钱包获取的
        BigDecimal aCoinCntReal = coinCnt.subtract(feeCnt).setScale(4, BigDecimal.ROUND_DOWN);
        //增加闪对钱包
        this.updateWalletCoinWithLock(aCoinCntReal,memberParent.getId(),1);
        //插入资产闪对的流水
        DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity(
                memberParent.getId(),
                aCoinCntReal,
                FundFlowEnum.ANDAO_MEMBER_TO_MENBER.getCode(),
                2,
                BigDecimal.ZERO,
                dappMemberEntity.getAddress(),
                memberParent.getAddress(),
                dappMemberEntity.getId());
        dappFundFlowDao.insert(dappFundFlowEntity);
        if(BigDecimal.ZERO.compareTo(feeCnt) < 0){
            //金本位底池数量
            DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                    PoolEnum.COIN_A_USDT_PRICE.getType(),
                    PoolEnum.COIN_A_USDT_PRICE.getCode()
            );
            BigDecimal coinAUsdtCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
            //币本位底池数量
            DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                    PoolEnum.COIN_A_CNT.getType(),
                    PoolEnum.COIN_A_CNT.getCode()
            );
            BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue());
            coinACnt = coinACnt.subtract(feeCnt).setScale(4,BigDecimal.ROUND_DOWN);
            coinACntDic.setValue(coinACnt.toString());
            dataDictionaryCustomMapper.updateById(coinACntDic);
            DataDictionaryCustom aCoinPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                    PoolEnum.COIN_A_PRICE.getType(),
                    PoolEnum.COIN_A_PRICE.getCode()
            );
            BigDecimal coinAPrice = new BigDecimal(aCoinPriceDic.getValue());
            coinAPrice = coinAUsdtCnt.divide(coinACnt,12,BigDecimal.ROUND_DOWN);
            aCoinPriceDic.setValue(coinAPrice.toString());
            dataDictionaryCustomMapper.updateById(aCoinPriceDic);
            chainProducer.sendAntKLineMsg(0);
        }
//        DappMemberEntity member = LoginUserUtil.getAppUser();
//        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
//
//        String address = roundCoinDto.getAddress();
//        DappMemberEntity memberParent = dappMemberDao.selectByAddress(address, null);
//        if(ObjectUtil.isEmpty(memberParent)){
//            throw new FebsException("请输入正确的地址");
//        }
//
//        BigDecimal coinCnt = roundCoinDto.getCoinCnt();
//        if(BigDecimal.ZERO.compareTo(coinCnt) >= 0){
//            throw new FebsException("输入正确的数量");
//        }
//
//        DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntity.getId());
//        BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount();
//        if(availableAmount.compareTo(coinCnt) < 0){
//            throw new FebsException("数量不足");
//        }
//        //减少闪兑钱包
//        this.updateWalletCoinWithLock(coinCnt,dappMemberEntity.getId(),2);
//        //插入资产闪对的流水
//        DappFundFlowEntity aCoinCntFlow = new DappFundFlowEntity(
//                dappMemberEntity.getId(),
//                coinCnt.negate(),
//                FundFlowEnum.ANDAO_MEMBER_TO_MENBER.getCode(),
//                2,
//                BigDecimal.ZERO,
//                dappMemberEntity.getAddress(),
//                memberParent.getAddress(),
//                memberParent.getId());
//        dappFundFlowDao.insert(aCoinCntFlow);
//        //闪对钱包20% 手续费(扣币)
//        DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getType(),
//                PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getCode());
//        BigDecimal feePercent = new BigDecimal(StrUtil.isEmpty(dic.getValue()) ? "0.2" : dic.getValue());
//        //手续费
//        BigDecimal feeCnt = coinCnt.multiply(feePercent).setScale(4,BigDecimal.ROUND_DOWN);
//        if(AppContants.YL_MEMBER_ID.equals(member.getId())
//        || AppContants.YL_MEMBER_ID_TWO.equals(member.getId())){
//            feeCnt = BigDecimal.ZERO;
//        }
//        //闪对钱包获取的
//        BigDecimal aCoinCntReal = coinCnt.subtract(feeCnt).setScale(4, BigDecimal.ROUND_DOWN);
//        //增加闪对钱包
//        this.updateWalletCoinWithLock(aCoinCntReal,memberParent.getId(),1);
//        //插入资产闪对的流水
//        DappFundFlowEntity dappFundFlowEntity = new DappFundFlowEntity(
//                memberParent.getId(),
//                aCoinCntReal,
//                FundFlowEnum.ANDAO_MEMBER_TO_MENBER.getCode(),
//                2,
//                BigDecimal.ZERO,
//                dappMemberEntity.getAddress(),
//                memberParent.getAddress(),
//                dappMemberEntity.getId());
//        dappFundFlowDao.insert(dappFundFlowEntity);
//
//        if(BigDecimal.ZERO.compareTo(feeCnt) < 0){
//            //金本位底池数量
//            DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                    PoolEnum.COIN_A_USDT_PRICE.getType(),
//                    PoolEnum.COIN_A_USDT_PRICE.getCode()
//            );
//            BigDecimal coinAUsdtCnt = new BigDecimal(coinAUsdtPriceDic.getValue());
//            //币本位底池数量
//            DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                    PoolEnum.COIN_A_CNT.getType(),
//                    PoolEnum.COIN_A_CNT.getCode()
//            );
//            BigDecimal coinACnt = new BigDecimal(coinACntDic.getValue());
//            coinACnt = coinACnt.subtract(feeCnt).setScale(4,BigDecimal.ROUND_DOWN);
//            coinACntDic.setValue(coinACnt.toString());
//            dataDictionaryCustomMapper.updateById(coinACntDic);
//
//            DataDictionaryCustom aCoinPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                    PoolEnum.COIN_A_PRICE.getType(),
//                    PoolEnum.COIN_A_PRICE.getCode()
//            );
//            BigDecimal coinAPrice = new BigDecimal(aCoinPriceDic.getValue());
//            coinAPrice = coinAUsdtCnt.divide(coinACnt,12,BigDecimal.ROUND_DOWN);
//            aCoinPriceDic.setValue(coinAPrice.toString());
//            dataDictionaryCustomMapper.updateById(aCoinPriceDic);
//
//            chainProducer.sendAntKLineMsg(0);
//        }
    }
    @Override
    public void roundCoinAusdt(RoundCoinDto roundCoinDto) {
        DappMemberEntity member = LoginUserUtil.getAppUser();
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
        String address = roundCoinDto.getAddress();
        DappMemberEntity memberParent = dappMemberDao.selectByAddress(address, null);
        if(ObjectUtil.isEmpty(memberParent)){
            throw new FebsException("请输入正确的地址");
        }
        /**
         * 转ausdt,只能推广线上
         */
        String refererIdsDone = dappMemberEntity.getRefererIds();
        String inviteIdDone = dappMemberEntity.getInviteId();
        String refererIdsOther = memberParent.getRefererIds();
        String inviteId1Other = memberParent.getInviteId();
        if(!(StrUtil.contains(refererIdsOther,inviteIdDone) || StrUtil.contains(refererIdsDone,inviteId1Other))){
            throw new FebsException("不满足互转规则");
        }
        BigDecimal coinCnt = roundCoinDto.getCoinCnt();
        if(BigDecimal.ZERO.compareTo(coinCnt) >= 0){
            throw new FebsException("输入正确的数量");
        }
        DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(dappMemberEntity.getId());
        BigDecimal availableAmount = dappUsdtPerkEntity.getAusdAmount();
        if(availableAmount.compareTo(coinCnt) < 0){
            throw new FebsException("数量不足");
        }
        dappUsdtPerkEntity.setAusdAmount(availableAmount.subtract(coinCnt));
        dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity);
        //插入资产闪对的流水
        DappFundFlowEntity aCoinCntFlow = new DappFundFlowEntity(
                dappMemberEntity.getId(),
                coinCnt.negate(),
                FundFlowEnum.AUSDT_MEMBER_TO_MENBER.getCode(),
                2,
                BigDecimal.ZERO,
                dappMemberEntity.getAddress(),
                memberParent.getAddress(),
                memberParent.getId());
        dappFundFlowDao.insert(aCoinCntFlow);
        DappUsdtPerkEntity parentEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberParent.getId());
        if(ObjectUtil.isEmpty(parentEntity)){
            parentEntity = new DappUsdtPerkEntity();
            parentEntity.setMemberId(memberParent.getId());
            dappUsdtPerkEntityMapper.insert(parentEntity);
        }
        BigDecimal availableAmountParent = ObjectUtil.isEmpty(parentEntity.getAusdAmount()) ? BigDecimal.ZERO : parentEntity.getAusdAmount();
        parentEntity.setAusdAmount(availableAmountParent.add(coinCnt));
        dappUsdtPerkEntityMapper.updateById(parentEntity);
        //插入资产闪对的流水
        DappFundFlowEntity aCoinCntFlowParent = new DappFundFlowEntity(
                memberParent.getId(),
                coinCnt,
                FundFlowEnum.AUSDT_MEMBER_TO_MENBER.getCode(),
                2,
                BigDecimal.ZERO,
                dappMemberEntity.getAddress(),
                memberParent.getAddress(),
                dappMemberEntity.getId());
        dappFundFlowDao.insert(aCoinCntFlowParent);
//        DappMemberEntity member = LoginUserUtil.getAppUser();
//        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(member.getId());
//
//        String address = roundCoinDto.getAddress();
//        DappMemberEntity memberParent = dappMemberDao.selectByAddress(address, null);
//        if(ObjectUtil.isEmpty(memberParent)){
//            throw new FebsException("请输入正确的地址");
//        }
//
//        /**
//         * 转ausdt,只能推广线上
//         */
//        String refererIdsDone = dappMemberEntity.getRefererIds();
//        String inviteIdDone = dappMemberEntity.getInviteId();
//        String refererIdsOther = memberParent.getRefererIds();
//        String inviteId1Other = memberParent.getInviteId();
//        if(!(StrUtil.contains(refererIdsOther,inviteIdDone) || StrUtil.contains(refererIdsDone,inviteId1Other))){
//            throw new FebsException("不满足互转规则");
//        }
//
//        BigDecimal coinCnt = roundCoinDto.getCoinCnt();
//        if(BigDecimal.ZERO.compareTo(coinCnt) >= 0){
//            throw new FebsException("输入正确的数量");
//        }
//
//        DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(dappMemberEntity.getId());
//        BigDecimal availableAmount = dappUsdtPerkEntity.getAusdAmount();
//        if(availableAmount.compareTo(coinCnt) < 0){
//            throw new FebsException("数量不足");
//        }
//        dappUsdtPerkEntity.setAusdAmount(availableAmount.subtract(coinCnt));
//        dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity);
//        //插入资产闪对的流水
//        DappFundFlowEntity aCoinCntFlow = new DappFundFlowEntity(
//                dappMemberEntity.getId(),
//                coinCnt.negate(),
//                FundFlowEnum.AUSDT_MEMBER_TO_MENBER.getCode(),
//                2,
//                BigDecimal.ZERO,
//                dappMemberEntity.getAddress(),
//                memberParent.getAddress(),
//                memberParent.getId());
//        dappFundFlowDao.insert(aCoinCntFlow);
//
//        DappUsdtPerkEntity parentEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberParent.getId());
//        if(ObjectUtil.isEmpty(parentEntity)){
//            parentEntity = new DappUsdtPerkEntity();
//            parentEntity.setMemberId(memberParent.getId());
//            dappUsdtPerkEntityMapper.insert(parentEntity);
//        }
//        BigDecimal availableAmountParent = ObjectUtil.isEmpty(parentEntity.getAusdAmount()) ? BigDecimal.ZERO : parentEntity.getAusdAmount();
//        parentEntity.setAusdAmount(availableAmountParent.add(coinCnt));
//        dappUsdtPerkEntityMapper.updateById(parentEntity);
//        //插入资产闪对的流水
//        DappFundFlowEntity aCoinCntFlowParent = new DappFundFlowEntity(
//                memberParent.getId(),
//                coinCnt,
//                FundFlowEnum.AUSDT_MEMBER_TO_MENBER.getCode(),
//                2,
//                BigDecimal.ZERO,
//                dappMemberEntity.getAddress(),
//                memberParent.getAddress(),
//                dappMemberEntity.getId());
//        dappFundFlowDao.insert(aCoinCntFlowParent);
    }
}
src/main/java/cc/mrbird/febs/dapp/vo/DappMemberInfoVo.java
@@ -13,58 +13,19 @@
    @ApiModelProperty(value = "邀请码")
    private String inviteId;
    @ApiModelProperty(value = "地址")
    private String address;
    @ApiModelProperty(value = "代理身份")
    private String accountType;
    @ApiModelProperty(value = "是否激活 1:已激活 2:未激活  已激活,有推广链接")
    private Integer activeStatus;
    @ApiModelProperty(value = "资产余额")
    private BigDecimal propertyAmount;
    @ApiModelProperty(value = "闪兑余额")
    private BigDecimal exchangeAmount;
    @ApiModelProperty(value = "ASUD余额")
    private BigDecimal ausdAmount;
    @ApiModelProperty(value = "权益额度")
    private BigDecimal amountPerkTotal;
    @ApiModelProperty(value = "剩余额度")
    @ApiModelProperty(value = "钱包余额")
    private BigDecimal amount;
    @ApiModelProperty(value = "AUSD的价格")
    private BigDecimal ausdPrice;
    @ApiModelProperty(value = "A币的价格")
    private BigDecimal coinAPrice;
    @ApiModelProperty(value = "兑换AUSDT的手续费比例")
    private BigDecimal ausdtFee;
    @ApiModelProperty(value = "ANDAO互转手续费比例")
    private BigDecimal aroundFee;
    @ApiModelProperty(value = "资产到闪兑的手续费比例")
    private BigDecimal mineToCoinFee;
    @ApiModelProperty(value = "提现手续费比例")
    private BigDecimal coinOutFee;
    @ApiModelProperty(value = "我的贡献值")
    private BigDecimal nftDevote;
    @ApiModelProperty(value = "是否是超级节点 1:是 2:否")
    private Integer nodeType;
    @ApiModelProperty(value = "今日涨幅")
    private BigDecimal todayIncrease;
    @ApiModelProperty(value = "全网剩余ANDAO总量")
    private BigDecimal andaoNum;
    @ApiModelProperty(value = "燃烧ANDAO总量")
    private BigDecimal fireAndaoNum;
    @ApiModelProperty(value = "赠送积分")
    private BigDecimal score;
}
src/main/java/cc/mrbird/febs/dapp/vo/TeamChildListVo.java
New file
@@ -0,0 +1,40 @@
package cc.mrbird.febs.dapp.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
@ApiModel(value = "TeamChildListVo", description = "团队列表返回参数类")
public class TeamChildListVo {
    @ApiModelProperty(value = "UID")
    private String inviteId;
    @ApiModelProperty(value = "地址")
    private String address;
    @ApiModelProperty(value = "代理等级")
    private String accountType;
    @ApiModelProperty(value = "注册时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @ApiModelProperty(value = "推荐个数")
    private Integer cnt;
    @ApiModelProperty(value = "本人是否下单 1:下过单 2:没下单")
    private Integer achieveState;
    @ApiModelProperty(value = "消费金额(实际业绩)")
    private BigDecimal realAchieve;
    @ApiModelProperty(value = "订单数量")
    private Integer orderCnt;
}
src/main/java/cc/mrbird/febs/dapp/vo/TeamListVo.java
@@ -17,10 +17,16 @@
@ApiModel(value = "TeamLIstVo", description = "团队列表接口返回参数类")
public class TeamListVo {
    @ApiModelProperty(value = "直推人数")
    private int directCnt;
    @ApiModelProperty(value = "我的业绩")
    private BigDecimal myAchieve;
    @ApiModelProperty(value = "团队业绩,不包含本人的")
    private BigDecimal achieve;
    @ApiModelProperty(value = "我的团队业绩")
    private BigDecimal myTeamAchieve;
    @ApiModelProperty(value = "团队数量")
    private int myTeamCnt;
    @ApiModelProperty(value = "团队列表")
    private List<TeamChildListVo> team;
}
src/main/java/cc/mrbird/febs/job/BnbTransferJob.java
@@ -28,32 +28,29 @@
    @Autowired
    private DappSystemService dappSystemService;
    /**
     * 每天按照消费金额的5‰静释放(千分之五的静态释放比例)
     * (按购买顺序结算,同时有5个订单就有结算记录)
     * (设置多少,全部按照最新的来释放)
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void memberPerk() {
        dappSystemService.memberPerk();
    }
    /**
     * 直推消费分享:享受直接分享人每日消费金额释放的100%加速;
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void directMemberPerk() {
        dappSystemService.directMemberPerk();
    }
    /**
     * 加速团队静态收益的70%(业绩全算)
     * 加速团队静态收益为极差制,平级10%
     * 如V1加速团队静态收益的15%=每日静态的20000*6‰*15%=18元的额外释放加速
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void teamStaticPerk() {
        /**
         * 加速团队静态收益的70%(业绩全算)
         * 加速团队静态收益为极差制,平级10%
         * 如V1加速团队静态收益的15%=每日静态的20000*6‰*15%=18元的额外释放加速
         * 共享区加速万分之5,上限1.8%(按本金计)
         */
        dappSystemService.teamStaticPerk();
        /**
         * 每天按照消费金额的5‰静释放(千分之五的静态释放比例)
         * (按购买顺序结算,同时有5个订单就有结算记录)
         * (设置多少,全部按照最新的来释放)
         */
        dappSystemService.memberPerk();
        /**
         * 直推消费分享:享受直接分享人每日消费金额释放的100%加速;
         */
        dappSystemService.directMemberPerk();
        /**
         * 实际更新账户业绩余额和积分
         */
        dappSystemService.updateAchieve();
    }
}
src/main/java/cc/mrbird/febs/job/ProfitDailyJob.java
@@ -28,68 +28,68 @@
@ConditionalOnProperty(prefix = "system", name = "reset-job", havingValue = "true")
public class ProfitDailyJob {
    @Autowired
    private DappMemberDao dappMemberDao;
    @Autowired
    private DappFundFlowDao dappFundFlowDao;
    @Autowired
    private DataDictionaryCustomMapper dataDictionaryCustomMapper;
    @Autowired
    private DappWalletService dappWalletService;
    //todo -- 升级会员等级
    @Scheduled(cron = "0 0 0 * * ?")
    public void profitDailyJob() {
        log.info("每日产矿任务执行");
        DataDictionaryCustom symbolPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode());
        if (symbolPriceDic == null) {
            log.info("未设置币种价格");
            return;
        }
        DataDictionaryCustom rebateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.REBATE_PERCENT.getType(), DataDictionaryEnum.REBATE_PERCENT.getCode());
        if (rebateDic == null) {
            log.info("未设置每日产矿比例");
            return;
        }
        BigDecimal symbolPrice = new BigDecimal(symbolPriceDic.getValue());
        BigDecimal rebateRatio = new BigDecimal(rebateDic.getValue());
        QueryWrapper<DappMemberEntity> query = new QueryWrapper<>();
        query.eq("active_status", 1);
        List<DappMemberEntity> members = dappMemberDao.selectList(query);
        if (CollUtil.isEmpty(members)) {
            return;
        }
        members.forEach(item -> {
            QueryWrapper<DappFundFlowEntity> fundFlowQuery = new QueryWrapper<>();
            fundFlowQuery.eq("member_id", item.getId());
            fundFlowQuery.eq("type", 11);
            List<DappFundFlowEntity> flows = dappFundFlowDao.selectList(fundFlowQuery);
            BigDecimal sum = BigDecimal.ZERO;
            if (CollUtil.isNotEmpty(flows)) {
                double symbolSum = flows.stream().mapToDouble(flow -> flow.getAmount().doubleValue()).sum();
                sum = symbolPrice.multiply(new BigDecimal(symbolSum));
            }
            if (CollUtil.isEmpty(flows) || TreeConstants.PUT_IN_AMOUNT.compareTo(sum) > 0) {
                BigDecimal profitU = TreeConstants.PUT_IN_AMOUNT.multiply(rebateRatio.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_DOWN));
                BigDecimal remain = TreeConstants.PUT_IN_AMOUNT.subtract(sum);
                if (remain.compareTo(profitU) < 0) {
                    profitU = remain;
                }
                BigDecimal profitSymbol = profitU.divide(symbolPrice, 8, RoundingMode.HALF_DOWN);
                dappWalletService.updateWalletMineWithLock(profitSymbol, item.getId(), 1);
                DappFundFlowEntity fundFlow = new DappFundFlowEntity(item.getId(), profitSymbol, 11, 2, null, null);
                dappFundFlowDao.insert(fundFlow);
            }
        });
    }
//    @Autowired
//    private DappMemberDao dappMemberDao;
//    @Autowired
//    private DappFundFlowDao dappFundFlowDao;
//    @Autowired
//    private DataDictionaryCustomMapper dataDictionaryCustomMapper;
//    @Autowired
//    private DappWalletService dappWalletService;
//    //todo -- 升级会员等级
//    @Scheduled(cron = "0 0 0 * * ?")
//    public void profitDailyJob() {
//        log.info("每日产矿任务执行");
//        DataDictionaryCustom symbolPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode());
//        if (symbolPriceDic == null) {
//            log.info("未设置币种价格");
//            return;
//        }
//
//        DataDictionaryCustom rebateDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.REBATE_PERCENT.getType(), DataDictionaryEnum.REBATE_PERCENT.getCode());
//        if (rebateDic == null) {
//            log.info("未设置每日产矿比例");
//            return;
//        }
//
//        BigDecimal symbolPrice = new BigDecimal(symbolPriceDic.getValue());
//        BigDecimal rebateRatio = new BigDecimal(rebateDic.getValue());
//
//        QueryWrapper<DappMemberEntity> query = new QueryWrapper<>();
//        query.eq("active_status", 1);
//        List<DappMemberEntity> members = dappMemberDao.selectList(query);
//        if (CollUtil.isEmpty(members)) {
//            return;
//        }
//
//        members.forEach(item -> {
//            QueryWrapper<DappFundFlowEntity> fundFlowQuery = new QueryWrapper<>();
//            fundFlowQuery.eq("member_id", item.getId());
//            fundFlowQuery.eq("type", 11);
//            List<DappFundFlowEntity> flows = dappFundFlowDao.selectList(fundFlowQuery);
//
//            BigDecimal sum = BigDecimal.ZERO;
//            if (CollUtil.isNotEmpty(flows)) {
//                double symbolSum = flows.stream().mapToDouble(flow -> flow.getAmount().doubleValue()).sum();
//                sum = symbolPrice.multiply(new BigDecimal(symbolSum));
//            }
//
//            if (CollUtil.isEmpty(flows) || TreeConstants.PUT_IN_AMOUNT.compareTo(sum) > 0) {
//                BigDecimal profitU = TreeConstants.PUT_IN_AMOUNT.multiply(rebateRatio.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_DOWN));
//
//                BigDecimal remain = TreeConstants.PUT_IN_AMOUNT.subtract(sum);
//                if (remain.compareTo(profitU) < 0) {
//                    profitU = remain;
//                }
//
//                BigDecimal profitSymbol = profitU.divide(symbolPrice, 8, RoundingMode.HALF_DOWN);
//
//                dappWalletService.updateWalletMineWithLock(profitSymbol, item.getId(), 1);
//                DappFundFlowEntity fundFlow = new DappFundFlowEntity(item.getId(), profitSymbol, 11, 2, null, null);
//                dappFundFlowDao.insert(fundFlow);
//            }
//        });
//
//
//    }
}
src/main/java/cc/mrbird/febs/websocket/WsAuthInterceptor.java
@@ -61,7 +61,7 @@
    private String resolveToken(String token) {
        try {
            RSA rsa = new RSA(AppContants.PRIVATE_KEY, null);
            String[] tokens = StrUtil.split(rsa.decryptStr(token, KeyType.PrivateKey), "_");
            String[] tokens = StrUtil.splitToArray(rsa.decryptStr(token, KeyType.PrivateKey), "_");
//            log.info("websocket token : {}, timestemp : {}", tokens[0], tokens[1]);
            if (verifyTokenExpired(Long.parseLong(tokens[1]))) {
                return tokens[0];
src/main/resources/mapper/dapp/DappFundFlowDao.xml
@@ -188,4 +188,13 @@
          and type = #{type}
          and status = 2
    </select>
    <select id="selectListByTypeAndDate" resultType="cc.mrbird.febs.dapp.entity.DappFundFlowEntity">
        select member_id as memberId,ifnull(sum(amount), 0) as amount
        from dapp_fund_flow
        where date_format(create_time, '%Y-%m-%d') = date_format(#{dateStr}, '%Y-%m-%d')
          and type = #{type}
          and status = 2
        group by member_id
    </select>
</mapper>
src/main/resources/mapper/dapp/DappMemberDao.xml
@@ -92,9 +92,9 @@
    <select id="selectMemberByAccountType" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select * from dapp_member
        <where>
            account_type = #{accountType}
        </where>
        where
            active_status = 1
            and account_type = #{accountType}
    </select>
    <select id="selectChildMemberDirectOrNot" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
@@ -165,6 +165,14 @@
        where referer_id = #{refererId}
    </select>
    <select id="selectAllMemberInfoByRefererId" resultType="cc.mrbird.febs.dapp.entity.DappMemberEntity">
        select
            *
        from dapp_member a
        where FIND_IN_SET(#{inviteId}, referer_ids)
    </select>
    <select id="selectCountByAccountTypeAndRefererId" resultType="java.lang.Integer">
        select count(id)
        from dapp_member
@@ -192,18 +200,10 @@
    <select id="selectByMemberId" resultType="cc.mrbird.febs.dapp.vo.DappMemberInfoVo">
        select
            a.invite_id inviteId,
            a.address address,
            a.account_type accountType,
            a.active_status activeStatus,
            a.node_type nodeType,
            b.ausd_amount ausdAmount,
            b.nft_devote nftDevote,
            b.amount amount,
            c.available_amount propertyAmount,
            d.available_amount exchangeAmount
        from dapp_member a
        left join dapp_usdt_perk b on a.id = b.member_id
        left join dapp_wallet_mine c on a.id = c.member_id
        left join dapp_wallet_coin d on a.id = d.member_id
        where a.id = #{id}
    </select>
src/main/resources/mapper/dapp/MallAchieveRecordMapper.xml
@@ -44,4 +44,53 @@
        order by CREATE_TIME asc
    </select>
    <select id="selectAchieveTotalByMemberIdAndCreateTime" resultType="java.math.BigDecimal">
        select IFNULL(sum(IFNULL(amount,0)),0) from mall_achieve_record
        where
            member_id = #{memberId}
            and payTime >= #{date}
    </select>
    <select id="selectAchieveTotalByCreateTime" resultType="java.math.BigDecimal">
        select IFNULL(sum(IFNULL(amount,0)),0) from mall_achieve_record
        where payTime >= #{date}
    </select>
    <select id="selectAchieveByMemberId" resultType="java.math.BigDecimal">
        select IFNULL(sum(IFNULL(a.amount, 0)), 0)
        from mall_achieve_record a
        inner join dapp_member b on a.member_id = b.ID
        where is_normal = 1
        <if test="type == 1">
            and b.invite_id=#{inviteId}
        </if>
        <if test="type == 2">
            and find_in_set(#{inviteId}, b.referer_ids)
        </if>
    </select>
    <select id="selectTeamListByInviteId" resultType="cc.mrbird.febs.dapp.vo.TeamChildListVo">
        select
            a.invite_id inviteId,
            a.address address,
            a.account_type accountType,
            a.create_time createTime
        from mall_member a
        where a.referrer_id=#{inviteId}
    </select>
    <select id="selectCountByInvitedId" resultType="cc.mrbird.febs.dapp.entity.MallAchieveRecord">
        select *
        from mall_achieve_record a
        inner join dapp_member b on a.member_id = b.ID
        where is_normal = 1
        <if test="type == 1">
            and b.invite_id=#{inviteId}
        </if>
        <if test="type == 2">
            and (find_in_set(#{inviteId}, b.referer_ids) or b.invite_id=#{inviteId})
        </if>
    </select>
</mapper>