Browse Source

fix:bug

token_replace
黄梓健 4 years ago
parent
commit
795528cd8e
  1. 82
      controllers/client/order_entry.go
  2. 18
      models/customer_goods.go

82
controllers/client/order_entry.go

@ -456,7 +456,7 @@ type OrderListResult struct {
OrderId int `json:"order_id"`
UserId int `json:"user_id"`
EntryName string `json:"entry_name"`
GoodName string `json:"good_name"`
GoodName string `json:"-"`
OrderTime string `json:"order_time"`
OrderMoney float64 `json:"order_money"`
Receiver string `json:"receiver"`
@ -485,49 +485,49 @@ func (t *OrderEntryCtl) EntryOrders() {
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
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)
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 if customer.IsSpecial == 2 {
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).Desc("o.created_at").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)
}
//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").
// 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)
// 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 if customer.IsSpecial == 2 {
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).Desc("o.created_at").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
}
list[i].Extra = s
}
//}
t.JSON(map[string]interface{}{
"list": list,

18
models/customer_goods.go

@ -14,15 +14,15 @@ type CustomerGoods struct {
CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"`
UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"`
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:"not null default '' comment('商品图片') VARCHAR(255)"`
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 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)"`
//// 无关变量
GoodType int `json:"good_type" xorm:"-"`

Loading…
Cancel
Save