- generate skuname place bind in Convert2JDSPU
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user