package com.ruoyi.demo.entity.bo;

import com.ruoyi.demo.entity.BrandStatistics;
import lombok.Data;

import java.io.Serializable;

@Data
public class BrandDistribution implements Serializable {
    private Integer total;
    private Integer coverProvinceCount;
    private String coverProvinceRatio;
    private Integer coverCityCount;
    private String coverCityRatio;
    private Integer coverZoneCount;
    private String coverZoneRatio;

    public BrandDistribution() {
    }

    public BrandDistribution(BrandStatistics statistics, int province, int city, int zone) {
        int cpc = statistics.getCoverProvinceCount();
        int ccc = statistics.getCoverCityCount();
        int czc = statistics.getCoverZoneCount();
        float provinceRatio = (float) cpc / province;
        float cityRatio = (float) ccc / city;
        float zoneRatio = (float) czc / zone;

        this.coverProvinceCount = cpc;
        this.coverProvinceRatio = (int) (provinceRatio * 100) + "%";

        this.coverCityCount = ccc;
        this.coverCityRatio = (int) (cityRatio * 100) + "%";

        this.coverZoneCount = czc;
        this.coverZoneRatio = (int) (zoneRatio * 100) + "%";

        this.total = statistics.getTotal();
    }
}
