Browse Source

fix:bug

dev
Tooooommy 4 years ago
parent
commit
40d34c7339
  1. 33
      controllers/client/invite_envelope.go
  2. 35
      controllers/client/login.go
  3. 14
      controllers/pc/calorie.go
  4. 8
      go.mod
  5. 19
      go.sum
  6. 4
      models/invitation.go

33
controllers/client/invite_envelope.go

@ -22,6 +22,16 @@ func (t *InvitationLetterCtl) Invite() {
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
area := new(models.AreaStore)
exist, err = area.GetByCustomerId(activity.CustomerId, activity.Id)
t.CheckErr(err)
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
customer := new(models.Customer)
exist, err = models.Get(customer, activity.CustomerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
letter := new(models.InvitationLetter)
exist, err = letter.GetByUserIdAndActivityId(uid, activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
@ -38,6 +48,29 @@ func (t *InvitationLetterCtl) Invite() {
letter.UpdatedAt = time.Now()
_, err = models.Add(letter)
t.CheckErr(err)
sign := new(models.SignUp)
exist, err = sign.GetByActivityId(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到活动不存在")
history := new(models.SignHistory)
signExist, err := history.GetByUserId(activityId, activity.ArchId, uid, activity.RehearsalId, area.Id)
t.CheckErr(err)
if customer.IsSpecial == 1 || customer.IsSpecial == 3 {
if signExist {
history = new(models.SignHistory)
history.UserId = uid
history.RehearsalId = activity.RehearsalId
history.ActivityId = activityId
history.SignRuleId = sign.Id
history.AreaId = area.Id
history.ArchId = activity.ArchId
history.Status = 2
_, err = models.Add(history)
t.CheckErr(err)
}
}
t.SUCCESS("success")
}

35
controllers/client/login.go

@ -122,21 +122,6 @@ func (t *UserCtl) WxLogin() {
t.CheckErr(err)
// 校验邀请函是否开启
var requireInvite = true
invitation := new(models.Invitation)
exist, err = invitation.GetInvitationByActivityId(activityId)
t.CheckErr(err)
//t.Assert(exist, code.MSG_INVITE_SETTING_NOT_EXIST, "邀请函设置不存在")
if exist { // 存在邀请函
letter := new(models.InvitationLetter)
exist, err = letter.GetByUserIdAndActivityId(user.Id, activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
if !exist {
requireInvite = false
}
//t.Assert(exist, code.MSG_INVITE_LETTER_NOT_EXIST, "您尚未接受过邀请")
}
sign := new(models.SignUp)
exist, err = sign.GetByActivityId(activityId)
t.CheckErr(err)
@ -160,14 +145,29 @@ func (t *UserCtl) WxLogin() {
t.CheckErr(err)
}
signIn = "已签到"
} else if customer.IsSpecial == 3 {
signIn = "已签到"
} else {
if signExist && history.Status == 2 { // 存在数据
signIn = "已签到"
}
}
//jwtToken, err := jwt.GenJwtToken(define.TYPE_USER, user.Id, customer.Id, customer.Pid, area.Id, activityId)
//t.CheckErr(err)
var requireInvite = false
invitation := new(models.Invitation)
exist, err = invitation.GetInvitationByActivityId(activityId)
t.CheckErr(err)
//t.Assert(exist, code.MSG_INVITE_SETTING_NOT_EXIST, "邀请函设置不存在")
if exist { // 存在邀请函
letter := new(models.InvitationLetter)
exist, err = letter.GetByUserIdAndActivityId(user.Id, activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
if !exist {
requireInvite = true
}
// t.Assert(exist, code.MSG_INVITE_LETTER_NOT_EXIST, "您尚未接受过邀请")
}
user.Token = fmt.Sprintf("%s:%s", define.TYPE_USER, user.Token)
t.SetSession(define.TOKEN, user.Token)
@ -182,6 +182,7 @@ func (t *UserCtl) WxLogin() {
"real_sign_json": sign.RealSignJsonTitle,
"tag": "activity",
"require_invite": requireInvite,
"is_special": customer.IsSpecial,
})
}

14
controllers/pc/calorie.go

@ -101,12 +101,22 @@ func (t *CalorieCtl) Qrcode() {
uid := t.GetAccountId()
calorieId := t.MustGetInt("calorie_id")
customer := models.Customer{}
exist, err := models.Get(&customer, uid)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
area := new(models.AreaStore)
exist, err := area.GetByCustomerId(uid, activityId)
exist, err = area.GetByCustomerId(uid, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常")
qrcode, err := utils.GenH5Qrcode(define.H5Calorie, map[string]interface{}{
var u = define.H5Calorie
if customer.IsSpecial == 3 {
u = "20201120/" + define.H5Calorie
}
qrcode, err := utils.GenH5Qrcode(u, map[string]interface{}{
"activity_id": activityId,
"customer_id": uid,
"area_id": area.Id,

8
go.mod

@ -9,9 +9,9 @@ require (
github.com/CloudyKit/jet v2.1.2+incompatible // indirect
github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee // indirect
github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4 // indirect
github.com/aws/aws-sdk-go v1.35.20 // indirect
github.com/aws/aws-sdk-go v1.35.34 // indirect
github.com/bndr/gotabulate v1.1.2 // indirect
github.com/chanxuehong/wechat v0.0.0-20200409104612-0a1fd76d7a3a
github.com/chanxuehong/wechat v0.0.0-20201110083048-0180211b69fd
github.com/clbanning/mxj v1.8.4 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fatih/structs v1.1.0 // indirect
@ -36,7 +36,7 @@ require (
github.com/smartystreets/goconvey v1.6.4
github.com/syndtr/goleveldb v1.0.0
github.com/tealeg/xlsx v1.0.5 // indirect
github.com/tencentyun/cos-go-sdk-v5 v0.7.10
github.com/tencentyun/cos-go-sdk-v5 v0.7.11
github.com/tencentyun/tls-sig-api-v2-golang v1.0.0
github.com/wailovet/db2struct v0.0.0-20190220022639-a297dc96489a // indirect
github.com/wailovet/overseer v0.0.0-20190412102736-c280479fa09f // indirect
@ -46,7 +46,7 @@ require (
go.uber.org/atomic v1.7.0
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 // indirect
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376

19
go.sum

@ -25,13 +25,23 @@ github.com/aws/aws-sdk-go v1.35.12 h1:qpxQ/DXfgsTNSYn8mUaCgQiJkCjBP8iHKw5ju+wkuc
github.com/aws/aws-sdk-go v1.35.12/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
github.com/aws/aws-sdk-go v1.35.20 h1:Hs7x9Czh+MMPnZLQqHhsuZKeNFA3Vuf7pdy2r5QlVb0=
github.com/aws/aws-sdk-go v1.35.20/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
github.com/aws/aws-sdk-go v1.35.32 h1:PMKbimvySE9aC5789AcNU4VOhIoicZX0EXUajTTuDxc=
github.com/aws/aws-sdk-go v1.35.32/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.35.33 h1:8qPRZqCRok5i7VNN51k/Ky7CuyoXMdSs4mUfKyCqvPw=
github.com/aws/aws-sdk-go v1.35.33/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.35.34 h1:PfsnVvEq7FgsgIOsW8YeParB9ZknW4NXPXcsgqt4srE=
github.com/aws/aws-sdk-go v1.35.34/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
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/chanxuehong/rand v0.0.0-20180830053958-4b3aff17f488/go.mod h1:h13adSJmQ5tsaV9bR72eTp7ePXJ2WIWyK6heLeietxA=
github.com/chanxuehong/rand v0.0.0-20201110082127-2f19a1bdd973 h1:Js/7nHtkpvUW62passc9FOflXyLQDjSoYclkFeDdTEM=
github.com/chanxuehong/rand v0.0.0-20201110082127-2f19a1bdd973/go.mod h1:9+sJ9zvvkXC5sPjPEZM3Jpb9n2Q2VtcrGZly0UHYF5I=
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-20200409104612-0a1fd76d7a3a h1:VIpXUoKyBnQTCKZqJuhVBGG2qpBdTJBdAEDJWpuKvYE=
github.com/chanxuehong/wechat v0.0.0-20200409104612-0a1fd76d7a3a/go.mod h1:u+9Q4tf4vndDvduUeFu+22H63ehFfSLBJlADV8n+RNw=
github.com/chanxuehong/wechat v0.0.0-20201110083048-0180211b69fd h1:TM3wjEWel4U31J72dlhnwCBqPC0+FA0Ejm2NCbn5a5U=
github.com/chanxuehong/wechat v0.0.0-20201110083048-0180211b69fd/go.mod h1:/dvhOIRCjjiZu6NV0QTTiMcc5XwoORbxfDSsRY2IfaM=
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/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
@ -139,6 +149,8 @@ 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.7.10 h1:hJPLdR4RPsnubB3M9qXNBeUbcOJMVANnO/L6Att/PZU=
github.com/tencentyun/cos-go-sdk-v5 v0.7.10/go.mod h1:wQBO5HdAkLjj2q6XQiIfDSP8DXDNrppDRw2Kp/1BODA=
github.com/tencentyun/cos-go-sdk-v5 v0.7.11 h1:G1QB/FPuDuhyfhreW1RWYD7Bb47FOiCDYure6MEftxE=
github.com/tencentyun/cos-go-sdk-v5 v0.7.11/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/wailovet/db2struct v0.0.0-20190220022639-a297dc96489a h1:RndWCoBQ9Ltyj1m46BmGexEv3ZU8hPjV3fGo1xxh07A=
@ -168,6 +180,7 @@ golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/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/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
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=
@ -179,6 +192,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
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 h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -188,14 +202,19 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13 h1:5jaG59Zhd+8ZXe8C+lgiAGqkOaZBruqrWclLkgAww34=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201020230747-6e5568b54d1a h1:e3IU37lwO4aq3uoRKINC7JikojFmE5gO7xhfxs8VC34=
golang.org/x/sys v0.0.0-20201020230747-6e5568b54d1a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 h1:a/mKvvZr9Jcc8oKfcmgzyp7OwF73JPWsQLvH1z2Kxck=
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=

4
models/invitation.go

@ -15,11 +15,11 @@ type Invitation struct {
TimeLimitEnd time.Time `json:"time_limit_end" xorm:"not null default('1970-01-01 08:00:00') comment('限制时间段结束')" description:"限制时间段结束"`
QrImageUrl string `json:"qr_image_url" xorm:"not null comment('二维码图片地址')" description:"二维码图片地址"`
QrDestUrl string `json:"qr_dest_url" xorm:"not null comment('二维码图片指向地址')" description:"二维码图片指向地址"`
IsDelete bool `json:"-" xorm:"default(0)" description:"删除"`
IsDelete int `json:"-" xorm:"default(0)" description:"删除"`
CreatedAt time.Time `json:"-" xorm:"created"`
UpdatedAt time.Time `json:"-" xorm:"updated"`
}
func (i *Invitation) GetInvitationByActivityId(aid int) (bool, error) {
return core.GetXormAuto().Where("activity_id = ? and is_delete = ?", aid, false).Get(i)
return core.GetXormAuto().Where("activity_id = ? and is_delete = ?", aid, 0).Get(i)
}
Loading…
Cancel
Save