Helius
2021-01-26 ad01d9ed306451f37d309304f9f1b72616a8a165
Merge branch 'whole_new' of https://gitee.com/chonggaoxiao/new_excoin into whole_new
4 files added
8 files modified
338 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/documentary/controller/TraderController.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/dao/FollowTraderLabelDao.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/dto/UpdateTradeSetInfoDto.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderInfoEntity.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderLabelEntity.java 24 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/service/DocumentaryService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java 76 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/vo/FollowTraderProfitInfoVo.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/vo/TradeSetInfoVo.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/vo/TradeSetLabelInfoVo.java 17 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/documentary/FollowTraderLabelDao.xml 5 ●●●●● patch | view | raw | blame | history
src/test/java/com/xcong/excoin/ReturnMoneyTest.java 181 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/controller/TraderController.java
@@ -20,6 +20,7 @@
import com.xcong.excoin.modules.documentary.vo.TradeOrderInfoVo;
import com.xcong.excoin.modules.documentary.vo.TradeProfitInfoVo;
import com.xcong.excoin.modules.documentary.vo.TradeSetInfoVo;
import com.xcong.excoin.modules.documentary.vo.TradeSetLabelInfoVo;
import com.xcong.excoin.modules.documentary.vo.TraderStatusVo;
import io.swagger.annotations.Api;
@@ -118,6 +119,16 @@
    }
    
    /**
     * 交易员设置--进入编辑---获取标签信息
     */
    @ApiOperation(value="交易员设置--进入编辑---获取标签信息", notes="交易员设置--进入编辑---获取标签信息")
    @ApiResponses({@ApiResponse( code = 200, message = "success", response = TradeSetLabelInfoVo.class)})
    @GetMapping(value = "/getTradeSetLabelInfo")
    public Result  getTradeSetLabelInfo() {
        return documentaryService.getTradeSetLabelInfo();
    }
    /**
     * 交易员设置--更新设置
     */
    @ApiOperation(value="交易员设置--更新设置", notes="交易员设置--更新设置")
src/main/java/com/xcong/excoin/modules/documentary/dao/FollowTraderLabelDao.java
New file
@@ -0,0 +1,8 @@
package com.xcong.excoin.modules.documentary.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xcong.excoin.modules.documentary.entity.FollowTraderLabelEntity;
public interface FollowTraderLabelDao extends BaseMapper<FollowTraderLabelEntity> {
}
src/main/java/com/xcong/excoin/modules/documentary/dto/UpdateTradeSetInfoDto.java
@@ -21,5 +21,7 @@
        @NotNull(message = "宣言不能为空")
        @ApiModelProperty("宣言")
        private String declaration;
        @ApiModelProperty("标签")
        private String labels;
        
}
src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderInfoEntity.java
@@ -38,6 +38,10 @@
     */
    private String declaration;
    /**
     * 标签
     */
    private String labels;
    /**
     * 是否满员 1-是2-否
     */
    private Integer isAll;
src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderLabelEntity.java
New file
@@ -0,0 +1,24 @@
package com.xcong.excoin.modules.documentary.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xcong.excoin.common.system.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("follow_trader_label")
public class FollowTraderLabelEntity extends BaseEntity{
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    /**
     * 标签
     */
    private String labels;
}
src/main/java/com/xcong/excoin/modules/documentary/service/DocumentaryService.java
@@ -69,5 +69,7 @@
    public Result getFollowFollowerNoticeList(@Valid FollowFollowerNoticeDto followFollowerNoticeDto);
    public Result getTradeSetLabelInfo();
}
src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
@@ -16,8 +16,10 @@
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.taobao.api.internal.toplink.embedded.websocket.util.StringUtil;
import com.xcong.excoin.common.LoginUserUtils;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.modules.coin.dao.OrderCoinsDao;
@@ -32,6 +34,7 @@
import com.xcong.excoin.modules.documentary.dao.FollowFollowerProfitDao;
import com.xcong.excoin.modules.documentary.dao.FollowFollowerSettingDao;
import com.xcong.excoin.modules.documentary.dao.FollowTraderInfoDao;
import com.xcong.excoin.modules.documentary.dao.FollowTraderLabelDao;
import com.xcong.excoin.modules.documentary.dao.FollowTraderProfitDetailDao;
import com.xcong.excoin.modules.documentary.dao.FollowTraderProfitInfoDao;
import com.xcong.excoin.modules.documentary.dto.CancelDocumentaryOrderSetDto;
@@ -51,6 +54,7 @@
import com.xcong.excoin.modules.documentary.entity.FollowFollowerProfitEntity;
import com.xcong.excoin.modules.documentary.entity.FollowFollowerSettingEntity;
import com.xcong.excoin.modules.documentary.entity.FollowTraderInfoEntity;
import com.xcong.excoin.modules.documentary.entity.FollowTraderLabelEntity;
import com.xcong.excoin.modules.documentary.entity.FollowTraderProfitInfoEntity;
import com.xcong.excoin.modules.documentary.service.DocumentaryService;
import com.xcong.excoin.modules.documentary.vo.DocumentaryOrderInfoVo;
@@ -68,6 +72,7 @@
import com.xcong.excoin.modules.documentary.vo.TradeOrderInfoVo;
import com.xcong.excoin.modules.documentary.vo.TradeProfitInfoVo;
import com.xcong.excoin.modules.documentary.vo.TradeSetInfoVo;
import com.xcong.excoin.modules.documentary.vo.TradeSetLabelInfoVo;
import com.xcong.excoin.modules.documentary.vo.TraderStatusVo;
import com.xcong.excoin.modules.member.dao.MemberDao;
import com.xcong.excoin.modules.member.dao.MemberLevelRateDao;
@@ -80,6 +85,7 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import jnr.ffi.Struct.int16_t;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@@ -116,6 +122,8 @@
    private FollowFollowerOrderRelationDao followFollowerOrderRelationDao;
    @Resource
    private FollowFollowerNoticeDao followFollowerNoticeDao;
    @Resource
    private FollowTraderLabelDao followTraderLabelDao;
    
    
    @Override
@@ -165,9 +173,38 @@
                FollowTraderProfitInfoVo.setDeclaration(declaration);
                Integer isAll = followTraderInfoEntity.getIsAll();
                FollowTraderProfitInfoVo.setIsAll(isAll);
                String labels = followTraderInfoEntity.getLabels();
                if(StrUtil.isNotEmpty(labels)) {
                    String labelsName = "";
                    String[] split = labels.split(",");
                    int length = split.length;
                    for(int i = 0;i < length;i++) {
                        String string = split[i];
                        FollowTraderLabelEntity selectById = followTraderLabelDao.selectById(Long.parseLong(string));
                        labelsName = selectById.getLabels();
                        labelsName += (labelsName + ",");
                    }
                    FollowTraderProfitInfoVo.setLabels(labelsName);
                }
            }
        }
        return Result.ok(followTraderProfitInfoVoList);
    }
    public static void main(String[] args) {
        String labels = "";
        if(StrUtil.isNotEmpty(labels)) {
            String labelsName = "";
            String[] split = labels.split(",");
            int length = split.length;
            for(int i = 0;i < length;i++) {
                String string = split[i];
                labelsName += (string + ",");
            }
            System.out.println(labelsName);
        }
    }
    @Override
@@ -744,6 +781,20 @@
        tradeSetInfoVo.setDeclaration(declaration);
        Integer isOpen = followTraderInfoEntity.getIsOpen();
        tradeSetInfoVo.setIsOpen(isOpen);
        String labels = followTraderInfoEntity.getLabels();
        if(StrUtil.isNotEmpty(labels)) {
            String labelsName = "";
            String[] split = labels.split(",");
            int length = split.length;
            for(int i = 0;i < length;i++) {
                String string = split[i];
                FollowTraderLabelEntity selectById = followTraderLabelDao.selectById(Long.parseLong(string));
                labelsName = selectById.getLabels();
                labelsName += (labelsName + ",");
            }
            tradeSetInfoVo.setLabels(labelsName);
        }
        return Result.ok(tradeSetInfoVo);
    }
@@ -760,6 +811,8 @@
        String nickname = updateTradeSetInfoDto.getNickname();
        String declaration = updateTradeSetInfoDto.getDeclaration();
        int isOpen = updateTradeSetInfoDto.getIsOpen();
        String labels = updateTradeSetInfoDto.getLabels();
        followTraderInfoEntity.setLabels(labels);
        followTraderInfoEntity.setAvatar(avatar);
        followTraderInfoEntity.setNickname(nickname);
        followTraderInfoEntity.setDeclaration(declaration);
@@ -767,7 +820,7 @@
        followTraderInfoDao.updateById(followTraderInfoEntity);
        return Result.ok(MessageSourceUtils.getString("member_service_0024"));
    }
    @Override
    public Result getTradeProfitInfo() {
        //获取用户ID
@@ -1053,6 +1106,27 @@
        
        return Result.ok(arrayList);
    }
    @Override
    public Result getTradeSetLabelInfo() {
        //获取用户ID
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        Map<String, Object> columnMap = new HashMap<>();
        List<FollowTraderLabelEntity> selectByMap = followTraderLabelDao.selectByMap(columnMap);
        ArrayList<TradeSetLabelInfoVo> arrayList = new ArrayList<>();
        if(CollUtil.isNotEmpty(selectByMap)) {
            for(FollowTraderLabelEntity followTraderLabelEntity : selectByMap) {
                TradeSetLabelInfoVo tradeSetLabelInfoVo = new TradeSetLabelInfoVo();
                Long id = followTraderLabelEntity.getId();
                String labels = followTraderLabelEntity.getLabels();
                tradeSetLabelInfoVo.setId(id);
                tradeSetLabelInfoVo.setLabels(labels);
                arrayList.add(tradeSetLabelInfoVo);
            }
        }
        return Result.ok(arrayList);
    }
    
    
    
src/main/java/com/xcong/excoin/modules/documentary/vo/FollowTraderProfitInfoVo.java
@@ -72,6 +72,11 @@
     */
    @ApiModelProperty("宣言")
    private String declaration;
    /**
     * 标签
     */
    @ApiModelProperty("标签")
    private String labels;
    /**
     * 是否满员 1-是2-否
     */
src/main/java/com/xcong/excoin/modules/documentary/vo/TradeSetInfoVo.java
@@ -23,6 +23,9 @@
    @ApiModelProperty("宣言")
    private String declaration;
    
    @ApiModelProperty("标签")
    private String labels;
    
}
src/main/java/com/xcong/excoin/modules/documentary/vo/TradeSetLabelInfoVo.java
New file
@@ -0,0 +1,17 @@
package com.xcong.excoin.modules.documentary.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "TradeSetLabelInfoVo", description = "返回类")
public class TradeSetLabelInfoVo {
    @ApiModelProperty(value = "ID")
    private Long Id;
    @ApiModelProperty("标签")
    private String labels;
}
src/main/resources/mapper/documentary/FollowTraderLabelDao.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xcong.excoin.modules.documentary.dao.FollowTraderLabelDao">
</mapper>
src/test/java/com/xcong/excoin/ReturnMoneyTest.java
@@ -1,86 +1,95 @@
package com.xcong.excoin;
import cn.hutool.core.collection.CollUtil;
import jnr.ffi.annotations.IgnoreError;
import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
import com.xcong.excoin.modules.contract.dao.ContractOrderDao;
import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
import com.xcong.excoin.modules.contract.service.impl.OrderWebsocketServiceImpl;
import com.xcong.excoin.modules.member.dao.AgentReturnDao;
import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao;
import com.xcong.excoin.modules.member.entity.AgentReturnEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity;
import com.xcong.excoin.utils.SpringContextHolder;
import com.xcong.excoin.utils.ThreadPoolUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
/**
 * @author wzy
 * @date 2020-06-30
 **/
@Slf4j
@SpringBootTest
public class ReturnMoneyTest {
    @Resource
    private ContractOrderDao contractOrderDao;
    @Resource
    private AgentReturnDao agentReturnDao;
    @Resource
    private MemberWalletAgentDao memberWalletAgentDao;
    @Resource
    private MemberAccountMoneyChangeDao memberAccountMoneyChangeDao;
    /*@Test
    public void returnTest() {
        ContractOrderEntity entity = contractOrderDao.selectById(667L);
        OrderWebsocketServiceImpl orderWebsocketService = SpringContextHolder.getBean(OrderWebsocketServiceImpl.class);
        orderWebsocketService.calYj(19L, new BigDecimal(4.18004236), entity, AgentReturnEntity.ORDER_TYPE_OPEN);
    }*/
    @Test
    public void moneyReturnTest() {
        List<AgentReturnEntity> list = agentReturnDao.selectAllNeedMoneyReturn();
        log.info("返佣条数:{}", list.size());
        if (CollUtil.isNotEmpty(list)) {
            for (AgentReturnEntity agentReturn : list) {
                BigDecimal needReturn = agentReturn.getReturnAmount();
                Long refererId = agentReturn.getRefererId();
                MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(refererId, "USDT");
                if (walletAgent == null) {
                    continue;
                }
                log.info("用户ID:{}, 当前余额:{},总金额:{}, 返佣金额:{}", refererId, walletAgent.getAvailableBalance().toPlainString(), walletAgent.getTotalBalance().toPlainString(), needReturn);
                walletAgent.setAvailableBalance(walletAgent.getAvailableBalance().add(needReturn));
                walletAgent.setTotalBalance(walletAgent.getTotalBalance().add(needReturn));
                MemberAccountMoneyChange moneyChange = new MemberAccountMoneyChange();
                moneyChange.setAmount(needReturn);
                moneyChange.setContent("佣金到账");
                moneyChange.setType(MemberAccountMoneyChange.TYPE_WALLET_AGENT);
                moneyChange.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
                moneyChange.setMemberId(refererId);
                moneyChange.setSymbol("USDT");
//                // 更新代理钱包金额
                memberWalletAgentDao.updateById(walletAgent);
//                // 更新返佣明细中状态
                agentReturnDao.updateAgentReturnStatusByRefererId(AgentReturnEntity.IS_RETURN_Y, refererId);
//                // 插入财务流水记录
                memberAccountMoneyChangeDao.insert(moneyChange);
            }
        }
    }
}
package com.xcong.excoin;
import cn.hutool.core.collection.CollUtil;
import jnr.ffi.annotations.IgnoreError;
import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
import com.xcong.excoin.modules.contract.dao.ContractOrderDao;
import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
import com.xcong.excoin.modules.contract.service.impl.OrderWebsocketServiceImpl;
import com.xcong.excoin.modules.member.dao.AgentReturnDao;
import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao;
import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
import com.xcong.excoin.modules.member.entity.AgentReturnEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
import com.xcong.excoin.utils.SpringContextHolder;
import com.xcong.excoin.utils.ThreadPoolUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
/**
 * @author wzy
 * @date 2020-06-30
 **/
@Slf4j
@SpringBootTest
public class ReturnMoneyTest {
    @Resource
    private ContractOrderDao contractOrderDao;
    @Resource
    private AgentReturnDao agentReturnDao;
    @Resource
    private MemberWalletAgentDao memberWalletAgentDao;
    @Resource
    private MemberAccountMoneyChangeDao memberAccountMoneyChangeDao;
    @Resource
    private MemberWalletCoinDao memberWalletCoinDao;
    /*@Test
    public void returnTest() {
        ContractOrderEntity entity = contractOrderDao.selectById(667L);
        OrderWebsocketServiceImpl orderWebsocketService = SpringContextHolder.getBean(OrderWebsocketServiceImpl.class);
        orderWebsocketService.calYj(19L, new BigDecimal(4.18004236), entity, AgentReturnEntity.ORDER_TYPE_OPEN);
    }*/
    @Test
    public void moneyReturnTest() {
        List<AgentReturnEntity> list = agentReturnDao.selectAllNeedMoneyReturn();
        log.info("返佣条数:{}", list.size());
        if (CollUtil.isNotEmpty(list)) {
            for (AgentReturnEntity agentReturn : list) {
                BigDecimal needReturn = agentReturn.getReturnAmount();
                Long refererId = agentReturn.getRefererId();
                //查询币币钱包
                MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(refererId, "USDT");
//                MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(refererId, "USDT");
//                if (walletAgent == null) {
//                    continue;
//                }
                if (memberWalletCoinEntity == null) {
                    continue;
                }
                log.info("用户ID:{}, 当前余额:{},总金额:{}, 返佣金额:{}", refererId, memberWalletCoinEntity.getAvailableBalance().toPlainString(), memberWalletCoinEntity.getTotalBalance().toPlainString(), needReturn);
                memberWalletCoinEntity.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().add(needReturn));
                memberWalletCoinEntity.setTotalBalance(memberWalletCoinEntity.getTotalBalance().add(needReturn));
                MemberAccountMoneyChange moneyChange = new MemberAccountMoneyChange();
                moneyChange.setAmount(needReturn);
                moneyChange.setContent("佣金到账");
                moneyChange.setType(MemberAccountMoneyChange.TYPE_WALLET_AGENT);
                moneyChange.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
                moneyChange.setMemberId(refererId);
                moneyChange.setSymbol("USDT");
//                // 更新代理钱包金额
                memberWalletCoinDao.updateById(memberWalletCoinEntity);
//                // 更新返佣明细中状态
                agentReturnDao.updateAgentReturnStatusByRefererId(AgentReturnEntity.IS_RETURN_Y, refererId);
//                // 插入财务流水记录
                memberAccountMoneyChangeDao.insert(moneyChange);
            }
        }
    }
}