From d5490fda34d9e98f4595dadeb0bdf4d31457f710 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 25 Nov 2024 22:20:44 +0800 Subject: [PATCH] update --- src/dao/im_send_red_package_ord_dao.go | 12 ++++++ .../im_send_red_package_ord_implement.go | 42 +++++++++++++++++++ src/model/im_send_red_package_ord.go | 27 ++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 src/dao/im_send_red_package_ord_dao.go create mode 100644 src/implement/im_send_red_package_ord_implement.go create mode 100644 src/model/im_send_red_package_ord.go diff --git a/src/dao/im_send_red_package_ord_dao.go b/src/dao/im_send_red_package_ord_dao.go new file mode 100644 index 0000000..a9674ca --- /dev/null +++ b/src/dao/im_send_red_package_ord_dao.go @@ -0,0 +1,12 @@ +package dao + +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "xorm.io/xorm" +) + +type ImSendRedPackageOrdDao interface { + //TODO:: You can add specific method definitions here + ImSendRedPackageOrdGetOneByParams(params map[string]interface{}) (*model.ImSendRedPackageOrd, error) + ImSendRedPackageOrdUpdateBySession(session *xorm.Session, id interface{}, user *model.ImSendRedPackageOrd, forceColumns ...string) (int64, error) +} diff --git a/src/implement/im_send_red_package_ord_implement.go b/src/implement/im_send_red_package_ord_implement.go new file mode 100644 index 0000000..1b53582 --- /dev/null +++ b/src/implement/im_send_red_package_ord_implement.go @@ -0,0 +1,42 @@ +package implement + +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" +) + +func NewImSendRedPackageOrdDb(engine *xorm.Engine) dao.ImSendRedPackageOrdDao { + return &ImSendRedPackageOrdDb{Db: engine} +} + +type ImSendRedPackageOrdDb struct { + Db *xorm.Engine +} + +func (i ImSendRedPackageOrdDb) ImSendRedPackageOrdGetOneByParams(params map[string]interface{}) (*model.ImSendRedPackageOrd, error) { + var m model.ImSendRedPackageOrd + var query = fmt.Sprintf("%s = ?", params["key"]) + if has, err := i.Db.Where(query, params["value"]).Get(&m); err != nil || has == false { + return nil, zhios_order_relate_logx.Error(err) + } + return &m, nil +} + +func (i ImSendRedPackageOrdDb) ImSendRedPackageOrdUpdateBySession(session *xorm.Session, id interface{}, user *model.ImSendRedPackageOrd, forceColumns ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColumns != nil { + affected, err = session.Where("id=?", id).MustCols(forceColumns...).Update(user) + } else { + affected, err = session.Where("id=?", id).Update(user) + } + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/src/model/im_send_red_package_ord.go b/src/model/im_send_red_package_ord.go new file mode 100644 index 0000000..f17aa23 --- /dev/null +++ b/src/model/im_send_red_package_ord.go @@ -0,0 +1,27 @@ +package model + +import ( + "time" +) + +type ImSendRedPackageOrd struct { + Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` + OrdNo string `json:"ord_no" xorm:"not null comment('订单号') VARCHAR(20)"` + Uid int `json:"uid" xorm:"not null comment('用户id') INT(11)"` + ImUid int `json:"im_uid" xorm:"not null comment('im对应用户id') INT(11)"` + Amount string `json:"amount" xorm:"not null comment('金额') DECIMAL(10,2)"` + RedPacketBalanceAmount string `json:"red_packet_balance_amount" xorm:"not null comment('红包余额') DECIMAL(10,2)"` + RedPacketType int `json:"red_packet_type" xorm:"not null default 1 comment('红包类型(0:未知 1:好友红包 2:群组普通红包 3:群组手气红包 4:群组专属红包 5:系统红包)') TINYINT(1)"` + RedPacketNums int `json:"red_packet_nums" xorm:"not null default 1 comment('红包数量') INT(11)"` + RedPacketBalanceNums int `json:"red_packet_balance_nums" xorm:"not null default 1 comment('红包剩余数量') INT(11)"` + State int `json:"state" xorm:"not null default 1 comment('红包状态(0:未领取 1:领取中 2:领取完 3:已过期)') TINYINT(1)"` + WaitDrawUserIds string `json:"wait_draw_user_ids" xorm:"not null comment('待领取用户id(逗号分割)') VARCHAR(255)"` + WaitDrawImUserIds string `json:"wait_draw_im_user_ids" xorm:"not null comment('待领取im用户id(逗号分割)') VARCHAR(255)"` + ReceivedUserIds string `json:"received_user_ids" xorm:"not null comment('已领取用户id(逗号分割)') VARCHAR(255)"` + ReceivedImUserIds string `json:"received_im_user_ids" xorm:"not null comment('已领取用户id(逗号分割)') VARCHAR(255)"` + ReceivedUserAmount string `json:"received_user_amount" xorm:"not null comment('已领取用户金额(逗号分割)') VARCHAR(255)"` + ReceivedTimes string `json:"received_times" xorm:"not null comment('已领取时间(逗号分割)') VARCHAR(255)"` + CreateTime time.Time `json:"create_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` + UpdateTime time.Time `json:"update_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` + ImData string `json:"im_data" xorm:"comment('im数据') TEXT"` +}