package com.bonus.canteen.core.order.web.vo;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.bonus.canteen.core.common.constant.NuclearModeEnum;
import com.bonus.canteen.core.common.encrypt.HandleType;
import com.bonus.canteen.core.common.encrypt.LeNiuDecryptDataProcess;
import com.bonus.canteen.core.common.encrypt.LeNiuDecryptField;
import com.bonus.canteen.core.common.utils.CustomLocalDateStringConverter;
import com.bonus.canteen.core.common.utils.CustomNumberConverter;
import com.bonus.canteen.core.common.utils.SysUtil;
import com.bonus.canteen.core.customer.constants.OrderTypeEnum;
import com.bonus.canteen.core.order.common.constants.CheckStateEnum;
import com.bonus.canteen.core.order.utils.LeOrderUtil;
import com.bonus.canteen.core.pay.common.constants.PayTypeEnum;
import com.bonus.common.houqin.constant.LeConstants;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@LeNiuDecryptDataProcess
public class OrderRefundWebVO {
   @ExcelProperty(
      value = {"订单类型"},
      order = 0,
      converter = OrderTypeEnum.ExcelConvertor.class
   )
   private Integer orderType;
   @ApiModelProperty("审核状态")
   @ExcelProperty(
      value = {"审核状态"},
      order = 0,
      converter = CheckStateEnum.ExcelConvertor.class
   )
   private Integer checkState;
   @ApiModelProperty("申请时间")
   @ExcelProperty(
      value = {"申请时间"},
      order = 1,
      converter = CustomLocalDateStringConverter.class
   )
   private LocalDateTime applyTime;
   @ApiModelProperty("下单时间")
   @ExcelProperty(
      value = {"下单时间"},
      order = 1,
      converter = CustomLocalDateStringConverter.class
   )
   private LocalDateTime orderTime;
   @ApiModelProperty("人员编号")
   @ExcelProperty(
      value = {"用户编号"},
      order = 2
   )
   private String custNum;
   @ApiModelProperty("人员姓名")
   @ExcelProperty(
      value = {"用户姓名"},
      order = 3
   )
   @LeNiuDecryptField
   private String custName;
   @LeNiuDecryptField(HandleType.DESENSITIZE_MOBILE_PHONE)
   @ApiModelProperty("手机号")
   @ExcelProperty(
      value = {"用户手机号"},
      order = 4
   )
   private String mobile;
   @ApiModelProperty("组织名称")
   @ExcelProperty(
      value = {"所属组织"},
      order = 5
   )
   private String orgFullName;
   @ApiModelProperty("申请理由")
   @ExcelProperty(
      value = {"退款原因"},
      order = 6
   )
   private String applyReason;
   @ExcelIgnore
   private BigDecimal realAmount;
   @ExcelProperty(
      value = {"申请退款金额"},
      order = 10,
      converter = CustomNumberConverter.class
   )
   private BigDecimal refundAmount;
   @ExcelProperty(
      value = {"同意退款金额"},
      order = 10,
      converter = CustomNumberConverter.class
   )
   private BigDecimal realRefundAmount;
   @ExcelIgnore
   private BigDecimal feeRate;
   @ExcelProperty(
      value = {"手续费金额"},
      order = 10,
      converter = CustomNumberConverter.class
   )
   private BigDecimal refundFeeAmount;
   @ApiModelProperty("订单id")
   @ExcelProperty(
      value = {"订单号"},
      order = 12
   )
   private String orderId;
   @ApiModelProperty("设备订单号")
   @ExcelProperty(
      value = {"设备订单号"},
      order = 12
   )
   private String macOrderId;
   @ApiModelProperty("订单退单id")
   @ExcelIgnore
   private Long orderRefundId;
   @ApiModelProperty("申请类型  1-退单 2-纠错")
   @ExcelIgnore
   private Integer applyType;
   @ApiModelProperty("纠错图片 多个用逗号分割")
   @ExcelIgnore
   private String resressPicurl;
   @ApiModelProperty("审核时间  yyyy-MM-dd HH:mm:ss")
   @ExcelIgnore
   private LocalDateTime checkTime;
   @ApiModelProperty("审核结果")
   @ExcelIgnore
   private String checkResult;
   @ApiModelProperty("餐盘物理号")
   @ExcelProperty(
      value = {"餐盘物理号"},
      order = 13
   )
   private String plateSerialNum;
   @ExcelProperty(
      value = {"审核人"},
      order = 13
   )
   private String checkBy;
   @ExcelProperty(
      value = {"申请退款菜品"},
      order = 9
   )
   private String applyDishDetailStr;
   @ExcelProperty(
      value = {"同意退款菜品"},
      order = 9
   )
   private String realDishDetailStr;
   @ExcelProperty(
      value = {"退库存数量"},
      order = 9
   )
   private String restoreQuantityStr;
   @ExcelProperty(
      value = {"支付类型"},
      order = 10,
      converter = PayTypeEnum.ExcelConvertor.class
   )
   private Integer payType;
   @ExcelProperty(
      value = {"核身方式"},
      order = 10,
      converter = NuclearModeEnum.ExcelConvertor.class
   )
   private Integer nuClearMode;
   @ExcelIgnore
   private LocalDate orderDate;
   @ExcelIgnore
   private Long flowInstanceId;
   @ExcelIgnore
   private Integer auditable;
   @ExcelProperty(
      value = {"托盘编号"},
      order = 13
   )
   private String plateNum;
   @ApiModelProperty("退款明细")
   private List<OrderRefundDetailVO> refundDetailList;

   public String getApplyDishDetailStr() {
      return LeOrderUtil.getRefundDetailDescStr(this.refundDetailList, this.orderType, false);
   }

   public String getRealDishDetailStr() {
      return LeOrderUtil.getRefundDetailDescStr(this.refundDetailList, this.orderType, true);
   }

   public String getRestoreQuantityStr() {
      return LeOrderUtil.getRestoreQuantityDescStr(this.refundDetailList, this.orderType);
   }

   public String getResressPicurl() {
      return (String)StrUtil.splitTrim(this.resressPicurl, ",").stream().map(SysUtil::getCutFileUrl).collect(Collectors.joining(","));
   }

   public OrderRefundWebVO() {
      this.auditable = LeConstants.COMMON_NO;
   }

   public Integer getOrderType() {
      return this.orderType;
   }

   public Integer getCheckState() {
      return this.checkState;
   }

   public LocalDateTime getApplyTime() {
      return this.applyTime;
   }

   public LocalDateTime getOrderTime() {
      return this.orderTime;
   }

   public String getCustNum() {
      return this.custNum;
   }

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

   public String getMobile() {
      return this.mobile;
   }

   public String getOrgFullName() {
      return this.orgFullName;
   }

   public String getApplyReason() {
      return this.applyReason;
   }

   public BigDecimal getRealAmount() {
      return this.realAmount;
   }

   public BigDecimal getRefundAmount() {
      return this.refundAmount;
   }

   public BigDecimal getRealRefundAmount() {
      return this.realRefundAmount;
   }

   public BigDecimal getFeeRate() {
      return this.feeRate;
   }

   public BigDecimal getRefundFeeAmount() {
      return this.refundFeeAmount;
   }

   public String getOrderId() {
      return this.orderId;
   }

   public String getMacOrderId() {
      return this.macOrderId;
   }

   public Long getOrderRefundId() {
      return this.orderRefundId;
   }

   public Integer getApplyType() {
      return this.applyType;
   }

   public LocalDateTime getCheckTime() {
      return this.checkTime;
   }

   public String getCheckResult() {
      return this.checkResult;
   }

   public String getPlateSerialNum() {
      return this.plateSerialNum;
   }

   public String getCheckBy() {
      return this.checkBy;
   }

   public Integer getPayType() {
      return this.payType;
   }

   public Integer getNuClearMode() {
      return this.nuClearMode;
   }

   public LocalDate getOrderDate() {
      return this.orderDate;
   }

   public Long getFlowInstanceId() {
      return this.flowInstanceId;
   }

   public Integer getAuditable() {
      return this.auditable;
   }

   public String getPlateNum() {
      return this.plateNum;
   }

   public List<OrderRefundDetailVO> getRefundDetailList() {
      return this.refundDetailList;
   }

   public void setOrderType(final Integer orderType) {
      this.orderType = orderType;
   }

   public void setCheckState(final Integer checkState) {
      this.checkState = checkState;
   }

   public void setApplyTime(final LocalDateTime applyTime) {
      this.applyTime = applyTime;
   }

   public void setOrderTime(final LocalDateTime orderTime) {
      this.orderTime = orderTime;
   }

   public void setCustNum(final String custNum) {
      this.custNum = custNum;
   }

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

   public void setMobile(final String mobile) {
      this.mobile = mobile;
   }

   public void setOrgFullName(final String orgFullName) {
      this.orgFullName = orgFullName;
   }

   public void setApplyReason(final String applyReason) {
      this.applyReason = applyReason;
   }

   public void setRealAmount(final BigDecimal realAmount) {
      this.realAmount = realAmount;
   }

   public void setRefundAmount(final BigDecimal refundAmount) {
      this.refundAmount = refundAmount;
   }

   public void setRealRefundAmount(final BigDecimal realRefundAmount) {
      this.realRefundAmount = realRefundAmount;
   }

   public void setFeeRate(final BigDecimal feeRate) {
      this.feeRate = feeRate;
   }

   public void setRefundFeeAmount(final BigDecimal refundFeeAmount) {
      this.refundFeeAmount = refundFeeAmount;
   }

   public void setOrderId(final String orderId) {
      this.orderId = orderId;
   }

   public void setMacOrderId(final String macOrderId) {
      this.macOrderId = macOrderId;
   }

   public void setOrderRefundId(final Long orderRefundId) {
      this.orderRefundId = orderRefundId;
   }

   public void setApplyType(final Integer applyType) {
      this.applyType = applyType;
   }

   public void setResressPicurl(final String resressPicurl) {
      this.resressPicurl = resressPicurl;
   }

   public void setCheckTime(final LocalDateTime checkTime) {
      this.checkTime = checkTime;
   }

   public void setCheckResult(final String checkResult) {
      this.checkResult = checkResult;
   }

   public void setPlateSerialNum(final String plateSerialNum) {
      this.plateSerialNum = plateSerialNum;
   }

   public void setCheckBy(final String checkBy) {
      this.checkBy = checkBy;
   }

   public void setApplyDishDetailStr(final String applyDishDetailStr) {
      this.applyDishDetailStr = applyDishDetailStr;
   }

   public void setRealDishDetailStr(final String realDishDetailStr) {
      this.realDishDetailStr = realDishDetailStr;
   }

   public void setRestoreQuantityStr(final String restoreQuantityStr) {
      this.restoreQuantityStr = restoreQuantityStr;
   }

   public void setPayType(final Integer payType) {
      this.payType = payType;
   }

   public void setNuClearMode(final Integer nuClearMode) {
      this.nuClearMode = nuClearMode;
   }

   public void setOrderDate(final LocalDate orderDate) {
      this.orderDate = orderDate;
   }

   public void setFlowInstanceId(final Long flowInstanceId) {
      this.flowInstanceId = flowInstanceId;
   }

   public void setAuditable(final Integer auditable) {
      this.auditable = auditable;
   }

   public void setPlateNum(final String plateNum) {
      this.plateNum = plateNum;
   }

   public void setRefundDetailList(final List<OrderRefundDetailVO> refundDetailList) {
      this.refundDetailList = refundDetailList;
   }
}
