修改细节

This commit is contained in:
Rosy-zhudan
2019-09-17 10:32:49 +08:00
parent 6199a2e714
commit 957db04544
3 changed files with 25 additions and 32 deletions

View File

@@ -5,6 +5,7 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils"
@@ -18,17 +19,17 @@ import (
) )
const ( const (
canWriteTolocal = false canWriteTolocal = false
needStatistic = true needStatistic = true
isFilterToBeCreateAndNotSale = true isFilterToBeCreateAndNotSale = true
parallelCount = 5 parallelCount = 5
fileExt = ".xlsx" fileExt = ".xlsx"
) )
var ( var (
diffFileName = map[bool]string { diffFileName = map[bool]string{
true : "export/JXCSAndVendorSkuDiff", true: "export/JXCSAndVendorSkuDiff",
false : "export/JXGYAndVendorSkuDiff", false: "export/JXGYAndVendorSkuDiff",
} }
vendorNameList = map[int]string{ vendorNameList = map[int]string{
model.VendorIDMTWM: model.VendorChineseNames[model.VendorIDMTWM], model.VendorIDMTWM: model.VendorChineseNames[model.VendorIDMTWM],
@@ -86,7 +87,7 @@ type DiffData struct {
SkuID string `json:"SkuID"` SkuID string `json:"SkuID"`
SyncStatus string `json:"同步状态"` SyncStatus string `json:"同步状态"`
ToBeCreate string `json:"待创建"` ToBeCreate string `json:"待创建"`
ToBeDel string `json:"待删除"` ToBeDel string `json:"待删除"`
JxSkuName string `json:"京西商品名"` JxSkuName string `json:"京西商品名"`
VendorSkuName string `json:"平台商品名"` VendorSkuName string `json:"平台商品名"`
JxStatus string `json:"京西可售状态"` JxStatus string `json:"京西可售状态"`
@@ -94,11 +95,11 @@ type DiffData struct {
} }
type StatisticData struct { type StatisticData struct {
JxVendorStatus string `json:"京西和平台商品状态"` JxVendorStatus string `json:"京西和平台商品状态"`
ToBeCreate string `json:"待创建"` ToBeCreate string `json:"待创建"`
JxSaleStatus string `json:"京西可售状态"` JxSaleStatus string `json:"京西可售状态"`
Count string `json:"数量"` Count string `json:"数量"`
Percent string `json:"占比"` Percent string `json:"占比"`
} }
func (d *DiffDataLock) AppendData(vendorID int, diffData DiffData) { func (d *DiffDataLock) AppendData(vendorID int, diffData DiffData) {
@@ -111,14 +112,6 @@ func (d *DiffDataLock) InitData() {
d.diffDataMap = make(map[int][]DiffData) d.diffDataMap = make(map[int][]DiffData)
} }
func IsMultiStore(vendorID int) bool {
if _, ok := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler); ok {
return true
}
return false
}
func InitMultiStoreData() { func InitMultiStoreData() {
multiStoreAllSkuInfoMap = make(map[int]map[int]*partner.SkuNameInfo) multiStoreAllSkuInfoMap = make(map[int]map[int]*partner.SkuNameInfo)
multiStoreAllSkuInfoList = make(map[int][]*partner.StoreSkuInfo) multiStoreAllSkuInfoList = make(map[int][]*partner.StoreSkuInfo)
@@ -141,7 +134,7 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) {
continue continue
} }
} }
if IsMultiStore(vendorID) { if partner.IsMultiStore(vendorID) {
multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler) multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler)
allSkuNameInfoList, err := multiHandler.GetSkus(ctx, 0, "", "") allSkuNameInfoList, err := multiHandler.GetSkus(ctx, 0, "", "")
if err != nil { if err != nil {
@@ -267,7 +260,7 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
syncStatus := utils.Int2Str(int(status)) syncStatus := utils.Int2Str(int(status))
toBeCreate := GetBoolName(model.IsSyncStatusNeedCreate(status)) toBeCreate := GetBoolName(model.IsSyncStatusNeedCreate(status))
toBeDel := GetBoolName(model.IsSyncStatusNeedDelete(status)) toBeDel := GetBoolName(model.IsSyncStatusNeedDelete(status))
if vendorSkuInfo != nil { if vendorSkuInfo != nil {
vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName
vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status) vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status)
@@ -276,7 +269,7 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
isNameDiff := jxSkuDetailName != vendorSkuDetailName isNameDiff := jxSkuDetailName != vendorSkuDetailName
if jxSkuDetailName != "" && vendorSkuDetailName != "" && strings.Contains(jxSkuDetailName, vendorSkuDetailName) { if jxSkuDetailName != "" && vendorSkuDetailName != "" && strings.Contains(jxSkuDetailName, vendorSkuDetailName) {
isNameDiff = false isNameDiff = false
} }
if isSaleStatusDiff || isNameDiff { if isSaleStatusDiff || isNameDiff {
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName} outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName}
diffData.AppendData(vendorID, outPutData) diffData.AppendData(vendorID, outPutData)
@@ -334,7 +327,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
var filterJxSkuInfoMap map[int]*StoreSkuNameExt var filterJxSkuInfoMap map[int]*StoreSkuNameExt
for _, vendorListValue := range jxStoreInfoListValue.StoreMaps { for _, vendorListValue := range jxStoreInfoListValue.StoreMaps {
vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"])) vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"]))
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, []int{}, true, "", true, map[string]interface{}{}, 0, -1) jxSkuInfoData, _ := GetStoreSkus(ctx, storeID, []int{}, true, "", true, map[string]interface{}{}, 0, -1)
@@ -344,7 +337,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
vendorStoreID := utils.Interface2String(vendorListValue["vendorStoreID"]) vendorStoreID := utils.Interface2String(vendorListValue["vendorStoreID"])
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor storeID:%d vendorID:%d vendorStoreID:%s vendorListValue:%v", storeID, vendorID, vendorStoreID, vendorListValue) baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor storeID:%d vendorID:%d vendorStoreID:%s vendorListValue:%v", storeID, vendorID, vendorStoreID, vendorListValue)
if IsMultiStore(vendorID) { if partner.IsMultiStore(vendorID) {
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler) singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
allSkuInfoList := GetMultiStoreAllSkuInfoList(vendorID) allSkuInfoList := GetMultiStoreAllSkuInfoList(vendorID)
skuBareInfoList, err := singleStoreHandler.GetStoreSkusBareInfo(ctx, task, storeID, vendorStoreID, allSkuInfoList) skuBareInfoList, err := singleStoreHandler.GetStoreSkusBareInfo(ctx, task, storeID, vendorStoreID, allSkuInfoList)
@@ -433,14 +426,14 @@ func AddStatisticSheet(sheetName string, data []DiffData) (sheet *excel.Obj2Exce
} }
} }
for index, value := range count { for index, value := range count {
percent[index] = float32(value * 100) / float32(totalCount) percent[index] = float32(value*100) / float32(totalCount)
countStr := utils.Int2Str(value) countStr := utils.Int2Str(value)
percentStr := fmt.Sprintf("%.2f%%", percent[index]) percentStr := fmt.Sprintf("%.2f%%", percent[index])
subStatisticData := statisticDataList[index] subStatisticData := statisticDataList[index]
statisticData[index] = StatisticData{subStatisticData[0], subStatisticData[1], subStatisticData[2], countStr, percentStr} statisticData[index] = StatisticData{subStatisticData[0], subStatisticData[1], subStatisticData[2], countStr, percentStr}
} }
sheetName = sheetName + "统计" sheetName = sheetName + "统计"
sheet = &excel.Obj2ExcelSheetConfig { sheet = &excel.Obj2ExcelSheetConfig{
Title: sheetName, Title: sheetName,
Data: statisticData, Data: statisticData,
CaptionList: statisticTitleList, CaptionList: statisticTitleList,

View File

@@ -2,9 +2,10 @@ package misc
import ( import (
"testing" "testing"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
) )
func TestStartOrEndOpStore(t *testing.T) { func TestStartOrEndOpStore(t *testing.T) {
StartOrEndOpStore(jxcontext.AdminCtx, true, []int{}, []int{}, 0, 0, false, true) StartOrEndOpStore(jxcontext.AdminCtx, true, nil, nil, 0, 0, false, true)
} }

View File

@@ -657,10 +657,9 @@ func ScheduleScoreStore() {
func CheckScoreStore() { func CheckScoreStore() {
if !isScoring { if !isScoring {
curTime := time.Now() curTime := time.Now()
year, month, day := curTime.Date() checkTimeStr1 := fmt.Sprintf("%s %s", utils.Time2DateStr(curTime), scoreStoreTimeList[0])
checkTimeStr1 := fmt.Sprintf("%d-%d-%d "+scoreStoreTimeList[0], year, int(month), day)
checkTime1 := utils.Str2Time(checkTimeStr1) checkTime1 := utils.Str2Time(checkTimeStr1)
checkTimeStr2 := fmt.Sprintf("%d-%d-%d "+scoreStoreCheckTimeEnd, year, int(month), day) checkTimeStr2 := fmt.Sprintf("%s %s", utils.Time2DateStr(curTime), scoreStoreCheckTimeEnd)
checkTime2 := utils.Str2Time(checkTimeStr2) checkTime2 := utils.Str2Time(checkTimeStr2)
if curTime.Unix() >= checkTime1.Unix() && curTime.Unix() <= checkTime2.Unix() { if curTime.Unix() >= checkTime1.Unix() && curTime.Unix() <= checkTime2.Unix() {
db := dao.GetDB() db := dao.GetDB()