Helius
2021-05-14 c1d4d95aeb2cf3572401d7bc00ab6af0ba38a4d5
modify
4 files modified
28 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java 20 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/member/MemberDao.xml 4 ●●●● patch | view | raw | blame | history
src/test/java/com/xcong/excoin/XchTest.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java
@@ -31,4 +31,6 @@
    List<MemberEntity> selectMemberByRefererId(@Param("refererId") String refererId);
    List<MemberEntity> selectTeamAgentList(@Param("inviteId") String inviteId);
    List<MemberEntity> selectPartnerMemberList();
}
src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java
@@ -10,9 +10,11 @@
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
import com.xcong.excoin.modules.yunding.dao.YdBasicLevelSettingDao;
import com.xcong.excoin.modules.yunding.dao.YdBasicSettingDao;
import com.xcong.excoin.modules.yunding.dao.YdOrderDao;
import com.xcong.excoin.modules.yunding.dao.YdProductDao;
import com.xcong.excoin.modules.yunding.entity.YdBasicLevelSettingEntity;
import com.xcong.excoin.modules.yunding.entity.YdBasicSettingEntity;
import com.xcong.excoin.modules.yunding.entity.YdOrderEntity;
import com.xcong.excoin.modules.yunding.entity.YdProductEntity;
import com.xcong.excoin.modules.yunding.service.XchProfitService;
@@ -47,6 +49,9 @@
    @Autowired
    private YunDingProducter yunDingProducter;
    @Autowired
    private YdBasicSettingDao ydBasicSettingDao;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -177,6 +182,21 @@
            updateOrder.setId(order.getId());
            ydOrderDao.updateById(updateOrder);
        }
        List<MemberEntity> partners = memberDao.selectPartnerMemberList();
        YdBasicSettingEntity setting = ydBasicSettingDao.selectById(1L);
        if (CollUtil.isNotEmpty(partners)) {
            BigDecimal returnAmount = order.getAmount().multiply(setting.getPartnerRatio()).divide(BigDecimal.valueOf(partners.size()), 8, BigDecimal.ROUND_DOWN);
            log.info("合伙人分红:{}", returnAmount);
            for (MemberEntity partner : partners) {
                String conent = "合伙人USDT分红";
                LogRecordUtils.insertMemberAccountMoneyChangeWithId(partner.getId(), conent, returnAmount, "USDT", 1, 9, order.getId());
                MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(partner.getId(), "USDT");
                memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), returnAmount, BigDecimal.ZERO, 0);
            }
        }
    }
    private Map<Long, BigDecimal> buildReturnRatioObj(List<MemberEntity> agents, int type) {
src/main/resources/mapper/member/MemberDao.xml
@@ -87,4 +87,8 @@
        where (find_in_set(#{inviteId}, a.referer_ids) or invite_id=#{inviteId})
        and agent_level in (1, 2)
    </select>
    <select id="selectPartnerMemberList" resultType="com.xcong.excoin.modules.member.entity.MemberEntity">
        select * from member where is_trader=1
    </select>
</mapper>
src/test/java/com/xcong/excoin/XchTest.java
@@ -40,7 +40,7 @@
    @Test
    public void orderUsdtProfitTest() {
        xchProfitService.usdtProfitDistributorByOrderId(7L);
        xchProfitService.usdtProfitDistributorByOrderId(1L);
    }
//
//    @Autowired