package com.ruoyi.demo.entity.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.ruoyi.demo.entity.PlanPushStatistics;
import lombok.Data;

import java.time.LocalDateTime;

// 广告投放列表
@Data
public class PlanPushStatisticsListVo {
    private String statisticsId;
    private String equipmentId;
    private String equipmentName;
    private String equipmentCode;
    private Integer carouselCount;
    private Integer scanCodeCount;
    private String ratio;
    private Integer totalUserCount;
    private Float totalPrice;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime lasterTime;

    public PlanPushStatisticsListVo(){}
    public PlanPushStatisticsListVo(PlanPushStatistics statistics){
        this.statisticsId = statistics.getStatisticsId();
        this.equipmentId = statistics.getEquipmentId();
        this.equipmentName = statistics.getEquipmentName();
        this.equipmentCode = statistics.getEquipmentCode();
        this.carouselCount = statistics.getCarouselCount();
        this.scanCodeCount = statistics.getScanCodeCount();
        float r = (float) statistics.getTradeCount()/statistics.getScanCodeCount();
        this.ratio = ((int)(r*100)+"%");
        this.totalUserCount = statistics.getTotalUserCount();
        this.totalPrice = statistics.getTotalPrice();
        this.lasterTime = statistics.getLasterTime();
    }
}
