DIFF 对比对接做了修改新增了类别比较
This commit is contained in:
@@ -39,10 +39,11 @@ const (
|
||||
DatAanalyse4 = "商品可售状态不同 "
|
||||
DatAanalyse5 = "京西商品库没有,平台商品库有 "
|
||||
DatAanalyse6 = "京西商品库有,平台商品库没有"
|
||||
DatAanalyse7 = "同步状态异常"
|
||||
DatAanalyse7 = "" //update by hang 这个提示毫无意义 并未做任何同步操作获取错误码 纯粹因为有不同才会拼接
|
||||
DatAanalyse8 = "平台门店未关注或平台门店商品库存为0,应添加对应的平台门店商品"
|
||||
DatAanalyse9 = "平台门店价格与京西商品库价格不一致"
|
||||
DatAanalyse10 = "平台商品的VendorSkuID与京西的VendorSkuID不一致"
|
||||
DatAanalyse11 = "平台商品的类别与京西的类别不一致"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -71,6 +72,8 @@ var (
|
||||
"平台可售状态",
|
||||
"京西价格",
|
||||
"平台价格",
|
||||
"京西商品类别",
|
||||
"平台商品类别",
|
||||
"数据分析",
|
||||
}
|
||||
|
||||
@@ -134,22 +137,24 @@ type DepotDiffData struct {
|
||||
}
|
||||
|
||||
type DiffData struct {
|
||||
JxStoreID string `json:"京西门店ID"`
|
||||
VendorStoreID string `json:"平台门店ID"`
|
||||
VendorStoreName string `json:"门店名"`
|
||||
SkuID string `json:"SkuID"`
|
||||
MtwmID string `json:"京西美团外卖ID"`
|
||||
EbaiID string `json:"京西饿百ID"`
|
||||
SyncStatus string `json:"同步状态"`
|
||||
ToBeCreate string `json:"待创建"`
|
||||
ToBeDel string `json:"待删除"`
|
||||
JxSkuName string `json:"京西商品名"`
|
||||
VendorSkuName string `json:"平台商品名"`
|
||||
JxStatus string `json:"京西可售状态"`
|
||||
VendorStatus string `json:"平台可售状态"`
|
||||
JxSkuPrice string `json:"京西价格"` /*哇,不能小写,不然会搞事情*/
|
||||
VendorPrice string `json:"平台价格"`
|
||||
DatAanalyse string `json:"数据分析"`
|
||||
JxStoreID string `json:"京西门店ID"`
|
||||
VendorStoreID string `json:"平台门店ID"`
|
||||
VendorStoreName string `json:"门店名"`
|
||||
SkuID string `json:"SkuID"`
|
||||
MtwmID string `json:"京西美团外卖ID"`
|
||||
EbaiID string `json:"京西饿百ID"`
|
||||
SyncStatus string `json:"同步状态"`
|
||||
ToBeCreate string `json:"待创建"`
|
||||
ToBeDel string `json:"待删除"`
|
||||
JxSkuName string `json:"京西商品名"`
|
||||
VendorSkuName string `json:"平台商品名"`
|
||||
JxStatus string `json:"京西可售状态"`
|
||||
VendorStatus string `json:"平台可售状态"`
|
||||
JxSkuPrice string `json:"京西价格"` /*哇,不能小写,不然会搞事情*/
|
||||
VendorPrice string `json:"平台价格"`
|
||||
JxCategoryName string `json:"京西商品类别"`
|
||||
VendorCategoryName string `json:"平台商品类别"`
|
||||
DatAanalyse string `json:"数据分析"`
|
||||
}
|
||||
|
||||
type StatisticData struct {
|
||||
@@ -354,6 +359,12 @@ func IsSkuCanSale(saleStatus int) bool {
|
||||
//storeIDStr 京西商家id ,vendorStoreID 平台商家id ,isJd 京东比较的标记 0不是,1是
|
||||
func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*dao.StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo, isJd int) {
|
||||
//utils.Writelog("进入 CompareJxAndVendor 方法")
|
||||
var vendorMap map[string]string
|
||||
baseapi.SugarLogger.Debugf("-----------------------------------------------------------------------------------------------------")
|
||||
if vendorID == 0 {
|
||||
//TO DO 进行查询 select count(*) from sku_vendor_category where vendor_id=0; 一共3047 数据一次connection查询出来 组成一个map {categoryID,name}
|
||||
vendorMap = getJDVendorCategoryMap()
|
||||
}
|
||||
for skuID, jxSkuInfo := range filterJxSkuInfoMap {
|
||||
skuIDStr := utils.Int2Str(skuID)
|
||||
/*写京西skuIDStr*/
|
||||
@@ -372,6 +383,9 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
/*美团编码*/
|
||||
mtwmid := jxSkuInfo.Skus[0].MtwmID
|
||||
//jxSkuPrice := strconv.Itoa(jxSkuInfo.Skus[0].JxPrice)
|
||||
/*商品类名*/
|
||||
jxCategoryName := jxSkuInfo.Skus[0].CategoryName
|
||||
//fmt.Println(jxCategoryName)
|
||||
vendorSkuInfo := filterVendorSkuInfoMap[skuID]
|
||||
var status int8
|
||||
if vendorID == model.VendorIDMTWM {
|
||||
@@ -386,7 +400,19 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
toBeDel := GetBoolName(model.IsSyncStatusNeedDelete(status))
|
||||
|
||||
if vendorSkuInfo != nil {
|
||||
if vendorID == 0 && len(vendorMap) != 0 { //进行转换
|
||||
catID := []string{}
|
||||
categoryName := vendorMap[vendorSkuInfo.VendorCatIDList[len(vendorSkuInfo.VendorCatIDList)-1]]
|
||||
catID = append(catID, categoryName)
|
||||
vendorSkuInfo.VendorCatIDList = catID
|
||||
}
|
||||
|
||||
vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName
|
||||
vendorCategoryName := ""
|
||||
if len(vendorSkuInfo.VendorCatIDList) != 0 {
|
||||
vendorCategoryName = vendorSkuInfo.VendorCatIDList[len(vendorSkuInfo.VendorCatIDList)-1]
|
||||
}
|
||||
fmt.Println(vendorCategoryName)
|
||||
vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status + 3)
|
||||
/* 供货商价格 */
|
||||
vendorPrice := fmt.Sprintf("%.2f", float64(vendorSkuInfo.SkuList[0].StoreSkuInfo.VendorPrice)/float64(100))
|
||||
@@ -402,6 +428,7 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
isPriceDiff := vendorPrice != jxSkuPrice
|
||||
//utils.Writelog("isSaleStatusDiff:" + strconv.FormatBool(isSaleStatusDiff))
|
||||
//utils.Writelog("isNameDiff:" + strconv.FormatBool(isNameDiff))
|
||||
isCategoryDiff := vendorCategoryName != jxCategoryName
|
||||
if jxSkuDetailName != "" && vendorSkuDetailName != "" && strings.Contains(jxSkuDetailName, vendorSkuDetailName) {
|
||||
isNameDiff = false
|
||||
}
|
||||
@@ -416,18 +443,23 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
if isPriceDiff {
|
||||
reason += DatAanalyse9
|
||||
}
|
||||
if vendorID != 3 { //饿百平台查询获取到的商品信息是没有类别的 因此单独需要判断
|
||||
if isCategoryDiff {
|
||||
reason += DatAanalyse11
|
||||
}
|
||||
}
|
||||
if IdMark {
|
||||
reason += DatAanalyse10
|
||||
}
|
||||
if status != model.SkuStatusDontSale {
|
||||
reason += DatAanalyse7
|
||||
}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, mtwmid, ebaiid, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, jxSkuPrice, vendorPrice, reason}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, mtwmid, ebaiid, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, jxSkuPrice, vendorPrice, jxCategoryName, vendorCategoryName, reason}
|
||||
diffData.AppendData(vendorID, outPutData)
|
||||
}
|
||||
if !isSaleStatusDiff && !isNameDiff {
|
||||
if status != model.SkuStatusDontSale {
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, mtwmid, ebaiid, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, jxSkuPrice, vendorPrice, DatAanalyse7}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, mtwmid, ebaiid, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, jxSkuPrice, vendorPrice, jxCategoryName, vendorCategoryName, DatAanalyse7}
|
||||
diffData.AppendData(vendorID, outPutData)
|
||||
}
|
||||
}
|
||||
@@ -444,7 +476,7 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
if status != model.SkuStatusDontSale {
|
||||
reason += DatAanalyse7
|
||||
}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, mtwmid, ebaiid, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", jxSkuPrice, "", reason}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, mtwmid, ebaiid, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", jxSkuPrice, "", jxCategoryName, "", reason}
|
||||
diffData.AppendData(vendorID, outPutData)
|
||||
}
|
||||
}
|
||||
@@ -460,7 +492,12 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
jxSkuInfo := filterJxSkuInfoMap[skuID]
|
||||
/*平台有,京西没有*/
|
||||
if jxSkuInfo == nil {
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, "", "", storeName, skuIDStr, "", "", "", "", vendorSkuDetailName, "", vendorSkuSaleStatusName, "", vendorPrice, DatAanalyse1}
|
||||
//update by hang 2022/4/12 映射bug
|
||||
vendorCategoryName := ""
|
||||
if len(vendorSkuInfo.VendorCatIDList) != 0 {
|
||||
vendorCategoryName = vendorSkuInfo.VendorCatIDList[len(vendorSkuInfo.VendorCatIDList)-1]
|
||||
}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, "", "", "", "", "", "", vendorSkuDetailName, "", vendorSkuSaleStatusName, "", vendorPrice, "", vendorCategoryName, DatAanalyse1}
|
||||
diffData.AppendData(vendorID, outPutData)
|
||||
}
|
||||
} else {
|
||||
@@ -472,6 +509,35 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
}
|
||||
}
|
||||
|
||||
type VendorCategory struct {
|
||||
VendorCategoryID string `orm:"size(48);column(vendor_category_id)" json:"vendorCategoryID"`
|
||||
Name string `orm:"size(255);index" json:"name"`
|
||||
}
|
||||
|
||||
// 获取京东类别映射
|
||||
func getJDVendorCategoryEntity() (vendorCategoryList []*VendorCategory, err error) {
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
select vendor_category_id,name from sku_vendor_category where vendor_id=?
|
||||
`
|
||||
var sqlParams []interface{}
|
||||
sqlParams = append(sqlParams, 0)
|
||||
err = dao.GetRows(db, &vendorCategoryList, sql, sqlParams...)
|
||||
return vendorCategoryList, err
|
||||
}
|
||||
|
||||
//获取京东所有类别映射
|
||||
func getJDVendorCategoryMap() map[string]string {
|
||||
result := make(map[string]string)
|
||||
list, err := getJDVendorCategoryEntity()
|
||||
if err == nil {
|
||||
for _, v := range list {
|
||||
result[v.VendorCategoryID] = v.Name
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func FilterJxDepotUnSaleSkuID() {
|
||||
db := dao.GetDB()
|
||||
filterJxDepotUnSaleSkuIds = filterJxDepotUnSaleSkuIds[0:0]
|
||||
@@ -963,7 +1029,8 @@ func TestDiff(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) {
|
||||
vendorID := vendorListValue.VendorID
|
||||
if partner.IsMultiStore(vendorID) {
|
||||
if multiFlag == false {
|
||||
jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
//jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
jxSkuInfoDataMulti, _ = GetStoreSkus2(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
/*重新计算价格*/
|
||||
SetJxPrice(jxSkuInfoDataMulti, storeID, vendorID)
|
||||
filterJxSkuInfoMapMulti = GetFilterJxSkuInfoMap(jxSkuInfoDataMulti.SkuNames) //map[京西商品ID:StoreSkuNameExt]
|
||||
@@ -971,7 +1038,8 @@ func TestDiff(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) {
|
||||
}
|
||||
} else {
|
||||
if singleFlag == false {
|
||||
jxSkuInfoDataSingle, _ = GetStoreSkus(ctx, storeID, nil, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
//jxSkuInfoDataSingle, _ = GetStoreSkus(ctx, storeID, nil, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
jxSkuInfoDataSingle, _ = GetStoreSkus2(ctx, storeID, nil, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
/*重新计算价格*/
|
||||
SetJxPrice(jxSkuInfoDataSingle, storeID, vendorID)
|
||||
filterJxSkuInfoMapSingle = GetFilterJxSkuInfoMap(jxSkuInfoDataSingle.SkuNames) //map[京西商品ID:StoreSkuNameExt]
|
||||
@@ -1166,13 +1234,15 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
|
||||
vendorID := vendorListValue.VendorID
|
||||
if partner.IsMultiStore(vendorID) {
|
||||
if multiFlag == false {
|
||||
jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
//jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
jxSkuInfoDataMulti, _ = GetStoreSkus2(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
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)
|
||||
//jxSkuInfoDataSingle, _ = GetStoreSkus(ctx, storeID, nil, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
jxSkuInfoDataSingle, _ = GetStoreSkus2(ctx, storeID, nil, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
filterJxSkuInfoMapSingle = GetFilterJxSkuInfoMap(jxSkuInfoDataSingle.SkuNames) //map[京西商品ID:StoreSkuNameExt]
|
||||
singleFlag = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user