package com.slodon.b2b2c.vo.statistics;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * admin实时统计vo
 */
@Data
public class SellerPresentDataVO {
    @ApiModelProperty("更新时间")
    private Date statsTime;

    @ApiModelProperty("店铺汇总数据（统计至更新时间）")
    private SellerSummary sellerSummary;

    @ApiModelProperty("今日实时数据（今日0时至更新时间）")
    private SellerTodaySummary sellerTodaySummary;

    @ApiModelProperty("分时统计-下单金额（今日0时至更新时间）")
    private List<SellerTimeAmount> orderSubmitAmountList = new ArrayList<>();

    @ApiModelProperty("分时统计-支付金额（今日0时至更新时间）")
    private List<SellerTimeAmount> orderPayAmountList = new ArrayList<>();

    @ApiModelProperty("分时统计-新增用户数（今日0时至更新时间）")
    private List<SellerTimeNum> newMemberNumList = new ArrayList<>();

    @ApiModelProperty("分时统计-浏览量（今日0时至更新时间）")
    private List<SellerTimeNum> viewNumList = new ArrayList<>();

    @ApiModelProperty("分时统计-访客数（今日0时至更新时间）")
    private List<SellerTimeNum> visitorNumList = new ArrayList<>();

    @ApiModelProperty("实时商品销售排行-TOP10-销售额（今日0时至更新时间）")
    private List<SellerGoodsSale> goodsSaleAmountList = new ArrayList<>();

    @ApiModelProperty("实时商品销售排行-TOP10-销量（今日0时至更新时间）")
    private List<SellerGoodsSale> goodsSaleNumList = new ArrayList<>();

//    @ApiModelProperty("实时支付订单金额分布")
//    private List<OrderPayAmountDistribute> orderPayAmountDistributeList = new ArrayList<>();

    /**
     * 店铺汇总数据（统计至更新时间）
     */
    @Data
    public static class SellerSummary {
        @ApiModelProperty("销售总额")
        private BigDecimal orderPayAmount;

        @ApiModelProperty("用户总数")
        private Integer memberNum;

        @ApiModelProperty("商品总数")
        private Integer goodsNum;

        @ApiModelProperty("在售商品总数")
        private Integer saleGoodsNum;

        @ApiModelProperty("关注店铺人数")
        private Integer followMemberNum;
    }

    /**
     * 今日实时数据（今日0时至更新时间）
     */
    @Data
    public static class SellerTodaySummary {
        @ApiModelProperty("今日销售额")
        private BigDecimal orderPayAmount;

        @ApiModelProperty("新增会员数")
        private Integer newMemberNum;

        @ApiModelProperty("新增商品数")
        private Integer newGoodsNum;

        @ApiModelProperty("动销商品数")
        private Integer salingGoodsNum;

        @ApiModelProperty("访客数")
        private Integer visitorNum;

        @ApiModelProperty("浏览量")
        private Integer viewNum;

        @ApiModelProperty("商品访客数")
        private Integer goodsVisitorNum;

        @ApiModelProperty("商品浏览量")
        private Integer goodsViewNum;

        @ApiModelProperty("下单数")
        private Integer orderSubmitNum;

        @ApiModelProperty("下单金额")
        private BigDecimal orderSubmitAmount;

        @ApiModelProperty("下单人数")
        private Integer orderSubmitMemberNum;

        @ApiModelProperty("下单客单价，下单金额/下单人数")
        private BigDecimal orderSubmitAtv;

        @ApiModelProperty("支付订单数")
        private Integer orderPayNum;

        @ApiModelProperty("支付订单人数")
        private Integer orderPayMemberNum;

        @ApiModelProperty("支付订单客单价，支付订单金额/支付订单人数")
        private BigDecimal orderPayAtv;

        @ApiModelProperty("访问-下单转化率，下单人数/访客数*100%")
        private String pvSubmitRate;

        @ApiModelProperty("访问-支付转化率，支付订单人数/访客数*100%")
        private String pvPayRate;
    }

    /**
     * 实时商品销售概况（今日0时至更新时间）
     */
    @Data
    @NoArgsConstructor
    public static class SellerGoodsSale {

        @ApiModelProperty("商品id")
        private Long goodsId;

        @ApiModelProperty("商品名称")
        private String goodsName;

        @ApiModelProperty("商品图片")
        private String goodsImage;

        @ApiModelProperty("销售额")
        private BigDecimal saleAmount;

        @ApiModelProperty("销量")
        private Integer saleNum;
    }

    /**
     * 分时数量统计
     */
    @Data
    @NoArgsConstructor
    public static class SellerTimeNum {

        public SellerTimeNum(String hour, Integer num) {
            this.hour = hour;
            this.num = num;
        }

        @ApiModelProperty("统计时间,0-23")
        private String hour;

        @ApiModelProperty("统计数量")
        private Integer num;

        public void addNum(int num) {
            this.num += num;
        }
    }

    /**
     * 分时金额统计
     */
    @Data
    @NoArgsConstructor
    public static class SellerTimeAmount {

        public SellerTimeAmount(String hour, BigDecimal amount) {
            this.hour = hour;
            this.amount = amount;
        }

        @ApiModelProperty("统计时间,0-23")
        private String hour;

        @ApiModelProperty("统计金额")
        private BigDecimal amount;

        public void addAmount(BigDecimal amount) {
            this.amount = this.amount.add(amount);
        }
    }

    /**
     * 订单支付金额分布
     */
    @Data
    public static class OrderPayAmountDistribute {
        @ApiModelProperty("分布区间名称")
        private String sectionName;

        @ApiModelProperty("区间订单数")
        private Integer orderNum;

        @ApiModelProperty("区间订单数占比")
        private String percent;
    }
}
