From c3feea5ff4c4cc7ad745807ea5ff519c0c071e69 Mon Sep 17 00:00:00 2001 From: gazebo Date: Sat, 22 Jun 2019 18:18:25 +0800 Subject: [PATCH] =?UTF-8?q?-=20GetStoresSkus=E4=B8=AD=E8=BF=94=E5=9B=9Erea?= =?UTF-8?q?lEarningPrice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index ac35c57eb..b381ea969 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -45,6 +45,8 @@ type StoreSkuNameExt struct { PendingOpType int8 `json:"pendingOpType"` // 取值同 StoreOpRequest.Type PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请 + + PayPercentage int `json:"-"` } // GetStoreSkus用 @@ -256,7 +258,8 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword t1.img, t1.elm_img_hash_code, t3.id, - t3.name` + t3.name, + t3.pay_percentage` if isBySku { sql += `, t2.id` @@ -280,6 +283,7 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword t1.elm_img_hash_code, t3.id store_id, t3.name store_name, + t3.pay_percentage, CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"id":', t2.id, ',"comment":"', t2.comment, '","status":', t2.status, ',"createdAt":"', CONCAT(REPLACE(IF(t4.created_at IS NULL, '1970-01-01 00:00:00', t4.created_at)," ","T"),"+08:00"), '","updatedAt":"', CONCAT(REPLACE(IF(t4.updated_at IS NULL, '1970-01-01 00:00:00', t4.updated_at)," ","T"),"+08:00"), '","lastOperator":"', IF(t4.last_operator IS NULL, '', t4.last_operator), '","specQuality":', t2.spec_quality, ',"specUnit":"', t2.spec_unit, '","weight":', t2.weight, @@ -344,11 +348,20 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword } else { v["actPrice"] = 0 } + + earningPrice := 0 if jxSkuPriceMap[index] != nil { - v["earningPrice"] = jxSkuPriceMap[index].EarningPrice - } else { - v["earningPrice"] = 0 + earningPrice = jxSkuPriceMap[index].EarningPrice } + v["earningPrice"] = earningPrice + + realEarningPrice := earningPrice + if realEarningPrice == 0 { + shopPrice := utils.Interface2Int64WithDefault(v["price"], 0) + realEarningPrice = int(jxutils.CaculateSkuEarningPrice(shopPrice, shopPrice, skuName.PayPercentage)) + } + v["realEarningPrice"] = realEarningPrice + delete(v, "unitPrice") } } else {