package com.pusong.business.domain.vo;

import com.pusong.common.translation.annotation.Translation;
import com.pusong.common.translation.constant.TransConstant;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class ServiceScheduleVo {
    /**
     * 被分配者
     */
    @Translation(type = TransConstant.USER_ID_TO_NICKNAME)
    private Long allot;

    /**
     * 生成合同
     */
    @Translation(type = TransConstant.USER_ID_TO_NICKNAME)
    private Long createContract;
    /**
     * 第一笔回款
     */
    @Translation(type = TransConstant.USER_ID_TO_NICKNAME)
    private Long firstPay;
    /**
     * 派单者
     */
    @Translation(type = TransConstant.USER_ID_TO_NICKNAME)
    private Long appoint;
    /**
     * 内勤
     */

    /**
     * 内勤
     */
    List<UserAndStatus> in = new ArrayList<>();

    /**
     * 外勤
     */
    List<UserAndStatus> out = new ArrayList<>();

    /**
     * 特勤
     */
    List<UserAndStatus> secret = new ArrayList<>();

    /**
     * 回传
     */
    @Translation(type = TransConstant.USER_ID_TO_NICKNAME)
    private Long rollBack;
    /**
     * 最后一笔回款收款者
     */
    @Translation(type = TransConstant.USER_ID_TO_NICKNAME)
    private Long payee;
    /**
     * 最后一笔回款审批者
     */
    @Translation(type = TransConstant.USER_ID_TO_NICKNAME)
    private Long approve;
    /**
     * 是否已完成（1是  0否）
     */
    private Integer isFinish;


    public static class UserAndStatus{
        /**
         * 内勤
         */
        @Translation(type = TransConstant.USER_ID_TO_NICKNAME)
        private Long uid;
        /**
         * 内勤是否已完成（1是0否）
         */
        private Integer status;
        public UserAndStatus(Long uid, Integer status){
            this.uid = uid;
            this.status = status;
        }

        public Long getUid() {
            return uid;
        }

        public void setUid(Long uid) {
            this.uid = uid;
        }

        public Integer getStatus() {
            return status;
        }

        public void setStatus(Integer status) {
            this.status = status;
        }
    }

    public void addIn(UserAndStatus userAndStatus){
        this.in.add(userAndStatus);
    }
    public void addOut(UserAndStatus userAndStatus){
        this.out.add(userAndStatus);
    }
    public void addSecret(UserAndStatus userAndStatus){
        this.secret.add(userAndStatus);
    }

    public Integer getInStatus(){
        for (UserAndStatus userAndStatus : in) {
            if (userAndStatus.status == 0){
                return 0;
            }
        }
        return 1;
    }
    public Integer getOutStatus(){
        for (UserAndStatus userAndStatus : out) {
            if (userAndStatus.status == 0){
                return 0;
            }
        }
        return 1;
    }
    public Integer getSecretStatus(){
        for (UserAndStatus userAndStatus : secret) {
            if (userAndStatus.status == 0){
                return 0;
            }
        }
        return 1;
    }
}
