package com.yonge.cooleshow.biz.dal.wrapper;

import com.alibaba.fastjson.JSON;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Optional;

/**
 * 机构小组专辑配置表
 * 2024-01-24 13:32:00
 */
@ApiModel(value = "TenantGroupAlbumWrapper对象", description = "机构小组专辑配置表查询对象")
public class TenantGroupAlbumWrapper {

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" TenantGroupAlbumQuery-机构小组专辑配置表")
    public static class TenantGroupAlbumQuery implements QueryInfo {

        @ApiModelProperty("当前页")
        private Integer page;

        @ApiModelProperty("分页行数")
        private Integer rows;

        @ApiModelProperty("关键字匹配")
        private String keyword;

        @ApiModelProperty("机构ID")
        private Long tenantId;

        @ApiModelProperty("机构专辑ID")
        private Long tenantAlbumId;

        @ApiModelProperty("机构小组ID")
        private Long tenantGroupId;

        public String getKeyword() {
            return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
        }

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static TenantGroupAlbumQuery from(String json) {
            return JSON.parseObject(json, TenantGroupAlbumQuery.class);
        }
    }

    @Data
    @ApiModel(" TenantGroupAlbum-机构小组专辑配置表")
    public static class TenantGroupAlbum {
        @ApiModelProperty("主键ID")
        private Long id;

        @ApiModelProperty("机构小组ID")
        @NotNull(message = "小组不能为空")
        private Long tenantGroupId;

        @ApiModelProperty("专辑ID")
        @NotNull(message = "专辑ID不能为空")
        private Long tenantAlbumId;

        @ApiModelProperty("采购数量")
        @NotNull(message = "有效期不能为空")
        private Integer purchaseNum;

        @ApiModelProperty("原价")
        private BigDecimal originalPrice;

        @ApiModelProperty("售价")
        private BigDecimal actualPrice;

        @ApiModelProperty("购买次数限制")
        @NotNull(message = "购买次数限制不能为空")
        private Boolean buyTimesFlag;

        @ApiModelProperty("购买次数")
        private Integer buyTimes = 0;


        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static TenantGroupAlbum from(String json) {
            return JSON.parseObject(json, TenantGroupAlbum.class);
        }
    }


    @Data
    @ApiModel("修改状态")
    public static class UpdateStatus {

        @ApiModelProperty("id")
        @NotNull
        private String ids;

        @ApiModelProperty("状态")
        @NotNull
        private Boolean status;

    }

    @Data
    @ApiModel("修改状态")
    public static class Remove {

        @ApiModelProperty("id")
        @NotNull
        private Long id;
    }

    @Data
    @ApiModel(" TenantGroupAlbum-机构小组专辑配置表")
    public static class TenantGroupAlbumVo {
        @ApiModelProperty("主键ID")
        private Long id;

        @ApiModelProperty("机构小组ID")
        private Long tenantGroupId;

        @ApiModelProperty("专辑ID")
        private Long tenantAlbumId;

        @ApiModelProperty("采购数量")
        private Integer purchaseNum;

        @ApiModelProperty("原价")
        private BigDecimal originalPrice;

        @ApiModelProperty("售价")
        private BigDecimal actualPrice;

        @ApiModelProperty("购买次数限制")
        private Boolean buyTimesFlag;

        @ApiModelProperty("购买次数")
        private Integer buyTimes;

        @ApiModelProperty("状态")
        private Boolean status;

        @ApiModelProperty("采购周期")
        private String purchasePeriod;

        @ApiModelProperty("创建时间")
        private Date createTime;

        @ApiModelProperty("创建人")
        private Long createBy;

        @ApiModelProperty("更新人")
        private Long updateBy;

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

        @ApiModelProperty("机构小组名称")
        private String tenantGroupName;

        @ApiModelProperty("专辑名称")
        private String tenantAlbumName;

    }
    @Data
    @ApiModel(" BuyTenantAlbumQuery-可购买机构专辑信息查询")
    public static class BuyTenantAlbumQuery {

        @ApiModelProperty("机构ID")
        private Long tenantId;

        @ApiModelProperty("小组ID")
        private Long tenantGroupId;

        @ApiModelProperty("机构小组专辑ID")
        private Long tenantGroupAlbumId;

        @ApiModelProperty("专辑ID集合")
        private List<Long> tenantAlbumIds;

        @ApiModelProperty("用户ID")
        private Long userId;

        @ApiModelProperty("客户端类型")
        private ClientEnum clientType;

        private boolean sortFlag = false;
    }



    @Data
    @ApiModel(" BuyTenantAlbum-可购买机构专辑信息")
    public static class BuyTenantAlbum {

        @ApiModelProperty("专辑ID")
        private Long id;


        @ApiModelProperty("专辑名称")
        private String name;

        @ApiModelProperty("专辑介绍")
        private String describe;

        @ApiModelProperty("专辑封面")
        private String coverImg;

        @ApiModelProperty("曲目数")
        private Integer musicNum;


        @ApiModelProperty("曲目声部分类(多个,分隔)")
        private String subjectTypes;


        @ApiModelProperty("采购周期类型")
        private String purchaseTypes;



        @ApiModelProperty("采购金额数据")
        private String purchaseJson;


        @ApiModelProperty("合奏曲目数量")
        private Integer EnsembleCounts;

        @ApiModelProperty("小曲目数量")
        private Integer MusicCounts;

        @ApiModelProperty("声部曲目数")
        private Integer SubjectCounts;


        @ApiModelProperty("教材数")
        private Integer coursewareCounts;

        @ApiModelProperty("机构小组专辑ID ,学生购买需传参")
        private Long tenantGroupAlbumId;

        @ApiModelProperty("机构小组ID")
        private Long tenantGroupId;


        @ApiModelProperty("采购数量")
        private Integer purchaseNum;

        @ApiModelProperty("采购周期")
        private String purchasePeriod;

        @ApiModelProperty("原价")
        private BigDecimal originalPrice;

        @ApiModelProperty("售价")
        private BigDecimal actualPrice;


        @ApiModelProperty("购买次数限制")
        private Boolean buyTimesFlag;

        @ApiModelProperty("可购买次数")
        private Integer buyTimes;

        @ApiModelProperty("已购买次数")
        private Integer buyedTimes;

        @ApiModelProperty("是否生效中")
        private Boolean status = false;


        @ApiModelProperty("排序")
        private long sort =0L;

        @ApiModelProperty("到期时间")
        private Date expireTime;

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static TenantGroupAlbum from(String json) {
            return JSON.parseObject(json, TenantGroupAlbum.class);
        }
    }


    @Data
    public static class TenantGroupAlbumCount {

        private Long tenantGroupId;

        private Integer count;
    }



    @Data
    @ApiModel(" TenantAlbumSort-专辑排序")
    public static class TenantAlbumSort {

        @ApiModelProperty("专辑ID")
        private Long id;

        @ApiModelProperty("排序")
        private long sort =0L;
    }
}