Browse Source

fix:bug

dev
Tooooommy 4 years ago
parent
commit
38175756af
  1. 38
      controllers/client/login.go
  2. 22
      controllers/client/order_entry.go
  3. 6
      controllers/client/shake_red_envelope.go
  4. 4
      go.mod
  5. 4
      go.sum
  6. 8
      main.go
  7. 18
      models/customer_goods.go
  8. 14
      models/customer_order_sub.go
  9. 15
      models/order_entry_person.go

38
controllers/client/login.go

@ -29,12 +29,11 @@ func (t *UserCtl) EntryLogin() {
activityId := t.MustGetInt("activity_id") // 需要获取
entry := new(models.OrderEntryPerson)
exist, err := entry.Auth(account, password, activityId)
err := entry.Auth(account, password, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在")
activity := new(models.Activity)
exist, err = activity.Get(activity, activityId)
exist, err := activity.Get(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
@ -123,16 +122,20 @@ func (t *UserCtl) WxLogin() {
t.CheckErr(err)
// 校验邀请函是否开启
//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)
// t.Assert(exist, code.MSG_INVITE_LETTER_NOT_EXIST, "您尚未接受过邀请")
//}
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)
@ -178,6 +181,7 @@ func (t *UserCtl) WxLogin() {
"real_sign_form": sign.RealSignJsonForm,
"real_sign_json": sign.RealSignJsonTitle,
"tag": "activity",
"require_invite": requireInvite,
})
}
@ -195,9 +199,9 @@ func (t *UserCtl) Login() {
exist, err = models.Get(area, areaId)
t.CheckErr(err)
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "此直播间已被删除")
if activity.MoreAreaMode == define.StatusClose && area.IsMainArea != 1 {
t.ERROR("多地区功能关闭,链接失效,请打开后再试", code.MSG_AREASTORE_CLOSED)
}
//if activity.MoreAreaMode == define.StatusClose && area.IsMainArea != 1 {
// t.ERROR("多地区功能关闭,链接失效,请打开后再试", code.MSG_AREASTORE_CLOSED)
//}
token, err := wechat.GetToken(wxcode)
t.CheckErr(err)
@ -248,8 +252,6 @@ func (t *UserCtl) Login() {
}
}
//jwtToken, err := jwt.GenJwtToken(define.TYPE_USER, user.Id, 0, 0, 0, 0)
//t.CheckErr(err)
user.Token = fmt.Sprintf("%s:%s", define.TYPE_LIVEUSER, user.Token)
t.SetSession(define.TOKEN, user.Token)
sign, err := im.AccountImport(fmt.Sprintf("%d", user.Id), user.Nickname, user.Avatar)

22
controllers/client/order_entry.go

@ -39,23 +39,24 @@ func (t *OrderEntryCtl) List() {
areaId = t.MustGetInt("area_id")
}
area := &models.AreaStore{}
exist, err = models.Get(area, areaId)
t.CheckErr(err)
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
if area.IsMainArea != 1 && area.AreaGoodsRuleSwitch != 1 {
exist, err = area.GetMainAreaById(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
}
//area := &models.AreaStore{}
//exist, err = models.Get(area, areaId)
//t.CheckErr(err)
//t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
//if area.IsMainArea != 1 && area.AreaGoodsRuleSwitch != 1 {
// exist, err = area.GetMainAreaById(activityId)
// t.CheckErr(err)
// t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
//}
// 库存
goods, err := models.GetGoodsByActivityId(activityId, area.Id)
goods, err := models.GetGoodsByActivityId(activityId, areaId)
t.CheckErr(err)
goodIds := make([]int, 0)
for _, g := range goods {
goodIds = append(goodIds, g.Id)
}
res, err := models.GetSubOrderGoodNum(goodIds, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
@ -151,7 +152,6 @@ func (t *OrderEntryCtl) Order() {
return
}
}
}
order := models.CustomerOrder{}
// 查询库存

6
controllers/client/shake_red_envelope.go

@ -96,8 +96,10 @@ func (t *ShakeRedEnvelopeCtl) Shake() {
if activity.RehearsalId == 0 {
result, err := pay_service.SendRedPack("欧轩互动", user.Openid, "红包只会越抢越多",
"直播抢红包活动", "抢的多,赚得多", int(record.Amount*100), 1, 2)
t.CheckErr(err)
record.MchBillno = result.MchBillno
if err == nil {
record.MchBillno = result.MchBillno
}
// t.CheckErr(err)
models.Update(record.Id, record, "mch_billno")
}

4
go.mod

@ -9,7 +9,7 @@ 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.12 // indirect
github.com/aws/aws-sdk-go v1.35.20 // indirect
github.com/bndr/gotabulate v1.1.2 // indirect
github.com/chanxuehong/wechat v0.0.0-20200409104612-0a1fd76d7a3a
github.com/clbanning/mxj v1.8.4 // 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-20201020230747-6e5568b54d1a // indirect
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 // 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

4
go.sum

@ -23,6 +23,8 @@ github.com/aws/aws-sdk-go v1.35.11 h1:LICFl2K+3Y5dMTW6PCV6ycK8fzIxs21HvDhI5A3Ee3
github.com/aws/aws-sdk-go v1.35.11/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
github.com/aws/aws-sdk-go v1.35.12 h1:qpxQ/DXfgsTNSYn8mUaCgQiJkCjBP8iHKw5ju+wkucU=
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/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=
@ -190,6 +192,8 @@ golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13 h1:5jaG59Zhd+8ZXe8C+lgiAGqkO
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/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=

8
main.go

@ -1,18 +1,16 @@
package main
import (
"git.ouxuan.net/tommy/osmanthuswine"
"git.ouxuan.net/tommy/osmanthuswine/src/core"
"hudongzhuanjia/controllers/client"
"hudongzhuanjia/controllers/common"
"hudongzhuanjia/controllers/pc"
"hudongzhuanjia/utils/define"
"git.ouxuan.net/tommy/osmanthuswine"
"git.ouxuan.net/tommy/osmanthuswine/src/core"
//_ "net/http/pprof"
)
func main() {
define.SetDebug(true)
// define.SetDebug(true)
// pc
core.GetInstanceRouterManage().Registered(new(pc.WsCtl)) // 用户

18
models/customer_goods.go

@ -9,15 +9,15 @@ const CustomerGoodsTableName = TableNamePrefix + "customer_goods"
type CustomerGoods struct {
Model `xorm:"extends"`
ActivityId int `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
AreaId int `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
GoodsPicUrl []interface{} `json:"goods_pic_url" xorm:"json comment('商品图片')"`
IsForceAdded int `json:"is_force_added" xorm:"not null default 0 comment('是否强制上架0不强制1强制') TINYINT(1)"`
FixedField string `json:"fixed_field" xorm:"not null default '' comment('固定不可改字段,|分隔') VARCHAR(255)"`
Stock int `json:"stock" xorm:"not null default 0 comment('库存-1的时候无上限') INT(18)"`
Name string `json:"name" xorm:"not null default '' comment('商品名称') VARCHAR(255)"`
Price float64 `json:"price" xorm:"not null default 0.00 comment('商品单价') DECIMAL(18,2)"`
Desc string `json:"desc" xorm:"not null default '' comment('商品介绍') VARCHAR(255)"`
ActivityId int `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
AreaId int `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
GoodsPicUrl string `json:"goods_pic_url" xorm:"comment('商品图片')"`
IsForceAdded int `json:"is_force_added" xorm:"not null default 0 comment('是否强制上架0不强制1强制') TINYINT(1)"`
FixedField string `json:"fixed_field" xorm:"not null default '' comment('固定不可改字段,|分隔') VARCHAR(255)"`
Stock int `json:"stock" xorm:"not null default 0 comment('库存-1的时候无上限') INT(18)"`
Name string `json:"name" xorm:"not null default '' comment('商品名称') VARCHAR(255)"`
Price float64 `json:"price" xorm:"not null default 0.00 comment('商品单价') DECIMAL(18,2)"`
Desc string `json:"desc" xorm:"not null default '' comment('商品介绍') VARCHAR(255)"`
// 无关变量
GoodType int `json:"good_type" xorm:"-"`

14
models/customer_order_sub.go

@ -36,12 +36,12 @@ func (t *CustomerOrderSub) Alias(n string) string {
}
type SubOrderResult struct {
OrderId int `json:"order_id"`
GoodsId int `json:"goods_id"`
GoodsNum int `json:"goods_num"`
GoodName string `json:"good_name"`
GoodPrice float64 `json:"good_price"`
GoodsPicUrl []interface{} `json:"goods_pic_url"`
OrderId int `json:"order_id"`
GoodsId int `json:"goods_id"`
GoodsNum int `json:"goods_num"`
GoodName string `json:"good_name"`
GoodPrice float64 `json:"good_price"`
GoodsPicUrl string `json:"goods_pic_url"`
}
func GetCustomerOrderSubsByOrderIds(orderIds interface{}) (subs []*SubOrderResult, err error) {
@ -78,7 +78,7 @@ func GetSubOrderGoodNum(goodIds, rehearsalId, archId interface{}) (res []*OrderG
func GetSubOrderGoodNumBySession(s *xorm.Session, goodIds, rehearsalId, archId interface{}) (res []*OrderGoodNum, err error) {
err = s.Table(&CustomerOrderSub{}).Alias("s").Select("s.goods_id, SUM(s.goods_num) as goods_num").
Join("left", (&CustomerOrder{}).TableName()+" as o", "o.id=s.order_id").
Where("o.is_delete=0 and s.is_delete=0 and s.rehearsal_id=? and arch_id=?", rehearsalId, archId).
Where("o.is_delete=0 and s.is_delete=0 and o.rehearsal_id=? and arch_id=?", rehearsalId, archId).
In("s.goods_id", goodIds).NotIn("o.status", "0", "6", "8", "9").GroupBy("s.goods_id").Find(&res)
return
}

15
models/order_entry_person.go

@ -29,9 +29,18 @@ func (t *OrderEntryPerson) TableName() string {
return OrderEntryPersonTableName
}
func (t *OrderEntryPerson) Auth(account, password, activityId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and account = ? and password = ? and activity_id = ?",
account, password, activityId).Get(t)
func (t *OrderEntryPerson) Auth(account, password, activityId interface{}) error {
exist, err := core.GetXormAuto().Where("is_delete=0 and account=? and activity_id=?", account, activityId).Get(t)
if err != nil {
return err
}
if exist {
return errors.New("用户名错误")
}
if t.Password != password {
return errors.New("密码错误")
}
return nil
}
func (t *OrderEntryPerson) GetByToken(token string) error {

Loading…
Cancel
Save