package com.bohuikeji.delivery.backstage.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.bohuikeji.frame.module.admin.annotation.TableQueryField;
import com.bohuikeji.frame.module.admin.base.EntityBase;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableField;
import com.bohuikeji.frame.module.admin.annotation.TableShowField;
import com.bohuikeji.frame.module.admin.annotation.TableNewField;
import com.bohuikeji.frame.module.admin.entity.web.block.SelectBlock;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 评价记录表
 * </p>
 *
 * @author 10552
 * @since 2019-08-22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="TEvaluate对象", description="评价记录表")
@TableName("t_evaluate")
public class TEvaluate extends EntityBase<TEvaluate> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value="评价记录id(新增时请留空或null)")
    @TableId(value = "evaluate_id", type = IdType.AUTO)
    @TableShowField(value = "ID",id = true)
    @TableNewField(show = false)
    private Integer evaluateId;

    @ApiModelProperty(value = "评价类型")
    @TableField("evaluate_type")
    @TableShowField("评价类型")
    @TableQueryField
    @TableNewField
    private String evaluateType;

    @ApiModelProperty(value = "评价人id")
    @TableField("evaluator_id")
    @TableShowField(value = "评价人id",show = false)
    private Integer evaluatorId;

    @ApiModelProperty(value = "订单id")
    @TableField("order_id")
    @TableShowField(value = "订单id",show = false)
    private Integer orderId;

    @ApiModelProperty(value = "评价人")
    @TableField(exist = false)
    @TableShowField("评价人")
    @TableNewField
    private String evaluatorName;

    @ApiModelProperty(value = "被评价人id")
    @TableField("evaluated_person_id")
    @TableShowField(value = "被评价人id",show = false)
    private Integer evaluatedPersonId;

    @ApiModelProperty(value = "被评价人")
    @TableField(exist = false)
    @TableShowField("被评价人")
    @TableNewField
    private String evaluatedPersonName;

    @ApiModelProperty(value = "订单号")
    @TableField("order_num")
    @TableShowField("订单号")
    @TableNewField(block = SelectBlock.class)
    @TableQueryField(show = false)
    private String orderNum;

    @ApiModelProperty(value = "评价时间")
    @TableField("evaluate_time")
    @TableShowField("评价时间")
    @TableNewField
    @TableQueryField(sort = 0)
    private LocalDateTime evaluateTime=LocalDateTime.now();

    @ApiModelProperty(value = "累计评分")
    @TableField("evaluate_score")
    @TableShowField("累计评分")
    @TableNewField
    private String evaluateScore;

    @ApiModelProperty(value = "是否自动评价")
    @TableField("evaluation_status")
    @TableShowField("是否自动评价")
    @TableNewField(options = {"是","否"})
    @TableQueryField
    private String evaluationStatus="是";


    @TableField(exist = false)
    private List<TEvaluateDetailed> tEvaluateDetailed;
    /**
     * 评价人姓名
     * @param evaluatorId
     */
    public void setEvaluatorId(Integer evaluatorId) {
        this.evaluatorId = evaluatorId;
        if("客户评价派送员".equals(this.evaluateType)){
            this.evaluatorName = (String) sql().selectObj("select customer_name from t_customer where customer_id={0}",evaluatorId);
        }else if("派送员评价客户".equals(this.evaluateType)){
            this.evaluatorName = (String) sql().selectObj("select courier_name from t_courier where courier_id={0}",evaluatorId);
        }
    }

    /**
     * 被评价人姓名
     * @param evaluatedPersonId
     */
    public void setEvaluatedPersonId(Integer evaluatedPersonId) {
        this.evaluatedPersonId = evaluatedPersonId;
        if ("客户评价派送员".equals(this.evaluateType)){
            this.evaluatedPersonName = (String) sql().selectObj("select courier_name from t_courier where courier_id={0}",evaluatedPersonId);
        }else if("派送员评价客户".equals(this.evaluateType)){
            this.evaluatedPersonName = (String) sql().selectObj("select customer_name from t_customer where customer_id={0}",evaluatedPersonId);
        }
    }
}
