|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
10 |
|
from __future__ import absolute_import, unicode_literals |
|
3
|
10 |
|
from wechatpy.client.api.base import BaseWeChatAPI |
|
4
|
|
|
|
|
5
|
10 |
|
from wechatpy.client.api.merchant.category import MerchantCategory |
|
6
|
10 |
|
from wechatpy.client.api.merchant.stock import MerchantStock |
|
7
|
10 |
|
from wechatpy.client.api.merchant.express import MerchantExpress |
|
8
|
10 |
|
from wechatpy.client.api.merchant.group import MerchantGroup |
|
9
|
10 |
|
from wechatpy.client.api.merchant.shelf import MerchantShelf |
|
10
|
10 |
|
from wechatpy.client.api.merchant.order import MerchantOrder |
|
11
|
10 |
|
from wechatpy.client.api.merchant.common import MerchantCommon |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
10 |
|
class WeChatMerchant(BaseWeChatAPI): |
|
15
|
|
|
|
|
16
|
10 |
|
def __init__(self, *args, **kwargs): |
|
17
|
10 |
|
super(WeChatMerchant, self).__init__(*args, **kwargs) |
|
18
|
|
|
|
|
19
|
|
|
# sub APIs |
|
20
|
10 |
|
self.category = MerchantCategory(self._client) |
|
21
|
10 |
|
self.stock = MerchantStock(self._client) |
|
22
|
10 |
|
self.express = MerchantExpress(self._client) |
|
23
|
10 |
|
self.group = MerchantGroup(self._client) |
|
24
|
10 |
|
self.shelf = MerchantShelf(self._client) |
|
25
|
10 |
|
self.order = MerchantOrder(self._client) |
|
26
|
10 |
|
self.common = MerchantCommon(self._client) |
|
27
|
|
|
|
|
28
|
10 |
|
def create(self, product_data): |
|
29
|
|
|
return self._post( |
|
30
|
|
|
'merchant/create', |
|
31
|
|
|
data=product_data |
|
32
|
|
|
) |
|
33
|
|
|
|
|
34
|
10 |
|
def delete(self, product_id): |
|
35
|
|
|
return self._post( |
|
36
|
|
|
'merchant/del', |
|
37
|
|
|
data={ |
|
38
|
|
|
'product_id': product_id |
|
39
|
|
|
} |
|
40
|
|
|
) |
|
41
|
|
|
|
|
42
|
10 |
|
def update(self, product_id, product_data): |
|
43
|
|
|
product_data['product_id'] = product_id |
|
44
|
|
|
return self._post( |
|
45
|
|
|
'merchant/update', |
|
46
|
|
|
data=product_data |
|
47
|
|
|
) |
|
48
|
|
|
|
|
49
|
10 |
|
def get(self, product_id): |
|
50
|
|
|
return self._post( |
|
51
|
|
|
'merchant/get', |
|
52
|
|
|
data={ |
|
53
|
|
|
'product_id': product_id |
|
54
|
|
|
} |
|
55
|
|
|
) |
|
56
|
|
|
|
|
57
|
10 |
|
def get_by_status(self, status): |
|
58
|
|
|
return self._post( |
|
59
|
|
|
'merchant/getbystatus', |
|
60
|
|
|
data={ |
|
61
|
|
|
'status': status |
|
62
|
|
|
} |
|
63
|
|
|
) |
|
64
|
|
|
|
|
65
|
10 |
|
def update_product_status(self, product_id, status): |
|
66
|
|
|
return self._post( |
|
67
|
|
|
'merchant/modproductstatus', |
|
68
|
|
|
data={ |
|
69
|
|
|
'product_id': product_id, |
|
70
|
|
|
'status': status |
|
71
|
|
|
} |
|
72
|
|
|
) |
|
73
|
|
|
|