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.UserAssetsRecordVO;
import com.fzm.mall.server.admin.finance_center.model.UserAssetRecord;
import com.fzm.mall.server.admin.finance_center.mapper.UserAssetRecordMapper;
import com.fzm.mall.server.admin.finance_center.service.IUserAssetRecordService;
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 UserAssetRecordServiceImpl extends ServiceImpl<UserAssetRecordMapper, UserAssetRecord> implements IUserAssetRecordService {

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

    @Override
    public void saveOutNftRecharge(String uid, String coin, BigDecimal amount, String otherSide, String hash) {
        UserAssetRecord record = new UserAssetRecord();
        record.setFlowId(UUIDUtil.getUUID());
        record.setUid(uid);
        record.setCoin(coin);
        record.setType(23);
        record.setAmount(amount);
        record.setStatus(2);
        record.setOtherSide(otherSide);
        record.setHash(hash);
        save(record);
    }
}
