|
|
@@ -13,6 +13,7 @@ import ( |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok" |
|
|
|
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils/cache" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/vip" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng" |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
@@ -53,6 +54,7 @@ func TurnChainFeatures(eg *xorm.Engine, officialEg, zhimengEg *xorm.Engine, tikT |
|
|
|
} |
|
|
|
tikTokBase["acc_jd_share_id"] = userProfile.AccJdCloudId |
|
|
|
tikTokBase["acc_pdd_self_id"] = userProfile.AccPddSelfId |
|
|
|
tikTokBase["acc_vip_self_id"] = userProfile.AccVipShareId |
|
|
|
} |
|
|
|
tikTokBase["uid"] = zhios_third_party_utils.IntToStr(user.Uid) |
|
|
|
tikTokBase["gid"] = goodsId |
|
|
@@ -74,6 +76,8 @@ func TurnChainFeatures(eg *xorm.Engine, officialEg, zhimengEg *xorm.Engine, tikT |
|
|
|
|
|
|
|
case md.PVD_PDD: |
|
|
|
urls, err = PDDTurnChain(eg, dbName, tikTokBase) |
|
|
|
case md.PVD_VIP: |
|
|
|
urls, err = VipTurnChain(eg, dbName, tikTokBase) |
|
|
|
default: |
|
|
|
return nil, errors.New("失败") |
|
|
|
} |
|
|
@@ -145,6 +149,40 @@ func JDTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*md.Co |
|
|
|
} |
|
|
|
return urls, nil |
|
|
|
} |
|
|
|
func VipTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*md.ConvertedUrls, error) { |
|
|
|
// 初始化vip配置 |
|
|
|
pid := args["acc_vip_share_id"] |
|
|
|
openId := pid |
|
|
|
pidType := "cloud" |
|
|
|
auth, _ := db.SysUnionByPVDByUse(eg, dbName, "vip") |
|
|
|
unionType := "" |
|
|
|
if auth != nil { |
|
|
|
if auth.AuthType == 2 { |
|
|
|
pid = zhimeng.GetWphPid(zhios_third_party_utils.StrToInt(args["uid"]), pidType, dbName) |
|
|
|
openId = pid |
|
|
|
} |
|
|
|
unionType = zhios_third_party_utils.IntToStr(auth.AuthType) |
|
|
|
} |
|
|
|
var urls *md.ConvertedUrls |
|
|
|
var err error |
|
|
|
if unionType == "2" { |
|
|
|
urls, err = zhimeng.OwnWphConvertUrl(auth, |
|
|
|
args["gid"], |
|
|
|
pid, |
|
|
|
"", "vendoapi", openId, "1") |
|
|
|
} else { |
|
|
|
urls, err = zhimeng.VipConvertUrl( |
|
|
|
db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_AK), |
|
|
|
db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_SK), |
|
|
|
args["gid"], |
|
|
|
pid, |
|
|
|
"", "vendoapi", openId, "1") |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return urls, nil |
|
|
|
} |
|
|
|
|
|
|
|
// pdd转链 |
|
|
|
func PDDTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*md.ConvertedUrls, error) { |
|
|
@@ -382,23 +420,38 @@ func ConvertUrl(eg *xorm.Engine, officialEg, zhimengEg *xorm.Engine, args map[st |
|
|
|
|
|
|
|
} |
|
|
|
case md.PVD_VIP: |
|
|
|
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key") |
|
|
|
if thirdZmAppKeyData == nil || err != nil { |
|
|
|
return urls, err |
|
|
|
} |
|
|
|
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret") |
|
|
|
if thirdZmAppSecretData == nil || err != nil { |
|
|
|
return urls, err |
|
|
|
} |
|
|
|
// 初始化vip配置 |
|
|
|
pid := args["master_id"] + "_vip_cloud_" + args["uid"] |
|
|
|
openId := args["master_id"] + "_vip_" + args["uid"] |
|
|
|
urls, err = zhimeng.VipConvertUrl( |
|
|
|
thirdZmAppKeyData.Val, |
|
|
|
thirdZmAppSecretData.Val, |
|
|
|
args["gid"], |
|
|
|
pid, |
|
|
|
"", "vendoapi", openId, "1") |
|
|
|
union, _ := db.SysUnionByPVDByUse(eg, args["master_id"], "vip") |
|
|
|
authType := "0" |
|
|
|
if union != nil && union.AuthType == 2 { |
|
|
|
pid = "own_cloud_" + args["master_id"] + "_" + args["uid"] |
|
|
|
authType = "2" |
|
|
|
openId = pid |
|
|
|
} |
|
|
|
if authType == "2" { |
|
|
|
urls, err = zhimeng.OwnWphConvertUrl(union, args["gid"], |
|
|
|
pid, |
|
|
|
"", "vendoapi", openId, "1") |
|
|
|
} else { |
|
|
|
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key") |
|
|
|
if thirdZmAppKeyData == nil || err != nil { |
|
|
|
return urls, err |
|
|
|
} |
|
|
|
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret") |
|
|
|
if thirdZmAppSecretData == nil || err != nil { |
|
|
|
return urls, err |
|
|
|
} |
|
|
|
|
|
|
|
urls, err = zhimeng.VipConvertUrl( |
|
|
|
thirdZmAppKeyData.Val, |
|
|
|
thirdZmAppSecretData.Val, |
|
|
|
args["gid"], |
|
|
|
pid, |
|
|
|
"", "vendoapi", openId, "1") |
|
|
|
} |
|
|
|
|
|
|
|
case md.PVD_PDD: |
|
|
|
pid := args["acc_pdd_self_id"] |
|
|
|
union, _ := db.SysUnionByPVDByUse(eg, args["master_id"], "pdd") |
|
|
@@ -843,6 +896,8 @@ func FindTaobaoWord(eg *xorm.Engine, officialEg, zhimengEg *xorm.Engine, tmp map |
|
|
|
} |
|
|
|
goodsParam["acc_jd_share_id"] = userProfile.AccJdCloudId |
|
|
|
goodsParam["acc_pdd_self_id"] = userProfile.AccPddSelfId |
|
|
|
goodsParam["acc_vip_self_id"] = userProfile.AccVipShareId |
|
|
|
|
|
|
|
} |
|
|
|
//判断如果是有纯字母 字母+数字的内容 并且没有链接的 都调淘宝接口 |
|
|
|
split := regexp.MustCompile("[a-zA-Z0-9]{9,14}").FindAllString(reqCount, -1) |
|
|
@@ -1165,6 +1220,8 @@ func CheckKuaishouWord(eg *xorm.Engine, officialEg, zhimengEg *xorm.Engine, dbNa |
|
|
|
} |
|
|
|
args["acc_jd_share_id"] = userProfile.AccJdCloudId |
|
|
|
args["acc_pdd_self_id"] = userProfile.AccPddSelfId |
|
|
|
args["acc_vip_self_id"] = userProfile.AccVipShareId |
|
|
|
|
|
|
|
} |
|
|
|
args["gid"] = itemData.GoodsID |
|
|
|
args["master_id"] = dbName |
|
|
@@ -1225,7 +1282,13 @@ func ProcessTurnChainByGoodsId(eg *xorm.Engine, officialEg *xorm.Engine, tmp map |
|
|
|
} else { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
case md.PVD_VIP: |
|
|
|
vipResponse, vipProvider := VIPByGoodsID(eg, officialEg, tmp, goodsId, url, mdData) |
|
|
|
if vipResponse != nil && vipProvider != "" { |
|
|
|
return vipResponse, vipProvider, "", "", "", "", "", mdData |
|
|
|
} else { |
|
|
|
return |
|
|
|
} |
|
|
|
case md.PVD_PDD: |
|
|
|
pddResponse, pddProvider := PDDByGoodsId(eg, officialEg, tmp, goodsId, url, mdData) |
|
|
|
if pddResponse != nil && pddProvider != "" { |
|
|
@@ -1458,6 +1521,90 @@ func PDDByGoodsId(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]strin |
|
|
|
|
|
|
|
return nil, "" |
|
|
|
} |
|
|
|
func VIPByGoodsID(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]string, goodsId, url string, mdData *md.MoreDetailResponse) (*md.ProductDetailResponse, string) { |
|
|
|
postData := make(map[string]interface{}) |
|
|
|
union, _ := db.SysUnionByPVDByUse(eg, tmp["master_id"], "vip") |
|
|
|
if zhios_third_party_utils.StrToInt(goodsId) > 0 { |
|
|
|
postData["gid"] = goodsId |
|
|
|
} else { |
|
|
|
postData1 := make(map[string]interface{}) |
|
|
|
postData1["url"] = url |
|
|
|
postData["appkey"] = db.SysCfgGetWithDb(eg, tmp["master_id"], md.KEY_CFG_ZM_AK) |
|
|
|
postData["secret_key"] = db.SysCfgGetWithDb(eg, tmp["master_id"], md.KEY_CFG_ZM_SK) |
|
|
|
|
|
|
|
if union != nil { |
|
|
|
if union.AuthType == 2 { |
|
|
|
uid := zhios_third_party_utils.StrToInt(tmp["uid"]) |
|
|
|
postData["pid"] = zhimeng.GetWphPid(uid, "self", tmp["master_id"]) |
|
|
|
postData["openId"] = postData["pid"] |
|
|
|
} |
|
|
|
postData["union_type"] = zhios_third_party_utils.IntToStr(union.AuthType) |
|
|
|
} |
|
|
|
if postData["union_type"] == "2" { |
|
|
|
gid := zhimeng.OwnWphParseUrl(union, url) |
|
|
|
postData["gid"] = gid |
|
|
|
} else { |
|
|
|
//改 |
|
|
|
vipData1, err1 := vip.NewZhiMengVIPSDK(). |
|
|
|
SelectFunction("parse_url"). |
|
|
|
WithArgs(postData1). |
|
|
|
Result() |
|
|
|
if err1 != nil || vipData1 == nil { |
|
|
|
//e.OutErr(c, e.ERR_API_RESPONSE, e.NewErr(400, "商品已下架")) |
|
|
|
return nil, "" |
|
|
|
} |
|
|
|
stringInterface := vipData1.VipToMapStringInterface() |
|
|
|
postData["gid"] = stringInterface["gid"] |
|
|
|
} |
|
|
|
} |
|
|
|
postData["appkey"] = db.SysCfgGetWithDb(eg, tmp["master_id"], md.KEY_CFG_ZM_AK) |
|
|
|
postData["secret_key"] = db.SysCfgGetWithDb(eg, tmp["master_id"], md.KEY_CFG_ZM_SK) |
|
|
|
postData["realCall"] = "1" |
|
|
|
postData["openId"] = "default_open_id" |
|
|
|
postData["pid"] = "default_pid" |
|
|
|
if tmp["acc_vip_self_id"] != "" { |
|
|
|
postData["openId"] = strings.ReplaceAll(tmp["acc_vip_self_id"], "self_", "") |
|
|
|
postData["pid"] = tmp["acc_vip_self_id"] |
|
|
|
} |
|
|
|
if union != nil { |
|
|
|
if union.AuthType == 2 { |
|
|
|
uid := zhios_third_party_utils.StrToInt(tmp["uid"]) |
|
|
|
postData["pid"] = zhimeng.GetWphPid(uid, "self", tmp["master_id"]) |
|
|
|
postData["openId"] = postData["pid"] |
|
|
|
} |
|
|
|
postData["union_type"] = zhios_third_party_utils.IntToStr(union.AuthType) |
|
|
|
} |
|
|
|
if postData["union_type"] == "2" { |
|
|
|
slist := zhimeng.OwnWphDetail(union, postData) |
|
|
|
err := zhimeng.OwnPddToStruct(slist, mdData) |
|
|
|
if err != nil { |
|
|
|
return nil, "" |
|
|
|
} |
|
|
|
} else { |
|
|
|
//改 |
|
|
|
vipData, err := vip.NewZhiMengVIPSDK(). |
|
|
|
SelectFunction("goods_info"). |
|
|
|
WithArgs(postData). |
|
|
|
Result() |
|
|
|
if err != nil || vipData == nil { |
|
|
|
//e.OutErr(c, e.ERR_API_RESPONSE, e.NewErr(400, "商品已下架")) |
|
|
|
return nil, "" |
|
|
|
} |
|
|
|
// to struct |
|
|
|
err = vipData.ToObject().ToStruct(mdData) |
|
|
|
if err != nil { |
|
|
|
//e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
return nil, "" |
|
|
|
} |
|
|
|
} |
|
|
|
if mdData != nil { |
|
|
|
// to response |
|
|
|
r := &md.ProductDetailResponse{} |
|
|
|
r.GoodID = mdData.GID |
|
|
|
return r, md.PVD_VIP |
|
|
|
} |
|
|
|
return nil, "" |
|
|
|
} |
|
|
|
|
|
|
|
func OfficialRecommendUrl(eg *xorm.Engine, tmp map[string]string, sourceType string, isShare int, isWxMini int, lat float64, lng float64, ActivityId, linkType string, isShowMiniUrl int, activityPlatformUrl string) (*md.OfficialRecommendUrl, error) { |
|
|
|
var ( |
|
|
|