Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop
This commit is contained in:
@@ -4693,3 +4693,4 @@ func StoreSkuPriceAudit(ctx *jxcontext.Context, storeSkuAudits []*model.StoreSku
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"github.com/astaxie/beego"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -22,7 +25,7 @@ import (
|
||||
|
||||
const (
|
||||
canWriteTolocal = false
|
||||
needStatistic = true
|
||||
needStatistic = false
|
||||
isFilterToBeCreateAndNotSale = true
|
||||
parallelCount = 5
|
||||
fileExt = ".xlsx"
|
||||
@@ -30,14 +33,16 @@ const (
|
||||
|
||||
//错误类型
|
||||
const (
|
||||
DatAanalyse1 = "京西门店未关注,应删除对应的平台门店商品"
|
||||
DatAanalyse2 = "平台商品库未创建成功(可能无经营许可等) "
|
||||
DatAanalyse3 = "商品名不同 "
|
||||
DatAanalyse4 = "商品可售状态不同 "
|
||||
DatAanalyse5 = "京西商品库没有,平台商品库有 "
|
||||
DatAanalyse6 = "京西商品库有,平台商品库没有"
|
||||
DatAanalyse7 = "同步状态异常"
|
||||
DatAanalyse8 = "平台门店未关注或平台门店商品库存为0,应添加对应的平台门店商品"
|
||||
DatAanalyse1 = "京西门店未关注,应删除对应的平台门店商品"
|
||||
DatAanalyse2 = "平台商品库未创建成功(可能无经营许可等) "
|
||||
DatAanalyse3 = "商品名不同 "
|
||||
DatAanalyse4 = "商品可售状态不同 "
|
||||
DatAanalyse5 = "京西商品库没有,平台商品库有 "
|
||||
DatAanalyse6 = "京西商品库有,平台商品库没有"
|
||||
DatAanalyse7 = "同步状态异常"
|
||||
DatAanalyse8 = "平台门店未关注或平台门店商品库存为0,应添加对应的平台门店商品"
|
||||
DatAanalyse9 = "平台门店价格与京西商品库价格不一致"
|
||||
DatAanalyse10 = "平台商品的VendorSkuID与京西的VendorSkuID不一致"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -55,6 +60,8 @@ var (
|
||||
"平台门店ID",
|
||||
"门店名",
|
||||
"SkuID",
|
||||
"京西美团外卖ID",
|
||||
"京西饿百ID",
|
||||
"同步状态",
|
||||
"待创建",
|
||||
"待删除",
|
||||
@@ -62,6 +69,8 @@ var (
|
||||
"平台商品名",
|
||||
"京西可售状态",
|
||||
"平台可售状态",
|
||||
"京西价格",
|
||||
"平台价格",
|
||||
"数据分析",
|
||||
}
|
||||
|
||||
@@ -129,6 +138,8 @@ type DiffData struct {
|
||||
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:"待删除"`
|
||||
@@ -136,6 +147,8 @@ type DiffData struct {
|
||||
VendorSkuName string `json:"平台商品名"`
|
||||
JxStatus string `json:"京西可售状态"`
|
||||
VendorStatus string `json:"平台可售状态"`
|
||||
JxSkuPrice string `json:"京西价格"` /*哇,不能小写,不然会搞事情*/
|
||||
VendorPrice string `json:"平台价格"`
|
||||
DatAanalyse string `json:"数据分析"`
|
||||
}
|
||||
|
||||
@@ -216,7 +229,13 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) {
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("GetMultiStoreAllSkuInfo error:%v", err)
|
||||
} else {
|
||||
multiStoreAllSkuInfoList[vendorID][vendorOrgCode] = StoreSkuFullList2BareFilter(allSkuNameInfoList) //map[平台ID:[]StoreSkuInfo1,StoreSkuInfo2...]
|
||||
if multiStoreAllSkuInfoList[vendorID] != nil {
|
||||
multiStoreAllSkuInfoList[vendorID][vendorOrgCode] = StoreSkuFullList2BareFilter(allSkuNameInfoList) //map[平台ID:[]StoreSkuInfo1,StoreSkuInfo2...]
|
||||
} else {
|
||||
multiStoreAllSkuInfoList = make(map[int]map[string][]*partner.StoreSkuInfo)
|
||||
multiStoreAllSkuInfoList[vendorID] = make(map[string][]*partner.StoreSkuInfo)
|
||||
multiStoreAllSkuInfoList[vendorID][vendorOrgCode] = StoreSkuFullList2BareFilter(allSkuNameInfoList) //map[平台ID:[]StoreSkuInfo1,StoreSkuInfo2...]
|
||||
}
|
||||
tempMap := make(map[int]*partner.SkuNameInfo)
|
||||
for _, value := range allSkuNameInfoList {
|
||||
for _, skuInfo := range value.SkuList {
|
||||
@@ -332,10 +351,13 @@ func IsSkuCanSale(saleStatus int) bool {
|
||||
}
|
||||
|
||||
//京西平台和其他平台商品的对比
|
||||
//storeIDStr 京西商家id ,vendorStoreID 平台商家id
|
||||
func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*dao.StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo) {
|
||||
//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 方法")
|
||||
for skuID, jxSkuInfo := range filterJxSkuInfoMap {
|
||||
skuIDStr := utils.Int2Str(skuID)
|
||||
/*写京西skuIDStr*/
|
||||
//utils.Writelog("skuIDStr" + skuIDStr)
|
||||
var jxSkuDetailName string
|
||||
//多规格商品不用比较数量单位
|
||||
if jxSkuInfo.IsSpu == 0 {
|
||||
@@ -345,11 +367,17 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
//jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..)
|
||||
jxSkuDetailName = jxutils.ComposeSkuNameOriginal(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus[0].Comment, "", jxSkuInfo.Skus[0].SkuSpecQuality, "", 0)
|
||||
}
|
||||
|
||||
//utils.Writelog("jxSkuDetailName:" + jxSkuDetailName)
|
||||
//jxSkuSaleStatus : 商品状态 ,skustatus 优先级高于 StoreSkuStatus
|
||||
jxSkuSaleStatus := jxutils.MergeSkuStatus(jxSkuInfo.Skus[0].SkuStatus, jxSkuInfo.Skus[0].StoreSkuStatus)
|
||||
jxSkuSaleStatusName := GetSkuSaleStatusName(jxSkuSaleStatus)
|
||||
|
||||
jxSkuSaleStatusName := GetSkuSaleStatusName(jxSkuSaleStatus + 3)
|
||||
/*京西价格*/
|
||||
jxSkuPrice := fmt.Sprintf("%.2f", float64(jxSkuInfo.Skus[0].JxPrice)/float64(100))
|
||||
/*饿了吗编码*/
|
||||
ebaiid := jxSkuInfo.Skus[0].EbaiID
|
||||
/*美团编码*/
|
||||
mtwmid := jxSkuInfo.Skus[0].MtwmID
|
||||
//jxSkuPrice := strconv.Itoa(jxSkuInfo.Skus[0].JxPrice)
|
||||
vendorSkuInfo := filterVendorSkuInfoMap[skuID]
|
||||
var status int8
|
||||
if vendorID == model.VendorIDMTWM {
|
||||
@@ -365,14 +393,25 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
|
||||
if vendorSkuInfo != nil {
|
||||
vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName
|
||||
vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status)
|
||||
|
||||
vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status + 3)
|
||||
/* 供货商价格 */
|
||||
vendorPrice := fmt.Sprintf("%.2f", float64(vendorSkuInfo.SkuList[0].StoreSkuInfo.VendorPrice)/float64(100))
|
||||
var IdMark bool
|
||||
if isJd == 0 {
|
||||
IdMark = skuIDStr != ebaiid && skuIDStr != mtwmid
|
||||
} else {
|
||||
IdMark = false
|
||||
}
|
||||
isSaleStatusDiff := jxSkuSaleStatusName != vendorSkuSaleStatusName
|
||||
isNameDiff := jxSkuDetailName != vendorSkuDetailName
|
||||
/*比较价格*/
|
||||
isPriceDiff := vendorPrice != jxSkuPrice
|
||||
//utils.Writelog("isSaleStatusDiff:" + strconv.FormatBool(isSaleStatusDiff))
|
||||
//utils.Writelog("isNameDiff:" + strconv.FormatBool(isNameDiff))
|
||||
if jxSkuDetailName != "" && vendorSkuDetailName != "" && strings.Contains(jxSkuDetailName, vendorSkuDetailName) {
|
||||
isNameDiff = false
|
||||
}
|
||||
if isSaleStatusDiff || isNameDiff {
|
||||
if isSaleStatusDiff || isNameDiff || isPriceDiff {
|
||||
reason := ""
|
||||
if isNameDiff {
|
||||
reason += DatAanalyse3
|
||||
@@ -380,15 +419,21 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
if isSaleStatusDiff {
|
||||
reason += DatAanalyse4
|
||||
}
|
||||
if isPriceDiff {
|
||||
reason += DatAanalyse9
|
||||
}
|
||||
if IdMark {
|
||||
reason += DatAanalyse10
|
||||
}
|
||||
if status != model.SkuStatusDontSale {
|
||||
reason += DatAanalyse7
|
||||
}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, reason}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, mtwmid, ebaiid, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, jxSkuPrice, vendorPrice, reason}
|
||||
diffData.AppendData(vendorID, outPutData)
|
||||
}
|
||||
if !isSaleStatusDiff && !isNameDiff {
|
||||
if status != model.SkuStatusDontSale {
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, DatAanalyse7}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, mtwmid, ebaiid, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, jxSkuPrice, vendorPrice, DatAanalyse7}
|
||||
diffData.AppendData(vendorID, outPutData)
|
||||
}
|
||||
}
|
||||
@@ -405,7 +450,7 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
if status != model.SkuStatusDontSale {
|
||||
reason += DatAanalyse7
|
||||
}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", reason}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, mtwmid, ebaiid, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", jxSkuPrice, "", reason}
|
||||
diffData.AppendData(vendorID, outPutData)
|
||||
}
|
||||
}
|
||||
@@ -414,11 +459,14 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
if len(vendorSkuInfo.SkuList) > 0 {
|
||||
skuIDStr := utils.Int2Str(skuID)
|
||||
vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName
|
||||
vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status)
|
||||
|
||||
vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status + 3)
|
||||
/* 供货商价格 */
|
||||
vendorPrice := fmt.Sprintf("%.2f", float64(vendorSkuInfo.SkuList[0].StoreSkuInfo.VendorPrice)/float64(100))
|
||||
/* 供货商价格 */
|
||||
jxSkuInfo := filterJxSkuInfoMap[skuID]
|
||||
/*平台有,京西没有*/
|
||||
if jxSkuInfo == nil {
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, "", "", "", "", vendorSkuDetailName, "", vendorSkuSaleStatusName, DatAanalyse1}
|
||||
outPutData := DiffData{storeIDStr, vendorStoreID, "", "", storeName, skuIDStr, "", "", "", "", vendorSkuDetailName, "", vendorSkuSaleStatusName, "", vendorPrice, DatAanalyse1}
|
||||
diffData.AppendData(vendorID, outPutData)
|
||||
}
|
||||
} else {
|
||||
@@ -497,7 +545,7 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool
|
||||
if len(vendorSkuInfo.SkuList) > 0 {
|
||||
skuIDStr := utils.Int2Str(skuID)
|
||||
vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName
|
||||
vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status)
|
||||
vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status + 3)
|
||||
|
||||
jxSkuInfo := filterJxSkuInfoMap2[skuID]
|
||||
if jxSkuInfo == nil {
|
||||
@@ -515,6 +563,259 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiff(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) {
|
||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor start time: %v", time.Now())
|
||||
startProcessTime := time.Now().Unix()
|
||||
vendorMap := make(map[int]bool)
|
||||
for _, vendorID := range vendorIDList {
|
||||
vendorMap[vendorID] = true //map[平台ID:true]
|
||||
}
|
||||
storeIDMap := make(map[int]bool)
|
||||
for _, storeID := range storeIDList {
|
||||
storeIDMap[storeID] = true //map[门店ID:true]
|
||||
}
|
||||
/************************************************update**************************************************/
|
||||
//自己存值
|
||||
a := func() {
|
||||
for vendorID, _ := range vendorNameList {
|
||||
//filter for vendorID
|
||||
if len(vendorMap) > 0 {
|
||||
if _, ok := vendorMap[vendorID]; !ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if partner.IsMultiStore(vendorID) {
|
||||
multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler)
|
||||
for _, vendorOrgCode := range apimanager.CurAPIManager.GetAppOrgCodeList(vendorID) {
|
||||
allSkuNameInfoList, err := multiHandler.GetSkus(ctx, vendorOrgCode, 0, "")
|
||||
//获取单个表格对比的物品信息列表
|
||||
skuNameInfoList = allSkuNameInfoList
|
||||
if err != nil {
|
||||
fmt.Println("allSkuNameInfoList赋值错误,error信息" + err.Error())
|
||||
continue
|
||||
}
|
||||
//*partner.StoreSkuInfo skuNameList []*SkuNameInfo
|
||||
var bareStoreSkuList []*partner.StoreSkuInfo
|
||||
for _, v := range allSkuNameInfoList {
|
||||
for _, v2 := range v.SkuList {
|
||||
if v2.Status > model.SkuStatusDontSale {
|
||||
for _, v2 := range v.SkuList {
|
||||
bareStoreSkuList = append(bareStoreSkuList, &v2.StoreSkuInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//if multiStoreAllSkuInfoList[vendorID][vendorOrgCode] != nil && bareStoreSkuList != nil {
|
||||
if multiStoreAllSkuInfoList[vendorID] != nil && bareStoreSkuList != nil {
|
||||
multiStoreAllSkuInfoList[vendorID][vendorOrgCode] = bareStoreSkuList
|
||||
//}else if multiStoreAllSkuInfoList[vendorID][vendorOrgCode] == nil{
|
||||
} else if multiStoreAllSkuInfoList[vendorID] == nil {
|
||||
multiStoreAllSkuInfoList = make(map[int]map[string][]*partner.StoreSkuInfo)
|
||||
multiStoreAllSkuInfoList[vendorID] = make(map[string][]*partner.StoreSkuInfo)
|
||||
multiStoreAllSkuInfoList[vendorID][vendorOrgCode] = bareStoreSkuList
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
//商品信息
|
||||
if multiStoreAllSkuInfoMap[vendorID] == nil {
|
||||
multiStoreAllSkuInfoMap = make(map[int]map[string]map[int]*partner.SkuNameInfo)
|
||||
multiStoreAllSkuInfoMap[vendorID] = make(map[string]map[int]*partner.SkuNameInfo)
|
||||
//multiStoreAllSkuInfoMap[vendorID][vendorOrgCode] = make(map[int]*partner.SkuNameInfo)
|
||||
multiStoreAllSkuInfoMap[vendorID][vendorOrgCode] = tempMap
|
||||
} else {
|
||||
multiStoreAllSkuInfoMap[vendorID][vendorOrgCode] = tempMap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************update****************************************************/
|
||||
//1.获取京西本地所有门店信息 store、place、user表联查 jxStoreInfoList
|
||||
//2.过滤所有门店信息,只留下传进来的vendorMap,storeIDMap中对应的平台和门台信息 filterStoreList
|
||||
//3.判断是否多平台门店,两种情况两种处理
|
||||
b := func() {
|
||||
jxStoreInfoList, err := GetStores(ctx, "", map[string]interface{}{}, 0, -1, utils.DefaultTimeValue, utils.DefaultTimeValue, 0, 0)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("CheckSkuDiffBetweenJxAndVendor GetStores error:%v", err)
|
||||
} else {
|
||||
//获取总共几个门店任务
|
||||
filterStoreList := GetFilterStoreList(jxStoreInfoList.Stores, vendorMap, storeIDMap)
|
||||
diffData.InitData()
|
||||
jxStoreInfoListValue := filterStoreList[0]
|
||||
storeID := jxStoreInfoListValue.ID
|
||||
storeIDStr := utils.Int2Str(storeID)
|
||||
storeName := jxStoreInfoListValue.Name
|
||||
jxSkuInfoDataSingle := &dao.StoreSkuNamesInfo{}
|
||||
jxSkuInfoDataMulti := &dao.StoreSkuNamesInfo{}
|
||||
if jxStoreInfoListValue.StoreMaps != nil {
|
||||
var multiFlag = false
|
||||
var singleFlag = false
|
||||
var filterJxSkuInfoMapSingle map[int]*dao.StoreSkuNameExt
|
||||
var filterJxSkuInfoMapMulti map[int]*dao.StoreSkuNameExt
|
||||
for _, vendorListValue := range jxStoreInfoListValue.StoreMaps {
|
||||
vendorID := vendorListValue.VendorID
|
||||
if partner.IsMultiStore(vendorID) {
|
||||
if multiFlag == false {
|
||||
jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
/*重新计算价格*/
|
||||
SetJxPrice(jxSkuInfoDataMulti, storeID)
|
||||
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)
|
||||
filterJxSkuInfoMapSingle = GetFilterJxSkuInfoMap(jxSkuInfoDataSingle.SkuNames) //map[京西商品ID:StoreSkuNameExt]
|
||||
singleFlag = true
|
||||
}
|
||||
}
|
||||
|
||||
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, vendorListValue.VendorOrgCode)
|
||||
skuBareInfoList, err := singleStoreHandler.GetStoreSkusBareInfo(ctx, vendorListValue.VendorOrgCode, nil, storeID, vendorStoreID, allSkuInfoList)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusBareInfo error:%v", err)
|
||||
} else if len(skuBareInfoList) > 0 {
|
||||
//获取京东的商品
|
||||
filterSkuInfoMap := GetFilterMultiStoreSkuInfoMap(vendorID, vendorListValue.VendorOrgCode, skuBareInfoList) //map[京东商品ID:SkuNameInfo]
|
||||
CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapMulti, filterSkuInfoMap, 1)
|
||||
}
|
||||
} else {
|
||||
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
vendorSkuInfoList, err := singleStoreHandler.GetStoreSkusFullInfo(ctx, nil, storeID, vendorStoreID, nil)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusFullInfo error:%v", err)
|
||||
} else if len(vendorSkuInfoList) > 0 {
|
||||
//获取京东的商品
|
||||
filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(vendorSkuInfoList) //map[平台商品ID:SkuNameInfo]
|
||||
CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapSingle, filterVendorSkuInfoMap, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/********************************第三步****************************/
|
||||
c := func(data map[int][]DiffData, depotData map[int][]DepotDiffData) {
|
||||
var sheetList []*excel.Obj2ExcelSheetConfig
|
||||
for key, value := range data {
|
||||
sheetName := vendorNameList[key]
|
||||
if partner.IsMultiStore(key) {
|
||||
excelConfDepot := &excel.Obj2ExcelSheetConfig{
|
||||
Title: sheetName + "商品库与京西商品库对比",
|
||||
Data: depotData[key],
|
||||
CaptionList: deoptTitleList,
|
||||
}
|
||||
sheetList = append(sheetList, excelConfDepot)
|
||||
}
|
||||
excelConf := &excel.Obj2ExcelSheetConfig{
|
||||
Title: sheetName,
|
||||
Data: value,
|
||||
CaptionList: titleList,
|
||||
}
|
||||
sheetList = append(sheetList, excelConf)
|
||||
if needStatistic {
|
||||
statisticSheet := AddStatisticSheet(sheetName, value)
|
||||
sheetList = append(sheetList, statisticSheet)
|
||||
}
|
||||
baseapi.SugarLogger.Debugf("WriteToExcel:append:%s count:%d", sheetName, len(value))
|
||||
}
|
||||
|
||||
if len(sheetList) > 0 {
|
||||
excelBin := excel.Obj2Excel(sheetList)
|
||||
sheetList = nil
|
||||
timeStr := utils.Int64ToStr(time.Now().Unix())
|
||||
diffFullFileName := diffFileName[IsJXCS()] + timeStr + fileExt
|
||||
if canWriteTolocal {
|
||||
jxutils.WriteFile(diffFullFileName, excelBin)
|
||||
}
|
||||
baseapi.SugarLogger.Debugf("WriteToExcel:save %s success", diffFullFileName)
|
||||
//上传
|
||||
downloadURL, err := jxutils.UploadExportContent(excelBin, diffFullFileName)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s failed error:%v", diffFullFileName, err)
|
||||
} else {
|
||||
baseapi.SugarLogger.Debugf("WriteToExcel:upload %s success, downloadURL: %s", diffFullFileName, downloadURL)
|
||||
/*************发送钉钉消息**************/
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "", "异步任务完成", "京西平台对比数据上传成功:Excel下载地址是 "+downloadURL)
|
||||
}
|
||||
} else {
|
||||
baseapi.SugarLogger.Debug("WriteToExcel:No diff data!!!")
|
||||
}
|
||||
//}
|
||||
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)
|
||||
}
|
||||
apiover := make(chan int, 1)
|
||||
compover := make(chan int, 1)
|
||||
over := false
|
||||
/********************************第三步****************************/
|
||||
/*异步任务*/
|
||||
/************************************************************************************/
|
||||
go func() {
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
beego.Info("执行任务失败")
|
||||
panic("API调用失败")
|
||||
}
|
||||
}()
|
||||
a()
|
||||
depotDiffData.InitData2()
|
||||
CompareJxAndMultiVenderDepot(ctx, vendorMap)
|
||||
apiover <- 0
|
||||
}()
|
||||
/*a等待a现成执行完*/
|
||||
go func() {
|
||||
for !over {
|
||||
select {
|
||||
case <-apiover:
|
||||
/*第二步 为了获取 filterJxDepotUnSaleSkuIds*/
|
||||
go func() {
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
beego.Info("比较任务失败")
|
||||
panic("比较任务失败")
|
||||
}
|
||||
}()
|
||||
b()
|
||||
compover <- 0 //比较任务完成
|
||||
}()
|
||||
/*第二步*/
|
||||
case <-compover:
|
||||
go func() {
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
beego.Info("写入任务失败")
|
||||
panic("写入任务失败")
|
||||
}
|
||||
}()
|
||||
c(diffData.diffDataMap, depotDiffData.diffDataMap)
|
||||
fmt.Println("任务执行完成")
|
||||
over = true
|
||||
}()
|
||||
break
|
||||
}
|
||||
}
|
||||
}()
|
||||
/************************************************************************************/
|
||||
}
|
||||
|
||||
//入口函数,校验本地商品京西和其他平台的差异
|
||||
func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) {
|
||||
startProcessTime := time.Now().Unix()
|
||||
@@ -588,7 +889,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
|
||||
baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusBareInfo error:%v", err)
|
||||
} else if len(skuBareInfoList) > 0 {
|
||||
filterSkuInfoMap := GetFilterMultiStoreSkuInfoMap(vendorID, vendorListValue.VendorOrgCode, skuBareInfoList) //map[京东商品ID:SkuNameInfo]
|
||||
CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapMulti, filterSkuInfoMap)
|
||||
CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapMulti, filterSkuInfoMap, 1)
|
||||
}
|
||||
} else {
|
||||
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
@@ -597,7 +898,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
|
||||
baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusFullInfo error:%v", err)
|
||||
} else if len(vendorSkuInfoList) > 0 {
|
||||
filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(vendorSkuInfoList) //map[平台商品ID:SkuNameInfo]
|
||||
CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapSingle, filterVendorSkuInfoMap)
|
||||
CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapSingle, filterVendorSkuInfoMap, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -719,6 +1020,7 @@ func WriteToExcel(task *tasksch.SeqTask, data map[int][]DiffData, depotData map[
|
||||
jxutils.WriteFile(diffFullFileName, excelBin)
|
||||
}
|
||||
baseapi.SugarLogger.Debugf("WriteToExcel:save %s success", diffFullFileName)
|
||||
//上传
|
||||
downloadURL, err := jxutils.UploadExportContent(excelBin, diffFullFileName)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s failed error:%v", diffFullFileName, err)
|
||||
@@ -731,3 +1033,20 @@ func WriteToExcel(task *tasksch.SeqTask, data map[int][]DiffData, depotData map[
|
||||
baseapi.SugarLogger.Debug("WriteToExcel:No diff data!!!")
|
||||
}
|
||||
}
|
||||
|
||||
func SetJxPrice(jxSkuInfoDataMulti *dao.StoreSkuNamesInfo, storeId int) (err error) {
|
||||
db := dao.GetDB()
|
||||
storeDetail, err := dao.GetStoreDetail(dao.GetDB(), storeId, model.VendorIDJX)
|
||||
if err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
/*重新计算京西价格*/
|
||||
for _, values := range jxSkuInfoDataMulti.SkuNames {
|
||||
for _, value := range values.Skus {
|
||||
value.JxPrice = jxutils.CaculatePriceByPricePack(storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage), value.JxPrice)
|
||||
}
|
||||
}
|
||||
/*重新计算京西价格*/
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package cms
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
)
|
||||
|
||||
func TestCheckSkuDiffBetweenJxAndVendor(t *testing.T) {
|
||||
vendorIDList := []int{}
|
||||
storeIDList := []int{}
|
||||
CheckSkuDiffBetweenJxAndVendor(jxcontext.AdminCtx, vendorIDList, storeIDList)
|
||||
}
|
||||
Reference in New Issue
Block a user