Browse Source

good option

master
黄梓健 5 years ago
parent
commit
eb84567ece
  1. 23
      controllers/client/good.go
  2. 1
      go.mod
  3. 8
      models/customer_goods.go
  4. 17
      utils/utils_test.go

23
controllers/client/good.go

@ -13,6 +13,18 @@ type GoodCtl struct {
controllers.AuthorCtl
}
func (t *GoodCtl) GoodOption() {
activityId := t.MustGetInt64("activity_id")
//areaId := t.MustGetInt64("area_id")
option := new(models.CustomerOrderOption)
exist, err := option.GetByActivityId(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "订单活动不存在")
t.JSON(option)
}
// 商品列表
func (t *GoodCtl) ListGood() {
activityId := t.MustGetInt64("activity_id")
@ -22,18 +34,11 @@ func (t *GoodCtl) ListGood() {
exist, err := option.GetByActivityId(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "订单活动不存在")
//if option.Status == 0 {
// t.ERROR("订单活动尚未开启", code.MSG_ORDER_RULE_NOT_EXIST)
// return
//} else {
goods, err := models.GetGoodsByActivityId(activityId, areaId)
for index := range goods {
goods[index].GoodType = option.PostFeeType
goods[index].Postage = option.PostFee
}
t.CheckErr(err)
t.JSON(goods)
//}
return
}

1
go.mod

@ -23,6 +23,7 @@ require (
github.com/ouxuanserver/osmanthuswine v0.0.0-20190916032555-480efadf4941
github.com/panjf2000/ants v4.0.2+incompatible
github.com/pkg/errors v0.9.1
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24
github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086
github.com/smartystreets/goconvey v1.6.4
github.com/swaggo/http-swagger v0.0.0-20190614090009-c2865af9083e // indirect

8
models/customer_goods.go

@ -23,10 +23,10 @@ type CustomerGoods struct {
Price float64 `json:"price" xorm:"not null default '' comment('商品单价') DECIMAL(18)"`
Desc string `json:"desc" xorm:"not null default '' comment('商品介绍') VARCHAR(255)"`
// 无关变量
GoodType int `json:"good_type" xorm:"-"`
Postage float64 `json:"postage" xorm:"-"`
Qrcode string `json:"qrcode,omitempty" xorm:"-"`
//// 无关变量
//GoodType int `json:"good_type" xorm:"-"`
//Postage float64 `json:"postage" xorm:"-"`
Qrcode string `json:"qrcode,omitempty" xorm:"-"`
}
func (t *CustomerGoods) TableName() string {

17
utils/utils_test.go

@ -1,6 +1,8 @@
package utils
import (
"fmt"
"github.com/shopspring/decimal"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
@ -62,9 +64,14 @@ func TestPathExists(t *testing.T) {
}
func TestCountDownFormat(t *testing.T) {
Convey("测试倒计时格式", t, func() {
num := 12000
str := CountDownFormat(num)
So(str, ShouldEqual, "3:20:0")
})
//Convey("测试倒计时格式", t, func() {
// //num := 12000
// //str := CountDownFormat(num)
// //So(str, ShouldEqual, "3:20:0")
//})
d, _ := decimal.NewFromString("-123.45")
d2, _ := decimal.NewFromString(".0001")
a := d.Add(d2)
fmt.Println(a.Float64())
}
Loading…
Cancel
Save