1
This commit is contained in:
@@ -3,12 +3,14 @@ package cms
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"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/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/globals/api/apimanager"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
"time"
|
||||
|
||||
@@ -206,37 +208,37 @@ func CopyMtToMT(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isA
|
||||
switch step {
|
||||
case 1:
|
||||
// 同步分类
|
||||
//fromCategoryList, err := fromApi.RetailCatList(fromStore.VendorStoreID)
|
||||
//if len(fromCategoryList) == model.NO {
|
||||
// return nil, err
|
||||
//}
|
||||
//toCategoryList, err := toApi.RetailCatList(toStore.VendorStoreID)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//if len(fromCategoryList) != len(toCategoryList) {
|
||||
// for _, v := range fromCategoryList {
|
||||
// categoryErr := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||
// CategoryCode: v.Code,
|
||||
// Sequence: v.Sequence,
|
||||
// })
|
||||
// if categoryErr != nil {
|
||||
// globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr)
|
||||
// }
|
||||
// if v.Children != nil && len(v.Children) != 0 {
|
||||
// for _, c := range v.Children {
|
||||
// if err3 := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||
// CategoryNameOrigin: v.Name,
|
||||
// SecondaryCategoryCode: c.Code,
|
||||
// SecondaryCategoryName: c.Name,
|
||||
// Sequence: c.Sequence,
|
||||
// }); err3 != nil {
|
||||
// globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err3)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
fromCategoryList, err := fromApi.RetailCatList(fromStore.VendorStoreID)
|
||||
if len(fromCategoryList) == model.NO {
|
||||
return nil, err
|
||||
}
|
||||
toCategoryList, err := toApi.RetailCatList(toStore.VendorStoreID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(fromCategoryList) != len(toCategoryList) {
|
||||
for _, v := range fromCategoryList {
|
||||
categoryErr := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||
CategoryCode: v.Code,
|
||||
Sequence: v.Sequence,
|
||||
})
|
||||
if categoryErr != nil {
|
||||
globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr)
|
||||
}
|
||||
if v.Children != nil && len(v.Children) != 0 {
|
||||
for _, c := range v.Children {
|
||||
if err3 := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||
CategoryNameOrigin: v.Name,
|
||||
SecondaryCategoryCode: c.Code,
|
||||
SecondaryCategoryName: c.Name,
|
||||
Sequence: c.Sequence,
|
||||
}); err3 != nil {
|
||||
globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
i := offSet
|
||||
for {
|
||||
@@ -245,7 +247,6 @@ func CopyMtToMT(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isA
|
||||
if len(fromFoodList) == 0 || fromFoodList == nil {
|
||||
return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i)
|
||||
}
|
||||
globals.SugarLogger.Debugf("fromFoodList===============: %d", len(fromFoodList))
|
||||
|
||||
errDataList, err := BatchInitSkuMT2MT(ctx, fromFoodList, toApi, toStore.VendorStoreID, i)
|
||||
if err != nil {
|
||||
@@ -285,6 +286,8 @@ func CopyMtToMT(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isA
|
||||
func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string, offset int) ([]*mtwmapi.AppFoodResult, error) {
|
||||
errList := make([]*mtwmapi.AppFoodResult, 0, 0)
|
||||
foodDataList := make([]map[string]interface{}, len(fromSku))
|
||||
apiObj := apimanager.CurAPIManager.GetAPI(model.VendorIDJD, "320406").(*jdapi.API)
|
||||
|
||||
for k, storeSku := range fromSku {
|
||||
foodData := make(map[string]interface{})
|
||||
if storeSku.AppFoodCode != "" {
|
||||
@@ -296,6 +299,9 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
|
||||
skus := make([]interface{}, 0)
|
||||
upc := ""
|
||||
for _, v := range storeSku.SkuList {
|
||||
if v.Stock == "" {
|
||||
v.Stock = "99999"
|
||||
}
|
||||
if v.SkuId == "" {
|
||||
v.SkuId = storeSku.AppFoodCode
|
||||
}
|
||||
@@ -310,11 +316,29 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
|
||||
if v.BoxPrice == "" {
|
||||
delete(mapSkuList, "box_price")
|
||||
}
|
||||
if v.LadderBoxNum == "" {
|
||||
delete(mapSkuList, "ladder_box_num")
|
||||
}
|
||||
if v.LadderBoxPrice == "" {
|
||||
delete(mapSkuList, "ladder_box_price")
|
||||
}
|
||||
delete(mapSkuList, "min_order_count")
|
||||
if v.Upc != "" {
|
||||
upc = v.Upc
|
||||
} else if toApi.QuerySkuIsNeedUpc(storeSku.TagID) {
|
||||
upcList, _ := apiObj.GetJdUpcCodeByName(storeSku.Name, "", 1, 20)
|
||||
if len(upcList) != 0 {
|
||||
upc = upcList[0].UpcCode
|
||||
}
|
||||
}
|
||||
//mapSkuList["available_times"] = string(salesCycle)
|
||||
mapSkuList["available_times"] = v.AvailableTimes
|
||||
//if v.MinOrderCount != "" {
|
||||
// mapSkuList["min_order_count"] = utils.Str2Int(v.MinOrderCount)
|
||||
//}
|
||||
if upc != "" {
|
||||
mapSkuList["upc"] = upc
|
||||
}
|
||||
skus = append(skus, mapSkuList)
|
||||
}
|
||||
foodData["skus"] = skus
|
||||
@@ -324,7 +348,10 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
|
||||
foodData["min_order_count"] = storeSku.MinOrderCount
|
||||
foodData["unit"] = storeSku.Unit
|
||||
//todo 增加商品必填属性
|
||||
foodData["common_attr_value"] = storeSku.CommonAttrValue
|
||||
//foodData["common_attr_value"] = storeSku.CommonAttrValue
|
||||
if storeSku.CommonAttrValue != "" && storeSku.CommonAttrValue != "[]" {
|
||||
foodData["common_attr_value"] = mtwmapi.CommonAttrValueUpdate(storeSku.CommonAttrValue)
|
||||
}
|
||||
if storeSku.SecondaryCategoryCode != "" {
|
||||
foodData["category_code"] = storeSku.SecondaryCategoryCode
|
||||
} else {
|
||||
@@ -359,9 +386,7 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
|
||||
if len(foodDataList)%10 != 0 {
|
||||
count += 1
|
||||
}
|
||||
globals.SugarLogger.Debugf("fromFoodList===============count: %d", count)
|
||||
for i := 0; i < count; i++ {
|
||||
globals.SugarLogger.Debugf("fromFoodList===============i: %d", i)
|
||||
if i == count-1 {
|
||||
failedFoodList, _ := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:])
|
||||
if len(failedFoodList) != 0 {
|
||||
@@ -369,15 +394,12 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
|
||||
errList = append(errList, failedFoodList...)
|
||||
}
|
||||
} else {
|
||||
failedFoodList, err := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:(i+1)*10])
|
||||
failedFoodList, _ := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:(i+1)*10])
|
||||
if len(failedFoodList) != 0 {
|
||||
globals.SugarLogger.Debugf("failedFoodList := %s", utils.Format4Output(failedFoodList, false))
|
||||
errList = append(errList, failedFoodList...)
|
||||
}
|
||||
globals.SugarLogger.Debugf("========failedFoodList : = %s", utils.Format4Output(failedFoodList, false))
|
||||
globals.SugarLogger.Debugf("========failedFoodList : = %v", err)
|
||||
}
|
||||
globals.SugarLogger.Debugf("fromFoodList===============i: %d", 222222222)
|
||||
}
|
||||
|
||||
return errList, nil
|
||||
|
||||
@@ -1938,10 +1938,12 @@ func GetStoreSkuAudit(db *DaoDB, storeIDs, nameIDs, skuIDs, statuss, types []int
|
||||
txDB, _ := Begin(db)
|
||||
defer Commit(db, txDB)
|
||||
if err = GetRowsTx(txDB, &requestList, sql, sqlParams...); err == nil {
|
||||
return &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCount2(db, txDB),
|
||||
Data: requestList,
|
||||
}, nil
|
||||
result := &model.PagedInfo{
|
||||
Data: requestList,
|
||||
}
|
||||
result.TotalCount = GetLastTotalRowCount2(db, txDB)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user