Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop

This commit is contained in:
richboo111
2022-10-27 18:27:56 +08:00
17 changed files with 552 additions and 372 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
"io"
"math"
"mime/multipart"
@@ -6611,3 +6612,20 @@ func UpdateMtCatToJd(ctx *jxcontext.Context, mtCatID, jdCatID string) (err error
}
return err
}
func SyncTiktokMainIdToLocal(ctx *jxcontext.Context, param *tiktok_store.MainSku) error {
codes, err := dao.GetVendorOrgCode(dao.GetDB(), model.VendorIDDD, "", "platform")
if err != nil {
return err
}
for _, code := range codes {
result, err := tiktok_store.QueryAllMainSkuList(code.VendorOrgCode, param)
globals.SugarLogger.Debugf("=====%s", utils.Format4Output(result, false))
if err != nil {
continue
}
return OnCreateThing2Tiktok(ctx, dao.GetDB(), code.VendorOrgCode, result, model.ThingTypeSku, model.SyncFlagNewMask, false)
}
return nil
}

View File

@@ -2,6 +2,7 @@ package cms
import (
"fmt"
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
"strings"
"time"
@@ -331,6 +332,39 @@ func OnCreateThing(ctx *jxcontext.Context, db *dao.DaoDB, vendorInfoList []*mode
return err
}
func OnCreateThing2Tiktok(ctx *jxcontext.Context, db *dao.DaoDB, appOrgCode string, vendorThingList []*tiktok_store.TiktokIdAndLocalSkuId, thingType, syncFlag int8, vendorFlag bool) (err error) {
if thingType == model.ThingTypeSkuName {
return nil
}
errList := errlist.New()
for _, v := range vendorThingList {
globals.SugarLogger.Debugf("==========本地商品id:[%d],主商品id:[%d],主商品属性:[%s]", v.LocalSkuId, v.MainId, v.SkuAttrId)
thingMap := &model.ThingMap{
ThingID: v.LocalSkuId,
ThingType: thingType,
VendorID: model.VendorIDDD,
VendorOrgCode: appOrgCode,
VendorThingID: v.MainId,
Remark: v.SkuAttrId,
}
if thingType == model.ThingTypeCategory && !vendorFlag {
syncFlag = 0
}
thingMap.SyncStatus = syncFlag
dao.WrapAddIDCULDEntity(thingMap, ctx.GetUserName())
if err2 := dao.CreateEntity(db, thingMap); err2 != nil {
if err2 := getThingMap(db, thingMap); err2 == nil {
thingMap.SyncStatus = 2
thingMap.LastOperator = ctx.GetUserName()
_, err2 = dao.UpdateEntity(db, thingMap)
errList.AddErr(err2)
}
}
}
err = errList.GetErrListAsOne()
return err
}
func onUpdateThing(ctx *jxcontext.Context, db *dao.DaoDB, vendorInfoList []*model.VendorOrgCode, thingID int64, thingType int8, syncStatus int8) (err error) {
if thingType == model.ThingTypeSkuName {
return nil

View File

@@ -442,13 +442,10 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
vendorStoreID := storeDetail.VendorStoreID
var skus []*dao.StoreSkuSyncInfo
if isFull {
globals.SugarLogger.Debugf("===============true")
skus, err = dao.GetFullStoreSkus(db, vendorID, storeID)
} else {
globals.SugarLogger.Debugf("===============false")
skus, err = dao.GetStoreSkus(db, vendorID, storeID, skuIDs)
}
globals.SugarLogger.Debugf("===============skus:%s", utils.Format4Output(skus, false))
if err != nil || len(skus) == 0 {
return err

View File

@@ -3,6 +3,7 @@ package misc
import (
"fmt"
"git.rosy.net.cn/jx-callback/business/partner/delivery"
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
"sync"
"time"
@@ -192,6 +193,21 @@ func Init() {
"04:00:00",
})
// 定时任务更新昨天的都要商品和本地商品id的映射关系
ScheduleTimerFunc("RefreshStoreOperator", func() {
t := time.Now()
cms.SyncTiktokMainIdToLocal(jxcontext.AdminCtx, &tiktok_store.MainSku{
AppOrgCode: "",
CheckStatus: 3,
StartTime: time.Date(t.Year(), t.Month(), t.Day()-1, 0, 0, 1, 0, time.Local).Unix(),
EndTime: time.Date(t.Year(), t.Month(), t.Day()-1, 23, 59, 59, 0, time.Local).Unix(),
Page: 1,
PageSize: 100,
})
}, []string{
"04:30:00",
})
ScheduleTimerFuncByInterval(func() {
defsch.FixedScheduler.ConfirmSelfTakeOrders(jxcontext.AdminCtx, []int{model.VendorIDJD}, time.Now().Add(-48*time.Hour), time.Now().Add(-30*time.Minute), true, true)
}, 5*time.Second, 10*time.Minute)
@@ -207,7 +223,7 @@ func Init() {
ScheduleTimerFuncByInterval(func() {
curDate := utils.Time2Date(time.Now())
orderman.FixedOrderManager.AmendMissingOrders(jxcontext.AdminCtx, []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI}, 0, curDate, curDate, true, true)
orderman.FixedOrderManager.AmendMissingOrders(jxcontext.AdminCtx, []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI, model.VendorIDDD}, 0, curDate, curDate, true, true)
}, 5*time.Second, 10*time.Minute)
//刷新京东物竞天择订单结算价
@@ -330,7 +346,7 @@ func Init() {
}, dailyWorkTimeList)
ScheduleTimerFunc("doDailyWork3", func() {
dao.SetStoresMapSyncStatus(dao.GetDB(), nil, nil, model.SyncFlagStoreStatus)
cms.CurVendorSync.SyncStore2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDMTWM, model.VendorIDJD, model.VendorIDEBAI}, nil, true, true)
cms.CurVendorSync.SyncStore2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDMTWM, model.VendorIDJD, model.VendorIDEBAI, model.VendorIDDD}, nil, true, true)
syncStoreSku()
InitEx()
@@ -339,7 +355,7 @@ func Init() {
}, dailyWorkTimeList)
ScheduleTimerFunc("doDailyWork4", func() {
curDate := utils.Time2Date(time.Now())
orderman.FixedOrderManager.AmendMissingOrders(jxcontext.AdminCtx, []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI}, 0, curDate.Add(-72*time.Hour), curDate, true, true)
orderman.FixedOrderManager.AmendMissingOrders(jxcontext.AdminCtx, []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI, model.VendorIDDD}, 0, curDate.Add(-72*time.Hour), curDate, true, true)
//只传toDate默认刷新toDate到5天以前的订单
orderman.RefreshOrdersWithoutJxStoreID(jxcontext.AdminCtx, "", "", true, true)
//禁用没有绑定的门店
@@ -672,6 +688,7 @@ func ScheduleTimerFunc(name string, handler func(), timeList []string) {
nextTime := jxutils.GetNextTimeFromList(now, timeList)
duration := nextTime.Sub(now) + 1*time.Second
utils.AfterFuncWithRecover(duration, func() {
globals.SugarLogger.Debugf("循环时间序列=====%s", duration)
handler()
ScheduleTimerFunc(name, handler, timeList)
})