修改方法调用

This commit is contained in:
qidongsheng
2020-06-29 14:57:00 +08:00
parent 8ec989aded
commit 04bab11361

View File

@@ -589,10 +589,7 @@ func StoreOpenAll(ctx *jxcontext.Context) {
} }
client := &http.Client{} client := &http.Client{}
var StoreInfoList []*JdStore var StoreInfoList []*JdStore
num := 1 complate := make(chan bool, 1)
for {
/* cookie还需要修改*/
/* context.TODO()*/
cookie := "_lxsdk_cuid=172c5ed322ac8-081f1f7ebdcbeb-f7d1d38-149c48-172c5ed322ac8; " + cookie := "_lxsdk_cuid=172c5ed322ac8-081f1f7ebdcbeb-f7d1d38-149c48-172c5ed322ac8; " +
"_lxsdk=172c5ed322ac8-081f1f7ebdcbeb-f7d1d38-149c48-172c5ed322ac8; " + "_lxsdk=172c5ed322ac8-081f1f7ebdcbeb-f7d1d38-149c48-172c5ed322ac8; " +
"uuid=fa1894be8819a84be4ef.1592458555.1.0.0; wm_order_channel=sjzxpc; " + "uuid=fa1894be8819a84be4ef.1592458555.1.0.0; wm_order_channel=sjzxpc; " +
@@ -601,25 +598,35 @@ func StoreOpenAll(ctx *jxcontext.Context) {
"bmm-uuid=dbdc11bf-fcfe-84a0-0586-97e3d7d23ec7; " + "bmm-uuid=dbdc11bf-fcfe-84a0-0586-97e3d7d23ec7; " +
"token=-MfbU7noKEgDWuNA559DeG6LmYZ51CCiH8bYrH-eYuaugCOqJL7863lKoAWfx8HoydOzJE8r9gGM3QJ0IC3niA; " + "token=-MfbU7noKEgDWuNA559DeG6LmYZ51CCiH8bYrH-eYuaugCOqJL7863lKoAWfx8HoydOzJE8r9gGM3QJ0IC3niA; " +
"_lxsdk_s=172fa436aed-861-103-c9b%7C%7C7" "_lxsdk_s=172fa436aed-861-103-c9b%7C%7C7"
go func() {
num := 1
for {
/* cookie还需要修改*/
/* context.TODO()*/
url := "https://peisong.meituan.com/api/haikuiopen/haikui/open/partner/poi/search?pageSize=20&pageNum=" + strconv.Itoa(num) + "" url := "https://peisong.meituan.com/api/haikuiopen/haikui/open/partner/poi/search?pageSize=20&pageNum=" + strconv.Itoa(num) + ""
req, _ := http.NewRequest("POST", url, nil) req, _ := http.NewRequest("POST", url, nil)
req.Header.Set("Cookie", cookie) req.Header.Set("Cookie", cookie)
req.Header.Set("Referer", "https://peisong.meituan.com/open/admin/accountList") req.Header.Set("Referer", "https://peisong.meituan.com/open/admin/accountList")
res, _ := client.Do(req) res, _ := client.Do(req)
defer res.Body.Close() //defer res.Body.Close()
if res.Body != nil { if res.Body != nil {
StoreInfo := &JdStore{} StoreInfo := &JdStore{}
body, _ := ioutil.ReadAll(res.Body) body, _ := ioutil.ReadAll(res.Body)
json.Unmarshal(body, StoreInfo) json.Unmarshal(body, StoreInfo)
StoreInfoList = append(StoreInfoList, StoreInfo) if len(StoreInfo.Data1.DataList) == 0 || StoreInfo.Data1.DataList == nil {
if StoreInfo.Data1.DataList == nil { complate <- true
break
} }
StoreInfoList = append(StoreInfoList, StoreInfo)
num++ num++
} else { } else {
break complate <- true
} }
} }
}()
select {
case <-complate:
break
}
/*StoreInfoList1 map[11691658]=1*/ /*StoreInfoList1 map[11691658]=1*/
StoreInfoList1 := make(map[string]int) StoreInfoList1 := make(map[string]int)
for _, store := range StoreInfoList { for _, store := range StoreInfoList {
@@ -631,15 +638,21 @@ func StoreOpenAll(ctx *jxcontext.Context) {
fmt.Println(StoreInfoList)*/ fmt.Println(StoreInfoList)*/
db := dao.GetDB() db := dao.GetDB()
/*比较营业状态*/ /*比较营业状态*/
StoreCourierList, err := dao.GetStoreCourierList(db, []int{0}, -9, -9) StoreCourierList, err := dao.GetStoreCourierList(db, []int{}, -9, -9)
for _, StoreCourierList1 := range StoreCourierList { for _, StoreCourierList1 := range StoreCourierList {
/*如果京西店在美团上没有,那下面有专门方法处理*/
if _, ok := StoreInfoList1[StoreCourierList1.VendorStoreID]; ok { if _, ok := StoreInfoList1[StoreCourierList1.VendorStoreID]; ok {
/*营业状态是没有营业的,但是京西却关联美团了*/ /*京西配送状态为配送,美团营业状态是没有营业的*/
if StoreInfoList1[StoreCourierList1.VendorStoreID] == 0 { if StoreCourierList1.Status == 1 && StoreInfoList1[StoreCourierList1.VendorStoreID] == 0 {
//调用方法解绑 {"status":0,"vendorStoreID":"667222"}
sl := make(map[string]interface{}) sl := make(map[string]interface{})
sl["status"] = 0 sl["status"] = 0
sl["vendorStoreID"] = "667222" sl["vendorStoreID"] = StoreCourierList1.VendorStoreID
UpdateStoreCourierMap(ctx, nil, StoreCourierList1.StoreID, StoreCourierList1.VendorID, sl, ctx.GetUserName())
/*京西配送状态为不配送,美团营业状态是营业的*/
} else if StoreCourierList1.Status != 1 && StoreInfoList1[StoreCourierList1.VendorStoreID] == 1 {
sl := make(map[string]interface{})
sl["status"] = 1
sl["vendorStoreID"] = StoreCourierList1.VendorStoreID
UpdateStoreCourierMap(ctx, nil, StoreCourierList1.StoreID, StoreCourierList1.VendorID, sl, ctx.GetUserName()) UpdateStoreCourierMap(ctx, nil, StoreCourierList1.StoreID, StoreCourierList1.VendorID, sl, ctx.GetUserName())
} }
} }
@@ -660,23 +673,38 @@ func StoreOpenAll(ctx *jxcontext.Context) {
if StoreCourierList1.VendorID != 102 { if StoreCourierList1.VendorID != 102 {
continue continue
} }
if StoreCourierList1.Status == -2 {
continue
}
/*京西不为空*/ /*京西不为空*/
if StoreCourierList1.VendorStoreID != "" { if StoreCourierList1.VendorStoreID != "" {
/*调用API获取美团的商店信息*/ /*调用API获取美团的商店信息*/
MTPSInfo, _ := api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID) MTPSInfo, _ := api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID)
if MTPSInfo.ShopID != "" { /*京西有,美团没有*/
if MTPSInfo == nil {
fmt.Println(strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑")
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
globals.SugarLogger.Debug(err.Error())
return
}
continue
}
/*美团上商店名不为空,容错*/
if MTPSInfo.ShopName != "" {
if MTPSInfo.ShopName == StoreList.Name { if MTPSInfo.ShopName == StoreList.Name {
/*平台上有且名字相同*/ /*平台上有且名字相同不做处理*/
continue continue
} else { } else {
/*平台上但是名字不同,解绑*/ /*平台上但是名字不同,解绑*/
fmt.Println(strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑")
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil { if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
globals.SugarLogger.Debug(err.Error()) globals.SugarLogger.Debug(err.Error())
return return
} }
} }
} else { } else { //容错
/*美团平台上面没找到,解绑*/ /*美团平台上面没找到,解绑*/
fmt.Println(strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑")
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil { if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
globals.SugarLogger.Debug(err.Error()) globals.SugarLogger.Debug(err.Error())
return return