ey-commerce-lib 1.0.0__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.

Potentially problematic release.


This version of ey-commerce-lib might be problematic. Click here for more details.

@@ -0,0 +1,273 @@
1
+ from typing import TypedDict, Optional
2
+ from urllib.parse import urlencode
3
+
4
+ from ey_commerce_lib.utils.str import to_camel
5
+ from pydantic import BaseModel, ConfigDict
6
+
7
+
8
+ class DxmOrderSearchForm(BaseModel):
9
+ """
10
+ /package/advancedSearch.htm
11
+ 店小秘订单搜索接口参数约束
12
+ """
13
+ # 搜索类型(orderId订单号, packageNum包裹号)
14
+ search_types: str = 'orderId'
15
+ # 搜索内容
16
+ contents: str = ''
17
+ order_adv_search_type: str = '1'
18
+ # 订单状态
19
+ state: str = ''
20
+ is_voided: str = '-1'
21
+ is_removed: str = '-1'
22
+ commit_platforms: str = ''
23
+ # 是否为海外仓-1代表全部,1是0否
24
+ is_oversea: str = '-1'
25
+ # 店铺id
26
+ shop_id: str = '-1'
27
+ # 平台
28
+ platform: str = ''
29
+ # 历史订单(空字符串就是代表没有, all 代表历史记录)
30
+ history: str = ''
31
+ # 排序方式
32
+ order_field: str = 'order_create_time'
33
+ is_desc: str = '1'
34
+ time_out: str = '0'
35
+ warehouse_code: str = ''
36
+ # 订单标记绿色
37
+ is_green: str = '0'
38
+ # 订单标记黄色
39
+ is_yellow: str = '0'
40
+ # 订单标记橙色
41
+ is_orange: str = '0'
42
+ # 订单标记红色
43
+ is_red: str = '0'
44
+ # 订单标记紫色
45
+ is_violet: str = '0'
46
+ # 订单标记蓝色
47
+ is_blue: str = '0'
48
+ # 订单标记青色
49
+ corn_flower_blue: str = '0'
50
+ # 订单标记粉色
51
+ pink: str = '0'
52
+ teal: str = '0'
53
+ turquoise: str = '0'
54
+ unmarked: str = '0'
55
+ forbidden_status: str = '-1'
56
+ forbidden_reason: str = '0'
57
+ picking_instructions: str = ''
58
+ # 订单金额起始
59
+ price_start: str = ''
60
+ # 订单金额结束
61
+ price_end: str = ''
62
+ # 下单时间
63
+ order_create_start: str = ''
64
+ order_create_end: str = ''
65
+ # 付款时间
66
+ order_pay_start: str = ''
67
+ order_pay_end: str = ''
68
+ # 发货时间
69
+ shipped_start: str = ''
70
+ shipped_end: str = ''
71
+ # 退款时间
72
+ refunded_start: str = ''
73
+ refunded_end: str = ''
74
+ # 面单打印时间
75
+ md_sign_start: str = ''
76
+ md_sign_end: str = ''
77
+ # 拣货单打印时间
78
+ jh_sign_start: str = ''
79
+ jh_sign_end: str = ''
80
+ # 剩余发货
81
+ time_out_query: str = '-1'
82
+ # 包裹类型
83
+ product_status: str = ''
84
+ # 订单商品数量
85
+ product_count_start: str = ''
86
+ product_count_end: str = ''
87
+ # 发货仓库, 多个仓库用逗号隔开
88
+ storage_ids: str = ''
89
+ storage_id: str = '0'
90
+ auth_id: str = '-1'
91
+ days: str = '-1'
92
+ # 国家区域
93
+ country: str = ''
94
+ # 拣货单打印(-1全部,1已打拣货单,2未打拣货单)
95
+ is_print_jh: str = '-1'
96
+ # 优先分配库存(-1全部,1是,2否)
97
+ sign_prior_ship: str = '-1'
98
+ # 面单打印(-1全部,1是,2否)
99
+ is_print_md: str = '-1'
100
+ # 提交单号(uncommit)
101
+ commit_platform: str = ''
102
+ # 买家留言(-1全部,1有留言,0没有留言)
103
+ is_has_order_message: str = '-1'
104
+ # 买家备注(-1全部,1有备注,0没有备注)
105
+ is_has_order_comment: str = '-1'
106
+ # 客服备注(-1全部,1有备注,0没有备注)
107
+ is_has_service_comment: str = '-1'
108
+ # 拣货备注(-1全部,1有备注,0没有备注)
109
+ is_has_pick_comment: str = '-1'
110
+
111
+ # 合并订单(1代表勾选)
112
+ is_merge: str = ''
113
+ # 拆分订单(1代表勾选)
114
+ is_split: str = ''
115
+ # 重发包裹(1代表勾选)
116
+ is_re_ship: str = ''
117
+ # 有退款
118
+ is_refund: str = ''
119
+ # 禁止处理(1代表勾选)
120
+ sign_ban_ship: str = ''
121
+ # 黑名单
122
+ black_list: str = ''
123
+ # 平台标识
124
+ global_collection: str = '-1'
125
+ # 分页
126
+ page_no: int = 1
127
+ page_size: int = 30
128
+
129
+ model_config = ConfigDict(
130
+ alias_generator=to_camel,
131
+ populate_by_name=True # 对应旧版的 allow_population_by_field_name
132
+ )
133
+
134
+
135
+ class DxmJsonResponse(TypedDict):
136
+ """
137
+ 店小秘一般json返回响应
138
+ """
139
+ code: int
140
+ msg: str
141
+
142
+
143
+ class DxmProcessMsg(TypedDict):
144
+ code: int
145
+ msg: str
146
+ data: Optional[dict]
147
+ num: int
148
+ totalNum: int
149
+ createDate: int
150
+
151
+
152
+ class DxmCheckProcessResponse(TypedDict):
153
+ """
154
+ 店小秘检测进度返回参数类型
155
+ """
156
+ processMsg: DxmProcessMsg
157
+
158
+
159
+ class DxmOrderRuleCond(BaseModel):
160
+ """
161
+ 店小秘订单规则参数项基类
162
+ """
163
+ # 条件值
164
+ cond_val: str
165
+ # 条件id
166
+ cond_id: str
167
+ # 条件名称
168
+ cond_name: str
169
+ # 条件单位
170
+ cond_unit: str = ''
171
+ # 条件类型
172
+ cond_type: str = '1'
173
+
174
+
175
+ class DxmOrderRule(BaseModel):
176
+ """
177
+ 店小秘订单规则参数基类
178
+ """
179
+ # 规则id
180
+ id: str
181
+ # 规则类型(1:审单规则,2:物流规则)
182
+ type: str
183
+ # 规则名称
184
+ rule_name: str
185
+ # 客服备注
186
+ kfbz: str = ''
187
+ # 拣货备足
188
+ jhbz: str = ''
189
+ # 拣货颜色
190
+ jh_color: str = ''
191
+ # 自定义备注
192
+ custom_mark: str = ''
193
+ # 附加规则(on勾选, ''未勾选)
194
+ other_action: str = ''
195
+ has_other_action: str = ''
196
+ # 条件列表
197
+ dxm_cond_list: list[DxmOrderRuleCond]
198
+
199
+ def to_update_rule_data_before(self):
200
+ data = list()
201
+ data.append(('id', self.id))
202
+ data.append(('type', self.type))
203
+ data.append(('ruleName', self.rule_name))
204
+ # 装填规则内容
205
+ for cond in self.dxm_cond_list:
206
+ data.append(('condVal', cond.cond_val))
207
+ data.append(('condId', cond.cond_id))
208
+ data.append(('condName', cond.cond_name))
209
+ data.append(('condUnit', cond.cond_unit))
210
+ data.append(('condType', cond.cond_type))
211
+ # 装填conditionId
212
+ for cond in self.dxm_cond_list:
213
+ data.append(('conditionId', cond.cond_id))
214
+ return data
215
+
216
+ def to_update_rule_data_after(self):
217
+ data = list()
218
+ data.append(('otherAction', self.other_action))
219
+ data.append(('kfbz', self.kfbz))
220
+ data.append(('jhbz', self.jhbz))
221
+ data.append(('hasOtherAction', self.has_other_action))
222
+ data.append(('customMark', self.custom_mark))
223
+ data.append(('jhColor', self.jh_color))
224
+ return data
225
+
226
+ def to_update_rule_data(self):
227
+ """
228
+ 转换成更新物流规则的参数数据,由子类实现
229
+ :return:
230
+ """
231
+ pass
232
+
233
+
234
+ class DxmOrderReviewRule(DxmOrderRule):
235
+ """
236
+ 店小秘审单规则参数
237
+ """
238
+ # 流程规则(paid: 待审核, approved: 待处理)
239
+ action: str = 'paid'
240
+
241
+ def to_update_rule_data(self):
242
+ """
243
+ 转换成更新物流规则的参数数据
244
+ :return:
245
+ """
246
+ data = super().to_update_rule_data_before()
247
+ # 装填其他参数
248
+ data.append(('action', self.action))
249
+ data.extend(super().to_update_rule_data_after())
250
+ return urlencode(data, encoding="utf-8")
251
+
252
+
253
+ class DxmOrderLogisticsRule(DxmOrderRule):
254
+ """
255
+ 店小秘订单物流规则参数
256
+ """
257
+ ware_id: str
258
+ # 物流方式id(物流规则使用, 必须要是distribute_type为0)
259
+ auth_id: str
260
+ # 分配方式(0:仅指定一个物流,1:指定多个物流)
261
+ distribute_type: str
262
+ # 物流方式ids(物流规则使用, 多个用逗号隔开, 必须要是distribute_type为1)
263
+ auth_ids: str
264
+
265
+ def to_update_rule_data(self):
266
+ data = super().to_update_rule_data_before()
267
+ # 装填其他参数
268
+ data.append(('wareId', self.ware_id))
269
+ data.append(('distributeType', self.distribute_type))
270
+ data.append(('authId', self.auth_id))
271
+ data.append(('authIds', self.auth_ids))
272
+ data.extend(super().to_update_rule_data_after())
273
+ return urlencode(data, encoding="utf-8")
@@ -0,0 +1,161 @@
1
+ from typing import Optional
2
+
3
+ from ey_commerce_lib.utils.str import to_camel
4
+ from pydantic import BaseModel, ConfigDict
5
+
6
+
7
+ class WarehouseProductQuery(BaseModel):
8
+ refresh_flag: str = ''
9
+ # 8(全部区)6(次品区)0(拣货区)
10
+ zone_type: int = 0
11
+ # 页码
12
+ page_no: int = 1
13
+ # 每页条数
14
+ page_size: int = 100
15
+ # 搜索类型1(商品sku)4(商品编码)2(商品名称)3(货架位)4(识别码)
16
+ search_type: int = 1
17
+ # 搜索内容
18
+ search_value: str = ''
19
+ # 匹配方式1(精确匹配)0(模糊匹配)2(完全匹配)
20
+ product_search_type: int = 1
21
+ # 仓库id
22
+ warehouse_id: str = '7167025'
23
+ is_transit: str = ''
24
+ # 筛选排序 1(按照创建时间)2(按更新时间)3(按sku)4(按库存总量)5(按单价)6(按采购在途)7(按总价)8(按货架位)9(按可用库存)10(按未发)
25
+ order_by: str = '1'
26
+ # 排序方式 1(降序)0(升序)
27
+ order_by_val: str = '1'
28
+ # 分类路径用-分隔最后以-结尾 例如1379550-1379554-1379559-
29
+ full_cid: str = ''
30
+ # 类型 全部('')单个sku(0)组合sku(1)加工sku(2)
31
+ group_or_not: str = ''
32
+ # 商品单价开始
33
+ price_min: str = ''
34
+ # 商品单价结束
35
+ price_max: str = ''
36
+ # 总库存起始
37
+ stock_min: str = ''
38
+ # 总库存结束
39
+ stock_max: str = ''
40
+ # 可用库存起始
41
+ available_min: str = ''
42
+ # 可用库存结束
43
+ available_max: str = ''
44
+ # 安全库存开始
45
+ safe_min: str = ''
46
+ # 安全库存结束
47
+ safe_max: str = ''
48
+ # 采购在途开始
49
+ on_pass_min: str = ''
50
+ # 采购在途结束
51
+ on_pass_max: str = ''
52
+ # 预售数量起始
53
+ lock_min: str = ''
54
+ # 预售数量结束
55
+ lock_max: str = ''
56
+ # 未发数量起始
57
+ un_billed_order_min: str = ''
58
+ # 未发数量结束
59
+ un_billed_order_max: str = ''
60
+ # 仓库商品状态 -1(全部)0(在售)1(热销)2(新品)3(清仓)4(停售)5(滞销)
61
+ product_status: str = '-1'
62
+
63
+ model_config = ConfigDict(
64
+ alias_generator=to_camel,
65
+ populate_by_name=True # 对应旧版的 allow_population_by_field_name
66
+ )
67
+
68
+
69
+ class WarehouseProduct(BaseModel):
70
+ sku: str
71
+ name: Optional[str] = None
72
+ sku_code: str
73
+ shelf_position: str
74
+ # 安全库存
75
+ safe_stock: Optional[int] = None
76
+ # 在途库存
77
+ on_the_way_stock: Optional[int] = None
78
+ # 未发库存
79
+ not_shipped_stock: Optional[int] = None
80
+ # 占用库存
81
+ occupy_stock: Optional[int] = None
82
+ # 可用库存
83
+ available_stock: Optional[int] = None
84
+ # 总库存
85
+ total_stock: Optional[int] = None
86
+ # 更新时间
87
+ update_time: str
88
+ # 创建时间
89
+ create_time: str
90
+
91
+
92
+ class PurchasingAllQuery(BaseModel):
93
+ """
94
+ 采购订单全部查询参数
95
+ """
96
+ page_no: int = 1
97
+ page_size: int = 300
98
+ # 搜索类型0(采购单号)1(供货商)2(商品sku)6(商品编码)5(商品名称)4(1688单号)3(运单号)7(关联单号)8(采购单备注)9(商品备注)
99
+ search_type: int = 0
100
+ # 搜索内容
101
+ search_value: str = ''
102
+ # 搜索模式1(精确匹配)0(模糊匹配)2(完全匹配)
103
+ search_mode: int = 1
104
+ # 评论颜色使用,分隔
105
+ comment_colors: str = ''
106
+ # 仓库id
107
+ warehouse_id: str = ''
108
+ # 店铺id(或者1688账号)
109
+ authorization_id: str = ''
110
+ # 排序方式: 1(按创建时间) 2(按更新时间) 4(按照采购单号)5(按照供货商名)
111
+ purchasing_px: int = 2
112
+ # 排序方式: asc(升序) desc(降序)
113
+ purchasing_px_val: str = 'desc'
114
+ is_advance_search: str = 'Y'
115
+ # 采购金额起始
116
+ price_left: str = ''
117
+ # 采购金额结束
118
+ price_right: str = ''
119
+ # 采购数量起始
120
+ quantity_left: str = ''
121
+ # 采购数量结束
122
+ quantity_right: str = ''
123
+ # 创建时间开始
124
+ create_start_time: str = ''
125
+ # 创建时间结束
126
+ create_end_time: str = ''
127
+ # 快递签收时间开始
128
+ end_time_start: str = ''
129
+ # 快递签收时间结束
130
+ end_time_end: str = ''
131
+ # 到货时间开始
132
+ arrive_start_time: str = ''
133
+ # 到货时间结束
134
+ arrive_end_time: str = ''
135
+ # 供货商id
136
+ supplier_id: str = ''
137
+ # 采购员id
138
+ agent_id: str = ''
139
+ # 结算方式 1(款到发货)2(货到付款)3(账期付款)4(其它)5(账期付款周结)6(账期付款半月结)7(账期付款月结)
140
+ settlement_method: str = ''
141
+ # 订单状态
142
+ cur_states: str = ''
143
+ # 付款状态
144
+ submit_states: str = ''
145
+ # 到货状态
146
+ arrive_state: str = ''
147
+ # 消息标记-有留言(勾选是Y)
148
+ has_comment: str = ''
149
+ # 消息标记-有备注(勾选是Y)
150
+ has_remark: str = ''
151
+ # 无备注
152
+ no_has_comment: str = ''
153
+ # 下单类型2(1688采购)3(手工采购)''(全部)
154
+ is_alibaba: str = ''
155
+ # 物流信息 ''(全部)2(有运单号)3(无运单号)
156
+ is_have_identify_no: str = ''
157
+
158
+ model_config = ConfigDict(
159
+ alias_generator=to_camel,
160
+ populate_by_name=True # 对应旧版的 allow_population_by_field_name
161
+ )
File without changes
File without changes
@@ -0,0 +1,43 @@
1
+ import math
2
+ from typing import TypedDict
3
+
4
+
5
+ class RemainingShipTime(TypedDict):
6
+ day: int
7
+ hour: int
8
+ minute: int
9
+ second: int
10
+
11
+
12
+ def get_remaining_ship_time(time_int) -> RemainingShipTime:
13
+ """
14
+ 获取剩余发货时间
15
+ :return:
16
+ """
17
+ d = math.floor(time_int / 86400)
18
+ h = math.floor((time_int % 86400) / 3600)
19
+ m = math.floor(((time_int % 86400) % 3600) / 60)
20
+ s = math.floor(((time_int % 86400) % 3600) % 60)
21
+ return {
22
+ "day": d,
23
+ "hour": h,
24
+ "minute": m,
25
+ "second": s
26
+ }
27
+
28
+
29
+ def get_data_custom_mark_to_str(custom_mark: str) -> str:
30
+ mark_list = custom_mark.split(',')
31
+ color_str_list = list()
32
+ mark_color_list = ['isGreen', 'isYellow', 'isOrange', 'isRed', 'isViolet', 'isBlue', 'cornflowerBlue', 'pink',
33
+ 'teal',
34
+ 'turquoise']
35
+
36
+ for index in range(len(mark_list)):
37
+ if index >= len(mark_list):
38
+ break
39
+ # print(mark_list[index])
40
+ if mark_list[index] == '0':
41
+ continue
42
+ color_str_list.append(f'{mark_color_list[index]}_{mark_list[index]}')
43
+ return '&'.join(color_str_list)
@@ -0,0 +1,23 @@
1
+ from typing import Optional
2
+
3
+
4
+ def get_list_first_or_none(array: list) -> Optional[any]:
5
+ """
6
+ 获取列表第一个元素没有则获取空
7
+ :param array:
8
+ :return:
9
+ """
10
+ if len(array) > 0:
11
+ return array[0]
12
+ return None
13
+
14
+
15
+ def get_str_list_first_not_blank_or_none(array: list) -> Optional[str]:
16
+ """
17
+ 获取列表第一个元素(不能为'')没有则获取空
18
+ :param array:
19
+ :return:
20
+ """
21
+ if len(array) > 0 and array[0] != '':
22
+ return array[0].strip()
23
+ return None
@@ -0,0 +1,3 @@
1
+ def to_camel(string: str) -> str:
2
+ parts = string.split('_')
3
+ return parts[0] + ''.join(word.capitalize() for word in parts[1:])
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: ey-commerce-lib
3
+ Version: 1.0.0
4
+ Summary: eeyoung电商客户端调用封装
5
+ Author-email: 饶奇奇 <1124393197@qq.com>
6
+ Requires-Python: >=3.13
7
+ Requires-Dist: httpx>=0.28.1
8
+ Requires-Dist: lxml>=5.3.2
9
+ Requires-Dist: pydantic>=2.11.3
10
+ Requires-Dist: pytest-asyncio>=0.26.0
11
+ Requires-Dist: pytest>=8.3.5
@@ -0,0 +1,25 @@
1
+ ey_commerce_lib/__init__.py,sha256=QTYqXqSTHFRkM9TEgpDFcHvwLbvqHDqvqfQ9EiXkcAM,23
2
+ ey_commerce_lib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ ey_commerce_lib/dxm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ ey_commerce_lib/dxm/main.py,sha256=nJEsEp7shGofGdAOd3fIyCF7NxMigGwpMdlpDuFtbUs,14569
5
+ ey_commerce_lib/dxm/order.py,sha256=hMdNm9X5h9tbvMWFnyE5hcSF4butzn7m-akGqLQUD0k,35
6
+ ey_commerce_lib/dxm/constant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ ey_commerce_lib/dxm/constant/order.py,sha256=U-2NYnkIcqukzMtOFpfqvzIktu_t7jYEms_n9LgKMlY,2213
8
+ ey_commerce_lib/dxm/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ ey_commerce_lib/dxm/exception/common.py,sha256=DM5vItHdZCGK2Piqp2S5TFxPm3pioMzzlV-1RTxty00,159
10
+ ey_commerce_lib/dxm/parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ ey_commerce_lib/dxm/parser/common.py,sha256=bJcP6ZQd0hNeZpEU-8_nN_2AKB69WufKF_JKXtKYZqA,2425
12
+ ey_commerce_lib/dxm/parser/order.py,sha256=KvXKdrmec9rWlYuXPDIIhMGTaPC3rDKTELK3CB-jQ0M,16394
13
+ ey_commerce_lib/dxm/parser/purchase.py,sha256=gBHpIMPPgOZXdU6RIU_a8NogjtzPphCtcLmRauh8r-s,2206
14
+ ey_commerce_lib/dxm/parser/warehouse.py,sha256=LfmqVixV5IcnPvr6Ma4XYoWUdXixQ16xzPP07bJrWb0,3192
15
+ ey_commerce_lib/dxm/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ ey_commerce_lib/dxm/schemas/common.py,sha256=ihCeYrh4K_-m9_4rVzHm-o8rFNqzcD5XkO0JQd2023g,234
17
+ ey_commerce_lib/dxm/schemas/order.py,sha256=uzhSgW0d7Z3L1yYb0meZ2AEF1OosnVM408W2-wZVriE,7802
18
+ ey_commerce_lib/dxm/schemas/warehouse.py,sha256=WkJcLIoeGsTkqEK-6UdQMxScdFT05gfGHv7ZWsavo84,5122
19
+ ey_commerce_lib/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ ey_commerce_lib/utils/dxm.py,sha256=jVNltK_Pm_yMzXReD0Aw5VW6kzIZ5Bn23RucS0DKBI0,1196
21
+ ey_commerce_lib/utils/list_util.py,sha256=R1w7B1m3sEXr38zSHWp-15C3xAs5ykYCCpvwmnRW4xs,545
22
+ ey_commerce_lib/utils/str.py,sha256=939xE0y8U7KEWjwbEezMlaWJNBsfb2BSb-dBpYbOD8Q,138
23
+ ey_commerce_lib-1.0.0.dist-info/METADATA,sha256=FCioN9_jIGdxiMiqAe1dGzH0CM1gZoohfKMpFLwNwKY,326
24
+ ey_commerce_lib-1.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
+ ey_commerce_lib-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any