From 5089875805d0606be00cc1c580f72f885d9d69e9 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 2 Jan 2019 18:58:57 +0800 Subject: [PATCH] - generate skuname place bind in Convert2JDSPU --- business/jxstore/initdata/initdata.go | 28 ++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/business/jxstore/initdata/initdata.go b/business/jxstore/initdata/initdata.go index 99074212f..26d5a6b85 100644 --- a/business/jxstore/initdata/initdata.go +++ b/business/jxstore/initdata/initdata.go @@ -16,7 +16,6 @@ import ( "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/purchase/mtwm" - "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" ) @@ -216,9 +215,7 @@ func Convert2JDSPU(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (h if err = dao.GetRows(db, &skuNameList, sql, sqlParams...); err != nil { return "", err } - globals.SugarLogger.Debug(len(skuNameList)) for _, skuName := range skuNameList { - globals.SugarLogger.Debug(skuName.Name) sql = ` SELECT * FROM sku @@ -233,9 +230,21 @@ func Convert2JDSPU(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (h if err = dao.GetRows(db, &skuList, sql, sqlParams...); err != nil { return "", err } + + sql = ` + SELECT t1.* + FROM sku_name_place_bind t1 + WHERE t1.name_id = ? AND t1.deleted_at = ? + ` + var skuNamePlaceBindList []*model.SkuNamePlaceBind + if err = dao.GetRows(db, &skuNamePlaceBindList, sql, sqlParams...); err != nil { + return "", err + } + if len(skuList) > 0 { dao.Begin(db) - skuNameNew := &(*skuName) + skuNameNew2 := *skuName + skuNameNew := &skuNameNew2 dao.WrapAddIDCULEntity(skuNameNew, ctx.GetUserName()) skuNameNew.JdID = 0 skuNameNew.LinkID = skuName.ID @@ -245,7 +254,8 @@ func Convert2JDSPU(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (h return "", err } for _, sku := range skuList { - skuNew := &(*sku) + skuNew2 := *sku + skuNew := &skuNew2 dao.WrapAddIDCULEntity(skuNew, ctx.GetUserName()) skuNew.JdID = jxutils.GenFakeID() skuNew.LinkID = sku.ID @@ -255,6 +265,14 @@ func Convert2JDSPU(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (h return "", err } } + for _, placeBind := range skuNamePlaceBindList { + dao.WrapAddIDCULEntity(placeBind, ctx.GetUserName()) + placeBind.NameID = skuNameNew.ID + if err = dao.CreateEntity(db, placeBind); err != nil { + dao.Rollback(db) + return "", err + } + } dao.Commit(db) } }