Authored by chunhua

add erp doc

## 推荐系统
### 流程图
![recommend](http://git.dev.yoho.cn/opentech/api/raw/master/rec.png)
### 接口定义
#### 前台系统->大数据Redis
前台配置文件中添加大数据redis服务器的地址
redis 数据结构为 `LIST`, key 的格式为: `<UID>:<REC_POS>` , 例如 `6323556:100002` 其中,REC_POS定义如下:
- 男生首页,为你优选 :100001 (最多200条)
- 女生首页,为你优选 :100002 (最多200条)
- 我的购物车,为你优选: 100003 (最多9条)
- 我的个人中心-为你优选: 100003 (最多9条) 同“我的购物车”
对每一个推荐位,如果获取不到,将`UID`设置为`-1`,获取默认值,例如 `-1:100001` 获取男生首页的推荐默认值。
游客按照默认推荐处理,即`UID = -1`
#### 客户端-> 前台系统
#### `首页--猜你喜欢(app.search.last7day)` 响应中添加`rec_id`(字符串)
```javascript
{
"alg": "SALT_MD5",
"code": 200,
"data": {
"content_code": "201504091403001",
"page": 2,
"page_total": 9,
"product_list": [
{},
{},
{}
],
"total": 432,
"rec_id": "08Hx124354fg-hhjhjh"
},
"md5": "b96d4db1c287aba3366040cc5d69371d",
"message": "Last Search List."
}
```
其他接口类似
\ No newline at end of file
... ...
### 提交订单
#### 接口描述: 前台系统订单创建成功之后,发送MQ消息到后台。
#### 接口定义
- 接口类型: `MQ`
- MQ位置: 阿里云、aws
- Exchange: `amq.topic`
- Routing Key: `order.submit`
``` javascript
[
{
"activities_id": 0,
"address": "ssddsdsds",
"amount": 469,
"area_code": "140203",
"attribute": 0,
"city": "大同市",
"consignee_name": "sssaaassa",
"coupon_amount": 0,
"coupon_code": "",
"coupon_id": 0,
"coupon_title": "",
"district": "矿区",
"email": "",
"fit_promotions": [ ],
"goods_list": [
{
"brand_id": 443,
"buy_number": 1,
"color_id": 3,
"color_name": "灰色",
"coupons_per": 0,
"erp_sku_id": 965990,
"get_yoho_coin": 0,
"goods_id": 403967,
"goods_type": 1,
"is_jit": "N",
"last_price": 459,
"num": 1,
"product_id": 313911,
"product_name": "Preppy Elite 条纹领口休闲夹克【2016春季新品】",
"product_skn": 51174561,
"product_sku": 965990,
"promo_code_per": 0,
"real_price": 459,
"real_vip_price": 0,
"red_envelope_per": 0,
"sale_price": 459,
"shop_id": 0,
"size_id": 207,
"size_name": "S",
"supplier_id": 0,
"vip_discount": 1,
"vip_discount_money": 0,
"yoho_coin_per": 0
}
],
"invoice_payable": "",
"invoice_type": 0,
"is_contact": "N",
"is_jit": "N",
"is_need_rapid": "N",
"is_print_price": "N",
"last_order_amount": 469,
"mobile": "18751986615",
"need_invoice": "",
"order_amount": 459,
"order_code": 16014231,
"order_referer": "",
"order_type": 3,
"orders_coupons": {
"coupon_amount": 0,
"coupon_code": "",
"coupon_id": 0,
"coupon_title": ""
},
"payment_type": 1,
"phone": "",
"promo_code": "",
"promo_code_amount": 0,
"promo_code_discount": 0,
"promo_id": 0,
"province": "山西省",
"receipt_time": 2,
"receipt_time_type": 0,
"receiver_info": {
"address": "ssddsdsds",
"area_code": "140203",
"city": "大同市",
"consignee_name": "sssaaassa",
"district": "矿区",
"email": "",
"mobile": "18751986615",
"phone": "",
"province": "山西省",
"zip_code": ""
},
"redenvelopesnum": 0,
"remark": "",
"shipping_cost": 10,
"shipping_manner": 1,
"uid": 11944784,
"use_yoho_coin": 0,
"user_level": 0,
"vip_cutdown_amount": 0,
"yoho_coin_num": 0,
"zip_code": ""
}
]
```
... ...
### 前台向ERP同步订单支付信息
#### 接口描述: 前台系统接收到订单支付成功消息之后,发送MQ消息到后台
#### 接口定义
- 接口类型: `MQ`
- MQ位置: 阿里云、aws
- Exchange: `amq.topic`
- Routing Key: `order.payment`
``` javascript
{
"orderCode": "123456",
"status": 200,
"statusData": {
"paymentCode": 123,
"bankCode": "1",
"bankName": "ali",
"amount": 100.01,
"payment": 12,
"payOrderCode": "122",
"tradeNo": "2222",
"bankBillNo": "111"
}
}
```
... ...
### ERP向前台同步库存
#### 接口描述: 后台系统向前台系统同步SKU的全量库存信息
#### 接口定义
- 接口类型: `POST https://service.yoho.cn/erp/sync/storage/full`
- 接口消息体: `JSON`
- 场景: ERP定时执行
``` javascript
[
{
"sku": "12341121",
"storageNum": 10
}
{
"sku": "1234111",
"storageNum": 12
}
]
```
#### 接口描述: 后台系统向前台系统同步SKU的增量库存信息 (订单提交场景下不需要发送这个消息)
#### 接口定义
- 接口类型: `POST https://service.yoho.cn/erp/sync/storage/change`
- 接口消息体: `JSON`
- 场景: 商品上架、商品SKU残次下架、其他渠道销售
``` javascript
[
{
"sku": "12341121",
"storageNum": 10
}
{
"sku": "1234111",
"storageNum": -8
}
]
```
... ...
### 前台提供yoho币变更接口,供erp调用
#### 接口描述:当用户yoho币有变更时,erp调用接口变更yoho币,退还yoho币调用单独的退还接口
#### 接口定义:
- 接口类型: POST https://service.yoho.cn/erp/yohocoin/change
- 接口消息体: JSON
- 场景: yoho币充值、活动赠送、下单使用等
输入举例:
``` javascript
{
"uid":11,
"num":100,
"type":4,
"params":"[]",
"order_code":0,
"pid":2847,
"expires_time":1514735999
}
```
输出举例:
``` javascript
{
"code":200,
"data":{
"uid": 7893817,
"currency": "16400"
},
"message":"ok"
}
```
#### 接口描述:当订单取消或订单退货退还yoho币调用。
#### 接口定义:
- 接口类型: POST https://service.yoho.cn/erp/yohocoin/refund
- 接口消息体: JSON
- 场景: 订单取消、订单退货退还yoho币
输入举例:
``` javascript
{
"uid":11,
"num":100,
"type":2,
"order_code":160125090
}
```
输出举例:
``` javascript
{
"code":200,
"data":{
"uid": 7893817,
"currency": "16400"
},
"message":"ok"
}
```
... ...
# API 说明
RabbitMQ部署
- ERP 发送消息的MQ部署在IDC中。访问地址为: `idc-rabbit.yohoops.org:5672`
- 前台发送消息的MQ部署在aws和aliyun中。访问地址为: `aws-rabbit.yohoops.org:5672` 或者 `aliyun-rabbit.yohoops.org:5672` 后台需要同时连接这2个rabbitmq
rabbitmq用户密码为 `yoho/yoho`,virtual host为 `yoho` (默认)
## ERP 到 前台
- 同步库存 (http://git.dev.yoho.cn/opentech/api/blob/master/ERP-CORE%20Storage.MD)
- 扣减youho币(http://git.dev.yoho.cn/opentech/api/blob/master/YOHCOIN-CHANGE.MD)
## 前台到ERP
- 订单创建 (http://git.dev.yoho.cn/opentech/api/blob/master/CORE-ERP%20Order%20Submit.MD)
- 订单支付 (http://git.dev.yoho.cn/opentech/api/blob/master/CORE-ERP%20PAY.MD)
... ...