- 实现GetStoresOrderSaleInfo

This commit is contained in:
gazebo
2019-05-13 16:07:42 +08:00
parent c9fcb83e56
commit 37da5be607
2 changed files with 44 additions and 7 deletions

View File

@@ -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
}

View File

@@ -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",