- 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,12 +32,14 @@ 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 model.IsSyncStatusNeedCreate(v.SyncStatus) { if v.VendorSkuID != "" {
skus = append(skus, &ebaiapi.ActivitySkuInfo4Add{ if model.IsSyncStatusNeedCreate(v.SyncStatus) {
SkuID: v.VendorSkuID, skus = append(skus, &ebaiapi.ActivitySkuInfo4Add{
SpecialPrice: v.ActualActPrice, SkuID: v.VendorSkuID,
Stock: v.Stock, SpecialPrice: v.ActualActPrice,
}) Stock: v.Stock,
})
}
} }
} }
return skus return skus
@@ -45,13 +47,15 @@ func actStoreSu2Ebai4Add(oneStoreActSku []*model.ActStoreSku2) (skus []*ebaiapi.
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 model.IsSyncStatusNeedUpdate(v.SyncStatus) { if v.VendorSkuID != "" {
skus = append(skus, &ebaiapi.ActivitySkuInfo4Update{ if model.IsSyncStatusNeedUpdate(v.SyncStatus) {
ShopID: utils.Int2Str(v.StoreID), skus = append(skus, &ebaiapi.ActivitySkuInfo4Update{
SkuID: v.VendorSkuID, ShopID: utils.Int2Str(v.StoreID),
SpecialPrice: v.ActPrice, SkuID: v.VendorSkuID,
Stock: v.Stock, SpecialPrice: v.ActPrice,
}) Stock: v.Stock,
})
}
} }
} }
return skus return skus
@@ -59,8 +63,10 @@ func actStoreSu2Ebai4Update(oneStoreActSku []*model.ActStoreSku2) (skus []*ebaia
func actStoreSu2Ebai4Delete(oneStoreActSku []*model.ActStoreSku2) (skus []string) { func actStoreSu2Ebai4Delete(oneStoreActSku []*model.ActStoreSku2) (skus []string) {
for _, v := range oneStoreActSku { for _, v := range oneStoreActSku {
if model.IsSyncStatusNeedDelete(v.SyncStatus) { if v.VendorSkuID != "" {
skus = append(skus, v.VendorSkuID) if model.IsSyncStatusNeedDelete(v.SyncStatus) {
skus = append(skus, v.VendorSkuID)
}
} }
} }
return skus return skus

View File

@@ -166,12 +166,14 @@ 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) {
jdActStoreSku = append(jdActStoreSku, &jdapi.PromotionSku{ if v.VendorStoreID != "" && v.VendorSkuID != "" {
StationNo: utils.Str2Int64(v.VendorStoreID), jdActStoreSku = append(jdActStoreSku, &jdapi.PromotionSku{
SkuID: utils.Str2Int64(v.VendorSkuID), StationNo: utils.Str2Int64(v.VendorStoreID),
PromotionPrice: v.ActualActPrice, SkuID: utils.Str2Int64(v.VendorSkuID),
LimitSkuCount: v.Stock, PromotionPrice: v.ActualActPrice,
}) LimitSkuCount: v.Stock,
})
}
} }
} }
return jdActStoreSku return jdActStoreSku