diff --git a/controllers/client/bully_screen.go b/controllers/client/bully_screen.go index dd04b26..e5d8b57 100644 --- a/controllers/client/bully_screen.go +++ b/controllers/client/bully_screen.go @@ -19,7 +19,6 @@ type BullyScreenCtl struct { } //用户霸屏 -// todo: 支付接口 func (t *BullyScreenCtl) PaScreen() { activityId := t.MustGetInt64("activity_id") uid := t.MustGetUID() diff --git a/controllers/client/live.go b/controllers/client/live.go index 61ff763..3a657f0 100644 --- a/controllers/client/live.go +++ b/controllers/client/live.go @@ -106,7 +106,7 @@ func (t *LiveCtl) SendLiveRedPack() { redPack.LiveRedPackInfoId = info.Id redPack.ActivityId = activityId redPack.Receiver = 0 - redPack.Amount = float64(v) / 100 + redPack.Amount = v redPack.CreatedAt = time.Now() redPack.UpdatedAt = time.Now() _, err = redPack.Add() @@ -125,8 +125,13 @@ func (t *LiveCtl) GetRedPack() { liveRedPackInfoId := t.MustGetInt64("live_red_pack_info_id") userId := t.MustGetUID() + user := models.User{} + exist, err := models.GetById(&user, userId) + t.CheckErr(err) + t.Assert(exist, code.MSG_USER_NOT_EXIST, "不存在用户") + redPack := new(models.LiveRedPack) - exist, err := redPack.GetByInfoId(liveRedPackInfoId) + exist, err = redPack.GetByInfoId(liveRedPackInfoId) t.CheckErr(err) if !exist { // 通知其他的人 @@ -141,5 +146,12 @@ func (t *LiveCtl) GetRedPack() { t.ERROR("红包被领完了", code.MSG_LIVE_RED_PACK_NOT_EXIST) return } + ip := strings.Split(t.Request.OriginRequest.RemoteAddr, ":") + res, err := pay_service.Transfer("欧轩互动-红包活动", ip[0], user.Openid, redPack.Amount) + redPack.TransferType = 1 + redPack.TransferNo = res.PartnerTradeNo + _, err = redPack.UpdateStatusById(redPack, 2) + t.CheckErr(err) + t.JSON(redPack) } diff --git a/controllers/client/login.go b/controllers/client/login.go index 390037e..d70ba57 100644 --- a/controllers/client/login.go +++ b/controllers/client/login.go @@ -93,7 +93,7 @@ func (t *UserCtl) WxLogin() { user.Openid = session.OpenId exist, err = user.GetUserByOpenid(user.Openid) t.CheckErr(err) - if exist { + if !exist { _, err = core.GetXormAuto().Insert(user) t.CheckErr(err) } @@ -103,7 +103,7 @@ func (t *UserCtl) WxLogin() { user.Openid = token.OpenId exist, err = user.GetUserByOpenid(user.Openid) t.CheckErr(err) - if exist { + if !exist { _, err = core.GetXormAuto().Insert(user) t.CheckErr(err) } @@ -185,7 +185,7 @@ func (t *UserCtl) Login() { user.Openid = session.OpenId exist, err := user.GetUserByOpenid(user.Openid) t.CheckErr(err) - if exist { + if !exist { _, err = core.GetXormAuto().Insert(user) t.CheckErr(err) } @@ -195,7 +195,7 @@ func (t *UserCtl) Login() { user.Openid = token.OpenId exist, err := user.GetUserByOpenid(user.Openid) t.CheckErr(err) - if exist { + if !exist { _, err = core.GetXormAuto().Insert(user) t.CheckErr(err) } diff --git a/controllers/client/order_entry.go b/controllers/client/order_entry.go index d4254a6..4fff3ac 100644 --- a/controllers/client/order_entry.go +++ b/controllers/client/order_entry.go @@ -116,7 +116,7 @@ func (t *OrderEntryCtl) Order() { _, err = core.GetXormAuto().InsertOne(userPrize) t.CheckErr(err) order.UserPrizeId = userPrize.Id - _, err := core.GetXormAuto().Id(order.Id).Cols("user_prize_id").Update(order) + _, err := core.GetXormAuto().Where("id=?", order.Id).Cols("user_prize_id").Update(order) t.CheckErr(err) } } diff --git a/controllers/client/shake_red_envelope.go b/controllers/client/shake_red_envelope.go index 5681801..467f2b8 100644 --- a/controllers/client/shake_red_envelope.go +++ b/controllers/client/shake_red_envelope.go @@ -3,7 +3,6 @@ package client import ( "fmt" "hudongzhuanjia/controllers" - "hudongzhuanjia/libs/wx" "hudongzhuanjia/models" activity_service "hudongzhuanjia/services/activity" pay_service "hudongzhuanjia/services/pay" @@ -11,6 +10,7 @@ import ( "hudongzhuanjia/utils/code" "hudongzhuanjia/utils/define" "math/rand" + "strings" "time" ) @@ -87,21 +87,22 @@ func (t *ShakeRedEnvelopeCtl) Shake() { record.IsDraw = 0 // 记录红包 ---> 非彩排才能 if activity.RehearsalId == 0 { - res, err := pay_service.SendRedPack("欧轩互动", user.Openid, fmt.Sprintf("感谢您参加%s", activity.Name), - "", rule.Model, "摇得越快抢得越多", int(record.Amount*100), 1, 1) - t.CheckErr(err) - record.MchBillno = res.MchBillno - record.Reason = fmt.Sprintf("%s:%s", res.ErrCode, res.ErrCodeDes) - record.Status = res.ResultCode - record.ReOpenid = user.Openid - if res.ResultCode == wx.CODE_SUCCESS && res.ErrCode == wx.CODE_SUCCESS { - record.IsDraw = 1 + //res, err := pay_service.SendRedPack("欧轩互动", user.Openid, fmt.Sprintf("感谢您参加%s", activity.Name), + // "", rule.Model, "摇得越快抢得越多", int(record.Amount*100), 1, 1) + + ip := strings.Split(t.Request.OriginRequest.RemoteAddr, ":") + res, err := pay_service.Transfer("欧轩互动-红包活动", ip[0], user.Openid, int(record.Amount*100)) + if err != nil { + t.ERROR("您与红包擦肩而过", code.MSG_SHAKERB_NOT_HIT) + return } + + record.TransferType = 1 + record.TransferNo = res.PartnerTradeNo + record.IsDraw = 1 } record.UserId = user.Id - record.UserName = user.Nickname - record.UserPhone = user.Phone record.AreaName = area.Name record.Name = activity.Name row, err := record.UpdateAllColsById(record.Id) diff --git a/controllers/common/wechat_oauth.go b/controllers/common/wechat_oauth.go index e71162e..208fe9b 100644 --- a/controllers/common/wechat_oauth.go +++ b/controllers/common/wechat_oauth.go @@ -66,7 +66,7 @@ type CallbackParam struct { func (t *WeChatOauthCtl) CallbackOrder() { // 搜索支付的order表, 查找到某条记录 logger.Sugar.Infof("%s", t.Request.OriginRequest.RemoteAddr) - t.CheckErr(pay_service.CallbackOrder(t.Request.OriginRequest)) + t.CheckErr(pay_service.NotifyOrder(t.Request.OriginRequest)) param := new(CallbackParam) param.ReturnCode = "SUCCESS" param.ReturnMsg = "OK" @@ -74,15 +74,15 @@ func (t *WeChatOauthCtl) CallbackOrder() { t.XML(xmlRes) } -func (t *WeChatOauthCtl) CallbackRefund() { - logger.Sugar.Infof("%s", t.Request.OriginRequest.RemoteAddr) - t.CheckErr(pay_service.CallbackRefund(t.Request.OriginRequest)) - param := new(CallbackParam) - param.ReturnCode = "SUCCESS" - param.ReturnMsg = "OK" - xmlRes, _ := xml.Marshal(param) - t.XML(xmlRes) -} +//func (t *WeChatOauthCtl) CallbackRefund() { +// logger.Sugar.Infof("%s", t.Request.OriginRequest.RemoteAddr) +// //t.CheckErr(pay_service.NotifyRefund(t.Request.OriginRequest)) +// param := new(CallbackParam) +// param.ReturnCode = "SUCCESS" +// param.ReturnMsg = "OK" +// xmlRes, _ := xml.Marshal(param) +// t.XML(xmlRes) +//} //func (t *WeChatOauthCtl) SendRedPack() { // user := new(models.User) diff --git a/go.mod b/go.mod index 667101f..d437dab 100644 --- a/go.mod +++ b/go.mod @@ -4,35 +4,41 @@ go 1.12 require ( github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.1 - github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee - github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 - github.com/chanxuehong/wechat v0.0.0-20190521093015-fafb751f9916 + github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect + github.com/aws/aws-sdk-go v1.30.7 // indirect + github.com/chanxuehong/wechat v0.0.0-20200409104612-0a1fd76d7a3a github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/elazarl/go-bindata-assetfs v1.0.0 // indirect + github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect - github.com/gorilla/websocket v1.4.0 - github.com/iGoogle-ink/gopay v1.5.1 // indirect + github.com/go-chi/chi v4.1.0+incompatible // indirect + github.com/go-errors/errors v1.0.2 // indirect + github.com/go-redis/redis v6.15.7+incompatible // indirect + github.com/golang/snappy v0.0.1 // indirect + github.com/gorilla/websocket v1.4.2 github.com/iGoogle-ink/gopay/v2 v2.0.5 github.com/importcjj/sensitive v0.0.0-20200106142752-42d1c505be7b - github.com/kirinlabs/HttpRequest v0.1.5 + github.com/jinzhu/gorm v1.9.12 // indirect + github.com/kirinlabs/HttpRequest v1.0.5 github.com/ouxuanserver/osmanthuswine v0.0.0-20190916032555-480efadf4941 github.com/panjf2000/ants v4.0.2+incompatible github.com/pkg/errors v0.9.1 - github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9 + github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086 github.com/smartystreets/goconvey v1.6.4 - github.com/swaggo/http-swagger v0.0.0-20190614090009-c2865af9083e - github.com/swaggo/swag v1.6.3 - github.com/tencentyun/cos-go-sdk-v5 v0.0.0-20190926121715-a33db3b0dede + github.com/swaggo/http-swagger v0.0.0-20190614090009-c2865af9083e // indirect + github.com/swaggo/swag v1.6.3 // indirect + github.com/tealeg/xlsx v1.0.5 // indirect + github.com/tencentyun/cos-go-sdk-v5 v0.7.4 github.com/tencentyun/tls-sig-api-v2-golang v1.0.0 - github.com/xormplus/xorm v0.0.0-20190419084314-284871d688a4 - go.uber.org/atomic v1.4.0 // indirect - go.uber.org/multierr v1.2.0 // indirect - go.uber.org/zap v1.10.0 - golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect + github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be // indirect + github.com/xormplus/core v0.0.0-20200308074340-f3bce19d5f31 // indirect + github.com/xormplus/xorm v0.0.0-20200410045938-f6b4c1cd3b8b + go.uber.org/zap v1.14.1 golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a // indirect - golang.org/x/net v0.0.0-20191021144547-ec77196f6094 // indirect - golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae // indirect - golang.org/x/tools v0.0.0-20191025023517-2077df36852e // indirect + golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 // indirect + google.golang.org/appengine v1.6.5 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 - gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376 + gopkg.in/yaml.v2 v2.2.8 // indirect + xorm.io/core v0.7.3 // indirect + xorm.io/xorm v1.0.1 // indirect ) diff --git a/go.sum b/go.sum index 67cb719..2992494 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU= cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= +gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s= +gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU= github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.1 h1:gnknz1/4RnpL2fZsJzsqsGHgjWDT7k11tGPsFiDQeDk= github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.1/go.mod h1:fkN+AZg31J/y9B4AtylxjzzNYetIxi6cElYu/WBUb7g= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= @@ -14,6 +16,8 @@ github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6 h1:Etfj2lhXyrY github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6/go.mod h1:YzuYAe2hrrwKXkM9kqjbkTLlkbA+/xw2MA46f1+ENxc= github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a h1:3SgJcK9l5uPdBC/X17wanyJAMxM33+4ZhEIV96MIH8U= github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= +github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4slttB4vD+b9btVEnWgL3Q00OBTzVT8B9C0c= +github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= github.com/CloudyKit/jet v2.1.2+incompatible h1:ybZoYzMBdoijK6I+Ke3vg9GZsmlKo/ZhKdNMWz0P26c= github.com/CloudyKit/jet v2.1.2+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= @@ -37,14 +41,20 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/aws/aws-sdk-go v1.19.14 h1:wUq6zI7Y5RfzFIkworUhK71bd/Vld9Otc6bgM/0ws1A= github.com/aws/aws-sdk-go v1.19.14/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.30.7 h1:IaXfqtioP6p9SFAnNfsqdNczbR5UNbYqvcZUSsCAdTY= +github.com/aws/aws-sdk-go v1.30.7/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bndr/gotabulate v1.1.2 h1:yC9izuZEphojb9r+KYL4W9IJKO/ceIO8HDwxMA24U4c= github.com/bndr/gotabulate v1.1.2/go.mod h1:0+8yUgaPTtLRTjf49E8oju7ojpU11YmXyvq1LbPAb3U= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/chanxuehong/rand v0.0.0-20180830053958-4b3aff17f488/go.mod h1:h13adSJmQ5tsaV9bR72eTp7ePXJ2WIWyK6heLeietxA= github.com/chanxuehong/util v0.0.0-20181116100727-caf892acd09c/go.mod h1:oCc2u0egGweOE68RdURGznc2LgbCrdGAAkXOQw2CuNM= +github.com/chanxuehong/util v0.0.0-20200304121633-ca8141845b13 h1:c1vUDbnwvu5d2ucfzXvMzBWzeu5IxPvtESOFPl3CieA= +github.com/chanxuehong/util v0.0.0-20200304121633-ca8141845b13/go.mod h1:XEYt99iTxMqkv+gW85JX/DdUINHUe43Sbe5AtqSaDAQ= github.com/chanxuehong/wechat v0.0.0-20190521093015-fafb751f9916 h1:uD+wIaoJkd0RznEoYFhjA4dHS30iP5D+TLTeYb+5Z4U= github.com/chanxuehong/wechat v0.0.0-20190521093015-fafb751f9916/go.mod h1:BO4IXwEfyapf9pSD8vEInR6JjnmQBxBw7VJKB3NZuiI= +github.com/chanxuehong/wechat v0.0.0-20200409104612-0a1fd76d7a3a h1:VIpXUoKyBnQTCKZqJuhVBGG2qpBdTJBdAEDJWpuKvYE= +github.com/chanxuehong/wechat v0.0.0-20200409104612-0a1fd76d7a3a/go.mod h1:u+9Q4tf4vndDvduUeFu+22H63ehFfSLBJlADV8n+RNw= github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I= github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -57,6 +67,9 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/denisenkom/go-mssqldb v0.0.0-20190401154936-ce35bd87d4b3/go.mod h1:EcO5fNtMZHCMjAvj8LE6T+5bphSdR6LQ75n+m1TtsFI= github.com/denisenkom/go-mssqldb v0.0.0-20190418034912-35416408c946 h1:xn+jBHAqNYs6CnHhJwfWZQspPHMEL+LzUk0vpqWj6eo= github.com/denisenkom/go-mssqldb v0.0.0-20190418034912-35416408c946/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= +github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= +github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM= +github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 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= @@ -69,6 +82,8 @@ github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= 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/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w= github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= @@ -83,8 +98,12 @@ github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7Y github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs= github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/go-chi/chi v4.1.0+incompatible h1:ETj3cggsVIY2Xao5ExCu6YhEh5MD6JTfcBzS37R260w= +github.com/go-chi/chi v4.1.0+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/go-errors/errors v1.0.2 h1:xMxH9j2fNg/L4hLn/4y3M0IUsn0M6Wbu/Uh9QlOfBh4= +github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= @@ -98,8 +117,12 @@ github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi88 github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDAhzyXg+Bs+0Sb4= github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= +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.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= 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/core v0.6.2 h1:EJLcSxf336POJr670wKB55Mah9f93xzvGYzNRgnT8/Y= github.com/go-xorm/core v0.6.2/go.mod h1:bwPIfLdm/FzWgVUH8WPVlr+uJhscvNGFcaZKXsI3n2c= @@ -108,6 +131,8 @@ github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuq github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -115,7 +140,10 @@ github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -123,6 +151,9 @@ github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+u github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= 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.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.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -132,6 +163,8 @@ github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyC github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/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/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/grpc-ecosystem/grpc-gateway v1.6.2/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= @@ -142,6 +175,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/iGoogle-ink/gopay v1.4.8 h1:c98uztaUODTJuV8vsJQUswN6G+TxVqn6cl/DYv5kHxg= github.com/iGoogle-ink/gopay v1.5.1 h1:uAKvQows+O7P8tPsdxXMwe/YqqeEIEswrdVDwF8bFOU= github.com/iGoogle-ink/gopay v1.5.1/go.mod h1:/A7M5Ts6OUEaQD+88stwhPtFV1AxOCL+CAtjreZlGGQ= +github.com/iGoogle-ink/gopay v1.5.7 h1:GDFt6VC0nrwjWA0rtnZL98JK/Hk0w6+UG6Hshml62Vw= github.com/iGoogle-ink/gopay/v2 v2.0.5 h1:jjiHTzkbXEOLC87hs3cAfAGC6+CqWzz/hQ/2x3w1lIU= github.com/iGoogle-ink/gopay/v2 v2.0.5/go.mod h1:plZK1Q8XAw19RkO4MLMYEWWmIhshVK9FtLOrS1ooNwg= github.com/importcjj/sensitive v0.0.0-20200106142752-42d1c505be7b h1:9hudrgWUhyfR4FRMOfL9KB1uYw48DUdHkkgr9ODOw7Y= @@ -153,12 +187,20 @@ github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGk github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jinzhu/gorm v1.9.4 h1:3KDoUjMEfH58nweXdD5Dng222YiwOVUNFShENhehJyQ= github.com/jinzhu/gorm v1.9.4/go.mod h1:7ZYqlk/T0SqZip7ZOIL1aC/sjDj+dJo6sN98WljHFXY= +github.com/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q= +github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs= github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a h1:eeaG9XMUvRBYXJi4pg1ZKM7nxc5AfXfojeLLW7O5J3k= github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.0.0 h1:6WV8LvwPpDhKjo5U9O6b4+xdG/jTXNPwlDme/MTo8Ns= github.com/jinzhu/now v1.0.0/go.mod h1:oHTiXerJ20+SfYcrdlBO7rzZRJWGwSTQ0iUY2jI6Gfc= +github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M= +github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= +github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -169,6 +211,8 @@ github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uia github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/kirinlabs/HttpRequest v0.1.5 h1:BzOb6AmBii232R93birBsf663kt8N9y8N0TCQKoEzhA= github.com/kirinlabs/HttpRequest v0.1.5/go.mod h1:XV38fA4rXZox83tlEV9KIQ7Cdsut319x6NGzVLuRlB8= +github.com/kirinlabs/HttpRequest v1.0.5 h1:1bWj23Tzxm5Zyzm3YURa+ujnBXoXiIbsQq3K9U4SP8s= +github.com/kirinlabs/HttpRequest v1.0.5/go.mod h1:XV38fA4rXZox83tlEV9KIQ7Cdsut319x6NGzVLuRlB8= 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/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -181,6 +225,8 @@ 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.1.0 h1:/5u4a+KGJptBRqGzPvYQL9p0d/tPR4S31+Tnzj9lEO4= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4= +github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -189,6 +235,8 @@ github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 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/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw= +github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -228,12 +276,15 @@ github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R 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/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/satori/go.uuid v0.0.0-20190313024323-b2ce2384e17b h1:PB8A682UQ6pwoFhkszETBsYw3B9Ze9FEA4cf9H9O3f8= github.com/satori/go.uuid v0.0.0-20190313024323-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 h1:pntxY8Ary0t43dCZ5dqY4YTJCObLY1kIXl0uzMv+7DE= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo= +github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086 h1:RYiqpb2ii2Z6J4x0wxK46kvPBbFuZcdhS+CIztmYgZs= +github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= @@ -242,6 +293,9 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= 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/swaggo/files v0.0.0-20190704085106-630677cd5c14 h1:PyYN9JH5jY9j6av01SpfRMb+1DWg/i3MbGOKPxJ2wjM= github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI= @@ -250,11 +304,16 @@ github.com/swaggo/http-swagger v0.0.0-20190614090009-c2865af9083e/go.mod h1:eycb github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y= github.com/swaggo/swag v1.6.3 h1:N+uVPGP4H2hXoss2pt5dctoSUPKKRInr6qcTMOm0usI= github.com/swaggo/swag v1.6.3/go.mod h1:wcc83tB4Mb2aNiL/HP4MFeQdpHUrca+Rp/DRNgWAUio= +github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tealeg/xlsx v1.0.3 h1:BXsDIQYBPq2HgbwUxrsVXIrnO0BDxmsdUfHSfvwfBuQ= github.com/tealeg/xlsx v1.0.3/go.mod h1:uxu5UY2ovkuRPWKQ8Q7JG0JbSivrISjdPzZQKeo74mA= +github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE= +github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM= github.com/tencentyun/cos-go-sdk-v5 v0.0.0-20190926121715-a33db3b0dede h1:4FiecrX2TsfWVkXozpV2JOOI09KvC4jD1JotxY2bSnQ= github.com/tencentyun/cos-go-sdk-v5 v0.0.0-20190926121715-a33db3b0dede/go.mod h1:wk2XFUg6egk4tSDNZtXeKfe2G6690UVyt163PuUxBZk= +github.com/tencentyun/cos-go-sdk-v5 v0.7.4 h1:Hsand7ideMevJKmogyFRTOGy0DxM+oSXHwePgZPI8s4= +github.com/tencentyun/cos-go-sdk-v5 v0.7.4/go.mod h1:wQBO5HdAkLjj2q6XQiIfDSP8DXDNrppDRw2Kp/1BODA= github.com/tencentyun/tls-sig-api-v2-golang v1.0.0 h1:NavMw9XO2iCLv8hTKaJW2kTaGR2SdNljMABbe39yu6Q= github.com/tencentyun/tls-sig-api-v2-golang v1.0.0/go.mod h1:u7WiArmCTXTaQAHJwAOaLgpJ5e2xdY5/cgMEy3ubL60= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= @@ -270,10 +329,16 @@ github.com/wailovet/overseer v0.0.0-20190412102736-c280479fa09f h1:N69pQZKxZw3tU github.com/wailovet/overseer v0.0.0-20190412102736-c280479fa09f/go.mod h1:IE0ZeKrlRAFsChkP21Tg3CKgybYJ7qiHHJAcH/xB4Sg= github.com/xormplus/builder v0.0.0-20181220055446-b12ceebee76f h1:1kd2rgJuSRqTCUSqFkKuaUNsNogLzjPhC9Pr8qnhZDs= github.com/xormplus/builder v0.0.0-20181220055446-b12ceebee76f/go.mod h1:Sz1j9HNsNKOUBDcBcezcwVpydQ/UkFrDo1M2XmuU3mc= +github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be h1:HTSana2sMSKVze3XXYrF89w2tw835Fh+7xX5KPvAkuo= +github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be/go.mod h1:PgBA7NoHtnttVkWModa/qpvIWkX6MpOKgyRCWsSKSB0= github.com/xormplus/core v0.0.0-20190120064039-da7907271e2f h1:RTzjDWlXKTcurd/cWTOuaxTACdWw+gs7HaNCLaK1PJQ= github.com/xormplus/core v0.0.0-20190120064039-da7907271e2f/go.mod h1:V3p6iAR/MaICgU6GJqxGQxspfljTyfOTv4Czz0B5atU= +github.com/xormplus/core v0.0.0-20200308074340-f3bce19d5f31 h1:Xc/TNcIKyvLIp1Y9K+K7a/XQ2wtBLiF6FNmyCjgmb5E= +github.com/xormplus/core v0.0.0-20200308074340-f3bce19d5f31/go.mod h1:V3p6iAR/MaICgU6GJqxGQxspfljTyfOTv4Czz0B5atU= github.com/xormplus/xorm v0.0.0-20190419084314-284871d688a4 h1:7cw+J6ScPpTq9QgHSS4wrGUkrbCE2oVL/dct7YP4d+M= github.com/xormplus/xorm v0.0.0-20190419084314-284871d688a4/go.mod h1:+v6b10b4x5IcQmp1/Cbo9IqaknxVeuhQng+fhya6bdI= +github.com/xormplus/xorm v0.0.0-20200410045938-f6b4c1cd3b8b h1:LkpWvTXxj8r18jZAhia1gHmq/ePBTvCDtFw6ZkYof6s= +github.com/xormplus/xorm v0.0.0-20200410045938-f6b4c1cd3b8b/go.mod h1:+v6b10b4x5IcQmp1/Cbo9IqaknxVeuhQng+fhya6bdI= github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= @@ -283,10 +348,18 @@ go.opencensus.io v0.20.1 h1:pMEjRZ1M4ebWGikflH7nQpV6+Zr88KBMA2XJD3sbijw= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/multierr v1.2.0 h1:6I+W7f5VwC5SV9dNrZ3qXrDB9mD0dyGOi/ZJmYw03T4= go.uber.org/multierr v1.2.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +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.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.14.1 h1:nYDKopTbvAPq/NrUVZwT15y2lpROBiLLyoRTbXOYWOo= +go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/x/build v0.0.0-20190314133821-5284462c4bec/go.mod h1:atTaCNAy0f16Ah5aV1gMSwgiKVHwu/JncqDpuRr7lS4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -295,8 +368,11 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480 h1:O5YqonU5IWby+w98jVUG9h7zlCWCcH4RHyPVReBmhzk= golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd h1:GGJVjV8waZKRHrgwvtH66z9ZGVurTD1MT0n1Bb+q4aM= +golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a h1:gHevYm0pO4QUbwy8Dmdr01R5r1BuKtfYqRqF0h/Cbh0= golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -306,6 +382,9 @@ golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f h1:hX65Cu3JDlGH3uEdK7I99Ii+9kjD6mvnnpfLdEAH0x4= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= 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= @@ -322,11 +401,14 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190419010253-1f3472d942ba h1:h0zCzEL5UW1mERvwTN6AXcc75PpLkY6OcReia6Dq1BM= golang.org/x/net v0.0.0-20190419010253-1f3472d942ba/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190611141213-3f473d35a33a h1:+KkCgOMgnKSgenxTBoiwkMqTiouMIy/3o8RLdmSbGoY= golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191021144547-ec77196f6094 h1:5O4U9trLjNpuhpynaDsqwCk+Tw6seqJz1EbqbnzHrc8= golang.org/x/net v0.0.0-20191021144547-ec77196f6094/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -354,8 +436,11 @@ golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be h1:mI+jhqkn68ybP0ORJqunXn+fq golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae h1:xiXzMMEQdQcric9hXtr1QU98MHunKK7OTtsoU6bYWs4= golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae h1:QoJmnb9uyPCrH8GIg9uRLn4Ta45yhcQtpymCd0AavO8= golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HXxFpW2sdCiP8MJSKLQY= +golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= @@ -367,13 +452,18 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20181219222714-6e267b5cc78e/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-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b h1:/mJ+GKieZA6hFDQGdWZrjj4AXPl5ylY+5HusG80roy0= golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191025023517-2077df36852e h1:ejUPpxsbZzyShOEURCSvFIT0ltnmBW92Vsc3i8QRcw8= golang.org/x/tools v0.0.0-20191025023517-2077df36852e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= @@ -388,6 +478,8 @@ google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c= google.golang.org/appengine v1.5.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/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -404,6 +496,9 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 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/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 h1:eyQQg/uGuZ3ndaBhqteakHpVW+dSOPalilfC9RpM2TA= gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4/go.mod h1:bJkYqV5pg6+Z7MsSu/hSb1zsPT955hBW2QHLE1jm4wA= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= @@ -420,8 +515,18 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/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.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +xorm.io/builder v0.3.7 h1:2pETdKRK+2QG4mLX4oODHEhn5Z8j1m8sXa7jfu+/SZI= +xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= +xorm.io/core v0.7.3 h1:W8ws1PlrnkS1CZU1YWaYLMQcQilwAmQXU0BJDJon+H0= +xorm.io/core v0.7.3/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM= +xorm.io/xorm v1.0.1 h1:/lITxpJtkZauNpdzj+L9CN/3OQxZaABrbergMcJu+Cw= +xorm.io/xorm v1.0.1/go.mod h1:o4vnEsQ5V2F1/WK6w4XTwmiWJeGj82tqjAnHe44wVHY= diff --git a/models/auction_history.go b/models/auction_history.go index 67d0937..9199d1a 100644 --- a/models/auction_history.go +++ b/models/auction_history.go @@ -59,5 +59,5 @@ func GetAuctionHistoriesByAuctionIds(ids []int64, rid int64, orderBy string) ([] func (t *AuctionHistory) SoftDelete() (int64, error) { t.IsDelete = true - return core.GetXormAuto().Id(t.Id).Cols("is_delete").Update(t) + return core.GetXormAuto().ID(t.Id).Cols("is_delete").Update(t) } diff --git a/models/bahe_team_member.go b/models/bahe_team_member.go index bb56dba..985abc3 100644 --- a/models/bahe_team_member.go +++ b/models/bahe_team_member.go @@ -39,5 +39,5 @@ func (t *BaheTeamMember) GetMemberByBaheIdAndUserId(uid, bid, rid int64) (bool, func (t *BaheTeamMember) IncrScoreById(id, score int64) (int64, error) { t.SortTime = time.Now().UnixNano() - return core.GetXormAuto().Id(id).Incr("score", score).Cols("score, sort_time").Update(t) + return core.GetXormAuto().ID(id).Incr("score", score).Cols("score, sort_time").Update(t) } diff --git a/models/base.go b/models/base.go index cdf2d3e..c5154b5 100644 --- a/models/base.go +++ b/models/base.go @@ -2,11 +2,11 @@ package models import ( "fmt" + "github.com/xormplus/xorm" "reflect" "strings" "github.com/ouxuanserver/osmanthuswine/src/core" - "github.com/xormplus/xorm" ) func Condition(condition map[string]interface{}) *xorm.Session { @@ -33,7 +33,7 @@ func Condition(condition map[string]interface{}) *xorm.Session { func Save(condition map[string]interface{}, obj interface{}, filed ...string) error { session := Condition(condition) defer session.Close() - if condition != nil && Exit(session.Clone(), reflect.New(reflect.TypeOf(obj).Elem()).Interface()) { + if condition != nil && Exist(CloneSession(session), reflect.New(reflect.TypeOf(obj).Elem()).Interface()) { //存在则更新 _, err := session.Cols(filed...).Update(obj) return err @@ -44,7 +44,7 @@ func Save(condition map[string]interface{}, obj interface{}, filed ...string) er } } -func Exit(session *xorm.Session, obj interface{}) (result bool) { +func Exist(session *xorm.Session, obj interface{}) (result bool) { defer session.Close() result, _ = session.Exist(obj) return result @@ -54,7 +54,7 @@ func GetTableName(bean interface{}) string { if table, ok := bean.(string); ok { return table } - return core.GetXormAuto().TableInfo(bean).Name + return core.GetXormAuto().TableName(bean) } func AliasTableName(bean interface{}, alias string) string { @@ -65,3 +65,9 @@ func AliasTableName(bean interface{}, alias string) string { func GetById(bean interface{}, id int64) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and id=?", id).Get(bean) } + +// Clone copy all the session's content and return a new session +func CloneSession(session *xorm.Session) *xorm.Session { + var sess = *session + return &sess +} diff --git a/models/bully_screen_history.go b/models/bully_screen_history.go index 702eaec..db32dd7 100644 --- a/models/bully_screen_history.go +++ b/models/bully_screen_history.go @@ -39,5 +39,10 @@ func (t *BullyScreenHistory) GetByUserOrderId(userOrderId int64) (bool, error) { func (t *BullyScreenHistory) UpdateStatus(id int64, status int) (int64, error) { t.Status = status - return core.GetXormAuto().Id(id).Cols("status").Update(t) + return core.GetXormAuto().ID(id).Cols("status").Update(t) +} + +func (t *BullyScreenHistory) UpdateStatusByUserOrderId(userOrderId interface{}, status int) (int64, error) { + t.Status = status + return core.GetXormAuto().Where("is_delete=0 and user_order_id=?", userOrderId).Cols("status").Update(t) } diff --git a/models/customer_order.go b/models/customer_order.go index abc8148..7125f7c 100644 --- a/models/customer_order.go +++ b/models/customer_order.go @@ -35,5 +35,5 @@ func (t *CustomerOrder) TableName() string { func (t *CustomerOrder) SoftDeleteById(id int64) (int64, error) { t.IsDelete = true - return core.GetXormAuto().Id(id).Cols("is_delete").Update(t) + return core.GetXormAuto().Where("id=?", id).Cols("is_delete").Update(t) } diff --git a/models/live_red_pack.go b/models/live_red_pack.go index 079d2ed..8dc3a88 100644 --- a/models/live_red_pack.go +++ b/models/live_red_pack.go @@ -13,11 +13,14 @@ type LiveRedPack struct { CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"` UpdatedAt time.Time `json:"updated_at" xorm:"not null updated default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"` - LiveRedPackInfoId int64 `json:"live_red_pack_info_id" xorm:"not null default 0 comment('红包信息id') INT(11)"` - ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"` - Receiver int64 `json:"receiver" xorm:"not null default 0 comment('[0未领取/非0领取用户id]') INT(11)"` - Amount float64 `json:"amount" xorm:"not null default 0.0 comment('红包金额') DECIMAL(18,2)"` - Version int `json:"version" xorm:"not null version comment('乐观锁') INT(11)"` + LiveRedPackInfoId int64 `json:"live_red_pack_info_id" xorm:"not null default 0 comment('红包信息id') INT(11)"` + ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"` + Receiver int64 `json:"receiver" xorm:"not null default 0 comment('[0未领取/非0领取用户id]') INT(11)"` + Amount int `json:"amount" xorm:"not null default 0 comment('红包金额, 分') INT(18)"` + TransferType int `json:"transfer_type" xorm:"not null default 0 comment('转账方式[0微信红包1微信零钱]')"` + TransferNo string `json:"transfer_no" xorm:"not null default '' comment('转账账号') VARCHAR(128) "` + Status int `json:"status" xorm:"not null default 0 comment('0 未被领取 1 已被领取 2 已发送')"` + Version int `json:"version" xorm:"not null version comment('乐观锁') INT(11)"` } func (t LiveRedPack) TableName() string { @@ -34,5 +37,11 @@ func (t *LiveRedPack) GetByInfoId(infoId int64) (bool, error) { func (t *LiveRedPack) Receive(userId int64) (int64, error) { t.Receiver = userId - return core.GetXormAuto().Where("id=?", t.Id).Cols("user_id").Update(t) + t.Status = 1 + return core.GetXormAuto().Where("id=?", t.Id).Cols("user_id, status").Update(t) +} + +func (t *LiveRedPack) UpdateStatusById(id interface{}, status int) (int64, error) { + t.Status = status + return core.GetXormAuto().Where("id=?", t.Id).Cols("status").Update(t) } diff --git a/models/new_auction_activity.go b/models/new_auction_activity.go index a998db2..9175798 100644 --- a/models/new_auction_activity.go +++ b/models/new_auction_activity.go @@ -42,11 +42,11 @@ func (t *NewAuctionActivity) Alias(name string) string { } func (t *NewAuctionActivity) IncrMoneyById(id int64, money float64) (int64, error) { - return core.GetXormAuto().Id(id).Incr("money", money).Update(t) + return core.GetXormAuto().Where("id=?", id).Incr("money", money).Update(t) } func (t *NewAuctionActivity) DecrMoneyById(id int64, money float64) (int64, error) { - return core.GetXormAuto().Id(id).Decr("money", money).Decr("goods_num", 1).Update(t) + return core.GetXormAuto().Where("id=?", id).Decr("money", money).Decr("goods_num", 1).Update(t) } func (t *NewAuctionActivity) UpdateToStatusByAid(aid int64, before, after string) (int64, error) { diff --git a/models/reward_history.go b/models/reward_history.go index 10c54b9..9fc8d3e 100644 --- a/models/reward_history.go +++ b/models/reward_history.go @@ -37,5 +37,10 @@ func (t *RewardHistory) GetByUserOrderId(userOrderId int64) (bool, error) { func (t *RewardHistory) UpdateStatus(id int64, status int) (int64, error) { t.Status = status - return core.GetXormAuto().Id(id).Cols("status").Update(t) + return core.GetXormAuto().Where("id=?", id).Cols("status").Update(t) +} + +func (t *RewardHistory) UpdateStatusByUserOrderId(userOrderId interface{}, status int) (int64, error) { + t.Status = status + return core.GetXormAuto().Where("is_delete=0 and user_order_id=?", userOrderId).Cols("status").Update(t) } diff --git a/models/shake_red_envelope_record.go b/models/shake_red_envelope_record.go index 45ba539..88d689f 100644 --- a/models/shake_red_envelope_record.go +++ b/models/shake_red_envelope_record.go @@ -16,17 +16,13 @@ type ShakeRedEnvelopeRecord struct { UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"` IsValid bool `json:"is_valid" xorm:"-"` Name string `json:"name" xorm:"not null default '' comment('红包名字') VARCHAR(255)"` - UserName string `json:"user_name" xorm:"not null default '' comment('用户名字') VARCHAR(255)"` - UserPhone string `json:"user_phone" xorm:"not null default '' comment('用户电话') VARCHAR(18)"` Amount float64 `json:"amount" xorm:"not null default '0' comment('金额') VARCHAR(18)"` AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"` AreaName string `json:"area_name" xorm:"not null default '' comment('地区名字') VARCHAR(18)"` IsDraw int `json:"is_draw" xorm:"not null default(0) comment('-1未被摇中,0已被摇中,1已被提现')"` - Reason string `json:"reason" xorm:"not null default '' comment('失败原因') VARCHAR(32)"` - MchBillno string `json:"mch_billno" xorm:"not null default 0 comment('')"` - ReOpenid string `json:"re_openid" xorm:"not null default '' comment('接收红包用户openid') VARCHAR(32)"` + TransferType int `json:"transfer_type" xorm:"not null default 0 comment('0微信红包 1 微信转账') TINYINT(1)"` + TransferNo string `json:"transfer_no" xorm:"not null default '' comment('转账账单no') VARCHAR(128)"` Status string `json:"status" xorm:"not null default '' comment('红包状态') VARCHAR(16)"` - RefundTime string `json:"refund_time" xorm:"not null default '' comment('红包退款时间') VARCHAR(32)"` Version int `json:"version" xorm:"not null version comment('乐观锁') INT(11)"` IsDelete bool `json:"-" xorm:"default(0)" description:"是否删除"` CreatedAt time.Time `json:"-" xorm:"created" description:"创建时间"` diff --git a/models/user_order.go b/models/user_order.go index 02d8b46..09931d6 100644 --- a/models/user_order.go +++ b/models/user_order.go @@ -24,7 +24,7 @@ type UserOrder struct { TimeExpire string `json:"time_expire" xorm:"not null default('') comment('交易结束时间') VARCHAR(14)"` TimeEnd string `json:"time_end" xorm:"not null default('') comment('交易结算时间') VARCHAR(14)"` PrepayId string `json:"prepay_id" xorm:"not null default('') comment('预支付交易会话标识') VARCHAR(64)"` - Status int `json:"status" xorm:"not null default(0) comment('-1订单关闭0尚未支付1支付成功') TINYINT(1)"` + Status int `json:"status" xorm:"not null default(0) comment('-1订单关闭0尚未支付/支付中1支付成功2已撤销3转入退款4支付失败') TINYINT(1)"` IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('是否删除') TINYINT(1)" description:"是否删除"` CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME" description:"创建时间"` UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME" description:"更新时间"` @@ -34,6 +34,33 @@ func (t *UserOrder) TableName() string { return UserOrderTableName } +func (t *UserOrder) AddUserOrder() (int64, error) { + return core.GetXormAuto().InsertOne(t) +} + func (t *UserOrder) GetByOutTradeNo(no string) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", no).Get(t) } + +func (t *UserOrder) UpdateStatusById(id interface{}) (int64, error) { + return core.GetXormAuto().Where("id=? and is_delete=0", id). + Cols("time_end, transaction_id, status").Update(t) +} + +func (t *UserOrder) UpdateStatusByOutTradeNo(outTradeNo interface{}, status int) (int64, error) { + t.Status = status + return core.GetXormAuto().Where("out_trade_no=? and is_delete=0", outTradeNo). + Cols("time_end, transaction_id, status").Update(t) +} + +func GetUserOrdersByStatusAndUserId(userId interface{}, status int) ([]*UserOrder, error) { + orders := make([]*UserOrder, 0) + err := core.GetXormAuto().Where("is_delete = 0 and status = ? and user_id = ?", status, userId).Find(&orders) + return orders, err +} + +func GetUserOrdersByStatusAndActivityId(activityId interface{}, status int) ([]*UserOrder, error) { + orders := make([]*UserOrder, 0) + err := core.GetXormAuto().Where("is_delete = 0 and status = ? and activity_id = ?", status, activityId).Find(&orders) + return orders, err +} diff --git a/models/user_prize.go b/models/user_prize.go index 04ec442..abc2a40 100644 --- a/models/user_prize.go +++ b/models/user_prize.go @@ -27,5 +27,5 @@ func (t *UserPrize) TableName() string { func (t *UserPrize) SoftDeleteById(id int64) (int64, error) { t.IsDelete = true - return core.GetXormAuto().Id(id).Cols("is_delete").Update(t) + return core.GetXormAuto().Where("id=?", id).Cols("is_delete").Update(t) } diff --git a/models/user_red_pack.go b/models/user_red_pack.go index 8844274..c2c4c31 100644 --- a/models/user_red_pack.go +++ b/models/user_red_pack.go @@ -1,6 +1,9 @@ package models -import "time" +import ( + "github.com/ouxuanserver/osmanthuswine/src/core" + "time" +) const UserRedPackTableName = TableNamePrefix + "user_red_pack" @@ -20,9 +23,6 @@ type UserRedPack struct { SendTime string `json:"send_time" xorm:"not null default '' comment('红包发送时间') VARCHAR(32)"` RefundTime string `json:"refund_time" xorm:"not null default '' comment('红包退款时间') VARCHAR(32)"` RefundAmount string `json:"refund_amount" xorm:"not null default '' comment('红包退款金额') VARCHAR(32)"` - ResultCode string `json:"result_code" xorm:"not null default '' comment('业务结果') VARCHAR(16)"` - ErrCode string `json:"err_code" xorm:"not null default '' comment('错误代码') VARCHAR(32)"` - ErrCodeDes string `json:"err_code_des" xorm:"not null default '' comment('错误代码描述') VARCHAR(128)"` UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"` ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"` IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('是否删除') TINYINT(1)" description:"是否删除"` @@ -33,3 +33,7 @@ type UserRedPack struct { func (t *UserRedPack) TableName() string { return UserRedPackTableName } + +func (t *UserRedPack) AddRedPack() (int64, error) { + return core.GetXormAuto().InsertOne(t) +} diff --git a/models/user_refund.go b/models/user_refund.go index b481638..d0983b1 100644 --- a/models/user_refund.go +++ b/models/user_refund.go @@ -21,7 +21,7 @@ type UserRefund struct { ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"` RefundStatus string `json:"refund_status" xorm:"not null default '' comment('微信退款状态') VARCHAR(16)"` Status int `json:"status" xorm:"not null default 0 comment('0未查询,1已查询') TINYINT(1)"` - SuccessTime string `json:"success_time" xorm:"not null default '' comment('退款成功时间') VARCHAR(20)"` + SuccessTime time.Time `json:"success_time" xorm:"not null default '' comment('退款成功时间') VARCHAR(20)"` RefundRecvAccount string `json:"refund_recv_account" xorm:"not null default '' comment('入账账号') VARCHAR(64)"` RefundAccount string `json:"refund_account" xorm:"not null default '' comment('入账账号') VARCHAR(64)"` IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('是否删除') TINYINT(1)" description:"是否删除"` @@ -36,3 +36,18 @@ func (t *UserRefund) TableName() string { func (t *UserRefund) GetByOutRefundNo(no string) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and out_refund_no=?", no).Get(t) } + +func (t *UserRefund) GetByOutTradeNo(no string) (bool, error) { + return core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", no).Get(t) +} + +func (t *UserRefund) AddUserRefund() (int64, error) { + return core.GetXormAuto().InsertOne(t) +} + +func (t *UserRefund) QueryUpdate() (int64, error) { + return core.GetXormAuto().Where("id=?", t.Id). + Cols("refund_account, refund_recv_account, " + + "status, refund_status, success_time, refund_id, transaction_id").Update(t) + +} diff --git a/services/pay/client.go b/services/pay/client.go index bc402c9..7ccc595 100644 --- a/services/pay/client.go +++ b/services/pay/client.go @@ -1,26 +1,15 @@ package pay_service import ( - "crypto/md5" "crypto/tls" "crypto/x509" - "encoding/hex" - "encoding/xml" - "errors" "fmt" - "github.com/iGoogle-ink/gopay/v2" - "hudongzhuanjia/libs/wx" - "strings" + "github.com/chanxuehong/wechat/mch/core" + "net/http" ) -func ClientExtend(bm gopay.BodyMap, url string) ([]byte, error) { - - //bm.Set("appid", wx.Appid) - //bm.Set("mch_id", wx.Mchid) - - h := md5.New() - h.Write([]byte(bm.EncodeWeChatSignParams(wx.ApiKey))) - bm.Set("sign", strings.ToUpper(hex.EncodeToString(h.Sum(nil)))) +// 配置 client +func Client() (*core.Client, error) { certP12, err := Asset("cacert/apiclient_cert.p12") if err != nil { @@ -45,28 +34,15 @@ func ClientExtend(bm gopay.BodyMap, url string) ([]byte, error) { tlsConfig := &tls.Config{ Certificates: []tls.Certificate{certificate}, RootCAs: pkcsPool, - InsecureSkipVerify: true} - - httpClient := gopay.NewHttpClient() - httpClient.SetTLSConfig(tlsConfig) - - bs, err := xml.Marshal(bm) - if err != nil { - return nil, err + InsecureSkipVerify: true, } - res, bs, errs := httpClient.Type(gopay.TypeXML).Post(url).SendString(string(bs)).EndBytes() - - if len(errs) > 0 { - return nil, fmt.Errorf("http client return error: %v", errs[0]) + httpClient := &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: tlsConfig, + DisableKeepAlives: true, + }, } - if res.StatusCode != 200 { - return nil, fmt.Errorf("HTTP Request Error, StatusCode = %d", res.StatusCode) - } - - if strings.Contains(string(bs), "HTML") || strings.Contains(string(bs), "html") { - return nil, errors.New(string(bs)) - } - return bs, nil + return core.NewClient(Appid, Mchid, ApiKey, httpClient), nil } diff --git a/services/pay/const.go b/services/pay/const.go new file mode 100644 index 0000000..bbdac5d --- /dev/null +++ b/services/pay/const.go @@ -0,0 +1,84 @@ +package pay_service + +import ( + "fmt" + "hudongzhuanjia/utils/define" +) + +var ( + WxCertPath = `./cacert/apiclient_cert.pem` + WxKeyPath = `./cacert/apiclient_key.pem` + WxCaPath = `./cacert/rootca.pem` + Appid = "wx7b0bcf476552c5e9" + Secret = "f6aabdd40ea25272f4442603a7dc8028" + Mchid = `1394404502` + ApiKey = `2c82c64ceec6ba89ffc9f593c671a12f` + mainHost = `https://api.mch.weixin.qq.com` + backHost = `https://api2.mch.weixin.qq.com` +) + +var ( + NotifyURL = fmt.Sprintf("%s/wechat/callback", define.HOST) // 微信回调通知 + UnifiedOrderURL = fmt.Sprintf("%s/pay/unifiedorder", mainHost) // 统一下单url + QueryOrderURL = fmt.Sprintf("%s/pay/orderquery", mainHost) // 微信查询订单 + CloseOrderURL = fmt.Sprintf("%s/pay/closeorder", mainHost) // 微信关闭订单 + RefundURL = fmt.Sprintf("%s/secapi/pay/refund", mainHost) // 微信退款 + RefundQueryURL = fmt.Sprintf("%s/pay/refundquery", mainHost) // 微信查询退款 + DownloadBillURL = fmt.Sprintf("%s/pay/downloadbill", mainHost) // 微信下载账单 + DownloadFundFlowURL = fmt.Sprintf("%s/pay/downloadfundflow", mainHost) + TransfersURL = fmt.Sprintf("%s/mmpaymkttransfers/promotion/transfers", mainHost) + SendRedPackURL = fmt.Sprintf("%s/mmpaymkttransfers/sendredpack", mainHost) + QueryRedPackURL = fmt.Sprintf("%s/mmpaymkttransfers/gethbinfo", mainHost) +) + +const ( + CODE_SUCCESS = "SUCCESS" // 成功 + CODE_FAIL = "FAIL" // 失败 + CODE_NOTPAY = "NOTPAY" // 未支付 + CODE_CHANGE = "CHANGE" // 退款异常 + CODE_REFUNDCLOSE = "REFUNDCLOSE" // 退款关闭 + CODE_ERROR = "ERROR" // 业务错误 + CODE_INVALID_REQUEST = "INVALID_REQUEST" // 无效请求 + CODE_NOAUTH = "NOAUTH" // 异常IP请求不予受理 + CODE_NOTENOUGH = "NOTENOUGH" // 余额不足 + CODE_ORDERPAID = "ORDERPAID" // 订单已支付 + CODE_ORDERCLOSED = "ORDERCLOSED" // 订单已关闭 + CODE_SYSTEMERROR = "SYSTEMERROR" // 系统错误 + CODE_APPID_NOT_EXIST = "APPID_NOT_EXIST" // APPID不存在 + CODE_MCHID_NOT_EXIST = "MCHID_NOT_EXIST" // MCHID不存在 + CODE_APPID_MCHID_NOT_MATCH = "APPID_MCHID_NOT_MATCH" // APPID MCHID 不匹配 + CODE_LACK_PARAMS = "LACK_PARAMS" // 缺少参数 + CODE_OUT_TRADE_NO_USED = "OUT_TRADE_NO_USED" // 商户订单号重复 + CODE_SIGNERROR = "SIGNERROR" // 签名错误 + CODE_XML_FORMAT_ERROR = "XML_FORMAT_ERROR" // xml格式错误 + CODE_REQUIRE_POST_METHOD = "REQUIRE_POST_METHOD" // 请使用post请求方法 + CODE_POST_DATA_EMPTY = "POST_DATA_EMPTY" // post数据为空 + CODE_NOT_UTF8 = "NOT_UTF8" // 编码错误 + CODE_ORDERNOTEXIST = "ORDERNOTEXIST" // 交易订单号不存在 + CODE_BIZERR_NEED_RETRY = "BIZERR_NEED_RETRY" // 退款业务流程错误,需要商户触发重试来解决 + CODE_TRADE_OVERDUE = "TRADE_OVERDUE" // 订单已经超过退款期限 + CODE_USER_ACCOUNT_ABNORMAL = "USER_ACCOUNT_ABNORMAL" // 退款请求失败用户帐号注销 + CODE_INVALID_REQ_TOO_MUCH = "INVALID_REQ_TOO_MUCH" // 无效请求过多 + CODE_INVALID_TRANSACTIONID = "INVALID_TRANSACTIONID" // 无效transaction_id + CODE_PARAM_ERROR = "PARAM_ERROR" // 参数错误 + CODE_FREQUENCY_LIMITED = "FREQUENCY_LIMITED" // 请求频率限制 + CODE_TRADE_SUCCESS = "SUCCESS" // 交易成功 + CODE_TRADE_REFUND = "REFUND" // 转入退款 + CODE_TRADE_NOTPAY = "NOTPAY" // 尚未退款 + CODE_TRADE_CLOSED = "CLOSED" // 已关闭 + CODE_TRADE_REVOKED = "REVOKED" // 已撤销 + CODE_TRADE_USERPAYING = "USERPAYING" // 用户支付中 + CODE_TRADE_PAYERROR = "PAYERROR" // 支付失败 +) + +type CommonReturn struct { + ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` + ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` +} + +type CommonResult struct { + ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` + ResultMsg string `xml:"result_msg,omitempty" json:"result_msg,omitempty"` + ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` + ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` +} diff --git a/services/pay/order.go b/services/pay/order.go index 11e14d9..9227aa1 100644 --- a/services/pay/order.go +++ b/services/pay/order.go @@ -1,14 +1,13 @@ package pay_service import ( - "errors" + "encoding/xml" "fmt" - "github.com/iGoogle-ink/gopay/v2" - "github.com/iGoogle-ink/gopay/v2/wechat" - "github.com/ouxuanserver/osmanthuswine/src/core" - "hudongzhuanjia/libs/wx" + core2 "github.com/chanxuehong/wechat/mch/core" + "github.com/chanxuehong/wechat/mch/pay" "hudongzhuanjia/logger" "hudongzhuanjia/models" + "hudongzhuanjia/utils" "net/http" "strconv" "time" @@ -17,52 +16,32 @@ import ( const CallbackOrderUrl = "https://api.ouxuanhudong.com/PcClient/common/WeChatOauthCtl/callbackOrder" func Order(content, ip, openid string, fee, goodType int, userId, activityId int64) (map[string]interface{}, error) { - client := wechat.NewClient(wx.Appid, wx.Mchid, wx.ApiKey, true) + client, err := Client() + if err != nil { + return nil, err + } - //设置国家 - client.SetCountry(wechat.China) now := time.Now() - - outTradeNo := gopay.GetRandomString(32) - nonceStr := gopay.GetRandomString(32) timeStart := now.Format("20060101150405") timeExpire := now.Add(2 * time.Hour).Format("20060101150405") - - //初始化参数Map - body := make(gopay.BodyMap) - body.Set("nonce_str", nonceStr) - body.Set("body", content) - body.Set("out_trade_no", outTradeNo) - body.Set("total_fee", fee) - body.Set("spbill_create_ip", ip) - body.Set("notify_url", CallbackOrderUrl) - body.Set("trade_type", wechat.TradeType_JsApi) - body.Set("device_info", "WEB") - body.Set("sign_type", wechat.SignType_MD5) - body.Set("openid", openid) - body.Set("time_start", timeStart) - //body.Set("time_expire", timeExpire) - - //请求支付下单,成功后得到结果 - res, err := client.UnifiedOrder(body) + outTradeNo := utils.RandomStr(32) + nonceStr := utils.RandomStr(32) + resp, err := pay.UnifiedOrder2(client, &pay.UnifiedOrderRequest{ + Body: content, + OutTradeNo: outTradeNo, + TotalFee: int64(fee), + SpbillCreateIP: ip, + NotifyURL: CallbackOrderUrl, + TradeType: "JSAPI", + DeviceInfo: "WEB", + NonceStr: nonceStr, + SignType: core2.SignType_MD5, + TimeStart: now, + OpenId: openid, + }) if err != nil { return nil, err } - //ok, err := wechat.VerifySign(wx.ApiKey, wechat.SignType_MD5, res) - //if err != nil { - // return nil, err - //} - //if !ok { - // return nil, errors.New("签名验证失败") - //} - - if res.ReturnCode != wx.CODE_SUCCESS { - return nil, fmt.Errorf("network error, retrun_code: %v and return_msg: %v", res.ReturnCode, res.ReturnMsg) - } - - if res.ResultCode != wx.CODE_SUCCESS { - return nil, fmt.Errorf("trade error, err_code: %v and err_code_des: %v", res.ErrCode, res.ErrCodeDes) - } userOrder := new(models.UserOrder) userOrder.DeviceInfo = "WEB" @@ -76,51 +55,79 @@ func Order(content, ip, openid string, fee, goodType int, userId, activityId int userOrder.TimeStart = timeStart userOrder.TimeExpire = timeExpire userOrder.TotalFee = fee - userOrder.TradeType = wechat.TradeType_JsApi - userOrder.PrepayId = res.PrepayId + userOrder.TradeType = "JSAPI" + userOrder.PrepayId = resp.PrepayId userOrder.Status = 0 userOrder.IsDelete = false userOrder.CreatedAt = time.Now() userOrder.UpdatedAt = time.Now() - if _, err := core.GetXormAuto().InsertOne(userOrder); err != nil { + if _, err = userOrder.AddUserOrder(); err != nil { return nil, err } timestamp := strconv.FormatInt(time.Now().Unix(), 10) //获取H5支付需要的paySign - pac := "prepay_id=" + res.PrepayId - paySign := wechat.GetH5PaySign(wx.Appid, res.NonceStr, pac, wechat.SignType_MD5, timestamp, wx.ApiKey) + pac := "prepay_id=" + resp.PrepayId + paySign := core2.JsapiSign(client.AppId(), nonceStr, pac, core2.SignType_MD5, timestamp, ApiKey) return map[string]interface{}{ - "appid": wx.Appid, + "appid": Appid, "timestamp": timestamp, - "nonce_str": res.NonceStr, + "nonce_str": nonceStr, "package": pac, - "sign_type": wechat.SignType_MD5, + "sign_type": core2.SignType_MD5, "pay_sign": paySign, "out_trade_no": outTradeNo, "user_order_id": userOrder.Id, }, nil } -func CallbackOrder(req *http.Request) error { - res, err := wechat.ParseNotifyResult(req) - if err != nil { - logger.Sugar.Error("解析微信毁掉结果失败") - return err +// Notify +type NotifyRequest struct { + ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` + ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` + ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` + ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` + ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` + Appid string `xml:"appid,omitempty" json:"appid,omitempty"` + MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` + DeviceInfo string `xml:"device_info,omitempty" json:"device_info,omitempty"` + NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` + Sign string `xml:"sign,omitempty" json:"sign,omitempty"` + SignType string `xml:"sign_type,omitempty" json:"sign_type,omitempty"` + Openid string `xml:"openid,omitempty" json:"openid,omitempty"` + IsSubscribe string `xml:"is_subscribe,omitempty" json:"is_subscribe,omitempty"` + TradeType string `xml:"trade_type,omitempty" json:"trade_type,omitempty"` + BankType string `xml:"bank_type,omitempty" json:"bank_type,omitempty"` + TotalFee int `xml:"total_fee,omitempty" json:"total_fee,omitempty"` + SettlementTotalFee int `xml:"settlement_total_fee,omitempty" json:"settlement_total_fee,omitempty"` + FeeType string `xml:"fee_type,omitempty" json:"fee_type,omitempty"` + CashFee int `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"` + CashFeeType string `xml:"cash_fee_type,omitempty" json:"cash_fee_type,omitempty"` + CouponFee int `xml:"coupon_fee,omitempty" json:"coupon_fee,omitempty"` + CouponCount int `xml:"coupon_count,omitempty" json:"coupon_count,omitempty"` + CouponType0 string `xml:"coupon_type_0,omitempty" json:"coupon_type_0,omitempty"` + CouponType1 string `xml:"coupon_type_1,omitempty" json:"coupon_type_1,omitempty"` + CouponId0 string `xml:"coupon_id_0,omitempty" json:"coupon_id_0,omitempty"` + CouponId1 string `xml:"coupon_id_1,omitempty" json:"coupon_id_1,omitempty"` + CouponFee0 int `xml:"coupon_fee_0,omitempty" json:"coupon_fee_0,omitempty"` + CouponFee1 int `xml:"coupon_fee_1,omitempty" json:"coupon_fee_1,omitempty"` + TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` + OutTradeNo string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"` + Attach string `xml:"attach,omitempty" json:"attach,omitempty"` + TimeEnd string `xml:"time_end,omitempty" json:"time_end,omitempty"` +} + +func NotifyOrder(req *http.Request) error { + res := new(NotifyRequest) + if err := xml.NewDecoder(req.Body).Decode(res); err != nil { + return fmt.Errorf("xml.NewDecoder.Decode:%w", err) } - //ok, err := wechat.VerifySign(wx.ApiKey, wechat.SignType_MD5, res) - //if err != nil { - // return err - //} - //if !ok { - // return errors.New("sign verify failed") - //} - if res.ReturnCode != wx.CODE_SUCCESS { + if res.ReturnCode != CODE_SUCCESS { return fmt.Errorf("network error, retrun_code: %v and return_msg: %v", res.ReturnCode, res.ReturnMsg) } - if res.ResultCode != wx.CODE_SUCCESS { + if res.ResultCode != CODE_SUCCESS { return fmt.Errorf("trade error, err_code: %v and err_code_des: %v", res.ErrCode, res.ErrCodeDes) } @@ -135,56 +142,65 @@ func CallbackOrder(req *http.Request) error { userOrder.TimeEnd = res.TimeEnd userOrder.TransactionId = res.TransactionId userOrder.Status = 1 - if _, err := core.GetXormAuto().Id(userOrder.Id).Cols("time_end, transaction_id, status").Update(userOrder); err != nil { + if _, err = userOrder.UpdateStatusById(userOrder.Id); err != nil { return err } // 设置一下 if userOrder.GoodType == 1 { // 霸屏 - history := new(models.BullyScreenHistory) - history.Status = 0 - _, err := core.GetXormAuto().Where("is_delete=0 and user_order_id=?", userOrder.Id).Cols("status").Update(history) - return err + _, err = new(models.BullyScreenHistory).UpdateStatusByUserOrderId(userOrder.Id, 0) + if err != nil { + return err + } } else if userOrder.GoodType == 2 { - history := new(models.RewardHistory) - history.Status = 0 - _, err := core.GetXormAuto().Where("is_delete=0 and user_order_id=?", userOrder.Id).Cols("status").Update(history) - return err + _, err = new(models.RewardHistory).UpdateStatusByUserOrderId(userOrder.Id, 0) + if err != nil { + return err + } } - logger.Sugar.Infof("%+v", res) return nil } -func Query(outTradeNo string) (*wechat.QueryOrderResponse, error) { - client := wechat.NewClient(wx.Appid, wx.Mchid, wx.ApiKey, true) - - client.SetCountry(wechat.China) - - body := make(gopay.BodyMap) - body.Set("out_trade_no", outTradeNo) - body.Set("nonce_str", gopay.GetRandomString(32)) - body.Set("sign_type", wechat.SignType_MD5) - +func Query(outTradeNo string) (*models.UserOrder, error) { + client, err := Client() + if err != nil { + return nil, err + } // 请求订单查询,成功后得到结果 - res, err := client.QueryOrder(body) + res, err := pay.OrderQuery2(client, &pay.OrderQueryRequest{ + OutTradeNo: outTradeNo, + NonceStr: utils.RandomStr(32), + SignType: core2.SignType_MD5, + }) if err != nil { - logger.Sugar.Errorf("wechat query order error, %s", err) return nil, err } - if res.TradeState == wx.CODE_SUCCESS { // 付款成功 - userOrder := new(models.UserOrder) + userOrder := new(models.UserOrder) + userOrder.TransactionId = res.TransactionId + userOrder.TimeEnd = core2.FormatTime(res.TimeEnd) + switch res.TradeState { + case CODE_TRADE_CLOSED: + userOrder.Status = -1 + case CODE_TRADE_SUCCESS: userOrder.Status = 1 - if _, err := core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", outTradeNo). - Cols("status").Update(userOrder); err != nil { - return nil, err - } + case CODE_TRADE_REVOKED: + userOrder.Status = 2 + case CODE_TRADE_REFUND: + userOrder.Status = 3 + case CODE_TRADE_PAYERROR: + userOrder.Status = 4 + default: + userOrder.Status = 0 + } + if _, err = userOrder.UpdateStatusByOutTradeNo(outTradeNo, userOrder.Status); err != nil { + return nil, err } - return res, nil + return userOrder, nil } func BatchQueryByUserId(userId int64) error { - orders := make([]*models.UserOrder, 0) - if err := core.GetXormAuto().Where("is_delete = 0 and status = 0 and user_id = ?", userId).Find(&orders); err != nil { + orders, err := models.GetUserOrdersByStatusAndUserId(userId, 0) + if err != nil { return err } @@ -192,9 +208,9 @@ func BatchQueryByUserId(userId int64) error { } func BatchQueryByActivityId(activityId int64) error { - orders := make([]*models.UserOrder, 0) - if err := core.GetXormAuto().Where("is_delete = 0 and status = 0 and activity_id = ?", activityId).Find(&orders); err != nil { - return err + orders, err := models.GetUserOrdersByStatusAndActivityId(activityId, 0) + if err != nil { + return nil } return batchQuery(orders) @@ -202,80 +218,59 @@ func BatchQueryByActivityId(activityId int64) error { func batchQuery(orders []*models.UserOrder) error { for _, order := range orders { - res, err := Query(order.OutTradeNo) + userOrder, err := Query(order.OutTradeNo) if err != nil { return err } - if res.TradeState == wx.CODE_SUCCESS { // 付款成功 - order.Status = 1 // 已支付 - order.TransactionId = res.TransactionId - - if _, err := core.GetXormAuto().ID(order.Id).Cols("status, transaction_id").Update(order); err != nil { - return err - } + order.Status = userOrder.Status + order.TransactionId = userOrder.TransactionId + order.TimeEnd = userOrder.TimeEnd + if order.Status == 1 { // 付款成功 if order.GoodType == 1 { - history := new(models.BullyScreenHistory) - exist, err := history.GetByUserOrderId(order.Id) + _, err = new(models.BullyScreenHistory).UpdateStatusByUserOrderId(order.Id, 0) if err != nil { return err } - if !exist { - return errors.New("BullyScreenHistory not exist") - } - if history.Status == -1 { - if _, err := history.UpdateStatus(history.Id, 0); err != nil { - return err - } - } - } else if order.GoodType == 2 { - history := new(models.RewardHistory) - exist, err := history.GetByUserOrderId(order.Id) + _, err = new(models.RewardHistory).UpdateStatusByUserOrderId(order.Id, 0) if err != nil { return err } - if !exist { - return errors.New("RewardHistory not exist") - } - if history.Status == 0 { - break - } - if history.Status == -1 { - if _, err := history.UpdateStatus(history.Id, 0); err != nil { - return err - } - } } else { logger.Sugar.Info("支付测试") } } else if order.TimeExpire <= time.Now().Format("20060101150405") { - Close(order.OutTradeNo) + err = Close(order.OutTradeNo) + if err != nil { + return err + } + order.Status = -1 // 关闭支付 - order.TransactionId = res.TransactionId - if _, err := core.GetXormAuto().ID(order.Id).Cols("status, transaction_id").Update(order); err != nil { + _, err = order.UpdateStatusById(order.Id) + if err != nil { return err } + } } return nil } -func Close(outTradeNo string) (*wechat.CloseOrderResponse, error) { - client := wechat.NewClient(wx.Appid, wx.Mchid, wx.ApiKey, true) - - // 初始化参数结构体 - body := make(gopay.BodyMap) - body.Set("out_trade_no", outTradeNo) - body.Set("nonce_str", gopay.GetRandomString(32)) - body.Set("sign_type", wechat.SignType_MD5) - +func Close(outTradeNo string) error { + //client := wechat.NewClient(Appid, Mchid, ApiKey, true) + client, err := Client() + if err != nil { + return err + } + err = pay.CloseOrder2(client, &pay.CloseOrderRequest{ + OutTradeNo: outTradeNo, + NonceStr: utils.RandomStr(32), + SignType: core2.SignType_MD5, + }) // 请求关闭订单,成功后得到结果 - wxRsp, err := client.CloseOrder(body) if err != nil { - fmt.Println("Error:", err) - return nil, err + return err } - fmt.Println("wxRsp:", *wxRsp) - return wxRsp, nil + return nil } diff --git a/services/pay/pay_test.go b/services/pay/pay_test.go new file mode 100644 index 0000000..a3cc5a7 --- /dev/null +++ b/services/pay/pay_test.go @@ -0,0 +1,12 @@ +package pay_service + +import ( + "fmt" + "testing" +) + +func TestTransfer(t *testing.T) { + res, err := Transfer("欧轩互动-转账测试", "127.0.0.1", "o9XM41s_NN8Y0QK6_MbM-aYMV3TE", 1) + fmt.Println(err) + fmt.Printf("%+v\n", res) +} diff --git a/services/pay/refund.go b/services/pay/refund.go index d33d372..f5410ae 100644 --- a/services/pay/refund.go +++ b/services/pay/refund.go @@ -1,81 +1,38 @@ package pay_service import ( - "encoding/xml" "errors" - "fmt" - "github.com/iGoogle-ink/gopay/v2" - "github.com/iGoogle-ink/gopay/v2/wechat" + core2 "github.com/chanxuehong/wechat/mch/core" + "github.com/chanxuehong/wechat/mch/pay" "github.com/ouxuanserver/osmanthuswine/src/core" - "hudongzhuanjia/libs/wx" "hudongzhuanjia/models" - "net/http" + "hudongzhuanjia/utils" "time" ) const CALLBACK_REFUND_URL = "https://api.ouxuanhudong.com/PcClient/common/WeChatOauthCtl/callbackRefund" -func RefundExtend(bm gopay.BodyMap) (*wechat.RefundResponse, error) { - - err := bm.CheckEmptyError("nonce_str", "out_refund_no", "total_fee", "refund_fee") - if err != nil { - return nil, err - } - if bm.Get("out_trade_no") == gopay.NULL && bm.Get("transaction_id") == gopay.NULL { - return nil, errors.New("out_trade_no and transaction_id are not allowed to be null at the same time") - } - - bs, err := ClientExtend(bm, wx.RefundURL) - if err != nil { - return nil, err - } - wxRsp := new(wechat.RefundResponse) - if err = xml.Unmarshal(bs, wxRsp); err != nil { - return nil, fmt.Errorf("xml.Unmarshal(%s):%s", string(bs), err) - } - return wxRsp, nil -} - -func Refund(reason, outTradeNo, openId string, goodType, totalFee, refundFee int, userId, activityId int64) (*wechat.RefundResponse, error) { - //client := wechat.NewClient(wx.Appid, wx.Mchid, wx.ApiKey, true) - - outRefundNo := gopay.GetRandomString(64) - // 初始化参数结构体 - body := make(gopay.BodyMap) - body.Set("out_trade_no", outTradeNo) - body.Set("nonce_str", gopay.GetRandomString(32)) - body.Set("sign_type", wechat.SignType_MD5) - body.Set("out_refund_no", outRefundNo) - body.Set("total_fee", totalFee) - body.Set("refund_fee", refundFee) - body.Set("notify_url", CALLBACK_REFUND_URL) - body.Set("refund_desc", reason) - body.Set("refund_fee_type", "CNY") - body.Set("appid", wx.Appid) - body.Set("mch_id", wx.Mchid) - - res, err := RefundExtend(body) +func Refund(reason, outTradeNo, openId string, goodType, totalFee, refundFee int, userId, activityId int64) (*pay.RefundResponse, error) { + client, err := Client() + + outRefundNo := utils.RandomStr(64) + nonceStr := utils.RandomStr(32) + res, err := pay.Refund2(client, &pay.RefundRequest{ + TransactionId: "", + OutTradeNo: outTradeNo, + OutRefundNo: outRefundNo, + TotalFee: int64(totalFee), + RefundFee: int64(refundFee), + NonceStr: nonceStr, + SignType: core2.SignType_MD5, + RefundFeeType: "CNY", + RefundDesc: reason, + }) + // if err != nil { return nil, err } - //ok, err := wechat.VerifySign(wx.ApiKey, wechat.SignType_MD5, res) - //if err != nil { - // return nil, err - //} - // - //if !ok { - // return nil, errors.New("签名验证失败") - //} - - if res.ReturnCode != wx.CODE_SUCCESS { - return nil, fmt.Errorf("network error, retrun_code: %v and return_msg: %v", res.ReturnCode, res.ReturnMsg) - } - - if res.ResultCode != wx.CODE_SUCCESS { - return nil, fmt.Errorf("trade error, err_code: %v and err_code_des: %v", res.ErrCode, res.ErrCodeDes) - } - refund := new(models.UserRefund) refund.OutTradeNo = outTradeNo refund.Status = 0 @@ -89,88 +46,47 @@ func Refund(reason, outTradeNo, openId string, goodType, totalFee, refundFee int refund.IsDelete = false refund.CreatedAt = time.Now() refund.UpdatedAt = time.Now() - if _, err := core.GetXormAuto().InsertOne(refund); err != nil { + _, err = refund.AddUserRefund() + if err != nil { return nil, err } return res, err } -func CallbackRefund(req *http.Request) error { - res, err := wechat.ParseRefundNotifyResult(req) - if err != nil { - return err - } - //ok, err := wechat.VerifySign(wx.ApiKey, wechat.SignType_MD5, res) - //if err != nil { - // return err - //} - //if !ok { - // return errors.New("sign verify failed") - //} - if res.ReturnCode != wx.CODE_SUCCESS { - return fmt.Errorf("network error, retrun_code: %v and return_msg: %v", res.ReturnCode, res.ReturnMsg) - } - - info, err := wechat.DecryptRefundNotifyReqInfo(res.ReqInfo, wx.ApiKey) - if err != nil { - return err - } - - userRefund := new(models.UserRefund) - exist, err := userRefund.GetByOutRefundNo(info.OutRefundNo) +func QueryRefund(outTradeNo string) (*pay.RefundQueryResponse, error) { + refund := new(models.UserRefund) + exist, err := refund.GetByOutTradeNo(outTradeNo) if err != nil { - return err + return nil, err } if !exist { - return errors.New("user refund not exist") - } - - userRefund.Status = 1 - userRefund.RefundStatus = info.RefundStatus - userRefund.TransactionId = info.TransactionId - userRefund.OutTradeNo = info.OutTradeNo - userRefund.RefundRecvAccount = info.RefundRecvAccout - userRefund.RefundAccount = info.RefundAccount - userRefund.SuccessTime = info.SuccessTime - if _, err := core.GetXormAuto().Id(userRefund.Id).Update(userRefund); err != nil { - return err + return nil, errors.New("不存在改笔退款") } - return nil -} - -func QueryRefund(outTradeNo string) (*wechat.QueryRefundResponse, error) { - client := wechat.NewClient(wx.Appid, wx.Mchid, wx.ApiKey, true) - - // 初始化参数结构体 - body := make(gopay.BodyMap) - body.Set("out_trade_no", outTradeNo) - body.Set("nonce_str", gopay.GetRandomString(32)) - body.Set("sign_type", wechat.SignType_MD5) + client, err := Client() + res, err := pay.RefundQuery2(client, &pay.RefundQueryRequest{ + OutTradeNo: outTradeNo, + NonceStr: utils.RandomStr(32), + SignType: core2.SignType_MD5, + }) //请求申请退款 - res, err := client.QueryRefund(body) if err != nil { return nil, err } - ok, err := wechat.VerifySign(wx.ApiKey, wechat.SignType_MD5, res) + refund.RefundAccount = res.RefundList[0].RefundAccount + refund.RefundRecvAccount = res.RefundList[0].RefundRecvAccout + refund.RefundStatus = res.RefundList[0].RefundStatus + refund.Status = 1 + refund.SuccessTime = res.RefundList[0].RefundSuccessTime + refund.WxRefundId = res.RefundList[0].RefundId + refund.TransactionId = res.TransactionId + _, err = refund.QueryUpdate() if err != nil { return nil, err } - if !ok { - return nil, errors.New("签名验证失败") - } - if res.ReturnCode != wx.CODE_SUCCESS { - return nil, fmt.Errorf("network error, retrun_code: %v and return_msg: %v", res.ReturnCode, res.ReturnMsg) - } - - if res.ResultCode != wx.CODE_SUCCESS { - return nil, fmt.Errorf("trade error, err_code: %v and err_code_des: %v", res.ErrCode, res.ErrCodeDes) - } - - fmt.Println("wxRsp:", *res) return res, nil } @@ -197,21 +113,10 @@ func BatchQueryRefundByActivityId(activityId int64) error { func batchQueryRefund(refunds []*models.UserRefund) error { for _, refund := range refunds { - res, err := QueryRefund(refund.OutTradeNo) + _, err := QueryRefund(refund.OutTradeNo) if err != nil { return err } - refund.RefundAccount = res.RefundAccount0 - refund.RefundRecvAccount = res.RefundRecvAccout0 - refund.RefundStatus = res.RefundStatus0 - refund.Status = 1 - refund.SuccessTime = res.RefundSuccessTime0 - refund.WxRefundId = res.RefundId0 - refund.TransactionId = res.TransactionId - if _, err = core.GetXormAuto().Id(refund.Id).Cols("refund_account, refund_recv_account, " + - "status, refund_status, success_time, wx_refund_id, transaction_id").Update(refund); err != nil { - return err - } } return nil } diff --git a/services/pay/transfer.go b/services/pay/transfer.go index deafab4..f9b0a10 100644 --- a/services/pay/transfer.go +++ b/services/pay/transfer.go @@ -1,148 +1,129 @@ package pay_service import ( - "encoding/xml" "fmt" - "github.com/iGoogle-ink/gopay/v2" - "github.com/iGoogle-ink/gopay/v2/wechat" - "github.com/ouxuanserver/osmanthuswine/src/core" - "hudongzhuanjia/libs/wx" - "hudongzhuanjia/logger" + "github.com/chanxuehong/wechat/mch/mmpaymkttransfers" + "github.com/chanxuehong/wechat/mch/mmpaymkttransfers/promotion" "hudongzhuanjia/models" + "hudongzhuanjia/utils" "time" ) -func TransferExtend(bm gopay.BodyMap) (*wechat.TransfersResponse, error) { - err := bm.CheckEmptyError("nonce_str", "partner_trade_no", "openid", "check_name", "amount", "desc", "spbill_create_ip") - if err != nil { - return nil, err - } - - bs, err := ClientExtend(bm, wx.TransfersURL) - if err != nil { - return nil, err - } - - wxRsp := new(wechat.TransfersResponse) - if err = xml.Unmarshal(bs, wxRsp); err != nil { - return nil, fmt.Errorf("xml.Unmarshal(%s):%s", string(bs), err) - } - return wxRsp, nil +// 企业向微信用户个人付款(不支持沙箱环境) +type TransferResponse struct { + DeviceInfo string `xml:"device_info,omitempty" json:"device_info,omitempty"` + NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` + PartnerTradeNo string `xml:"partner_trade_no,omitempty" json:"partner_trade_no,omitempty"` + PaymentNo string `xml:"payment_no,omitempty" json:"payment_no,omitempty"` + PaymentTime string `xml:"payment_time,omitempty" json:"payment_time,omitempty"` } -// 企业向微信用户个人付款(不支持沙箱环境) -func Transfer(desc, ip, openId string, amount int) (*wechat.TransfersResponse, error) { +func Transfer(desc, ip, openId string, amount int) (*TransferResponse, error) { - nonceStr := gopay.GetRandomString(32) - partnerTradeNo := gopay.GetRandomString(32) + nonceStr := utils.RandomStr(32) + partnerTradeNo := utils.RandomStr(32) // 初始化参数结构体 - body := make(gopay.BodyMap) - body.Set("nonce_str", nonceStr) - body.Set("partner_trade_no", partnerTradeNo) - body.Set("openid", openId) - body.Set("check_name", "NO_CHECK") // NO_CHECK:不校验真实姓名 , FORCE_CHECK:强校验真实姓名 - body.Set("amount", amount) // 企业付款金额,单位为分 - body.Set("desc", desc) // 企业付款备注,必填。注意:备注中的敏感词会被转成字符* - body.Set("spbill_create_ip", ip) - body.Set("mchid", wx.Mchid) - body.Set("mch_appid", wx.Appid) - res, err := TransferExtend(body) + body := make(map[string]string) + body["nonce_str"] = nonceStr + body["partner_trade_no"] = partnerTradeNo + body["openid"] = openId + body["check_name"] = "NO_CHECK" // NO_CHECK:不校验真实姓名 , FORCE_CHECK:强校验真实姓名 + body["amount"] = fmt.Sprintf("%d", amount) // 企业付款金额,单位为分 + body["desc"] = desc // 企业付款备注,必填。注意:备注中的敏感词会被转成字符* + body["spbill_create_ip"] = ip + body["mchid"] = Mchid + body["mch_appid"] = Appid + + client, err := Client() + m, err := promotion.Transfers(client, body) if err != nil { - fmt.Println("Error:", err) return nil, err } - fmt.Println("wxRsp:", *res) - // 保存到user_transfer + res := &TransferResponse{ + DeviceInfo: m["device_info"], + NonceStr: m["nonce_str"], + PartnerTradeNo: m["partner_trade_no"], + PaymentNo: m["payment_no"], + PaymentTime: m["payment_time"], + } return res, nil } -func QueryTransfer(partnerTradeNo string) { - body := make(gopay.BodyMap) - body.Set("nonce_str", gopay.GetRandomString(32)) - body.Set("partner_trade_no", partnerTradeNo) - // todo: 查询, 遇到查询失败,需要原订单号重新请求 +type RedPackResult struct { + MchBillno string `xml:"mch_billno,omitempty" json:"mch_billno,omitempty"` + ReOpenid string `xml:"re_openid,omitempty" json:"re_openid,omitempty"` + TotalAmount int `xml:"total_amount,omitempty" json:"total_amount,omitempty"` + SendListid string `xml:"send_listid,omitempty" json:"send_listid,omitempty"` } // 发送红包 -func SendRedPack(sendName, openId, wishing, ip, actName, remark string, totalAmount, totalNum, scene int) (*wx.RedPackResult, error) { - mchBillNo := gopay.GetRandomString(28) - - body := make(gopay.BodyMap) - body.Set("nonce_str", gopay.GetRandomString(32)) - body.Set("mch_billno", mchBillNo) - body.Set("send_name", sendName) - body.Set("re_openid", openId) - body.Set("total_amount", totalAmount) - body.Set("total_num", totalNum) - body.Set("wishing", wishing) - body.Set("client_ip", ip) - body.Set("act_name", actName) - body.Set("remark", remark) - body.Set("scene_id", fmt.Sprintf("PRODUCT_%d", scene)) - body.Set("wxappid", wx.Appid) - body.Set("mch_id", wx.Mchid) - - bs, err := ClientExtend(body, wx.SendRedPackURL) +func SendRedPack(sendName, openId, wishing, ip, actName, remark string, totalAmount, totalNum, scene int) (*RedPackResult, error) { + mchBillNo := utils.RandomStr(28) + nonceStr := utils.RandomStr(32) + + body := make(map[string]string, 0) + body["nonce_str"] = nonceStr + body["mch_billno"] = mchBillNo + body["send_name"] = sendName + body["re_openid"] = openId + body["total_amount"] = fmt.Sprintf("%d", totalAmount) + body["total_num"] = fmt.Sprintf("%d", totalNum) + body["wishing"] = wishing + body["client_ip"] = ip + body["act_name"] = actName + body["remark"] = remark + body["scene_id"] = fmt.Sprintf("PRODUCT_%d", scene) + body["ppid"] = Appid + body["mch_id"] = Mchid + + client, err := Client() + m, err := mmpaymkttransfers.SendRedPack(client, body) if err != nil { return nil, err } - res := new(wx.RedPackResult) - if err = xml.Unmarshal(bs, res); err != nil { - logger.Sugar.Errorf("xml.Unmarshal(%s): %s", string(bs), err) - return nil, fmt.Errorf("xml.Unmarshal(%s):%s", string(bs), err) - } - if res.ReturnCode != wx.CODE_SUCCESS { - err = fmt.Errorf("network error, retrun_code: %v and return_msg: %v", res.ReturnCode, res.ReturnMsg) - logger.Sugar.Error(err) - return nil, err + res := &RedPackResult{ + MchBillno: m["mch_billno"], + ReOpenid: m["re_openid"], + TotalAmount: totalAmount, + SendListid: m["send_listid"], } userRedPack := new(models.UserRedPack) - userRedPack.ErrCode = res.ErrCode - userRedPack.ErrCodeDes = res.ErrCodeDes userRedPack.MchBillno = mchBillNo userRedPack.ReOpenid = openId userRedPack.SceneId = scene userRedPack.SendListid = res.SendListid userRedPack.TotalAmount = totalAmount userRedPack.TotalNum = totalNum - userRedPack.ResultCode = res.ResultCode userRedPack.IsDelete = false userRedPack.UpdatedAt = time.Now() userRedPack.CreatedAt = time.Now() - if _, err := core.GetXormAuto().InsertOne(userRedPack); err != nil { - logger.Sugar.Errorf("insert into user red pack error: %s", err) + _, err = userRedPack.AddRedPack() + if err != nil { return nil, err } return res, nil } -// todo: 小心谨慎查询 -func QueryRedPack(mchBillno string) (*wx.QueryRedPackResult, error) { - body := make(gopay.BodyMap) - body.Set("nonce_str", gopay.GetRandomString(32)) - body.Set("mch_billno", mchBillno) - body.Set("bill_type", "MCHT") - body.Set("appid", wx.Appid) - body.Set("mch_id", wx.Mchid) - bs, err := ClientExtend(body, wx.QueryRedPackURL) - if err != nil { - logger.Sugar.Errorf("client extend request wx error: %s", err) - return nil, err - } - res := new(wx.QueryRedPackResult) - if err = xml.Unmarshal(bs, res); err != nil { - logger.Sugar.Errorf("xml.Unmarshal(%s):%s", string(bs), err) - return nil, fmt.Errorf("xml.Unmarshal(%s):%s", string(bs), err) - } - if res.ReturnCode != wx.CODE_SUCCESS { - err = fmt.Errorf("network error, retrun_code: %v and return_msg: %v", res.ReturnCode, res.ReturnMsg) - logger.Sugar.Error(err) - return nil, err - } - - return res, nil +type QueryRedPackResult struct { + CommonReturn + CommonResult + MchBillno string `xml:"mch_billno,omitempty" json:"mch_billno,omitempty"` + Mchid string `xml:"mchid,omitempty" json:"mchid,omitempty"` + DetailId string `xml:"detail_id,omitempty" json:"detail_id,omitempty"` + Status string `xml:"status,omitempty" json:"status,omitempty"` + SendType string `xml:"send_type,omitempty" json:"send_type,omitempty"` + HbType string `xml:"hb_type,omitempty" json:"hb_type,omitempty"` + TotalNum int `xml:"total_num,omitempty" json:"total_num,omitempty"` + TotalAmount int `xml:"total_amount,omitempty" json:"total_amount,omitempty"` + Reason string `xml:"reason,omitempty" json:"reason,omitempty"` + SendTime string `xml:"send_time,omitempty" json:"send_time,omitempty"` + RefundTime string `xml:"refund_time,omitempty" json:"refund_time,omitempty"` + RefundAmount int `xml:"refund_amount,omitempty" json:"refund_amount,omitempty"` + Wishing string `xml:"wishing,omitempty" json:"wishing,omitempty"` + Remark string `xml:"remark,omitempty" json:"remark,omitempty"` + ActName string `xml:"act_name,omitempty" json:"act_name,omitempty"` } diff --git a/test/pay_test.go b/test/pay_test.go new file mode 100644 index 0000000..b7bb96c --- /dev/null +++ b/test/pay_test.go @@ -0,0 +1,13 @@ +package test + +import ( + "fmt" + pay_service "hudongzhuanjia/services/pay" + "testing" +) + +func TestTransfer(t *testing.T) { + res, err := pay_service.Transfer("欧轩互动-转账测试", "127.0.0.1", "o9XM41s_NN8Y0QK6_MbM-aYMV3TE", 30) + fmt.Println(err) + fmt.Printf("%+v\n", res) +} diff --git a/utils/code/code.go b/utils/code/code.go index 430d3bf..e3656f7 100644 --- a/utils/code/code.go +++ b/utils/code/code.go @@ -43,6 +43,7 @@ const ( MSG_SHAKERB_NOT_EXIST = 8000 // 摇红包不存在 MSG_SHAKERB_RECORD_NOT_EXIST = 8001 // 摇红包不存在 MSG_SHAKERB_RULE_NOT_EXIST = 8002 // 红包规则不存在 + MSG_SHAKERB_NOT_HIT = 8003 // 红包没有命中 MSG_AUCTION_NOT_EXIST = 9000 // 竞拍不存在 MSG_CALORIE_NOT_EXIST = 10001 // 卡路里轮次不存在 )