- CaculateSkuPrice return UnitPrice when unit is 份
This commit is contained in:
@@ -47,6 +47,7 @@ type tStoreSkuBindAndSpec struct {
|
||||
SpecQuality float32
|
||||
SpecUnit string
|
||||
SkuNamePrice int
|
||||
SkuNameUnit string
|
||||
RealSkuID int `orm:"column(real_sku_id)"`
|
||||
}
|
||||
|
||||
@@ -241,7 +242,7 @@ func UpdateStoreSkus(storeID int, skuBindInfos []*StoreSkuBindInfo, userName str
|
||||
inSkuBinds := skuBindInfo.Skus
|
||||
var allBinds []*tStoreSkuBindAndSpec
|
||||
if err = dao.GetRows(db, &allBinds, `
|
||||
SELECT t2.*, t1.id real_sku_id, t1.spec_quality, t1.spec_unit, t3.price sku_name_price
|
||||
SELECT t2.*, t1.id real_sku_id, t1.spec_quality, t1.spec_unit, t3.price sku_name_price, t3.unit sku_name_unit
|
||||
FROM sku t1
|
||||
LEFT JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND store_id = ?
|
||||
JOIN sku_name t3 ON t1.name_id = t3.id
|
||||
@@ -272,7 +273,7 @@ func UpdateStoreSkus(storeID int, skuBindInfos []*StoreSkuBindInfo, userName str
|
||||
SkuID: v.RealSkuID,
|
||||
SubStoreID: skuBindInfo.SubStoreID, // todo 这个应该从用户信息中自动获得
|
||||
UnitPrice: unitPrice,
|
||||
Price: jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit),
|
||||
Price: jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit),
|
||||
Status: model.StoreSkuBindStatusDontSale, // 缺省不可售?
|
||||
}
|
||||
if inSkuBind != nil && inSkuBind.IsSale == 1 {
|
||||
@@ -318,7 +319,7 @@ func UpdateStoreSkus(storeID int, skuBindInfos []*StoreSkuBindInfo, userName str
|
||||
}
|
||||
if skuBindInfo.UnitPrice != 0 { // 这里是否需要加此条件限制
|
||||
skuBind.UnitPrice = unitPrice
|
||||
skuBind.Price = jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit)
|
||||
skuBind.Price = jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit)
|
||||
setStoreSkuBindStatus(skuBind, model.SyncFlagPriceMask)
|
||||
needUpdate = true
|
||||
}
|
||||
|
||||
@@ -114,7 +114,10 @@ func IntMap2List(intMap map[int]int) []int {
|
||||
}
|
||||
|
||||
// 计算SKU价格,unitPrice为一斤的单价,specQuality为质量,单位为克
|
||||
func CaculateSkuPrice(unitPrice int, specQuality float32, specUnit string) int {
|
||||
func CaculateSkuPrice(unitPrice int, specQuality float32, specUnit string, skuNameUnit string) int {
|
||||
if skuNameUnit == "份" {
|
||||
return unitPrice
|
||||
}
|
||||
if strings.ToLower(specUnit) == "kg" {
|
||||
specQuality *= 1000
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (p *PurchaseHandler) cuSku(db *dao.DaoDB, sku *model.Sku, handler func(skuE
|
||||
}
|
||||
if err == nil {
|
||||
skuName := jxutils.ComposeSkuName(skuInfoExt.Prefix, skuInfoExt.Name, skuInfoExt.Comment, skuInfoExt.Unit, sku.SpecQuality, sku.SpecUnit, 0)
|
||||
skuPrice := jxutils.CaculateSkuPrice(skuInfoExt.Price, sku.SpecQuality, sku.SpecUnit)
|
||||
skuPrice := jxutils.CaculateSkuPrice(skuInfoExt.Price, sku.SpecQuality, sku.SpecUnit, skuInfoExt.Unit)
|
||||
result, err2 := handler(&skuInfoExt, skuPrice, skuName, shopCategories, addParams)
|
||||
if err = err2; err == nil {
|
||||
if jdID := utils.Str2Int64WithDefault(result, 0); jdID != 0 {
|
||||
|
||||
Reference in New Issue
Block a user