lingxingapi 1.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. lingxingapi/__init__.py +7 -0
  2. lingxingapi/ads/__init__.py +0 -0
  3. lingxingapi/ads/api.py +5946 -0
  4. lingxingapi/ads/param.py +192 -0
  5. lingxingapi/ads/route.py +134 -0
  6. lingxingapi/ads/schema.py +2615 -0
  7. lingxingapi/api.py +557 -0
  8. lingxingapi/base/__init__.py +0 -0
  9. lingxingapi/base/api.py +568 -0
  10. lingxingapi/base/param.py +59 -0
  11. lingxingapi/base/route.py +11 -0
  12. lingxingapi/base/schema.py +198 -0
  13. lingxingapi/basic/__init__.py +0 -0
  14. lingxingapi/basic/api.py +466 -0
  15. lingxingapi/basic/param.py +72 -0
  16. lingxingapi/basic/route.py +20 -0
  17. lingxingapi/basic/schema.py +218 -0
  18. lingxingapi/errors.py +152 -0
  19. lingxingapi/fba/__init__.py +0 -0
  20. lingxingapi/fba/api.py +1691 -0
  21. lingxingapi/fba/param.py +250 -0
  22. lingxingapi/fba/route.py +30 -0
  23. lingxingapi/fba/schema.py +987 -0
  24. lingxingapi/fields.py +50 -0
  25. lingxingapi/finance/__init__.py +0 -0
  26. lingxingapi/finance/api.py +3091 -0
  27. lingxingapi/finance/param.py +616 -0
  28. lingxingapi/finance/route.py +44 -0
  29. lingxingapi/finance/schema.py +1243 -0
  30. lingxingapi/product/__init__.py +0 -0
  31. lingxingapi/product/api.py +2643 -0
  32. lingxingapi/product/param.py +934 -0
  33. lingxingapi/product/route.py +49 -0
  34. lingxingapi/product/schema.py +1004 -0
  35. lingxingapi/purchase/__init__.py +0 -0
  36. lingxingapi/purchase/api.py +496 -0
  37. lingxingapi/purchase/param.py +126 -0
  38. lingxingapi/purchase/route.py +11 -0
  39. lingxingapi/purchase/schema.py +215 -0
  40. lingxingapi/sales/__init__.py +0 -0
  41. lingxingapi/sales/api.py +3200 -0
  42. lingxingapi/sales/param.py +723 -0
  43. lingxingapi/sales/route.py +70 -0
  44. lingxingapi/sales/schema.py +1718 -0
  45. lingxingapi/source/__init__.py +0 -0
  46. lingxingapi/source/api.py +1799 -0
  47. lingxingapi/source/param.py +176 -0
  48. lingxingapi/source/route.py +38 -0
  49. lingxingapi/source/schema.py +1011 -0
  50. lingxingapi/tools/__init__.py +0 -0
  51. lingxingapi/tools/api.py +291 -0
  52. lingxingapi/tools/param.py +73 -0
  53. lingxingapi/tools/route.py +8 -0
  54. lingxingapi/tools/schema.py +169 -0
  55. lingxingapi/utils.py +456 -0
  56. lingxingapi/warehourse/__init__.py +0 -0
  57. lingxingapi/warehourse/api.py +1778 -0
  58. lingxingapi/warehourse/param.py +506 -0
  59. lingxingapi/warehourse/route.py +28 -0
  60. lingxingapi/warehourse/schema.py +926 -0
  61. lingxingapi-1.1.4.dist-info/METADATA +73 -0
  62. lingxingapi-1.1.4.dist-info/RECORD +65 -0
  63. lingxingapi-1.1.4.dist-info/WHEEL +5 -0
  64. lingxingapi-1.1.4.dist-info/licenses/LICENSE +22 -0
  65. lingxingapi-1.1.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,723 @@
1
+ # -*- coding: utf-8 -*-
2
+ from typing import Optional
3
+ from pydantic import ValidationInfo, Field, field_validator
4
+ from lingxingapi import utils
5
+ from lingxingapi.base.param import Parameter, PageOffestAndLength
6
+ from lingxingapi.fields import (
7
+ NonEmptyStr,
8
+ NonNegativeInt,
9
+ NonNegativeFloat,
10
+ StrOrNone2Blank,
11
+ )
12
+
13
+
14
+ # 销售 - Listing ----------------------------------------------------------------------------------------------------------------
15
+ # . Listings
16
+ class Listings(PageOffestAndLength):
17
+ # 领星店铺ID (Seller.sid)
18
+ sids: str = Field(alias="sid")
19
+ # 搜索字段, 可选值为: 'msku', 'lsku', 'asin'
20
+ search_field: Optional[NonEmptyStr] = None
21
+ # 搜索模式 (0: 模糊搜索, 1: 精确搜索) [默认值 1]
22
+ search_mode: Optional[NonNegativeInt] = Field(None, alias="exact_search")
23
+ # 搜索值 (最多支持10个), 根据 search_field 和 search_mode 进行匹配
24
+ search_value: Optional[list] = None
25
+ # 是否已删除 (0: 未删除, 1: 已删除)
26
+ deleted: Optional[NonNegativeInt] = Field(None, alias="is_delete")
27
+ # 是否已完成领星配对 (1: 已配对, 2: 未配对)
28
+ paired: Optional[NonNegativeInt] = Field(None, alias="is_pair")
29
+ # 领星配对更新开始时间, 此参数查询要求 `paired=1`
30
+ pair_start_time: Optional[str] = Field(None, alias="pair_update_start_time")
31
+ # 领星配对更新结束时间, 此参数查询要求 `paired=1`
32
+ pair_end_time: Optional[str] = Field(None, alias="pair_update_end_time")
33
+ # 亚马逊更新开始时间
34
+ update_start_time: Optional[str] = Field(None, alias="listing_update_start_time")
35
+ # 亚马逊更新结束时间
36
+ update_end_time: Optional[str] = Field(None, alias="listing_update_end_time")
37
+ # 产品类型 (1: 普通产品, 2: 多属性产品)
38
+ product_type: Optional[NonNegativeInt] = Field(None, alias="store_type")
39
+
40
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41
+ @field_validator("sids", mode="before")
42
+ @classmethod
43
+ def _validate_sids(cls, v) -> str:
44
+ l = utils.validate_array_of_unsigned_int(v, "领星店铺ID sids")
45
+ return ",".join(map(str, l))
46
+
47
+ @field_validator("search_field", mode="before")
48
+ @classmethod
49
+ def _validate_search_field(cls, v) -> str | None:
50
+ if v is None:
51
+ return None
52
+ if v == "msku":
53
+ return "seller_sku"
54
+ if v == "lsku":
55
+ return "sku"
56
+ return v
57
+
58
+ @field_validator("search_value", mode="before")
59
+ @classmethod
60
+ def _validate_search_value(cls, v) -> list[str] | None:
61
+ if v is None:
62
+ return None
63
+ return utils.validate_array_of_non_empty_str(v, "搜索值 search_value")
64
+
65
+ @field_validator(
66
+ "pair_start_time",
67
+ "pair_end_time",
68
+ "update_start_time",
69
+ "update_end_time",
70
+ mode="before",
71
+ )
72
+ @classmethod
73
+ def _validate_update_time(cls, v, info: ValidationInfo) -> str | None:
74
+ if v is None:
75
+ return None
76
+ dt = utils.validate_datetime(v, True, "更新时间 %s" % info.field_name)
77
+ # fmt: off
78
+ return "%04d-%02d-%02d %02d:%02d:%02d" % (
79
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
80
+ )
81
+ # fmt: on
82
+
83
+
84
+ # . Edit Listing Operators
85
+ class EditListingOperator(Parameter):
86
+ # 领星店铺ID (Listing.sid)
87
+ sid: NonNegativeInt
88
+ # 商品ASIN码 (Listing.asin)
89
+ asin: NonEmptyStr
90
+ # 负责人姓名, 最多支持10个负责人, 传入 None 表示清空负责人
91
+ name: Optional[list] = Field(None, alias="principal_name")
92
+
93
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94
+ @field_validator("name", mode="before")
95
+ @classmethod
96
+ def _validate_name(cls, v) -> list[str] | None:
97
+ if v is None:
98
+ return None
99
+ return utils.validate_array_of_non_empty_str(v, "负责人名称 name")
100
+
101
+
102
+ class EditListingOperators(Parameter):
103
+ # 修改负责人参数列表
104
+ operators: list = Field(alias="sid_asin_list")
105
+
106
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
107
+ @field_validator("operators", mode="before")
108
+ @classmethod
109
+ def _validate_operators(cls, v) -> list[dict]:
110
+ if not isinstance(v, (list, tuple)):
111
+ res = [EditListingOperator.model_validate_params(v)]
112
+ else:
113
+ res = [EditListingOperator.model_validate_params(i) for i in v]
114
+ if len(res) == 0:
115
+ raise ValueError("必须提供至少一个 operator 来修改商品负责人")
116
+ return res
117
+
118
+
119
+ # . Edit Listing Prices
120
+ class EditListingPrice(Parameter):
121
+ # 领星店铺ID (Listing.sid)
122
+ sid: NonNegativeInt
123
+ # 亚马逊卖家SKU (Listing.msku)
124
+ msku: NonEmptyStr
125
+ # 商品标准价 (不包含促销, 运费, 积分) (Listing.standard_price)
126
+ standard_price: NonNegativeFloat
127
+ # 商品优惠价 (不包含运费, 积分) (Listing.sale_price)
128
+ sale_price: Optional[NonNegativeFloat]
129
+ # 商品优惠价开始时间, 格式为 "YYYY-MM-DD"
130
+ start_date: Optional[str] = None
131
+ # 商品优惠价结束时间, 格式为 "YYYY-MM-DD"
132
+ end_date: Optional[str] = None
133
+
134
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
135
+ @field_validator("end_date", "start_date", mode="before")
136
+ @classmethod
137
+ def _validate_date(cls, v, info: ValidationInfo) -> str | None:
138
+ if v is None:
139
+ return None
140
+ dt = utils.validate_datetime(v, True, "优惠价 %s" % info.field_name)
141
+ return "%04d-%02d-%02d" % (dt.year, dt.month, dt.day)
142
+
143
+
144
+ class EditListingPrices(Parameter):
145
+ # 修改商品价格参数列表
146
+ prices: list = Field(alias="pricing_params")
147
+
148
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
149
+ @field_validator("prices", mode="before")
150
+ @classmethod
151
+ def _validate_prices(cls, v) -> list[dict]:
152
+ if not isinstance(v, (list, tuple)):
153
+ res = [EditListingPrice.model_validate_params(v)]
154
+ else:
155
+ res = [EditListingPrice.model_validate_params(i) for i in v]
156
+ if len(res) == 0:
157
+ raise ValueError("必须提供至少一个 prices 来修改商品价格")
158
+ return res
159
+
160
+
161
+ # . Pair Listing Products
162
+ class PairListingProduct(Parameter):
163
+ # 亚马逊卖家SKU (Listing.msku)
164
+ msku: NonEmptyStr
165
+ # 领星本地SKU (Listing.lsku)
166
+ lsku: NonEmptyStr = Field(alias="sku")
167
+ # 是否同步Listing图片 (0 否, 1 是)
168
+ sync_pic: NonNegativeInt = Field(alias="is_sync_pic")
169
+ # 亚马逊卖家ID (Sellers.Seller.seller_id)
170
+ seller_id: Optional[NonEmptyStr] = None
171
+ # 亚马逊市场ID (Sellers.Seller.marketplace_id)
172
+ marketplace_id: Optional[NonEmptyStr] = None
173
+
174
+
175
+ class PairListingProducts(Parameter):
176
+ # 修改商品配对参数列表
177
+ pair_products: list = Field(alias="data")
178
+
179
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
180
+ @field_validator("pair_products", mode="before")
181
+ @classmethod
182
+ def _validate_pair_products(cls, v) -> list[dict]:
183
+ if not isinstance(v, (list, tuple)):
184
+ res = [PairListingProduct.model_validate_params(v)]
185
+ else:
186
+ res = [PairListingProduct.model_validate_params(i) for i in v]
187
+ if len(res) == 0:
188
+ raise ValueError("必须提供至少一个 pair_product 来修改领星商品配对")
189
+ return res
190
+
191
+
192
+ # . Unpair Listing Products
193
+ class UnpairListingProduct(Parameter):
194
+ # 领星店铺ID (Listing.sid)
195
+ sid: NonNegativeInt = Field(alias="storeId")
196
+ # 亚马逊卖家SKU (Listing.msku)
197
+ msku: NonEmptyStr
198
+
199
+
200
+ class UnpairListingProducts(Parameter):
201
+ # 删除商品配对参数列表
202
+ unpair_products: list = Field(alias="list")
203
+
204
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
205
+ @field_validator("unpair_products", mode="before")
206
+ @classmethod
207
+ def _validate_unpair_products(cls, v) -> list[dict]:
208
+ if not isinstance(v, (list, tuple)):
209
+ res = [UnpairListingProduct.model_validate_params(v)]
210
+ else:
211
+ res = [UnpairListingProduct.model_validate_params(i) for i in v]
212
+ if len(res) == 0:
213
+ raise ValueError("必须提供至少一个 product_unpair 来删除领星商品配对")
214
+ return res
215
+
216
+
217
+ # . Listing Global Tags
218
+ class ListingGlobalTags(PageOffestAndLength):
219
+ # 搜索类型, 支持 "tag_name"
220
+ search_field: Optional[NonEmptyStr] = None
221
+ # 搜索值, 仅支持字符串作为检索值
222
+ search_value: Optional[NonEmptyStr] = None
223
+
224
+
225
+ # . Create Listing Global Tag
226
+ class CreateListingGlobalTag(Parameter):
227
+ # 领星标签名称 (ListingGlobalTag.tag_name)
228
+ tag_name: NonEmptyStr
229
+
230
+
231
+ # . Remove Listing Global Tag
232
+ class RemoveListingGlobalTag(Parameter):
233
+ # 领星标签IDs, 最多支持 200 个 (ListingGlobalTag.tag_id)
234
+ tag_ids: list[NonEmptyStr]
235
+
236
+
237
+ # . Listing Tags
238
+ class ListingTags(Parameter):
239
+ # 领星店铺ID (Listing.sid)
240
+ sid: NonNegativeInt
241
+ # 亚马逊卖家SKU (Listing.msku)
242
+ msku: NonEmptyStr = Field(alias="relation_id")
243
+
244
+
245
+ class ListingTagsMskus(Parameter):
246
+ # 查询Listing标签参数列表
247
+ mskus: list = Field(alias="bind_detail")
248
+
249
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
250
+ @field_validator("mskus", mode="before")
251
+ @classmethod
252
+ def _validate_mskus(cls, v) -> list[dict]:
253
+ if not isinstance(v, (list, tuple)):
254
+ res = [ListingTags.model_validate_params(v)]
255
+ else:
256
+ res = [ListingTags.model_validate_params(i) for i in v]
257
+ if len(res) == 0:
258
+ raise ValueError("必须提供至少一个 msku 来查询 Listing 的关联标签信息")
259
+ return res
260
+
261
+
262
+ # . Edit Listing Tags
263
+ class EditListingTag(Parameter):
264
+ # 领星店铺ID (Listing.sid)
265
+ sid: NonNegativeInt
266
+ # 亚马逊卖家SKU (Listing.msku)
267
+ msku: NonEmptyStr = Field(alias="relationId")
268
+
269
+
270
+ class SetListingTag(Parameter):
271
+ # 领星标签ID列表 (ListingTag.tag_id)
272
+ tag_ids: list = Field(alias="tagIds")
273
+ # 亚马逊卖家SKU列表
274
+ mskus: list = Field(alias="bindDetail")
275
+
276
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
277
+ @field_validator("tag_ids", mode="before")
278
+ @classmethod
279
+ def _validate_tag_ids(cls, v) -> list[str]:
280
+ return utils.validate_array_of_non_empty_str(v, "领星标签ID列表 tag_ids")
281
+
282
+ @field_validator("mskus", mode="before")
283
+ @classmethod
284
+ def _validate_mskus(cls, v) -> list[dict]:
285
+ if not isinstance(v, (list, tuple)):
286
+ res = [EditListingTag.model_validate_params(v)]
287
+ else:
288
+ res = [EditListingTag.model_validate_params(i) for i in v]
289
+ if len(res) == 0:
290
+ raise ValueError("必须提供至少一个 msku 来新增 Listing 标签")
291
+ return res
292
+
293
+
294
+ class UnsetListingTag(Parameter):
295
+ # 领星标签ID列表 (ListingTag.tag_id)
296
+ tag_ids: list = Field(alias="globalTagIds")
297
+ # 亚马逊卖家SKU列表
298
+ mskus: list = Field(alias="bindDetail")
299
+
300
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
301
+ @field_validator("tag_ids", mode="before")
302
+ @classmethod
303
+ def _validate_tag_ids(cls, v) -> list[str]:
304
+ return utils.validate_array_of_non_empty_str(v, "领星标签ID列表 tag_ids")
305
+
306
+ @field_validator("mskus", mode="before")
307
+ @classmethod
308
+ def _validate_mskus(cls, v) -> list[dict]:
309
+ if not isinstance(v, (list, tuple)):
310
+ res = [EditListingTag.model_validate_params(v)]
311
+ else:
312
+ res = [EditListingTag.model_validate_params(i) for i in v]
313
+ if len(res) == 0:
314
+ raise ValueError("必须提供至少一个 msku 来删除 Listing 标签")
315
+ return res
316
+
317
+
318
+ # . Listing FBA Fees
319
+ class ListingFbaFees(Parameter):
320
+ # 领星店铺ID (Listing.sid)
321
+ sid: NonNegativeInt
322
+ # 亚马逊卖家SKU (Listing.msku)
323
+ msku: NonEmptyStr
324
+
325
+
326
+ class ListingFbaFeesMskus(Parameter):
327
+ # 查询预估 FBA 费用参数列表
328
+ mskus: list = Field(alias="data")
329
+
330
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
331
+ @field_validator("mskus", mode="before")
332
+ @classmethod
333
+ def _validate_mskus(cls, v) -> list[dict]:
334
+ if not isinstance(v, (list, tuple)):
335
+ res = [ListingFbaFees.model_validate_params(v)]
336
+ else:
337
+ res = [ListingFbaFees.model_validate_params(i) for i in v]
338
+ if len(res) == 0:
339
+ raise ValueError("必须提供至少一个 msku 来查询预估FBA费用")
340
+ return res
341
+
342
+
343
+ # . Edit Listing FBM
344
+ class EditListingFbm(Parameter):
345
+ # 领星店铺ID (Listing.sid)
346
+ sid: NonNegativeInt = Field(alias="storeId")
347
+ # 亚马逊卖家SKU (Listing.msku)
348
+ msku: NonEmptyStr
349
+ # FBM库存数量
350
+ qty: NonNegativeInt = Field(alias="fbmInventory")
351
+ # 发货/处理天数
352
+ ship_days: Optional[NonNegativeInt] = Field(None, alias="shipDays")
353
+
354
+
355
+ class EditListingFbms(Parameter):
356
+ # 更新 FBM 库存参数列表
357
+ mskus: list = Field(alias="fbmInventoryList")
358
+
359
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
360
+ @field_validator("mskus", mode="before")
361
+ @classmethod
362
+ def _validate_mskus(cls, v) -> list[dict]:
363
+ if not isinstance(v, (list, tuple)):
364
+ res = [EditListingFbm.model_validate_params(v)]
365
+ else:
366
+ res = [EditListingFbm.model_validate_params(i) for i in v]
367
+ if len(res) == 0:
368
+ raise ValueError("必须提供至少一个 msku 来更新 FBM 库存")
369
+ return res
370
+
371
+
372
+ # . Listing Operate Logs
373
+ class ListingOperationLogs(PageOffestAndLength):
374
+ # 领星店铺ID (Listing.sid)
375
+ sid: NonNegativeInt
376
+ # 亚马逊卖家SKU (Listing.msku)
377
+ msku: NonEmptyStr
378
+ # 操作用户ID列表 (Account.user_id)
379
+ operator_ids: Optional[list] = Field(None, alias="operate_uid")
380
+ # 操作类型列表 (1: 调价, 2: 调库存, 3: 修改标题, 4: 编辑商品, 5: B2B调价)
381
+ operation_types: Optional[list] = Field(None, alias="operate_type")
382
+ # 操作时间开始, 格式为 "YYYY-MM-DD HH:MM:SS"
383
+ start_time: Optional[str] = Field(None, alias="operate_time_start")
384
+ # 操作时间结束, 格式为 "YYYY-MM-DD HH:MM:SS"
385
+ end_time: Optional[str] = Field(None, alias="operate_time_end")
386
+
387
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
388
+ @field_validator("operator_ids", mode="before")
389
+ @classmethod
390
+ def _validate_operator_ids(cls, v) -> list[str] | None:
391
+ if v is None:
392
+ return None
393
+ return utils.validate_array_of_non_empty_str(v, "操作用户ID operator_ids")
394
+
395
+ @field_validator("operation_types", mode="before")
396
+ @classmethod
397
+ def _validate_operation_types(cls, v) -> list[int] | None:
398
+ if v is None:
399
+ return None
400
+ return utils.validate_array_of_unsigned_int(v, "操作类型 operation_types")
401
+
402
+ @field_validator("start_time", "end_time", mode="before")
403
+ @classmethod
404
+ def _validate_time(cls, v, info: ValidationInfo) -> str | None:
405
+ if v is None:
406
+ return None
407
+ dt = utils.validate_datetime(v, True, "操作时间 %s" % info.field_name)
408
+ # fmt: off
409
+ return "%04d-%02d-%02d %02d:%02d:%02d" % (
410
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second
411
+ )
412
+ # fmt: on
413
+
414
+
415
+ # 销售 - 平台订单 ----------------------------------------------------------------------------------------------------------------
416
+ # . Orders
417
+ class Orders(PageOffestAndLength):
418
+ # 查询开始时间, 格式为 "YYYY-MM-DD HH:MM:SS"
419
+ start_time: str = Field(alias="start_date")
420
+ # 查询结束时间, 格式为 "YYYY-MM-DD HH:MM:SS"
421
+ end_time: str = Field(alias="end_date")
422
+ # 查询时间类型 (1: 订购时间[站点时间], 2: 订单修改时间[北京时间], 3: 平台更新时间[UTC时间], 4: 发货时间[站点时间]) [默认值 1]
423
+ time_type: Optional[NonNegativeInt] = Field(None, alias="date_type")
424
+ # 是否按时间排序 (0: 否, 1: 降序, 2: 升序) [默认值 0]
425
+ time_sort: Optional[NonNegativeInt] = Field(None, alias="sort_desc_by_date_type")
426
+ # 领星店铺ID列表 (Order.sid)
427
+ sids: Optional[list] = Field(None, alias="sid_list")
428
+ # 配送方式 (1: AFN, 2: MFN) (Order.fulfillment_channel)
429
+ fulfillment_channel: Optional[NonNegativeInt] = None
430
+ # 订单状态列表 ("Pending", "Unshipped", "PartiallyShipped", "Shipped", "Canceled") (Order.order_status)
431
+ order_status: Optional[list]
432
+
433
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
434
+ @field_validator("start_time", "end_time", mode="before")
435
+ @classmethod
436
+ def _validate_time(cls, v, info: ValidationInfo) -> str:
437
+ dt = utils.validate_datetime(v, True, "查询日期 %s" % info.field_name)
438
+ # fmt: off
439
+ return "%04d-%02d-%02d %02d:%02d:%02d" % (
440
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second
441
+ )
442
+ # fmt: on
443
+
444
+ @field_validator("sids", mode="before")
445
+ @classmethod
446
+ def _validate_sids(cls, v) -> list[int] | None:
447
+ if v is None:
448
+ return None
449
+ return utils.validate_array_of_unsigned_int(v, "领星店铺ID sid")
450
+
451
+ @field_validator("order_status", mode="before")
452
+ @classmethod
453
+ def _validate_order_status(cls, v) -> list[str] | None:
454
+ if v is None:
455
+ return None
456
+ return utils.validate_array_of_non_empty_str(v, "订单状态 order_status")
457
+
458
+
459
+ # . Edit Order Note
460
+ class EditOrderNote(Parameter):
461
+ # 领星店铺ID (Order.sid)
462
+ sid: NonNegativeInt
463
+ # 亚马逊订单ID (Order.amazon_order_id)
464
+ amazon_order_id: NonEmptyStr = Field(alias="amazonOrderId")
465
+ # 备注内容
466
+ note: StrOrNone2Blank = Field(alias="remark")
467
+
468
+
469
+ # . Order Details
470
+ class OrderDetails(Parameter):
471
+ # 亚马逊订单ID列表 (Order.amazon_order_id)
472
+ amazon_order_ids: str = Field(alias="order_id")
473
+
474
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
475
+ @field_validator("amazon_order_ids", mode="before")
476
+ @classmethod
477
+ def _validate_amazon_order_ids(cls, v) -> str:
478
+ ids = utils.validate_array_of_non_empty_str(
479
+ v, "亚马逊订单ID列表 amazon_order_ids"
480
+ )
481
+ return ",".join(ids)
482
+
483
+
484
+ # . After-Sales Orders
485
+ class AfterSalesOrder(PageOffestAndLength):
486
+ # 查询开始日期, 左闭右开, 格式为 "YYYY-MM-DD"
487
+ start_date: str
488
+ # 查询结束日期, 左闭右开, 格式为 "YYYY-MM-DD"
489
+ end_date: str
490
+ # 查询日期类型 (1: 售后时间, 2: 订购时间, 3: 更新时间) [默认值: 1]
491
+ date_type: Optional[NonNegativeInt] = None
492
+ # 售后类型 (1: 退款, 2: 退货, 3: 换货) [默认查询所有类型]
493
+ service_type: Optional[str] = Field(None, alias="after_type")
494
+ # 领星店铺ID列表 (Order.sid)
495
+ sids: Optional[str] = Field(None, alias="sid")
496
+ # 亚马逊订单ID列表, 最多支持 50 个 (Order.amazon_order_id)
497
+ amazon_order_ids: Optional[list] = Field(None, alias="amazon_order_id_list")
498
+
499
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
500
+ @field_validator("start_date", "end_date", mode="before")
501
+ @classmethod
502
+ def _validate_date(cls, v, info: ValidationInfo) -> str:
503
+ dt = utils.validate_datetime(v, True, "查询日期 %s" % info.field_name)
504
+ return "%04d-%02d-%02d" % (dt.year, dt.month, dt.day)
505
+
506
+ @field_validator("service_type", mode="before")
507
+ @classmethod
508
+ def _validate_service_type(cls, v) -> str | None:
509
+ if v is None:
510
+ return None
511
+ l = utils.validate_array_of_unsigned_int(v, "售后类型 service_type")
512
+ return ",".join(map(str, l))
513
+
514
+ @field_validator("sids", mode="before")
515
+ @classmethod
516
+ def _validate_sids(cls, v) -> str | None:
517
+ if v is None:
518
+ return None
519
+ ids = utils.validate_array_of_unsigned_int(v, "店铺ID列表 sids")
520
+ return ",".join(map(str, ids))
521
+
522
+ @field_validator("amazon_order_ids", mode="before")
523
+ @classmethod
524
+ def _validate_amazon_order_ids(cls, v) -> list[str] | None:
525
+ if v is None:
526
+ return None
527
+ return utils.validate_array_of_non_empty_str(
528
+ v, "亚马逊订单ID列表 amazon_order_ids"
529
+ )
530
+
531
+
532
+ # . MCF Orders
533
+ class McfOrders(Parameter):
534
+ # 领星店铺ID列表 (Order.sid)
535
+ sids: Optional[list] = None
536
+ # 查询开始时间 (不传默认最近6个月)
537
+ start_date: Optional[str] = None
538
+ # 查询结束时间 (不传默认最近6个月)
539
+ end_date: Optional[str] = None
540
+ # 查询时期类型 (1: 订购时间[站点时间], 2: 订单修改时间[北京时间]) [默认值: 1]
541
+ date_type: Optional[NonNegativeInt] = None
542
+ # 分页偏移量
543
+ offset: NonNegativeInt
544
+ # 分页长度 [最大值 1000]
545
+ length: NonNegativeInt
546
+
547
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
548
+ @field_validator("sids", mode="before")
549
+ @classmethod
550
+ def _validate_sids(cls, v) -> list[int] | None:
551
+ if v is None:
552
+ return None
553
+ return utils.validate_array_of_unsigned_int(v, "领星店铺ID sids")
554
+
555
+ @field_validator("start_date", "end_date", mode="before")
556
+ @classmethod
557
+ def _validate_date(cls, v, info: ValidationInfo) -> str | None:
558
+ if v is None:
559
+ return None
560
+ dt = utils.validate_datetime(v, True, "查询日期 %s" % info.field_name)
561
+ return "%04d-%02d-%02d" % (dt.year, dt.month, dt.day)
562
+
563
+
564
+ # . MCF Fulfillment Order IDs
565
+ class McfFulfillmentOrderId(Parameter):
566
+ # 领星店铺ID (McfOrder.sid)
567
+ sid: NonNegativeInt
568
+ # 多渠道订单配送ID (McfOrder.fulfillment_order_id)
569
+ fulfillment_order_id: NonEmptyStr = Field(alias="seller_fulfillment_order_id")
570
+
571
+
572
+ class McfFulfillmentOrderIds(Parameter):
573
+ # 订单ID参数列表
574
+ fulfillment_order_ids: list = Field(alias="order_info")
575
+
576
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
577
+ @field_validator("fulfillment_order_ids", mode="before")
578
+ @classmethod
579
+ def _validate_fulfillment_order_ids(cls, v) -> list[dict]:
580
+ if not isinstance(v, (list, tuple)):
581
+ res = [McfFulfillmentOrderId.model_validate_params(v)]
582
+ else:
583
+ res = [McfFulfillmentOrderId.model_validate_params(i) for i in v]
584
+ if len(res) == 0:
585
+ raise ValueError(
586
+ "必须提供至少一个 fulfillment_order_id 来查询多渠道配送的商品信息"
587
+ )
588
+ return res
589
+
590
+
591
+ # . MCF Order Transactions
592
+ class McfOrderTransaction(Parameter):
593
+ # 领星店铺ID (McfOrder.sid)
594
+ sid: NonNegativeInt
595
+ # 多渠道亚马逊订单ID (McfOrder.amazon_order_id)
596
+ amazon_order_id: NonEmptyStr = Field(alias="amazonOrderId")
597
+
598
+
599
+ # 销售 - 自发货管理 --------------------------------------------------------------------------------------------------------------
600
+ # . FBM Orders
601
+ class FbmOrders(Parameter):
602
+ # 领星店铺ID列表 (Order.sid)
603
+ sids: str = Field(alias="sid")
604
+ # 订购开始时间, 格式为 "YYYY-MM-DD HH:MM:SS"
605
+ purchase_start_time: Optional[str] = Field(None, alias="start_time")
606
+ # 订购结束时间, 格式为 "YYYY-MM-DD HH:MM:
607
+ purchase_end_time: Optional[str] = Field(None, alias="end_time")
608
+ # 订单状态 (1: 同步中, 2: 已发货, 3: 未付款, 4: 待审核, 5: 待发货, 6: 不发货)
609
+ order_status: Optional[str] = None
610
+ # 分页页码 [默认值 1]
611
+ page: Optional[NonNegativeInt] = None
612
+ # 分页长度 [默认值 100]
613
+ length: Optional[NonNegativeInt] = None
614
+
615
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
616
+ @field_validator("sids", mode="before")
617
+ @classmethod
618
+ def _validate_sids(cls, v) -> str:
619
+ l = utils.validate_array_of_unsigned_int(v, "领星店铺ID sids")
620
+ return ",".join(map(str, l))
621
+
622
+ @field_validator("purchase_start_time", "purchase_end_time", mode="before")
623
+ @classmethod
624
+ def _validate_time(cls, v, info: ValidationInfo) -> str | None:
625
+ if v is None:
626
+ return None
627
+ dt = utils.validate_datetime(v, True, "订购时间 %s" % info.field_name)
628
+ # fmt: off
629
+ return "%04d-%02d-%02d %02d:%02d:%02d" % (
630
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second
631
+ )
632
+ # fmt: on
633
+
634
+ @field_validator("order_status", mode="before")
635
+ @classmethod
636
+ def _validate_order_status(cls, v) -> str | None:
637
+ if v is None:
638
+ return None
639
+ l = utils.validate_array_of_unsigned_int(v, "订单状态 order_status")
640
+ return ",".join(map(str, l))
641
+
642
+
643
+ # . FBM Order Detail
644
+ class FbmOrderDetail(Parameter):
645
+ # 自发货订单号 (FbmOrder.order_number)
646
+ order_number: NonEmptyStr
647
+
648
+
649
+ # 销售 - 促销管理 ----------------------------------------------------------------------------------------------------------------
650
+ # . Promotions
651
+ class Promotions(PageOffestAndLength):
652
+ # 领星店铺ID列表 (Seller.sid)
653
+ sids: Optional[list] = None
654
+ # 优惠券开始日期, 时间间隔长度不超过90天, 格式为 "YYYY-MM-DD"
655
+ start_date: Optional[str] = None
656
+ # 优惠券结束日期, 时间间隔长度不超过90天, 格式为 "YYYY-MM-DD"
657
+ end_date: Optional[str] = None
658
+
659
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
660
+ @field_validator("sids", mode="before")
661
+ @classmethod
662
+ def _validate_sids(cls, v) -> list[int] | None:
663
+ if v is None:
664
+ return None
665
+ return utils.validate_array_of_unsigned_int(v, "领星店铺ID sids")
666
+
667
+ @field_validator("start_date", "end_date", mode="before")
668
+ @classmethod
669
+ def _validate_date(cls, v, info: ValidationInfo) -> str | None:
670
+ if v is None:
671
+ return None
672
+ dt = utils.validate_datetime(v, True, "优惠券日期 %s" % info.field_name)
673
+ return "%04d-%02d-%02d" % (dt.year, dt.month, dt.day)
674
+
675
+
676
+ # . Promotion On Listings
677
+ class PromotionOnListings(PageOffestAndLength):
678
+ # 站点日期, 格式为 "YYYY-MM-DD"
679
+ site_date: str
680
+ # 促销开始日期, 格式为 "YYYY-MM-DD"
681
+ start_date: Optional[str] = Field(None, alias="start_time")
682
+ # 促销结束日期, 格式为 "YYYY-MM-DD"
683
+ end_date: Optional[str] = Field(None, alias="end_time")
684
+ # 领星店铺ID列表 (Seller.sid)
685
+ sids: Optional[list] = None
686
+ # 促销类型 (1: 优惠券, 2: Deal, 3 活动, 4 价格折扣)
687
+ promotion_type: Optional[list] = Field(None, alias="promotion_category")
688
+ # 促销状态 (0: 其他, 1: 进行中, 2: 已过期, 3: 未开始)
689
+ promotion_status: Optional[list] = Field(None, alias="status")
690
+ # 商品状态 (-1: 已删除, 0: 停售, 1: 在售)
691
+ product_status: Optional[list] = None
692
+ # 是否叠加优惠券 (0: 否, 1: 是)
693
+ is_coupon_stacked: Optional[NonNegativeInt] = Field(None, alias="is_overlay")
694
+
695
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
696
+ @field_validator("site_date", "start_date", "end_date", mode="before")
697
+ @classmethod
698
+ def _validate_date(cls, v, info: ValidationInfo) -> str | None:
699
+ if v is None:
700
+ return None
701
+ dt = utils.validate_datetime(v, True, "促销日期 %s" % info.field_name)
702
+ return "%04d-%02d-%02d" % (dt.year, dt.month, dt.day)
703
+
704
+ @field_validator("sids", mode="before")
705
+ @classmethod
706
+ def _validate_sids(cls, v) -> list[int] | None:
707
+ if v is None:
708
+ return None
709
+ return utils.validate_array_of_unsigned_int(v, "领星店铺ID sids")
710
+
711
+ @field_validator("promotion_type", "promotion_status", mode="before")
712
+ @classmethod
713
+ def _validate_promotion_type(cls, v, info: ValidationInfo) -> list[int] | None:
714
+ if v is None:
715
+ return None
716
+ return utils.validate_array_of_unsigned_int(v, "促销 %s" % info.field_name)
717
+
718
+ @field_validator("product_status", mode="before")
719
+ @classmethod
720
+ def _validate_product_status(cls, v) -> list[int] | None:
721
+ if v is None:
722
+ return None
723
+ return utils.validate_array_of_int(v, "商品状态 product_status")