diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 38af80cbd..e20bdf037 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -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 } diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 9553ade12..4d06acffb 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -700,6 +700,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"], + beego.ControllerComments{ + Method: "GetStoresOrderSaleInfo", + Router: `/GetStoresOrderSaleInfo`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"], beego.ControllerComments{ Method: "GetWaybills",