Browse Source

fix:bug

master
黄梓健 5 years ago
parent
commit
80fb71e4a1
  1. 5
      controllers/client/auction.go
  2. 2
      controllers/client/live.go
  3. 11
      controllers/client/sign.go
  4. 2
      controllers/pc/auction.go
  5. 7
      go.mod
  6. 12
      go.sum
  7. 3
      libs/jwt/jwt_go.go
  8. 4
      models/live_config.go
  9. 4
      models/live_viewer.go

5
controllers/client/auction.go

@ -7,6 +7,7 @@ import (
auction_service "hudongzhuanjia/services/auction"
ws_send_service "hudongzhuanjia/services/ws_send"
"hudongzhuanjia/utils/code"
"hudongzhuanjia/utils/define"
"time"
)
@ -94,7 +95,7 @@ func (t *AuctionCtl) Auction() {
"num": 0,
"user_id": user.Id,
"status": "进行中",
"model": "加价竞拍",
"model": define.INCR_AUCTION,
},
})
// 成功
@ -135,7 +136,7 @@ func (t *AuctionCtl) Auction() {
"user_id": user.Id,
"status": "进行中",
"num": auction.GoodsNum - int(count) - 1,
"model": "减价竞拍",
"model": define.DECR_AUCTION,
},
})
}

2
controllers/client/live.go

@ -22,7 +22,7 @@ func init() {
}
func QueryOnline() error {
lives, err := models.GetLiveConfigByStatus(2) // 进行中的直播
lives, err := models.GetLiveConfigByStatus(2, 2) // 进行中的直播, 统计峰值
if err != nil {
return err
}

11
controllers/client/sign.go

@ -28,10 +28,15 @@ func (t *SignCtl) CheckSign() {
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "直播活动不存在")
if live.LiveMode == 2 {
var num = 0
if live.LimitType == 1 {
count, err := models.CountLiveViewerByLiveConfigId(live.Id)
if live.LimitType == 1 { // 累计人数->可以重复进入
viewer := new(models.LiveViewer)
exist, err := viewer.ExistByUserId(uid, live.Id)
t.CheckErr(err)
num = int(count)
if !exist {
count, err := models.CountLiveViewerByLiveConfigId(live.Id)
t.CheckErr(err)
num = int(count)
}
} else if live.LimitType == 2 {
num = live.WatchNum + 1
}

2
controllers/pc/auction.go

@ -195,7 +195,7 @@ func (t *AuctionCtl) List() {
t.CheckErr(err)
for i := range auctions {
if auctions[i].AuctionModel == "加价竞拍" {
if auctions[i].AuctionModel == define.INCR_AUCTION {
userIdMap := make(map[int64]struct{}, 0) // 去重操作
for u := range upH {
if _, ok := userIdMap[upH[u].UserId]; ok {

7
go.mod

@ -5,7 +5,7 @@ go 1.12
require (
github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.1
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
github.com/aws/aws-sdk-go v1.32.4 // indirect
github.com/aws/aws-sdk-go v1.32.8 // 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
@ -19,8 +19,9 @@ require (
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/jinzhu/gorm v1.9.13 // indirect
github.com/jinzhu/gorm v1.9.14 // indirect
github.com/kirinlabs/HttpRequest v1.0.5
github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect
github.com/ouxuanserver/osmanthuswine v0.0.0-20190916032555-480efadf4941
github.com/panjf2000/ants v4.0.2+incompatible
github.com/pkg/errors v0.9.1
@ -38,7 +39,7 @@ require (
go.uber.org/atomic v1.6.0
go.uber.org/zap v1.15.0
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a // indirect
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 // indirect
google.golang.org/appengine v1.6.5 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v2 v2.3.0 // indirect

12
go.sum

@ -22,6 +22,7 @@ github.com/CloudyKit/jet v2.1.2+incompatible h1:ybZoYzMBdoijK6I+Ke3vg9GZsmlKo/Zh
github.com/CloudyKit/jet v2.1.2+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4=
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
@ -37,6 +38,7 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
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=
@ -51,6 +53,8 @@ github.com/aws/aws-sdk-go v1.32.3 h1:E3OciOGVlJrv1gQ2T7/Oou+I9nGPB2j978THQjvZBf0
github.com/aws/aws-sdk-go v1.32.3/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.32.4 h1:J2OMvipVB5dPIn+VH7L5rOqM4WoTsBxOqv+I06sjYOM=
github.com/aws/aws-sdk-go v1.32.4/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.32.8 h1:ULxiQqR1eZ+k2/1gqv3GYAjkunlS7ncVU2eL801t08M=
github.com/aws/aws-sdk-go v1.32.8/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=
@ -205,6 +209,8 @@ 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/gorm v1.9.13 h1:fcdacwmUcoyon8XHkQrdPJZ7pnHAYclHZ6iLYER5nX4=
github.com/jinzhu/gorm v1.9.13/go.mod h1:C0zfmO9z9J61PGrs46nfRkfsq0/8ErGTKBxyudR2KvI=
github.com/jinzhu/gorm v1.9.14 h1:Kg3ShyTPcM6nzVo148fRrcMO6MNKuqtOUwnzqMgVniM=
github.com/jinzhu/gorm v1.9.14/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
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=
@ -251,6 +257,7 @@ 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 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
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=
@ -411,6 +418,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
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-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
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=
@ -435,6 +443,7 @@ golang.org/x/net v0.0.0-20191021144547-ec77196f6094 h1:5O4U9trLjNpuhpynaDsqwCk+T
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/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
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=
@ -465,6 +474,7 @@ golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7w
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-20200323222414-85ca7c5b95cd/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/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
@ -473,6 +483,8 @@ golang.org/x/sys v0.0.0-20200610111108-226ff32320da h1:bGb80FudwxpeucJUjPYJXuJ8H
golang.org/x/sys v0.0.0-20200610111108-226ff32320da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 h1:5/PjkGUjvEU5Gl6BxmvKRPpqo2uNMv4rcHBMwzk/st8=
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/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=

3
libs/jwt/jwt_go.go

@ -40,7 +40,8 @@ func GenJwtToken(accountType string, accountId, customerId, customerPid, areaId,
return t.SignedString([]byte(Secret))
}
const Secret = "十步杀一人,千里不留行。"
//const Secret = "十步杀一人,千里不留行。"
const Secret = "osmanthuswine-very-secret"
const Issuer = "osmanthuswine-issuer-ox"
const Subject = "osmanthuswine-subject-ox"
const Audience = "osmanthuswine-audience-ox"

4
models/live_config.go

@ -65,8 +65,8 @@ func (t *LiveConfig) HaveModule(module string) bool {
return exist
}
func GetLiveConfigByStatus(status interface{}) ([]*LiveConfig, error) {
func GetLiveConfigByStatus(status, _type interface{}) ([]*LiveConfig, error) {
lives := make([]*LiveConfig, 0)
err := core.GetXormAuto().Where("is_delete=0 and status=?", status).Find(&lives)
err := core.GetXormAuto().Where("is_delete=0 and status=? and limit_type=?", status, _type).Find(&lives)
return lives, err
}

4
models/live_viewer.go

@ -60,3 +60,7 @@ func GetLiveViewerByLiveConfigIds(ids interface{}) ([]*LiveViewer, error) {
func CountLiveViewerByLiveConfigId(lid interface{}) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and live_config_id=?", lid).Count(&LiveViewer{})
}
func (t *LiveViewer) ExistByUserId(userId, liveId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and live_config_id=?", userId, liveId).Exist(t)
}
Loading…
Cancel
Save