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 返回的审核单,并确认结果后调用。' '用商品编号定位,商品编号就是审核页上的 SKU,不是内部商品 ID。' '同一个商品编号有多条时,带上和打开时相同的起运国、目的国。' '一次只提交一条。审核单字段名和嵌套与打开时相同。' '审核通过交齐清关信息;审核驳回交驳回类型和驳回原因;' '预审通过交备注和商品标记。' '参考、可选项名单和编码旁边的税率提示可以原样带上,服务端会丢掉。' '禁止使用:把这次记成系统审核,改写操作日志,批量审核,或未打开审核单就猜测字段。' '参数只用于工具内部调用;最终回答只能展示中文业务名称。' ), 'input_schema': self._schema(), } def call( self, sku='', status=None, departure_country='', destination_country='', request_id='rq_submit_goods_audit', **extra, ): if self.api_client is None: raise RuntimeError('api client is required for submit_goods_audit') status_text = str(status) if status_text not in self.STATUSES: raise ValueError('status is invalid') payload = dict(extra) payload['sku'] = self._text(sku) payload['status'] = status_text if departure_country: payload['departure_country'] = self._text(departure_country) if destination_country: payload['destination_country'] = self._text(destination_country) return self.api_client.call_tool( self.name, self.route_path, payload, request_id, ) @staticmethod def _text(value): if not isinstance(value, str): raise ValueError('sku is invalid') text = value.strip() if not text or len(text) > 200: raise ValueError('sku is invalid') return text 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': { 'sku': { 'type': 'string', 'minLength': 1, 'maxLength': 200, 'description': '商品编号,即审核页上的 SKU。', }, 'departure_country': { 'type': 'string', 'maxLength': 100, 'description': '起运国,与打开审核单时相同。', }, 'destination_country': { 'type': 'string', 'maxLength': 100, 'description': '目的国,与打开审核单时相同。', }, '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': ['sku', 'status'], 'additionalProperties': False, }