WH01243 4 lat temu
rodzic
commit
e4a15e7c68

+ 88 - 0
entity/activity.go

@@ -0,0 +1,88 @@
+package entity
+
+import (
+	"github.com/go-xorm/xorm"
+	"time"
+)
+
+//定义orm引擎
+var Engine *xorm.Engine
+
+
+//定义返回状态
+const (
+	SuccessCode int64 = 1
+	ErrorCode   int64 = 0
+)
+
+//奖品信息
+type PrizeJson struct {
+	PrizeId          int64  `xorm:"prizeId" form:"prizeId" json:"prizeId"`                            //奖品Id
+	BeginDate        string `xorm:"beginDate" form:"beginDate" json:"beginDate"`                      //有效期起
+	EndDate          string `xorm:"endDate" form:"endDate" json:"endDate"`                            //有效期止
+	IsLimitNumber    int    `xorm:"isLimitNumber" form:"isLimitNumber" json:"isLimitNumber"`          //是否限制0限制1不限制
+	LimitNumber      int    `xorm:"limitNumber" form:"limitNumber" json:"limitNumber"`                //领取次数
+	ValidityDates    int    `xorm:"validityDates" form:"validityDates" json:"validityDates"`          //有效天数
+	ValidityTimeType int    `xorm:"validityTimeType" form:"validityTimeType" json:"validityTimeType"` //有效时间类型0、有起止时间1、当天起几天可用2、次日起几天可用
+	Name             string `xorm:"name" form:"name" json:"name"`                                     //奖券名字
+	Full             int    `xorm:"full" form:"full" json:"full"`                                     //满多少
+	Reduce           int    `xorm:"reduce" form:"reduce" json:"reduce"`                               //减多少
+}
+
+//奖券信息
+type Lottery struct {
+	Id            int64     `xorm:"pk autoincr id" form:"id" json:"id"`
+	PrizeId       int64     `xorm:"prizeId" form:"prizeId" json:"prizeId"`                   //奖品Id
+	StockNumber   int       `xorm:"stockNumber" form:"stockNumber" json:"stockNumber"`       //库存
+	ReceiveNumber string    `xorm:"receiveNumber" form:"receiveNumber" json:"receiveNumber"` //领取数量
+	UseNumber     int       `xorm:"useNumber" form:"useNumber" json:"useNumber"`             //使用数量
+	Name          string    `xorm:"name" form:"name" json:"name"`                            //奖券名字
+	Full          int       `xorm:"full" form:"full" json:"full"`                            //满多少
+	Reduce        int       `xorm:"reduce" form:"reduce" json:"reduce"`                      //减多少
+	CreateTime    time.Time `xorm:"createTime" form:"createTime" json:"createTime"`          //创建时间
+}
+
+//活动奖券数量
+type LotteryJson struct {
+	LotteryId        int64  `xorm:"lotteryId" form:"lotteryId" json:"lotteryId"`                      //奖品Id
+	Instructions     string `xorm:"instructions" form:"instructions" json:"instructions"`             //使用说明
+	Remark           string `xorm:"remark" form:"remark" json:"remark"`                               //备注
+	IsLimitNumber    int    `xorm:"isLimitNumber" form:"isLimitNumber" json:"isLimitNumber"`          //是否限制0限制1不限制
+	LimitNumber      int    `xorm:"limitNumber" form:"limitNumber" json:"limitNumber"`                //领取次数
+	ValidityDates    int    `xorm:"validityDates" form:"validityDates" json:"validityDates"`          //有效天数
+	ValidityTimeType int    `xorm:"validityTimeType" form:"validityTimeType" json:"validityTimeType"` //有效时间类型0、有起止时间1、当天起几天可用2、次日起几天可用
+	Name             string `xorm:"name" form:"name" json:"name"`                                     //奖券名字
+	Count            int64  `xorm:"count" form:"count" json:"reduce"`                                 //领取次数
+	UseProductList   string `xorm:"useProductList" form:"useProductList" json:"useProductList"`       //使用商品列表
+}
+
+//用户奖券信息
+type UserPrize struct {
+	Id            int64     `xorm:"pk autoincr id" form:"id" json:"id"`
+	PrizeId       int64     `xorm:"prizeId" form:"prizeId" json:"prizeId"`                   //奖品Id
+	UserId        string    `xorm:"userId" form:"userId" json:"userId"`                      //用户标识
+	ValidityDates int       `xorm:"validityDates" form:"validityDates" json:"validityDates"` //有效天数
+	BeginDate     string    `xorm:"beginDate" form:"beginDate" json:"beginDate"`             //有效期起
+	EndDate       string    `xorm:"endDate" form:"endDate" json:"endDate"`                   //有效期止
+	UseDate       time.Time `xorm:"useDate" form:"useDate" json:"useDate"`                   //使用时间
+	PrizeType     int       `xorm:"prizeType" form:"prizeType" json:"prizeType"`             //0未使用1已使用2已过期
+	AppId         string    `xorm:"appId" form:"appId" json:"appId"`                         //身份标识
+	LotteryId     int64     `xorm:"lotteryId" form:"lotteryId" json:"lotteryId"`             //奖券标识
+	CreateTime    time.Time `xorm:"createTime" form:"createTime" json:"createTime"`          //创建时间
+	Name          string    `xorm:"name" form:"name" json:"name"`                            //奖券名字
+	Full          int64     `xorm:"full" form:"full" json:"full"`                            //满多少
+	Reduce        int64     `xorm:"reduce" form:"reduce" json:"reduce"`                      //减多少
+}
+
+//用户奖券返回信息
+type UserPrizeJson struct {
+	Id             int64  `xorm:"pk autoincr id" form:"id" json:"id"`
+	BeginDate      string `xorm:"beginDate" form:"beginDate" json:"beginDate"`                //有效期起
+	EndDate        string `xorm:"endDate" form:"endDate" json:"endDate"`                      //有效期止
+	PrizeType      int    `xorm:"prizeType" form:"prizeType" json:"prizeType"`                //0未使用1已使用2已过期
+	LotteryId      int64  `xorm:"lotteryId" form:"lotteryId" json:"lotteryId"`                //奖券标识
+	Name           string `xorm:"name" form:"name" json:"name"`                               //奖券名字
+	Full           int64  `xorm:"full" form:"full" json:"full"`                               //满多少
+	Reduce         int64  `xorm:"reduce" form:"reduce" json:"reduce"`                         //减多少
+	UseProductList string `xorm:"useProductList" form:"useProductList" json:"useProductList"` //使用商品列表
+}

+ 15 - 0
go.mod

@@ -0,0 +1,15 @@
+module app.yhyue.com/moapp/jyMarketing
+
+go 1.13
+
+require (
+	github.com/garyburd/redigo v1.6.2
+	github.com/go-sql-driver/mysql v1.5.0
+	github.com/go-xorm/xorm v0.7.9
+	github.com/golang/protobuf v1.5.1
+	github.com/robfig/cron v1.2.0
+	github.com/tal-tech/go-zero v1.1.6
+	go.uber.org/automaxprocs v1.4.0 // indirect
+	google.golang.org/grpc v1.29.1
+	google.golang.org/protobuf v1.26.0
+)

+ 146 - 6
rpc/go.sum → go.sum

@@ -1,24 +1,33 @@
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU=
+cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
+github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/ClickHouse/clickhouse-go v1.4.3/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
 github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
+github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
+github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
 github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
 github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk=
 github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
+github.com/alicebob/miniredis/v2 v2.14.1 h1:GjlbSeoJ24bzdLRs13HoMEeaRZx9kg5nHoRW7QV/nCs=
 github.com/alicebob/miniredis/v2 v2.14.1/go.mod h1:uS970Sw5Gs9/iK3yBg0l9Uj9s25wXxSpQUE9EaJ/Blg=
 github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
 github.com/antlr/antlr4 v0.0.0-20210105212045-464bcbc32de2 h1:rL2miklL5rhxUaZO7hntBcy/VHaiyuPQ4EJoy/NMwaM=
 github.com/antlr/antlr4 v0.0.0-20210105212045-464bcbc32de2/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y=
-github.com/antlr/antlr4 v0.0.0-20210319025552-3590d4d5e18c h1:qGOWI+NNhKcTXy3JuHGXgCOfcz77a1zVeW4ChjluDCA=
-github.com/antlr/antlr4 v0.0.0-20210319025552-3590d4d5e18c/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y=
+github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
 github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
+github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
 github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
 github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
 github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4=
 github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
+github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
 github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
 github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
@@ -26,17 +35,29 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
 github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
 github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
+github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
+github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y=
 github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
+github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY=
 github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQamW5YV28=
 github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
 github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
 github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
 github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4 h1:YcpmyvADGYw5LqMnHqSkyIELsHCGF6PkrmM31V8rF7o=
+github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
+github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
 github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4 h1:qk/FSDDxo05wdJH28W+p5yivv7LuLYLRXPPD8KQCtZs=
 github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
+github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
+github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
+github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
 github.com/emicklei/proto v1.9.0 h1:l0QiNT6Qs7Yj0Mb4X6dnWBQer4ebei2BFcgQLbGqUDc=
 github.com/emicklei/proto v1.9.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -48,28 +69,42 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL
 github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
 github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
 github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o=
+github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/garyburd/redigo v1.6.2 h1:yE/pwKCrbLpLpQICzYTeZ7JsTA/C53wFTJHaEtRqniM=
+github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
 github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
 github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-redis/redis v6.15.7+incompatible h1:3skhDh95XQMpnqeqNftPkQD9jL9e5e36z/1SUm6dy1U=
 github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
 github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
+github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
 github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
 github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
 github.com/go-xorm/builder v0.3.4/go.mod h1:KxkQkNN1DpPKTedxXyTQcmH+rXfvk4LZ9SOOBoZBAxw=
+github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
 github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
+github.com/go-xorm/xorm v0.7.9 h1:LZze6n1UvRmM5gpL9/U9Gucwqo6aWlFVlfcHKH10qA0=
+github.com/go-xorm/xorm v0.7.9/go.mod h1:XiVxrMMIhFkwSkh96BW7PACl7UhLtx2iJIHMdmjh5sQ=
 github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
 github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
 github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
+github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
 github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
 github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
 github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
 github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw=
 github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -85,48 +120,72 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
 github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
 github.com/golang/protobuf v1.5.1 h1:jAbXjIeW2ZSW2AwFxlGTDoc2CjI2XujLkV3ArsZFCvc=
 github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
+github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
 github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
 github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
 github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
+github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
+github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
+github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
 github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
+github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4 h1:z53tR0945TRRQO/fLEVPI6SMv7ZflF0TEaTAoU7tOzg=
 github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
+github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
 github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/grpc-ecosystem/grpc-gateway v1.14.3 h1:OCJlWkOUoTnl0neNGlf4fUm3TmbEtguw7vR+nGtnDjY=
 github.com/grpc-ecosystem/grpc-gateway v1.14.3/go.mod h1:6CwZWGDSPRJidgKAtJVvND6soZe6fT7iteq8wDPdhb0=
+github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
 github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
+github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/iancoleman/strcase v0.1.2 h1:gnomlvw9tnV3ITTAxzKSgTF+8kFWcU/f+TgttpXGz1U=
 github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
-github.com/iancoleman/strcase v0.1.3 h1:dJBk1m2/qjL1twPLf68JND55vvivMupZ4wIzE8CTdBw=
-github.com/iancoleman/strcase v0.1.3/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ=
+github.com/jackc/pgx v3.6.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I=
 github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
+github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=
 github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
 github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
 github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
 github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA=
 github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
 github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
 github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
 github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
 github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
 github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
@@ -141,99 +200,146 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
 github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
 github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
 github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
+github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
+github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
+github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
 github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
 github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
 github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
 github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
 github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
 github.com/pierrec/lz4 v2.5.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
 github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
+github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
 github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
+github.com/prometheus/client_golang v1.5.1 h1:bdHYieyGlH+6OLEk2YQha8THib30KP0/yD0YH9m6xcA=
 github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
 github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
 github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
 github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U=
 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
 github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
+github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8=
 github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
+github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
+github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
+github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
 github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
 github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
 github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=
 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
 github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
 github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
+github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4=
 github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
 github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
-github.com/tal-tech/go-zero v1.1.5 h1:c6xATUIEdTGoERNtguy7jGTW2/edly5D5zJq8osYG28=
-github.com/tal-tech/go-zero v1.1.5/go.mod h1:LbN0C7/rbl2+LUWTSUYx5leXmgedeMWjt1jc3/8/zFA=
+github.com/tal-tech/go-zero v1.1.6 h1:Xnbx0t10zzT2dcbpWOxmhsSu3DOkYwj604BSdfSkJlM=
+github.com/tal-tech/go-zero v1.1.6/go.mod h1:LbN0C7/rbl2+LUWTSUYx5leXmgedeMWjt1jc3/8/zFA=
 github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
+github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 h1:lYIiVDtZnyTWlNwiAxLj0bbpTcx1BWCFhXjfsvmPdNc=
 github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
 github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
 github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
 github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
+github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
 github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
 github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 h1:zzrxE1FKn5ryBNl9eKOeqQ58Y/Qpo3Q9QNxKHX5uzzQ=
 github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2/go.mod h1:hzfGeIUDq/j97IG+FhNqkowIyEcD88LrW6fyU3K3WqY=
 github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb h1:ZkM6LRnq40pR1Ox0hTHlnpkcOTuFIDQpZ1IN8rKKhX0=
 github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
+github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
+github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
+go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg=
 go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
+go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 h1:jWtjCJX1qxhHISBMLRztWwR+EXkI7MJAF2HjHAE/x/I=
 go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698/go.mod h1:YoUyTScD3Vcv2RBm3eGVOq7i1ULiz3OuXoQFWOirmAM=
+go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
+go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
 go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
 go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0=
 go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA=
 go.uber.org/automaxprocs v1.4.0 h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0=
 go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q=
+go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A=
 go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
+go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
 go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
+go.uber.org/zap v1.14.1 h1:nYDKopTbvAPq/NrUVZwT15y2lpROBiLLyoRTbXOYWOo=
 go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
 golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
 golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
 golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
 golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
 golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
+golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
 golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
 golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
 golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -242,11 +348,14 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
 golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
 golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -254,6 +363,7 @@ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5h
 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -265,18 +375,25 @@ golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1 h1:sIky/MyNRSHTrdxfsiUSS4WIAMvInbeXljJz+jDjeYE=
 golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
 golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
@@ -286,23 +403,34 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
 golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200410132612-ae9902aceb98 h1:ibc1eDGW5ajwA4qzFTj0WHlD9eofMe1gAre+A0a3Vhs=
 golang.org/x/tools v0.0.0-20200410132612-ae9902aceb98/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
 google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
 google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c h1:hrpEMCZ2O7DR5gC1n2AJGVhrwiEjOi35+jxtIuZpTMo=
 google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
 google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
+google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f h1:ohwtWcCwB/fZUxh/vjazHorYmBnua3NmY3CAjwC7mEA=
 google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
 google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
 google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
 google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
 google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
+google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg=
 google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4=
 google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
 google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
 google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
@@ -320,13 +448,17 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
 gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
 gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
 gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/h2non/gock.v1 v1.0.15 h1:SzLqcIlb/fDfg7UvukMpNcWsu7sI5tWwL+KCATZqks0=
 gopkg.in/h2non/gock.v1 v1.0.15/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE=
 gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
 gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
@@ -337,11 +469,19 @@ gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
+honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=
 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
 rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
 sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
+sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
 sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
+xorm.io/builder v0.3.6 h1:ha28mQ2M+TFx96Hxo+iq6tQgnkC9IZkM6D8w9sKHHF8=
+xorm.io/builder v0.3.6/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU=
+xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb h1:msX3zG3BPl8Ti+LDzP33/9K7BzO/WqFXk610K1kYKfo=
+xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM=

+ 150 - 0
rpc/activity.go

@@ -0,0 +1,150 @@
+package main
+
+import (
+	"app.yhyue.com/moapp/jyMarketing/entity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/config"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/server"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
+	"app.yhyue.com/moapp/jyMarketing/service"
+	"app.yhyue.com/moapp/jyMarketing/util"
+	"context"
+	"encoding/json"
+	"flag"
+	"fmt"
+	_ "github.com/go-sql-driver/mysql"
+	"github.com/go-xorm/xorm"
+	"github.com/robfig/cron"
+	"github.com/tal-tech/go-zero/core/conf"
+	"github.com/tal-tech/go-zero/zrpc"
+	"google.golang.org/grpc"
+	"log"
+	"strconv"
+	"time"
+)
+
+var configFile = flag.String("f", "etc/activity.yaml", "the config file")
+var c config.Config
+func main() {
+	flag.Parse()
+	conf.MustLoad(*configFile, &c)
+	ctx := svc.NewServiceContext(c)
+	srv := server.NewActivityServer(ctx)
+	s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
+		activity.RegisterActivityServer(grpcServer, srv)
+	})
+	defer s.Stop()
+	b := cron.New()
+	b.AddFunc(c.TimeSource, timeDask)
+	b.Start()
+	timeDask()
+	fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
+	s.Start()
+}
+//创建orm引擎
+func init() {
+	var err error
+	conf.MustLoad(*configFile, &c)
+	entity.Engine, err = xorm.NewEngine("mysql", c.DataSource)
+	entity.Engine.ShowSQL(true)
+	if err != nil {
+		log.Fatal("数据库连接失败:", err)
+	}
+	fmt.Println(c.DataSource+"链接成功")
+
+	redisCfg := c.Redis
+	if redisCfg.Addr != "" {
+		e := util.InitRedisPool(redisCfg.Modules, redisCfg.Addr, redisCfg.PoolMaxSize, redisCfg.PoolMaxIdle, redisCfg.IdleTimeout)
+		if e == nil {
+			log.Printf("redis addr:[%s] pool init successful......", redisCfg.Addr)
+		}
+	} else {
+		log.Println("redis has no configuration......")
+	}
+}
+
+func rateLimitInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
+	fmt.Println("拦截器")
+	log.Println("方法名:",info.FullMethod,"  参数:",req)
+	resp, err = handler(ctx, req)
+	fmt.Println("返回值",resp,err)
+	orm := entity.Engine.NewSession()
+	/*	reqData := req.(map[string]interface{})
+		appId:=reqData["AppId"]*/
+	var dat map[string]interface{}
+	jsonStr := Strval(req)
+	if err := json.Unmarshal([]byte(jsonStr), &dat); err == nil {
+		fmt.Println(dat)
+	}
+	appId:=dat["appId"]
+	eqspStr := Strval(resp)
+	if(len(eqspStr)>300){
+		eqspStr=eqspStr[0:300]
+	}
+	var sqlerr error
+	_,sqlerr = orm.Exec("INSERT INTO `interface_log`(`interName`, `calleeId`, `appId`, `inParameter`, `reTurnInfo`, `node`, `summary`,timestamp) VALUES (?,?,?,?,?,?,?,now())",info.FullMethod,c.CalleeId,appId,jsonStr,eqspStr,c.Node,"")
+	if sqlerr != nil {
+		log.Print("日志存储失败", sqlerr)
+	}
+	return resp,err
+}
+func Strval(value interface{}) string {
+	var key string
+	if value == nil {
+		return key
+	}
+
+	switch value.(type) {
+	case float64:
+		ft := value.(float64)
+		key = strconv.FormatFloat(ft, 'f', -1, 64)
+	case float32:
+		ft := value.(float32)
+		key = strconv.FormatFloat(float64(ft), 'f', -1, 64)
+	case int:
+		it := value.(int)
+		key = strconv.Itoa(it)
+	case uint:
+		it := value.(uint)
+		key = strconv.Itoa(int(it))
+	case int8:
+		it := value.(int8)
+		key = strconv.Itoa(int(it))
+	case uint8:
+		it := value.(uint8)
+		key = strconv.Itoa(int(it))
+	case int16:
+		it := value.(int16)
+		key = strconv.Itoa(int(it))
+	case uint16:
+		it := value.(uint16)
+		key = strconv.Itoa(int(it))
+	case int32:
+		it := value.(int32)
+		key = strconv.Itoa(int(it))
+	case uint32:
+		it := value.(uint32)
+		key = strconv.Itoa(int(it))
+	case int64:
+		it := value.(int64)
+		key = strconv.FormatInt(it, 10)
+	case uint64:
+		it := value.(uint64)
+		key = strconv.FormatUint(it, 10)
+	case string:
+		key = value.(string)
+	case []byte:
+		key = string(value.([]byte))
+	default:
+		newValue, _ := json.Marshal(value)
+		key = string(newValue)
+	}
+
+	return key
+}
+var (
+	activityService = &service.ActivityService{}
+)
+func timeDask()  {
+	activityService.UpdateLottery(time.Now().Format("2006-01-02"))
+}

+ 46 - 4
rpc/activity.proto

@@ -1,14 +1,56 @@
 syntax = "proto3";
 
 package activity;
+
 message Request {
-  string ping = 1;
+  int64 activityId= 1;//活动标识
+  string userId=2;//用户标识
+  string AppId=3;//身份标识
+  int64  Page=4;
+  int64  PageSize=5;
+  int64  model=6;//1查看名下所有奖券 0查看可以使用的奖券(没有过期的)
+}
+message LotteryOperation{
+   repeated int64 lotteryIdArr=1;//奖券标识集合
+   string userId=2;//用户标识
+   string AppId=3;//身份标识
 }
 
+
 message Response {
-  string pong = 1;
+   int64 code =1;    //响应代码
+   string message=2; //响应消息
 }
 
-service Activity {
-  rpc Ping(Request) returns(Response);
+//活动下的奖券信息
+message activityLotteryResp {
+  int64     code =1;            //响应代码
+  string    message=2;          //响应消息
+  repeated  LotteryJson data=3; //奖券信息
+  int64     count=4;            //数据条数
 }
+message LotteryJson{
+      int64   lotteryId=1;//奖券Id
+      string  lotteryName=2;//奖券名字
+      string  activityName=3;//活动名字
+      string  activityBeginDate=4;//活动时间起
+      string  activityendDate=5;//活动时间止
+      bool    isReceive=6;//是否领取
+      string  useProductList=7;//使用商品列表
+      int64   full=8;//满多少
+      int64   reduce=9;//减多少
+      string  Instructions=10;//使用说明
+      string  remark=11;//备注
+}
+
+
+service Activity {
+  //查询活动下的奖券
+  rpc activityLottery(Request) returns(activityLotteryResp);
+  //奖券领取
+  rpc lotteryReceive(LotteryOperation) returns(Response);
+  //奖券使用
+  rpc activityUse(LotteryOperation) returns(Response);
+  //用户可用的奖券
+  rpc userLottery(Request) returns(activityLotteryResp);
+}

+ 773 - 0
rpc/activity/activity.pb.go

@@ -0,0 +1,773 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.25.0
+// 	protoc        v3.15.1
+// source: activity.proto
+
+package activity
+
+import (
+	context "context"
+	proto "github.com/golang/protobuf/proto"
+	grpc "google.golang.org/grpc"
+	codes "google.golang.org/grpc/codes"
+	status "google.golang.org/grpc/status"
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	reflect "reflect"
+	sync "sync"
+)
+
+const (
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+// This is a compile-time assertion that a sufficiently up-to-date version
+// of the legacy proto package is being used.
+const _ = proto.ProtoPackageIsVersion4
+
+type Request struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ActivityId int64  `protobuf:"varint,1,opt,name=activityId,proto3" json:"activityId,omitempty"` //活动标识
+	UserId     string `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"`          //用户标识
+	AppId      string `protobuf:"bytes,3,opt,name=AppId,proto3" json:"AppId,omitempty"`            //身份标识
+}
+
+func (x *Request) Reset() {
+	*x = Request{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_activity_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Request) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Request) ProtoMessage() {}
+
+func (x *Request) ProtoReflect() protoreflect.Message {
+	mi := &file_activity_proto_msgTypes[0]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Request.ProtoReflect.Descriptor instead.
+func (*Request) Descriptor() ([]byte, []int) {
+	return file_activity_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *Request) GetActivityId() int64 {
+	if x != nil {
+		return x.ActivityId
+	}
+	return 0
+}
+
+func (x *Request) GetUserId() string {
+	if x != nil {
+		return x.UserId
+	}
+	return ""
+}
+
+func (x *Request) GetAppId() string {
+	if x != nil {
+		return x.AppId
+	}
+	return ""
+}
+
+type LotteryOperation struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	LotteryIdArr []int64 `protobuf:"varint,1,rep,packed,name=lotteryIdArr,proto3" json:"lotteryIdArr,omitempty"` //奖券标识集合
+	UserId       string  `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"`                     //用户标识
+	AppId        string  `protobuf:"bytes,3,opt,name=AppId,proto3" json:"AppId,omitempty"`                       //身份标识
+}
+
+func (x *LotteryOperation) Reset() {
+	*x = LotteryOperation{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_activity_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *LotteryOperation) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*LotteryOperation) ProtoMessage() {}
+
+func (x *LotteryOperation) ProtoReflect() protoreflect.Message {
+	mi := &file_activity_proto_msgTypes[1]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use LotteryOperation.ProtoReflect.Descriptor instead.
+func (*LotteryOperation) Descriptor() ([]byte, []int) {
+	return file_activity_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *LotteryOperation) GetLotteryIdArr() []int64 {
+	if x != nil {
+		return x.LotteryIdArr
+	}
+	return nil
+}
+
+func (x *LotteryOperation) GetUserId() string {
+	if x != nil {
+		return x.UserId
+	}
+	return ""
+}
+
+func (x *LotteryOperation) GetAppId() string {
+	if x != nil {
+		return x.AppId
+	}
+	return ""
+}
+
+type Response struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Code    int64  `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`      //响应代码
+	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` //响应消息
+}
+
+func (x *Response) Reset() {
+	*x = Response{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_activity_proto_msgTypes[2]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Response) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Response) ProtoMessage() {}
+
+func (x *Response) ProtoReflect() protoreflect.Message {
+	mi := &file_activity_proto_msgTypes[2]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Response.ProtoReflect.Descriptor instead.
+func (*Response) Descriptor() ([]byte, []int) {
+	return file_activity_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *Response) GetCode() int64 {
+	if x != nil {
+		return x.Code
+	}
+	return 0
+}
+
+func (x *Response) GetMessage() string {
+	if x != nil {
+		return x.Message
+	}
+	return ""
+}
+
+//活动下的奖券信息
+type ActivityLotteryResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Code    int64          `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`      //响应代码
+	Message string         `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` //响应消息
+	Data    []*LotteryJson `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"`       //奖券信息
+}
+
+func (x *ActivityLotteryResp) Reset() {
+	*x = ActivityLotteryResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_activity_proto_msgTypes[3]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ActivityLotteryResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ActivityLotteryResp) ProtoMessage() {}
+
+func (x *ActivityLotteryResp) ProtoReflect() protoreflect.Message {
+	mi := &file_activity_proto_msgTypes[3]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ActivityLotteryResp.ProtoReflect.Descriptor instead.
+func (*ActivityLotteryResp) Descriptor() ([]byte, []int) {
+	return file_activity_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *ActivityLotteryResp) GetCode() int64 {
+	if x != nil {
+		return x.Code
+	}
+	return 0
+}
+
+func (x *ActivityLotteryResp) GetMessage() string {
+	if x != nil {
+		return x.Message
+	}
+	return ""
+}
+
+func (x *ActivityLotteryResp) GetData() []*LotteryJson {
+	if x != nil {
+		return x.Data
+	}
+	return nil
+}
+
+type LotteryJson struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	LotteryId         int64  `protobuf:"varint,1,opt,name=lotteryId,proto3" json:"lotteryId,omitempty"`                //奖券Id
+	LotteryName       string `protobuf:"bytes,2,opt,name=lotteryName,proto3" json:"lotteryName,omitempty"`             //奖券名字
+	ActivityName      string `protobuf:"bytes,3,opt,name=activityName,proto3" json:"activityName,omitempty"`           //活动名字
+	ActivityBeginDate string `protobuf:"bytes,4,opt,name=activityBeginDate,proto3" json:"activityBeginDate,omitempty"` //活动时间起
+	ActivityendDate   string `protobuf:"bytes,5,opt,name=activityendDate,proto3" json:"activityendDate,omitempty"`     //活动时间止
+	IsReceive         bool   `protobuf:"varint,6,opt,name=isReceive,proto3" json:"isReceive,omitempty"`                //是否领取
+	UseProductList    string `protobuf:"bytes,7,opt,name=useProductList,proto3" json:"useProductList,omitempty"`       //使用商品列表
+	Full              int64  `protobuf:"varint,8,opt,name=full,proto3" json:"full,omitempty"`                          //满多少
+	Reduce            int64  `protobuf:"varint,9,opt,name=reduce,proto3" json:"reduce,omitempty"`                      //减多少
+}
+
+func (x *LotteryJson) Reset() {
+	*x = LotteryJson{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_activity_proto_msgTypes[4]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *LotteryJson) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*LotteryJson) ProtoMessage() {}
+
+func (x *LotteryJson) ProtoReflect() protoreflect.Message {
+	mi := &file_activity_proto_msgTypes[4]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use LotteryJson.ProtoReflect.Descriptor instead.
+func (*LotteryJson) Descriptor() ([]byte, []int) {
+	return file_activity_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *LotteryJson) GetLotteryId() int64 {
+	if x != nil {
+		return x.LotteryId
+	}
+	return 0
+}
+
+func (x *LotteryJson) GetLotteryName() string {
+	if x != nil {
+		return x.LotteryName
+	}
+	return ""
+}
+
+func (x *LotteryJson) GetActivityName() string {
+	if x != nil {
+		return x.ActivityName
+	}
+	return ""
+}
+
+func (x *LotteryJson) GetActivityBeginDate() string {
+	if x != nil {
+		return x.ActivityBeginDate
+	}
+	return ""
+}
+
+func (x *LotteryJson) GetActivityendDate() string {
+	if x != nil {
+		return x.ActivityendDate
+	}
+	return ""
+}
+
+func (x *LotteryJson) GetIsReceive() bool {
+	if x != nil {
+		return x.IsReceive
+	}
+	return false
+}
+
+func (x *LotteryJson) GetUseProductList() string {
+	if x != nil {
+		return x.UseProductList
+	}
+	return ""
+}
+
+func (x *LotteryJson) GetFull() int64 {
+	if x != nil {
+		return x.Full
+	}
+	return 0
+}
+
+func (x *LotteryJson) GetReduce() int64 {
+	if x != nil {
+		return x.Reduce
+	}
+	return 0
+}
+
+var File_activity_proto protoreflect.FileDescriptor
+
+var file_activity_proto_rawDesc = []byte{
+	0x0a, 0x0e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+	0x12, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x22, 0x57, 0x0a, 0x07, 0x52, 0x65,
+	0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74,
+	0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x76,
+	0x69, 0x74, 0x79, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18,
+	0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a,
+	0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x41, 0x70,
+	0x70, 0x49, 0x64, 0x22, 0x64, 0x0a, 0x10, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x4f, 0x70,
+	0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x6f, 0x74, 0x74, 0x65,
+	0x72, 0x79, 0x49, 0x64, 0x41, 0x72, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0c, 0x6c,
+	0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x49, 0x64, 0x41, 0x72, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x75,
+	0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65,
+	0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x22, 0x38, 0x0a, 0x08, 0x52, 0x65, 0x73,
+	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
+	0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73,
+	0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73,
+	0x61, 0x67, 0x65, 0x22, 0x6e, 0x0a, 0x13, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c,
+	0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f,
+	0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18,
+	0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
+	0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74,
+	0x79, 0x2e, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x4a, 0x73, 0x6f, 0x6e, 0x52, 0x04, 0x64,
+	0x61, 0x74, 0x61, 0x22, 0xbb, 0x02, 0x0a, 0x0b, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x4a,
+	0x73, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x49, 0x64,
+	0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x49,
+	0x64, 0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65,
+	0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x4e,
+	0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4e,
+	0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76,
+	0x69, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x11, 0x61, 0x63, 0x74, 0x69, 0x76,
+	0x69, 0x74, 0x79, 0x42, 0x65, 0x67, 0x69, 0x6e, 0x44, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x11, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x42, 0x65, 0x67, 0x69,
+	0x6e, 0x44, 0x61, 0x74, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74,
+	0x79, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f,
+	0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x65, 0x12,
+	0x1c, 0x0a, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, 0x01,
+	0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x12, 0x26, 0x0a,
+	0x0e, 0x75, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x18,
+	0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x75, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63,
+	0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x75, 0x6c, 0x6c, 0x18, 0x08, 0x20,
+	0x01, 0x28, 0x03, 0x52, 0x04, 0x66, 0x75, 0x6c, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x64,
+	0x75, 0x63, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x72, 0x65, 0x64, 0x75, 0x63,
+	0x65, 0x32, 0x91, 0x02, 0x0a, 0x08, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x43,
+	0x0a, 0x0f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72,
+	0x79, 0x12, 0x11, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x71,
+	0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e,
+	0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52,
+	0x65, 0x73, 0x70, 0x12, 0x40, 0x0a, 0x0e, 0x6c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x52, 0x65,
+	0x63, 0x65, 0x69, 0x76, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
+	0x2e, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f,
+	0x6e, 0x1a, 0x12, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x73,
+	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74,
+	0x79, 0x55, 0x73, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e,
+	0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72, 0x79, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+	0x1a, 0x12, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52, 0x65, 0x73, 0x70,
+	0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x0b, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x74, 0x74,
+	0x65, 0x72, 0x79, 0x12, 0x11, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e, 0x52,
+	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74,
+	0x79, 0x2e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4c, 0x6f, 0x74, 0x74, 0x65, 0x72,
+	0x79, 0x52, 0x65, 0x73, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+	file_activity_proto_rawDescOnce sync.Once
+	file_activity_proto_rawDescData = file_activity_proto_rawDesc
+)
+
+func file_activity_proto_rawDescGZIP() []byte {
+	file_activity_proto_rawDescOnce.Do(func() {
+		file_activity_proto_rawDescData = protoimpl.X.CompressGZIP(file_activity_proto_rawDescData)
+	})
+	return file_activity_proto_rawDescData
+}
+
+var file_activity_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
+var file_activity_proto_goTypes = []interface{}{
+	(*Request)(nil),             // 0: activity.Request
+	(*LotteryOperation)(nil),    // 1: activity.LotteryOperation
+	(*Response)(nil),            // 2: activity.Response
+	(*ActivityLotteryResp)(nil), // 3: activity.activityLotteryResp
+	(*LotteryJson)(nil),         // 4: activity.LotteryJson
+}
+var file_activity_proto_depIdxs = []int32{
+	4, // 0: activity.activityLotteryResp.data:type_name -> activity.LotteryJson
+	0, // 1: activity.Activity.activityLottery:input_type -> activity.Request
+	1, // 2: activity.Activity.lotteryReceive:input_type -> activity.LotteryOperation
+	1, // 3: activity.Activity.activityUse:input_type -> activity.LotteryOperation
+	0, // 4: activity.Activity.userLottery:input_type -> activity.Request
+	3, // 5: activity.Activity.activityLottery:output_type -> activity.activityLotteryResp
+	2, // 6: activity.Activity.lotteryReceive:output_type -> activity.Response
+	2, // 7: activity.Activity.activityUse:output_type -> activity.Response
+	3, // 8: activity.Activity.userLottery:output_type -> activity.activityLotteryResp
+	5, // [5:9] is the sub-list for method output_type
+	1, // [1:5] is the sub-list for method input_type
+	1, // [1:1] is the sub-list for extension type_name
+	1, // [1:1] is the sub-list for extension extendee
+	0, // [0:1] is the sub-list for field type_name
+}
+
+func init() { file_activity_proto_init() }
+func file_activity_proto_init() {
+	if File_activity_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_activity_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Request); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_activity_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*LotteryOperation); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_activity_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Response); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_activity_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ActivityLotteryResp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_activity_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*LotteryJson); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+	}
+	type x struct{}
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+			RawDescriptor: file_activity_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   5,
+			NumExtensions: 0,
+			NumServices:   1,
+		},
+		GoTypes:           file_activity_proto_goTypes,
+		DependencyIndexes: file_activity_proto_depIdxs,
+		MessageInfos:      file_activity_proto_msgTypes,
+	}.Build()
+	File_activity_proto = out.File
+	file_activity_proto_rawDesc = nil
+	file_activity_proto_goTypes = nil
+	file_activity_proto_depIdxs = nil
+}
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ context.Context
+var _ grpc.ClientConnInterface
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion6
+
+// ActivityClient is the client API for Activity service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
+type ActivityClient interface {
+	//查询活动下的奖券
+	ActivityLottery(ctx context.Context, in *Request, opts ...grpc.CallOption) (*ActivityLotteryResp, error)
+	//奖券领取
+	LotteryReceive(ctx context.Context, in *LotteryOperation, opts ...grpc.CallOption) (*Response, error)
+	//奖券使用
+	ActivityUse(ctx context.Context, in *LotteryOperation, opts ...grpc.CallOption) (*Response, error)
+	//用户可用的奖券
+	UserLottery(ctx context.Context, in *Request, opts ...grpc.CallOption) (*ActivityLotteryResp, error)
+}
+
+type activityClient struct {
+	cc grpc.ClientConnInterface
+}
+
+func NewActivityClient(cc grpc.ClientConnInterface) ActivityClient {
+	return &activityClient{cc}
+}
+
+func (c *activityClient) ActivityLottery(ctx context.Context, in *Request, opts ...grpc.CallOption) (*ActivityLotteryResp, error) {
+	out := new(ActivityLotteryResp)
+	err := c.cc.Invoke(ctx, "/activity.Activity/activityLottery", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *activityClient) LotteryReceive(ctx context.Context, in *LotteryOperation, opts ...grpc.CallOption) (*Response, error) {
+	out := new(Response)
+	err := c.cc.Invoke(ctx, "/activity.Activity/lotteryReceive", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *activityClient) ActivityUse(ctx context.Context, in *LotteryOperation, opts ...grpc.CallOption) (*Response, error) {
+	out := new(Response)
+	err := c.cc.Invoke(ctx, "/activity.Activity/activityUse", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *activityClient) UserLottery(ctx context.Context, in *Request, opts ...grpc.CallOption) (*ActivityLotteryResp, error) {
+	out := new(ActivityLotteryResp)
+	err := c.cc.Invoke(ctx, "/activity.Activity/userLottery", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+// ActivityServer is the server API for Activity service.
+type ActivityServer interface {
+	//查询活动下的奖券
+	ActivityLottery(context.Context, *Request) (*ActivityLotteryResp, error)
+	//奖券领取
+	LotteryReceive(context.Context, *LotteryOperation) (*Response, error)
+	//奖券使用
+	ActivityUse(context.Context, *LotteryOperation) (*Response, error)
+	//用户可用的奖券
+	UserLottery(context.Context, *Request) (*ActivityLotteryResp, error)
+}
+
+// UnimplementedActivityServer can be embedded to have forward compatible implementations.
+type UnimplementedActivityServer struct {
+}
+
+func (*UnimplementedActivityServer) ActivityLottery(context.Context, *Request) (*ActivityLotteryResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ActivityLottery not implemented")
+}
+func (*UnimplementedActivityServer) LotteryReceive(context.Context, *LotteryOperation) (*Response, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method LotteryReceive not implemented")
+}
+func (*UnimplementedActivityServer) ActivityUse(context.Context, *LotteryOperation) (*Response, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ActivityUse not implemented")
+}
+func (*UnimplementedActivityServer) UserLottery(context.Context, *Request) (*ActivityLotteryResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method UserLottery not implemented")
+}
+
+func RegisterActivityServer(s *grpc.Server, srv ActivityServer) {
+	s.RegisterService(&_Activity_serviceDesc, srv)
+}
+
+func _Activity_ActivityLottery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(Request)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ActivityServer).ActivityLottery(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/activity.Activity/ActivityLottery",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ActivityServer).ActivityLottery(ctx, req.(*Request))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Activity_LotteryReceive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(LotteryOperation)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ActivityServer).LotteryReceive(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/activity.Activity/LotteryReceive",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ActivityServer).LotteryReceive(ctx, req.(*LotteryOperation))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Activity_ActivityUse_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(LotteryOperation)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ActivityServer).ActivityUse(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/activity.Activity/ActivityUse",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ActivityServer).ActivityUse(ctx, req.(*LotteryOperation))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Activity_UserLottery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(Request)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ActivityServer).UserLottery(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/activity.Activity/UserLottery",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ActivityServer).UserLottery(ctx, req.(*Request))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+var _Activity_serviceDesc = grpc.ServiceDesc{
+	ServiceName: "activity.Activity",
+	HandlerType: (*ActivityServer)(nil),
+	Methods: []grpc.MethodDesc{
+		{
+			MethodName: "activityLottery",
+			Handler:    _Activity_ActivityLottery_Handler,
+		},
+		{
+			MethodName: "lotteryReceive",
+			Handler:    _Activity_LotteryReceive_Handler,
+		},
+		{
+			MethodName: "activityUse",
+			Handler:    _Activity_ActivityUse_Handler,
+		},
+		{
+			MethodName: "userLottery",
+			Handler:    _Activity_UserLottery_Handler,
+		},
+	},
+	Streams:  []grpc.StreamDesc{},
+	Metadata: "activity.proto",
+}

+ 67 - 0
rpc/activityclient/activity.go

@@ -0,0 +1,67 @@
+// Code generated by goctl. DO NOT EDIT!
+// Source: activity.proto
+
+//go:generate mockgen -destination ./activity_mock.go -package activityclient -source $GOFILE
+
+package activityclient
+
+import (
+	"context"
+
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+
+	"github.com/tal-tech/go-zero/zrpc"
+)
+
+type (
+	Request             = activity.Request
+	LotteryOperation    = activity.LotteryOperation
+	Response            = activity.Response
+	ActivityLotteryResp = activity.ActivityLotteryResp
+	LotteryJson         = activity.LotteryJson
+
+	Activity interface {
+		// 查询活动下的奖券
+		ActivityLottery(ctx context.Context, in *Request) (*ActivityLotteryResp, error)
+		// 奖券领取
+		LotteryReceive(ctx context.Context, in *LotteryOperation) (*Response, error)
+		// 奖券使用
+		ActivityUse(ctx context.Context, in *LotteryOperation) (*Response, error)
+		// 用户可用的奖券
+		UserLottery(ctx context.Context, in *Request) (*ActivityLotteryResp, error)
+	}
+
+	defaultActivity struct {
+		cli zrpc.Client
+	}
+)
+
+func NewActivity(cli zrpc.Client) Activity {
+	return &defaultActivity{
+		cli: cli,
+	}
+}
+
+// 查询活动下的奖券
+func (m *defaultActivity) ActivityLottery(ctx context.Context, in *Request) (*ActivityLotteryResp, error) {
+	client := activity.NewActivityClient(m.cli.Conn())
+	return client.ActivityLottery(ctx, in)
+}
+
+// 奖券领取
+func (m *defaultActivity) LotteryReceive(ctx context.Context, in *LotteryOperation) (*Response, error) {
+	client := activity.NewActivityClient(m.cli.Conn())
+	return client.LotteryReceive(ctx, in)
+}
+
+// 奖券使用
+func (m *defaultActivity) ActivityUse(ctx context.Context, in *LotteryOperation) (*Response, error) {
+	client := activity.NewActivityClient(m.cli.Conn())
+	return client.ActivityUse(ctx, in)
+}
+
+// 用户可用的奖券
+func (m *defaultActivity) UserLottery(ctx context.Context, in *Request) (*ActivityLotteryResp, error) {
+	client := activity.NewActivityClient(m.cli.Conn())
+	return client.UserLottery(ctx, in)
+}

+ 19 - 0
rpc/etc/activity.yaml

@@ -1,6 +1,25 @@
 Name: activity.rpc
 ListenOn: 127.0.0.1:8080
+Redis:
+  Host: 127.0.0.1
+  addr: 127.0.0.1:6379
+  modules:  activity
+  poolMaxSize: 10
+  poolMaxIdle: 20
+  idleTimeout: 240
+  maxSize: 20
+  maxIdle: 20
 Etcd:
   Hosts:
   - 127.0.0.1:2379
   Key: activity.rpc
+DataSource: root:Topnet123@tcp(192.168.3.11:3366)/jyactivities?charset=utf8mb4&parseTime=true&loc=Local
+FileSystemConf:
+  Etcd:
+    Hosts:
+      - 127.0.0.1:2379
+    Key: activity.rpc
+CalleeId: activity.rpc
+Node: 1
+TimeSource: 0 1 0 * * ? *
+

+ 0 - 11
rpc/go.mod

@@ -1,11 +0,0 @@
-module rpc
-
-go 1.13
-
-require (
-	github.com/antlr/antlr4 v0.0.0-20210319025552-3590d4d5e18c // indirect
-	github.com/golang/protobuf v1.5.1 // indirect
-	github.com/iancoleman/strcase v0.1.3 // indirect
-	github.com/tal-tech/go-zero v1.1.5 // indirect
-	go.uber.org/automaxprocs v1.4.0 // indirect
-)

+ 20 - 0
rpc/internal/config/config.go

@@ -0,0 +1,20 @@
+package config
+
+import "github.com/tal-tech/go-zero/zrpc"
+
+type Config struct {
+	zrpc.RpcServerConf
+	DataSource     string // 手动代码
+	Node           int    // 节点
+	CalleeId       string // 服务名字
+	FileSystemConf zrpc.RpcClientConf
+	TimeSource     string //定时任务
+	Redis          Redis
+}
+type Redis struct {
+	Addr        string `json:"addr"`
+	Modules     string `json:"modules"`
+	PoolMaxSize int    `json:"maxSize"`
+	PoolMaxIdle int    `json:"maxIdle"`
+	IdleTimeout int    `json:"idleTimeOut"`
+}

+ 47 - 0
rpc/internal/logic/activitylotterylogic.go

@@ -0,0 +1,47 @@
+package logic
+
+import (
+	"context"
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type ActivityLotteryLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewActivityLotteryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ActivityLotteryLogic {
+	return &ActivityLotteryLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 查询活动下的奖券
+func (l *ActivityLotteryLogic) ActivityLottery(in *activity.Request) (*activity.ActivityLotteryResp, error) {
+	// todo: add your logic here and delete this line
+	result := &activity.ActivityLotteryResp{}
+	code, msg, data := activityService.ActivityLottery(in)
+	var userLotteryList []*activity.LotteryJson
+	for _, value := range data {
+		userLottery := activity.LotteryJson{}
+		userLottery.LotteryId = value.LotteryId
+		userLottery.LotteryName=value.Name
+		userLottery.IsReceive=true
+		if (value.IsLimitNumber==1){
+			if value.Count>=int64(value.LimitNumber){
+				userLottery.IsReceive=false
+			}
+		}
+		userLottery.UseProductList = value.UseProductList
+		userLotteryList = append(userLotteryList, &userLottery)
+	}
+	result.Code = code
+	result.Message = msg
+	result.Data=userLotteryList
+	return result, nil
+}

+ 34 - 0
rpc/internal/logic/activityuselogic.go

@@ -0,0 +1,34 @@
+package logic
+
+import (
+	"context"
+
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type ActivityUseLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewActivityUseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ActivityUseLogic {
+	return &ActivityUseLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 奖券使用
+func (l *ActivityUseLogic) ActivityUse(in *activity.LotteryOperation) (*activity.Response, error) {
+	// todo: add your logic here and delete this line
+	result := &activity.Response{}
+	code, msg := activityService.ActivityUse(in)
+	result.Code =code
+	result.Message = msg
+	return result, nil
+}

+ 39 - 0
rpc/internal/logic/lotteryreceivelogic.go

@@ -0,0 +1,39 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jyMarketing/service"
+	"context"
+
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+var (
+	activityService = &service.ActivityService{}
+)
+
+type LotteryReceiveLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewLotteryReceiveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LotteryReceiveLogic {
+	return &LotteryReceiveLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 奖券领取
+func (l *LotteryReceiveLogic) LotteryReceive(in *activity.LotteryOperation) (*activity.Response, error) {
+	// todo: add your logic here and delete this line
+	result := &activity.Response{}
+	code, msg := activityService.LotteryReceive(in)
+	result.Code =code
+	result.Message = msg
+	return result, nil
+}

+ 50 - 0
rpc/internal/logic/userlotterylogic.go

@@ -0,0 +1,50 @@
+package logic
+
+import (
+	"context"
+	"fmt"
+
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type UserLotteryLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewUserLotteryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLotteryLogic {
+	return &UserLotteryLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 用户可用的奖券
+func (l *UserLotteryLogic) UserLottery(in *activity.Request) (*activity.ActivityLotteryResp, error) {
+	// todo: add your logic here and delete this line
+	result := &activity.ActivityLotteryResp{}
+	code, msg, data,count := activityService.UserLottery(in, 1)
+	var userLotteryList []*activity.LotteryJson
+	for _, value := range data {
+		userLottery := activity.LotteryJson{}
+		userLottery.Reduce = value.Reduce
+		userLottery.Full = value.Full
+		userLottery.LotteryId = value.LotteryId
+		userLottery.ActivityBeginDate = value.BeginDate
+		userLottery.ActivityendDate = value.EndDate
+		userLottery.ActivityName = value.Name
+		userLottery.UseProductList = value.UseProductList
+		userLotteryList = append(userLotteryList, &userLottery)
+	}
+	fmt.Println(count)
+	result.Code = code
+	result.Message = msg
+	///result.Count=count
+	result.Data = userLotteryList
+	return &activity.ActivityLotteryResp{}, nil
+}

+ 46 - 0
rpc/internal/server/activityserver.go

@@ -0,0 +1,46 @@
+// Code generated by goctl. DO NOT EDIT!
+// Source: activity.proto
+
+package server
+
+import (
+	"context"
+
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/logic"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/svc"
+)
+
+type ActivityServer struct {
+	svcCtx *svc.ServiceContext
+}
+
+func NewActivityServer(svcCtx *svc.ServiceContext) *ActivityServer {
+	return &ActivityServer{
+		svcCtx: svcCtx,
+	}
+}
+
+// 查询活动下的奖券
+func (s *ActivityServer) ActivityLottery(ctx context.Context, in *activity.Request) (*activity.ActivityLotteryResp, error) {
+	l := logic.NewActivityLotteryLogic(ctx, s.svcCtx)
+	return l.ActivityLottery(in)
+}
+
+// 奖券领取
+func (s *ActivityServer) LotteryReceive(ctx context.Context, in *activity.LotteryOperation) (*activity.Response, error) {
+	l := logic.NewLotteryReceiveLogic(ctx, s.svcCtx)
+	return l.LotteryReceive(in)
+}
+
+// 奖券使用
+func (s *ActivityServer) ActivityUse(ctx context.Context, in *activity.LotteryOperation) (*activity.Response, error) {
+	l := logic.NewActivityUseLogic(ctx, s.svcCtx)
+	return l.ActivityUse(in)
+}
+
+// 用户可用的奖券
+func (s *ActivityServer) UserLottery(ctx context.Context, in *activity.Request) (*activity.ActivityLotteryResp, error) {
+	l := logic.NewUserLotteryLogic(ctx, s.svcCtx)
+	return l.UserLottery(in)
+}

+ 13 - 0
rpc/internal/svc/servicecontext.go

@@ -0,0 +1,13 @@
+package svc
+
+import "app.yhyue.com/moapp/jyMarketing/rpc/internal/config"
+
+type ServiceContext struct {
+	Config config.Config
+}
+
+func NewServiceContext(c config.Config) *ServiceContext {
+	return &ServiceContext{
+		Config: c,
+	}
+}

+ 14 - 0
rpc/test/activity.yaml

@@ -0,0 +1,14 @@
+Name: activity.rpc
+ListenOn: 127.0.0.1:8080
+Etcd:
+  Hosts:
+    - 127.0.0.1:2379
+  Key: activity.rpc
+DataSource: root:Topnet123@tcp(192.168.3.11:3366)/jyactivities?charset=utf8mb4&parseTime=true&loc=Local
+FileSystemConf:
+  Etcd:
+    Hosts:
+      - 127.0.0.1:2379
+    Key: activity.rpc
+CalleeId: activity.rpc
+Node: 1

+ 59 - 0
rpc/test/test1_test.go

@@ -0,0 +1,59 @@
+package test
+
+import (
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/activityclient"
+	"app.yhyue.com/moapp/jyMarketing/rpc/internal/config"
+	"context"
+	"flag"
+	"github.com/tal-tech/go-zero/core/conf"
+	"github.com/tal-tech/go-zero/zrpc"
+	"log"
+	"testing"
+	"time"
+)
+
+var configFile = flag.String("f", "activity.yaml", "the config file")
+var c config.Config
+
+func init() {
+	conf.MustLoad(*configFile, &c)
+}
+//活动下的奖券
+func  Test_activityLottery(t *testing.T)  {
+	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
+	req := &activity.Request{UserId: "ABC", AppId: "123",ActivityId:1}
+	res, err := FileSystem.ActivityLottery(ctx, req)
+	log.Println("err ", err)
+	log.Println("req ", res)
+}
+//奖券领取
+func  Test_lotteryReceive(t *testing.T)  {
+	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
+	lotteryIdArr:=[]int64{2}
+	req := &activity.LotteryOperation{UserId: "ABC", AppId: "123",LotteryIdArr:lotteryIdArr}
+	res, err := FileSystem.LotteryReceive(ctx, req)
+	log.Println("err ", err)
+	log.Println("req ", res)
+}
+//用户下的奖券
+func  Test_UserLottery(t *testing.T)  {
+	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
+	req := &activity.Request{UserId: "ABC", AppId: "123"}
+	res, err := FileSystem.UserLottery(ctx, req)
+	log.Println("err ", err)
+	log.Println("req ", res)
+}
+//奖券使用
+func Test_ActivityUse(t *testing.T)  {
+	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
+	lotteryIdArr:=[]int64{2}
+	req := &activity.LotteryOperation{UserId: "ABC", AppId: "123",LotteryIdArr:lotteryIdArr}
+	res, err := FileSystem.ActivityUse(ctx, req)
+	log.Println("err ", err)
+	log.Println("req ", res)
+}

+ 236 - 0
service/ActivityService.go

@@ -0,0 +1,236 @@
+package service
+
+import (
+	"app.yhyue.com/moapp/jyMarketing/entity"
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"fmt"
+	_ "github.com/garyburd/redigo/redis"
+	"log"
+	"time"
+)
+
+type ActivityService struct{}
+
+//奖券获取
+func (service *ActivityService) LotteryReceive(data *activity.LotteryOperation) (int64, string) {
+	orm := entity.Engine.NewSession()
+	defer orm.Close()
+	err := orm.Begin()
+	bool := true
+	if len(data.LotteryIdArr) == 0 {
+		return entity.ErrorCode, "没有卷可以领取"
+	}
+	for _, lotteryId := range data.LotteryIdArr {
+		log.Println(fmt.Sprint(lotteryId) + "Id奖券领取")
+		//每种劵处理
+		//1、先查询奖券信息
+		prizeData := entity.PrizeJson{}
+		bool, err = orm.Table("lottery").
+			Alias("l").Select("l.name,l.full,l.reduce,	l.prizeId,p.beginDate,p.endDate,p.isLimitNumber,p.limitNumber,p.validityDates,p.validityTimeType").
+			Join("left", "prize p", "l.prizeId=p.id").
+			Where("l.id=?", lotteryId).Get(&prizeData)
+		if err != nil {
+			log.Panicln("查询奖品信息:", err)
+			orm.Rollback()
+			return entity.ErrorCode, "奖品信息查询失败"
+		}
+		if !bool {
+			log.Panicln("查询奖品信息:", err)
+			orm.Rollback()
+			return entity.ErrorCode, "奖品信息查询失败"
+		}
+		//2、先判断奖券是否可以重复领取,在判断之前是否领取过
+		if prizeData.IsLimitNumber == 1 {
+			//查询之前是否领取过
+			userLotteryList := []entity.UserPrize{}
+			err = orm.Table("user_prize").
+				Where("userId=? and  appId=? and  lotteryId=?", data.UserId, data.AppId, lotteryId).Find(&userLotteryList)
+			if err != nil {
+				log.Panicln("查询奖品信息:", err)
+				orm.Rollback()
+				return entity.ErrorCode, "查询领取次数失败"
+			}
+			if len(userLotteryList) >= prizeData.LimitNumber {
+				orm.Rollback()
+				return entity.ErrorCode, "你领取奖券数量已达上限"
+			}
+		}
+		//3、在判断奖券是否够用
+		//4、领取奖券
+		userLettry := entity.UserPrize{}
+		userLettry.AppId = data.AppId
+		userLettry.UserId = data.UserId
+		userLettry.PrizeType = 0
+		userLettry.CreateTime = time.Now()
+		userLettry.LotteryId = lotteryId
+		userLettry.PrizeId = prizeData.PrizeId
+		userLettry.ValidityDates = prizeData.ValidityDates
+		userLettry.Name = prizeData.Name
+		userLettry.Full = int64(prizeData.Full)
+		userLettry.Reduce = int64(prizeData.Reduce)
+		//0、有起止时间1、当天起几天可用2、次日起几天可用
+		switch prizeData.ValidityTimeType {
+		case 0:
+			userLettry.EndDate = prizeData.EndDate
+			userLettry.BeginDate = prizeData.BeginDate
+		case 1:
+			nowStr := time.Now().Format("2006-01-02")
+			userLettry.BeginDate = nowStr
+			userLettry.EndDate = service.ObtainAppointTimeString(nowStr, prizeData.ValidityDates)
+		case 2:
+			nowStr := time.Now().Format("2006-01-02")
+			nextDayStr := service.ObtainAppointTimeString(nowStr, 1)
+			userLettry.BeginDate = nextDayStr
+			userLettry.EndDate = service.ObtainAppointTimeString(nextDayStr, prizeData.ValidityDates)
+		}
+		numb, err := orm.Table("user_prize").Insert(&userLettry)
+		if err != nil || numb == int64(0) {
+			log.Panicln("领取奖券失败:", err)
+			orm.Rollback()
+			return entity.ErrorCode, "领取奖券失败"
+		}
+
+		//5、修改奖券余额数量
+		lottery := entity.Lottery{}
+		lottery.Id = lotteryId
+		_, err = orm.Exec("UPDATE lottery SET `stockNumber` = stockNumber-1, `receiveNumber` = receiveNumber+1 WHERE `id` = ?", lotteryId)
+		if err != nil {
+			log.Panicln("修改奖券库存失败:", err)
+			orm.Rollback()
+			return entity.ErrorCode, "修改奖券库存失败"
+		}
+
+	}
+	orm.Commit()
+	return entity.SuccessCode, "奖券领取成功"
+}
+
+//奖券使用
+func (service *ActivityService) ActivityUse(data *activity.LotteryOperation) (int64, string) {
+	orm := entity.Engine.NewSession()
+	defer orm.Close()
+	err := orm.Begin()
+	nowStr := time.Now().Format("2006-01-02")
+	for _, lotteryId := range data.LotteryIdArr {
+		//1、先查看是否有这张奖券
+		userLotteryList := []*entity.UserPrize{}
+		err = orm.Table("user_prize").
+			Where("userId=? and  appId=? and  endDate>=? and  prizeType=0  and  lotteryId=? ", data.UserId, data.AppId, nowStr, lotteryId).
+			Asc("createTime").Find(&userLotteryList)
+		if err != nil {
+			log.Println("查询奖券库存失败:", err)
+			orm.Rollback()
+			return entity.ErrorCode, "查询奖券库存失败"
+		}
+		if (len(userLotteryList) == 0) {
+			log.Println(data.UserId, "用户没有ID为", lotteryId, "的奖券")
+			orm.Rollback()
+			return entity.ErrorCode, "该用户没有此此奖券"
+		}
+		//2、奖券状态改为已使用
+		userLotteryList[0].UseDate = time.Now()
+		userLotteryList[0].PrizeType = 1
+		numb, err := orm.Table("user_prize").ID(userLotteryList[0].Id).Cols("prizeType", "useDate").Update(userLotteryList[0])
+		if err != nil || numb == 0 {
+			log.Println("修改用户奖券失败:", err)
+			orm.Rollback()
+			return entity.ErrorCode, "修改用户奖券失败"
+		}
+		//3、修改卷的使用量
+		lottery := entity.Lottery{}
+		lottery.Id = lotteryId
+		_, err = orm.Exec("UPDATE lottery SET `useNumber` = useNumber+1 WHERE `id` = ?", lotteryId)
+		if err != nil || numb==0  {
+			log.Println("修改奖券使用数量失败:", err)
+			orm.Rollback()
+			return entity.ErrorCode, "修改奖券使用数量失败"
+		}
+
+	}
+
+	orm.Commit()
+	return entity.SuccessCode, "使用奖券成功"
+}
+
+//活动下的奖券
+func (service *ActivityService) ActivityLottery(in *activity.Request) (int64, string,[]entity.LotteryJson) {
+	orm := entity.Engine.NewSession()
+	defer orm.Close()
+	err := orm.Begin()
+	//1、先查找活动下的奖品Id
+	lotteryJsonList := []entity.LotteryJson{}
+	err = orm.Table("activity").Alias("a").
+		Select(" p.limitNumber,UseProductList,( select  count(up.id) FROM user_prize up where  up.lotteryId = l.id AND up.userId ='"+in.UserId+"' ) AS count,p.isLimitNumber,p.validityTimeType,p.validityDates,p.instructions,p.remark,l.id as lotteryId ,l.name ").
+		Join("left", "prize p", " a.prizeId = p.Id").
+		Join("left", "lottery l", " l.prizeId = p.id ").
+			Where("a.id = ?  and a.appId=? ",in.ActivityId,in.AppId).Find(&lotteryJsonList)
+	if err != nil {
+		log.Println("用户单位下的奖券查询失败:", err)
+		orm.Rollback()
+		return entity.ErrorCode, "用户单位下的奖券查询失败", lotteryJsonList
+	}
+	orm.Commit()
+	return entity.SuccessCode, "活动下的奖券", lotteryJsonList
+
+}
+
+//用户下的奖券
+func (service *ActivityService) UserLottery(data *activity.Request, model int) (int64, string, []entity.UserPrizeJson, int64) {
+	orm := entity.Engine.NewSession()
+	defer orm.Close()
+	err := orm.Begin()
+	userLettryList := []entity.UserPrizeJson{}
+	nowStr := time.Now().Format("2006-01-02")
+	count := int64(0)
+	if model == 1 {
+		err = orm.Table("user_prize").Alias("up").Select("up.*,a.useProductList").
+			Join("left", "activity a ", "a.prizeId=up.prizeId").Where("up.userId=? and  up.appId=? and  up.endDate>=?", data.UserId, data.AppId, nowStr).And("up.prizeType=0").Desc("up.createTime").Find(&userLettryList)
+	} else {
+		/*	count,err = orm.Table("user_prize").Alias("up").Select("up.*,a.useProductList").
+			Join("left", "activity a ", "a.prizeId=up.prizeId").Where("up.userId=? and  up.appId=? and  up.endDate>=?", data.UserId, data.AppId, nowStr).Limit(int(data.PageSize), (int(data.Page - 1))*int(data.PageSize)).FindAndCount(&userLettryList)
+		*/
+	}
+	if err != nil {
+		log.Println("用户单位下的奖券查询失败:", err)
+		orm.Rollback()
+		return entity.ErrorCode, "用户单位下的奖券查询失败", userLettryList, count
+	}
+	orm.Commit()
+	return entity.SuccessCode, "", userLettryList, count
+}
+
+//计算几天之后的时间
+func (service *ActivityService) ObtainAppointTimeString(now string, beApartDay int) string {
+	local, _ := time.LoadLocation("Local")
+	t, _ := time.ParseInLocation("2006-01-02", now, local)
+	stopTime := t.AddDate(0, 0, beApartDay)
+	stopTimeStr := stopTime.Format("2006-01-02")
+	return stopTimeStr
+}
+//查询过期的奖券改为已过期
+func (service *ActivityService) UpdateLottery( endDate string) (int64, string) {
+	orm := entity.Engine.NewSession()
+	defer orm.Close()
+	err := orm.Begin()
+	//1、先查找过期的奖券
+	userPrizeList := []entity.UserPrize{}
+	err = orm.Table("user_prize").
+		Where("endDate<? and prizeType=0 ",endDate).Find(&userPrizeList)
+	if err != nil {
+		log.Println("查询过期奖券失败:", err)
+		orm.Rollback()
+		return entity.ErrorCode, "查询过期奖券失败"
+	}
+
+	for _, value := range userPrizeList {
+		value.PrizeType=2
+		numb, err := orm.Table("user_prize").ID(value.Id).Cols("prizeType").Update(value)
+		if err != nil || numb==0  {
+			log.Println("修改奖券使用数量失败:", err)
+			orm.Rollback()
+			return entity.ErrorCode, "修改奖券使用数量失败"
+		}
+	}
+	orm.Commit()
+	return entity.SuccessCode, "过期奖券处理成功"
+}

+ 538 - 0
util/redis.go

@@ -0,0 +1,538 @@
+package util
+
+import (
+	"encoding/json"
+	"errors"
+	"log"
+	"runtime"
+	"strings"
+	"time"
+
+	redigo "github.com/garyburd/redigo/redis"
+)
+
+var RedisPool = make(map[string]*redigo.Pool, 0)
+func InitRedisPool(modules, address string, maxPoolSize, maxPoolIdle, idleTimeOut int) error {
+	var e error
+	if !IsEmpty(modules) && !IsEmpty(address) {
+		a := strings.Split(address, ",")
+		m := strings.Split(modules, ",")
+		if len(a) == len(m) {
+			for i, val := range a {
+				e = InitModuleRedis(val, m[i], maxPoolSize, maxPoolIdle, idleTimeOut)
+			}
+		}
+	}
+	return e
+}
+func IsEmpty(str string) bool {
+	if strings.TrimSpace(str) == "" {
+		return true
+	}
+	return false
+}
+func InitModuleRedis(addr string, module string, maxSize, maxIdle, timeout int) error {
+	var e error
+	RedisPool[module] = &redigo.Pool{
+		MaxActive:   maxSize,
+		MaxIdle:     maxIdle,
+		IdleTimeout: time.Duration(timeout) * time.Second,
+		Dial: func() (redigo.Conn, error) {
+			c, err := redigo.Dial("tcp", addr)
+			if err != nil {
+				log.Printf("redis addr:[%s],module:[%s] dial error:[%v]", addr, err)
+				e = err
+				return nil, err
+			}
+			return c, nil
+		}}
+	return e
+}
+
+/*func InitRedisBySize(addrs string, maxSize, maxIdle, timeout int) {
+	RedisPool = map[string]*redigo.Pool{}
+	addr := strings.Split(addrs, ",")
+	for _, v := range addr {
+		saddr := strings.Split(v, "=")
+		RedisPool[saddr[0]] = &redigo.Pool{MaxActive: maxSize, MaxIdle: maxIdle,
+			IdleTimeout: time.Duration(timeout) * time.Second, Dial: func() (redigo.Conn, error) {
+				c, err := redigo.Dial("tcp", saddr[1])
+				if err != nil {
+					return nil, err
+				}
+				return c, nil
+			}}
+	}
+}*/
+
+//分流redis
+//并存入字符串缓存
+func PutKV(key string, obj interface{}) bool {
+	return Put("other", key, obj, -1)
+}
+func PutCKV(code, key string, obj interface{}) bool {
+	return Put(code, key, obj, -1)
+}
+func Put(code, key string, obj interface{}, timeout int) bool {
+	b := false
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	var err error
+	_obj, _err := json.Marshal(obj)
+	if _err != nil {
+		log.Println("redisutil-SET-序列化出错Error", _err)
+		return b
+	}
+	if timeout < 1 {
+		_, err = conn.Do("SET", key, _obj)
+	} else {
+		_, err = conn.Do("SET", key, _obj, "EX", timeout)
+	}
+	if nil != err {
+		log.Println("redisutil-SETError-put", err)
+	} else {
+		b = true
+	}
+	return b
+}
+
+func BulkPut(code string, timeout int, obj ...interface{}) bool {
+	b := false
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	var err error
+	for _, _tmp := range obj {
+		tmp, ok := _tmp.([]interface{})
+		if ok && len(tmp) == 2 {
+			key, kok := tmp[0].(string)
+			if kok && key != "" {
+				_obj, _err := json.Marshal(tmp[1])
+				if _err != nil {
+					log.Println("redisutil-SET-序列化出错Error", _err)
+					return b
+				}
+				if timeout < 1 {
+					_, err = conn.Do("SET", key, _obj)
+				} else {
+					_, err = conn.Do("SET", key, _obj, "EX", timeout)
+				}
+			}
+		}
+	}
+	if nil != err {
+		b = false
+		log.Println("redisutil-SETError-put", err)
+	} else {
+		b = b && true
+	}
+	return b
+}
+
+//直接存字节流
+func PutBytes(code, key string, data *[]byte, timeout int) (err error) {
+	defer catch()
+
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+
+	if timeout < 1 {
+		_, err = conn.Do("SET", key, *data)
+	} else {
+		_, err = conn.Do("SET", key, *data, "EX", timeout)
+	}
+	if nil != err {
+		log.Println("redisutil-SETError", err)
+	}
+	return
+}
+
+//设置超时时间,单位秒
+func SetExpire(code, key string, expire int) error {
+	defer catch()
+
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	_, err := conn.Do("expire", key, expire)
+	return err
+}
+
+//判断一个key是否存在
+func Exists(code, key string) (bool, error) {
+	defer catch()
+
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	repl, err := conn.Do("exists", key)
+	ret, _ := redigo.Int(repl, err)
+	return ret == 1, err
+}
+
+//获取string
+func GetStr(code, key string) string {
+	res := Get(code, key)
+	str, _ := res.(string)
+	return str
+}
+
+//获取int
+func GetInt(code, key string) int {
+	res := Get(code, key)
+	var result int
+	if str, ok := res.(float64); ok {
+		result = int(str)
+	}
+	return result
+}
+
+//取得字符串,支持变参,2个 (key,code),返回后自己断言
+func Get(code, key string) (result interface{}) {
+	GetInterface(code, key, &result)
+	return
+}
+
+func GetInterface(code, key string, result interface{}) {
+	defer catch()
+
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	ret, err := conn.Do("GET", key)
+	if nil != err {
+		log.Println("redisutil-GetError", err)
+	} else {
+		var ok bool
+		var res []byte
+		if res, ok = ret.([]byte); ok {
+			err = json.Unmarshal(res, result)
+			if err != nil {
+				log.Println("Get ERROR:", err.Error())
+			}
+		}
+	}
+}
+
+//直接返回字节流
+func GetBytes(code, key string) (ret *[]byte, err error) {
+	defer catch()
+
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	var r interface{}
+	r, err = conn.Do("GET", key)
+	if err != nil {
+		log.Println("redisutil-GetBytesError", err)
+	} else {
+		if tmp, ok := r.([]byte); ok {
+			ret = &tmp
+		} else {
+			err = errors.New("redis返回数据格式不对")
+		}
+	}
+	return
+}
+func GetNewBytes(code, key string) (ret *[]byte, err error) {
+	defer catch()
+	redisPool := RedisPool[code]
+	if redisPool == nil {
+		err = errors.New("redis code " + code + " is nil")
+		log.Println("redisutil-GetNewBytesError", err)
+		return
+	}
+	conn := redisPool.Get()
+	defer conn.Close()
+	var r interface{}
+	r, err = conn.Do("GET", key)
+	if err != nil {
+		log.Println("redisutil-GetNewBytesError", err)
+	} else if r != nil {
+		if tmp, ok := r.([]byte); ok {
+			ret = &tmp
+		}
+	}
+	return
+}
+
+//删所有key
+func FlushDB(code string) bool {
+	b := false
+	defer catch()
+
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+
+	var err error
+	_, err = conn.Do("FLUSHDB")
+	if nil != err {
+		log.Println("redisutil-FLUSHDBError", err)
+	} else {
+		b = true
+	}
+	return b
+}
+
+//支持删除多个key
+func Del(code string, key ...interface{}) bool {
+	defer catch()
+	b := false
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+
+	var err error
+	_, err = conn.Do("DEL", key...)
+	if nil != err {
+		log.Println("redisutil-DELError", err)
+	} else {
+		b = true
+	}
+	return b
+}
+
+/**
+func DelKey(key ...interface{}) {
+	defer func() {
+		if r := recover(); r != nil {
+			log.Println("[E]", r)
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
+	for i := 0; i < len(RedisPool); i++ {
+		delByNum(i, key...)
+	}
+
+}
+**/
+
+/**
+func delByNum(n int, key ...interface{}) {
+	defer func() {
+		if r := recover(); r != nil {
+			log.Println("[E]", r)
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
+	i := 0
+	for _, v := range RedisPool {
+		if i == n {
+			conn := v.Get()
+			defer conn.Close()
+			conn.Do("DEL", key...)
+			break
+		}
+		i++
+	}
+}
+
+//根据代码和前辍key删除多个
+func DelByCodePattern(code, key string) {
+	defer catch()
+
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	ret, err := conn.Do("KEYS", key)
+	var result []interface{}
+	if nil != err {
+		log.Println("redisutil-GetError", err)
+	} else {
+		result = ret.([]interface{})
+		for k := 0; k < len(result); k++ {
+			conn.Do("DEL", string(result[k].([]uint8)))
+		}
+	}
+}
+
+/**
+func DelByPattern(key string) {
+	defer func() {
+		if r := recover(); r != nil {
+			log.Println("[E]", r)
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
+	i := 0
+	for _, v := range RedisPool {
+		conn := v.Get()
+		defer conn.Close()
+		ret, err := conn.Do("KEYS", key)
+		var result []interface{}
+		if nil != err {
+			log.Println("redisutil-GetError", err)
+		} else {
+			result = ret.([]interface{})
+			for k := 0; k < len(result); k++ {
+				delByNum(i, string(result[k].([]uint8)))
+			}
+		}
+		i++
+	}
+
+}
+**/
+//自增计数器
+func Incr(code, key string) int64 {
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	ret, err := conn.Do("INCR", key)
+	if nil != err {
+		log.Println("redisutil-INCR-Error", err)
+	} else {
+		if res, ok := ret.(int64); ok {
+			return res
+		} else {
+			return 0
+		}
+	}
+	return 0
+}
+
+//自减
+func Decrby(code, key string, val int) int64 {
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	ret, err := conn.Do("DECRBY", key, val)
+	if nil != err {
+		log.Println("redisutil-DECR-Error", err)
+	} else {
+		if res, ok := ret.(int64); ok {
+			return res
+		} else {
+			return 0
+		}
+	}
+	return 0
+}
+
+//根据正则去取
+func GetKeysByPattern(code, key string) []interface{} {
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	ret, err := conn.Do("KEYS", key)
+	if nil != err {
+		log.Println("redisutil-GetKeysError", err)
+		return nil
+	} else {
+		res, _ := ret.([]interface{})
+		return res
+	}
+}
+
+//批量取多个key
+func Mget(code string, key []string) []interface{} {
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	interfaceKeys := make([]interface{}, len(key))
+	for n, k := range key {
+		interfaceKeys[n] = k
+	}
+	ret, err := conn.Do("MGET", interfaceKeys...)
+	if nil != err {
+		log.Println("redisutil-MgetError", err)
+		return nil
+	} else {
+		res, _ := ret.([]interface{})
+		return res
+	}
+}
+
+//取出并删除Key
+func Pop(code string, key string) (result interface{}) {
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	ret, err := conn.Do("GET", key)
+	if nil != err {
+		log.Println("redisutil-PopError", err)
+	} else {
+		var ok bool
+		var res []byte
+		if res, ok = ret.([]byte); ok {
+			err = json.Unmarshal(res, &result)
+			if err != nil {
+				log.Println("Poperr", err)
+			}
+		}
+		conn.Do("DEL", key)
+	}
+	return
+}
+
+//list操作
+func LPOP(code, list string) (result interface{}) {
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	ret, err := conn.Do("LPOP", list)
+	if nil != err {
+		log.Println("redisutil-LPopError", err)
+	} else {
+		if res, ok := ret.([]byte); ok {
+			err = json.Unmarshal(res, &result)
+			log.Println(err)
+		}
+	}
+	return
+}
+
+func RPUSH(code, list string, val interface{}) bool {
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	_obj, _ := json.Marshal(val)
+	_, err := conn.Do("RPUSH", list, _obj)
+	if nil != err {
+		log.Println("redisutil-RPUSHError", err)
+		return false
+	}
+	return true
+}
+
+func LLEN(code, list string) int64 {
+	defer catch()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	ret, err := conn.Do("LLEN", list)
+	if nil != err {
+		log.Println("redisutil-LLENError", err)
+		return 0
+	}
+	if res, ok := ret.(int64); ok {
+		return res
+	} else {
+		return 0
+	}
+}
+
+func catch() {
+	if r := recover(); r != nil {
+		log.Println(r)
+		for skip := 0; ; skip++ {
+			_, file, line, ok := runtime.Caller(skip)
+			if !ok {
+				break
+			}
+			go log.Printf("%v,%v\n", file, line)
+		}
+	}
+}