
package com.tmerclub.cloud.user.feign;

import com.tmerclub.cloud.api.user.dto.FinanceDetailDTO;
import com.tmerclub.cloud.api.user.dto.UserTypeDTO;
import com.tmerclub.cloud.api.user.feign.UserLevelLogFeignClient;
import com.tmerclub.cloud.api.user.vo.FinanceDetailExcelVO;
import com.tmerclub.cloud.api.user.vo.FinanceDetailVO;
import com.tmerclub.cloud.api.user.vo.UserApiVO;
import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.user.model.UserLevelLog;
import com.tmerclub.cloud.user.service.UserLevelLogService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 会员等级日志
 * @author tmerclub
 */
@DubboService
public class UserLevelLogFeignController implements UserLevelLogFeignClient {

    @Autowired
    private UserLevelLogService userLevelLogService;

    @Override
    public ServerResponseEntity<Long> getPayAmount(Long userLevelLogId) {
        UserLevelLog userLevelLog = userLevelLogService.getByLevelLogId(userLevelLogId);
        return ServerResponseEntity.success(userLevelLog.getPayAmount());
    }

    @Override
    public ServerResponseEntity<Integer> getIsPay(Long userLevelLogId) {
        UserLevelLog userLevelLog = userLevelLogService.getByLevelLogId(userLevelLogId);
        return ServerResponseEntity.success(userLevelLog.getIsPayed());
    }

    @Override
    public UserApiVO getUserTypeAndUserNameAtTime(UserTypeDTO userTypeDTO) {
        return userLevelLogService.getUserTypeAndUserNameAtTime(userTypeDTO.getUserId(), userTypeDTO.getCreateTime());
    }

    @Override
    public ServerResponseEntity<PageVO<FinanceDetailVO>> pageFinanceDetail(FinanceDetailDTO financeDetailDTO) {
        PageDTO pageDTO = new PageDTO();
        pageDTO.setPageSize(financeDetailDTO.getPageSize());
        pageDTO.setPageNum(financeDetailDTO.getPageNum());
        PageVO<FinanceDetailVO> result = userLevelLogService.pageFinanceDetail(pageDTO, financeDetailDTO);
        return ServerResponseEntity.success(result);
    }

    @Override
    public ServerResponseEntity<List<FinanceDetailExcelVO>> listFinanceDetail(FinanceDetailDTO financeDetailDTO) {
        List<FinanceDetailExcelVO> listFinanceDetail = userLevelLogService.listFinanceDetail(financeDetailDTO);
        return ServerResponseEntity.success(listFinanceDetail);
    }

}
