From 3d8781ca0fbbe5941bfb0c4a71ee4255df71bfe1 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 24 Dec 2019 10:41:46 +0800 Subject: [PATCH] UpdateActPrice4StoreSkuNameNew --- business/model/dao/store_sku.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 +}