From 91ec7c195b62b6ce7e84cd338e8725ced6c83659 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Thu, 4 Jul 2024 21:06:39 +0800 Subject: [PATCH] update --- .../hdl_central_kitchen_for_school.go | 5 ++- app/db/db_central_kitchen_wx_transfer_ord.go | 37 +++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go b/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go index 15141db..ecdd68b 100644 --- a/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go +++ b/app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go @@ -1663,7 +1663,7 @@ func CentralKitchenForSchoolWxTransferOrdList(c *gin.Context) { centralKitchenWxTransferOrdDb := db.CentralKitchenWxTransferOrd{} centralKitchenWxTransferOrdDb.Set("") - list, total, err := centralKitchenWxTransferOrdDb.FindCentralKitchenWxTransferOrd(req.Phone, req.Page, req.Limit) + list, total, err := centralKitchenWxTransferOrdDb.FindCentralKitchenWxTransferOrd(req.Page, req.Limit) if err != nil { e.OutErr(c, e.ERR, err.Error()) return @@ -1771,7 +1771,8 @@ func CentralKitchenForSchoolWxTransfer(c *gin.Context) { func CentralKitchenForSchoolWxTransferOrdFlow(c *gin.Context) { outTradeNo := c.DefaultQuery("out_trade_no", "") - centralKitchenWxTransferOrdDb := db.CentralKitchenWxTransferOrd{OutTradeNo: outTradeNo} + centralKitchenWxTransferOrdDb := db.CentralKitchenWxTransferOrd{} + centralKitchenWxTransferOrdDb.Set(outTradeNo) resp, err := centralKitchenWxTransferOrdDb.GetCentralKitchenWxTransferOrd() if err != nil { e.OutErr(c, e.ERR, err.Error()) diff --git a/app/db/db_central_kitchen_wx_transfer_ord.go b/app/db/db_central_kitchen_wx_transfer_ord.go index 629a3f1..ab7f33b 100644 --- a/app/db/db_central_kitchen_wx_transfer_ord.go +++ b/app/db/db_central_kitchen_wx_transfer_ord.go @@ -17,9 +17,18 @@ func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) Set(outTradeNo centralKitchenWxTransferOrdDb.OutTradeNo = outTradeNo } +type FindCentralKitchenWxTransferOrd struct { + model.CentralKitchenWxTransferOrdList `xorm:"extends"` + model.User `xorm:"extends"` +} + +func (FindCentralKitchenWxTransferOrd) TableName() string { + return "central_kitchen_wx_transfer_ord_list" +} + type GetCentralKitchenWxTransferOrdResp struct { - Ord *model.CentralKitchenWxTransferOrd `json:"ord"` - List *[]model.CentralKitchenWxTransferOrdList `json:"list"` + Ord *model.CentralKitchenWxTransferOrd `json:"ord"` + List []*FindCentralKitchenWxTransferOrd `json:"list"` } func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) GetCentralKitchenWxTransferOrd() (resp GetCentralKitchenWxTransferOrdResp, err error) { @@ -35,8 +44,10 @@ func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) GetCentralKitc resp.Ord = m //1、查找 central_kitchen_wx_transfer_ord_list 记录 - var list *[]model.CentralKitchenWxTransferOrdList - err = centralKitchenWxTransferOrdDb.Db.Where("out_trade_no =?", centralKitchenWxTransferOrdDb.OutTradeNo).Find(&list) + var list []*FindCentralKitchenWxTransferOrd + err = centralKitchenWxTransferOrdDb.Db.Where("out_trade_no =?", centralKitchenWxTransferOrdDb.OutTradeNo). + Join("LEFT", "user", "user.id = central_kitchen_wx_transfer_ord_list.uid"). + Find(&list) if err != nil { return resp, err } @@ -44,13 +55,8 @@ func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) GetCentralKitc return } -func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) FindCentralKitchenWxTransferOrd(phone string, page, limit int) (list []*FindCentralKitchenWxTransferOrd, total int64, err error) { - sess := centralKitchenWxTransferOrdDb.Db. - Join("LEFT", "user", "user.id = central_kitchen_wx_transfer_ord.uid") - if phone != "" { - sess.And("user.phone like ?", "%"+phone+"%") - } - total, err = sess.Limit(limit, (page-1)*limit).FindAndCount(&list) +func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) FindCentralKitchenWxTransferOrd(page, limit int) (list []*model.CentralKitchenWxTransferOrd, total int64, err error) { + total, err = centralKitchenWxTransferOrdDb.Db.Limit(limit, (page-1)*limit).FindAndCount(&list) if err != nil { return nil, 0, err } @@ -88,12 +94,3 @@ func (centralKitchenWxTransferOrdDb *CentralKitchenWxTransferOrd) CentralKitchen } return affected, nil } - -type FindCentralKitchenWxTransferOrd struct { - model.CentralKitchenWxTransferOrd `xorm:"extends"` - model.User `xorm:"extends"` -} - -func (FindCentralKitchenWxTransferOrd) TableName() string { - return "central_kitchen_wx_transfer_ord" -}