package com.slodon.b2b2c.vo.statistics;

import com.slodon.b2b2c.core.util.FileUrlUtil;
import com.slodon.b2b2c.statistics.pojo.base.CategoryBase;
import com.slodon.b2b2c.statistics.pojo.base.GoodsBase;
import com.slodon.b2b2c.statistics.pojo.base.StoreBase;
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 AdminPresentDataVO {
    @ApiModelProperty("更新时间")
    private Date statsTime;

    @ApiModelProperty("平台汇总数据（统计至更新时间）")
    private PlatformSummary platformSummary;

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

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

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

    @ApiModelProperty("实时店铺销售排行-TOP10-销售额（今日0时至更新时间）")
    private List<PlatformStoreSale> storeSaleAmountList = new ArrayList<>();

    @ApiModelProperty("实时店铺销售排行-TOP10-订单量（今日0时至更新时间）")
    private List<PlatformStoreSale> storeOrderNumList = new ArrayList<>();

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

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

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

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

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

    @ApiModelProperty("分时统计-新增店铺数（今日0时至更新时间）")
    private List<PlatformTimeNum> newStoreNumList = new ArrayList<>();

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

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

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

        @ApiModelProperty("会员总数")
        private Integer memberNum;

        @ApiModelProperty("站点会员总数")
        private Integer webSiteMemberNum;

        @ApiModelProperty("店铺总数")
        private Integer storeNum;

        @ApiModelProperty("站点店铺总数")
        private Integer webSiteStoreNum;

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

        @ApiModelProperty("站点在售商品总数")
        private Integer webSiteSaleGoodsNum;

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

        @ApiModelProperty("下架商品数")
        private Integer shelfGoodsNum;
    }

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

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

        @ApiModelProperty("新增店铺数")
        private Integer newStoreNum;

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

        @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 PlatformGoodsSale {
        public PlatformGoodsSale(GoodsBase goodsBase) {
            this.goodsId = goodsBase.getGoodsId();
            this.goodsName = goodsBase.getGoodsName();
            this.goodsImage = FileUrlUtil.getFileUrl(goodsBase.getGoodsImage(), null);
            this.saleAmount = goodsBase.getSaleAmount();
            this.saleNum = goodsBase.getSaleNum();
        }

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

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

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

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

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

    /**
     * 实时店铺销售概况（今日0时至更新时间）
     */
    @Data
    @NoArgsConstructor
    public static class PlatformStoreSale {
        public PlatformStoreSale(StoreBase storeBase) {
            this.storeId = storeBase.getStoreId();
            this.storeName = storeBase.getStoreName();
            this.orderPayAmount = storeBase.getOrderPayAmount();
            this.orderSubmitNum = storeBase.getOrderSubmitNum();
        }

        @ApiModelProperty("店铺id")
        private Long storeId;

        @ApiModelProperty("店铺名称")
        private String storeName;

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

        @ApiModelProperty("订单量")
        private Integer orderSubmitNum;
    }

    /**
     * 实时商品分类销售概况（今日0时至更新时间）
     */
    @Data
    @NoArgsConstructor
    public static class PlatformCategorySale {
        public PlatformCategorySale(CategoryBase categoryBase) {
            this.categoryId = categoryBase.getCategoryId();
            this.categoryName = categoryBase.getCategoryName();
            this.saleAmount = categoryBase.getSaleAmount();
            this.saleNum = categoryBase.getSaleNum();
        }

        @ApiModelProperty("商品分类id")
        private Integer categoryId;

        @ApiModelProperty("商品分类名称")
        private String categoryName;

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

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

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

        public PlatformTimeNum(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 PlatformTimeAmount {
        public PlatformTimeAmount(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);
        }
    }

    /**
     * 今日询盘概况（今日0时至更新时间）
     */
    @Data
    @NoArgsConstructor
    public static class PlatformEnquiryTodayInfo {

        @ApiModelProperty("询盘总数")
        private Integer enquiryTotalNum;

        @ApiModelProperty("新增询盘")
        private Integer enquiryNewNum;

        @ApiModelProperty("有效询盘")
        private Integer validInquiryNum;

        @ApiModelProperty("待分配询盘")
        private Integer enquiryToBeAssignNum;

        @ApiModelProperty("更新时间")
        private Date statsTime;
    }
}
