Browse Source

fix:bug

token_replace
黄梓健 5 years ago
parent
commit
0128c61d38
  1. 4
      controllers/client/lottery.go
  2. 15
      controllers/client/order_entry.go
  3. 5
      controllers/pc/lottery_draw.go
  4. 4
      models/customer_order.go
  5. 27
      models/lottery_draw_record.go
  6. 3
      services/lottery/lottery.go

4
controllers/client/lottery.go

@ -49,8 +49,8 @@ func (t *LotteryCtl) CashLottery() {
exist, err := record.GetByUserPrizeId(prizeId)
t.CheckErr(err)
t.Assert(exist, code.MSG_LOTTERY_DRAW_RECORD_NOT_EXIST, "中奖记录不存在")
record.Name = name
record.Phone = phone
record.UserName = name
record.UserPhone = phone
record.WxNo = wxNo
record.Address = address
record.Status = 1

15
controllers/client/order_entry.go

@ -277,16 +277,23 @@ func (t *OrderEntryCtl) ManualOrder() {
s.Rollback()
t.CheckErr(err)
}
user := models.User{
Phone: param.Phone,
Nickname: param.Name,
Password: utils.RandomStr(6),
user := models.User{}
exist, err = s.Where("is_delete=0 and phone=?", param.Phone).NoAutoCondition().Get(&user)
if err != nil {
s.Rollback()
t.CheckErr(err)
}
if !exist {
user.Phone = param.Phone
user.Nickname = param.Name
user.Password = utils.RandomStr(8)
_, err = s.InsertOne(&user)
if err != nil {
s.Rollback()
t.CheckErr(err)
}
}
// 校验库存
goods := make([]*models.CustomerGoods, 0)
err = s.Where("is_delete=0").In("id", goodIds).Find(&goods)

5
controllers/pc/lottery_draw.go

@ -220,11 +220,6 @@ func (t *LotteryDrawCtl) Users() {
ruleId := t.MustGetInt("lottery_draw_rule_id")
customerId := t.GetAccountId()
//customer := new(models.Customer)
//exist, err := models.Get(customer, customerId)
//t.CheckErr(err)
//t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
activity := new(models.Activity)
exist, err := models.Get(activity, activityId)
t.CheckErr(err)

4
models/customer_order.go

@ -59,6 +59,10 @@ func (t *CustomerOrder) TableName() string {
return CustomerOrderTableName
}
func (t *CustomerOrder) Alias(name string) string {
return Alias(t, name)
}
func (t *CustomerOrder) GetByOutTradeNO(outTradeNo string) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", outTradeNo).Get(t)
}

27
models/lottery_draw_record.go

@ -9,24 +9,23 @@ import (
const LotteryDrawRecordTableName = TableNamePrefix + "lottery_draw_record"
type LotteryDrawRecord struct {
Id int `json:"id" xorm:"pk autoincr"`
ActivityId int `json:"activity_id" xorm:"not null comment('主活动id')"`
RehearsalId int `json:"rehearsal_id" xorm:"not null comment('彩排id/0正式')"`
Id int `json:"id" xorm:"pk autoincr not null INT(11)"`
ActivityId int `json:"activity_id" xorm:"not null comment('主活动id') INT(11)"`
RehearsalId int `json:"rehearsal_id" xorm:"not null comment('彩排id/0正式') INT(11)"`
UserPrizeId int `json:"user_prize_id" xorm:"not null comment('用户奖品id') INT(11)"`
LotteryDrawActivityId int `json:"lottery_draw_activity_id" xorm:"not null comment('抽奖活动id')"`
LotteryDrawRuleId int `json:"lottery_draw_rule_id" xorm:"not null comment('抽奖规则id') BIGINT(20)"`
LotteryDrawRuleLadderId int `json:"lottery_draw_rule_ladder_id" xorm:"not null comment('规则阶梯id')"`
LotteryDrawActivityId int `json:"lottery_draw_activity_id" xorm:"not null comment('抽奖活动id') INT(11)"`
LotteryDrawRuleId int `json:"lottery_draw_rule_id" xorm:"not null comment('抽奖规则id') INT(20)"`
LotteryDrawRuleLadderId int `json:"lottery_draw_rule_ladder_id" xorm:"not null comment('规则阶梯id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
UserId int `json:"user_id" xorm:"not null comment('用户id')"`
UserId int `json:"user_id" xorm:"not null comment('用户id') INT(11)"`
AreaId int `json:"area_id" xorm:"not null default(0) comment('地区id') INT(11)"`
RollNum int `json:"roll_num" xrom:"not null default 0 comment('滚动次数') INT(11)"`
UserName string `json:"user_name" description:"用户名" xorm:"not null comment('用户名')"`
UserPhone string `json:"user_phone" description:"电话" xorm:"not null comment('电话号码')"`
PrizeName string `json:"prize_name" description:"奖品名字" xorm:"not null comment('奖品名字')"`
AreaName string `json:"area_name" description:"名字" xorm:"not null comment('地区名字')"`
AreaId int `json:"area_id" xorm:"not null default(0) comment('地区id')"`
UserName string `json:"user_name" xorm:"not null comment('用户名') VARCHAR(128)"`
UserPhone string `json:"user_phone" xorm:"not null comment('电话号码') VARCHAR(128)"`
PrizeName string `json:"prize_name" xorm:"not null comment('奖品名字') VARCHAR(128)"`
AreaName string `json:"area_name" xorm:"not null comment('地区名字') VARCHAR(128)"`
EntryPersonName string `json:"entry_person_name" xorm:"not null default '' comment('录入人员名单') VARCHAR(128)"`
Status int `json:"status" xorm:"not null default 0 comment('是否已经兑奖0否1是') TINYINT(1)"`
Name string `json:"name" xorm:"not null default '' comment('姓名') VARCHAR(128)"`
Phone string `json:"phone" xorm:"not null default '' comment('电话号码') VARCHAR(128)"`
WxNo string `json:"wx_no" xorm:"not null default '' comment('微信号') VARCHAR(128)"`
Address string `json:"address" xorm:"not null default '' comment('地址') VARCHAR(128)"`
IsDelete bool `json:"-" xorm:"default(0)"`

3
services/lottery/lottery.go

@ -181,11 +181,12 @@ type WinnersResult struct {
UserPhone string `json:"user_phone"`
Avatar string `json:"avatar"`
PrizeName string `json:"prize_name"`
EntryPersonName string `json:"entry_person_name"`
}
func GetWinnersResult(ruleId, rehearsalId, archId interface{}) ([]*WinnersResult, error) {
result := make([]*WinnersResult, 0)
err := core.GetXormAuto().Table(new(models.LotteryDrawRecord)).Alias("r").
err := core.GetXormAuto().Table(&models.LotteryDrawRecord{}).Alias("r").
Join("LEFT", new(models.User).Alias("u"), "u.id=r.user_id").
Where("r.is_delete=0 and r.lottery_draw_rule_id=? and r.rehearsal_id=? and r.arch_id=?",
ruleId, rehearsalId, archId).Find(&result)

Loading…
Cancel
Save