package com.yiqi.order.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yiqi.activity.domain.ActivityCouponItem;
import com.yiqi.app.domain.AppCouponType;
import com.yiqi.common.annotation.Excel;
import com.yiqi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Map;


@ApiModel("活动订单优惠券信息")
@TableName("order_activity_item")
@Data
public class OrderActivityItem extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @ApiModelProperty("主键ID")
    @TableId(type = IdType.AUTO)

    private Long id;

    /**
     * 订单ID
     */
    @Excel(name = "订单ID")
    @ApiModelProperty("订单ID")

    private Long orderId;

    /**
     * 订单编号
     */
    @Excel(name = "订单编号")
    @ApiModelProperty("订单编号")
    private String orderNo;

    /** 活动id */
    @Excel(name = "活动id")
    @ApiModelProperty("活动id")

    private Long activityId;

    /**
     * 优惠券类型ID
     */
    @Excel(name = "优惠券类型ID")
    @ApiModelProperty("优惠券类型ID")

    private Long couponTypeId;

    /**
     * 优惠券类型名称
     */
    @Excel(name = "优惠券类型名称")
    @ApiModelProperty("优惠券类型名称")
    private String title;

    /**
     * 优惠券类型图片
     */
    @Excel(name = "优惠券类型图片")
    @ApiModelProperty("优惠券类型图片")
    private String imgUrl;

    /**
     * 优惠券数量
     */
    @Excel(name = "优惠券数量")
    @ApiModelProperty("优惠券数量")
    private Integer couponCount;

    public static OrderActivityItem buildOrderActivityItem(OrderActivity orderActivity, AppCouponType appCouponType){
        OrderActivityItem orderActivityItem = new OrderActivityItem();
        orderActivityItem.setOrderNo(orderActivity.getOrderNo());
        orderActivityItem.setOrderId(orderActivity.getId());
        orderActivityItem.setActivityId(orderActivity.getActivityId());
        orderActivityItem.setCouponCount(1);
        orderActivityItem.setTitle(appCouponType.getTitle());
        orderActivityItem.setImgUrl(appCouponType.getImgUrl());
        orderActivityItem.setCouponTypeId(appCouponType.getId());
        orderActivityItem.buildCreateData();
        return orderActivityItem;
    }
}
