package com.ruoyi.dashboard.domain.dailySettleStat;

import java.time.LocalDate;
import java.util.List;

import org.springframework.format.annotation.DateTimeFormat;

import com.ruoyi.bst.bonus.domain.BonusQuery;
import com.ruoyi.bst.bonus.domain.enums.BonusArrivalType;
import com.ruoyi.bst.bonus.domain.enums.BonusStatus;
import com.ruoyi.bst.bonusRefund.domain.BonusRefundQuery;
import com.ruoyi.bst.order.domain.OrderQuery;
import com.ruoyi.bst.order.domain.enums.OrderStatus;
import com.ruoyi.bst.refund.domain.RefundQuery;
import com.ruoyi.bst.refund.domain.enums.RefundStatus;
import com.ruoyi.bst.refund.domain.enums.RefundType;

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

@Data
public class DailySettleStatQuery {

    @ApiModelProperty("日期范围")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private List<LocalDate> dateRange;

    @ApiModelProperty("运营区ID")
    private Long areaId;

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

    @ApiModelProperty("数据隔离")
    private Boolean scope;

    public OrderQuery toOrderQuery() {
        OrderQuery query = new OrderQuery();
        query.setEndDateRange(dateRange);
        query.setStatusList(OrderStatus.finishedList());
        query.setAreaId(areaId);
        return query;
    }

    public RefundQuery toRefundQuery() {
        RefundQuery query = new RefundQuery();
        query.setCreateDateRange(dateRange);
        query.setStatusList(RefundStatus.valid());
        query.setPayAreaId(areaId);
        query.setType(RefundType.ADMIN.getCode());
        return query;
    }

    public BonusQuery toBonusQuery() {
        BonusQuery query = new BonusQuery();
        query.setWaitDateRange(dateRange);
        query.setStatusList(BonusStatus.settle());
        query.setAreaId(areaId);
        query.setArrivalId(userId);
        query.setArrivalTypes(BonusArrivalType.userList());
        return query;
    }

    public BonusRefundQuery toBonusRefundQuery() {
        BonusRefundQuery query = new BonusRefundQuery();
        query.setCreateDateRange(dateRange);
        query.setBonusStatusList(BonusStatus.settle());
        query.setBonusAreaId(areaId);
        query.setBonusArrivalId(userId);
        query.setBonusArrivalTypes(BonusArrivalType.userList());
        return query;
    }
    
}
