Accept Merge Request #212: (qidongsheng -> jdshop)
Merge Request: 修改price对比价格,修改美团配送的同步方法 Created By: @漆东升 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/212
This commit is contained in:
@@ -2,6 +2,7 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -568,162 +569,86 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool
|
||||
|
||||
func StoreOpenAll(ctx *jxcontext.Context) {
|
||||
globals.SugarLogger.Debug("StoreOpenAll skuID is start")
|
||||
/* 美团配送的门店营业状态,如果是休息,则京西这边不发单,如果是营业,京西这边状态就是发单
|
||||
美团配送的门店营业状态要通过网页扒取(应该是接了的代码里要找一下)*/
|
||||
/*获取门店信息*/
|
||||
//type DataList struct {
|
||||
// OuterPoiId string `json:"outerPoiId"` //店ID
|
||||
// PoiName string `json:"poiName"` //店名
|
||||
// OpenType int `json:"openType"` //营业状态 1是营业 0是休息
|
||||
//}
|
||||
//type jdData struct {
|
||||
// PageNum int `json:"pageNum"`
|
||||
// PageSize int `json:"pageSize"`
|
||||
// DataList []DataList `json:"dataList"`
|
||||
//}
|
||||
//type JdStore struct {
|
||||
// Code int `json:"code"`
|
||||
// Msg string `json:"msg"`
|
||||
// Data1 jdData `json:"data"`
|
||||
//}
|
||||
//client := &http.Client{}
|
||||
//var StoreInfoList []*JdStore
|
||||
//complate := make(chan bool, 1)
|
||||
//cookie := "_lxsdk_cuid=172c5ed322ac8-081f1f7ebdcbeb-f7d1d38-149c48-172c5ed322ac8; " +
|
||||
// "_lxsdk=172c5ed322ac8-081f1f7ebdcbeb-f7d1d38-149c48-172c5ed322ac8; " +
|
||||
// "uuid=fa1894be8819a84be4ef.1592458555.1.0.0; wm_order_channel=sjzxpc; " +
|
||||
// "cssVersion=82f258e3; utm_source=60376; au_trace_key_net=default; " +
|
||||
// "openh5_uuid=172c5ed322ac8-081f1f7ebdcbeb-f7d1d38-149c48-172c5ed322ac8; " +
|
||||
// "bmm-uuid=dbdc11bf-fcfe-84a0-0586-97e3d7d23ec7; " +
|
||||
// "token=-MfbU7noKEgDWuNA559DeG6LmYZ51CCiH8bYrH-eYuaugCOqJL7863lKoAWfx8HoydOzJE8r9gGM3QJ0IC3niA; " +
|
||||
// "_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) + ""
|
||||
// req, _ := http.NewRequest("POST", url, nil)
|
||||
// req.Header.Set("Cookie", cookie)
|
||||
// req.Header.Set("Referer", "https://peisong.meituan.com/open/admin/accountList")
|
||||
// res, _ := client.Do(req)
|
||||
// //defer res.Body.Close()
|
||||
// if res.Body != nil {
|
||||
// StoreInfo := &JdStore{}
|
||||
// body, _ := ioutil.ReadAll(res.Body)
|
||||
// json.Unmarshal(body, StoreInfo)
|
||||
// if len(StoreInfo.Data1.DataList) == 0 || StoreInfo.Data1.DataList == nil {
|
||||
// complate <- true
|
||||
// }
|
||||
// StoreInfoList = append(StoreInfoList, StoreInfo)
|
||||
// num++
|
||||
// } else {
|
||||
// complate <- true
|
||||
// }
|
||||
// }
|
||||
//}()
|
||||
//select {
|
||||
//case <-complate:
|
||||
// break
|
||||
//}
|
||||
///*StoreInfoList1 map[11691658]=1*/
|
||||
//StoreInfoList1 := make(map[string]int)
|
||||
//for _, store := range StoreInfoList {
|
||||
// for _, data := range store.Data1.DataList {
|
||||
// StoreInfoList1[data.OuterPoiId] = data.OpenType
|
||||
// }
|
||||
//}
|
||||
StoreInfoList, err := api.MtpsAPI.GetStoreStatusAll()
|
||||
StoreInfoList1 := make(map[string]int)
|
||||
/*获取美团门店信息*/
|
||||
StoreInfoList, _ := api.MtpsAPI.GetStoreStatusAll()
|
||||
StoreInfoList2 := make(map[string]string)
|
||||
for _, store := range StoreInfoList {
|
||||
for _, data := range store.DataList {
|
||||
StoreInfoList1[data.OuterPoiID] = data.OpenType
|
||||
StoreInfoList2[data.OuterPoiID] = data.PoiName
|
||||
}
|
||||
}
|
||||
/* fmt.Println(num)
|
||||
fmt.Println(StoreInfoList)*/
|
||||
db := dao.GetDB()
|
||||
/*比较营业状态*/
|
||||
StoreCourierList, err := dao.GetStoreCourierList(db, []int{}, -9, -9)
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
/*如果京西店在美团上没有,那下面有专门方法处理*/
|
||||
if _, ok := StoreInfoList1[StoreCourierList1.VendorStoreID]; ok {
|
||||
/*京西配送状态为配送,美团营业状态是没有营业的*/
|
||||
if StoreCourierList1.Status == 1 && StoreInfoList1[StoreCourierList1.VendorStoreID] == 0 {
|
||||
sl := make(map[string]interface{})
|
||||
sl["status"] = 0
|
||||
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())
|
||||
/*把获取的京西状态和名称存一下*/
|
||||
StoreCourierList, _ := dao.GetStoreCourierList(db, []int{}, model.StoreStatusAll, model.StoreStatusAll)
|
||||
/*循环美团*/
|
||||
for _, StoreInfoList1 := range StoreInfoList {
|
||||
for _, StoreInfoList11 := range StoreInfoList1.DataList {
|
||||
/*循环京西*/
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
/*只比较美团*/
|
||||
if StoreCourierList1.VendorID != model.VendorIDMTPS {
|
||||
continue
|
||||
}
|
||||
/*如果门店ID相同的时候进入判断,一个门店只用判断一次就行*/
|
||||
if StoreCourierList1.VendorStoreID == StoreInfoList11.OuterPoiID {
|
||||
if StoreCourierList1.Status != StoreInfoList11.OpenType {
|
||||
sl := make(map[string]interface{})
|
||||
sl["vendorStoreID"] = StoreInfoList11.OuterPoiID
|
||||
sl["status"] = StoreInfoList11.OpenType
|
||||
globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s",
|
||||
StoreInfoList11.OuterPoiID, StoreInfoList11.PoiName, strconv.Itoa(StoreInfoList11.OpenType), strconv.Itoa(StoreCourierList1.Status))
|
||||
UpdateStoreCourierMap(ctx, nil, StoreCourierList1.StoreID, StoreCourierList1.VendorID, sl, ctx.GetUserName())
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 美团配送的门店是否存在,调用美团配送的api(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店
|
||||
怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/
|
||||
/*获取所有门店信息*/
|
||||
StoreLists, err := dao.GetStoreList(db, nil, nil, []int{}, nil, "")
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
}
|
||||
for _, StoreList := range StoreLists {
|
||||
StoreCourierList, err := dao.GetStoreCourierList(db, []int{StoreList.ID}, model.StoreStatusAll, model.StoreStatusAll)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
test:
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
diff := false
|
||||
StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, "")
|
||||
if StoreLists == nil {
|
||||
globals.SugarLogger.Debugf("StoreID为:%s,在store表未找到", StoreCourierList1.StoreID)
|
||||
continue
|
||||
}
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
if StoreCourierList1.VendorID != model.VendorIDMTPS {
|
||||
continue
|
||||
if StoreCourierList1.VendorID != model.VendorIDMTPS || StoreCourierList1.VendorStoreID == "" {
|
||||
continue
|
||||
}
|
||||
if StoreCourierList1.Status == model.StoreStatusDisabled || StoreCourierList1.Status == model.StoreStatusClosed {
|
||||
continue
|
||||
}
|
||||
/*京西不为空,容错*/
|
||||
//if {
|
||||
/*调用API获取美团的商店信息*/
|
||||
MTPSInfo := new(mtpsapi.ShopInfo)
|
||||
MTPSInfo, _ = api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID)
|
||||
if MTPSInfo == nil {
|
||||
globals.SugarLogger.Debug("美团未找到该门店," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
diff = true
|
||||
}
|
||||
if MTPSInfo != nil && MTPSInfo.ShopName == "" {
|
||||
MTPSInfo.ShopName = StoreInfoList2[MTPSInfo.ShopID]
|
||||
}
|
||||
if MTPSInfo != nil && MTPSInfo.ShopLng != StoreCourierList1.Lng && MTPSInfo.ShopLat == StoreCourierList1.Lat {
|
||||
/*平台上但是坐标不同,解绑*/
|
||||
globals.SugarLogger.Debug("商店与美团配送上的坐标不同," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
return
|
||||
}
|
||||
if StoreCourierList1.Status == model.StoreStatusDisabled {
|
||||
continue
|
||||
}
|
||||
/*京西不为空*/
|
||||
if StoreCourierList1.VendorStoreID != "" {
|
||||
/*调用API获取美团的商店信息*/
|
||||
MTPSInfo, _ := api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID)
|
||||
/*京西有,美团没有*/
|
||||
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
|
||||
}
|
||||
/* 果园和菜市的门店ID可能有重复,导致在美团配送上建的门店只有一方的门店是生效的,可以根据ID在美团配送上查,查到是果园的店,那菜市的店则要重新绑定美团配送(要换一个美团配送的门店ID。不然要重复),
|
||||
反之也要,可根据其他信息,比如门店名(传到平台上的规则都是一样的),坐标等判断是果园的还是菜市的*/
|
||||
|
||||
/*美团上坐标不为空,容错 PS:用名字的话,本身就没办法判断是菜市还是果园*/
|
||||
if MTPSInfo.ShopLng != 0 && MTPSInfo.ShopLat != 0 {
|
||||
if MTPSInfo.ShopLng == StoreList.Lng && MTPSInfo.ShopLat == StoreList.Lat {
|
||||
/*平台上有且坐标相同不做处理*/
|
||||
continue
|
||||
} else {
|
||||
/*平台上但是坐标不同,解绑*/
|
||||
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
|
||||
}
|
||||
}
|
||||
} else { //容错
|
||||
/*美团平台上面没找到,解绑*/
|
||||
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
|
||||
}
|
||||
//} else {
|
||||
// 美团平台上有,京西没得,调用方法可能需要做一些修改
|
||||
// context.TODO()
|
||||
//}
|
||||
}
|
||||
diff = true
|
||||
}
|
||||
if diff {
|
||||
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
return
|
||||
}
|
||||
break test
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debug("StoreOpenAll skuID is Complete")
|
||||
@@ -1420,7 +1345,7 @@ func SetJxPrice(jxSkuInfoDataMulti *dao.StoreSkuNamesInfo, storeId int) (err err
|
||||
/*重新计算京西价格*/
|
||||
for _, values := range jxSkuInfoDataMulti.SkuNames {
|
||||
for _, value := range values.Skus {
|
||||
value.JxPrice = jxutils.CaculatePriceByPricePack(storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage), value.JxPrice)
|
||||
value.JxPrice = jxutils.CaculatePriceByPricePack(storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage), value.BindPrice)
|
||||
}
|
||||
}
|
||||
/*重新计算京西价格*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package cms
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -1259,100 +1260,88 @@ func SyncSkuExperfixAndWatermark(ctx *jxcontext.Context) (err error) {
|
||||
}
|
||||
|
||||
func SetMTPSStatus(ctx *jxcontext.Context) {
|
||||
/* 美团配送的门店营业状态,如果是休息,则京西这边不发单,如果是营业,京西这边状态就是发单
|
||||
美团配送的门店营业状态要通过网页扒取(应该是接了的代码里要找一下)*/
|
||||
/*获取门店信息*/
|
||||
StoreInfoList, err := api.MtpsAPI.GetStoreStatusAll()
|
||||
StoreInfoList1 := make(map[string]int)
|
||||
globals.SugarLogger.Debug("StoreOpenAll skuID is start")
|
||||
/*获取美团门店信息*/
|
||||
StoreInfoList, _ := api.MtpsAPI.GetStoreStatusAll()
|
||||
StoreInfoList2 := make(map[string]string)
|
||||
for _, store := range StoreInfoList {
|
||||
for _, data := range store.DataList {
|
||||
StoreInfoList1[data.OuterPoiID] = data.OpenType
|
||||
StoreInfoList2[data.OuterPoiID] = data.PoiName
|
||||
}
|
||||
}
|
||||
/* fmt.Println(num)
|
||||
fmt.Println(StoreInfoList)*/
|
||||
db := dao.GetDB()
|
||||
/*比较营业状态*/
|
||||
StoreCourierList, err := dao.GetStoreCourierList(db, []int{}, -9, -9)
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
/*如果京西店在美团上没有,那下面有专门方法处理*/
|
||||
if _, ok := StoreInfoList1[StoreCourierList1.VendorStoreID]; ok {
|
||||
/*京西配送状态为配送,美团营业状态是没有营业的*/
|
||||
if StoreCourierList1.Status == 1 && StoreInfoList1[StoreCourierList1.VendorStoreID] == 0 {
|
||||
sl := make(map[string]interface{})
|
||||
sl["status"] = 0
|
||||
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())
|
||||
/*把获取的京西状态和名称存一下*/
|
||||
StoreCourierList, _ := dao.GetStoreCourierList(db, []int{}, model.StoreStatusAll, model.StoreStatusAll)
|
||||
/*循环美团*/
|
||||
for _, StoreInfoList1 := range StoreInfoList {
|
||||
for _, StoreInfoList11 := range StoreInfoList1.DataList {
|
||||
/*循环京西*/
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
/*只比较美团*/
|
||||
if StoreCourierList1.VendorID != model.VendorIDMTPS {
|
||||
continue
|
||||
}
|
||||
/*如果门店ID相同的时候进入判断,一个门店只用判断一次就行*/
|
||||
if StoreCourierList1.VendorStoreID == StoreInfoList11.OuterPoiID {
|
||||
if StoreCourierList1.Status != StoreInfoList11.OpenType {
|
||||
sl := make(map[string]interface{})
|
||||
sl["vendorStoreID"] = StoreInfoList11.OuterPoiID
|
||||
sl["status"] = StoreInfoList11.OpenType
|
||||
globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s",
|
||||
StoreInfoList11.OuterPoiID, StoreInfoList11.PoiName, strconv.Itoa(StoreInfoList11.OpenType), strconv.Itoa(StoreCourierList1.Status))
|
||||
UpdateStoreCourierMap(ctx, nil, StoreCourierList1.StoreID, StoreCourierList1.VendorID, sl, ctx.GetUserName())
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 美团配送的门店是否存在,调用美团配送的api(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店
|
||||
怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/
|
||||
/*获取所有门店信息*/
|
||||
StoreLists, err := dao.GetStoreList(db, nil, nil, []int{}, nil, "")
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
}
|
||||
for _, StoreList := range StoreLists {
|
||||
StoreCourierList, err := dao.GetStoreCourierList(db, []int{StoreList.ID}, model.StoreStatusAll, model.StoreStatusAll)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
test:
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
diff := false
|
||||
StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, "")
|
||||
if StoreLists == nil {
|
||||
globals.SugarLogger.Debugf("StoreID为:%s,在store表未找到", StoreCourierList1.StoreID)
|
||||
continue
|
||||
}
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
if StoreCourierList1.VendorID != model.VendorIDMTPS {
|
||||
continue
|
||||
if StoreCourierList1.VendorID != model.VendorIDMTPS || StoreCourierList1.VendorStoreID == "" {
|
||||
continue
|
||||
}
|
||||
if StoreCourierList1.Status == model.StoreStatusDisabled || StoreCourierList1.Status == model.StoreStatusClosed {
|
||||
continue
|
||||
}
|
||||
/*京西不为空,容错*/
|
||||
//if {
|
||||
/*调用API获取美团的商店信息*/
|
||||
MTPSInfo := new(mtpsapi.ShopInfo)
|
||||
MTPSInfo, _ = api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID)
|
||||
if MTPSInfo == nil {
|
||||
globals.SugarLogger.Debug("美团未找到该门店," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
diff = true
|
||||
}
|
||||
if MTPSInfo != nil && MTPSInfo.ShopName == "" {
|
||||
MTPSInfo.ShopName = StoreInfoList2[MTPSInfo.ShopID]
|
||||
}
|
||||
if MTPSInfo != nil && MTPSInfo.ShopLng != StoreCourierList1.Lng && MTPSInfo.ShopLat == StoreCourierList1.Lat {
|
||||
/*平台上但是坐标不同,解绑*/
|
||||
globals.SugarLogger.Debug("商店与美团配送上的坐标不同," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
return
|
||||
}
|
||||
if StoreCourierList1.Status == model.StoreStatusDisabled {
|
||||
continue
|
||||
}
|
||||
/*京西不为空*/
|
||||
if StoreCourierList1.VendorStoreID != "" {
|
||||
/*调用API获取美团的商店信息*/
|
||||
MTPSInfo, _ := api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID)
|
||||
/*京西有,美团没有*/
|
||||
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
|
||||
}
|
||||
/* 果园和菜市的门店ID可能有重复,导致在美团配送上建的门店只有一方的门店是生效的,可以根据ID在美团配送上查,查到是果园的店,那菜市的店则要重新绑定美团配送(要换一个美团配送的门店ID。不然要重复),
|
||||
反之也要,可根据其他信息,比如门店名(传到平台上的规则都是一样的),坐标等判断是果园的还是菜市的*/
|
||||
|
||||
/*美团上坐标不为空,容错 PS:用名字的话,本身就没办法判断是菜市还是果园*/
|
||||
if MTPSInfo.ShopLng != 0 && MTPSInfo.ShopLat != 0 {
|
||||
if MTPSInfo.ShopLng == StoreList.Lng && MTPSInfo.ShopLat == StoreList.Lat {
|
||||
/*平台上有且坐标相同不做处理*/
|
||||
continue
|
||||
} else {
|
||||
/*平台上但是坐标不同,解绑*/
|
||||
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
|
||||
}
|
||||
}
|
||||
} else { //容错
|
||||
/*美团平台上面没找到,解绑*/
|
||||
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
|
||||
}
|
||||
//} else {
|
||||
// 美团平台上有,京西没得,调用方法可能需要做一些修改
|
||||
// context.TODO()
|
||||
//}
|
||||
}
|
||||
diff = true
|
||||
}
|
||||
if diff {
|
||||
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
return
|
||||
}
|
||||
break test
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debug("StoreOpenAll skuID is Complete")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user