package com.bonus.canteen.core.menu.vo;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.bonus.canteen.core.common.encrypt.LeNiuDecryptDataProcess;
import com.bonus.canteen.core.common.encrypt.LeNiuDecryptField;
import com.bonus.canteen.core.common.utils.CustomLocalDateTimeConverter;
import com.bonus.canteen.core.common.utils.DishesConverter;
import com.bonus.canteen.core.common.utils.SysUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.compress.utils.Lists;

import java.time.LocalDateTime;
import java.util.List;

@ApiModel("获取评价列表(pc端)")
@LeNiuDecryptDataProcess
public class MenuEvaluateOrderPageVO {
   @ExcelIgnore
   @ApiModelProperty("评价id")
   private Long evaluaId;
   @ExcelProperty(
      value = {"订单编号"},
      order = 0
   )
   @ApiModelProperty("订单编号")
   private Long ordId;
   @ExcelProperty(
      value = {"用户姓名"},
      order = 1
   )
   @ApiModelProperty("用户姓名")
   @LeNiuDecryptField
   private String custName;
   @ExcelProperty(
      value = {"所属区域"},
      order = 2
   )
   @ApiModelProperty("所属区域")
   private String areaName;
   @ExcelProperty(
      value = {"所属食堂"},
      order = 3
   )
   @ApiModelProperty("所属食堂")
   private String canteenName;
   @ExcelProperty(
      value = {"所属档口"},
      order = 4
   )
   @ApiModelProperty("所属档口")
   private String stallName;
   @ExcelProperty(
      value = {"餐次"},
      order = 5
   )
   @ApiModelProperty("餐次名称")
   private String mealtimeName;
   @ExcelProperty(
      value = {"评价内容"},
      order = 7
   )
   @ApiModelProperty("评价内容")
   private String description;
   @ExcelProperty(
      value = {"评价回复"},
      order = 8
   )
   @ApiModelProperty("评价回复")
   private String reply;
   @ExcelIgnore
   @ApiModelProperty("评价回复时间")
   private LocalDateTime replyTime;
   @ExcelProperty(
      value = {"评价时间"},
      order = 9,
      converter = CustomLocalDateTimeConverter.class
   )
   @ApiModelProperty("评价时间")
   private LocalDateTime crtime;
   @ApiModelProperty("是否显示(1-显示,2-不显示)")
   private Integer showFlag;
   @ExcelProperty(
      value = {"菜品评分详情"},
      order = 6,
      converter = DishesConverter.class
   )
   @ApiModelProperty("菜品评分")
   private List<MenuEvaluateDishesVO> dishesList;
   @ApiModelProperty("星级")
   @ExcelIgnore
   private Integer starLevel;
   @ExcelIgnore
   @ApiModelProperty("评价照片")
   private List<String> pictureList;

   public List<String> getPictureList() {
      List<String> resultList = Lists.newArrayList();
      if (!CollUtil.isEmpty(this.pictureList)) {
         this.pictureList.forEach((p) -> {
            resultList.add(SysUtil.getCutFileUrl(p));
         });
      }

      return resultList;
   }

   public Integer getStarLevel() {
      if (ObjectUtil.isEmpty(this.dishesList)) {
         return 0;
      } else {
         Double asDouble = this.dishesList.stream().mapToInt(MenuEvaluateDishesVO::getStarLevel).average().getAsDouble();
         return asDouble.intValue();
      }
   }

   public Long getEvaluaId() {
      return this.evaluaId;
   }

   public Long getOrdId() {
      return this.ordId;
   }

   public String getCustName() {
      return this.custName;
   }

   public String getAreaName() {
      return this.areaName;
   }

   public String getCanteenName() {
      return this.canteenName;
   }

   public String getStallName() {
      return this.stallName;
   }

   public String getMealtimeName() {
      return this.mealtimeName;
   }

   public String getDescription() {
      return this.description;
   }

   public String getReply() {
      return this.reply;
   }

   public LocalDateTime getReplyTime() {
      return this.replyTime;
   }

   public LocalDateTime getCrtime() {
      return this.crtime;
   }

   public Integer getShowFlag() {
      return this.showFlag;
   }

   public List<MenuEvaluateDishesVO> getDishesList() {
      return this.dishesList;
   }

   public void setEvaluaId(final Long evaluaId) {
      this.evaluaId = evaluaId;
   }

   public void setOrdId(final Long ordId) {
      this.ordId = ordId;
   }

   public void setCustName(final String custName) {
      this.custName = custName;
   }

   public void setAreaName(final String areaName) {
      this.areaName = areaName;
   }

   public void setCanteenName(final String canteenName) {
      this.canteenName = canteenName;
   }

   public void setStallName(final String stallName) {
      this.stallName = stallName;
   }

   public void setMealtimeName(final String mealtimeName) {
      this.mealtimeName = mealtimeName;
   }

   public void setDescription(final String description) {
      this.description = description;
   }

   public void setReply(final String reply) {
      this.reply = reply;
   }

   public void setReplyTime(final LocalDateTime replyTime) {
      this.replyTime = replyTime;
   }

   public void setCrtime(final LocalDateTime crtime) {
      this.crtime = crtime;
   }

   public void setShowFlag(final Integer showFlag) {
      this.showFlag = showFlag;
   }

   public void setDishesList(final List<MenuEvaluateDishesVO> dishesList) {
      this.dishesList = dishesList;
   }

   public void setStarLevel(final Integer starLevel) {
      this.starLevel = starLevel;
   }

   public void setPictureList(final List<String> pictureList) {
      this.pictureList = pictureList;
   }
}
