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