diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 9b6907fb2..7f62439dd 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -518,6 +518,21 @@ func (a *ActManager) CreateActFromVendor(ctx *jxcontext.Context, act2 *model.Act } func createActFromVendor(ctx *jxcontext.Context, db *dao.DaoDB, act2 *model.Act2, actStoreSku []*model.ActStoreSku2) (actID int, err error) { + actMap := &model.ActMap{ + VendorID: act2.VendorID, + VendorActID: act2.VendorActID, + SyncStatus: 0, + } + dao.WrapAddIDCULDEntity(actMap, ctx.GetUserName()) + if actMap.VendorActID != "" { + if err = dao.GetEntity(db, actMap, model.FieldVendorActID, model.FieldVendorID, model.FieldDeletedAt); err == nil { + return actMap.ActID, nil + } else if !dao.IsNoRowsError(err) { + return 0, err + } + err = nil + } + dao.Begin(db) defer func() { if r := recover(); r != nil { @@ -534,13 +549,7 @@ func createActFromVendor(ctx *jxcontext.Context, db *dao.DaoDB, act2 *model.Act2 return 0, err } - actMap := &model.ActMap{ - ActID: act.ID, - VendorID: act2.VendorID, - VendorActID: act2.VendorActID, - SyncStatus: 0, - } - dao.WrapAddIDCULDEntity(actMap, ctx.GetUserName()) + actMap.ActID = act.ID err = dao.CreateEntity(db, actMap) if err != nil { dao.Rollback(db) @@ -702,7 +711,7 @@ func DeleteActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, act } } - if isNeedCancelAct { + if isNeedCancelAct && act.Type != model.ActSkuFake { act := &model.Act{} act.ID = actID if _, err = dao.UpdateEntityLogically(db, act,