- Change2JDSPU4Store
This commit is contained in:
@@ -307,3 +307,59 @@ func Convert2JDSPU(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (h
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func Change2JDSPU4Store(ctx *jxcontext.Context, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
sql := `
|
||||
DELETE t1
|
||||
FROM store_sku_bind t1
|
||||
JOIN sku t2 ON t1.sku_id = t2.id AND t2.link_id <> 0
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND store_id IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
db := dao.GetDB()
|
||||
if _, err = dao.ExecuteSQL(db, sql, sqlParams...); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
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,?,?,?
|
||||
FROM store_sku_bind t1
|
||||
JOIN sku t2 ON t2.link_id = t1.sku_id AND t2.deleted_at = ?
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams = []interface{}{
|
||||
ctx.GetUserName(),
|
||||
utils.DefaultTimeValue,
|
||||
model.SkuStatusDontSale,
|
||||
model.SyncFlagNewMask,
|
||||
0, //model.SyncFlagNewMask,
|
||||
0, //model.SyncFlagNewMask,
|
||||
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 {
|
||||
return "", err
|
||||
}
|
||||
var skuIDs []int
|
||||
sql = `
|
||||
SELECT id
|
||||
FROM sku
|
||||
WHERE link_id <> 0 AND deleted_at = ?
|
||||
`
|
||||
sqlParams = []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if err = dao.GetRows(db, &skuIDs, sql, sqlParams...); err != nil {
|
||||
return "", err
|
||||
}
|
||||
hint, err = cms.CurVendorSync.SyncStoresSkus(ctx, db, []int{model.VendorIDJD}, storeIDs, skuIDs, isAsync, isContinueWhenError)
|
||||
return hint, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user