- GetStoresSkus中返回realEarningPrice

This commit is contained in:
gazebo
2019-06-22 18:18:25 +08:00
parent b536d7a01a
commit c3feea5ff4

View File

@@ -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 {