京西平台和其他平台商品的对比
This commit is contained in:
@@ -2,6 +2,7 @@ package cms
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
"fmt"
|
||||||
"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"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
@@ -11,6 +12,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
"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/jxutils/excel"
|
"git.rosy.net.cn/jx-callback/business/jxutils/excel"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -198,16 +200,14 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckSkuDiffBetweenJxAndVendor(vendorIDList []string, storeIDList []string) {
|
func CheckSkuDiffBetweenJxAndVendor(vendorIDList []int, storeIDList []int) {
|
||||||
startProcessTime := time.Now().Unix()
|
startProcessTime := time.Now().Unix()
|
||||||
vendorMap := make(map[int]bool)
|
vendorMap := make(map[int]bool)
|
||||||
for _, value := range vendorIDList {
|
for _, vendorID := range vendorIDList {
|
||||||
vendorID := int(utils.Str2Int64(value))
|
|
||||||
vendorMap[vendorID] = true
|
vendorMap[vendorID] = true
|
||||||
}
|
}
|
||||||
storeIDMap := make(map[int]bool)
|
storeIDMap := make(map[int]bool)
|
||||||
for _, value := range storeIDList {
|
for _, storeID := range storeIDList {
|
||||||
storeID := int(utils.Str2Int64(value))
|
|
||||||
storeIDMap[storeID] = true
|
storeIDMap[storeID] = true
|
||||||
}
|
}
|
||||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor start time: %v", time.Now())
|
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor start time: %v", time.Now())
|
||||||
@@ -218,75 +218,84 @@ func CheckSkuDiffBetweenJxAndVendor(vendorIDList []string, storeIDList []string)
|
|||||||
} else {
|
} else {
|
||||||
GetJdAllSkuInfo()
|
GetJdAllSkuInfo()
|
||||||
diffData = make(map[int][]DiffData)
|
diffData = make(map[int][]DiffData)
|
||||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
jxStoreInfoListValue := batchItemList[0].(*StoreExt)
|
switch step {
|
||||||
storeID := jxStoreInfoListValue.ID
|
case 0:
|
||||||
//filter for storeID
|
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
if len(storeIDMap) > 0 {
|
jxStoreInfoListValue := batchItemList[0].(*StoreExt)
|
||||||
if _, ok := storeIDMap[storeID]; !ok {
|
storeID := jxStoreInfoListValue.ID
|
||||||
return retVal, err
|
//filter for storeID
|
||||||
}
|
if len(storeIDMap) > 0 {
|
||||||
}
|
if _, ok := storeIDMap[storeID]; !ok {
|
||||||
storeIDStr := utils.Int2Str(storeID)
|
return retVal, err
|
||||||
storeName := jxStoreInfoListValue.Name
|
|
||||||
if jxStoreInfoListValue.StoreMaps != nil {
|
|
||||||
for vendorListIndex, vendorListValue := range jxStoreInfoListValue.StoreMaps {
|
|
||||||
vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"]))
|
|
||||||
//filter for vendorID
|
|
||||||
if len(vendorMap) > 0 {
|
|
||||||
if _, ok := vendorMap[vendorID]; !ok {
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if _, ok := vendorNameList[vendorID]; ok {
|
|
||||||
var filterJxSkuInfoMap map[int]*StoreSkuNameExt
|
|
||||||
if vendorListIndex == 0 {
|
|
||||||
jxSkuInfoData, _ := GetStoreSkus(ctx, storeID, []int{}, true, "", true, map[string]interface{}{}, 0, -1)
|
|
||||||
filterJxSkuInfoMap = GetFilterJxSkuInfoMap(jxSkuInfoData.SkuNames)
|
|
||||||
}
|
|
||||||
|
|
||||||
vendorStoreID := utils.Interface2String(vendorListValue["vendorStoreID"])
|
|
||||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor storeID:%d vendorID:%d vendorStoreID:%s vendorListValue:%v", storeID, vendorID, vendorStoreID, vendorListValue)
|
|
||||||
|
|
||||||
if vendorID == model.VendorIDJD {
|
|
||||||
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
|
||||||
jdSkuInfoList, err := singleStoreHandler.GetStoreSkusBareInfo(ctx, nil, storeID, vendorStoreID, jdAllSkuInfoList)
|
|
||||||
if err != nil {
|
|
||||||
baseapi.SugarLogger.Errorf("CheckSkuDiffBetweenJxAndVendor GetStoreSkusBareInfo error:%v", err)
|
|
||||||
} else if len(jdSkuInfoList) > 0 {
|
|
||||||
filterJdSkuInfoMap := GetFilterJdSkuInfoMap(jdSkuInfoList)
|
|
||||||
CompareJxAndJd(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMap, filterJdSkuInfoMap)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
|
||||||
vendorSkuInfoList, err := singleStoreHandler.GetStoreSkusFullInfo(ctx, nil, storeID, vendorStoreID, nil)
|
|
||||||
if err != nil {
|
|
||||||
baseapi.SugarLogger.Errorf("CheckSkuDiffBetweenJxAndVendor GetStoreSkusFullInfo error:%v", err)
|
|
||||||
} else if len(vendorSkuInfoList) > 0 {
|
|
||||||
filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(vendorSkuInfoList)
|
|
||||||
CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMap, filterVendorSkuInfoMap)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
storeIDStr := utils.Int2Str(storeID)
|
||||||
|
storeName := jxStoreInfoListValue.Name
|
||||||
|
if jxStoreInfoListValue.StoreMaps != nil {
|
||||||
|
for vendorListIndex, vendorListValue := range jxStoreInfoListValue.StoreMaps {
|
||||||
|
vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"]))
|
||||||
|
//filter for vendorID
|
||||||
|
if len(vendorMap) > 0 {
|
||||||
|
if _, ok := vendorMap[vendorID]; !ok {
|
||||||
|
return retVal, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := vendorNameList[vendorID]; ok {
|
||||||
|
var filterJxSkuInfoMap map[int]*StoreSkuNameExt
|
||||||
|
if vendorListIndex == 0 {
|
||||||
|
jxSkuInfoData, _ := GetStoreSkus(ctx, storeID, []int{}, true, "", true, map[string]interface{}{}, 0, -1)
|
||||||
|
filterJxSkuInfoMap = GetFilterJxSkuInfoMap(jxSkuInfoData.SkuNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
vendorStoreID := utils.Interface2String(vendorListValue["vendorStoreID"])
|
||||||
|
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor storeID:%d vendorID:%d vendorStoreID:%s vendorListValue:%v", storeID, vendorID, vendorStoreID, vendorListValue)
|
||||||
|
|
||||||
|
if vendorID == model.VendorIDJD {
|
||||||
|
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
||||||
|
jdSkuInfoList, err := singleStoreHandler.GetStoreSkusBareInfo(ctx, nil, storeID, vendorStoreID, jdAllSkuInfoList)
|
||||||
|
if err != nil {
|
||||||
|
baseapi.SugarLogger.Errorf("CheckSkuDiffBetweenJxAndVendor GetStoreSkusBareInfo error:%v", err)
|
||||||
|
} else if len(jdSkuInfoList) > 0 {
|
||||||
|
filterJdSkuInfoMap := GetFilterJdSkuInfoMap(jdSkuInfoList)
|
||||||
|
CompareJxAndJd(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMap, filterJdSkuInfoMap)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||||
|
vendorSkuInfoList, err := singleStoreHandler.GetStoreSkusFullInfo(ctx, nil, storeID, vendorStoreID, nil)
|
||||||
|
if err != nil {
|
||||||
|
baseapi.SugarLogger.Errorf("CheckSkuDiffBetweenJxAndVendor GetStoreSkusFullInfo error:%v", err)
|
||||||
|
} else if len(vendorSkuInfoList) > 0 {
|
||||||
|
filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(vendorSkuInfoList)
|
||||||
|
CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMap, filterVendorSkuInfoMap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retVal, err
|
||||||
}
|
}
|
||||||
}
|
taskParallel := tasksch.NewParallelTask("CheckSkuDiffBetweenJxAndVendor", tasksch.NewParallelConfig().SetParallelCount(parallelCount), ctx, taskFunc, jxStoreInfoList.Stores)
|
||||||
|
tasksch.HandleTask(taskParallel, task, false).Run()
|
||||||
|
_, err = taskParallel.GetResult(0)
|
||||||
|
if err != nil {
|
||||||
|
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor taskParallel error:%v", err)
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
WriteToExcel(task, diffData)
|
||||||
|
endProcessTime := time.Now().Unix()
|
||||||
|
diff := endProcessTime - startProcessTime
|
||||||
|
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor end time: %v", time.Now())
|
||||||
|
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor cost time: %d sec", diff)
|
||||||
}
|
}
|
||||||
return retVal, err
|
return result, err
|
||||||
}
|
}
|
||||||
task := tasksch.NewParallelTask("CheckSkuDiffBetweenJxAndVendor", tasksch.NewParallelConfig().SetParallelCount(parallelCount), ctx, taskFunc, jxStoreInfoList.Stores)
|
taskSeq := tasksch.NewSeqTask("CheckSkuDiffBetweenJxAndVendor SeqTask", ctx, taskSeqFunc, 2)
|
||||||
tasksch.HandleTask(task, nil, false).Run()
|
tasksch.HandleTask(taskSeq, nil, false).Run()
|
||||||
_, err = task.GetResult(0)
|
|
||||||
if err != nil {
|
|
||||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor tasksch error:%v", err)
|
|
||||||
}
|
|
||||||
WriteToExcel(diffData)
|
|
||||||
endProcessTime := time.Now().Unix()
|
|
||||||
diff := endProcessTime - startProcessTime
|
|
||||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor end time: %v", time.Now())
|
|
||||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor cost time: %d sec", diff)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteToExcel(data map[int][]DiffData) {
|
func WriteToExcel(task *tasksch.SeqTask, data map[int][]DiffData) {
|
||||||
var sheetList []*excel.Obj2ExcelSheetConfig
|
var sheetList []*excel.Obj2ExcelSheetConfig
|
||||||
for key, value := range data {
|
for key, value := range data {
|
||||||
sheetName := vendorNameList[key]
|
sheetName := vendorNameList[key]
|
||||||
@@ -310,6 +319,8 @@ func WriteToExcel(data map[int][]DiffData) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s failed error:%v", diffFullFileName, err)
|
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s failed error:%v", diffFullFileName, err)
|
||||||
} else {
|
} else {
|
||||||
|
noticeMsg := fmt.Sprintf("[详情点我](%s/billshow/?normal=true&path=%s) \n", globals.BackstageHost, downloadURL)
|
||||||
|
task.SetNoticeMsg(noticeMsg)
|
||||||
baseapi.SugarLogger.Debugf("WriteToExcel:upload %s success, downloadURL:%s", diffFullFileName, downloadURL)
|
baseapi.SugarLogger.Debugf("WriteToExcel:upload %s success, downloadURL:%s", diffFullFileName, downloadURL)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/tempop"
|
"git.rosy.net.cn/jx-callback/business/jxstore/tempop"
|
||||||
@@ -295,23 +294,20 @@ func (c *TempOpController) TestStartOrEndOpStore() {
|
|||||||
|
|
||||||
// @Title 京西平台和其他平台商品的对比
|
// @Title 京西平台和其他平台商品的对比
|
||||||
// @Description 京西平台和其他平台商品的对比
|
// @Description 京西平台和其他平台商品的对比
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param vendorIDList query string false "运营商ID列表(京东0 美团1 饿百3)"
|
// @Param vendorIDs formData string false "运营商ID列表(京东0 美团1 饿百3)"
|
||||||
// @Param storeIDList query string false "京西门店ID列表"
|
// @Param storeIDs formData string false "京西门店ID列表"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /CheckSkuDiffBetweenJxAndVendor [get]
|
// @router /CheckSkuDiffBetweenJxAndVendor [post]
|
||||||
func (c *TempOpController) CheckSkuDiffBetweenJxAndVendor() {
|
func (c *TempOpController) CheckSkuDiffBetweenJxAndVendor() {
|
||||||
c.callCheckSkuDiffBetweenJxAndVendor(func(params *tTempopCheckSkuDiffBetweenJxAndVendorParams) (retVal interface{}, errCode string, err error) {
|
c.callCheckSkuDiffBetweenJxAndVendor(func(params *tTempopCheckSkuDiffBetweenJxAndVendorParams) (retVal interface{}, errCode string, err error) {
|
||||||
var vendorIDList []string
|
var vendorIDList []int
|
||||||
if params.VendorIDList != "" {
|
var storeIDList []int
|
||||||
vendorIDList = strings.Split(params.VendorIDList, ",")
|
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil {
|
||||||
|
cms.CheckSkuDiffBetweenJxAndVendor(vendorIDList, storeIDList)
|
||||||
}
|
}
|
||||||
var storeIDList []string
|
|
||||||
if params.StoreIDList != "" {
|
|
||||||
storeIDList = strings.Split(params.StoreIDList, ",")
|
|
||||||
}
|
|
||||||
cms.CheckSkuDiffBetweenJxAndVendor(vendorIDList, storeIDList)
|
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1658,7 +1658,7 @@ func init() {
|
|||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "CheckSkuDiffBetweenJxAndVendor",
|
Method: "CheckSkuDiffBetweenJxAndVendor",
|
||||||
Router: `/CheckSkuDiffBetweenJxAndVendor`,
|
Router: `/CheckSkuDiffBetweenJxAndVendor`,
|
||||||
AllowHTTPMethods: []string{"get"},
|
AllowHTTPMethods: []string{"post"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|||||||
Reference in New Issue
Block a user