diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 712136722..2d77070a2 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -1280,8 +1280,11 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil { v.EarningPrice = int(actStoreSku.EarningPrice) v.EarningActID = actStoreSku.ActID - } else if v.EarningPrice == 0 { - v.EarningPrice = int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage)) + } else { + earningPrice := int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage)) + if earningPrice < v.EbaiPrice { + v.EbaiPrice = earningPrice + } } } } else { @@ -1290,3 +1293,18 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI } return err } + +func GetDeletedStoreSkuBind(db *DaoDB, storeID, skuID int) (storeSkuBind *model.StoreSkuBind) { + sql := ` + SELECT a.* + FROM store_sku_bind a + WHERE a.store_id = ? AND a.sku_id = ? + ORDER BY a.deleted_at DESC` + sqlParams := []interface{}{ + storeID, skuID, + } + if err := GetRow(db, &storeSkuBind, sql, sqlParams...); err != nil { + storeSkuBind = nil + } + return storeSkuBind +}