一. 订单下载接口
1.机制
《网店蜘蛛》主动发起获取订单请求,网店系统验证请求后,返回订单信息。订单为XML格式,每次返回一个。
2.消息
《网店蜘蛛》会定时向接口文件发出一个http请求。参数如下:
参数 |
说明 |
uCode |
接入码,用于验证请求的有效性。接入码的值在网店系统和网店蜘蛛中设置,必须一致。 |
mType |
请求类别,获取订单时,该值为“GetOrder”。 |
如:http://www.differsoft.com/shop/interface.asp? uCode=123456& mType=mGetOrder
接口收到请求后,验证合法性,如果接入码错误,返回:Error,否则返回订单信息。订单信息采用XML格式,收到一个请求后返回一个订单。
为了确保订单不会重复下载,需要在商城系统中做过滤处理。比如在订单字段里面,增加一个布尔型字段,例如:download(bool),当订单开始建立时,置成false,递交给《网店蜘蛛》后,置为true,收到订单下载请求的时候,取该值为“true”的订单返回。每次返回一个订单,当没有新订单的时候,返回XML格式的结果: <rsp><result>Empty </result></rsp>。
订单格式如下:
标记 |
定义 |
说明 |
Ver |
版本 |
|
OrderID |
订单号 |
不能重复 |
DateTime |
成交日期 |
|
BuyerID |
买家用户名 |
|
BuyerName |
买家姓名 |
|
Country |
国家 |
|
Province |
省/州 |
|
City |
市/县 |
|
Town |
区/镇 |
|
Adr |
地址 |
|
Zip |
邮编 |
|
Email |
Email |
|
Phone |
联系电话 |
|
Total |
货款总额 |
|
PayAccount |
支付方式 |
|
PayID |
支付编号 |
|
Postage |
货运费用 |
|
TradeNO |
原始单号 |
|
TradeURL |
交易链接 |
|
Remark |
备注 |
|
Item |
成交商品集 |
|
|
GoodsID |
库存编码 |
|
GoodsName |
货品名称 |
|
GoodsSpec |
货品规格 |
|
Count |
数量 |
|
Price |
单价 |
|
Reserved3 |
预留3 |
|
Reserved4 |
预留4 |
|
一个符合规范的订单描述:
<?xml version='1.0' encoding='gb2312'?>
<Order>
<Ver>1.0</Ver>
<OrderID>a4fd5a4fda1f2a1d</OrderID>
<DateTime>2006-06-08:12:30</DateTime>
<BuyerID>huadog</BuyerID>
<BuyerName>张三</BuyerName>
<Country>中国</Country>
<Province>浙江</Province>
<City>杭州</City>
<Town>西湖区</Town>
<Adr>文三路90号</Adr>
<Zip>310012</Zip>
<Email>zhangsan@163.com</Email>
<Phone>0571-85642212</Phone>
<Total>250</Total>
<Postage>10</Postage>
<Remark></Remark>
< TradeNO>JY563221</TradeNO>
< TradeURL></TradeURL>
<Item>
<GoodsID>YF001</ GoodsID>
<GoodsName>衣服</GoodsName>
<Price>1.0</Price>
<Count>2</Count>
<Reserved3></Reserved3>
<Reserved4></Reserved4>
</Item>
<Item>
<GoodsID>PJ002</ GoodsID>
<GoodsName>皮带</GoodsName>
<Price>76.5</Price>
<Count>1</Count>
<Reserved3></Reserved3>
<Reserved4></Reserved4>
</Item>
</Order>
3. 例子
验证失败,返回错误的asp例子
<%
Response.write "Error"
%>
没有新订单的asp例子
<%
Response.write "Empty"
%>
返回订单的asp例子
<%
str = "<?xml version='1.0' encoding='gb2312'?>" & chr(13)
str = str & "<Order>" & chr(13)
str = str & "<Ver>1.0</Ver>" & chr(13)
str = str & "<OrderID>a4fd5a4fda1f2a1d</OrderID>" & chr(13)
str = str & "<DateTime>2006-06-08:12:30</DateTime>" & chr(13)
str = str & "<BuyerID>huadog</BuyerID>" & chr(13)
str = str & "<BuyerName>张三</BuyerName>" & chr(13)
str = str & "<Country>中国</Country>" & chr(13)
str = str & "<Province>浙江省</Province>" & chr(13)
str = str & "<City>杭州</City>" & chr(13)
str = str & "<Town>西湖区</Town>" & chr(13)
str = str & "<Adr>文三路90号</Adr>" & chr(13)
str = str & "<Zip>310012</Zip>" & chr(13)
str = str & "<Email>zhangsan@163.com</Email>" & chr(13)
str = str & "<Phone>0571-85642212</Phone>" & chr(13)
str = str & "<Total>250</Total>" & chr(13)
str = str & "< Postage>10</Postage>" & chr(13)
str = str & "<Remark></Remark>" & chr(13)
str = str & "<Reserved1></Reserved1>" & chr(13)
str = str & "<Reserved2></Reserved2>" & chr(13)
str = str & "<Item>" & chr(13)
str = str & "<GoodsID>YF001</GoodsID>" & chr(13)
str = str & "<GoodsName>衣服</GoodsName>" & chr(13)
str = str & "<Price>185.00</Price>" & chr(13)
str = str & "<Count>1</Count>" & chr(13)
str = str & "<Reserved3></Reserved3>" & chr(13)
str = str & "<Reserved4></Reserved4>" & chr(13)
str = str & "</Item>" & chr(13)
str = str & "<Item>" & chr(13)
str = str & "<GoodsID>PJ002</GoodsID>" & chr(13)
str = str & "<GoodsName>皮带</GoodsName>" & chr(13)
str = str & "<Price>65.00</Price>" & chr(13)
str = str & "<Count>2</Count>" & chr(13)
str = str & "<Reserved3></Reserved3>" & chr(13)
str = str & "<Reserved4></Reserved4>" & chr(13)
str = str & "</Item>" & chr(13)
str = str & "</Order>" & chr(13)
Response.write str
%>