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

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.fastjson.JSON;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import com.yonge.cooleshow.biz.dal.enums.OrderStatusEnum;
import com.yonge.cooleshow.common.enums.payment.EGoodsType;
import com.yonge.cooleshow.common.enums.payment.EOrderType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * 分账子账户记录表
 * 2023-07-28 15:45:03
 */
@ApiModel(value = "PaymentDivMemberRecordWrapper对象", description = "分账子账户记录表查询对象")
public class PaymentDivMemberRecordWrapper {

    @Data
	@Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" PaymentDivMemberRecordQuery-分账子账户记录表")
    public static class PaymentDivMemberRecordQuery implements QueryInfo {
    
    	@ApiModelProperty("当前页")
        private Integer page;
        
        @ApiModelProperty("分页行数")
        private Integer rows;
        
        @ApiModelProperty("关键字匹配")
		private String keyword;
        
        public String getKeyword() {
            return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
        }
        
        public String jsonString() {
            return JSON.toJSONString(this);
        }

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

    @Data
    @ApiModel("首页收入明细查询")
    public static class IndexIncomeQuery implements QueryInfo {

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

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

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

        @ApiModelProperty("支付时（年月日 时分秒）")
		private String startTime;

        @ApiModelProperty("支付时间（年月日 时分秒）")
		private String endTime;

        @ApiModelProperty("订单类型")
        private EOrderType orderType;

        @ApiModelProperty("排序字段")
        private String sortField = "payTime";

        @ApiModelProperty("排序方式")
        private String sortType = "DESC";

        private Long tenantId;

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

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

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

    @Data
    @ApiModel("首页收入明细查询")
    public static class IndexIncomeQueryDto{

        @ApiModelProperty("姓名")
        private String name;

        @ApiModelProperty("头像")
        private String avatar;

        @ApiModelProperty("电话号码")
        private String phone;

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

        @ApiModelProperty("支付时间")
        private String payTime;

        @ApiModelProperty("订单编号")
        private String orderNo;

        @ApiModelProperty("订单类型")
        private EOrderType orderType;
    }

    @Data
    @ApiModel("首页收入明细导出")
    public static class IndexIncomeExportDto{

        @ExcelProperty("用户名称")
        private String name;

        @ExcelProperty("手机号")
        private String phone;

        @ExcelProperty("收入")
        private BigDecimal amount;

        @ExcelProperty("订单时间")
        private String payTime;

        @ExcelProperty("订单类型")
        private String orderType;
    }

    @Data
    @ApiModel("首页收入、支出汇总")
    public static class IndexIncomeSummaryDto{

        @ApiModelProperty("累计收入")
        private BigDecimal totalIncome = BigDecimal.ZERO;

        @ApiModelProperty("累计支出")
        private BigDecimal totalExpend = BigDecimal.ZERO;

        @ApiModelProperty("收入汇总详情")
        private List<IndexIncomeSummaryDetailDto> incomeDtos;

        @ApiModelProperty("支出汇总详情")
        private List<IndexIncomeSummaryDetailDto> expendDtos;
    }

    @Data
    @ApiModel("首页收入、支出汇总")
    public static class IndexIncomeSummaryDetailDto{
        @ApiModelProperty("金额")
        private BigDecimal amount = BigDecimal.ZERO;

        @ApiModelProperty("订单类型")
        private EOrderType orderType;
    }

    @Data
    @ApiModel("首页订单详情")
    public static class OrderDetailDto extends IndexIncomeQueryDto{

        @ApiModelProperty("商品类型")
        private EGoodsType goodsType;

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

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

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

	@ApiModel(" PaymentDivMemberRecord-分账子账户记录表")
    public static class PaymentDivMemberRecord {
        
        public String jsonString() {
            return JSON.toJSONString(this);
        }

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

}