Browse Source

fix:bug

token_replace
黄梓健 5 years ago
parent
commit
ce68ab2037
  1. 97
      controllers/client/order_entry.go
  2. 5
      controllers/pc/order_draw.go

97
controllers/client/order_entry.go

@ -146,6 +146,9 @@ func (t *OrderEntryCtl) Order() {
order.Receiver = name order.Receiver = name
order.Phone = phone order.Phone = phone
order.Address = address order.Address = address
order.GoodsName = good.Name
order.GoodsId = good.Id
order.GoodsNum = 1
order.OutTradeNo = utils.RandomStr(32) order.OutTradeNo = utils.RandomStr(32)
order.OrderNo = fmt.Sprint(define.DefaultOrderNo + int(total)) order.OrderNo = fmt.Sprint(define.DefaultOrderNo + int(total))
order.Status = 1 order.Status = 1
@ -442,54 +445,80 @@ func (t *OrderEntryCtl) DeleteOrder() {
} }
type OrderListResult struct { type OrderListResult struct {
OrderId int `json:"order_id"`
UserId int `json:"user_id"`
EntryName string `json:"entry_name"`
GoodName string `json:"good_name"`
OrderTime string `json:"order_time"`
OrderMoney float64 `json:"order_money"`
Receiver string `json:"receiver"`
Phone string `json:"phone"`
Address string `json:"address"`
Extra []map[string]interface{} `json:"extra"` // 额外信息
ExtraData string `json:"-"`
OrderId int `json:"order_id"`
UserId int `json:"user_id"`
EntryName string `json:"entry_name"`
GoodName string `json:"good_name"`
OrderTime string `json:"order_time"`
OrderMoney float64 `json:"order_money"`
Receiver string `json:"receiver"`
Phone string `json:"phone"`
Address string `json:"address"`
Extra interface{} `json:"extra"` // 额外信息
ExtraData string `json:"-"`
} }
func (t *OrderEntryCtl) EntryOrders() { func (t *OrderEntryCtl) EntryOrders() {
uid := t.GetAccountId() uid := t.GetAccountId()
activityId := t.MustGetInt("activity_id")
entry := new(models.OrderEntryPerson)
exist, err := models.Get(entry, uid)
entry := models.OrderEntryPerson{}
exist, err := models.Get(&entry, uid)
t.CheckErr(err) t.CheckErr(err)
t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在") t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在")
activity := new(models.Activity)
exist, err = models.Get(activity, activityId)
activity := models.Activity{}
exist, err = models.Get(&activity, entry.ActivityId)
t.CheckErr(err) t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
list := make([]*OrderListResult, 0)
err = core.GetXormAuto().Table(new(models.CustomerOrder)).Alias("o").
Select("o.receiver as receiver, o.phone as phone, o.address as address,l.extra_data as extra_data, "+
" g.name as good_name, o.buyer_id as user_id, o.total_amount as order_money, o.id as order_id, "+
" DATE_FORMAT(o.created_at, '%Y-%m-%d %H:%i:%S') AS order_time").
Join("LEFT", new(models.CustomerGoods).Alias("g"),
"o.goods_id=g.id and o.activity_id=g.activity_id and g.is_delete=0").
Join("LEFT", new(models.InvitationLetter).Alias("l"),
"l.user_id = o.buyer_id and o.activity_id=l.activity_id and o.arch_id=l.arch_id and l.is_delete=0").
Where("o.activity_id=? and o.order_entry_person_id=? and o.rehearsal_id=? and o.arch_id=? and o.is_delete=0",
activityId, uid, activity.RehearsalId, activity.ArchId).Desc("o.created_at").Find(&list)
customer := models.Customer{}
exist, err = models.Get(&customer, activity.CustomerId)
t.CheckErr(err) t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
// 添加邀请函的内容
optionItems, err := invitation_service.GetOptionItem(activityId)
t.CheckErr(err)
for i := range list {
data, err := invitation_service.GetOptionValue(optionItems, list[i].ExtraData)
list := make([]*OrderListResult, 0)
if customer.IsSpecial == 0 {
// 添加邀请函的内容
err = core.GetXormAuto().Table(&models.CustomerOrder{}).Alias("o").
Select("o.receiver as receiver, o.phone as phone, o.address as address,l.extra_data as extra_data, "+
" g.name as good_name, o.buyer_id as user_id, o.total_amount as order_money, o.id as order_id, "+
" DATE_FORMAT(o.created_at, '%Y-%m-%d %H:%i:%S') AS order_time").Join("LEFT",
(&models.CustomerGoods{}).Alias("g"), "o.goods_id=g.id and o.activity_id=g.activity_id and g.is_delete=0").
Join("LEFT", (&models.InvitationLetter{}).Alias("l"), "l.user_id = o.buyer_id and o.activity_id=l.activity_id and o.arch_id=l.arch_id and l.is_delete=0").
Where("o.activity_id=? and o.order_entry_person_id=? and o.rehearsal_id=? and o.arch_id=? "+
" and o.is_delete=0", activity.Id, uid, activity.RehearsalId, activity.ArchId).
Desc("o.created_at").Find(&list)
t.CheckErr(err) t.CheckErr(err)
list[i].Extra = data
list[i].EntryName = entry.Name
optionItems, err := invitation_service.GetOptionItem(activity.Id)
t.CheckErr(err)
for i := range list {
data, err := invitation_service.GetOptionValue(optionItems, list[i].ExtraData)
t.CheckErr(err)
list[i].Extra = data
list[i].EntryName = entry.Name
}
} else {
err = core.GetXormAuto().Table(&models.CustomerOrder{}).Alias("o").Select("o.id as order_id, "+
" o.receiver as receiver, o.phone as phone, o.address as address, o.buyer_id as user_id, o.order_entry_person_name as entry_name, "+
" o.total_amount as order_money, DATE_FORMAT(o.created_at, '%Y-%m-%d %H:%i:%S') AS order_time").
Where("o.activity_id=? and o.rehearsal_id=? and o.order_entry_person_id=? and o.arch_id=?",
activity.Id, activity.RehearsalId, uid, activity.ArchId).Find(&list)
t.CheckErr(err)
orderIds := make([]int, 0)
for _, v := range list {
orderIds = append(orderIds, v.OrderId)
}
subs, err := models.GetCustomerOrderSubsByOrderIds(orderIds)
t.CheckErr(err)
for i := range list {
s := make([]interface{}, 0)
for _, sub := range subs {
if sub["order_id"] == fmt.Sprint(list[i].OrderId) {
s = append(s, sub)
}
}
list[i].Extra = s
}
} }
t.JSON(map[string]interface{}{ t.JSON(map[string]interface{}{

5
controllers/pc/order_draw.go

@ -19,6 +19,11 @@ type OrderDrawCtl struct {
controllers.AuthorCtl controllers.AuthorCtl
} }
// 屏蔽
func (t *OrderDrawCtl) Block() {
}
// 开启订单活动 // 开启订单活动
func (t *OrderDrawCtl) Switch() { func (t *OrderDrawCtl) Switch() {
activityId := t.MustGetInt("activity_id") activityId := t.MustGetInt("activity_id")

Loading…
Cancel
Save