|
|
@ -43,10 +43,11 @@ type CustomerOrder struct { |
|
|
|
CancelTime time.Time `json:"cancel_time" xorm:"comment('取消时间') DATETIME"` |
|
|
|
AutoReceiveTime time.Time `json:"auto_receive_time" xorm:"comment('自动收货时间') DATETIME"` |
|
|
|
|
|
|
|
GoodsId int `json:"goods_id" xorm:"not null default 0 comment('customer_goods表id') BIGINT(20)"` |
|
|
|
GoodsName string `json:"goods_name" xorm:"not null default '' comment('商品名字') VARCHAR(255)"` |
|
|
|
GoodsNum int `json:"goods_num" xorm:"not null default 0 comment('商品数量') INT(11)"` |
|
|
|
|
|
|
|
// 无关变量
|
|
|
|
GoodsId int `json:"goods_id,omitempty" xorm:"not null default 0 comment('customer_goods表id') BIGINT(20)"` |
|
|
|
GoodsName string `json:"goods_name,omitempty" xorm:"not null default '' comment('商品名字') VARCHAR(255)"` |
|
|
|
GoodsNum int `json:"goods_num,omitempty" xorm:"not null default 0 comment('商品数量') INT(11)"` |
|
|
|
OrderTime string `json:"order_time,omitempty" xorm:"-"` |
|
|
|
Good *CustomerGoods `json:"good,omitempty" xorm:"-"` |
|
|
|
User *User `json:"user,omitempty" xorm:"-"` |
|
|
@ -92,3 +93,17 @@ func (t *CustomerOrder) CountCustomerOrder(activityId, rehearsalId, archId inter |
|
|
|
activityId, rehearsalId, archId).Distinct("buyer_id").Count(t) |
|
|
|
return buyerCount, err |
|
|
|
} |
|
|
|
|
|
|
|
func (t *CustomerOrder) SumCustomerOrder(activityId, rehearsalId, archId interface{}, limit int) ([]map[string]string, error) { |
|
|
|
res := make([]map[string]string, 0) |
|
|
|
err := core.GetXormAuto().Table(t).Select("order_entry_person_id, order_entry_person_name, SUM(goods_num) as num"). |
|
|
|
NoAutoCondition().Where("is_delete=0 and activity_id=? and rehearsal_id=? and arch_id=?", |
|
|
|
activityId, rehearsalId, archId).Limit(limit).Desc("num").Find(&res) |
|
|
|
return res, err |
|
|
|
} |
|
|
|
|
|
|
|
func (t *CustomerOrder) TotalCustomerOrderGoodsNum(activityId, rehearsalId, archId interface{}) (int64, error) { |
|
|
|
sum, err := core.GetXormAuto().NoAutoCondition().Where("is_delete=0 and activity_id=? and rehearsal_id=? and arch_id=?", |
|
|
|
activityId, rehearsalId, archId).SumInt(t, "goods_num") |
|
|
|
return sum, err |
|
|
|
} |