- 实现GetStoresOrderSaleInfo
This commit is contained in:
@@ -28,11 +28,13 @@ type tWaybillExt struct {
|
||||
}
|
||||
|
||||
type StoresOrderSaleInfo struct {
|
||||
StoreID int `json:"storeID"`
|
||||
Status int `json:"status"`
|
||||
Count int `json:"count"`
|
||||
SalePrice int64 `json:"salePrice"`
|
||||
ActualPay int64 `json:"actualPay"`
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
Status int `json:"status"`
|
||||
Count int `json:"count"`
|
||||
ShopPrice int64 `json:"shopPrice"`
|
||||
SalePrice int64 `json:"salePrice"`
|
||||
ActualPayPrice int64 `json:"actualPayPrice"`
|
||||
}
|
||||
|
||||
//此函数会被GetStoreOrderCountInfo2取代
|
||||
@@ -617,6 +619,32 @@ func (c *OrderManager) GetOrdersFinancial(ctx *jxcontext.Context, fromDateStr, t
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetStoresOrderSaleInfo(ctx *jxcontext.Context, storeIDList []int, fromTime time.Time, toTime time.Time, statusList []int) (saleInfo *StoresOrderSaleInfo, err error) {
|
||||
return saleInfo, err
|
||||
func (c *OrderManager) GetStoresOrderSaleInfo(ctx *jxcontext.Context, storeIDList []int, fromTime time.Time, toTime time.Time, statusList []int) (saleInfoList []*StoresOrderSaleInfo, err error) {
|
||||
if toTime.Sub(fromTime) > time.Hour*24*60 {
|
||||
return nil, fmt.Errorf("查询时间范围不能超过2个月")
|
||||
}
|
||||
sql := `
|
||||
SELECT IF(t1.jx_store_id > 0, t1.jx_store_id, t1.store_id) store_id, t1.vendor_id, IF(t1.status < ?, 0, t1.status) status,
|
||||
COUNT(*) count, SUM(t1.shop_price) shop_price, SUM(t1.sale_price) sale_price, SUM(t1.actual_pay_price) actual_pay_price
|
||||
FROM goods_order t1
|
||||
WHERE t1.order_created_at >= ? AND t1.order_created_at <= ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.OrderStatusEndBegin,
|
||||
fromTime,
|
||||
toTime,
|
||||
}
|
||||
if len(storeIDList) > 0 {
|
||||
sql += " AND IF(t1.jx_store_id > 0, t1.jx_store_id, t1.store_id) IN (" + dao.GenQuestionMarks(len(storeIDList)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDList)
|
||||
}
|
||||
if len(statusList) > 0 {
|
||||
sql += " AND t1.status IN (" + dao.GenQuestionMarks(len(statusList)) + ")"
|
||||
sqlParams = append(sqlParams, statusList)
|
||||
}
|
||||
sql += `
|
||||
GROUP BY 1,2,3
|
||||
ORDER BY 1,2,3`
|
||||
err = dao.GetRows(dao.GetDB(), &saleInfoList, sql, sqlParams...)
|
||||
return saleInfoList, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user