- test
This commit is contained in:
@@ -197,16 +197,18 @@ func InitVendorCategory(ctx *jxcontext.Context) (num int64, err error) {
|
|||||||
return num, err
|
return num, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func Convert2JDSPU(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func Convert2JDSPU(ctx *jxcontext.Context, count int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.*
|
SELECT t1.*
|
||||||
FROM sku_name t1
|
FROM sku_name t1
|
||||||
LEFT JOIN sku_name t2 ON t1.link_id = t2.id
|
LEFT JOIN sku_name t2 ON t2.link_id = t1.id
|
||||||
WHERE t1.deleted_at = ? AND t1.status <> ? AND t1.is_spu = 0 AND t1.unit = '份'
|
WHERE t1.deleted_at = ? AND t1.status <> ? AND t1.is_spu = 0 AND t1.unit = '份'
|
||||||
AND t2.id IS NULL
|
AND t2.id IS NULL
|
||||||
AND t1.id IN (1079, 202, 930)
|
ORDER BY t1.id
|
||||||
LIMIT 10;
|
|
||||||
`
|
`
|
||||||
|
if count > 0 {
|
||||||
|
sql += " LIMIT " + utils.Int2Str(count)
|
||||||
|
}
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
model.SkuStatusDeleted,
|
model.SkuStatusDeleted,
|
||||||
@@ -316,7 +318,7 @@ func Change2JDSPU4Store(ctx *jxcontext.Context, storeIDs []int, isAsync, isConti
|
|||||||
sql := `
|
sql := `
|
||||||
DELETE t1
|
DELETE t1
|
||||||
FROM store_sku_bind t1
|
FROM store_sku_bind t1
|
||||||
JOIN sku t2 ON t1.sku_id = t2.id AND t2.link_id <> 0
|
JOIN sku t2 ON t2.id = t1.sku_id AND t2.link_id <> 0
|
||||||
WHERE 1 = 1
|
WHERE 1 = 1
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{}
|
sqlParams := []interface{}{}
|
||||||
@@ -329,29 +331,33 @@ func Change2JDSPU4Store(ctx *jxcontext.Context, storeIDs []int, isAsync, isConti
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dao.Begin(db)
|
||||||
sql = `
|
sql = `
|
||||||
INSERT INTO store_sku_bind(created_at, updated_at, last_operator, deleted_at, store_id, sku_id, price, unit_price, status, ebai_id, mtwm_id, jd_sync_status, ebai_sync_status, mtwm_sync_status)
|
INSERT INTO store_sku_bind(created_at, updated_at, last_operator, deleted_at, store_id, sku_id, price, unit_price, status, ebai_id, mtwm_id, jd_sync_status, ebai_sync_status, mtwm_sync_status)
|
||||||
SELECT NOW(), NOW(), ?, ?, t1.store_id, t2.id, t1.price, t1.unit_price, ?,0,0,?,?,?
|
SELECT NOW(), NOW(), ?, ?, t1.store_id, t2.id, t1.price, t1.unit_price, t1.status , 0, 0, ?, ?, ?
|
||||||
FROM store_sku_bind t1
|
FROM store_sku_bind t1
|
||||||
JOIN sku t2 ON t2.link_id = t1.sku_id AND t2.deleted_at = ?
|
JOIN sku t2 ON t2.link_id = t1.sku_id AND t2.deleted_at = ?
|
||||||
WHERE 1 = 1
|
WHERE t1.deleted_at = ?
|
||||||
`
|
`
|
||||||
sqlParams = []interface{}{
|
sqlParams = []interface{}{
|
||||||
ctx.GetUserName(),
|
ctx.GetUserName(),
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
model.SkuStatusDontSale,
|
// model.SkuStatusDontSale,
|
||||||
model.SyncFlagNewMask,
|
model.SyncFlagNewMask,
|
||||||
0, //model.SyncFlagNewMask,
|
0, //model.SyncFlagNewMask,
|
||||||
0, //model.SyncFlagNewMask,
|
0, //model.SyncFlagNewMask,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
}
|
}
|
||||||
if len(storeIDs) > 0 {
|
if len(storeIDs) > 0 {
|
||||||
sql += " AND t1.store_id IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
|
sql += " AND t1.store_id IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
|
||||||
sqlParams = append(sqlParams, storeIDs)
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
}
|
}
|
||||||
if _, err = dao.ExecuteSQL(db, sql, sqlParams...); err != nil {
|
if _, err = dao.ExecuteSQL(db, sql, sqlParams...); err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
var skuIDs []int
|
var skuIDs []int
|
||||||
sql = `
|
sql = `
|
||||||
SELECT id
|
SELECT id
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ func (c *InitDataController) InitVendorCategory() {
|
|||||||
// @Title 将为份的商品在京东转成SPU
|
// @Title 将为份的商品在京东转成SPU
|
||||||
// @Description 将为份的商品在京东转成SPU
|
// @Description 将为份的商品在京东转成SPU
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
// @Param count formData int false "转换的数量,缺省0表示全部"
|
||||||
// @Param isAsync formData bool false "是否异步操作"
|
// @Param isAsync formData bool false "是否异步操作"
|
||||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
@@ -62,7 +63,7 @@ func (c *InitDataController) InitVendorCategory() {
|
|||||||
// @router /Convert2JDSPU [post]
|
// @router /Convert2JDSPU [post]
|
||||||
func (c *InitDataController) Convert2JDSPU() {
|
func (c *InitDataController) Convert2JDSPU() {
|
||||||
c.callConvert2JDSPU(func(params *tInitdataConvert2JDSPUParams) (retVal interface{}, errCode string, err error) {
|
c.callConvert2JDSPU(func(params *tInitdataConvert2JDSPUParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = initdata.Convert2JDSPU(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
retVal, err = initdata.Convert2JDSPU(params.Ctx, params.Count, params.IsAsync, params.IsContinueWhenError)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -70,7 +71,7 @@ func (c *InitDataController) Convert2JDSPU() {
|
|||||||
// @Title 将京东商店为份的SPU转换
|
// @Title 将京东商店为份的SPU转换
|
||||||
// @Description 将京东商店为份的SPU转换
|
// @Description 将京东商店为份的SPU转换
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param storeIDs formData string false "门店列表"
|
// @Param storeIDs formData string true "门店列表"
|
||||||
// @Param isAsync formData bool false "是否异步操作"
|
// @Param isAsync formData bool false "是否异步操作"
|
||||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
|||||||
Reference in New Issue
Block a user