From 15020a0c9fc06b42c5c0321e97a02edf597ea3a4 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 19 Nov 2019 16:02:25 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8DGetPricePercentage?= =?UTF-8?q?=E4=B8=AD=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxutils/jxutils_cms.go | 8 +++++--- business/jxutils/jxutils_cms_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/business/jxutils/jxutils_cms.go b/business/jxutils/jxutils_cms.go index 874682300..150e96066 100644 --- a/business/jxutils/jxutils_cms.go +++ b/business/jxutils/jxutils_cms.go @@ -279,7 +279,7 @@ func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercenta mid := 0 for low <= high { mid = low + (high-low)/2 - if mid == 0 || mid == itemLen-1 { + if mid < 0 || mid >= itemLen-1 { break } if price >= l[mid].BeginPrice { @@ -292,8 +292,10 @@ func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercenta high = mid - 1 } } - pricePercentage = l[mid].PricePercentage - priceAdd = l[mid].PriceAdd + if mid >= 0 && mid <= itemLen-1 && low <= high { + pricePercentage = l[mid].PricePercentage + priceAdd = l[mid].PriceAdd + } } return pricePercentage, priceAdd } diff --git a/business/jxutils/jxutils_cms_test.go b/business/jxutils/jxutils_cms_test.go index 90bcd437e..701e3093b 100644 --- a/business/jxutils/jxutils_cms_test.go +++ b/business/jxutils/jxutils_cms_test.go @@ -173,6 +173,7 @@ func TestGetPricePercentage(t *testing.T) { SpecUnit string Unit string } + l := []*model.PricePercentageItem{ &model.PricePercentageItem{ BeginPrice: 0, @@ -194,12 +195,21 @@ func TestGetPricePercentage(t *testing.T) { PricePercentage: 30, PriceAdd: 3, }, + &model.PricePercentageItem{ + BeginPrice: 60, + PricePercentage: 60, + PriceAdd: 6, + }, } + for _, v := range [][]int{ + []int{88, 0, -1, 88}, []int{0, 0, 0, 0}, []int{30, 3, 40, 0}, []int{20, 2, 25, 0}, []int{10, 1, 10, 0}, + []int{60, 6, 60, 0}, + []int{60, 6, 1000, 10}, } { pricePercentage, priceAdd := GetPricePercentage(l, v[2], v[3]) if pricePercentage != v[0] || priceAdd != v[1] { From 56869ef22ab13788955696d93f2480fce0e2e4f5 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 19 Nov 2019 16:06:56 +0800 Subject: [PATCH 2/4] =?UTF-8?q?+StoreSkuNamesInfo=E6=B7=BB=E5=8A=A0actType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 1076854ea..6e54f624d 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -72,6 +72,7 @@ type StoreSkuExt struct { ActPrice int `json:"actPrice"` ActID int `orm:"column(act_id)" json:"actID"` + ActType int `orm:"column(act_type)" json:"actType"` EarningPrice int `json:"earningPrice"` 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 { v.ActPrice = int(actStoreSku.ActualActPrice) v.ActID = actStoreSku.ActID + v.ActType = actStoreSku.Type } if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil { v.EarningPrice = int(actStoreSku.EarningPrice) From 61570289a2d056feab54464f7239bf468748e741 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 20 Nov 2019 09:12:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E6=8A=98=E6=89=A3=E6=A3=80=E6=9F=A5=E5=A4=B1=E8=B4=A5=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=BF=94=E5=9B=9E=E5=B9=B3=E5=8F=B0=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/act/act.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 60b6aa224..da94f2567 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -34,6 +34,7 @@ type ActStoreSkuParam struct { model.ActStoreSku ActualActPrice int64 `json:"actualActPrice,omitempty"` // 单品级活动用,创建活动时商品的活动价格 + VendorPrice int64 `json:"vendorPrice,omitempty"` // 创建活动时的平台价格 ErrMsg string `json:"errMsg,omitempty"` } @@ -149,6 +150,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac jxPrice := storeSkuInfo.Price actSkuMap.VendorPrice = int64(getVendorPriceFromStoreSkuBind(storeSkuInfo, vendorID)) v.OriginalPrice = int64(jxPrice) + v.OriginalPrice = actSkuMap.VendorPrice // 暂时返回平台价 } var err2 error 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 { v.ErrMsg = err2.Error() v.ActualActPrice = actSkuMap.ActualActPrice + v.VendorPrice = actSkuMap.VendorPrice wrongSkuList = append(wrongSkuList, v) } } From ea49b205280070b9cb025877a7f6b9584a9de45b Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 20 Nov 2019 09:41:00 +0800 Subject: [PATCH 4/4] =?UTF-8?q?InitVendorCategory=E4=B8=AD=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E6=89=B9=E9=87=8F=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/initdata/initdata.go | 6 +++--- controllers/init_data.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/business/jxstore/initdata/initdata.go b/business/jxstore/initdata/initdata.go index 2d1046eb2..448a5b61a 100644 --- a/business/jxstore/initdata/initdata.go +++ b/business/jxstore/initdata/initdata.go @@ -275,9 +275,9 @@ func InitVendorCategory(ctx *jxcontext.Context, vendorID int, isAsync bool) (hin } for _, cat := range cats { 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) } diff --git a/controllers/init_data.go b/controllers/init_data.go index 0226244c3..91a6b0b39 100644 --- a/controllers/init_data.go +++ b/controllers/init_data.go @@ -39,7 +39,7 @@ func (c *InitDataController) InitSkuName() { } // @Title 初始化vendor category -// @Description 初始化vendor category(当前只有美团外卖的通过这个设置) +// @Description 初始化vendor category // @Param token header string true "认证token" // @Param vendorID formData int true "厂商ID" // @Param isAsync formData bool false "是否异步操作"