Browse Source

fix:bug

token_replace
黄梓健 4 years ago
parent
commit
f81253a676
  1. 15
      controllers/pc/order_draw.go
  2. 11
      models/customer_order.go

15
controllers/pc/order_draw.go

@ -244,10 +244,9 @@ func (t *OrderDrawCtl) Users() {
defer s.Close()
if customer.IsSpecial == 2 {
s = s.Table(&models.CustomerOrder{}).Alias("o").Select("o.buyer_id as user_id, "+
" o.phone, o.order_entry_person_name as entry_person_name, u.nickname as username, u.avatar").
Distinct("o.buyer_id").Join("LEFT", (&models.User{}).Alias("u"),
"o.buyer_id=u.id and u.is_delete=0").Where("o.activity_id=? and o.is_delete=0 "+
" and o.rehearsal_id=? and o.arch_id=?", activityId, activity.RehearsalId, activity.ArchId)
" o.phone, o.order_entry_person_name as entry_person_name, o.receiver as username").
Where("o.is_delete=0 and o.activity_id=? and o.rehearsal_id=? and o.arch_id=?",
activityId, activity.RehearsalId, activity.ArchId)
if moduleService.BesideRepeat == define.MODULE_BESIDE_REPEAT {
recordIds := make([]int, 0)
@ -516,10 +515,9 @@ func (t *OrderDrawCtl) Orders() {
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
// 下订单人数
buyerCount, err := (&models.CustomerOrder{}).CountCustomerOrder(activity.Id, activity.RehearsalId, activity.ArchId)
t.CheckErr(err)
if customer.IsSpecial == 2 {
count, err := (&models.CustomerOrder{}).CountCustomerOrder(activity.Id, activity.RehearsalId, activity.ArchId, 0)
orders := make([]*SpecialOrdersResult, 0)
err = core.GetXormAuto().Table(&models.CustomerOrder{}).Alias("o").Select("o.id as id, "+
" o.area_name as area_name, o.order_entry_person_name as entry_person_name, o.buyer_id as user_id, "+
@ -544,10 +542,11 @@ func (t *OrderDrawCtl) Orders() {
t.JSON(map[string]interface{}{
"orders": orders,
"total": len(orders),
"buyer_count": buyerCount,
"buyer_count": count,
})
return
} else {
count, err := (&models.CustomerOrder{}).CountCustomerOrder(activity.Id, activity.RehearsalId, activity.ArchId, 1)
orders := make([]*OrdersResult, 0)
err = core.GetXormAuto().Table(&models.CustomerOrder{}).Alias("o").
Select("o.area_name, o.goods_name, o.buyer_id as user_id, u.nickname, l.extra_data as extra_data, o.created_at").
@ -569,7 +568,7 @@ func (t *OrderDrawCtl) Orders() {
t.JSON(map[string]interface{}{
"orders": orders,
"total": len(orders),
"buyer_count": buyerCount,
"buyer_count": count,
})
return
}

11
models/customer_order.go

@ -91,10 +91,15 @@ func GetExpiredAtLiveCustomerOrder() ([]*CustomerOrder, error) {
return orders, nil
}
func (t *CustomerOrder) CountCustomerOrder(activityId, rehearsalId, archId interface{}) (int64, error) {
buyerCount, err := core.GetXormAuto().NoAutoCondition().
func (t *CustomerOrder) CountCustomerOrder(activityId, rehearsalId, archId interface{}, _type int) (int64, error) {
s := core.GetXormAuto().NoAutoCondition().
Where("is_delete=0 and activity_id=? and rehearsal_id=? and arch_id=?",
activityId, rehearsalId, archId).Distinct("buyer_id").Count(t)
activityId, rehearsalId, archId)
defer s.Close()
if _type == 1 {
s.Distinct("buyer_id")
}
s.Count(t)
return buyerCount, err
}

Loading…
Cancel
Save