diff --git a/base/util/util.go b/base/util/util.go index 1cf88a2..15024e4 100644 --- a/base/util/util.go +++ b/base/util/util.go @@ -1,7 +1,21 @@ package util -import "fmt" +import ( + "fmt" + "regexp" + "strings" +) func MoneyFen(money int64) string { return fmt.Sprintf("%.2f", float64(money)/100) } + +func CinemaBrand(name string) string { + + reg, err := regexp.Compile("[^((]*") + if err != nil { + panic(err) + } + r := reg.Find([]byte(name)) + return strings.Trim(string(r), "\r\n\t ") +} diff --git a/model/orders.go b/model/orders.go index 6746ef4..d5be30b 100644 --- a/model/orders.go +++ b/model/orders.go @@ -30,6 +30,7 @@ type Order struct { ProvinceName string Ting string CinemaName string + CinemaBrand string MovieName string Address string Count int diff --git a/worker/haha/haha_sync_order.go b/worker/haha/haha_sync_order.go index 0b2f42e..79de0a6 100644 --- a/worker/haha/haha_sync_order.go +++ b/worker/haha/haha_sync_order.go @@ -3,6 +3,7 @@ package haha import ( "crypto/tls" "encoding/json" + "film/base/util" "film/model" "fmt" "github.com/go-co-op/gocron" @@ -99,6 +100,7 @@ func (s *SyncOrder) run() { order.Address = cast.ToString(data["address"]) order.Ting = cast.ToString(data["ting"]) order.CinemaName = cast.ToString(data["cinemaName"]) + order.CinemaBrand = util.CinemaBrand(order.CinemaName) order.Count = cast.ToInt(data["count"]) order.IsSeat = cast.ToInt(data["is_seat"]) order.LoverSeat = cast.ToInt(data["loverSeat"])