package com.fzm.mall.server.admin.finance_center.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fzm.mall.server.admin.finance_center.entity.vo.MerchantAssetsFlowVO;
import com.fzm.mall.server.admin.finance_center.entity.vo.PlatformAssetsFlowVO;
import com.fzm.mall.server.admin.finance_center.model.MerchantAssetsFlow;
import com.fzm.mall.server.admin.finance_center.mapper.MerchantAssetsFlowMapper;
import com.fzm.mall.server.admin.finance_center.service.IMerchantAssetsFlowService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.mall.server.admin.util.UUIDUtil;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @author wangp
 * @date 2021/4/29 15:53
 * @description 服务实现类
 * @since JDK 1.8
 */
@Service
public class MerchantAssetsFlowServiceImpl extends ServiceImpl<MerchantAssetsFlowMapper, MerchantAssetsFlow> implements IMerchantAssetsFlowService {

    @Override
    public IPage<MerchantAssetsFlowVO> page(String flowId, String merchantId, String coin, Integer type, Integer pageNum, Integer pageSize) {
        IPage<MerchantAssetsFlowVO> page = new Page<>(pageNum, pageSize);
        return baseMapper.page(page, flowId, merchantId, coin, type);
    }

    @Override
    public void saveOutRecharge(String merchantId, String coin, BigDecimal amount, Integer type, String otherSide) {
        MerchantAssetsFlow flow = new MerchantAssetsFlow();
        flow.setFlowId(UUIDUtil.getUUID());
        flow.setMerchantId(merchantId);
        flow.setCoin(coin);
        flow.setAmount(amount);
        flow.setType(type);
        flow.setStatus(2);
        flow.setOtherSide(otherSide);
        save(flow);
    }
}
