package com.cool.store.vo.wallet;

import com.cool.store.dto.wallet.TradeRecordDTO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Objects;

/**
 * <p>
 * 账户交易列表分页VO
 * </p>
 *
 * @author wangff
 * @since 2025/11/19
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AccountBillPageVO {
    @ApiModelProperty("分页数据")
    PageInfo<TradeRecordDTO> data;

    @ApiModelProperty("收入")
    private BigDecimal getAmount;

    @ApiModelProperty("支出")
    private BigDecimal useAmount;

    public AccountBillPageVO(PageInfo<TradeRecordDTO> data, Long getAmount, Long useAmount) {
        this.data = data;
        BigDecimal denominator = new BigDecimal(100);
        this.getAmount = new BigDecimal(Objects.nonNull(getAmount) ? getAmount : 0).divide(denominator, 2, RoundingMode.HALF_UP);
        this.useAmount = new BigDecimal(Objects.nonNull(useAmount) ? useAmount : 0).divide(denominator, 2, RoundingMode.HALF_UP);
    }
}
