第三方api接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
1 jaar geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package taobao
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
  5. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  6. "errors"
  7. "github.com/tidwall/gjson"
  8. "xorm.io/xorm"
  9. )
  10. func NewTaobaoSDK(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int) (*TB, error) {
  11. // 从联盟设置中获取淘宝配置
  12. taobaoCfg, err := db.SysUnionByTaobaoByUseByAuth(eg, dbName)
  13. if err != nil {
  14. return nil, err
  15. }
  16. var cfg *TB
  17. freeCfg := db.SysCfgGetWithDb(eg, dbName, "newcomers_free_cfg")
  18. /*if freeCfg == "" {
  19. return nil, errors.New("no free cfg found")
  20. }*/
  21. Svc_AK := "26302019"
  22. Svc_SK := "ba877cfcdc64d3fbc1105d61d66dd1d7"
  23. if taobaoCfg.AuthTime.Unix() >= zhios_third_party_utils.TimeStdParseUnix(TB_SVC_TIME) {
  24. Svc_AK = TB_SVC_AK
  25. Svc_SK = TB_SVC_SK
  26. }
  27. cloudPid := ""
  28. cloudTaobaoPromoId, _ := db.SysCfgGetOne(eg, "cloud_taobao_promo_id")
  29. if cloudTaobaoPromoId != nil {
  30. cloudPid = cloudTaobaoPromoId.Val
  31. }
  32. // 跟随官方
  33. if taobaoCfg.AuthType == 1 {
  34. cfg = &TB{
  35. Web_AK: Svc_AK,
  36. Web_SK: Svc_SK,
  37. CloudPromoIdWeb: cloudPid,
  38. UserSID: gjson.Get(taobaoCfg.KeyData, "accessToken").String(),
  39. SID: "6200f110dca5586962fhjf512d05f0cb731d43045fdd460199979191",
  40. Svc_AK: Svc_AK,
  41. Svc_SK: Svc_SK,
  42. Svc_SID: "6200f110dca5586962fhjf512d05f0cb731d43045fdd460199979191",
  43. User_Web_AK: gjson.Get(taobaoCfg.KeyData, "apiAppKey").String(),
  44. User_Web_SK: gjson.Get(taobaoCfg.KeyData, "apiAppSecret").String(),
  45. ShareInviteCode: gjson.Get(taobaoCfg.KeyData, "channelUrl").String(),
  46. SharePromoIdIOS: gjson.Get(taobaoCfg.KeyData, "ios.shareKey").String(),
  47. SharePromoIdAndroid: gjson.Get(taobaoCfg.KeyData, "android.shareKey").String(),
  48. SharePromoIdWeb: gjson.Get(taobaoCfg.KeyData, "webShareKey").String(),
  49. SelfInviteCode: gjson.Get(taobaoCfg.KeyData, "memberUrl").String(),
  50. SelfPromoIdIOS: gjson.Get(taobaoCfg.KeyData, "ios.selfKey").String(),
  51. SelfPromoIdAndroid: gjson.Get(taobaoCfg.KeyData, "android.selfKey").String(),
  52. SelfPromoIdWeb: gjson.Get(taobaoCfg.KeyData, "webSelfKey").String(),
  53. SelfPromoIdFree: gjson.Get(freeCfg, "taobao_pid").String(),
  54. ActivitySelfPromoIdWeb: gjson.Get(taobaoCfg.KeyData, "activitySelfKey").String(),
  55. ActivitySharePromoIdWeb: gjson.Get(taobaoCfg.KeyData, "activityShareKey").String(),
  56. WechatActivitySelfPromoIdWeb: gjson.Get(taobaoCfg.KeyData, "wechatActivitySelfKey").String(),
  57. WechatActivitySharePromoIdWeb: gjson.Get(taobaoCfg.KeyData, "wechatActivityShareKey").String(),
  58. ChannelUrl: gjson.Get(taobaoCfg.KeyData, "channelUrl").String(),
  59. ShareChannelUrl: gjson.Get(taobaoCfg.KeyData, "channelUrl").String(),
  60. AuthType: 1,
  61. AppletIsAuth: zhios_third_party_utils.IntToStr(taobaoCfg.AppletIsAuth),
  62. }
  63. var authBuyType = gjson.Get(taobaoCfg.KeyData, "authBuyType").String()
  64. cfg.AuthBuyType = authBuyType
  65. if authBuyType == "1" && Platform != md.PLATFORM_WX_APPLET {
  66. //如果是1 就是纯渠道模式 要更换渠道推广位
  67. cfg.SelfPromoIdWeb = gjson.Get(taobaoCfg.KeyData, "webRelationSelfKey").String()
  68. cfg.SelfPromoIdAndroid = gjson.Get(taobaoCfg.KeyData, "androidRelationSelfKey").String()
  69. cfg.SelfPromoIdIOS = gjson.Get(taobaoCfg.KeyData, "iosRelationSelfKey").String()
  70. }
  71. if Platform == md.PLATFORM_WX_APPLET {
  72. if authBuyType == "1" && AccTaobaoShareId > 0 {
  73. //如果是1 就是纯渠道模式 要更换渠道推广位
  74. cfg.SelfPromoIdWeb = gjson.Get(taobaoCfg.KeyData, "webRelationSelfKey").String()
  75. cfg.SelfPromoIdAndroid = gjson.Get(taobaoCfg.KeyData, "androidRelationSelfKey").String()
  76. cfg.SelfPromoIdIOS = gjson.Get(taobaoCfg.KeyData, "iosRelationSelfKey").String()
  77. } else if gjson.Get(taobaoCfg.KeyData, "wechatSelfKey").String() != "" {
  78. cfg.SelfPromoIdWeb = gjson.Get(taobaoCfg.KeyData, "wechatSelfKey").String()
  79. }
  80. }
  81. } else {
  82. if gjson.Get(taobaoCfg.KeyData, "apiAppKey").String() == "" ||
  83. gjson.Get(taobaoCfg.KeyData, "apiAppSecret").String() == "" ||
  84. gjson.Get(taobaoCfg.KeyData, "accessToken").String() == "" {
  85. return nil, errors.New("联盟配置错误")
  86. }
  87. // 自由联盟账号
  88. cfg = &TB{
  89. Web_AK: gjson.Get(taobaoCfg.KeyData, "apiAppKey").String(),
  90. Web_SK: gjson.Get(taobaoCfg.KeyData, "apiAppSecret").String(),
  91. SID: gjson.Get(taobaoCfg.KeyData, "accessToken").String(),
  92. UserSID: gjson.Get(taobaoCfg.KeyData, "accessToken").String(),
  93. Svc_AK: Svc_AK,
  94. Svc_SK: Svc_SK,
  95. CloudPromoIdWeb: cloudPid,
  96. Svc_SID: "6200f110dca5586962fhjf512d05f0cb731d43045fdd460199979191",
  97. User_Web_AK: gjson.Get(taobaoCfg.KeyData, "apiAppKey").String(),
  98. User_Web_SK: gjson.Get(taobaoCfg.KeyData, "apiAppSecret").String(),
  99. ShareInviteCode: gjson.Get(taobaoCfg.KeyData, "channelUrl").String(),
  100. SharePromoIdIOS: gjson.Get(taobaoCfg.KeyData, "ios.shareKey").String(),
  101. SharePromoIdAndroid: gjson.Get(taobaoCfg.KeyData, "android.shareKey").String(),
  102. SharePromoIdWeb: gjson.Get(taobaoCfg.KeyData, "webShareKey").String(),
  103. SelfInviteCode: gjson.Get(taobaoCfg.KeyData, "memberUrl").String(),
  104. SelfPromoIdIOS: gjson.Get(taobaoCfg.KeyData, "ios.selfKey").String(),
  105. SelfPromoIdAndroid: gjson.Get(taobaoCfg.KeyData, "android.selfKey").String(),
  106. SelfPromoIdWeb: gjson.Get(taobaoCfg.KeyData, "webSelfKey").String(),
  107. SelfPromoIdFree: gjson.Get(freeCfg, "taobao_pid").String(),
  108. ActivitySelfPromoIdWeb: gjson.Get(taobaoCfg.KeyData, "activitySelfKey").String(),
  109. ActivitySharePromoIdWeb: gjson.Get(taobaoCfg.KeyData, "activityShareKey").String(),
  110. WechatActivitySelfPromoIdWeb: gjson.Get(taobaoCfg.KeyData, "wechatActivitySelfKey").String(),
  111. WechatActivitySharePromoIdWeb: gjson.Get(taobaoCfg.KeyData, "wechatActivityShareKey").String(),
  112. ChannelUrl: gjson.Get(taobaoCfg.KeyData, "channelUrl").String(),
  113. ShareChannelUrl: gjson.Get(taobaoCfg.KeyData, "channelUrl").String(),
  114. AuthType: 0,
  115. AppletIsAuth: zhios_third_party_utils.IntToStr(taobaoCfg.AppletIsAuth),
  116. }
  117. var authBuyType = gjson.Get(taobaoCfg.KeyData, "authBuyType").String()
  118. cfg.AuthBuyType = authBuyType
  119. if authBuyType == "1" && Platform != md.PLATFORM_WX_APPLET {
  120. //如果是1 就是纯渠道模式 要更换渠道推广位
  121. cfg.SelfPromoIdWeb = gjson.Get(taobaoCfg.KeyData, "webRelationSelfKey").String()
  122. cfg.SelfPromoIdAndroid = gjson.Get(taobaoCfg.KeyData, "androidRelationSelfKey").String()
  123. cfg.SelfPromoIdIOS = gjson.Get(taobaoCfg.KeyData, "iosRelationSelfKey").String()
  124. }
  125. if Platform == md.PLATFORM_WX_APPLET {
  126. if authBuyType == "1" && AccTaobaoShareId > 0 {
  127. //如果是1 就是纯渠道模式 要更换渠道推广位
  128. cfg.SelfPromoIdWeb = gjson.Get(taobaoCfg.KeyData, "webRelationSelfKey").String()
  129. cfg.SelfPromoIdAndroid = gjson.Get(taobaoCfg.KeyData, "androidRelationSelfKey").String()
  130. cfg.SelfPromoIdIOS = gjson.Get(taobaoCfg.KeyData, "iosRelationSelfKey").String()
  131. } else if gjson.Get(taobaoCfg.KeyData, "wechatSelfKey").String() != "" {
  132. cfg.SelfPromoIdWeb = gjson.Get(taobaoCfg.KeyData, "wechatSelfKey").String()
  133. }
  134. }
  135. }
  136. return cfg, nil
  137. }