|
| 1 | +package spda |
| 2 | + |
| 3 | +import ( |
| 4 | + "encoding/xml" |
| 5 | +) |
| 6 | + |
| 7 | +// CDATA generate cdata field |
| 8 | +type CDATA struct { |
| 9 | + Text string `xml:",cdata"` |
| 10 | +} |
| 11 | + |
| 12 | +// CDATAList list of cdata fields |
| 13 | +type CDATAList struct { |
| 14 | + //Items |
| 15 | + Items []CDATA `xml:"e,omitempty"` |
| 16 | +} |
| 17 | + |
| 18 | +// DocIndex 索引文件 |
| 19 | +type DocIndex struct { |
| 20 | + XMLName xml.Name `xml:"docindex"` |
| 21 | + // FileItem 文件 |
| 22 | + FileItem []FileItem `xml:"fileitem"` |
| 23 | +} |
| 24 | + |
| 25 | +// FileItem 单条索引文件 |
| 26 | +type FileItem struct { |
| 27 | + // File 包含商品信息的XML文件地址 |
| 28 | + File string `xml:"file"` |
| 29 | + // Lastmod 最后修改时间,单位秒 |
| 30 | + Lastmod int64 `xml:"lastmod"` |
| 31 | +} |
| 32 | + |
| 33 | +// Image 图片 |
| 34 | +type Image struct { |
| 35 | + // Url 图片链接 |
| 36 | + Url string `xml:"url"` |
| 37 | + // Width 图片宽度 |
| 38 | + Width int `xml:"width,omitempty"` |
| 39 | + // Height 图片高度 |
| 40 | + Height int `xml:"height,omitempty"` |
| 41 | + // Desc 图片描述 |
| 42 | + Desc *CDATA `xml:"description,omitempty"` |
| 43 | +} |
| 44 | + |
| 45 | +// Video 视频 |
| 46 | +type Video struct { |
| 47 | + // Url 视频链接 |
| 48 | + Url string `xml:"url"` |
| 49 | + // Width 视频宽度 |
| 50 | + Width int `xml:"width,omitempty"` |
| 51 | + // Height 视频高度 |
| 52 | + Height int `xml:"height,omitempty"` |
| 53 | + // Duration 视频时长 |
| 54 | + Duration int `xml:"duration,omitempty"` |
| 55 | + // Ratio 视频码率 |
| 56 | + Ratio *CDATA `xml:"ratio,omitempty"` |
| 57 | +} |
| 58 | + |
| 59 | +// Ext 扩展字段 |
| 60 | +type Ext struct { |
| 61 | + // Name |
| 62 | + Name CDATA `xml:"name"` |
| 63 | + // Value |
| 64 | + Value CDATA `xml:"value"` |
| 65 | +} |
| 66 | + |
| 67 | +// GPS 投放范围 |
| 68 | +type GPS struct { |
| 69 | + // Lng 经度 |
| 70 | + Lng float64 `xml:"longitude"` |
| 71 | + // Lat 维度 |
| 72 | + Lat float64 `xml:"latitude"` |
| 73 | + // Range 缓存半径 |
| 74 | + Range int `xml:"range"` |
| 75 | +} |
| 76 | + |
| 77 | +// Target 定向 |
| 78 | +type Target struct { |
| 79 | + // GPS 投放范围 |
| 80 | + GPS *GPS `xml:"GPS,omitempty"` |
| 81 | + // Country 国家 |
| 82 | + Country *CDATAList `xml:"country,omitempty"` |
| 83 | + // Province 省份 |
| 84 | + Province *CDATAList `xml:"province,omitempty"` |
| 85 | + // City 城市 |
| 86 | + City *CDATAList `xml:"city,omitempty"` |
| 87 | + // TradingArea 商圈 |
| 88 | + TradingArea *CDATAList `xml:"tradingArea,omitempty"` |
| 89 | + // Age 年龄 |
| 90 | + Age []int `xml:"age>e,omitempty"` |
| 91 | + // Gender 性别 |
| 92 | + Gender int `xml:"gender,omitempty"` |
| 93 | + // ToutiaoTag 兴趣标签, https://bytedance.feishu.cn/sheets/shtcn7B174AiQDTsKrkeSNHiJ7c |
| 94 | + ToutiaoTag []int `xml:"toutiaoTag,omitempty"` |
| 95 | +} |
| 96 | + |
| 97 | +// Delivery 投放控制 |
| 98 | +type Delivery struct { |
| 99 | + // DeliverVideo 是否投放视频广告 |
| 100 | + DeliverVideo int `xml:"deliverVideo"` |
| 101 | +} |
| 102 | + |
| 103 | +// File 商品信息文件 |
| 104 | +type File struct { |
| 105 | + XMLName xml.Name `xml:"dataset"` |
| 106 | + // ID 商品ID, 主键,用于区别商品 |
| 107 | + ID uint64 `xml:"id"` |
| 108 | + // Name 商品名, |
| 109 | + Name CDATA `xml:"name"` |
| 110 | + // Title 商品标题 |
| 111 | + Title *CDATA `xml:"title"` |
| 112 | + // Condition 商品新旧情况, 全新,翻新,二手 |
| 113 | + Condition *CDATA `xml:"condition,omitempty"` |
| 114 | + // Desc 商品描述 |
| 115 | + Desc *CDATA `xml:"description,omitempty"` |
| 116 | + // Stock 库存状态,用限制商品投放状态;如果投放时间在上线时间和下线时间之间,stock为1,且status为1时可以投放 |
| 117 | + Stock int `xml:"stock"` |
| 118 | + // Status 投放状态, 限制商品投放状态;如果投放时间在上线时间和下线时间之间,stock为1,且status为1时可以投放 |
| 119 | + Status int `xml:"status"` |
| 120 | + // Image 商品主图, 基础商品图,展示在信息流中的原始素材 |
| 121 | + Image Image `xml:"image"` |
| 122 | + // Images 图片列表, 扩展商品图,商品图片的补充, "和image不一致的最好大于3张的商品图片,如果要投放视频广告建议至少5张图片,像素大小690*388以上(5K以上),图片的顺序默认为广告主认为按重要性传输的,与image比例一致,不超过10张" |
| 123 | + Images []Image `xml:"images>e"` |
| 124 | + // Video 视频内容,7-30s之间, {""url"":""www.xxx.com"",""width"":1280,""height"":720,""duration"":15,""ratio"":4818//码率,单位kps},抖音:1280*720(横板)或720*1280(竖版)URL应保证可用,浏览器可打开,比例一致,链接要保持长久有效,不能是临时链接" |
| 125 | + Video *Video `xml:"video,omitempty"` |
| 126 | + // BrandID 品牌ID, "应保证每一种品牌的id唯一性,用于相似商品推荐时强烈建议传,否则影响投放效果,如组图" |
| 127 | + BrandID *CDATA `xml:"brandID,omitempty"` |
| 128 | + // BrandName 品牌名 |
| 129 | + BrandName *CDATA `xml:"brandName,omitempty"` |
| 130 | + // EnBrand 英文品牌名 |
| 131 | + EnBrand *CDATA `xml:"enBrand,omitempty"` |
| 132 | + // BrandUrl PC端品牌落地页URL |
| 133 | + BrandUrl *CDATA `xml:"brandUrl,omitempty"` |
| 134 | + // BrandUrlMobile H5页面品牌落地页URL |
| 135 | + BrandUrlMobile *CDATA `xml:"brandUrlMobile,omitempty"` |
| 136 | + // BrandUrlAndroidApp Android应用品牌直达吊起链接 |
| 137 | + BrandUrlAndroidApp *CDATA `xml:"brandUrlAndroidApp,omitempty"` |
| 138 | + // BrandUrlIosApp IOS应用品牌直达吊起链接 |
| 139 | + BrandUrlIosApp *CDATA `xml:"brandUrlIosApp,omitempty"` |
| 140 | + // BrandUrlUniversalLink IOS应用品牌吊起ulink链接 |
| 141 | + BrandUrlUniversalLink *CDATA `xml:"brandUrlUniversalLink,omitempty"` |
| 142 | + // ShopKeeperID 商户ID;"应保证每一个商户的id唯一性,用于相似商品推荐时强烈建议传,否则影响投放效果,如组图" |
| 143 | + ShopKeeperID *CDATA `xml:"shopKeeperID,omitempty"` |
| 144 | + // ShopKeeperName 商户名 |
| 145 | + ShopKeeperName *CDATA `xml:"shopKeeperName,omitempty"` |
| 146 | + // ShopKeeperUrl PC端商户落地页URL |
| 147 | + ShopKeeperUrl *CDATA `xml:"shopKeeperUrl,omitempty"` |
| 148 | + // ShopKeeperUrlMobile H5页面商户落地页URL |
| 149 | + ShopKeeperUrlMobile *CDATA `xml:"shopKeeperUrlMobile,omitempty"` |
| 150 | + // ShopKeeperUrlAndroidApp Android应用商户直达吊起链接 |
| 151 | + ShopKeeperUrlAndroidApp *CDATA `xml:"shopKeeperUrlAndroidApp,omitempty"` |
| 152 | + // ShopKeeperUrlIosApp IOS应用商户直达吊起链接 |
| 153 | + ShopKeeperUrlIosApp *CDATA `xml:"shopKeeperUrlIosApp,omitempty"` |
| 154 | + // ShopKeeperUrlUniversalLink IOS应用商户吊起ulink链接 |
| 155 | + ShopKeeperUrlUniversalLink *CDATA `xml:"shopKeeperUrlUniversalLink,omitempty"` |
| 156 | + // TargetUrl PC端商品落地页URL |
| 157 | + TargetUrl *CDATA `xml:"targetUrl,omitempty"` |
| 158 | + // TargetUrlMobile H5页面商品落地页URL |
| 159 | + TargetUrlMobile *CDATA `xml:"targetUrlMobile,omitempty"` |
| 160 | + // TargetUrlAndroidApp Android应用直达落地页 |
| 161 | + TargetUrlAndroidApp *CDATA `xml:"targetUrlAndroidApp,omitempty"` |
| 162 | + // TargetUrlIosApp IOS应用商品直达吊起链接 |
| 163 | + TargetUrlIosApp *CDATA `xml:"targetUrlIosApp,omitempty"` |
| 164 | + // TargetUrlUniversalLink IOS应用商品吊起ulink链接 |
| 165 | + TargetUrlUniversalLink *CDATA `xml:"targetUrlUniversalLink,omitempty"` |
| 166 | + // FirstCategory 一级分类 |
| 167 | + FirstCategory *CDATA `xml:"firstCategory,omitempty"` |
| 168 | + // SubCategory 二级分类 |
| 169 | + SubCategory *CDATA `xml:"subCategory,omitempty"` |
| 170 | + // ThirdCategory 三级分类 |
| 171 | + ThirdCategory *CDATA `xml:"thirdCategory,omitempty"` |
| 172 | + // FirstCategoryID 一级分类ID |
| 173 | + FirstCategoryID uint64 `xml:"firstCategryId,omitempty"` |
| 174 | + // SubCategoryID 二级分类ID |
| 175 | + SubCategoryID uint64 `xml:"subCategoryId,omitempty"` |
| 176 | + // ThirdCategoryID 三级分类ID |
| 177 | + ThirdCategoryID uint64 `xml:"thirdCategoryId,omitempty"` |
| 178 | + // Value 商品原价 |
| 179 | + Value float64 `xml:"value,omitempty"` |
| 180 | + // PriceUnit 价格单位; RMB,万元两种格式都可 |
| 181 | + PriceUnit string `xml:"priceUnit,omitempty"` |
| 182 | + // Saving 减价 |
| 183 | + Saving float64 `xml:"saving,omitempty"` |
| 184 | + // Discount 商品折扣 |
| 185 | + Discount float64 `xml:"discount,omitempty"` |
| 186 | + // Price 商品现价 |
| 187 | + Price float64 `xml:"price,omitempty"` |
| 188 | + // SalesPromotion 促销活动 |
| 189 | + SalesPromotion *CDATA `xml:"salesPromotion,omitempty"` |
| 190 | + // DownPayment 首付 |
| 191 | + DownPayment *CDATA `xml:"downPayment,omitempty"` |
| 192 | + // Mortage 月付 |
| 193 | + Mortage *CDATA `xml:"mortage,omitempty"` |
| 194 | + // DailyMortage 日付 |
| 195 | + DailyMortage *CDATA `xml:"dailyMortage,omitempty"` |
| 196 | + // Address 地址; 可填商户地址 |
| 197 | + Address *CDATA `xml:"address,omitempty"` |
| 198 | + // Feature 特色; 七天无条件退款 |
| 199 | + Feature *CDATA `xml:"feature,omitempty"` |
| 200 | + // Mark 评分 |
| 201 | + Mark float64 `xml:"mark,omitempty"` |
| 202 | + // Bought 购买量 |
| 203 | + Bought int `xml:"bought,omitempty"` |
| 204 | + // Comments 评论数 |
| 205 | + Comments int `xml:"comments,omitempty"` |
| 206 | + // Tag 商品标签 |
| 207 | + Tag *CDATA `xml:"tag,omitempty"` |
| 208 | + // Ext 扩展字段; 广告主定制,通知头条方 |
| 209 | + Ext []Ext `xml:"ext>e"` |
| 210 | + // Target 定向字段 |
| 211 | + Target *Target `xml:"target,omitempty"` |
| 212 | + // Delivery 投放控制字段 |
| 213 | + Delivery *Delivery `xml:"delivery,omitempty"` |
| 214 | + // OnlineTime 上线时间; 时间戳类型,限制商品投放状态, |
| 215 | + OnlineTime int64 `xml:"onlineTime,omitempty"` |
| 216 | + // OfflineTime 下线时间; 时间戳类型,限制商品投放状态;如果投放时间在上线时间和下线时间之间,stock为1,且status为1时可以投放 |
| 217 | + OfflineTime int64 `xml:"offlineTime,omitempty"` |
| 218 | +} |
0 commit comments