Merge remote-tracking branch 'origin/mark' into su

This commit is contained in:
苏尹岚
2019-11-20 09:55:42 +08:00
6 changed files with 24 additions and 7 deletions

View File

@@ -34,6 +34,7 @@ type ActStoreSkuParam struct {
model.ActStoreSku model.ActStoreSku
ActualActPrice int64 `json:"actualActPrice,omitempty"` // 单品级活动用,创建活动时商品的活动价格 ActualActPrice int64 `json:"actualActPrice,omitempty"` // 单品级活动用,创建活动时商品的活动价格
VendorPrice int64 `json:"vendorPrice,omitempty"` // 创建活动时的平台价格
ErrMsg string `json:"errMsg,omitempty"` ErrMsg string `json:"errMsg,omitempty"`
} }
@@ -149,6 +150,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
jxPrice := storeSkuInfo.Price jxPrice := storeSkuInfo.Price
actSkuMap.VendorPrice = int64(getVendorPriceFromStoreSkuBind(storeSkuInfo, vendorID)) actSkuMap.VendorPrice = int64(getVendorPriceFromStoreSkuBind(storeSkuInfo, vendorID))
v.OriginalPrice = int64(jxPrice) v.OriginalPrice = int64(jxPrice)
v.OriginalPrice = actSkuMap.VendorPrice // 暂时返回平台价
} }
var err2 error var err2 error
if act.Type != model.ActSkuFake { // 非结算,要计算实际活动价格 if act.Type != model.ActSkuFake { // 非结算,要计算实际活动价格
@@ -176,6 +178,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
if err2 = checkDiscountValidation(act.Type, float64(actSkuMap.ActualActPrice)*100/float64(actSkuMap.VendorPrice)); err2 != nil { if err2 = checkDiscountValidation(act.Type, float64(actSkuMap.ActualActPrice)*100/float64(actSkuMap.VendorPrice)); err2 != nil {
v.ErrMsg = err2.Error() v.ErrMsg = err2.Error()
v.ActualActPrice = actSkuMap.ActualActPrice v.ActualActPrice = actSkuMap.ActualActPrice
v.VendorPrice = actSkuMap.VendorPrice
wrongSkuList = append(wrongSkuList, v) wrongSkuList = append(wrongSkuList, v)
} }
} }

View File

@@ -72,6 +72,7 @@ type StoreSkuExt struct {
ActPrice int `json:"actPrice"` ActPrice int `json:"actPrice"`
ActID int `orm:"column(act_id)" json:"actID"` ActID int `orm:"column(act_id)" json:"actID"`
ActType int `orm:"column(act_type)" json:"actType"`
EarningPrice int `json:"earningPrice"` EarningPrice int `json:"earningPrice"`
EarningActID int `orm:"column(earning_act_id)" json:"earningActID"` EarningActID int `orm:"column(earning_act_id)" json:"earningActID"`
@@ -568,6 +569,7 @@ func updateActPrice4StoreSkuNameNew(db *dao.DaoDB, storeIDs, skuIDs []int, skuNa
if actStoreSku := actStoreSkuMap4Act.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil { if actStoreSku := actStoreSkuMap4Act.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
v.ActPrice = int(actStoreSku.ActualActPrice) v.ActPrice = int(actStoreSku.ActualActPrice)
v.ActID = actStoreSku.ActID v.ActID = actStoreSku.ActID
v.ActType = actStoreSku.Type
} }
if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil { if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
v.EarningPrice = int(actStoreSku.EarningPrice) v.EarningPrice = int(actStoreSku.EarningPrice)

View File

@@ -275,9 +275,9 @@ func InitVendorCategory(ctx *jxcontext.Context, vendorID int, isAsync bool) (hin
} }
for _, cat := range cats { for _, cat := range cats {
dao.WrapAddIDCULEntity(cat, ctx.GetUserName()) dao.WrapAddIDCULEntity(cat, ctx.GetUserName())
if err = dao.CreateEntity(db, cat); err != nil { }
return nil, err if err = dao.CreateMultiEntities(db, cats); err != nil {
} return nil, err
} }
dao.Commit(db) dao.Commit(db)
} }

View File

@@ -279,7 +279,7 @@ func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercenta
mid := 0 mid := 0
for low <= high { for low <= high {
mid = low + (high-low)/2 mid = low + (high-low)/2
if mid == 0 || mid == itemLen-1 { if mid < 0 || mid >= itemLen-1 {
break break
} }
if price >= l[mid].BeginPrice { if price >= l[mid].BeginPrice {
@@ -292,8 +292,10 @@ func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercenta
high = mid - 1 high = mid - 1
} }
} }
pricePercentage = l[mid].PricePercentage if mid >= 0 && mid <= itemLen-1 && low <= high {
priceAdd = l[mid].PriceAdd pricePercentage = l[mid].PricePercentage
priceAdd = l[mid].PriceAdd
}
} }
return pricePercentage, priceAdd return pricePercentage, priceAdd
} }

View File

@@ -173,6 +173,7 @@ func TestGetPricePercentage(t *testing.T) {
SpecUnit string SpecUnit string
Unit string Unit string
} }
l := []*model.PricePercentageItem{ l := []*model.PricePercentageItem{
&model.PricePercentageItem{ &model.PricePercentageItem{
BeginPrice: 0, BeginPrice: 0,
@@ -194,12 +195,21 @@ func TestGetPricePercentage(t *testing.T) {
PricePercentage: 30, PricePercentage: 30,
PriceAdd: 3, PriceAdd: 3,
}, },
&model.PricePercentageItem{
BeginPrice: 60,
PricePercentage: 60,
PriceAdd: 6,
},
} }
for _, v := range [][]int{ for _, v := range [][]int{
[]int{88, 0, -1, 88},
[]int{0, 0, 0, 0}, []int{0, 0, 0, 0},
[]int{30, 3, 40, 0}, []int{30, 3, 40, 0},
[]int{20, 2, 25, 0}, []int{20, 2, 25, 0},
[]int{10, 1, 10, 0}, []int{10, 1, 10, 0},
[]int{60, 6, 60, 0},
[]int{60, 6, 1000, 10},
} { } {
pricePercentage, priceAdd := GetPricePercentage(l, v[2], v[3]) pricePercentage, priceAdd := GetPricePercentage(l, v[2], v[3])
if pricePercentage != v[0] || priceAdd != v[1] { if pricePercentage != v[0] || priceAdd != v[1] {

View File

@@ -39,7 +39,7 @@ func (c *InitDataController) InitSkuName() {
} }
// @Title 初始化vendor category // @Title 初始化vendor category
// @Description 初始化vendor category(当前只有美团外卖的通过这个设置) // @Description 初始化vendor category
// @Param token header string true "认证token" // @Param token header string true "认证token"
// @Param vendorID formData int true "厂商ID" // @Param vendorID formData int true "厂商ID"
// @Param isAsync formData bool false "是否异步操作" // @Param isAsync formData bool false "是否异步操作"