UserServiceImpl.java 3.78 KB
Newer Older
licc's avatar
licc committed
1 2
package cn.wisenergy.service.app.impl;

licc's avatar
licc committed
3
import cn.wisenergy.common.utils.R;
4 5
import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.*;
licc's avatar
licc committed
6 7
import cn.wisenergy.model.dto.UsersInfoDto;
import cn.wisenergy.model.vo.UserVo;
licc's avatar
licc committed
8 9 10 11 12 13
import cn.wisenergy.service.app.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

licc's avatar
licc committed
14 15 16
import java.util.ArrayList;
import java.util.List;

licc's avatar
licc committed
17
/**
licc's avatar
licc committed
18
 * @author 86187
licc's avatar
licc committed
19 20 21 22 23 24
 * @ Description: 用户接口实现
 * @ Author     : 86187
 * @ Date       : 2021/1/6 16:11
 */
@Service
@Slf4j
licc's avatar
licc committed
25
public class UserServiceImpl extends ServiceImpl<UsersMapper, Users> implements UserService {
licc's avatar
licc committed
26 27 28 29

    @Autowired
    private UsersMapper usersMapper;

licc's avatar
licc committed
30 31 32 33 34 35 36 37 38 39 40 41
    @Autowired
    private ActivesMapper activesMapper;

    @Autowired
    private UserRechargeMapper userRechargeMapper;

    @Autowired
    private UserWithdrawsMapper withdrawsMapper;

    @Autowired
    private UsdtOrderDetailsMapper orderDetailsMapper;

42
    @Override
licc's avatar
licc committed
43
    public Users getById(Long userId) {
licc's avatar
licc committed
44
        return null;
45
    }
m1991's avatar
m1991 committed
46 47

    @Override
licc's avatar
licc committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
    public R<List<UserVo>> getLastUser(Long userId) {

        //用户id为空时,查询最顶级
        if (null == userId) {
            userId = 1L;
            Users users = usersMapper.getById(userId);
            UserVo userVo = new UserVo();
            userVo.setUserId(users.getId());
            userVo.setParentId(users.getParentId());
            userVo.setRealName(null);

            List<UserVo> list = new ArrayList<>();
            list.add(userVo);
            return R.ok(list);
        }

        //id不为空,查询当前用户的下一级
        Users user = usersMapper.getById(userId);
        List<UserVo> lastList = usersMapper.getLastUser(Integer.valueOf(user.getId().toString()));
        return R.ok(lastList);
m1991's avatar
m1991 committed
68 69
    }

70
    @Override
licc's avatar
licc committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
    public R<UsersInfoDto> getByUserInfoById(Long userId) {
        if (null == userId) {
            return R.error("入参不能为空!");
        }

        UsersInfoDto userDto = new UsersInfoDto();

        //1、获取用户信息
        Users users = usersMapper.getById(userId);
        if (null != users) {
            userDto.setUserId(users.getId());
            userDto.setPhone(users.getPhone());
            userDto.setRank(users.getRank());
        }

        //2、获取用户身份信息
        Actives actives = activesMapper.getByUserId(userId);
        if (null != actives) {
            userDto.setIdNumber(actives.getIdNumber());
            userDto.setRealName(actives.getRealName());
        }

        //3、向下最深层级层级数
        double downLevel = usersMapper.getDownLevel(userId, userId);
        userDto.setBottom((int) downLevel);

        //4、伞下人员总和
        Integer total = usersMapper.getTotal(userId);
        if (null != total) {
            userDto.setTotalPeople(total);
        }

        //5、充值总额
        Double totalRecharge = userRechargeMapper.getTotalRecharge(userId);
        if (null != totalRecharge) {
            userDto.setTotalRecharge(String.valueOf(totalRecharge));
        }

        //6、提现总额
        Double totalWithdrawal = withdrawsMapper.getTotalWithdrawal(userId);
        if (null != totalWithdrawal) {
            userDto.setTotalWithdrawal(String.valueOf(totalWithdrawal));
        }

        //7、otc卖出总额
        Double buyTotal = orderDetailsMapper.getBuyTotal(userId);
        if (null != buyTotal) {
            userDto.setBuyTotal(String.valueOf(buyTotal));
        }

        //8、otc买入总额
        Double saleTotal = orderDetailsMapper.getSaleTotal(userId);
        if (null != saleTotal) {
            userDto.setSaleTotal(String.valueOf(saleTotal));
        }
        return R.ok(userDto);
m1991's avatar
m1991 committed
127
    }
licc's avatar
licc committed
128

licc's avatar
licc committed
129
}