diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 8b8972c93..12f5fd815 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -573,7 +573,7 @@ func CreateAct(ctx *jxcontext.Context, act *model.Act, vendorIDs []int, vendorOr } }() dao.WrapAddIDCULDEntity(act, ctx.GetUserName()) - err = dao.CreateEntity(db, act) + err = dao.CreateEntityTx(txDB, act) if err != nil { dao.Rollback(db, txDB) return "", err diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index 0fbada587..1aed3aa54 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -246,7 +246,8 @@ func (v *VendorSync) SyncStore2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs db2 = dao.GetDB() } if model.IsSyncStatusNew(storeMap.SyncStatus) { - if vendorStoreID, err = handler.CreateStore2(db2, storeMap.StoreID, userName, nil, nil); err == nil { + storeDetail, _ := dao.GetStoreDetail(db, storeMap.StoreID, storeMap.VendorID, storeMap.VendorOrgCode) + if vendorStoreID, err = handler.CreateStore2(db2, storeMap.StoreID, userName, nil, storeDetail); err == nil { resultList = append(resultList, 1) } else { failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeMap.StoreID, model.VendorChineseNames[storeMap.VendorID], "创建门店") @@ -284,7 +285,8 @@ func (v *VendorSync) SyncStore2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs var vendorStoreID string storeMap := loopMapInfo.StoreMapList[0] if model.IsSyncStatusNew(storeMap.SyncStatus) { - if vendorStoreID, err = handler.CreateStore2(db2, storeMap.StoreID, userName, nil, nil); err == nil { + storeDetail, _ := dao.GetStoreDetail(db, storeMap.StoreID, storeMap.VendorID, storeMap.VendorOrgCode) + if vendorStoreID, err = handler.CreateStore2(db2, storeMap.StoreID, userName, nil, storeDetail); err == nil { resultList = append(resultList, 1) } else { failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeMap.StoreID, model.VendorChineseNames[storeMap.VendorID], "创建门店") diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 03b2a5437..d6bb66623 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -166,7 +166,6 @@ func Init() { ScheduleTimerFunc("doDailyWork", doDailyWork, dailyWorkTimeList) ScheduleTimerFunc("doDailyWork2", doDailyWork2, dailyWorkTimeList2) - // ScheduleTimerFuncByInterval(func() { // orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-20*time.Minute), time.Now()) // }, 10*time.Second, 10*time.Minute) diff --git a/business/model/dao/dao.go b/business/model/dao/dao.go index 4356535e5..dd8a1d782 100644 --- a/business/model/dao/dao.go +++ b/business/model/dao/dao.go @@ -207,6 +207,16 @@ func CreateEntity(db *DaoDB, item interface{}) (err error) { return err } +func CreateEntityTx(txDB orm.TxOrmer, item interface{}) (err error) { + if txDB == nil { + return + } + if _, err = txDB.Insert(item); err != nil && !IsDuplicateError(err) { + globals.SugarLogger.Errorf("CreateEntity %s failed with error:%v", reflect.TypeOf(item).Name(), err) + } + return err +} + // InsertMulti执行成功后ID不会改写成正确的(象Insert一样) func CreateMultiEntities(db *DaoDB, item interface{}) (err error) { if db == nil { diff --git a/globals/api/api.go b/globals/api/api.go index 7fe1c4eba..df5ed622c 100644 --- a/globals/api/api.go +++ b/globals/api/api.go @@ -3,6 +3,8 @@ package api import ( "time" + "git.rosy.net.cn/baseapi/platformapi/mtunionapi" + "git.rosy.net.cn/baseapi/platformapi/fnpsapi" "git.rosy.net.cn/baseapi/platformapi/unipushapi" @@ -46,6 +48,8 @@ import ( ) var ( + MtUnionAPI *mtunionapi.API + JdAPI *jdapi.API JdPageAPI *jdapi.API @@ -111,6 +115,7 @@ func init() { // 这样写的原因是在测试时,可以重新读取配置文件 func Init() { + MtUnionAPI = mtunionapi.New("appKey", "appSecret") if !beego.AppConfig.DefaultBool("disableJd", false) { //初始化京东api // JdAPI = jdapi.New(beego.AppConfig.DefaultString("jdToken"), beego.AppConfig.DefaultString("jdAppKey"), beego.AppConfig.DefaultString("jdSecret"))