Merge branch 'mark' of e.coding.net:rosydev/jx-callback into mark
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,13 +29,14 @@ const (
|
|||||||
|
|
||||||
//错误类型
|
//错误类型
|
||||||
const (
|
const (
|
||||||
DatAanalyse1 = "京东商品库直接创建,京西无数据"
|
DatAanalyse1 = "京西门店未关注,应删除对应的平台门店商品"
|
||||||
DatAanalyse2 = "京东商品库未创建成功(可能无经营许可等) "
|
DatAanalyse2 = "平台商品库未创建成功(可能无经营许可等) "
|
||||||
DatAanalyse3 = "商品名不同 "
|
DatAanalyse3 = "商品名不同 "
|
||||||
DatAanalyse4 = "商品可售状态不同 "
|
DatAanalyse4 = "商品可售状态不同 "
|
||||||
DatAanalyse5 = "京西商品库没有,平台商品库有 "
|
DatAanalyse5 = "京西商品库没有,平台商品库有 "
|
||||||
DatAanalyse6 = "京西商品库有,平台商品库没有"
|
DatAanalyse6 = "京西商品库有,平台商品库没有"
|
||||||
DatAanalyse7 = "同步状态异常"
|
DatAanalyse7 = "同步状态异常"
|
||||||
|
DatAanalyse8 = "平台门店未关注,应添加对应的平台门店商品"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -99,7 +99,8 @@ var (
|
|||||||
multiStoreAllSkuInfoMap map[int]map[int]*partner.SkuNameInfo
|
multiStoreAllSkuInfoMap map[int]map[int]*partner.SkuNameInfo
|
||||||
multiStoreAllSkuInfoList map[int][]*partner.StoreSkuInfo
|
multiStoreAllSkuInfoList map[int][]*partner.StoreSkuInfo
|
||||||
skuNameInfoList []*partner.SkuNameInfo
|
skuNameInfoList []*partner.SkuNameInfo
|
||||||
filterCloseSkuIds []int
|
filterVendorDepotUnSaleSkuIds []int
|
||||||
|
filterJxDepotUnSaleSkuIds []int
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiffDataLock struct {
|
type DiffDataLock struct {
|
||||||
@@ -177,9 +178,21 @@ func GetMultiStoreAllSkuInfoList(vendorID int) []*partner.StoreSkuInfo {
|
|||||||
return multiStoreAllSkuInfoList[vendorID]
|
return multiStoreAllSkuInfoList[vendorID]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//过滤掉平台下架的
|
||||||
|
func StoreSkuFullList2BareFilter(storeSkuFull []*partner.SkuNameInfo) (bareStoreSkuList []*partner.StoreSkuInfo) {
|
||||||
|
for _, v := range storeSkuFull {
|
||||||
|
for _, v2 := range v.SkuList {
|
||||||
|
if v2.Status > model.SkuStatusDontSale {
|
||||||
|
bareStoreSkuList = append(bareStoreSkuList, &v2.StoreSkuInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bareStoreSkuList
|
||||||
|
}
|
||||||
|
|
||||||
func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) {
|
func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) {
|
||||||
InitMultiStoreData()
|
InitMultiStoreData()
|
||||||
filterCloseSkuIds = filterCloseSkuIds[0:0]
|
filterVendorDepotUnSaleSkuIds = filterVendorDepotUnSaleSkuIds[0:0]
|
||||||
for vendorID, _ := range vendorNameList {
|
for vendorID, _ := range vendorNameList {
|
||||||
//filter for vendorID
|
//filter for vendorID
|
||||||
if len(vendorMap) > 0 {
|
if len(vendorMap) > 0 {
|
||||||
@@ -194,13 +207,13 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
baseapi.SugarLogger.Errorf("GetMultiStoreAllSkuInfo error:%v", err)
|
baseapi.SugarLogger.Errorf("GetMultiStoreAllSkuInfo error:%v", err)
|
||||||
} else {
|
} else {
|
||||||
multiStoreAllSkuInfoList[vendorID] = putils.StoreSkuFullList2Bare(allSkuNameInfoList) //map[平台ID:[]StoreSkuInfo1,StoreSkuInfo2...]
|
multiStoreAllSkuInfoList[vendorID] = StoreSkuFullList2BareFilter(allSkuNameInfoList) //map[平台ID:[]StoreSkuInfo1,StoreSkuInfo2...]
|
||||||
tempMap := make(map[int]*partner.SkuNameInfo)
|
tempMap := make(map[int]*partner.SkuNameInfo)
|
||||||
for _, value := range allSkuNameInfoList {
|
for _, value := range allSkuNameInfoList {
|
||||||
for _, skuInfo := range value.SkuList {
|
for _, skuInfo := range value.SkuList {
|
||||||
//表示平台商品库未下架的
|
//表示平台商品库未下架的
|
||||||
if skuInfo.Status > model.SkuStatusDontSale {
|
if skuInfo.Status > model.SkuStatusDontSale {
|
||||||
filterCloseSkuIds = append(filterCloseSkuIds, skuInfo.SkuID)
|
filterVendorDepotUnSaleSkuIds = append(filterVendorDepotUnSaleSkuIds, skuInfo.SkuID)
|
||||||
tempMap[skuInfo.SkuID] = value
|
tempMap[skuInfo.SkuID] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,7 +324,6 @@ func IsSkuCanSale(saleStatus int) bool {
|
|||||||
//storeIDStr 京西商家id ,vendorStoreID 平台商家id
|
//storeIDStr 京西商家id ,vendorStoreID 平台商家id
|
||||||
func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo) {
|
func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo) {
|
||||||
for skuID, jxSkuInfo := range filterJxSkuInfoMap {
|
for skuID, jxSkuInfo := range filterJxSkuInfoMap {
|
||||||
reason := ``
|
|
||||||
skuIDStr := utils.Int2Str(skuID)
|
skuIDStr := utils.Int2Str(skuID)
|
||||||
var jxSkuDetailName string
|
var jxSkuDetailName string
|
||||||
//多规格商品不用比较数量单位
|
//多规格商品不用比较数量单位
|
||||||
@@ -350,6 +362,7 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
|||||||
isNameDiff = false
|
isNameDiff = false
|
||||||
}
|
}
|
||||||
if isSaleStatusDiff || isNameDiff {
|
if isSaleStatusDiff || isNameDiff {
|
||||||
|
reason := ""
|
||||||
if isNameDiff {
|
if isNameDiff {
|
||||||
reason += DatAanalyse3
|
reason += DatAanalyse3
|
||||||
}
|
}
|
||||||
@@ -369,7 +382,13 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
|||||||
if isFilterToBeCreateAndNotSale && model.IsSyncStatusNeedCreate(status) && !IsSkuCanSale(jxSkuSaleStatus) {
|
if isFilterToBeCreateAndNotSale && model.IsSyncStatusNeedCreate(status) && !IsSkuCanSale(jxSkuSaleStatus) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", DatAanalyse2}
|
reason := ""
|
||||||
|
if status == 0 {
|
||||||
|
reason = DatAanalyse8
|
||||||
|
} else {
|
||||||
|
reason = DatAanalyse2
|
||||||
|
}
|
||||||
|
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", reason}
|
||||||
diffData.AppendData(vendorID, outPutData)
|
diffData.AppendData(vendorID, outPutData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -394,6 +413,19 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FilterJxDepotUnSaleSkuID() {
|
||||||
|
db := dao.GetDB()
|
||||||
|
filterJxDepotUnSaleSkuIds = filterJxDepotUnSaleSkuIds[0:0]
|
||||||
|
skuList, _ := dao.GetSkus(db, filterVendorDepotUnSaleSkuIds, []int{}, []int{}, []int{})
|
||||||
|
filterJxSkuInfoMap2 := GetFilterJxSkuInfoMap2(skuList)
|
||||||
|
for skuid, jxSkuInfo := range filterJxSkuInfoMap2 {
|
||||||
|
//过滤掉平台库下架,且京西库下架的商品,为下面比较门店商品用
|
||||||
|
if jxSkuInfo.Status != model.SkuStatusDontSale {
|
||||||
|
filterJxDepotUnSaleSkuIds = append(filterJxDepotUnSaleSkuIds, skuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool) {
|
func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
for vendorID, _ := range vendorNameList {
|
for vendorID, _ := range vendorNameList {
|
||||||
@@ -404,15 +436,19 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if partner.IsMultiStore(vendorID) {
|
if partner.IsMultiStore(vendorID) {
|
||||||
// multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler)
|
FilterJxDepotUnSaleSkuID()
|
||||||
// allSkuNameInfoList, _ := multiHandler.GetSkus(ctx, 0, "", "")
|
|
||||||
filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(skuNameInfoList)
|
filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(skuNameInfoList)
|
||||||
skuNameInfoList = skuNameInfoList[0:0]
|
skuNameInfoList = skuNameInfoList[0:0]
|
||||||
skuList, _ := dao.GetSkus(db, []int{}, []int{}, []int{}, []int{})
|
skuList, _ := dao.GetSkus(db, []int{}, []int{}, []int{}, []int{})
|
||||||
filterJxSkuInfoMap2 := GetFilterJxSkuInfoMap2(skuList)
|
filterJxSkuInfoMap2 := GetFilterJxSkuInfoMap2(skuList)
|
||||||
for skuid, jxSkuInfo := range filterJxSkuInfoMap2 {
|
for skuid, jxSkuInfo := range filterJxSkuInfoMap2 {
|
||||||
reason := ``
|
var jxSkuDetailName string
|
||||||
jxSkuDetailName := jxutils.ComposeSkuName(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, jxSkuInfo.Unit, jxSkuInfo.SpecQuality, jxSkuInfo.SpecUnit, 0)
|
//多规格商品不用比较数量单位
|
||||||
|
if jxSkuInfo.IsSpu == 0 {
|
||||||
|
jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, jxSkuInfo.Unit, jxSkuInfo.SpecQuality, jxSkuInfo.SpecUnit, 0)
|
||||||
|
} else {
|
||||||
|
jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, "", jxSkuInfo.SpecQuality, "", 0)
|
||||||
|
}
|
||||||
|
|
||||||
vendorSkuInfoMap := filterVendorSkuInfoMap[skuid]
|
vendorSkuInfoMap := filterVendorSkuInfoMap[skuid]
|
||||||
jxSkuSaleStatus := jxSkuInfo.Status
|
jxSkuSaleStatus := jxSkuInfo.Status
|
||||||
@@ -424,6 +460,7 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool
|
|||||||
isSaleStatusDiff := jxSkuSaleStatusName != vendorSkuSaleStatusName
|
isSaleStatusDiff := jxSkuSaleStatusName != vendorSkuSaleStatusName
|
||||||
isNameDiff := strings.Compare(jxSkuDetailName, vendorSkuDetailName) != 0
|
isNameDiff := strings.Compare(jxSkuDetailName, vendorSkuDetailName) != 0
|
||||||
if isNameDiff || isSaleStatusDiff {
|
if isNameDiff || isSaleStatusDiff {
|
||||||
|
reason := ""
|
||||||
if isNameDiff {
|
if isNameDiff {
|
||||||
reason += DatAanalyse3
|
reason += DatAanalyse3
|
||||||
}
|
}
|
||||||
@@ -507,7 +544,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
|
|||||||
|
|
||||||
if isGetJxSkuInfoData == false { //only get once jx sku info list every store id
|
if isGetJxSkuInfoData == false { //only get once jx sku info list every store id
|
||||||
isGetJxSkuInfoData = true
|
isGetJxSkuInfoData = true
|
||||||
jxSkuInfoData, _ := GetStoreSkus(ctx, storeID, filterCloseSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
jxSkuInfoData, _ := GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||||
filterJxSkuInfoMap = GetFilterJxSkuInfoMap(jxSkuInfoData.SkuNames) //map[京西商品ID:StoreSkuNameExt]
|
filterJxSkuInfoMap = GetFilterJxSkuInfoMap(jxSkuInfoData.SkuNames) //map[京西商品ID:StoreSkuNameExt]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func DeleteSkuNamePlace(db *DaoDB, nameID int, placeCodes []int) (num int64, err
|
|||||||
|
|
||||||
func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int) (skuList []*model.SkuAndName, err error) {
|
func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int) (skuList []*model.SkuAndName, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.*, t2.name, t2.unit, t2.prefix
|
SELECT t1.*, t2.name, t2.unit, t2.prefix, t2.is_spu
|
||||||
FROM sku t1
|
FROM sku t1
|
||||||
JOIN sku_name t2 ON t2.id = t1.name_id AND t2.deleted_at = ?
|
JOIN sku_name t2 ON t2.id = t1.name_id AND t2.deleted_at = ?
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ type SkuAndName struct {
|
|||||||
Name string
|
Name string
|
||||||
Unit string
|
Unit string
|
||||||
Prefix string
|
Prefix string
|
||||||
|
IsSpu int
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (*Sku) TableUnique() [][]string {
|
// func (*Sku) TableUnique() [][]string {
|
||||||
|
|||||||
Reference in New Issue
Block a user