Merge remote-tracking branch 'origin/mark' into yonghui

This commit is contained in:
苏尹岚
2019-12-11 18:12:33 +08:00
17 changed files with 325 additions and 323 deletions

View File

@@ -1231,12 +1231,12 @@ func DeleteSkuNamePlace(ctx *jxcontext.Context, nameID, placeCode int, userName
return num, err
}
func GetVendorSku(ctx *jxcontext.Context, vendorID int, vendorOrgCode, vendorSkuID string) (skuNameInfo *model.SkuNameExt, err error) {
if handler := CurVendorSync.GetMultiStoreHandler(vendorID); handler != nil {
return handler.ReadSku(ctx, vendorOrgCode, vendorSkuID)
}
return nil, ErrCanNotFindVendor
}
// func GetVendorSku(ctx *jxcontext.Context, vendorID int, vendorOrgCode, vendorSkuID string) (skuNameInfo *model.SkuNameExt, err error) {
// if handler := CurVendorSync.GetMultiStoreHandler(vendorID); handler != nil {
// return handler.ReadSku(ctx, vendorOrgCode, vendorSkuID)
// }
// return nil, ErrCanNotFindVendor
// }
func SortCategorySkus(ctx *jxcontext.Context, catID int, skuIDList []int) (err error) {
db := dao.GetDB()

View File

@@ -55,15 +55,17 @@ type StoreExt struct {
FloatLng float64 `json:"lng"`
FloatLat float64 `json:"lat"`
ProvinceCode int `json:"provinceCode"`
ProvinceName string `json:"provinceName"`
CityName string `json:"cityName"`
DistrictName string `json:"districtName"`
StoreMapStr string `json:"-"`
CourierMapStr string `json:"-"`
PayeeBankName string `json:"payeeBankName"` // 开户行名称
StoreMaps []map[string]interface{} `orm:"-"`
CourierMaps []map[string]interface{} `orm:"-"`
ProvinceCode int `json:"provinceCode"`
ProvinceName string `json:"provinceName"`
CityName string `json:"cityName"`
DistrictName string `json:"districtName"`
StoreMapStr string `json:"-"`
CourierMapStr string `json:"-"`
PayeeBankName string `json:"payeeBankName"` // 开户行名称
// StoreMaps []map[string]interface{} `orm:"-"`
// CourierMaps []map[string]interface{} `orm:"-"`
StoreMaps []*model.StoreMap `json:"StoreMaps"`
CourierMaps []*model.StoreCourierMap `json:"CourierMaps"`
OrderCount int `json:"orderCount"`
}
@@ -404,10 +406,10 @@ func setStoreMapInfo(ctx *jxcontext.Context, db *dao.DaoDB, storesInfo *StoresIn
v.Licence2Image = ""
}
for _, v2 := range storeMapMap[v.ID] {
v.StoreMaps = append(v.StoreMaps, utils.Struct2FlatMap(v2))
v.StoreMaps = append(v.StoreMaps, v2)
}
for _, v2 := range storeCourierMap[v.ID] {
v.CourierMaps = append(v.CourierMaps, utils.Struct2FlatMap(v2))
v.CourierMaps = append(v.CourierMaps, v2)
}
}
return nil
@@ -1188,7 +1190,6 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
return 0, err
}
if num > 0 {
// TODO 重算京西商城价
if vendorID != model.VendorIDJX {
if valid["pricePercentage"] != nil || valid["pricePercentagePack"] != nil {
storeSkuBind := &model.StoreSkuBind{}

View File

@@ -17,6 +17,7 @@ import (
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api/apimanager"
)
const (
@@ -96,8 +97,9 @@ var (
diffData DiffDataLock
depotDiffData DeoptDiffDataLock
multiStoreAllSkuInfoMap map[int]map[int]*partner.SkuNameInfo
multiStoreAllSkuInfoList map[int][]*partner.StoreSkuInfo
multiStoreAllSkuInfoMap map[int]map[string]map[int]*partner.SkuNameInfo
multiStoreAllSkuInfoList map[int]map[string][]*partner.StoreSkuInfo
skuNameInfoList []*partner.SkuNameInfo
filterVendorDepotUnSaleSkuIds []int
filterJxDepotUnSaleSkuIds []int
@@ -166,16 +168,22 @@ func (d *DiffDataLock) InitData() {
}
func InitMultiStoreData() {
multiStoreAllSkuInfoMap = make(map[int]map[int]*partner.SkuNameInfo)
multiStoreAllSkuInfoList = make(map[int][]*partner.StoreSkuInfo)
multiStoreAllSkuInfoMap = make(map[int]map[string]map[int]*partner.SkuNameInfo)
multiStoreAllSkuInfoList = make(map[int]map[string][]*partner.StoreSkuInfo)
}
func GetMultiStoreAllSkuInfoMap(vendorID int) map[int]*partner.SkuNameInfo {
return multiStoreAllSkuInfoMap[vendorID]
func GetMultiStoreAllSkuInfoMap(vendorID int, vendorOrgCode string) (retVal map[int]*partner.SkuNameInfo) {
if multiStoreAllSkuInfoMap[vendorID] != nil {
retVal = multiStoreAllSkuInfoMap[vendorID][vendorOrgCode]
}
return retVal
}
func GetMultiStoreAllSkuInfoList(vendorID int) []*partner.StoreSkuInfo {
return multiStoreAllSkuInfoList[vendorID]
func GetMultiStoreAllSkuInfoList(vendorID int, vendorOrgCode string) (retVal []*partner.StoreSkuInfo) {
if multiStoreAllSkuInfoList[vendorID] != nil {
retVal = multiStoreAllSkuInfoList[vendorID][vendorOrgCode]
}
return retVal
}
//过滤掉平台下架的
@@ -202,23 +210,26 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) {
}
if partner.IsMultiStore(vendorID) {
multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler)
allSkuNameInfoList, err := multiHandler.GetSkus(ctx, 0, "", "")
skuNameInfoList = allSkuNameInfoList
if err != nil {
baseapi.SugarLogger.Errorf("GetMultiStoreAllSkuInfo error:%v", err)
} else {
multiStoreAllSkuInfoList[vendorID] = StoreSkuFullList2BareFilter(allSkuNameInfoList) //map[平台ID[]StoreSkuInfo1,StoreSkuInfo2...]
tempMap := make(map[int]*partner.SkuNameInfo)
for _, value := range allSkuNameInfoList {
for _, skuInfo := range value.SkuList {
//表示平台商品库未下架的
if skuInfo.Status > model.SkuStatusDontSale {
filterVendorDepotUnSaleSkuIds = append(filterVendorDepotUnSaleSkuIds, skuInfo.SkuID)
tempMap[skuInfo.SkuID] = value
for _, vendorOrgCode := range apimanager.CurAPIManager.GetAppOrgCodeList(vendorID) {
allSkuNameInfoList, err := multiHandler.GetSkus(ctx, vendorOrgCode, 0, "")
skuNameInfoList = allSkuNameInfoList
if err != nil {
baseapi.SugarLogger.Errorf("GetMultiStoreAllSkuInfo error:%v", err)
} else {
multiStoreAllSkuInfoList[vendorID][vendorOrgCode] = StoreSkuFullList2BareFilter(allSkuNameInfoList) //map[平台ID[]StoreSkuInfo1,StoreSkuInfo2...]
tempMap := make(map[int]*partner.SkuNameInfo)
for _, value := range allSkuNameInfoList {
for _, skuInfo := range value.SkuList {
//表示平台商品库未下架的
if skuInfo.Status > model.SkuStatusDontSale {
filterVendorDepotUnSaleSkuIds = append(filterVendorDepotUnSaleSkuIds, skuInfo.SkuID)
tempMap[skuInfo.SkuID] = value
}
}
}
multiStoreAllSkuInfoMap[vendorID] = make(map[string]map[int]*partner.SkuNameInfo)
multiStoreAllSkuInfoMap[vendorID][vendorOrgCode] = tempMap //map[平台ID][map[skuID1SkuNameInfo1skuID2SkuNameInfo2]...]
}
multiStoreAllSkuInfoMap[vendorID] = tempMap //map[平台ID][map[skuID1SkuNameInfo1skuID2SkuNameInfo2]...]
}
}
}
@@ -254,8 +265,8 @@ func GetFilterJxSkuInfoMap2(jxSkuInfoList []*model.SkuAndName) map[int]*model.Sk
return filterVendorSkuInfoMap
}
func GetFilterMultiStoreSkuInfoMap(vendorID int, skuInfoList []*partner.StoreSkuInfo) map[int]*partner.SkuNameInfo {
allSkuInfoMap := GetMultiStoreAllSkuInfoMap(vendorID)
func GetFilterMultiStoreSkuInfoMap(vendorID int, vendorOrgCode string, skuInfoList []*partner.StoreSkuInfo) map[int]*partner.SkuNameInfo {
allSkuInfoMap := GetMultiStoreAllSkuInfoMap(vendorID, vendorOrgCode)
filterSkuInfoMap := make(map[int]*partner.SkuNameInfo)
for _, value := range skuInfoList {
if value.Stock > 0 {
@@ -276,10 +287,10 @@ func GetFilterStoreList(storeList []*StoreExt, vendorMap, storeIDMap map[int]boo
}
}
if storeInfo.StoreMaps != nil {
var tempStoreMaps []map[string]interface{}
var tempStoreMaps []*model.StoreMap
for _, vendorStoreInfo := range storeInfo.StoreMaps {
vendorID := int(utils.MustInterface2Int64(vendorStoreInfo["vendorID"]))
isSyncStoreSku := int(utils.MustInterface2Int64(vendorStoreInfo["isSync"]))
vendorID := vendorStoreInfo.VendorID
isSyncStoreSku := int(vendorStoreInfo.IsSync)
if isSyncStoreSku == 0 {
continue
}
@@ -548,7 +559,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
var filterJxSkuInfoMapSingle map[int]*dao.StoreSkuNameExt
var filterJxSkuInfoMapMulti map[int]*dao.StoreSkuNameExt
for _, vendorListValue := range jxStoreInfoListValue.StoreMaps {
vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"]))
vendorID := vendorListValue.VendorID
var flag = false
if partner.IsMultiStore(vendorID) {
if flag == false {
@@ -564,18 +575,17 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
}
}
vendorStoreID := utils.Interface2String(vendorListValue["vendorStoreID"])
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)
// TODO vendorOrgCode
skuBareInfoList, err := singleStoreHandler.GetStoreSkusBareInfo(ctx, "", task, storeID, vendorStoreID, allSkuInfoList)
allSkuInfoList := GetMultiStoreAllSkuInfoList(vendorID, vendorListValue.VendorOrgCode)
skuBareInfoList, err := singleStoreHandler.GetStoreSkusBareInfo(ctx, vendorListValue.VendorOrgCode, task, storeID, vendorStoreID, allSkuInfoList)
if err != nil {
baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusBareInfo error:%v", err)
} else if len(skuBareInfoList) > 0 {
filterSkuInfoMap := GetFilterMultiStoreSkuInfoMap(vendorID, skuBareInfoList) //map[京东商品ID:SkuNameInfo]
filterSkuInfoMap := GetFilterMultiStoreSkuInfoMap(vendorID, vendorListValue.VendorOrgCode, skuBareInfoList) //map[京东商品ID:SkuNameInfo]
CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapMulti, filterSkuInfoMap)
}
} else {

View File

@@ -103,13 +103,13 @@ func (s *StoreListQueueData) TransferWaitQueueToProcessQueue() {
}
}
func AddOrDelExtraStoreOptime(ctx *jxcontext.Context, vendorID, storeID int, vendorStoreID string, storeInfo *model.Store, startOpStoreTime, endOpStoreTime int16, needAddTime bool) bool {
func AddOrDelExtraStoreOptime(ctx *jxcontext.Context, vendorID int, vendorOrgCode string, storeID int, vendorStoreID string, storeInfo *model.Store, startOpStoreTime, endOpStoreTime int16, needAddTime bool) bool {
opTimeList := storeInfo.GetOpTimeList()
if needAddTime {
opTimeList = []int16{startOpStoreTime, endOpStoreTime}
}
handler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IStoreHandler)
return handler.UpdateStoreOpTime(ctx, "", storeID, vendorStoreID, opTimeList) == nil // TODO vendorOrgCode应该用传入的值
return handler.UpdateStoreOpTime(ctx, vendorOrgCode, storeID, vendorStoreID, opTimeList) == nil
}
func GetStockValue(isStart bool) int {
@@ -142,14 +142,13 @@ func SetSkuStock(isStart bool, storeSkuNameList []*partner.SkuNameInfo) {
}
}
func SetSpecialSkuStatus(ctx *jxcontext.Context, storeID, vendorID int, vendorStoreID string, storeSkuNameList []*partner.SkuNameInfo) {
func SetSpecialSkuStatus(ctx *jxcontext.Context, vendorID int, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuNameList []*partner.SkuNameInfo) {
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
for _, skuNameInfo := range storeSkuNameList {
for _, skuInfo := range skuNameInfo.SkuList {
if IsSpecialSku(skuNameInfo.Name) || IsSpecialSku(skuInfo.SkuName) {
storeSkuList := []*partner.StoreSkuInfo{&skuInfo.StoreSkuInfo}
// TODO vendorOrgCode
singleStoreHandler.UpdateStoreSkusStatus(ctx, "", storeID, vendorStoreID, storeSkuList, model.SkuStatusNormal)
singleStoreHandler.UpdateStoreSkusStatus(ctx, vendorOrgCode, storeID, vendorStoreID, storeSkuList, model.SkuStatusNormal)
}
}
}
@@ -181,7 +180,7 @@ func GetFilterStoreList(storeList []*cms.StoreExt, vendorMap, storeIDMap map[int
}
}
for _, vendorStoreInfo := range storeInfo.StoreMaps {
vendorID := int(utils.MustInterface2Int64(vendorStoreInfo["vendorID"]))
vendorID := vendorStoreInfo.VendorID
//filter for vendorID
if len(vendorMap) > 0 {
if _, ok := vendorMap[vendorID]; !ok {
@@ -193,7 +192,7 @@ func GetFilterStoreList(storeList []*cms.StoreExt, vendorMap, storeIDMap map[int
}
temp := *storeInfo
newStoreInfo := &temp
newStoreInfo.StoreMaps = []map[string]interface{}{vendorStoreInfo}
newStoreInfo.StoreMaps = []*model.StoreMap{vendorStoreInfo}
outStoreList = append(outStoreList, newStoreInfo)
}
}
@@ -224,9 +223,9 @@ func StartOrEndOpStoreEx(ctx *jxcontext.Context, isStart bool, startTime, endTim
storeListValue := batchItemList[0].(*cms.StoreExt)
storeID := storeListValue.ID
for _, vendorListValue := range storeListValue.StoreMaps {
vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"]))
startOpStoreTime := int16(utils.MustInterface2Int64(vendorListValue["fakeOpenStart"]))
endOpStoreTime := int16(utils.MustInterface2Int64(vendorListValue["fakeOpenStop"]))
vendorID := vendorListValue.VendorID
startOpStoreTime := vendorListValue.FakeOpenStart
endOpStoreTime := vendorListValue.FakeOpenStop
//startOpStoreTime, endOpStoreTime := GetOpStoreTime(vendorID)
if startTime != 0 && endTime != 0 {
startOpStoreTime = startTime
@@ -236,7 +235,7 @@ func StartOrEndOpStoreEx(ctx *jxcontext.Context, isStart bool, startTime, endTim
if isStart && (startOpStoreTime == 0 || endOpStoreTime == 0) {
continue
}
vendorStoreID := utils.Interface2String(vendorListValue["vendorStoreID"])
vendorStoreID := vendorListValue.VendorStoreID
baseapi.SugarLogger.Debugf("StartOrEndOpStore storeID:%d vendorID:%d vendorStoreID:%s", storeID, vendorID, vendorStoreID)
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
storeSkuNameList, err := singleStoreHandler.GetStoreSkusFullInfo(ctx, task, storeID, vendorStoreID, nil)
@@ -244,24 +243,23 @@ func StartOrEndOpStoreEx(ctx *jxcontext.Context, isStart bool, startTime, endTim
baseapi.SugarLogger.Errorf("StartOrEndOpStore GetStoreSkusFullInfo error:%v storeID:%d vendorID:%d vendorStoreID:%s", err, storeID, vendorID, vendorStoreID)
} else {
SetSkuStock(isStart, storeSkuNameList)
SetSpecialSkuStatus(ctx, storeID, vendorID, vendorStoreID, storeSkuNameList)
SetSpecialSkuStatus(ctx, vendorID, vendorListValue.VendorOrgCode, storeID, vendorStoreID, storeSkuNameList)
storeSkuList := putils.StoreSkuFullList2Bare(storeSkuNameList)
if vendorID == model.VendorIDMTWM {
storeSkuList = GetFilterStoreSkuList(storeSkuList)
}
if len(storeSkuList) > 0 {
if !isStart {
AddOrDelExtraStoreOptime(ctx, vendorID, storeID, vendorStoreID, &storeListValue.Store, startOpStoreTime, endOpStoreTime, false)
AddOrDelExtraStoreOptime(ctx, vendorID, vendorListValue.VendorOrgCode, storeID, vendorStoreID, &storeListValue.Store, startOpStoreTime, endOpStoreTime, false)
}
_, err = putils.FreeBatchStoreSkuInfo("更新门店商品库存", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
// TODO vendorOrgCode
_, err = singleStoreHandler.UpdateStoreSkusStock(ctx, "", storeID, vendorStoreID, batchedStoreSkuList)
_, err = singleStoreHandler.UpdateStoreSkusStock(ctx, vendorListValue.VendorOrgCode, storeID, vendorStoreID, batchedStoreSkuList)
return nil, 0, err
}, ctx, task, storeSkuList, singleStoreHandler.GetStoreSkusBatchSize(partner.FuncUpdateStoreSkusStock), true)
if isStart {
AddOrDelExtraStoreOptime(ctx, vendorID, storeID, vendorStoreID, &storeListValue.Store, startOpStoreTime, endOpStoreTime, true)
AddOrDelExtraStoreOptime(ctx, vendorID, vendorListValue.VendorOrgCode, storeID, vendorStoreID, &storeListValue.Store, startOpStoreTime, endOpStoreTime, true)
}
}
}
@@ -341,8 +339,8 @@ func InitEx() {
if err == nil {
for _, storeInfo := range storeList {
for _, vendorStoreInfo := range storeInfo.StoreMaps {
startOpStoreTime := int16(utils.MustInterface2Int64(vendorStoreInfo["fakeOpenStart"]))
endOpStoreTime := int16(utils.MustInterface2Int64(vendorStoreInfo["fakeOpenStop"]))
startOpStoreTime := vendorStoreInfo.FakeOpenStart
endOpStoreTime := vendorStoreInfo.FakeOpenStop
if startOpStoreTime == 0 || endOpStoreTime == 0 {
continue
}

View File

@@ -263,8 +263,8 @@ func ScoreStoreOpenTime(storeInfo *cms.StoreExt) {
finalScore := 0
if isStoreOpen {
for _, storeMap := range storeInfo.StoreMaps {
isSyncStoreSku := int(utils.MustInterface2Int64(storeMap["isSync"]))
vendorStoreStatus := int(utils.MustInterface2Int64(storeMap["status"]))
isSyncStoreSku := storeMap.IsSync
vendorStoreStatus := storeMap.Status
isVendorStoreOpen := vendorStoreStatus == model.StoreStatusOpened
opTimeList := storeInfo.GetOpTimeList()
if len(opTimeList) > 0 && isStoreOpen && isVendorStoreOpen && isSyncStoreSku != 0 {
@@ -428,8 +428,8 @@ func ScoreFullVendor(storeInfo *cms.StoreExt) {
isStoreOpen := storeStatus == model.StoreStatusOpened
count := 0
for _, storeMap := range storeInfo.StoreMaps {
isSyncStoreSku := int(utils.MustInterface2Int64(storeMap["isSync"]))
vendorStoreStatus := int(utils.MustInterface2Int64(storeMap["status"]))
isSyncStoreSku := storeMap.IsSync
vendorStoreStatus := storeMap.Status
isVendorStoreOpen := vendorStoreStatus == model.StoreStatusOpened
opTimeList := storeInfo.GetOpTimeList()
if len(opTimeList) > 0 && isStoreOpen && isVendorStoreOpen && isSyncStoreSku != 0 {
@@ -569,9 +569,9 @@ func GetFilterStoreListEx(storeList []*cms.StoreExt, storeIDMap map[int]int) (ou
continue
}
}
var tempStoreMaps []map[string]interface{}
var tempStoreMaps []*model.StoreMap
for _, vendorStoreInfo := range storeInfo.StoreMaps {
vendorID := int(utils.MustInterface2Int64(vendorStoreInfo["vendorID"]))
vendorID := vendorStoreInfo.VendorID
if _, ok := fullVendorList[vendorID]; !ok {
continue
}