From 9d0d3464e2d8cb8b2dd785b1403e854a81242480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 27 Mar 2020 13:31:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=93=B6=E8=B1=B9=E6=9C=AA?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E7=9A=84sku=E7=9A=84ybid=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync_store_sku.go | 10 ++++++++++ business/model/dao/store_sku.go | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index ed1d6beaf..f16fe9d88 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -325,10 +325,20 @@ func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyn updateItemList[k] = sku2Update(vendorID, v, syncStatus) } num, err = dao.BatchUpdateEntityByKV(db, updateItemList) + if vendorID == model.VendorIDYB { + err = updateYbOhterSku(db, storeSkuList) + } } return num, err } +func updateYbOhterSku(db *dao.DaoDB, storeSkuList []*dao.StoreSkuSyncInfo) (err error) { + for _, v := range storeSkuList { + err = dao.UpdateYbOtherSku(db, v) + } + return err +} + func isSkuLockTimeValid(sku *dao.StoreSkuSyncInfo) bool { return sku.LockTime != nil && time.Now().Sub(*sku.LockTime) < 0 } diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 7d4ca4838..9a2a3622c 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -1478,3 +1478,22 @@ func GetStoreSkusAndSkuName(db *DaoDB, storeIDs, skuIDs, nameIDs []int) (storeSk err = GetRows(db, &storeSkuAndName, sql, sqlParams...) return storeSkuAndName, err } + +func UpdateYbOtherSku(db *DaoDB, storeSkuSyncInfo *StoreSkuSyncInfo) (err error) { + sql := ` + UPDATE store_sku_bind a + JOIN sku b ON a.sku_id = b.id AND b.name_id = ? + JOIN (SELECT * FROM store_sku_bind WHERE sku_id = ?)c ON c.store_id = a.store_id + SET a.yb_id = c.yb_id,a.yb_sync_status = c.yb_sync_status,a.yb_price = c.yb_price + WHERE a.store_id = ? + AND a.yb_sync_status <> ? + ` + sqlParams := []interface{}{ + storeSkuSyncInfo.NameID, + storeSkuSyncInfo.SkuID, + storeSkuSyncInfo.StoreID, + 0, + } + _, err = ExecuteSQL(db, sql, sqlParams) + return err +}