+GetMyOrderCountInfo

This commit is contained in:
gazebo
2019-12-02 11:00:57 +08:00
parent 67976664e6
commit 0a42beac8a
4 changed files with 66 additions and 0 deletions

View File

@@ -918,3 +918,31 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat
}
return orders, totalCount, err
}
func GetMyOrderCountInfo(db *DaoDB, userID string, fromDate, toDate time.Time, statuss []int) (countInfo []*model.GoodsOrderCountInfo, err error) {
if utils.IsTimeZero(fromDate) {
return nil, fmt.Errorf("必须指定开始日期")
}
if utils.IsTimeZero(toDate) {
toDate = fromDate
}
sql := `
SELECT t1.lock_status, t1.status, COUNT(*) count
FROM goods_order t1
WHERE t1.user_id = ? AND t1.vendor_id = ?
AND t1.order_created_at >= ? AND t1.order_created_at <= ?
`
sqlParams := []interface{}{
userID,
model.VendorIDJX,
fromDate, toDate,
}
if len(statuss) > 0 {
sql += " AND t1.status IN (" + GenQuestionMarks(len(statuss)) + ")"
sqlParams = append(sqlParams, statuss)
}
sql += " GROUP BY 1,2"
err = GetRows(db, &countInfo, sql, sqlParams...)
return countInfo, err
}