package com.gxwebsoft.shop.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * 机构
 *
 * @author LX
 * @since 2025-04-14 00:35:34
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class UnionGoodsItem implements Serializable {
    //商品ID
    public String goodsId;
    //商品名称
    public String goodsName;
    //商品数量
    public String quantity;
    //商品单价（分）
    public String price;
    //商品分类
//    public String goodsCategory;
    //商品说明
    public String body;
    //商品单位
    public String unit;
    //商品折扣
    public int discount;
    //子商户号
//    public String subMerchantId;
    //子商户商品总额
//    int subOrderAmount;

    public String toJson() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (this.goodsId != null) sb.append("\"goodsId\":\"" + this.goodsId + "\",");
        if (this.goodsName != null) sb.append("\"goodsName\":\"" + this.goodsName + "\",");
        if (this.quantity != null) sb.append("\"quantity\":\"" + this.quantity + "\",");
        if (this.price != null) sb.append("\"price\":\"" + this.price + "\",");
//        if (this.goodsCategory != null) sb.append("\"goodsCategory\":\"" + this.goodsCategory + "\",");
        if (this.body != null) sb.append("\"body\":\"" + this.body + "\",");
        if (this.unit != null) sb.append("\"unit\":\"" + this.unit + "\",");
        if (this.discount != 0) sb.append("\"discount\":\"" + this.discount + "\",");
//        if (this.subMerchantId != null) sb.append("\"subMerchantId\":\"" + this.subMerchantId + "\",");
//        if (this.subOrderAmount != 0) sb.append("\"subOrderAmount\":\"" + this.subOrderAmount + "\",");
        if (sb.charAt(sb.length() - 1) == ',')
            sb.deleteCharAt(sb.length() - 1);
        sb.append("}");
        return sb.toString();
    }
}
