ItemsGetRequest.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <?php
  2. /**
  3. * TOP API: taobao.items.get request
  4. *
  5. * @author auto create
  6. * @since 1.0, 2015.06.11
  7. */
  8. class ItemsGetRequest
  9. {
  10. /**
  11. * 商品所属类目Id,ItemCat中的cid字段。可以通过taobao.itemcats.get取到
  12. **/
  13. private $cid;
  14. /**
  15. * 商品最高价格。单位:元。正整数,取值范围:0-100000000
  16. **/
  17. private $endPrice;
  18. /**
  19. * 商品所属卖家的最大信用等级数,1表示1心,2表示2心……,设置此条件表示搜索结果里的商品,所属的卖家信用必须小于等于设置的end_score
  20. **/
  21. private $endScore;
  22. /**
  23. * 商品最近成交量最大值,设置此条件表示搜索结果里的商品,最近成交量必须小于等于设置的end_volume
  24. **/
  25. private $endVolume;
  26. /**
  27. * 需返回的商品结构字段列表。可选值为Item中的以下字段:num_iid,title,nick,pic_url,cid,price,type,delist_time,post_fee;多个字段用“,”分隔。如:num_iid,title。新增字段score(卖家信用等级数),volume(最近成交量),location(卖家地址,可以分别获取location.city,location.state),num_iid商品数字id。此接口返回的post_fee是快递费用,volume对应搜索商品列表页的最近成交量
  28. **/
  29. private $fields;
  30. /**
  31. * 是否正品保障商品(既是如实描述,又是7天无理由退换货的商品,设置了这个属性时:is_prepay和promoted_service不能再行设置),设置为true表示该商品是正品保障的商品,设置为false或不设置表示不判断这个属性
  32. **/
  33. private $genuineSecurity;
  34. /**
  35. * 是否是3D淘宝的商品,置为false或为空表示不对是否3D商品进行判断
  36. **/
  37. private $is3D;
  38. /**
  39. * 是否支持货到付款,设置为true表示支持货到付款,设置为false或不设置表示不判断这个属性
  40. **/
  41. private $isCod;
  42. /**
  43. * 表示是否搜索商城的商品这一搜索条件。值含义:true:搜索商城商品,false:搜素集市商品,若为null,则搜索全部的商品(默认值)
  44. **/
  45. private $isMall;
  46. /**
  47. * 是否如实描述(即:先行赔付)商品,设置为true表示该商品是如实描述的商品,设置为false或不设置表示不判断这个属性
  48. **/
  49. private $isPrepay;
  50. /**
  51. * 表示是否新品这一搜索条件。值含义:true-是新品,false-无限制,null-无限制
  52. **/
  53. private $isXinpin;
  54. /**
  55. * 所在市。如:杭州。具体可以根据taobao.areas.get取到
  56. **/
  57. private $locationCity;
  58. /**
  59. * 所在省。如:浙江。具体可以根据taobao.areas.get 取到
  60. **/
  61. private $locationState;
  62. /**
  63. * 卖家昵称列表。多个之间以“,”分隔;最多支持5个卖家昵称。如:nick1,nick2,nick3
  64. **/
  65. private $nicks;
  66. /**
  67. * 是否淘1站代购商品,设置为true表示淘1站商品,设置为false或不设置表示不判断这个属性
  68. **/
  69. private $oneStation;
  70. /**
  71. * 排序方式。格式为column:asc/desc,column可选值为: price(价格), delist_time(下架时间), seller_credit(卖家信用),popularity(人气)。如按价格升序排列表示为:price:asc。新增排序字段:volume(最近成交量)
  72. **/
  73. private $orderBy;
  74. /**
  75. * 页码。取值范围:大于零的整数。默认值为1,即默认返回第一页数据。用此接口获取数据时,当翻页获取的条数(page_no*page_size)超过10240,为了保护后台搜索引擎,接口将报错。所以请大家尽可能的细化自己的搜索条件,例如根据修改时间分段获取商品
  76. **/
  77. private $pageNo;
  78. /**
  79. * 每页条数。取值范围:大于零的整数;最大值:200;默认值:40
  80. **/
  81. private $pageSize;
  82. /**
  83. * 免运费(不设置包含所有邮费状态,设置为true结果只有卖家包邮的商品)。不能单独使用,要和其他条件一起用才行
  84. **/
  85. private $postFree;
  86. /**
  87. * 可以根据产品Id搜索属于这个spu的商品。这个字段可以通过查询 taobao.products.get 取到
  88. **/
  89. private $productId;
  90. /**
  91. * 是否提供保障服务的商品。可选入参有:2、4。设置为2表示该商品是“假一赔三”的商品,设置为4表示该商品是“7天无理由退换货”的商品
  92. **/
  93. private $promotedService;
  94. /**
  95. * 商品属性。可以搜到拥有和输入的属性一样的商品列表。字段格式为:pid1:vid1;pid2:vid2.属性的pid调用taobao.itemprops.get取得,属性值的vid用taobao.itempropvalues.get取得vid。
  96. **/
  97. private $props;
  98. /**
  99. * 搜索字段。 用来搜索商品的title以及商品所对应的产品的title
  100. **/
  101. private $q;
  102. /**
  103. * 商品最低价格。单位:元。正整数,取值范围:0-100000000。
  104. **/
  105. private $startPrice;
  106. /**
  107. * 商品所属卖家的最小信用等级数,1表示1心,2表示2心……,设置此条件表示搜索结果里的商品,所属的卖家信用必须大于等于设置的start_score。
  108. **/
  109. private $startScore;
  110. /**
  111. * 商品最近成交量最小值,设置此条件表示搜索结果里的商品,最近成交量必须大于等于设置的start_volume。
  112. **/
  113. private $startVolume;
  114. /**
  115. * 商品的新旧状态。可选入参有:new、second、unused 。设置为new表示该商品是全新的商品,设置为second表示该商品是二手的商品,设置为unused表示该商品是闲置的商品
  116. **/
  117. private $stuffStatus;
  118. /**
  119. * 旺旺在线状态(不设置结果包含所有状态,设置为true结果只有旺旺在线卖家的商品)。不能单独使用,要和其他条件一起用才行
  120. **/
  121. private $wwStatus;
  122. private $apiParas = array();
  123. public function setCid($cid)
  124. {
  125. $this->cid = $cid;
  126. $this->apiParas["cid"] = $cid;
  127. }
  128. public function getCid()
  129. {
  130. return $this->cid;
  131. }
  132. public function setEndPrice($endPrice)
  133. {
  134. $this->endPrice = $endPrice;
  135. $this->apiParas["end_price"] = $endPrice;
  136. }
  137. public function getEndPrice()
  138. {
  139. return $this->endPrice;
  140. }
  141. public function setEndScore($endScore)
  142. {
  143. $this->endScore = $endScore;
  144. $this->apiParas["end_score"] = $endScore;
  145. }
  146. public function getEndScore()
  147. {
  148. return $this->endScore;
  149. }
  150. public function setEndVolume($endVolume)
  151. {
  152. $this->endVolume = $endVolume;
  153. $this->apiParas["end_volume"] = $endVolume;
  154. }
  155. public function getEndVolume()
  156. {
  157. return $this->endVolume;
  158. }
  159. public function setFields($fields)
  160. {
  161. $this->fields = $fields;
  162. $this->apiParas["fields"] = $fields;
  163. }
  164. public function getFields()
  165. {
  166. return $this->fields;
  167. }
  168. public function setGenuineSecurity($genuineSecurity)
  169. {
  170. $this->genuineSecurity = $genuineSecurity;
  171. $this->apiParas["genuine_security"] = $genuineSecurity;
  172. }
  173. public function getGenuineSecurity()
  174. {
  175. return $this->genuineSecurity;
  176. }
  177. public function setIs3D($is3D)
  178. {
  179. $this->is3D = $is3D;
  180. $this->apiParas["is_3D"] = $is3D;
  181. }
  182. public function getIs3D()
  183. {
  184. return $this->is3D;
  185. }
  186. public function setIsCod($isCod)
  187. {
  188. $this->isCod = $isCod;
  189. $this->apiParas["is_cod"] = $isCod;
  190. }
  191. public function getIsCod()
  192. {
  193. return $this->isCod;
  194. }
  195. public function setIsMall($isMall)
  196. {
  197. $this->isMall = $isMall;
  198. $this->apiParas["is_mall"] = $isMall;
  199. }
  200. public function getIsMall()
  201. {
  202. return $this->isMall;
  203. }
  204. public function setIsPrepay($isPrepay)
  205. {
  206. $this->isPrepay = $isPrepay;
  207. $this->apiParas["is_prepay"] = $isPrepay;
  208. }
  209. public function getIsPrepay()
  210. {
  211. return $this->isPrepay;
  212. }
  213. public function setIsXinpin($isXinpin)
  214. {
  215. $this->isXinpin = $isXinpin;
  216. $this->apiParas["is_xinpin"] = $isXinpin;
  217. }
  218. public function getIsXinpin()
  219. {
  220. return $this->isXinpin;
  221. }
  222. public function setLocationCity($locationCity)
  223. {
  224. $this->locationCity = $locationCity;
  225. $this->apiParas["location.city"] = $locationCity;
  226. }
  227. public function getLocationCity()
  228. {
  229. return $this->locationCity;
  230. }
  231. public function setLocationState($locationState)
  232. {
  233. $this->locationState = $locationState;
  234. $this->apiParas["location.state"] = $locationState;
  235. }
  236. public function getLocationState()
  237. {
  238. return $this->locationState;
  239. }
  240. public function setNicks($nicks)
  241. {
  242. $this->nicks = $nicks;
  243. $this->apiParas["nicks"] = $nicks;
  244. }
  245. public function getNicks()
  246. {
  247. return $this->nicks;
  248. }
  249. public function setOneStation($oneStation)
  250. {
  251. $this->oneStation = $oneStation;
  252. $this->apiParas["one_station"] = $oneStation;
  253. }
  254. public function getOneStation()
  255. {
  256. return $this->oneStation;
  257. }
  258. public function setOrderBy($orderBy)
  259. {
  260. $this->orderBy = $orderBy;
  261. $this->apiParas["order_by"] = $orderBy;
  262. }
  263. public function getOrderBy()
  264. {
  265. return $this->orderBy;
  266. }
  267. public function setPageNo($pageNo)
  268. {
  269. $this->pageNo = $pageNo;
  270. $this->apiParas["page_no"] = $pageNo;
  271. }
  272. public function getPageNo()
  273. {
  274. return $this->pageNo;
  275. }
  276. public function setPageSize($pageSize)
  277. {
  278. $this->pageSize = $pageSize;
  279. $this->apiParas["page_size"] = $pageSize;
  280. }
  281. public function getPageSize()
  282. {
  283. return $this->pageSize;
  284. }
  285. public function setPostFree($postFree)
  286. {
  287. $this->postFree = $postFree;
  288. $this->apiParas["post_free"] = $postFree;
  289. }
  290. public function getPostFree()
  291. {
  292. return $this->postFree;
  293. }
  294. public function setProductId($productId)
  295. {
  296. $this->productId = $productId;
  297. $this->apiParas["product_id"] = $productId;
  298. }
  299. public function getProductId()
  300. {
  301. return $this->productId;
  302. }
  303. public function setPromotedService($promotedService)
  304. {
  305. $this->promotedService = $promotedService;
  306. $this->apiParas["promoted_service"] = $promotedService;
  307. }
  308. public function getPromotedService()
  309. {
  310. return $this->promotedService;
  311. }
  312. public function setProps($props)
  313. {
  314. $this->props = $props;
  315. $this->apiParas["props"] = $props;
  316. }
  317. public function getProps()
  318. {
  319. return $this->props;
  320. }
  321. public function setQ($q)
  322. {
  323. $this->q = $q;
  324. $this->apiParas["q"] = $q;
  325. }
  326. public function getQ()
  327. {
  328. return $this->q;
  329. }
  330. public function setStartPrice($startPrice)
  331. {
  332. $this->startPrice = $startPrice;
  333. $this->apiParas["start_price"] = $startPrice;
  334. }
  335. public function getStartPrice()
  336. {
  337. return $this->startPrice;
  338. }
  339. public function setStartScore($startScore)
  340. {
  341. $this->startScore = $startScore;
  342. $this->apiParas["start_score"] = $startScore;
  343. }
  344. public function getStartScore()
  345. {
  346. return $this->startScore;
  347. }
  348. public function setStartVolume($startVolume)
  349. {
  350. $this->startVolume = $startVolume;
  351. $this->apiParas["start_volume"] = $startVolume;
  352. }
  353. public function getStartVolume()
  354. {
  355. return $this->startVolume;
  356. }
  357. public function setStuffStatus($stuffStatus)
  358. {
  359. $this->stuffStatus = $stuffStatus;
  360. $this->apiParas["stuff_status"] = $stuffStatus;
  361. }
  362. public function getStuffStatus()
  363. {
  364. return $this->stuffStatus;
  365. }
  366. public function setWwStatus($wwStatus)
  367. {
  368. $this->wwStatus = $wwStatus;
  369. $this->apiParas["ww_status"] = $wwStatus;
  370. }
  371. public function getWwStatus()
  372. {
  373. return $this->wwStatus;
  374. }
  375. public function getApiMethodName()
  376. {
  377. return "taobao.items.get";
  378. }
  379. public function getApiParas()
  380. {
  381. return $this->apiParas;
  382. }
  383. public function check()
  384. {
  385. RequestCheckUtil::checkMinValue($this->cid,0,"cid");
  386. RequestCheckUtil::checkMinValue($this->endPrice,0,"endPrice");
  387. RequestCheckUtil::checkMinValue($this->endScore,0,"endScore");
  388. RequestCheckUtil::checkMinValue($this->endVolume,0,"endVolume");
  389. RequestCheckUtil::checkNotNull($this->fields,"fields");
  390. RequestCheckUtil::checkMinValue($this->productId,0,"productId");
  391. RequestCheckUtil::checkMinValue($this->startPrice,0,"startPrice");
  392. RequestCheckUtil::checkMinValue($this->startScore,0,"startScore");
  393. RequestCheckUtil::checkMinValue($this->startVolume,0,"startVolume");
  394. }
  395. public function putOtherTextParam($key, $value) {
  396. $this->apiParas[$key] = $value;
  397. $this->$key = $value;
  398. }
  399. }