From 98716fefc87ba8f947f483802aa756bf298108de Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 25 Nov 2024 11:43:18 +0800 Subject: [PATCH 1/2] update --- .../new_user_red_package_with_user_records_dao.go | 1 + ...user_red_package_with_user_records_implement.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/dao/new_user_red_package_with_user_records_dao.go b/src/dao/new_user_red_package_with_user_records_dao.go index c0a00c2..87e9c5f 100644 --- a/src/dao/new_user_red_package_with_user_records_dao.go +++ b/src/dao/new_user_red_package_with_user_records_dao.go @@ -5,4 +5,5 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type NewUserRedPackageWithUserRecordsDao interface { //TODO:: You can add specific method definitions here NewUserRedPackageWithUserRecordsFind(page, limit int, uid int64, startAt, endAt string) (*[]model.NewUserRedPackageWithUserRecords, int64, error) + NewUserRedPackageWithUserRecordsGetLastPendingByParams(params map[string]interface{}) (*model.NewUserRedPackageWithUserRecords, error) } diff --git a/src/implement/new_user_red_package_with_user_records_implement.go b/src/implement/new_user_red_package_with_user_records_implement.go index fb450e8..2603157 100644 --- a/src/implement/new_user_red_package_with_user_records_implement.go +++ b/src/implement/new_user_red_package_with_user_records_implement.go @@ -4,6 +4,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "fmt" "xorm.io/xorm" ) @@ -33,3 +34,16 @@ func (n NewUserRedPackageWithUserRecordsDb) NewUserRedPackageWithUserRecordsFind } return &m, total, nil } + +func (n NewUserRedPackageWithUserRecordsDb) NewUserRedPackageWithUserRecordsGetLastPendingByParams(params map[string]interface{}) (*model.NewUserRedPackageWithUserRecords, error) { + var m model.NewUserRedPackageWithUserRecords + query := fmt.Sprintf("%s = ?", params["key"]) + has, err := n.Db.Where(query, params["value"]).And("state = ? OR state = ?", 0, 1).Desc("create_at").Get(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if !has { + return ni, nil + } + return &m, nil +} From ef18ee319fd28c21ec7a9740bfb104ba86d640c9 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 25 Nov 2024 11:44:00 +0800 Subject: [PATCH 2/2] update --- .../new_user_red_package_with_user_records_implement.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/implement/new_user_red_package_with_user_records_implement.go b/src/implement/new_user_red_package_with_user_records_implement.go index 2603157..bb9df74 100644 --- a/src/implement/new_user_red_package_with_user_records_implement.go +++ b/src/implement/new_user_red_package_with_user_records_implement.go @@ -43,7 +43,7 @@ func (n NewUserRedPackageWithUserRecordsDb) NewUserRedPackageWithUserRecordsGetL return nil, zhios_order_relate_logx.Error(err) } if !has { - return ni, nil + return nil, nil } return &m, nil }