From baf3c242616b0486391bd9585e048150facfe333 Mon Sep 17 00:00:00 2001 From: qidongsheng Date: Thu, 2 Jul 2020 14:27:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku_check.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/jxstore/cms/store_sku_check.go b/business/jxstore/cms/store_sku_check.go index 72636a90f..fd2a91d82 100644 --- a/business/jxstore/cms/store_sku_check.go +++ b/business/jxstore/cms/store_sku_check.go @@ -608,7 +608,7 @@ func StoreOpenAll(ctx *jxcontext.Context) { /* 美团配送的门店是否存在,调用美团配送的api(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店 怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/ /*获取所有门店信息*/ -test: + //test: for _, StoreCourierList1 := range StoreCourierList { diff := false StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, "") @@ -648,7 +648,7 @@ test: globals.SugarLogger.Debug(err.Error()) return } - break test + //break test } } globals.SugarLogger.Debug("StoreOpenAll skuID is Complete") From e79c42f1a7a80f678225529840f2d3501d028dc4 Mon Sep 17 00:00:00 2001 From: qidongsheng Date: Thu, 2 Jul 2020 15:07:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=85=8D=E9=80=81=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku_check.go | 295 ++++++++++++------------ 1 file changed, 147 insertions(+), 148 deletions(-) diff --git a/business/jxstore/cms/store_sku_check.go b/business/jxstore/cms/store_sku_check.go index fd2a91d82..15fcc7cbc 100644 --- a/business/jxstore/cms/store_sku_check.go +++ b/business/jxstore/cms/store_sku_check.go @@ -2,8 +2,6 @@ package cms import ( "fmt" - "git.rosy.net.cn/baseapi/platformapi/mtpsapi" - "git.rosy.net.cn/jx-callback/globals/api" "strconv" "strings" "sync" @@ -567,92 +565,92 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool } } -func StoreOpenAll(ctx *jxcontext.Context) { - 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 { - StoreInfoList2[data.OuterPoiID] = data.PoiName - } - } - db := dao.GetDB() - /*比较营业状态*/ - /*把获取的京西状态和名称存一下*/ - 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(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店 - 怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/ - /*获取所有门店信息*/ - //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 - } - 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 - } - 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") -} +//func StoreOpenAll(ctx *jxcontext.Context) { +//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 { +// StoreInfoList2[data.OuterPoiID] = data.PoiName +// } +//} +//db := dao.GetDB() +///*比较营业状态*/ +///*把获取的京西状态和名称存一下*/ +//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(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店 +// 怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/ +///*获取所有门店信息*/ +////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 +// } +// 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 +// } +// 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") +//} //func StoreOpenAll(ctx *jxcontext.Context) { //db := dao.GetDB() @@ -807,62 +805,62 @@ func StoreOpenAll(ctx *jxcontext.Context) { //} //} -//}func StoreOpenAll(ctx *jxcontext.Context) { -// db := dao.GetDB() -// StoreLists, err := dao.GetStoreList(db, nil, nil, []int{1}, nil, "") -// if err != nil { -// globals.SugarLogger.Debugf("商店列表获取失败") -// } -// var StoreMapLists []*model.StoreMap -// for _, StoreList := range StoreLists { -// if StoreMapLists, err = dao.GetStoresMapList(db, []int{0, 1, 3}, []int{StoreList.ID}, nil, 1, -1, "", ""); err != nil { -// globals.SugarLogger.Debugf("商店列表获取失败") -// } -// if len(StoreMapLists) > 0 { -// /*将map查询的结果全部放进数组*/ -// for _, StoreMapList := range StoreMapLists { -// /*二元运算符*/ -// StoreMapList.SyncStatus = StoreMapList.SyncStatus | model.SyncFlagModifiedMask -// StoreMapList.UpdatedAt = time.Now() -// StoreMapList.LastOperator = ctx.GetUserName() -// dao.UpdateEntity(db, StoreMapList, "SyncStatus", "UpdatedAt", "LastOperator") -// //} -// /*同步*/ -// if _, err = CurVendorSync.SyncStore(ctx, db, StoreMapList.VendorID, StoreList.ID, false, ctx.GetUserName()); err != nil { -// globals.SugarLogger.Debugf("同步失败") -// } -// } -// } -// if StoreMapLists, err = dao.GetStoresMapList(db, []int{9}, []int{StoreList.ID}, nil, 1, -1, "", ""); err != nil { -// globals.SugarLogger.Debugf("商店列表获取失败") -// } -// if len(StoreMapLists) == 0 { -// /*遍历,绑定*/ -// Map := &model.StoreMap{} -// Map.VendorStoreID = strconv.Itoa(StoreList.ID) -// Map.AutoPickup = 1 -// Map.DeliveryCompetition = 1 -// Map.PricePercentage = 100 -// Map.IsSync = 1 -// Map.PricePercentagePack = "京西100-100" -// Map.DeliveryFeeDeductionSill = 0 -// Map.DeliveryFeeDeductionFee = 0 -// Map.IsOrder = 0 -// if _, err := AddStoreVendorMap(ctx, db, 9, "", StoreList.ID, Map); err != nil { -// globals.SugarLogger.Debugf("AddStoreVendorMap调用出错,StoreID是" + strconv.Itoa(StoreList.ID)) -// globals.SugarLogger.Debugf(err.Error()) -// } -// } -// /*改配送范围*/ -// //deliverrangetype 3 -// //deliverrange 3000 -// StoreList.DeliveryRange = "3000" -// StoreList.DeliveryRangeType = 3 -// StoreList.UpdatedAt = time.Now() -// StoreList.LastOperator = ctx.GetUserName() -// dao.UpdateEntity(db, StoreList, "DeliveryRange", "DeliveryRangeType", "LastOperator", "UpdatedAt") -// } -//} +func StoreOpenAll(ctx *jxcontext.Context) { + db := dao.GetDB() + StoreLists, err := dao.GetStoreList(db, nil, nil, []int{1}, nil, "") + if err != nil { + globals.SugarLogger.Debugf("商店列表获取失败") + } + var StoreMapLists []*model.StoreMap + for _, StoreList := range StoreLists { + if StoreMapLists, err = dao.GetStoresMapList(db, []int{0, 1, 3}, []int{StoreList.ID}, nil, 1, -1, "", ""); err != nil { + globals.SugarLogger.Debugf("商店列表获取失败") + } + if len(StoreMapLists) > 0 { + /*将map查询的结果全部放进数组*/ + for _, StoreMapList := range StoreMapLists { + /*二元运算符*/ + StoreMapList.SyncStatus = StoreMapList.SyncStatus | model.SyncFlagModifiedMask + StoreMapList.UpdatedAt = time.Now() + StoreMapList.LastOperator = ctx.GetUserName() + dao.UpdateEntity(db, StoreMapList, "SyncStatus", "UpdatedAt", "LastOperator") + //} + /*同步*/ + if _, err = CurVendorSync.SyncStore(ctx, db, StoreMapList.VendorID, StoreList.ID, false, ctx.GetUserName()); err != nil { + globals.SugarLogger.Debugf("同步失败") + } + } + } + if StoreMapLists, err = dao.GetStoresMapList(db, []int{9}, []int{StoreList.ID}, nil, 1, -1, "", ""); err != nil { + globals.SugarLogger.Debugf("商店列表获取失败") + } + if len(StoreMapLists) == 0 { + /*遍历,绑定*/ + Map := &model.StoreMap{} + Map.VendorStoreID = strconv.Itoa(StoreList.ID) + Map.AutoPickup = 1 + Map.DeliveryCompetition = 1 + Map.PricePercentage = 100 + Map.IsSync = 1 + Map.PricePercentagePack = "京西100-100" + Map.DeliveryFeeDeductionSill = 0 + Map.DeliveryFeeDeductionFee = 0 + Map.IsOrder = 0 + if _, err := AddStoreVendorMap(ctx, db, 9, "", StoreList.ID, Map); err != nil { + globals.SugarLogger.Debugf("AddStoreVendorMap调用出错,StoreID是" + strconv.Itoa(StoreList.ID)) + globals.SugarLogger.Debugf(err.Error()) + } + } + /*改配送范围*/ + //deliverrangetype 3 + //deliverrange 3000 + StoreList.DeliveryRange = "3000" + StoreList.DeliveryRangeType = 3 + StoreList.UpdatedAt = time.Now() + StoreList.LastOperator = ctx.GetUserName() + dao.UpdateEntity(db, StoreList, "DeliveryRange", "DeliveryRangeType", "LastOperator", "UpdatedAt") + } +} func TestDiff(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) { baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor start time: %v", time.Now()) @@ -968,18 +966,19 @@ func TestDiff(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) { if multiFlag == false { jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1) /*重新计算价格*/ - SetJxPrice(jxSkuInfoDataMulti, storeID) + SetJxPrice(jxSkuInfoDataMulti, storeID, vendorID) filterJxSkuInfoMapMulti = GetFilterJxSkuInfoMap(jxSkuInfoDataMulti.SkuNames) //map[京西商品ID:StoreSkuNameExt] multiFlag = true } } else { if singleFlag == false { jxSkuInfoDataSingle, _ = GetStoreSkus(ctx, storeID, nil, true, "", true, false, map[string]interface{}{}, 0, -1) + /*重新计算价格*/ + SetJxPrice(jxSkuInfoDataSingle, storeID, vendorID) filterJxSkuInfoMapSingle = GetFilterJxSkuInfoMap(jxSkuInfoDataSingle.SkuNames) //map[京西商品ID:StoreSkuNameExt] singleFlag = true } } - vendorStoreID := vendorListValue.VendorStoreID baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor storeID:%d vendorID:%d vendorStoreID:%s vendorListValue:%v", storeID, vendorID, vendorStoreID, vendorListValue) @@ -1335,9 +1334,9 @@ func WriteToExcel(task *tasksch.SeqTask, data map[int][]DiffData, depotData map[ } } -func SetJxPrice(jxSkuInfoDataMulti *dao.StoreSkuNamesInfo, storeId int) (err error) { +func SetJxPrice(jxSkuInfoDataMulti *dao.StoreSkuNamesInfo, storeId int, Vendorid int) (err error) { db := dao.GetDB() - storeDetail, err := dao.GetStoreDetail(dao.GetDB(), storeId, model.VendorIDJX) + storeDetail, err := dao.GetStoreDetail(dao.GetDB(), storeId, Vendorid) if err != nil { dao.Rollback(db) return err From 74b48efba278e7e393c4695d5b88158dd78aaab2 Mon Sep 17 00:00:00 2001 From: qidongsheng Date: Thu, 2 Jul 2020 15:38:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E6=AF=94?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=92=8C=E7=BE=8E=E5=9B=A2=E9=85=8D=E9=80=81?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=96=B9=E6=B3=95=E7=9A=84=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku_check.go | 400 ++++++++++++------------ business/jxstore/cms/sync.go | 4 +- 2 files changed, 201 insertions(+), 203 deletions(-) diff --git a/business/jxstore/cms/store_sku_check.go b/business/jxstore/cms/store_sku_check.go index 15fcc7cbc..9a004cc6c 100644 --- a/business/jxstore/cms/store_sku_check.go +++ b/business/jxstore/cms/store_sku_check.go @@ -2,6 +2,8 @@ package cms import ( "fmt" + "git.rosy.net.cn/baseapi/platformapi/mtpsapi" + "git.rosy.net.cn/jx-callback/globals/api" "strconv" "strings" "sync" @@ -361,14 +363,8 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin /*写京西skuIDStr*/ //utils.Writelog("skuIDStr" + skuIDStr) var jxSkuDetailName string - //多规格商品不用比较数量单位 - if jxSkuInfo.IsSpu == 0 { - //jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..) - jxSkuDetailName = jxutils.ComposeSkuNameOriginal(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus[0].Comment, jxSkuInfo.SkuName.Unit, jxSkuInfo.Skus[0].SkuSpecQuality, jxSkuInfo.Skus[0].SkuSpecUnit, 0) - } else { - //jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..) - jxSkuDetailName = jxutils.ComposeSkuNameOriginal(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus[0].Comment, "", jxSkuInfo.Skus[0].SkuSpecQuality, "", 0) - } + //jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..) + jxSkuDetailName = jxutils.ComposeSkuNameOriginal(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus[0].Comment, jxSkuInfo.SkuName.Unit, jxSkuInfo.Skus[0].SkuSpecQuality, jxSkuInfo.Skus[0].SkuSpecUnit, 0) //utils.Writelog("jxSkuDetailName:" + jxSkuDetailName) //jxSkuSaleStatus : 商品状态 ,skustatus 优先级高于 StoreSkuStatus jxSkuSaleStatus := jxutils.MergeSkuStatus(jxSkuInfo.Skus[0].SkuStatus, jxSkuInfo.Skus[0].StoreSkuStatus) @@ -565,92 +561,92 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool } } -//func StoreOpenAll(ctx *jxcontext.Context) { -//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 { -// StoreInfoList2[data.OuterPoiID] = data.PoiName -// } -//} -//db := dao.GetDB() -///*比较营业状态*/ -///*把获取的京西状态和名称存一下*/ -//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(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店 -// 怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/ -///*获取所有门店信息*/ -////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 -// } -// 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 -// } -// 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") -//} +func StoreOpenAll(ctx *jxcontext.Context) { + 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 { + StoreInfoList2[data.OuterPoiID] = data.PoiName + } + } + db := dao.GetDB() + /*比较营业状态*/ + /*把获取的京西状态和名称存一下*/ + 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(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店 + 怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/ + /*获取所有门店信息*/ + //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 + } + 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 + } + 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") +} //func StoreOpenAll(ctx *jxcontext.Context) { //db := dao.GetDB() @@ -805,62 +801,62 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool //} //} -func StoreOpenAll(ctx *jxcontext.Context) { - db := dao.GetDB() - StoreLists, err := dao.GetStoreList(db, nil, nil, []int{1}, nil, "") - if err != nil { - globals.SugarLogger.Debugf("商店列表获取失败") - } - var StoreMapLists []*model.StoreMap - for _, StoreList := range StoreLists { - if StoreMapLists, err = dao.GetStoresMapList(db, []int{0, 1, 3}, []int{StoreList.ID}, nil, 1, -1, "", ""); err != nil { - globals.SugarLogger.Debugf("商店列表获取失败") - } - if len(StoreMapLists) > 0 { - /*将map查询的结果全部放进数组*/ - for _, StoreMapList := range StoreMapLists { - /*二元运算符*/ - StoreMapList.SyncStatus = StoreMapList.SyncStatus | model.SyncFlagModifiedMask - StoreMapList.UpdatedAt = time.Now() - StoreMapList.LastOperator = ctx.GetUserName() - dao.UpdateEntity(db, StoreMapList, "SyncStatus", "UpdatedAt", "LastOperator") - //} - /*同步*/ - if _, err = CurVendorSync.SyncStore(ctx, db, StoreMapList.VendorID, StoreList.ID, false, ctx.GetUserName()); err != nil { - globals.SugarLogger.Debugf("同步失败") - } - } - } - if StoreMapLists, err = dao.GetStoresMapList(db, []int{9}, []int{StoreList.ID}, nil, 1, -1, "", ""); err != nil { - globals.SugarLogger.Debugf("商店列表获取失败") - } - if len(StoreMapLists) == 0 { - /*遍历,绑定*/ - Map := &model.StoreMap{} - Map.VendorStoreID = strconv.Itoa(StoreList.ID) - Map.AutoPickup = 1 - Map.DeliveryCompetition = 1 - Map.PricePercentage = 100 - Map.IsSync = 1 - Map.PricePercentagePack = "京西100-100" - Map.DeliveryFeeDeductionSill = 0 - Map.DeliveryFeeDeductionFee = 0 - Map.IsOrder = 0 - if _, err := AddStoreVendorMap(ctx, db, 9, "", StoreList.ID, Map); err != nil { - globals.SugarLogger.Debugf("AddStoreVendorMap调用出错,StoreID是" + strconv.Itoa(StoreList.ID)) - globals.SugarLogger.Debugf(err.Error()) - } - } - /*改配送范围*/ - //deliverrangetype 3 - //deliverrange 3000 - StoreList.DeliveryRange = "3000" - StoreList.DeliveryRangeType = 3 - StoreList.UpdatedAt = time.Now() - StoreList.LastOperator = ctx.GetUserName() - dao.UpdateEntity(db, StoreList, "DeliveryRange", "DeliveryRangeType", "LastOperator", "UpdatedAt") - } -} +//func StoreOpenAll(ctx *jxcontext.Context) { +// db := dao.GetDB() +// StoreLists, err := dao.GetStoreList(db, nil, nil, []int{1}, nil, "") +// if err != nil { +// globals.SugarLogger.Debugf("商店列表获取失败") +// } +// var StoreMapLists []*model.StoreMap +// for _, StoreList := range StoreLists { +// if StoreMapLists, err = dao.GetStoresMapList(db, []int{0, 1, 3}, []int{StoreList.ID}, nil, 1, -1, "", ""); err != nil { +// globals.SugarLogger.Debugf("商店列表获取失败") +// } +// if len(StoreMapLists) > 0 { +// /*将map查询的结果全部放进数组*/ +// for _, StoreMapList := range StoreMapLists { +// /*二元运算符*/ +// StoreMapList.SyncStatus = StoreMapList.SyncStatus | model.SyncFlagModifiedMask +// StoreMapList.UpdatedAt = time.Now() +// StoreMapList.LastOperator = ctx.GetUserName() +// dao.UpdateEntity(db, StoreMapList, "SyncStatus", "UpdatedAt", "LastOperator") +// //} +// /*同步*/ +// if _, err = CurVendorSync.SyncStore(ctx, db, StoreMapList.VendorID, StoreList.ID, false, ctx.GetUserName()); err != nil { +// globals.SugarLogger.Debugf("同步失败") +// } +// } +// } +// if StoreMapLists, err = dao.GetStoresMapList(db, []int{9}, []int{StoreList.ID}, nil, 1, -1, "", ""); err != nil { +// globals.SugarLogger.Debugf("商店列表获取失败") +// } +// if len(StoreMapLists) == 0 { +// /*遍历,绑定*/ +// Map := &model.StoreMap{} +// Map.VendorStoreID = strconv.Itoa(StoreList.ID) +// Map.AutoPickup = 1 +// Map.DeliveryCompetition = 1 +// Map.PricePercentage = 100 +// Map.IsSync = 1 +// Map.PricePercentagePack = "京西100-100" +// Map.DeliveryFeeDeductionSill = 0 +// Map.DeliveryFeeDeductionFee = 0 +// Map.IsOrder = 0 +// if _, err := AddStoreVendorMap(ctx, db, 9, "", StoreList.ID, Map); err != nil { +// globals.SugarLogger.Debugf("AddStoreVendorMap调用出错,StoreID是" + strconv.Itoa(StoreList.ID)) +// globals.SugarLogger.Debugf(err.Error()) +// } +// } +// /*改配送范围*/ +// //deliverrangetype 3 +// //deliverrange 3000 +// StoreList.DeliveryRange = "3000" +// StoreList.DeliveryRangeType = 3 +// StoreList.UpdatedAt = time.Now() +// StoreList.LastOperator = ctx.GetUserName() +// dao.UpdateEntity(db, StoreList, "DeliveryRange", "DeliveryRangeType", "LastOperator", "UpdatedAt") +// } +//} func TestDiff(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) { baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor start time: %v", time.Now()) @@ -949,59 +945,61 @@ func TestDiff(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) { //获取总共几个门店任务 filterStoreList := GetFilterStoreList(jxStoreInfoList.Stores, vendorMap, storeIDMap) diffData.InitData() - jxStoreInfoListValue := filterStoreList[0] - storeID := jxStoreInfoListValue.ID - storeIDStr := utils.Int2Str(storeID) - storeName := jxStoreInfoListValue.Name - jxSkuInfoDataSingle := &dao.StoreSkuNamesInfo{} - jxSkuInfoDataMulti := &dao.StoreSkuNamesInfo{} - if jxStoreInfoListValue.StoreMaps != nil { - var multiFlag = false - var singleFlag = false - var filterJxSkuInfoMapSingle map[int]*dao.StoreSkuNameExt - var filterJxSkuInfoMapMulti map[int]*dao.StoreSkuNameExt - for _, vendorListValue := range jxStoreInfoListValue.StoreMaps { - vendorID := vendorListValue.VendorID - if partner.IsMultiStore(vendorID) { - if multiFlag == false { - jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1) - /*重新计算价格*/ - SetJxPrice(jxSkuInfoDataMulti, storeID, vendorID) - filterJxSkuInfoMapMulti = GetFilterJxSkuInfoMap(jxSkuInfoDataMulti.SkuNames) //map[京西商品ID:StoreSkuNameExt] - multiFlag = true + for i := range filterStoreList { + jxStoreInfoListValue := filterStoreList[i] + storeID := jxStoreInfoListValue.ID + storeIDStr := utils.Int2Str(storeID) + storeName := jxStoreInfoListValue.Name + jxSkuInfoDataSingle := &dao.StoreSkuNamesInfo{} + jxSkuInfoDataMulti := &dao.StoreSkuNamesInfo{} + if jxStoreInfoListValue.StoreMaps != nil { + var multiFlag = false + var singleFlag = false + var filterJxSkuInfoMapSingle map[int]*dao.StoreSkuNameExt + var filterJxSkuInfoMapMulti map[int]*dao.StoreSkuNameExt + for _, vendorListValue := range jxStoreInfoListValue.StoreMaps { + vendorID := vendorListValue.VendorID + if partner.IsMultiStore(vendorID) { + if multiFlag == false { + jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1) + /*重新计算价格*/ + SetJxPrice(jxSkuInfoDataMulti, storeID, vendorID) + filterJxSkuInfoMapMulti = GetFilterJxSkuInfoMap(jxSkuInfoDataMulti.SkuNames) //map[京西商品ID:StoreSkuNameExt] + multiFlag = true + } + } else { + if singleFlag == false { + jxSkuInfoDataSingle, _ = GetStoreSkus(ctx, storeID, nil, true, "", true, false, map[string]interface{}{}, 0, -1) + /*重新计算价格*/ + SetJxPrice(jxSkuInfoDataSingle, storeID, vendorID) + filterJxSkuInfoMapSingle = GetFilterJxSkuInfoMap(jxSkuInfoDataSingle.SkuNames) //map[京西商品ID:StoreSkuNameExt] + singleFlag = true + } } - } else { - if singleFlag == false { - jxSkuInfoDataSingle, _ = GetStoreSkus(ctx, storeID, nil, true, "", true, false, map[string]interface{}{}, 0, -1) - /*重新计算价格*/ - SetJxPrice(jxSkuInfoDataSingle, storeID, vendorID) - filterJxSkuInfoMapSingle = GetFilterJxSkuInfoMap(jxSkuInfoDataSingle.SkuNames) //map[京西商品ID:StoreSkuNameExt] - singleFlag = true - } - } - vendorStoreID := vendorListValue.VendorStoreID - baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor storeID:%d vendorID:%d vendorStoreID:%s vendorListValue:%v", storeID, vendorID, vendorStoreID, vendorListValue) + vendorStoreID := vendorListValue.VendorStoreID + baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor storeID:%d vendorID:%d vendorStoreID:%s vendorListValue:%v", storeID, vendorID, vendorStoreID, vendorListValue) - if partner.IsMultiStore(vendorID) { - singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler) - allSkuInfoList := GetMultiStoreAllSkuInfoList(vendorID, vendorListValue.VendorOrgCode) - skuBareInfoList, err := singleStoreHandler.GetStoreSkusBareInfo(ctx, vendorListValue.VendorOrgCode, nil, storeID, vendorStoreID, allSkuInfoList) - if err != nil { - baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusBareInfo error:%v", err) - } else if len(skuBareInfoList) > 0 { - //获取京东的商品 - filterSkuInfoMap := GetFilterMultiStoreSkuInfoMap(vendorID, vendorListValue.VendorOrgCode, skuBareInfoList) //map[京东商品ID:SkuNameInfo] - CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapMulti, filterSkuInfoMap, 1) - } - } else { - singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler) - vendorSkuInfoList, err := singleStoreHandler.GetStoreSkusFullInfo(ctx, nil, storeID, vendorStoreID, nil) - if err != nil { - baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusFullInfo error:%v", err) - } else if len(vendorSkuInfoList) > 0 { - //获取京东的商品 - filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(vendorSkuInfoList) //map[平台商品ID:SkuNameInfo] - CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapSingle, filterVendorSkuInfoMap, 0) + if partner.IsMultiStore(vendorID) { + singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler) + allSkuInfoList := GetMultiStoreAllSkuInfoList(vendorID, vendorListValue.VendorOrgCode) + skuBareInfoList, err := singleStoreHandler.GetStoreSkusBareInfo(ctx, vendorListValue.VendorOrgCode, nil, storeID, vendorStoreID, allSkuInfoList) + if err != nil { + baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusBareInfo error:%v", err) + } else if len(skuBareInfoList) > 0 { + //获取京东的商品 + filterSkuInfoMap := GetFilterMultiStoreSkuInfoMap(vendorID, vendorListValue.VendorOrgCode, skuBareInfoList) //map[京东商品ID:SkuNameInfo] + CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapMulti, filterSkuInfoMap, 1) + } + } else { + singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler) + vendorSkuInfoList, err := singleStoreHandler.GetStoreSkusFullInfo(ctx, nil, storeID, vendorStoreID, nil) + if err != nil { + baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusFullInfo error:%v", err) + } else if len(vendorSkuInfoList) > 0 { + //获取京东的商品 + filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(vendorSkuInfoList) //map[平台商品ID:SkuNameInfo] + CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapSingle, filterVendorSkuInfoMap, 0) + } } } } diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index 457cb454d..856b5f40e 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -1300,7 +1300,7 @@ func SetMTPSStatus(ctx *jxcontext.Context) { /* 美团配送的门店是否存在,调用美团配送的api(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店 怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/ /*获取所有门店信息*/ -test: + //test: for _, StoreCourierList1 := range StoreCourierList { diff := false StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, "") @@ -1340,7 +1340,7 @@ test: globals.SugarLogger.Debug(err.Error()) return } - break test + //break test } } globals.SugarLogger.Debug("StoreOpenAll skuID is Complete")