package com.gxwebsoft.shop.entity;

import java.math.BigDecimal;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.*;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 商品记录表
 *
 * @author 科技小王子
 * @since 2024-07-25 19:22:01
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "Goods对象", description = "商品记录表")
@TableName("shop_goods")
public class Goods implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "自增ID")
    @TableId(value = "goods_id", type = IdType.AUTO)
    private Integer goodsId;

    @ApiModelProperty(value = "类型 1实物商品 2虚拟商品")
    private Integer type;

    @ApiModelProperty(value = "商品编码")
    private String code;

    @ApiModelProperty(value = "商品标题")
    private String goodsName;

    @ApiModelProperty(value = "商品封面图")
    private String image;

    @ApiModelProperty(value = "商品视频")
    private String video;

    @ApiModelProperty(value = "商品详情")
    private String content;

    @ApiModelProperty(value = "商品分类")
    private String category;

    @ApiModelProperty(value = "商品分类ID")
    private Integer categoryId;

    @ApiModelProperty(value = "商品规格 0单规格 1多规格")
    private Integer specs;

    @ApiModelProperty(value = "货架")
    private String position;

    @ApiModelProperty(value = "单位名称")
    private String unitName;

    @ApiModelProperty(value = "消费赚取积分")
    private BigDecimal gainIntegral;

    @ApiModelProperty(value = "进货价格")
    private BigDecimal price;

    @ApiModelProperty(value = "销售价格")
    private BigDecimal salePrice;

    @ApiModelProperty(value = "进货价")
    private BigDecimal buyingPrice;

    @ApiModelProperty(value = "经销商价格")
    private BigDecimal dealerPrice;

    @ApiModelProperty(value = "有赠品(经销商)")
    private Boolean buyingGift;

    @ApiModelProperty(value = "有赠品(会员店)")
    private Boolean priceGift;

    @ApiModelProperty(value = "库存计算方式(10下单减库存 20付款减库存)")
    private Integer deductStockType;

    @ApiModelProperty(value = "封面图")
    private String files;

    @ApiModelProperty(value = "销量")
    private Integer sales;

    @ApiModelProperty(value = "库存")
    private Integer stock;

    @ApiModelProperty(value = "商品重量")
    private Integer goodsWeight;

    @ApiModelProperty(value = "推荐")
    private Integer recommend;

    @ApiModelProperty(value = "商户ID")
    private Integer merchantId;

    @ApiModelProperty(value = "商户名称")
    private String merchantName;

    @ApiModelProperty(value = "商户logo")
    @TableField(exist = false)
    private String merchantAvatar;

    @ApiModelProperty(value = "状态（0：未上架，1：上架）")
    private Integer isShow;

    @ApiModelProperty(value = "状态, 0上架 1待上架 2待审核 3审核不通过")
    private Integer status;

    @ApiModelProperty(value = "备注")
    private String comments;

    @ApiModelProperty(value = "排序号")
    private Integer sortNumber;

    @ApiModelProperty(value = "用户ID")
    private Integer userId;

    @ApiModelProperty(value = "是否删除, 0否, 1是")
    @TableLogic
    private Integer deleted;

    @ApiModelProperty(value = "租户id")
    private Integer tenantId;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @ApiModelProperty(value = "商品规格")
    @TableField(exist = false)
    private GoodsSpec goodsSpec;

    @ApiModelProperty(value = "规格值")
    @TableField(exist = false)
    private String specValue;

    @ApiModelProperty(value = "商品规格值")
    @TableField(exist = false)
    private Object goodsSpecValue;

    @ApiModelProperty(value = "商品sku列表")
    @TableField(exist = false)
    private List<GoodsSku> goodsSkus;

    @ApiModelProperty(value = "购物车数量")
    @TableField(exist = false)
    private Integer totalNums;

    @ApiModelProperty(value = "行业分类")
    @TableField(exist = false)
    private String industryName;

    @ApiModelProperty(value = "按店铺ID集合查询")
    @TableField(exist = false)
    private Set<Integer> shopIdsByIndustry;

    @ApiModelProperty(value = "店铺信息")
    @TableField(exist = false)
    private Merchant merchant;

    @ApiModelProperty(value = "父级栏目ID")
    @TableField(exist = false)
    private Integer parentId;

    @ApiModelProperty(value = "父级栏目名称")
    private String parentName;

    @ApiModelProperty(value = "父级栏目路径")
    @TableField(exist = false)
    private String parentPath;

    @ApiModelProperty(value = "当前栏目名称")
    private String categoryName;

    @ApiModelProperty(value = "三级栏目名称")
    @TableField(exist = false)
    private String childrenName;

  public String getParentPath() {
    if (ObjectUtil.isNotEmpty(this.parentId)) {
      return "/product/".concat(this.parentId.toString());
    }
    return "/product";
  }
}
