1
This commit is contained in:
@@ -16,22 +16,24 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"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/apimanager"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 该函数主要用于对比京西平台商品和各个平台门店商品的差异
|
||||
// 对比上下架状态以及商品价格差异,相同的不做修改,不同的以京西系统商品为主
|
||||
|
||||
func CompareJxVendorSku(jxStoreId int, vendorIds []int) error {
|
||||
funcCompareJxVendorSku(jxStoreId int, vendorIds []int) (string, error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
errListToStr = new(strings.Builder)
|
||||
)
|
||||
skuList, err := dao.GetStoresSkusInfo(db, []int{jxStoreId}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 门店商品列表平
|
||||
@@ -46,7 +48,7 @@ func CompareJxVendorSku(jxStoreId int, vendorIds []int) error {
|
||||
// 有效的三方平台
|
||||
storeMap, err := dao.GetStoresMapList(db, vendorIds, []int{jxStoreId}, []int{model.StoreStatusOpened, model.StoreStatusClosed, model.StoreStatusHaveRest}, model.StoreStatusDisabled, 1, "", "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, sm := range storeMap {
|
||||
@@ -73,11 +75,11 @@ func CompareJxVendorSku(jxStoreId int, vendorIds []int) error {
|
||||
}
|
||||
continue
|
||||
default:
|
||||
return fmt.Errorf("无法识别的平台id")
|
||||
return errListToStr.String(), fmt.Errorf("无法识别的平台id")
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
|
||||
// MtWmSyncSkuPriceAndStatus 校验美团平台和京西系统商品差异
|
||||
@@ -90,6 +92,13 @@ func MtWmSyncSkuPriceAndStatus(db *dao.DaoDB, sm *model.StoreMap, skuMap map[str
|
||||
vendorStatus = 0
|
||||
)
|
||||
|
||||
if sm.VendorOrgCode == globals.Mtwm2Code {
|
||||
mtApi = mtwmapi.New(beego.AppConfig.DefaultString("mtwmAppID2", ""), beego.AppConfig.DefaultString("mtwmSecret2", ""), beego.AppConfig.DefaultString("mtwmCallbackURL2", ""), "")
|
||||
mtApi.SetToken(sm.MtwmToken)
|
||||
} else {
|
||||
mtApi = partner.CurAPIManager.GetAPI(model.VendorIDMTWM, sm.VendorOrgCode).(*mtwmapi.API)
|
||||
}
|
||||
|
||||
for {
|
||||
foodList, err := mtApi.RetailListAll(sm.VendorStoreID, i)
|
||||
if err != nil {
|
||||
@@ -198,7 +207,6 @@ func EBaiSyncSkuPriceAndStatus(db *dao.DaoDB, sm *model.StoreMap, skuMap map[str
|
||||
errs = append(errs, fmt.Sprintf("skuCode:%d,修改饿百不可售状态错误%v", sku.SkuID, err))
|
||||
}
|
||||
}
|
||||
//_, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{sm.VendorID}, []int{sku.StoreID}, false, []int{sku.SkuID}, []int{27379}, 56, true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,7 +332,7 @@ func TiktokSyncSkuPriceAndStatus(db *dao.DaoDB, sm *model.StoreMap, skuMap map[s
|
||||
for _, vsl := range foodListData {
|
||||
if sku, ok := skuMap[vsl.OuterProductId]; ok {
|
||||
// 同步商品价格
|
||||
if vsl.DiscountPrice != int64(sku.EbaiPrice) {
|
||||
if vsl.DiscountPrice != int64(sku.DdPrice) {
|
||||
_, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{sm.VendorID}, []int{sku.StoreID}, false, []int{sku.SkuID}, []int{27379}, model.SyncFlagPriceMask, true, true)
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Sprintf("抖音对比商品价格异常skuid:%d,错误%v", sku.SkuID, err))
|
||||
|
||||
@@ -57,7 +57,7 @@ func (c *SessionController) CheckVendorSkuDiffer() {
|
||||
return retVal, "", err
|
||||
}
|
||||
|
||||
err = enterprise.CompareJxVendorSku(params.StoreId, vendorIDs)
|
||||
return nil, "", err
|
||||
errStr, err := enterprise.CompareJxVendorSku(params.StoreId, vendorIDs)
|
||||
return errStr, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user