|
|
@@ -7,10 +7,12 @@ import ( |
|
|
|
md2 "applet/app/task/md" |
|
|
|
"applet/app/utils" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" |
|
|
|
md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/jd_union" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/cps_jd" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"github.com/syyongx/php2go" |
|
|
|
"github.com/tidwall/gjson" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
) |
|
|
@@ -29,8 +31,6 @@ func DataCollectCronHaodankuRealNews(types int) { |
|
|
|
fmt.Println("============", time.Since(now)) |
|
|
|
sysCfgDb := db.SysCfgDb{} |
|
|
|
sysCfgDb.Set() |
|
|
|
third_zm_app_key := sysCfgDb.SysCfgGetOneData("third_zm_app_key") |
|
|
|
third_zm_app_secret := sysCfgDb.SysCfgGetOneData("third_zm_app_secret") |
|
|
|
for _, v := range ids { |
|
|
|
for i := 1; i <= num; i++ { |
|
|
|
time.Sleep(time.Microsecond * 10) // 等待10毫秒 |
|
|
@@ -61,6 +61,8 @@ func DataCollectCronHaodankuRealNews(types int) { |
|
|
|
doc, _ := es.FirstDoc(key, uniqueId) |
|
|
|
if doc == nil { |
|
|
|
goodsList := make([]map[string]string, 0) |
|
|
|
hasGoods := 0 |
|
|
|
|
|
|
|
for k1, v1 := range item.List { |
|
|
|
if item.Platform == "1" { |
|
|
|
item.Platform = "淘宝" |
|
|
@@ -76,33 +78,33 @@ func DataCollectCronHaodankuRealNews(types int) { |
|
|
|
"platform_type": platformMap[item.Platform], |
|
|
|
"url": "", |
|
|
|
} |
|
|
|
hasGoods = 1 |
|
|
|
if item.Platform == "京东" && strings.Contains(v1.ItemId, "http") { |
|
|
|
itemId := "" |
|
|
|
if strings.Contains(v1.ItemId, "jd.") { |
|
|
|
time.Sleep(time.Microsecond * 10) // 等待500毫秒 |
|
|
|
//gid = decode |
|
|
|
postData := make(map[string]interface{}) |
|
|
|
// 配置智盟 appkey 和 sk |
|
|
|
postData["appkey"] = third_zm_app_key |
|
|
|
postData["secret_key"] = third_zm_app_secret |
|
|
|
postData["size"] = "2" |
|
|
|
postData["p"] = "1" |
|
|
|
postData["is_url"] = "1" |
|
|
|
postData["keyword"] = v1.ItemId |
|
|
|
jdData, err := zhimeng.NewZhiMengJingDongSDK(). |
|
|
|
SelectFunction("new_getgoods"). |
|
|
|
WithArgs(postData). |
|
|
|
Result() |
|
|
|
param := map[string]interface{}{ |
|
|
|
"pageIndex": "1", |
|
|
|
"pageSize": "10", |
|
|
|
"keyword": v1.ItemId, |
|
|
|
} |
|
|
|
keyArr := map[string]string{ |
|
|
|
"app_key": "444ab671c4d095122916453d09af27fc", |
|
|
|
"access_token": "", |
|
|
|
"app_secret": "aef3c2745cc44194816d0c89c65b3847", |
|
|
|
} |
|
|
|
goods, err := jd_union.SearchGoods(keyArr, param) |
|
|
|
if err != nil { |
|
|
|
utils.FilePutContents("jd", utils.SerializeStr(err)) |
|
|
|
} |
|
|
|
utils.FilePutContents("jd", utils.SerializeStr(goods)) |
|
|
|
if err == nil { |
|
|
|
itemInfo := &md3.MoreDetailResponse{} |
|
|
|
if err := jdData.ToStruct(itemInfo); err == nil { |
|
|
|
itemId = itemInfo.GID |
|
|
|
if itemInfo.GID == "" || itemInfo.GID == "100038437991" { |
|
|
|
itemId = "" |
|
|
|
} |
|
|
|
resp := gjson.Get(goods, "jd_union_open_goods_query_responce.queryResult").String() |
|
|
|
var data cps_jd.JdSearchGoods |
|
|
|
err = json.Unmarshal([]byte(resp), &data) |
|
|
|
for _, v2 := range data.Data { |
|
|
|
itemId = v2.ItemId |
|
|
|
} |
|
|
|
} else { |
|
|
|
itemId = "" |
|
|
|
} |
|
|
|
} |
|
|
|
if itemId != "" { |
|
|
@@ -111,6 +113,7 @@ func DataCollectCronHaodankuRealNews(types int) { |
|
|
|
tmp1["gid"] = "" |
|
|
|
tmp1["is_click"] = "0" |
|
|
|
tmp1["content"] = "\n" + v1.ItemId + "\n" |
|
|
|
hasGoods = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
goodsList = append(goodsList, tmp1) |
|
|
@@ -118,6 +121,9 @@ func DataCollectCronHaodankuRealNews(types int) { |
|
|
|
if v1.Content == "" { |
|
|
|
v1.Content = v1.CouponUrl |
|
|
|
} |
|
|
|
if strings.Contains(v1.Content, "http") { |
|
|
|
hasGoods = 1 |
|
|
|
} |
|
|
|
tmp1 := map[string]string{ |
|
|
|
"content": v1.Content, |
|
|
|
"gid": "", |
|
|
@@ -131,7 +137,9 @@ func DataCollectCronHaodankuRealNews(types int) { |
|
|
|
goodsList = append(goodsList, tmp1) |
|
|
|
} |
|
|
|
} |
|
|
|
tmp.Content = utils.SerializeStr(goodsList) |
|
|
|
if hasGoods == 1 { |
|
|
|
tmp.Content = utils.SerializeStr(goodsList) |
|
|
|
} |
|
|
|
createDocRet, err := es.CreateDoc(key, uniqueId, tmp) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|