优化工单模块,增加企微模块

This commit is contained in:
mgw
2024-07-10 15:58:47 +08:00
parent e8512b23e4
commit 6b140fe6dd
134 changed files with 12830 additions and 2 deletions

View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from wechatpy.client.api.base import BaseWeChatAPI
from wechatpy.client.api.merchant.category import MerchantCategory
from wechatpy.client.api.merchant.stock import MerchantStock
from wechatpy.client.api.merchant.express import MerchantExpress
from wechatpy.client.api.merchant.group import MerchantGroup
from wechatpy.client.api.merchant.shelf import MerchantShelf
from wechatpy.client.api.merchant.order import MerchantOrder
from wechatpy.client.api.merchant.common import MerchantCommon
class WeChatMerchant(BaseWeChatAPI):
def __init__(self, *args, **kwargs):
super(WeChatMerchant, self).__init__(*args, **kwargs)
# sub APIs
self.category = MerchantCategory(self._client)
self.stock = MerchantStock(self._client)
self.express = MerchantExpress(self._client)
self.group = MerchantGroup(self._client)
self.shelf = MerchantShelf(self._client)
self.order = MerchantOrder(self._client)
self.common = MerchantCommon(self._client)
def create(self, product_data):
return self._post(
'merchant/create',
data=product_data
)
def delete(self, product_id):
return self._post(
'merchant/del',
data={
'product_id': product_id
}
)
def update(self, product_id, product_data):
product_data['product_id'] = product_id
return self._post(
'merchant/update',
data=product_data
)
def get(self, product_id):
return self._post(
'merchant/get',
data={
'product_id': product_id
}
)
def get_by_status(self, status):
return self._post(
'merchant/getbystatus',
data={
'status': status
}
)
def update_product_status(self, product_id, status):
return self._post(
'merchant/modproductstatus',
data={
'product_id': product_id,
'status': status
}
)

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from wechatpy.client.api.base import BaseWeChatAPI
class MerchantCategory(BaseWeChatAPI):
def get_sub_categories(self, cate_id):
res = self._post(
'merchant/category/getsub',
data={'cate_id': cate_id},
result_processor=lambda x: x['cate_list']
)
return res
def get_sku_list(self, cate_id):
res = self._post(
'merchant/category/getsku',
data={'cate_id': cate_id},
result_processor=lambda x: x['sku_table']
)
return res
def get_properties(self, cate_id):
res = self._post(
'merchant/category/getproperty',
data={'cate_id': cate_id},
result_processor=lambda x: x['properties']
)
return res

View File

@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from wechatpy.client.api.base import BaseWeChatAPI
class MerchantCommon(BaseWeChatAPI):
def upload_image(self, filename, image_data):
res = self._post(
'merchant/common/upload_img',
params={
'filename': filename
},
data=image_data,
result_processor=lambda x: x['image_url']
)
return res

View File

@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from wechatpy.client.api.base import BaseWeChatAPI
class MerchantExpress(BaseWeChatAPI):
def add(self, delivery_template):
return self._post(
'merchant/express/add',
data={
'delivery_template': delivery_template
}
)
def delete(self, template_id):
return self._post(
'merchant/express/del',
data={
'template_id': template_id
}
)
def update(self, template_id, delivery_template):
return self._post(
'merchant/express/update',
data={
'template_id': template_id,
'delivery_template': delivery_template
}
)
def get(self, template_id):
res = self._post(
'merchant/express/getbyid',
data={
'template_id': template_id
},
result_processor=lambda x: x['template_info']
)
return res
def get_all(self):
res = self._get(
'merchant/express/getall',
result_processor=lambda x: x['template_info']
)
return res

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from wechatpy.client.api.base import BaseWeChatAPI
class MerchantGroup(BaseWeChatAPI):
def add(self, name, product_list):
return self._post(
'merchant/group/add',
data={
'group_detail': {
'group_name': name,
'product_list': product_list
}
}
)
def delete(self, group_id):
return self._post(
'merchant/group/del',
data={
'group_id': group_id
}
)
def update(self, group_id, name):
return self._post(
'merchant/group/propertymod',
data={
'group_id': group_id,
'group_name': name
}
)
def update_product(self, group_id, product):
return self._post(
'merchant/group/productmod',
data={
'group_id': group_id,
'product': product
}
)
def get_all(self):
res = self._get(
'merchant/group/getall',
result_processor=lambda x: x['group_detail']
)
return res
def get(self, group_id):
res = self._post(
'merchant/group/getbyid',
data={
'group_id': group_id
},
result_processor=lambda x: x['group_detail']
)
return res

View File

@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from optionaldict import optionaldict
from wechatpy.client.api.base import BaseWeChatAPI
class MerchantOrder(BaseWeChatAPI):
def get(self, order_id):
res = self._post(
'merchant/order/getbyid',
data={
'order_id': order_id
},
result_processor=lambda x: x['order']
)
return res
def get_by_filter(self, status=None, begin_time=None, end_time=None):
filter_dict = optionaldict(
status=status,
begintime=begin_time,
endtime=end_time
)
res = self._post(
'merchant/order/getbyfilter',
data=dict(filter_dict),
result_processor=lambda x: x['order_list']
)
return res
def set_delivery(self, order_id, company, track_no,
need_delivery=1, is_others=0):
return self._post(
'merchant/order/setdelivery',
data={
'order_id': order_id,
'delivery_company': company,
'delivery_track_no': track_no,
'need_delivery': need_delivery,
'is_others': is_others
}
)
def close(self, order_id):
return self._post(
'merchant/order/close',
data={
'order_id': order_id
}
)

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from wechatpy.client.api.base import BaseWeChatAPI
class MerchantShelf(BaseWeChatAPI):
def add(self, name, banner, shelf_data):
return self._post(
'merchant/shelf/add',
data={
'shelf_name': name,
'shelf_banner': banner,
'shelf_data': shelf_data
}
)
def delete(self, shelf_id):
return self._post(
'merchant/shelf/del',
data={
'shelf_id': shelf_id
}
)
def update(self, shelf_id, name, banner, shelf_data):
return self._post(
'merchant/shelf/add',
data={
'shelf_id': shelf_id,
'shelf_name': name,
'shelf_banner': banner,
'shelf_data': shelf_data
}
)
def get_all(self):
res = self._get(
'merchant/shelf/getall',
result_processor=lambda x: x['shelves']
)
return res
def get(self, shelf_id):
return self._post(
'merchant/shelf/getbyid',
data={
'shelf_id': shelf_id
}
)

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from wechatpy.client.api.base import BaseWeChatAPI
class MerchantStock(BaseWeChatAPI):
def add(self, product_id, quantity, sku_info=''):
return self._post(
'merchant/stock/add',
data={
'product_id': product_id,
'quantity': quantity,
'sku_info': sku_info
}
)
def reduce(self, product_id, quantity, sku_info=''):
return self._post(
'merchant/stock/reduce',
data={
'product_id': product_id,
'quantity': quantity,
'sku_info': sku_info
}
)