wangchuanjin 3 жил өмнө
parent
commit
eabd515521

+ 1 - 1
public/entity/base_goods_spec.go

@@ -20,7 +20,7 @@ type base_goods_spec struct {
 //根据代码查找功能详情
 func (b *base_goods_spec) FindById(id int64, appid, goodsCode string) *[]*base_goods_spec {
 	bgss := Mysql_BaseService.SelectBySql(`select * from base_goods_spec where id=? and appid=? and goods_code=? limit 1`, id, appid, goodsCode)
-	list := JsonUnmarshal((*bgss)[0], &[]*base_goods_spec{}).(*[]*base_goods_spec)
+	list := JsonUnmarshal(*bgss, &[]*base_goods_spec{}).(*[]*base_goods_spec)
 	if list != nil {
 		for _, v := range *list {
 			v.Base_goods_spec_powers = *Base_goods_spec_power.FindByGoodsCode(v.Id, v.Appid, goodsCode)

+ 3 - 3
public/entity/base_goods_spec_power.go

@@ -11,7 +11,7 @@ var Base_goods_spec_power = base_goods_spec_power{}
 type base_goods_spec_power struct {
 	Id                     int64
 	Appid                  string
-	Goods_spec_id          int64  //商品规格表id
+	Spec_id                int64  //商品规格表id
 	Goods_code             string //商品代码
 	Function_code          string //功能代码
 	Cycle                  string //周期 d、m、y;比如:1d 7d 3m 1y
@@ -29,11 +29,11 @@ type base_goods_spec_power struct {
 
 //根据商品代码查找商品的功能明细
 func (b *base_goods_spec_power) FindByGoodsCode(goods_spec_id int64, appid, goods_code string) *[]*base_goods_spec_power {
-	list := Mysql_BaseService.SelectBySql(`select * from base_goods_spec_power where goods_spec_id=? and appid=? and goods_code=?`, goods_spec_id, appid, goods_code)
+	list := Mysql_BaseService.SelectBySql(`select * from base_goods_spec_power where spec_id=? and appid=? and goods_code=?`, goods_spec_id, appid, goods_code)
 	if list != nil && len(*list) > 0 {
 		bgsps := JsonUnmarshal(list, &[]*base_goods_spec_power{}).(*[]*base_goods_spec_power)
 		for _, v := range *bgsps {
-			b.Base_function = Base_function.FindByCode(appid, v.Function_code)
+			v.Base_function = Base_function.FindByCode(appid, v.Function_code)
 		}
 		return bgsps
 	}

+ 6 - 0
public/service/power_test.go

@@ -5,6 +5,7 @@ import (
 
 	. "app.yhyue.com/moapp/jybase/mysql"
 	. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/db"
+	. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/entity"
 	"github.com/stretchr/testify/assert"
 )
 
@@ -19,6 +20,11 @@ func init() {
 	})
 }
 
+func TestOpenPowers(t *testing.T) {
+	list := Base_goods_spec.FindById(4, "10000", "xxfb_gyxx")
+	Base_power.OpenPower(4, "10000", "xxfb_gyxx", 0, 14184, 1, list)
+}
+
 func TestHasPowers(t *testing.T) {
 	t.Log(HasPowers("10000", 0, 14184, 4271))
 }