From 397071ea1aed524ee5c59a13ab921bcbd7cd4dfb Mon Sep 17 00:00:00 2001 From: lijikun Date: Wed, 25 Dec 2024 20:20:00 +0800 Subject: [PATCH] =?UTF-8?q?12.25=E6=97=A5=E7=94=9F=E6=88=90service,?= =?UTF-8?q?=E7=BC=96=E5=86=99=E6=9F=A5=E8=AF=A2=E6=8B=A5=E6=9C=89=E5=8D=A1?= =?UTF-8?q?=E5=88=B8=E7=9A=84=E7=94=A8=E6=88=B7,=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8D=A1=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/couponusers/couponUsers.go | 19 ++++ internal/cmd/cmd.go | 4 +- internal/controller/couponusers/couponUsers.go | 47 +++++++++ internal/dao/coupon.go | 27 +++++ internal/dao/coupon_users.go | 27 +++++ internal/dao/internal/coupon.go | 89 ++++++++++++++++ internal/dao/internal/coupon_users.go | 83 +++++++++++++++ internal/dao/internal/member_info.go | 139 +++++++++++++++++++++++++ internal/dao/member_info.go | 27 +++++ internal/logic/couponusers/couponUsers.go | 113 ++++++++++++++++++++ internal/logic/logic.go | 8 ++ internal/model/do/coupon.go | 24 +++++ internal/model/do/coupon_users.go | 20 ++++ internal/model/do/member_info.go | 49 +++++++++ internal/model/entity/coupon.go | 22 ++++ internal/model/entity/coupon_users.go | 15 +++ internal/model/entity/member_info.go | 47 +++++++++ internal/service/couponusers.go | 43 ++++++++ 18 files changed, 802 insertions(+), 1 deletion(-) create mode 100644 api/v1/couponusers/couponUsers.go create mode 100644 internal/controller/couponusers/couponUsers.go create mode 100644 internal/dao/coupon.go create mode 100644 internal/dao/coupon_users.go create mode 100644 internal/dao/internal/coupon.go create mode 100644 internal/dao/internal/coupon_users.go create mode 100644 internal/dao/internal/member_info.go create mode 100644 internal/dao/member_info.go create mode 100644 internal/logic/couponusers/couponUsers.go create mode 100644 internal/model/do/coupon.go create mode 100644 internal/model/do/coupon_users.go create mode 100644 internal/model/do/member_info.go create mode 100644 internal/model/entity/coupon.go create mode 100644 internal/model/entity/coupon_users.go create mode 100644 internal/model/entity/member_info.go create mode 100644 internal/service/couponusers.go diff --git a/api/v1/couponusers/couponUsers.go b/api/v1/couponusers/couponUsers.go new file mode 100644 index 0000000..baf834d --- /dev/null +++ b/api/v1/couponusers/couponUsers.go @@ -0,0 +1,19 @@ +package couponusers + +type GetCouponUsersReq struct { + CouponId int `json:"couponId" dc:"卡券id"` + Jwcode int `json:"jwcode" dc:"查询条件中的精网号"` + Name string `json:"name" dc:"查询条件中的名字"` +} + +type GetCouponUsersRes struct { + Name string `json:"name" dc:"姓名"` + Jwcode int `json:"jwcode" dc:"精网号"` + DeptName string `json:"deptName" dc:"部门"` + ShopName string `json:"shopName" dc:"门店"` +} + +type DelCouponUserByJwcodeReq struct { + CouponId int `json:"couponId" dc:"卡券id"` + Jwcode int `json:"jwcode" dc:"精网号"` +} diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 4c9236b..8eb49a9 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -1,6 +1,7 @@ package cmd import ( + "CouponBackendGo/internal/controller/couponusers" "context" "github.com/gogf/gf/v2/frame/g" @@ -16,7 +17,8 @@ var ( Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { s := g.Server() s.Group("/api/coupon_backend", func(group *ghttp.RouterGroup) { - + group.POST("/get-coupon-users", couponusers.NewCouponUsers().GetCouponUsers) + group.POST("delete-coupon-user", couponusers.NewCouponUsers().DeleteCouponUserByJwcode) }) s.Run() return nil diff --git a/internal/controller/couponusers/couponUsers.go b/internal/controller/couponusers/couponUsers.go new file mode 100644 index 0000000..0a4acc2 --- /dev/null +++ b/internal/controller/couponusers/couponUsers.go @@ -0,0 +1,47 @@ +package couponusers + +import ( + "CouponBackendGo/api/v1/couponusers" + "CouponBackendGo/internal/model/dto" + "CouponBackendGo/internal/service" + "github.com/gogf/gf/v2/net/ghttp" +) + +type CouponUsers struct{} + +func NewCouponUsers() *CouponUsers { + return &CouponUsers{} +} + +func (c *CouponUsers) GetCouponUsers(r *ghttp.Request) { + var req *couponusers.GetCouponUsersReq + if err := r.Parse(&req); err != nil { + r.Response.WriteJsonExit(dto.Error(err.Error())) + } + result, err := service.CouponUsers().GetCouponUsersByCondition(r.Context(), req.CouponId, req.Jwcode, req.Name) + if err != nil { + r.Response.WriteJsonExit(dto.Error(err.Error())) + } + if result == nil { + r.Response.WriteJsonExit(dto.Error("没有符合条件的用户")) + } + r.Response.WriteJsonExit(dto.SuccessWithData(result)) + +} + +func (c *CouponUsers) DeleteCouponUserByJwcode(r *ghttp.Request) { + var req *couponusers.DelCouponUserByJwcodeReq + if err := r.Parse(&req); err != nil { + r.Response.WriteJsonExit(dto.Error(err.Error())) + } + result, err := service.CouponUsers().DeleteCouponUserByJwcode(r.Context(), req.CouponId, req.Jwcode) + if err != nil { + r.Response.WriteJsonExit(dto.Error(err.Error())) + } + affected, err := result.RowsAffected() + if affected == 0 { + r.Response.WriteJsonExit(dto.Error("删除失败,删除了0条")) + } + r.Response.WriteJsonExit(dto.SuccessWithMsg("删除成功")) + //r.Response.WriteJsonExit(dto.SuccessWithData(result)) +} diff --git a/internal/dao/coupon.go b/internal/dao/coupon.go new file mode 100644 index 0000000..6755e8c --- /dev/null +++ b/internal/dao/coupon.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "CouponBackendGo/internal/dao/internal" +) + +// internalCouponDao is internal type for wrapping internal DAO implements. +type internalCouponDao = *internal.CouponDao + +// couponDao is the data access object for table coupon. +// You can define custom methods on it to extend its functionality as you wish. +type couponDao struct { + internalCouponDao +} + +var ( + // Coupon is globally public accessible object for table coupon operations. + Coupon = couponDao{ + internal.NewCouponDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/dao/coupon_users.go b/internal/dao/coupon_users.go new file mode 100644 index 0000000..ecfee65 --- /dev/null +++ b/internal/dao/coupon_users.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "CouponBackendGo/internal/dao/internal" +) + +// internalCouponUsersDao is internal type for wrapping internal DAO implements. +type internalCouponUsersDao = *internal.CouponUsersDao + +// couponUsersDao is the data access object for table coupon_users. +// You can define custom methods on it to extend its functionality as you wish. +type couponUsersDao struct { + internalCouponUsersDao +} + +var ( + // CouponUsers is globally public accessible object for table coupon_users operations. + CouponUsers = couponUsersDao{ + internal.NewCouponUsersDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/dao/internal/coupon.go b/internal/dao/internal/coupon.go new file mode 100644 index 0000000..58b2a99 --- /dev/null +++ b/internal/dao/internal/coupon.go @@ -0,0 +1,89 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// CouponDao is the data access object for table coupon. +type CouponDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns CouponColumns // columns contains all the column names of Table for convenient usage. +} + +// CouponColumns defines and stores column names for table coupon. +type CouponColumns struct { + Id string // + Title string // + Cover string // + ImgUrl string // + StartTime string // 到期时间 + EndTime string // + Deleted string // + CreatedAt string // + UpdatedAt string // +} + +// couponColumns holds the columns for table coupon. +var couponColumns = CouponColumns{ + Id: "id", + Title: "title", + Cover: "cover", + ImgUrl: "img_url", + StartTime: "start_time", + EndTime: "end_time", + Deleted: "deleted", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} + +// NewCouponDao creates and returns a new DAO object for table data access. +func NewCouponDao() *CouponDao { + return &CouponDao{ + group: "default", + table: "coupon", + columns: couponColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *CouponDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *CouponDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *CouponDao) Columns() CouponColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *CouponDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *CouponDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *CouponDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/dao/internal/coupon_users.go b/internal/dao/internal/coupon_users.go new file mode 100644 index 0000000..b0d66ef --- /dev/null +++ b/internal/dao/internal/coupon_users.go @@ -0,0 +1,83 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// CouponUsersDao is the data access object for table coupon_users. +type CouponUsersDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns CouponUsersColumns // columns contains all the column names of Table for convenient usage. +} + +// CouponUsersColumns defines and stores column names for table coupon_users. +type CouponUsersColumns struct { + Id string // + Jwcode string // + Time string // 领取时间 + CouponId string // 优惠券id + Code string // + State string // 0 未使用 1 已使用 +} + +// couponUsersColumns holds the columns for table coupon_users. +var couponUsersColumns = CouponUsersColumns{ + Id: "id", + Jwcode: "jwcode", + Time: "time", + CouponId: "coupon_id", + Code: "code", + State: "state", +} + +// NewCouponUsersDao creates and returns a new DAO object for table data access. +func NewCouponUsersDao() *CouponUsersDao { + return &CouponUsersDao{ + group: "default", + table: "coupon_users", + columns: couponUsersColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *CouponUsersDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *CouponUsersDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *CouponUsersDao) Columns() CouponUsersColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *CouponUsersDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *CouponUsersDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *CouponUsersDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/dao/internal/member_info.go b/internal/dao/internal/member_info.go new file mode 100644 index 0000000..6e3d9f5 --- /dev/null +++ b/internal/dao/internal/member_info.go @@ -0,0 +1,139 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// MemberInfoDao is the data access object for table member_info. +type MemberInfoDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns MemberInfoColumns // columns contains all the column names of Table for convenient usage. +} + +// MemberInfoColumns defines and stores column names for table member_info. +type MemberInfoColumns struct { + Id string // + Jwcode string // + Name string // + Sex string // 0:未知,1:男,2:女 + Avatar string // 用户头像 + Widget string // 头像挂件 + DeptId string // + DeptName string // + ShopId string // + ShopName string // + MembershipTime string // + LiveLock string // 0:解锁 1:锁住 + LocMarket string // 用户市场归属 + Level string // 等级 + LevelIcon string // 等级图标 + Star string // 星级 + AccountOwner string // + AccountOwnerText string // + Employee string // 1:员工 + Dachang string // 0:不是大厂员工 1:是大厂员工 + BoguMember string // 1:博股会员 + LearningIcon string // 学习等级icon + Mobile string // 手机号 + UserIdentity string // 0:无认证 1:红V 2:蓝V 3:黄V + UserIdentityTitle string // 用户身份头衔 + Openid string // 微信openid + UserRole string // 用户身份(1:网员 2:非网) + IsBlacklist string // 是否是黑名单用户 + IsLecturer string // 讲师 + Shenqiangshou string // 神枪手 + Huanqiu string // 环球 + Age string // 年纪 + CreatedAt string // + UpdatedAt string // +} + +// memberInfoColumns holds the columns for table member_info. +var memberInfoColumns = MemberInfoColumns{ + Id: "id", + Jwcode: "jwcode", + Name: "name", + Sex: "sex", + Avatar: "avatar", + Widget: "widget", + DeptId: "deptId", + DeptName: "deptName", + ShopId: "shopId", + ShopName: "shopName", + MembershipTime: "membership_time", + LiveLock: "live_lock", + LocMarket: "loc_market", + Level: "level", + LevelIcon: "level_icon", + Star: "star", + AccountOwner: "account_owner", + AccountOwnerText: "account_owner_text", + Employee: "employee", + Dachang: "dachang", + BoguMember: "bogu_member", + LearningIcon: "learning_icon", + Mobile: "mobile", + UserIdentity: "user_identity", + UserIdentityTitle: "user_identity_title", + Openid: "openid", + UserRole: "user_role", + IsBlacklist: "is_blacklist", + IsLecturer: "is_lecturer", + Shenqiangshou: "shenqiangshou", + Huanqiu: "huanqiu", + Age: "age", + CreatedAt: "created_at", + UpdatedAt: "updated_at", +} + +// NewMemberInfoDao creates and returns a new DAO object for table data access. +func NewMemberInfoDao() *MemberInfoDao { + return &MemberInfoDao{ + group: "default", + table: "member_info", + columns: memberInfoColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *MemberInfoDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *MemberInfoDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *MemberInfoDao) Columns() MemberInfoColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *MemberInfoDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *MemberInfoDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *MemberInfoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/dao/member_info.go b/internal/dao/member_info.go new file mode 100644 index 0000000..20ed4a3 --- /dev/null +++ b/internal/dao/member_info.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "CouponBackendGo/internal/dao/internal" +) + +// internalMemberInfoDao is internal type for wrapping internal DAO implements. +type internalMemberInfoDao = *internal.MemberInfoDao + +// memberInfoDao is the data access object for table member_info. +// You can define custom methods on it to extend its functionality as you wish. +type memberInfoDao struct { + internalMemberInfoDao +} + +var ( + // MemberInfo is globally public accessible object for table member_info operations. + MemberInfo = memberInfoDao{ + internal.NewMemberInfoDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/logic/couponusers/couponUsers.go b/internal/logic/couponusers/couponUsers.go new file mode 100644 index 0000000..21689f1 --- /dev/null +++ b/internal/logic/couponusers/couponUsers.go @@ -0,0 +1,113 @@ +package couponusers + +import ( + "CouponBackendGo/api/v1/couponusers" + "CouponBackendGo/internal/dao" + "CouponBackendGo/internal/service" + "context" + "database/sql" + "encoding/json" + "errors" + "fmt" + "github.com/gogf/gf/v2/frame/g" + "strings" +) + +type sCouponUsers struct{} + +func init() { + service.RegisterCouponUsers(&sCouponUsers{}) +} + +// 根据优惠券id查看拥有优惠券的用户 +func (s *sCouponUsers) GetCouponUsersByCondition(ctx context.Context, couponId, jwcode int, name string) (users []couponusers.GetCouponUsersRes, err error) { + //从redis中获取数据但不返回 + value, _ := g.Redis().Get(ctx, fmt.Sprintf("%d CouponUsers", couponId)) + if value.String() != "" { + err = json.Unmarshal(value.Bytes(), &users) + if err != nil { + return nil, errors.New("redis中数据解析失败") + } + } else { + + /*查询所有数据*/ + //在coupon_users中查询出对应的jwcode + err = dao.CouponUsers.Ctx(ctx).Fields("jwcode"). + Where("coupon_id = ", couponId).Scan(&users) + if err != nil { + return nil, errors.New("根据卡券id搜索jwcode失败") + } + //根据jwcode查询用户信息 + for i, userInfo := range users { + err = dao.MemberInfo.Ctx(ctx).Fields("jwcode", "name", "deptName", "shopName"). + Where("jwcode = ?", userInfo.Jwcode).Scan(&users[i]) + if err != nil { + return nil, errors.New("根据jwcode搜索用户信息失败") + } + } + /*查询所有数据*/ + + //将数据存入redis + UsersMarshal, _ := json.Marshal(users) + _, err = g.Redis().Set(ctx, fmt.Sprintf("%d CouponUsers", couponId), UsersMarshal) + if err != nil { + return nil, errors.New("将数据存入redis失败") + } + + } + + if jwcode != 0 && name == "" { + var result []couponusers.GetCouponUsersRes + for _, user := range users { + if user.Jwcode == jwcode { + result = append(result, user) + } + } + return result, err + } else if jwcode == 0 && name != "" { + var result []couponusers.GetCouponUsersRes + for _, user := range users { + if strings.Contains(user.Name, name) { + result = append(result, user) + } + } + return result, err + } else if jwcode != 0 && name != "" { + var result []couponusers.GetCouponUsersRes + for _, user := range users { + if user.Jwcode == jwcode && strings.Contains(user.Name, name) { + result = append(result, user) + } + } + return result, err + } + + return users, err +} + +// 根据jwcode,优惠券id删除用户 +func (s *sCouponUsers) DeleteCouponUserByJwcode(ctx context.Context, couponId, jwcode int) (result sql.Result, err error) { + if jwcode == 0 { + return nil, errors.New("jwcode不能为空") + } + if couponId == 0 { + return nil, errors.New("couponId不能为空") + } + result, err = dao.CouponUsers.Ctx(ctx).Where("coupon_id = ?", couponId).Where("jwcode = ?", jwcode).Delete() + if err != nil { + return nil, errors.New("删除用户失败") + } + return result, err +} + +// 通过excel导入精网号 +func (s *sCouponUsers) InsertJwcodeByExcel(ctx context.Context) { + + return +} + +// 根据精网号发放用户优惠券 +func (s *sCouponUsers) InsertCouponUserByJwcode(ctx context.Context) { + + return +} diff --git a/internal/logic/logic.go b/internal/logic/logic.go index 4c79103..64cb80c 100644 --- a/internal/logic/logic.go +++ b/internal/logic/logic.go @@ -1 +1,9 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + package logic + +import ( + _ "CouponBackendGo/internal/logic/couponusers" +) diff --git a/internal/model/do/coupon.go b/internal/model/do/coupon.go new file mode 100644 index 0000000..47fc0e8 --- /dev/null +++ b/internal/model/do/coupon.go @@ -0,0 +1,24 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// Coupon is the golang structure of table coupon for DAO operations like Where/Data. +type Coupon struct { + g.Meta `orm:"table:coupon, do:true"` + Id interface{} // + Title interface{} // + Cover interface{} // + ImgUrl interface{} // + StartTime interface{} // 到期时间 + EndTime interface{} // + Deleted interface{} // + CreatedAt *gtime.Time // + UpdatedAt *gtime.Time // +} diff --git a/internal/model/do/coupon_users.go b/internal/model/do/coupon_users.go new file mode 100644 index 0000000..8aa0d1b --- /dev/null +++ b/internal/model/do/coupon_users.go @@ -0,0 +1,20 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// CouponUsers is the golang structure of table coupon_users for DAO operations like Where/Data. +type CouponUsers struct { + g.Meta `orm:"table:coupon_users, do:true"` + Id interface{} // + Jwcode interface{} // + Time interface{} // 领取时间 + CouponId interface{} // 优惠券id + Code interface{} // + State interface{} // 0 未使用 1 已使用 +} diff --git a/internal/model/do/member_info.go b/internal/model/do/member_info.go new file mode 100644 index 0000000..28988d6 --- /dev/null +++ b/internal/model/do/member_info.go @@ -0,0 +1,49 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// MemberInfo is the golang structure of table member_info for DAO operations like Where/Data. +type MemberInfo struct { + g.Meta `orm:"table:member_info, do:true"` + Id interface{} // + Jwcode interface{} // + Name interface{} // + Sex interface{} // 0:未知,1:男,2:女 + Avatar interface{} // 用户头像 + Widget interface{} // 头像挂件 + DeptId interface{} // + DeptName interface{} // + ShopId interface{} // + ShopName interface{} // + MembershipTime *gtime.Time // + LiveLock interface{} // 0:解锁 1:锁住 + LocMarket interface{} // 用户市场归属 + Level interface{} // 等级 + LevelIcon interface{} // 等级图标 + Star interface{} // 星级 + AccountOwner interface{} // + AccountOwnerText interface{} // + Employee interface{} // 1:员工 + Dachang interface{} // 0:不是大厂员工 1:是大厂员工 + BoguMember interface{} // 1:博股会员 + LearningIcon interface{} // 学习等级icon + Mobile interface{} // 手机号 + UserIdentity interface{} // 0:无认证 1:红V 2:蓝V 3:黄V + UserIdentityTitle interface{} // 用户身份头衔 + Openid interface{} // 微信openid + UserRole interface{} // 用户身份(1:网员 2:非网) + IsBlacklist interface{} // 是否是黑名单用户 + IsLecturer interface{} // 讲师 + Shenqiangshou interface{} // 神枪手 + Huanqiu interface{} // 环球 + Age interface{} // 年纪 + CreatedAt *gtime.Time // + UpdatedAt *gtime.Time // +} diff --git a/internal/model/entity/coupon.go b/internal/model/entity/coupon.go new file mode 100644 index 0000000..c71209d --- /dev/null +++ b/internal/model/entity/coupon.go @@ -0,0 +1,22 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// Coupon is the golang structure for table coupon. +type Coupon struct { + Id uint `json:"id" orm:"id" description:""` // + Title string `json:"title" orm:"title" description:""` // + Cover string `json:"cover" orm:"cover" description:""` // + ImgUrl string `json:"imgUrl" orm:"img_url" description:""` // + StartTime int `json:"startTime" orm:"start_time" description:"到期时间"` // 到期时间 + EndTime int `json:"endTime" orm:"end_time" description:""` // + Deleted int `json:"deleted" orm:"deleted" description:""` // + CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` // + UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` // +} diff --git a/internal/model/entity/coupon_users.go b/internal/model/entity/coupon_users.go new file mode 100644 index 0000000..967d382 --- /dev/null +++ b/internal/model/entity/coupon_users.go @@ -0,0 +1,15 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// CouponUsers is the golang structure for table coupon_users. +type CouponUsers struct { + Id uint `json:"id" orm:"id" description:""` // + Jwcode string `json:"jwcode" orm:"jwcode" description:""` // + Time int `json:"time" orm:"time" description:"领取时间"` // 领取时间 + CouponId int `json:"couponId" orm:"coupon_id" description:"优惠券id"` // 优惠券id + Code string `json:"code" orm:"code" description:""` // + State int `json:"state" orm:"state" description:"0 未使用 1 已使用"` // 0 未使用 1 已使用 +} diff --git a/internal/model/entity/member_info.go b/internal/model/entity/member_info.go new file mode 100644 index 0000000..0fd0368 --- /dev/null +++ b/internal/model/entity/member_info.go @@ -0,0 +1,47 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// MemberInfo is the golang structure for table member_info. +type MemberInfo struct { + Id int `json:"id" orm:"id" description:""` // + Jwcode int `json:"jwcode" orm:"jwcode" description:""` // + Name string `json:"name" orm:"name" description:""` // + Sex int `json:"sex" orm:"sex" description:"0:未知,1:男,2:女"` // 0:未知,1:男,2:女 + Avatar string `json:"avatar" orm:"avatar" description:"用户头像"` // 用户头像 + Widget string `json:"widget" orm:"widget" description:"头像挂件"` // 头像挂件 + DeptId string `json:"deptId" orm:"deptId" description:""` // + DeptName string `json:"deptName" orm:"deptName" description:""` // + ShopId string `json:"shopId" orm:"shopId" description:""` // + ShopName string `json:"shopName" orm:"shopName" description:""` // + MembershipTime *gtime.Time `json:"membershipTime" orm:"membership_time" description:""` // + LiveLock int `json:"liveLock" orm:"live_lock" description:"0:解锁 1:锁住"` // 0:解锁 1:锁住 + LocMarket string `json:"locMarket" orm:"loc_market" description:"用户市场归属"` // 用户市场归属 + Level int `json:"level" orm:"level" description:"等级"` // 等级 + LevelIcon string `json:"levelIcon" orm:"level_icon" description:"等级图标"` // 等级图标 + Star int `json:"star" orm:"star" description:"星级"` // 星级 + AccountOwner string `json:"accountOwner" orm:"account_owner" description:""` // + AccountOwnerText string `json:"accountOwnerText" orm:"account_owner_text" description:""` // + Employee int `json:"employee" orm:"employee" description:"1:员工"` // 1:员工 + Dachang int `json:"dachang" orm:"dachang" description:"0:不是大厂员工 1:是大厂员工"` // 0:不是大厂员工 1:是大厂员工 + BoguMember int `json:"boguMember" orm:"bogu_member" description:"1:博股会员"` // 1:博股会员 + LearningIcon string `json:"learningIcon" orm:"learning_icon" description:"学习等级icon"` // 学习等级icon + Mobile string `json:"mobile" orm:"mobile" description:"手机号"` // 手机号 + UserIdentity int `json:"userIdentity" orm:"user_identity" description:"0:无认证 1:红V 2:蓝V 3:黄V"` // 0:无认证 1:红V 2:蓝V 3:黄V + UserIdentityTitle string `json:"userIdentityTitle" orm:"user_identity_title" description:"用户身份头衔"` // 用户身份头衔 + Openid string `json:"openid" orm:"openid" description:"微信openid"` // 微信openid + UserRole int `json:"userRole" orm:"user_role" description:"用户身份(1:网员 2:非网)"` // 用户身份(1:网员 2:非网) + IsBlacklist int `json:"isBlacklist" orm:"is_blacklist" description:"是否是黑名单用户"` // 是否是黑名单用户 + IsLecturer int `json:"isLecturer" orm:"is_lecturer" description:"讲师"` // 讲师 + Shenqiangshou int `json:"shenqiangshou" orm:"shenqiangshou" description:"神枪手"` // 神枪手 + Huanqiu int `json:"huanqiu" orm:"huanqiu" description:"环球"` // 环球 + Age uint `json:"age" orm:"age" description:"年纪"` // 年纪 + CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` // + UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` // +} diff --git a/internal/service/couponusers.go b/internal/service/couponusers.go new file mode 100644 index 0000000..6f72c5f --- /dev/null +++ b/internal/service/couponusers.go @@ -0,0 +1,43 @@ +// ================================================================================ +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "CouponBackendGo/api/v1/couponusers" + "context" + "database/sql" +) + +type ( + ICouponUsers interface { + // 根据优惠券id查看拥有优惠券的用户 + GetCouponUsersByCondition(ctx context.Context, couponId int, jwcode int, name string) (users []couponusers.GetCouponUsersRes, err error) + // 根据jwcode,优惠券id删除用户 + DeleteCouponUserByJwcode(ctx context.Context, couponId int, jwcode int) (result sql.Result, err error) + // 通过excel导入精网号 + InsertJwcodeByExcel(ctx context.Context) + // 根据精网号发放用户优惠券 + InsertCouponUserByJwcode(ctx context.Context) + // 原来的(不全) + // 根据优惠券id查看拥有优惠券的用户 + GetCouponUsersByCondition1(ctx context.Context, couponId int, jwcode int, name string) (users []couponusers.GetCouponUsersRes, err error) + } +) + +var ( + localCouponUsers ICouponUsers +) + +func CouponUsers() ICouponUsers { + if localCouponUsers == nil { + panic("implement not found for interface ICouponUsers, forgot register?") + } + return localCouponUsers +} + +func RegisterCouponUsers(i ICouponUsers) { + localCouponUsers = i +}