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