- GetActStoreSkuVendorInfo中对于store_sku_bind用LEFT JOIN

This commit is contained in:
gazebo
2019-07-15 15:44:36 +08:00
parent ae4dff1b2d
commit 46a43f78fc
3 changed files with 30 additions and 22 deletions

View File

@@ -101,7 +101,7 @@ func GetActStoreSkuVendorInfo(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs
sql += fmt.Sprintf(` sql += fmt.Sprintf(`
%s JOIN store_map t3 ON t3.store_id = t1.store_id AND t3.vendor_id = t2.vendor_id AND t3.deleted_at = ? %s JOIN store_map t3 ON t3.store_id = t1.store_id AND t3.vendor_id = t2.vendor_id AND t3.deleted_at = ?
JOIN sku t4 ON t4.id = t1.sku_id JOIN sku t4 ON t4.id = t1.sku_id
JOIN store_sku_bind t5 ON t5.sku_id = t1.sku_id AND t5.store_id = t1.store_id AND t5.deleted_at = ? LEFT JOIN store_sku_bind t5 ON t5.sku_id = t1.sku_id AND t5.store_id = t1.store_id AND t5.deleted_at = ?
LEFT JOIN store t6 ON t6.id = t1.store_id LEFT JOIN store t6 ON t6.id = t1.store_id
WHERE t1.act_id = ? WHERE t1.act_id = ?
`, leftOrEmpty) `, leftOrEmpty)

View File

@@ -32,6 +32,7 @@ func actOrderRules2Ebai(actOrderRules []*model.ActOrderRule) (ebaiRules []*ebaia
func actStoreSu2Ebai4Add(oneStoreActSku []*model.ActStoreSku2) (skus []*ebaiapi.ActivitySkuInfo4Add) { func actStoreSu2Ebai4Add(oneStoreActSku []*model.ActStoreSku2) (skus []*ebaiapi.ActivitySkuInfo4Add) {
for _, v := range oneStoreActSku { for _, v := range oneStoreActSku {
if v.VendorSkuID != "" {
if model.IsSyncStatusNeedCreate(v.SyncStatus) { if model.IsSyncStatusNeedCreate(v.SyncStatus) {
skus = append(skus, &ebaiapi.ActivitySkuInfo4Add{ skus = append(skus, &ebaiapi.ActivitySkuInfo4Add{
SkuID: v.VendorSkuID, SkuID: v.VendorSkuID,
@@ -40,11 +41,13 @@ func actStoreSu2Ebai4Add(oneStoreActSku []*model.ActStoreSku2) (skus []*ebaiapi.
}) })
} }
} }
}
return skus return skus
} }
func actStoreSu2Ebai4Update(oneStoreActSku []*model.ActStoreSku2) (skus []*ebaiapi.ActivitySkuInfo4Update) { func actStoreSu2Ebai4Update(oneStoreActSku []*model.ActStoreSku2) (skus []*ebaiapi.ActivitySkuInfo4Update) {
for _, v := range oneStoreActSku { for _, v := range oneStoreActSku {
if v.VendorSkuID != "" {
if model.IsSyncStatusNeedUpdate(v.SyncStatus) { if model.IsSyncStatusNeedUpdate(v.SyncStatus) {
skus = append(skus, &ebaiapi.ActivitySkuInfo4Update{ skus = append(skus, &ebaiapi.ActivitySkuInfo4Update{
ShopID: utils.Int2Str(v.StoreID), ShopID: utils.Int2Str(v.StoreID),
@@ -54,15 +57,18 @@ func actStoreSu2Ebai4Update(oneStoreActSku []*model.ActStoreSku2) (skus []*ebaia
}) })
} }
} }
}
return skus return skus
} }
func actStoreSu2Ebai4Delete(oneStoreActSku []*model.ActStoreSku2) (skus []string) { func actStoreSu2Ebai4Delete(oneStoreActSku []*model.ActStoreSku2) (skus []string) {
for _, v := range oneStoreActSku { for _, v := range oneStoreActSku {
if v.VendorSkuID != "" {
if model.IsSyncStatusNeedDelete(v.SyncStatus) { if model.IsSyncStatusNeedDelete(v.SyncStatus) {
skus = append(skus, v.VendorSkuID) skus = append(skus, v.VendorSkuID)
} }
} }
}
return skus return skus
} }

View File

@@ -166,6 +166,7 @@ func AdjustPromotionSku(promotionType int, infoId int64, outInfoId string, skus
func storeSku2Jd(actStoreSku []*model.ActStoreSku2, handler func(syncStatus int) bool) (jdActStoreSku []*jdapi.PromotionSku) { func storeSku2Jd(actStoreSku []*model.ActStoreSku2, handler func(syncStatus int) bool) (jdActStoreSku []*jdapi.PromotionSku) {
for _, v := range actStoreSku { for _, v := range actStoreSku {
if handler(v.SyncStatus) { if handler(v.SyncStatus) {
if v.VendorStoreID != "" && v.VendorSkuID != "" {
jdActStoreSku = append(jdActStoreSku, &jdapi.PromotionSku{ jdActStoreSku = append(jdActStoreSku, &jdapi.PromotionSku{
StationNo: utils.Str2Int64(v.VendorStoreID), StationNo: utils.Str2Int64(v.VendorStoreID),
SkuID: utils.Str2Int64(v.VendorSkuID), SkuID: utils.Str2Int64(v.VendorSkuID),
@@ -174,6 +175,7 @@ func storeSku2Jd(actStoreSku []*model.ActStoreSku2, handler func(syncStatus int)
}) })
} }
} }
}
return jdActStoreSku return jdActStoreSku
} }