sc-common-interface 2.7.7__tar.gz → 2.7.9__tar.gz
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.
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/PKG-INFO +1 -1
- sc_common_interface-2.7.9/sc_common_interface/CommonOa.py +248 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface.egg-info/SOURCES.txt +1 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/setup.py +1 -1
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface/LiveCommonInterface.py +0 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface/McCommonInterface.py +0 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface/Platform.py +0 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface/PostCommonInterface.py +0 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface/__init__.py +0 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface.egg-info/requires.txt +0 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/setup.cfg +0 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from datetime import datetime,timedelta,timezone
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def modify_order_payment_status(data):
|
|
6
|
+
"""
|
|
7
|
+
:param data:
|
|
8
|
+
status:订单的状态
|
|
9
|
+
pending:未付款
|
|
10
|
+
completed:已付款
|
|
11
|
+
refunding :退款中
|
|
12
|
+
refunded:已退款
|
|
13
|
+
partially_refunded:部分退款
|
|
14
|
+
:return:
|
|
15
|
+
"""
|
|
16
|
+
oa_env = data["oa_env"]
|
|
17
|
+
oa_headers = data["oa_headers"]
|
|
18
|
+
status = data["status"]
|
|
19
|
+
order_id = data["order_id"]
|
|
20
|
+
# 修改订单状态为-已确认
|
|
21
|
+
url = "%s/v1/orders/%s/order_payment_status" % (oa_env,order_id)
|
|
22
|
+
body = {
|
|
23
|
+
"status": status,
|
|
24
|
+
"mail_notify": False
|
|
25
|
+
}
|
|
26
|
+
res = requests.patch(url, headers=oa_headers, json=body).json()
|
|
27
|
+
return res
|
|
28
|
+
|
|
29
|
+
def modify_order_delivery_status(data):
|
|
30
|
+
"""
|
|
31
|
+
:param data:
|
|
32
|
+
status:订单的状态
|
|
33
|
+
pending:备货中
|
|
34
|
+
shipping:发货中
|
|
35
|
+
shipped :已发货
|
|
36
|
+
arrived:已到达
|
|
37
|
+
collected:已取货
|
|
38
|
+
returned:已退货
|
|
39
|
+
returning:退回中
|
|
40
|
+
:return:
|
|
41
|
+
"""
|
|
42
|
+
oa_env = data["oa_env"]
|
|
43
|
+
oa_headers = data["oa_headers"]
|
|
44
|
+
status = data["status"]
|
|
45
|
+
order_id = data["order_id"]
|
|
46
|
+
# 查询订单id
|
|
47
|
+
url = "%s/v1/orders/%s/order_delivery_status" % (oa_env,order_id)
|
|
48
|
+
body = {
|
|
49
|
+
"status": status,
|
|
50
|
+
"mail_notify": False
|
|
51
|
+
}
|
|
52
|
+
res = requests.patch(url, headers=oa_headers, json=body).json()
|
|
53
|
+
return res
|
|
54
|
+
|
|
55
|
+
def delete_product(data):
|
|
56
|
+
"""可以删除组合商品和普通商品"""
|
|
57
|
+
oa_env = data["oa_env"]
|
|
58
|
+
oa_headers = data["oa_headers"]
|
|
59
|
+
product_id = data["product_id"]
|
|
60
|
+
url = "%s/v1/products/%s"%(oa_env,product_id)
|
|
61
|
+
res = requests.delete(url,headers=oa_headers).json()
|
|
62
|
+
return res
|
|
63
|
+
|
|
64
|
+
def get_product(data):
|
|
65
|
+
oa_env = data["oa_env"]
|
|
66
|
+
oa_headers = data["oa_headers"]
|
|
67
|
+
product_id = data["product_id"]
|
|
68
|
+
url = "%s/v1/products/%s" % (oa_env, product_id)
|
|
69
|
+
res = requests.get(url, headers=oa_headers).json()
|
|
70
|
+
return res
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def edit_product_spu(data):
|
|
74
|
+
""""编辑商品名称、隐藏价格、限购数量、预售时间,spu维度的编辑
|
|
75
|
+
hide_price:false true
|
|
76
|
+
隐藏商品/下架商品[status]: hidden、active、draft
|
|
77
|
+
限购数量【max_order_quantity】:-1【不限购】
|
|
78
|
+
商品名称格式:
|
|
79
|
+
{'vi': '商品名称1734667300--多规格---编辑', 'th': '商品名称1734667300', 'zh-hant': '商品名称1734667300---编辑繁体', 'en': '商品名称1734667300-----编辑英文', 'id': '商品名称1734624132',
|
|
80
|
+
'fr': '商品名称1734624132', 'zh-cn': '商品名称1734667300----多篇规格简体中文'}
|
|
81
|
+
available_start_time 预购开始时间:格式:"2024-12-25T15:00:00.000+00:00"
|
|
82
|
+
available_end_time 预购结束时间:用不过期为null
|
|
83
|
+
------无规格商品编辑商品预购库存、无限库存-------
|
|
84
|
+
unlimited_quantity:现货库存无限库存,True,False
|
|
85
|
+
is_preorder【预购类型】:True,False
|
|
86
|
+
preorder_limit:预购数量,无限数量为-1
|
|
87
|
+
"""
|
|
88
|
+
oa_env = data["oa_env"]
|
|
89
|
+
oa_headers = data["oa_headers"]
|
|
90
|
+
product_id = data["product_id"]
|
|
91
|
+
url = "%s/v1/products/%s" % (oa_env, product_id)
|
|
92
|
+
body = {}
|
|
93
|
+
if "title" in data:
|
|
94
|
+
title_translations = data["title"]
|
|
95
|
+
body["title_translations"] = title_translations
|
|
96
|
+
else:
|
|
97
|
+
response = get_product(data)
|
|
98
|
+
# print(response)
|
|
99
|
+
title_translations = response["title_translations"]
|
|
100
|
+
body["title_translations"] = title_translations
|
|
101
|
+
|
|
102
|
+
if "hide_price" in data:
|
|
103
|
+
hide_price = data["hide_price"]
|
|
104
|
+
body["hide_price"] = hide_price
|
|
105
|
+
if "status" in data:
|
|
106
|
+
status = data["status"]
|
|
107
|
+
body["status"] = status
|
|
108
|
+
if "max_order_quantity" in data:
|
|
109
|
+
max_order_quantity = data["max_order_quantity"]
|
|
110
|
+
body["max_order_quantity"] = max_order_quantity
|
|
111
|
+
if "available_start_time" in data:
|
|
112
|
+
available_start_time = data["available_start_time"]
|
|
113
|
+
available_end_time = data["available_end_time"]
|
|
114
|
+
body["available_end_time"] = available_end_time
|
|
115
|
+
body["available_start_time"] = available_start_time
|
|
116
|
+
# if "quantity" in data:
|
|
117
|
+
# quantity = data["quantity"]
|
|
118
|
+
# body["quantity"] = quantity
|
|
119
|
+
if "unlimited_quantity" in data:
|
|
120
|
+
unlimited_quantity = data["unlimited_quantity"]
|
|
121
|
+
body["unlimited_quantity"] = unlimited_quantity
|
|
122
|
+
if "is_preorder" in data:
|
|
123
|
+
is_preorder = data["is_preorder"]
|
|
124
|
+
body["is_preorder"] = is_preorder
|
|
125
|
+
if is_preorder==True:
|
|
126
|
+
preorder_limit = data["preorder_limit"]
|
|
127
|
+
body["preorder_limit"] = preorder_limit
|
|
128
|
+
if "with_product_set" in data:
|
|
129
|
+
with_product_set = data["with_product_set"]
|
|
130
|
+
body["with_product_set"] = with_product_set
|
|
131
|
+
# print(body)
|
|
132
|
+
res = requests.put(url, headers=oa_headers, json=body).json()
|
|
133
|
+
return res
|
|
134
|
+
|
|
135
|
+
def edit_spu_quantity(data):
|
|
136
|
+
"""更新无库存商品的现货库存数量"""
|
|
137
|
+
oa_env = data["oa_env"]
|
|
138
|
+
oa_headers = data["oa_headers"]
|
|
139
|
+
product_id = data["product_id"]
|
|
140
|
+
url = "%s/v1/products/%s/update_quantity" % (oa_env, product_id)
|
|
141
|
+
# print(url)
|
|
142
|
+
quantity = 100
|
|
143
|
+
if "quantity" in data:
|
|
144
|
+
quantity = data["quantity"]
|
|
145
|
+
body = {
|
|
146
|
+
"quantity": quantity,
|
|
147
|
+
"replace": True
|
|
148
|
+
}
|
|
149
|
+
# print(body)
|
|
150
|
+
res = requests.put(url, headers=oa_headers, json=body).json()
|
|
151
|
+
return res
|
|
152
|
+
|
|
153
|
+
def edit_sku_quantity(data):
|
|
154
|
+
"""更新指定规格的库存数量"""
|
|
155
|
+
oa_env = data["oa_env"]
|
|
156
|
+
oa_headers = data["oa_headers"]
|
|
157
|
+
product_id = data["product_id"]
|
|
158
|
+
sku_id = data["sku_id"]
|
|
159
|
+
url = "%s/v1/products/%s/variations/%s/update_quantity" % (oa_env, product_id,sku_id)
|
|
160
|
+
quantity = 100
|
|
161
|
+
if "quantity" in data:
|
|
162
|
+
quantity = data["quantity"]
|
|
163
|
+
body = {
|
|
164
|
+
"quantity": quantity,
|
|
165
|
+
"replace": True
|
|
166
|
+
}
|
|
167
|
+
res = requests.put(url, headers=oa_headers, json=body).json()
|
|
168
|
+
return res
|
|
169
|
+
|
|
170
|
+
def edit_spu_price(data):
|
|
171
|
+
"""更新无库存商品的价格"""
|
|
172
|
+
oa_env = data["oa_env"]
|
|
173
|
+
oa_headers = data["oa_headers"]
|
|
174
|
+
product_id = data["product_id"]
|
|
175
|
+
url = "%s/v1/products/%s/update_price" % (oa_env, product_id)
|
|
176
|
+
body = {}
|
|
177
|
+
if "price" in data:
|
|
178
|
+
"""原价"""
|
|
179
|
+
price = data["price"]
|
|
180
|
+
body["price"] = price
|
|
181
|
+
if "price_sale" in data:
|
|
182
|
+
"""特价"""
|
|
183
|
+
price_sale = data["price_sale"]
|
|
184
|
+
body["price_sale"] = price_sale
|
|
185
|
+
if "cost" in data:
|
|
186
|
+
"""成本价"""
|
|
187
|
+
cost = data["cost"]
|
|
188
|
+
body["cost"] = cost
|
|
189
|
+
if "member_price" in data:
|
|
190
|
+
"""会员价"""
|
|
191
|
+
member_price = data["member_price"]
|
|
192
|
+
body["member_price"] = member_price
|
|
193
|
+
if "retail_price" in data:
|
|
194
|
+
"""实体店价格"""
|
|
195
|
+
retail_price = data["retail_price"]
|
|
196
|
+
body["retail_price"] = retail_price
|
|
197
|
+
|
|
198
|
+
res = requests.put(url, headers=oa_headers, json=body).json()
|
|
199
|
+
return res
|
|
200
|
+
|
|
201
|
+
def edit_sku_price(data):
|
|
202
|
+
"""更新指定规格的价格"""
|
|
203
|
+
oa_env = data["oa_env"]
|
|
204
|
+
oa_headers = data["oa_headers"]
|
|
205
|
+
product_id = data["product_id"]
|
|
206
|
+
sku_id = data["sku_id"]
|
|
207
|
+
url = "%s/v1/products/%s/variations/%s/update_price" % (oa_env, product_id, sku_id)
|
|
208
|
+
body = {}
|
|
209
|
+
if "price" in data:
|
|
210
|
+
"""原价"""
|
|
211
|
+
price = data["price"]
|
|
212
|
+
body["price"] = price
|
|
213
|
+
if "price_sale" in data:
|
|
214
|
+
"""特价"""
|
|
215
|
+
price_sale = data["price_sale"]
|
|
216
|
+
body["price_sale"] = price_sale
|
|
217
|
+
if "cost" in data:
|
|
218
|
+
"""成本价"""
|
|
219
|
+
cost = data["cost"]
|
|
220
|
+
body["cost"] = cost
|
|
221
|
+
if "member_price" in data:
|
|
222
|
+
"""会员价"""
|
|
223
|
+
member_price = data["member_price"]
|
|
224
|
+
body["member_price"] = member_price
|
|
225
|
+
if "retail_price" in data:
|
|
226
|
+
"""实体店价格"""
|
|
227
|
+
retail_price = data["retail_price"]
|
|
228
|
+
body["retail_price"] = retail_price
|
|
229
|
+
res = requests.put(url, headers=oa_headers, json=body).json()
|
|
230
|
+
return res
|
|
231
|
+
|
|
232
|
+
def get_str_time(time_type="add",unit="days",num=1,format='%Y-%m-%dT%H:%M:%S.%f'):
|
|
233
|
+
now = datetime.now()
|
|
234
|
+
expect_time = now+timedelta(**{unit:num if time_type=="add" else -num})
|
|
235
|
+
format_time = expect_time.strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + '+00:00'
|
|
236
|
+
return format_time
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
if __name__=="__main__":
|
|
243
|
+
format_time = get_str_time(num=2,time_type="sub")
|
|
244
|
+
print(format_time)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
{sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface/LiveCommonInterface.py
RENAMED
|
File without changes
|
{sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface/McCommonInterface.py
RENAMED
|
File without changes
|
|
File without changes
|
{sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface/PostCommonInterface.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{sc_common_interface-2.7.7 → sc_common_interface-2.7.9}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|