| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- class SubmitGoodsAuditTool:
- name = 'submit_goods_audit'
- route_path = '/mcp/tools/submitGoodsAudit'
- STATUSES = ('30', '-10', '25')
- def __init__(self, api_client=None):
- self.api_client = api_client
- def metadata(self):
- return {
- 'name': self.name,
- 'description': (
- '使用场景:用户已经看过 open_goods_audit 返回的审核单,并确认结果后调用。'
- '一次只提交一条。字段名和嵌套与打开时的审核单相同。'
- '审核通过交齐清关信息;审核驳回交驳回类型和驳回原因;'
- '预审通过交备注和商品标记。'
- '参考、可选项名单和编码旁边的税率提示可以原样带上,服务端会丢掉。'
- '禁止使用:把这次记成系统审核,改写操作日志,批量审核,或未打开审核单就猜测字段。'
- '参数只用于工具内部调用;最终回答只能展示中文业务名称。'
- ),
- 'input_schema': self._schema(),
- }
- def call(self, goods_id, status, request_id='rq_submit_goods_audit', **extra):
- if self.api_client is None:
- raise RuntimeError('api client is required for submit_goods_audit')
- if not isinstance(goods_id, int) or isinstance(goods_id, bool) or goods_id < 1:
- raise ValueError('goods_id is invalid')
- status_text = str(status)
- if status_text not in self.STATUSES:
- raise ValueError('status is invalid')
- payload = dict(extra)
- payload['goods_id'] = goods_id
- payload['status'] = status_text
- return self.api_client.call_tool(
- self.name, self.route_path, payload, request_id,
- )
- def _schema(self):
- text = {'type': 'string'}
- row = {
- 'type': 'object',
- 'properties': {
- 'clearance_hscode': text,
- 'material': text,
- 'material_ratio': text,
- 'kit_hscode': text,
- 'adjust_hscode_data': {
- 'type': 'array',
- 'items': text,
- },
- 'tax_rate': text,
- 'extra_tax': text,
- 'is_new_hscode': {'type': 'string', 'enum': ['是', '否']},
- 'kit_tax_rate': text,
- },
- 'required': [
- 'clearance_hscode', 'material', 'material_ratio',
- 'kit_hscode', 'adjust_hscode_data',
- ],
- 'additionalProperties': False,
- }
- attr = {
- 'type': 'object',
- 'properties': {
- key: {'type': 'boolean'}
- for key in (
- 'is_battery', 'is_magnetic', 'is_wood', 'is_other', 'is_fda',
- 'is_toy', 'is_ultra_limit', 'is_sensitive', 'is_food',
- )
- },
- 'required': [
- 'is_battery', 'is_magnetic', 'is_wood', 'is_other', 'is_fda',
- 'is_toy', 'is_ultra_limit', 'is_sensitive', 'is_food',
- ],
- 'additionalProperties': False,
- }
- return {
- 'type': 'object',
- 'properties': {
- 'goods_id': {
- 'type': 'integer',
- 'minimum': 1,
- 'description': '商品编号。',
- },
- 'goods_clearance_id': {
- 'type': 'string',
- 'description': '这条商品自己的清关记录编号。审核通过时要带上。',
- },
- 'status': {
- 'type': 'string',
- 'enum': list(self.STATUSES),
- 'description': '30 审核通过,-10 审核驳回,25 预审通过。',
- },
- 'audit_result': text,
- 'select_result': text,
- 'category_ids': text,
- 'shipping_method': text,
- 'goods_type': text,
- 'goods_category_id': text,
- 'goods_attr': attr,
- 'is_inspection_fee': text,
- 'is_fda_declaration': text,
- 'is_epa_declaration': text,
- 'is_act_declaration': text,
- 'is_dot_declaration': text,
- 'is_cpsc_declaration': text,
- 'product_surcharge': text,
- 'tax_surcharge': text,
- 'yf_cn_goodsname': text,
- 'yf_en_goodsname': text,
- 'yf_clearance_price': text,
- 'ys_clearance_price': text,
- 'yf_clearance_data': {'type': 'array', 'items': row},
- 'ys_clearance_data': {'type': 'array', 'items': row},
- 'sync_order_ids': text,
- 'options': {'type': 'object'},
- 'reference': {'type': 'object'},
- },
- 'required': ['goods_id', 'status'],
- 'additionalProperties': False,
- }
|