[关闭]
@my943813636 2020-06-23T02:18:19.000000Z 字数 8159 阅读 516

Redis 数据同步

分类

1. 分类绑定 category:sections:%d

分类关系
%d 为父分类id
父分类下套子分类, 数据为直接子分类

数据格式

hash
- key 分类id
- value // 直接子分类

  1. {
  2. "id": 3,
  3. "categorie_id": 41,
  4. "cid": 1,
  5. "sort": 1,
  6. "range": 999,
  7. "num": 100,
  8. "rule": "sort_asc",
  9. "is_enabled": 0
  10. }

方法定义

  1. //@params:cid 分类id
  2. //1. 清空原有的 category:sections:${cid}
  3. //2. 根据直接子分类生成数据 [ {key,value}] ,如果没有子分类不添加 添加category:sections:${cid}
  4. func syncCategorySections(cid int)

2. 分类信息 category:routine_set

数据格式

hash
- key 分类id
- value

  1. {
  2. "id": 3,
  3. "parent_id": 41,
  4. "nest_left": 2,
  5. "nest_right": 173,
  6. "nest_depth": 1,
  7. "name": "Girl",
  8. "name2": "ガーリー",
  9. "slug": "second-sisilily",
  10. "page_title": "Girl ガーリー",
  11. "meta_keywords": "",
  12. "meta_description": "",
  13. "position": 2,
  14. "description": "",
  15. "is_enabled": 1,
  16. "app_icon": "//img.sisilily.com/public/5d5/ce9/454/thumb_457_50x50_0_0_auto.png",
  17. "thumb": "//img.sisilily.com/public/5dd/3bb/da5/thumb_47286_50x50_0_0_auto.png",
  18. "origin_app_icon": "//img.sisilily.com/public/5d5/ce9/454/5d5ce9454bc8a082229987.png",
  19. "origin_thumb": "//img.sisilily.com/public/5dd/3bb/da5/5dd3bbda54446331588658.png"
  20. }

方法定义

  1. //@params:cid 分类id
  2. // 生成分类信息数据
  3. func syncCategory(cid int)

3. 分类特征 category:features

数据格式

hash
- key 分类id
- value

  1. [
  2. {
  3. "id": 1,
  4. "title": "図案",
  5. "sort": 0,
  6. "options": [
  7. {
  8. "name": "無地",
  9. "val": "1"
  10. },
  11. {
  12. "name": "プリント",
  13. "val": "2,7,13,14,16"
  14. }
  15. ]
  16. }
  17. ]

方法定义

  1. //@params:cid 分类id
  2. // 生成所有分类数据
  3. func syncCategoryFeatures(cid int)

4. 关键字 category:hot_words

数据格式

hash
- key 分类id
- value

  1. [
  2. {
  3. "type": "category",
  4. "keyword": "トップス",
  5. "name": "second",
  6. "val": "11",
  7. "slugType": "tops"
  8. }
  9. ]

方法定义

  1. //@params:cid 分类id
  2. // 生成所有分类数据
  3. func syncCategoryHotwords(cid int)

5. 关键字 category:reward_points

数据格式

hash
- key : 分类id
- value

  1. [
  2. {
  3. "amount_type": "point", //ratio , specify
  4. "amount": 1,
  5. "user_group": 1,
  6. }
  7. ]

amount_type 类型:
- ratio 比例
- specify 固定金额

方法定义

  1. // 生成所有积分策略数据
  2. func syncCategoryPoints()

6. 分类id列表

方法定义

  1. //返回全部分类的id
  2. func getCategoryIdList() []int

促销

1. 获取促销类型为产品的 关联产品

方法定义

  1. //@params:id 促销id
  2. //返回该促销下的关联的产品id列表, 如果折扣类型不是产品返回 []
  3. func getPromoteProductIdList(id int) []int

2. 获取类型是产品的促销id列表

方法定义

  1. //@params:id 促销id
  2. //返回该折扣类型是产品的促销列表
  3. func getPromoteIdList() []int

广告位

1. 同步单个广告位 adverts

数据格式

hash
- key : 广告位code
- value :

  1. {
  2. "name": "首页-GIRL类目快速入口",
  3. "members_count": 1,
  4. "enabled_cycle": 0,
  5. "is_enabled": 1,
  6. "from_date": 946742399,
  7. "to_date": 946742399,
  8. "members": [
  9. {
  10. "id": 255,
  11. "name": "トップス",
  12. "link": "https://m.sisilily.com/design.html?first=3&second=7",
  13. "sort": 1,
  14. "is_enabled": 1,
  15. "describe": "<p>トップス</p>",
  16. "url": "https://img.sisilily.com/storage/app/uploads/public/5e2/588/877/5e2588877a709985817768.png"
  17. }
  18. ]
  19. }

方法定义

  1. //@params:id 广告位id
  2. //给定广告位id 同步广告位 和 广告位成员数据
  3. func syncAvert(id int)

2. 获取广告位id 列表

方法定义

  1. //返回全部广告位id 列表
  2. func getBannerIdList() []int

产品勾选位

1. 同步单个勾选位 product_sections:%s

数据格式

Zset
- score : 商品排序
- member : 商品id

方法定义

  1. //@params:code 勾选位code
  2. //清空原有的勾选位数据 product_sections:${code}
  3. //给定勾选位code 同步勾选位商品数据 和 商品排序 key product_sections:${code}
  4. func syncProductSections(code string)

2. 获取勾选位code 列表

方法定义

  1. //返回全部商品勾选位code 列表
  2. func getProductSectionsCodeList() []string

3. 获取勾选位关联的商品id列表

方法定义

  1. //@params:code 勾选位code
  2. //返回勾选位关联的商品列表
  3. func getProductSectionsRelateProduct(code string) int[]

商品

1. 同步商品基础信息 product

数据格式

hash
- key : 商品id
- value :

  1. {
  2. "id": 1129,
  3. "code": "1129",
  4. "name": "レトロハイヒールスエードジッパーショート丈ブーツ",
  5. "pid": 1551157,
  6. "name2": "",
  7. "slug": "b-shoes-boots-1129",
  8. "status": "instock",
  9. "spu": "0001551157",
  10. "spu_status": 1,
  11. "stock_status": 1,
  12. "list_price": 478000,
  13. "price": 239000,
  14. "activity_price": 0,
  15. "amount": 9999,
  16. "sales_num": 1,
  17. "collect": 4,
  18. "rating": 5,
  19. "reviews_count": 7,
  20. "sort": 9999,
  21. "sort_section": 0,
  22. "sort2": 9999,
  23. "sort3": 9999,
  24. "thumb": "//img.sisilily.com/public/5d6/ce5/47b/thumb_8949_344x420_0_0_auto_65.jpg",
  25. "s_thumb": "//img.sisilily.com/public/5d6/ce5/486/thumb_8950_344x420_0_0_auto.jpg",
  26. "instock_time": 1567670771
  27. }

方法定义

  1. //@params:id 商品id
  2. //@params:isSyncActivePrice 是否需要同步 活动价格,如果需要同步活动价格需要查询商品所属的促销规则,然后根据促销规则同步活动价格,如果不属于任何促销活动活动价格为 0 , 字段 activity_price
  3. //1. 如果 activity_price 是false 需要先判断 redis 中是否存在这个商品数据, 如果存在保留redis中的 activity_price 不存在 使用 0 作为默认值,表示没有参与活动
  4. //给定商品id 同步商品基础信息, 价格需要 * 100 结果为整数 , instock_time 为utc 时间戳 秒
  5. func syncProduct(id int, isSyncActivePrice bool)

2. 同步商品积分信息

待定

3. 同步商品尺码信息 product:sizes

数据格式

hash
- key : 商品id
- value :

  1. {
  2. "id": 4923,
  3. "product_id": 2,
  4. "sizes": "[{\"id\":1330558,\"first_name\":\"尺码\",\"trans_name\":\"サイズ(CM)\",\"values\":[\"フリー\"]},{\"id\":1330559,\"first_name\":\"袖长\",\"trans_name\":\"袖丈\",\"values\":[\"33\"]},{\"id\":1330560,\"first_name\":\"衣长\",\"trans_name\":\"着丈\",\"values\":[\"39\"]},{\"id\":1330561,\"first_name\":\"胸围\",\"trans_name\":\"バスト\",\"values\":[\"106\"]}]",
  5. "size_image": "",
  6. "size_group": ""
  7. }

方法定义

  1. //@params:id 商品id
  2. //给定商品id 同步商品尺码信息
  3. func syncProductSize(id int)

4. 同步商品详情 product:content

数据格式

hash
- key : 商品id
- value :

  1. {
  2. "content": "<p></p>",
  3. }

方法定义

  1. //@params:id 商品id
  2. //给定商品id 同步商品详情信息
  3. func syncProductContent(id int)

5. 同步商品特征值 product:features:%d

数据格式

hash
- key : 商品id
- value :

  1. {
  2. "id": 39,
  3. "name": "カバン模様",
  4. "name2": "包包图案",
  5. "group_id": 0,
  6. "type": "",
  7. "sort": 1,
  8. "description": "",
  9. "display_on_product": 1,
  10. "options": 0,
  11. "values": "{\"533\":{\"id\":533,\"feature_id\":39,\"name\":\"\\u914d\\u8272\",\"name2\":\"\\u914d\\u8272\",\"code\":\"\",\"sort\":1,\"options\":0}}"
  12. }

方法定义

  1. //@params:id 商品id
  2. // 清空原有的商品特征值数据 product:features:${id}
  3. //给定商品id 同步商品详情信息
  4. func syncProductFeatures(id int)

6. 同步商品评论 product:reviews:%d

数据格式

hash
- key : 评论 id
- value :

  1. {
  2. "id": 8556,
  3. "admin_id": 535,
  4. "parent_id": 0,
  5. "uid": 0,
  6. "product_id": 10198,
  7. "title": "外出するのも良いかも",
  8. "name": "和智麻衣",
  9. "email": "",
  10. "rating": 5,
  11. "audit": 1,
  12. "location": "frontend",
  13. "content": "これから暑くなるので薄着になる事が多くなると思います。シャツ1枚で外出するのには抵抗があったのですが、このシャツなら1枚で外出するのも良いかもと思える位のシャツだと感じてます。",
  14. "user_cate": "2",
  15. "thumbs": [
  16. "://img.sisilily.com"
  17. ]
  18. }

方法定义

  1. //@params:id 商品id
  2. //清空原有的商品评论数据 product:reviews:${id}
  3. //给定商品id 同步商品评论 ( thumbs 为带图评论 如果有图片返回图片地址列表)
  4. func syncProductReviews(id int)

7. 同步商品图片列表 product:images

数据格式

hash
- key : 商品id
- value :

  1. [
  2. "//img.sisilily.com/public/5d6/74d/606/5d674d60610df766731997.jpg",
  3. "//img.sisilily.com/public/5d6/74d/628/5d674d62877b7953816338.jpg"
  4. ]

方法定义

  1. //@params:id 商品id
  2. //给定商品id 同步商品图片列表
  3. func syncProductReviews(id int)

8. 同步商品选项 product:options:%d

数据格式

hash
- key : 商品选项 id
- value :

  1. {
  2. "id": 19952,
  3. "parent_id": 0,
  4. "name": "カラー",
  5. "name2": "颜色",
  6. "product_id": 10107,
  7. "sort": 3,
  8. "type": "radio",
  9. "variate_value": 0,
  10. "required": 0,
  11. "comment": "",
  12. "values": [
  13. {
  14. "id": 65751,
  15. "option_id": 19952,
  16. "name": "イエロー",
  17. "name2": "黄色",
  18. "remind_tags": "",
  19. "price_variate": "+",
  20. "variate_value": 0,
  21. "sort": 3,
  22. "f_thumb": "",
  23. "o_thumb": "//img.sisilily.com/public/5e2/69b/bc2/thumb_93040_40x40_0_0_crop.jpg",
  24. "origin_f_thumb": "",
  25. "origin_o_thumb": "//img.sisilily.com/public/5e2/69b/bc2/5e269bbc24d55949232313.jpg"
  26. }
  27. ]
  28. }

方法定义

  1. //@params:id 商品id
  2. //清空原有的商品选项 product:options:${id}
  3. //给定商品id 同步商品选项列表
  4. func syncProductOptions(id int)

9. 同步商品SKU product:skus:%d

数据格式

hash
- key : 商品sku id
- value :

  1. {
  2. "id": 112784,
  3. "product_id": 10036,
  4. "option_values": "{\"19810\":{\"65323\":\"\\u7816\\u7ea2\\u8272\\u5957\\u88c5\"},\"19811\":{\"65331\":\"85B\"}}",
  5. "sku": "000276163200024",
  6. "item_id": "",
  7. "sku_price": 7200,
  8. "sku_status": 1,
  9. "sku_list_price": 21400,
  10. "sku_stock": 7427,
  11. "presell": 1
  12. }

方法定义

  1. //@params:id 商品id
  2. //清空原有的商品选项 product:skus:${id}
  3. //给定商品id 同步商品sku列表
  4. func syncProductSkus(id int)

10. 同步商品猜你喜欢 product:guess_like:%d

数据格式

set
- value : 商品 id

方法定义

  1. //@params:id 商品id
  2. //清空原有的商品猜你喜欢 product:guess_like:${id}
  3. //给定商品id 同步商品sku列表
  4. func syncProductGuessLike(id int)

11. 同步商品推荐 product:recommend:%d

数据格式

set
- value : 商品 id

方法定义

  1. //@params:id 商品id
  2. //清空原有的商品推荐 product:recommend:${id}
  3. //给定商品id 同步商品推荐列表
  4. func syncProductRecommend(id int)

12. 同步商品标签 product:tags

数据格式

hash
- key : 商品 id
- value

  1. // tag type
  2. /**
  3. 1. 场馆
  4. 2. 不处理 (后台绑定标签)
  5. 3. HOT
  6. 4. NEW
  7. 5. time-sale
  8. 6. new-sale
  9. 7. special-sale
  10. **/
  11. {
  12. "product_id": 68,
  13. "tags": [
  14. {
  15. "type": 1,
  16. "content": "Lady"
  17. }
  18. ]
  19. }

方法定义

  1. //@params:id 商品id
  2. //给定商品id 同步商品标签
  3. func syncProductTags(id int)

13. 同步商品所属分类 product:categories

数据格式

hash
- key : 商品 id
- value : [4, 24,15] 所属分类层级

方法定义

  1. //@params:id 商品id
  2. //给定商品id 同步商品分类层级 分类关系如下
  3. /**
  4. - 4
  5. - 24
  6. - 15
  7. **/
  8. //排序后 [4,24,15]
  9. func syncProductCategories(id int)

14. 获取全部商品id列表

方法定义

  1. //@params:startProductId 起始商品id 包含
  2. //@params:endProductId 结束商品id 不包含
  3. //获取商品id范围内全部商品的id列表
  4. func getProductIdList(startProductId int, endProductId int) []int

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注