Authored by chunhua

add erp doc

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