package com.kxs.user.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kxs.common.core.util.AssertUtil;
import com.kxs.user.api.vo.kxsapp.shareholder.ShareholderGetShareholderAmountVO;
import com.kxs.user.biz.mapper.KxsShdTradeAmtMapper;
import com.kxs.user.api.model.KxsShdTradeAmt;
import com.kxs.user.biz.service.KxsShdTradeAmtService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * 股东大盘分红交易表(KxsShdTradeAmt)表服务实现类
 *
 * @author 系统
 * @since 2024-05-07 09:11:27
 */
@Service("kxsShdTradeAmtService")
@RequiredArgsConstructor
public class KxsShdTradeAmtServiceImpl extends ServiceImpl<KxsShdTradeAmtMapper, KxsShdTradeAmt> implements KxsShdTradeAmtService {
    private final KxsShdTradeAmtMapper kxsShdTradeAmtMapper;
    @Override
    public Object getShareholderAmount(String tradeMonth) {
        //格式校验
        AssertUtil.isYyyyMM(tradeMonth);
        KxsShdTradeAmt kxsShdTradeAmt = kxsShdTradeAmtMapper.selectOne(Wrappers.<KxsShdTradeAmt>query().lambda().eq(KxsShdTradeAmt::getTradeMonth, tradeMonth));
        ShareholderGetShareholderAmountVO shareholderGetShareholderAmountVO = new ShareholderGetShareholderAmountVO();
        if (kxsShdTradeAmt != null){
            BeanUtil.copyProperties(kxsShdTradeAmt,shareholderGetShareholderAmountVO);
        }
        return shareholderGetShareholderAmountVO;
    }
}

