From 7b6c9fd73aa53771f57d82c9bf89ac7214271a99 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 24 Oct 2018 11:45:37 +0800 Subject: [PATCH] - financial/GetStoreBills --- business/jxstore/financial/financial.go | 13 +++++++++++++ business/model/legacymodel/storebill.go | 10 +++++----- controllers/financial.go | 14 ++++++++++++++ routers/commentsRouter_controllers.go | 8 ++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/business/jxstore/financial/financial.go b/business/jxstore/financial/financial.go index 55545d880..ec8878a6e 100644 --- a/business/jxstore/financial/financial.go +++ b/business/jxstore/financial/financial.go @@ -91,3 +91,16 @@ func SendFilesToStores(ctx *jxcontext.Context, files []*multipart.FileHeader, is } return task.ID, err } + +func GetStoreBills(ctx *jxcontext.Context, storeID int) (bills []*legacymodel.StoreBill, err error) { + db := dao.GetDB() + if err = dao.GetRows(db, &bills, ` + SELECT * + FROM store_bill + WHERE store_id = ? + ORDER BY date DESC + `, storeID); err != nil { + return nil, err + } + return bills, err +} diff --git a/business/model/legacymodel/storebill.go b/business/model/legacymodel/storebill.go index a159e5a9c..b66559ff4 100644 --- a/business/model/legacymodel/storebill.go +++ b/business/model/legacymodel/storebill.go @@ -3,11 +3,11 @@ package legacymodel import "time" type StoreBill struct { - Id int `orm:"column(id);auto"` - Date time.Time `orm:"column(date);type(datetime)"` - Url string `orm:"column(url);size(255)"` - StoreId int `orm:"column(store_id)"` - BillName string `orm:"column(bill_name);size(30)"` + Id int `orm:"column(id);auto" json:"id"` + Date time.Time `orm:"column(date);type(datetime)" json:"date"` + Url string `orm:"column(url);size(255)" json:"url"` + StoreId int `orm:"column(store_id)" json:"storeId"` + BillName string `orm:"column(bill_name);size(30)" json:"billName"` } func (t *StoreBill) TableName() string { diff --git a/controllers/financial.go b/controllers/financial.go index b15d71ccd..fe43457c6 100644 --- a/controllers/financial.go +++ b/controllers/financial.go @@ -41,3 +41,17 @@ func (c *FinancialController) SendFilesToStores() { }) } } + +// @Title 查询门店账单 +// @Description 查询门店账单 +// @Param token header string true "认证token" +// @Param storeID query int true "门店ID" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetStoreBills [get] +func (c *FinancialController) GetStoreBills() { + c.callGetStoreBills(func(params *tFinancialGetStoreBillsParams) (retVal interface{}, errCode string, err error) { + retVal, err = financial.GetStoreBills(params.Ctx, params.StoreID) + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 419ae2572..b10a3422a 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -95,6 +95,14 @@ func init() { MethodParams: param.Make(), Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FinancialController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FinancialController"], + beego.ControllerComments{ + Method: "GetStoreBills", + Router: `/GetStoreBills`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FinancialController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FinancialController"], beego.ControllerComments{ Method: "SendFilesToStores",