实现商户注册、管理员审核商户申请接口
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
"server/internal/controller/admin"
|
||||
"server/internal/controller/auth"
|
||||
"server/internal/controller/menu"
|
||||
"server/internal/controller/merchant"
|
||||
"server/internal/controller/role"
|
||||
"server/internal/controller/wx"
|
||||
"server/internal/middleware"
|
||||
@ -34,6 +35,7 @@ var (
|
||||
admin.NewV1(),
|
||||
role.NewV1(),
|
||||
menu.NewV1(),
|
||||
merchant.NewV1(),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,8 +1 @@
|
||||
package consts
|
||||
|
||||
const (
|
||||
UserRoleCode = "user"
|
||||
AdminRoleCode = "admin"
|
||||
MerchantRoleCode = "merchant"
|
||||
StoreRoleCode = "store"
|
||||
)
|
||||
|
||||
20
internal/consts/merchant.go
Normal file
20
internal/consts/merchant.go
Normal file
@ -0,0 +1,20 @@
|
||||
package consts
|
||||
|
||||
// 商户状态
|
||||
const (
|
||||
MerchantNormalStatus = iota + 1
|
||||
MerchantDisabledStatus
|
||||
)
|
||||
|
||||
// 商户审核状态
|
||||
const (
|
||||
MerchantPendingReview = iota
|
||||
MerchantReviewPassed
|
||||
MerchantReviewRejected
|
||||
)
|
||||
|
||||
// 商户注册类型
|
||||
const (
|
||||
MerchantRegisterByAdmin = iota + 1
|
||||
MerchantRegisterBySelf
|
||||
)
|
||||
7
internal/consts/merchant_admin.go
Normal file
7
internal/consts/merchant_admin.go
Normal file
@ -0,0 +1,7 @@
|
||||
package consts
|
||||
|
||||
// 商户管理员状态
|
||||
const (
|
||||
MerchantAdministratorEnable = iota + 1
|
||||
MerchantAdministratorDisable
|
||||
)
|
||||
14
internal/consts/role.go
Normal file
14
internal/consts/role.go
Normal file
@ -0,0 +1,14 @@
|
||||
package consts
|
||||
|
||||
const (
|
||||
GuestRoleCode = "guest"
|
||||
UserRoleCode = "user"
|
||||
AdminRoleCode = "admin"
|
||||
MerchantRoleCode = "merchant"
|
||||
StoreRoleCode = "store"
|
||||
)
|
||||
|
||||
const (
|
||||
RoleEnable = iota + 1
|
||||
RoleDisable
|
||||
)
|
||||
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AdminInfo(ctx context.Context, req *v1.AdminInfoReq) (res *v1.AdminInfoRes, err error) {
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("userId").Int()
|
||||
userId := g.RequestFromCtx(ctx).GetCtxVar("userId").Int64()
|
||||
out, err := service.Admin().Info(ctx, &model.AdminInfoIn{Id: userId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
16
internal/controller/auth/auth_v1_merchant_code.go
Normal file
16
internal/controller/auth/auth_v1_merchant_code.go
Normal file
@ -0,0 +1,16 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) MerchantCode(ctx context.Context, req *v1.MerchantCodeReq) (res *v1.MerchantCodeRes, err error) {
|
||||
if _, err = service.MerchantAdmin().Code(ctx, &model.MerchantAdminCodeIn{Phone: req.Phone}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.MerchantCodeRes{}, nil
|
||||
}
|
||||
@ -2,13 +2,16 @@ package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) MerchantLogin(ctx context.Context, req *v1.MerchantLoginReq) (res *v1.MerchantLoginRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
out, err := service.MerchantAdmin().Login(ctx, &model.MerchantLoginIn{Password: req.Password, Username: req.Username})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.MerchantLoginRes{Token: out.Token}, nil
|
||||
}
|
||||
|
||||
20
internal/controller/auth/auth_v1_merchant_register.go
Normal file
20
internal/controller/auth/auth_v1_merchant_register.go
Normal file
@ -0,0 +1,20 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) MerchantRegister(ctx context.Context, req *v1.MerchantRegisterReq) (res *v1.MerchantRegisterRes, err error) {
|
||||
out, err := service.MerchantAdmin().Register(ctx, &model.MerchantAdminRegisterIn{Username: req.Username, Password: req.Password, Phone: req.Phone, ApplicationReason: req.ApplicationReason, Code: req.Code})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.MerchantRegisterRes{
|
||||
Msg: "申请成功, 等待系统管理员审核申请",
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
}
|
||||
@ -2,4 +2,4 @@
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package roleMenu
|
||||
package merchant
|
||||
@ -2,14 +2,14 @@
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package roleMenu
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"server/api/roleMenu"
|
||||
"server/api/merchant"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() roleMenu.IRoleMenuV1 {
|
||||
func NewV1() merchant.IMerchantV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
19
internal/controller/merchant/merchant_v1_audit.go
Normal file
19
internal/controller/merchant/merchant_v1_audit.go
Normal file
@ -0,0 +1,19 @@
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/merchant/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Audit(ctx context.Context, req *v1.AuditReq) (res *v1.AuditRes, err error) {
|
||||
adminId := g.RequestFromCtx(ctx).GetCtxVar("adminId").Int64()
|
||||
_, err = service.Merchant().Audit(ctx, &model.MerchantAuditIn{Id: req.Id, AuditStatus: req.AuditStatus, AuditRemark: req.AuditRemark, AdminId: adminId, RejectReason: req.RejectReason})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AuditRes{}, nil
|
||||
}
|
||||
14
internal/controller/merchant/merchant_v1_create.go
Normal file
14
internal/controller/merchant/merchant_v1_create.go
Normal file
@ -0,0 +1,14 @@
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
|
||||
"server/api/merchant/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
}
|
||||
@ -1,20 +1,20 @@
|
||||
package roleMenu
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/roleMenu/v1"
|
||||
"server/api/merchant/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
|
||||
list, err := service.RoleMenu().List(ctx, &model.RoleMenuListInput{RoleId: req.RoleId})
|
||||
out, err := service.Merchant().List(ctx, &model.MerchantListIn{Page: req.Page, Size: req.Size, AuditStatus: req.AuditStatus, Status: req.Status})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ListRes{
|
||||
List: list.List,
|
||||
Total: list.Total,
|
||||
List: out.List,
|
||||
Total: out.Total,
|
||||
}, nil
|
||||
}
|
||||
14
internal/controller/merchant/merchant_v1_update.go
Normal file
14
internal/controller/merchant/merchant_v1_update.go
Normal file
@ -0,0 +1,14 @@
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
|
||||
"server/api/merchant/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
}
|
||||
5
internal/controller/merchantAdmin/merchantAdmin.go
Normal file
5
internal/controller/merchantAdmin/merchantAdmin.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package merchantAdmin
|
||||
15
internal/controller/merchantAdmin/merchantAdmin_new.go
Normal file
15
internal/controller/merchantAdmin/merchantAdmin_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package merchantAdmin
|
||||
|
||||
import (
|
||||
"server/api/merchantAdmin"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() merchantAdmin.IMerchantAdminV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package merchantAdmin
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
|
||||
"server/api/merchantAdmin/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) MerchantAdminInfo(ctx context.Context, req *v1.MerchantAdminInfoReq) (res *v1.MerchantAdminInfoRes, err error) {
|
||||
return nil, gerror.NewCode(gcode.CodeNotImplemented)
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package roleMenu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/roleMenu/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) SaveRoleMenu(ctx context.Context, req *v1.SaveRoleMenuReq) (res *v1.SaveRoleMenuRes, err error) {
|
||||
out, err := service.RoleMenu().Save(ctx, &model.RoleMenuSaveInput{RoleId: req.RoleId, MenuIds: req.MenuIds})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.SaveRoleMenuRes{
|
||||
Success: out.Success,
|
||||
}, nil
|
||||
|
||||
}
|
||||
@ -33,6 +33,9 @@ type MerchantAdminsColumns struct {
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
IsPrimary string // 是否主账号:0=否,1=是
|
||||
LastLoginIp string // 最后登录IP
|
||||
RoleId string // 角色ID
|
||||
}
|
||||
|
||||
// merchantAdminsColumns holds the columns for the table merchant_admins.
|
||||
@ -50,6 +53,9 @@ var merchantAdminsColumns = MerchantAdminsColumns{
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
IsPrimary: "is_primary",
|
||||
LastLoginIp: "last_login_ip",
|
||||
RoleId: "role_id",
|
||||
}
|
||||
|
||||
// NewMerchantAdminsDao creates and returns a new DAO object for table data access.
|
||||
|
||||
@ -20,36 +20,52 @@ type MerchantsDao struct {
|
||||
|
||||
// MerchantsColumns defines and stores column names for the table merchants.
|
||||
type MerchantsColumns struct {
|
||||
Id string // 商户ID
|
||||
Name string // 商户名称
|
||||
BusinessLicense string // 营业执照号
|
||||
LegalPerson string // 法人姓名
|
||||
ContactName string // 联系人姓名
|
||||
ContactPhone string // 联系人电话
|
||||
ContactEmail string // 联系人邮箱
|
||||
Address string // 商户地址
|
||||
Status string // 状态:1=正常,2=禁用,3=待审核
|
||||
ExpireAt string // 服务到期时间
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
Id string // 商户ID
|
||||
Name string // 商户名称
|
||||
BusinessLicense string // 营业执照号
|
||||
LegalPerson string // 法人姓名
|
||||
ContactName string // 联系人姓名
|
||||
ContactPhone string // 联系人电话
|
||||
ContactEmail string // 联系人邮箱
|
||||
Address string // 商户地址
|
||||
Status string // 状态:1=正常,2=禁用
|
||||
ExpireAt string // 服务到期时间
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
ApplicationReason string // 申请理由
|
||||
CreatedBy string // 创建人ID
|
||||
CreatedByType string // 创建人类型:1=系统管理员,2=商户注册
|
||||
AuditStatus string // 审核状态:0=待审核,1=审核通过,2=审核拒绝
|
||||
AuditBy string // 审核人ID
|
||||
AuditAt string // 审核时间
|
||||
AuditRemark string // 审核备注
|
||||
RejectReason string // 拒绝原因
|
||||
}
|
||||
|
||||
// merchantsColumns holds the columns for the table merchants.
|
||||
var merchantsColumns = MerchantsColumns{
|
||||
Id: "id",
|
||||
Name: "name",
|
||||
BusinessLicense: "business_license",
|
||||
LegalPerson: "legal_person",
|
||||
ContactName: "contact_name",
|
||||
ContactPhone: "contact_phone",
|
||||
ContactEmail: "contact_email",
|
||||
Address: "address",
|
||||
Status: "status",
|
||||
ExpireAt: "expire_at",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
Id: "id",
|
||||
Name: "name",
|
||||
BusinessLicense: "business_license",
|
||||
LegalPerson: "legal_person",
|
||||
ContactName: "contact_name",
|
||||
ContactPhone: "contact_phone",
|
||||
ContactEmail: "contact_email",
|
||||
Address: "address",
|
||||
Status: "status",
|
||||
ExpireAt: "expire_at",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
ApplicationReason: "application_reason",
|
||||
CreatedBy: "created_by",
|
||||
CreatedByType: "created_by_type",
|
||||
AuditStatus: "audit_status",
|
||||
AuditBy: "audit_by",
|
||||
AuditAt: "audit_at",
|
||||
AuditRemark: "audit_remark",
|
||||
RejectReason: "reject_reason",
|
||||
}
|
||||
|
||||
// NewMerchantsDao creates and returns a new DAO object for table data access.
|
||||
|
||||
@ -33,6 +33,7 @@ type StoreAdminsColumns struct {
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
RoleId string // 角色ID
|
||||
}
|
||||
|
||||
// storeAdminsColumns holds the columns for the table store_admins.
|
||||
@ -50,6 +51,7 @@ var storeAdminsColumns = StoreAdminsColumns{
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
RoleId: "role_id",
|
||||
}
|
||||
|
||||
// NewStoreAdminsDao creates and returns a new DAO object for table data access.
|
||||
|
||||
@ -20,34 +20,32 @@ type StoresDao struct {
|
||||
|
||||
// StoresColumns defines and stores column names for the table stores.
|
||||
type StoresColumns struct {
|
||||
Id string // 门店ID
|
||||
MerchantId string // 所属商户ID
|
||||
Name string // 门店名称
|
||||
StoreCode string // 门店编号
|
||||
Address string // 门店地址
|
||||
ContactName string // 联系人姓名
|
||||
ContactPhone string // 联系人电话
|
||||
BusinessHours string // 营业时间
|
||||
Status string // 状态:1=正常营业,2=暂停营业,3=已关闭
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
Id string // 门店ID
|
||||
MerchantId string // 所属商户ID
|
||||
Name string // 门店名称
|
||||
StoreCode string // 门店编号
|
||||
Address string // 门店地址
|
||||
ContactName string // 联系人姓名
|
||||
ContactPhone string // 联系人电话
|
||||
Status string // 状态:1=正常营业,2=暂停营业,3=已关闭
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
}
|
||||
|
||||
// storesColumns holds the columns for the table stores.
|
||||
var storesColumns = StoresColumns{
|
||||
Id: "id",
|
||||
MerchantId: "merchant_id",
|
||||
Name: "name",
|
||||
StoreCode: "store_code",
|
||||
Address: "address",
|
||||
ContactName: "contact_name",
|
||||
ContactPhone: "contact_phone",
|
||||
BusinessHours: "business_hours",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
Id: "id",
|
||||
MerchantId: "merchant_id",
|
||||
Name: "name",
|
||||
StoreCode: "store_code",
|
||||
Address: "address",
|
||||
ContactName: "contact_name",
|
||||
ContactPhone: "contact_phone",
|
||||
Status: "status",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewStoresDao creates and returns a new DAO object for table data access.
|
||||
|
||||
@ -37,7 +37,7 @@ func checkAdmin() {
|
||||
Name: "系统管理员",
|
||||
Code: consts.AdminRoleCode,
|
||||
Description: "管理员角色",
|
||||
Status: 1,
|
||||
Status: consts.RoleEnable,
|
||||
IsDeletable: false,
|
||||
})
|
||||
} else {
|
||||
|
||||
@ -7,9 +7,8 @@ package logic
|
||||
import (
|
||||
_ "server/internal/logic/admin"
|
||||
_ "server/internal/logic/menu"
|
||||
_ "server/internal/logic/merchant"
|
||||
_ "server/internal/logic/merchantAdmin"
|
||||
_ "server/internal/logic/role"
|
||||
_ "server/internal/logic/roleMenu"
|
||||
_ "server/internal/logic/storeAdmin"
|
||||
_ "server/internal/logic/user"
|
||||
)
|
||||
|
||||
83
internal/logic/merchant/merchant.go
Normal file
83
internal/logic/merchant/merchant.go
Normal file
@ -0,0 +1,83 @@
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"server/internal/consts"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
)
|
||||
|
||||
type sMerchant struct {
|
||||
}
|
||||
|
||||
func New() service.IMerchant {
|
||||
return &sMerchant{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterMerchant(New())
|
||||
}
|
||||
|
||||
func (s *sMerchant) List(ctx context.Context, in *model.MerchantListIn) (out *model.MerchantListOut, err error) {
|
||||
list := make([]model.Merchant, 0)
|
||||
var total int
|
||||
orm := dao.Merchants.Ctx(ctx)
|
||||
if in.Status != 0 {
|
||||
orm = orm.Where(dao.Merchants.Columns().Status, in.Status)
|
||||
}
|
||||
if in.AuditStatus != 0 {
|
||||
orm = orm.Where(dao.Merchants.Columns().AuditStatus, in.AuditStatus)
|
||||
}
|
||||
if err = orm.Page(in.Page, in.Size).ScanAndCount(&list, &total, false); err != nil {
|
||||
return nil, ecode.Fail.Sub("查询商户列表失败")
|
||||
}
|
||||
return &model.MerchantListOut{
|
||||
List: list,
|
||||
Total: total,
|
||||
}, nil
|
||||
}
|
||||
func (s *sMerchant) Audit(ctx context.Context, in *model.MerchantAuditIn) (out *model.MerchantAuditOut, err error) {
|
||||
merchant, err := dao.Merchants.Ctx(ctx).WherePri(in.Id).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询商户失败")
|
||||
}
|
||||
if merchant.IsEmpty() {
|
||||
return nil, ecode.Params.Sub("商户不存在")
|
||||
}
|
||||
if merchant[dao.Merchants.Columns().AuditStatus].Int() != 0 {
|
||||
return nil, ecode.Params.Sub("商户已审核")
|
||||
}
|
||||
if err = dao.Merchants.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||
if _, err = tx.Model(dao.Merchants.Table()).WherePri(in.Id).Data(do.Merchants{
|
||||
AuditBy: in.AdminId,
|
||||
AuditRemark: in.AuditRemark,
|
||||
AuditStatus: in.AuditStatus,
|
||||
AuditAt: gtime.Now(),
|
||||
Status: in.AuditStatus, // 暂定审核通过商户即可使用
|
||||
RejectReason: in.RejectReason,
|
||||
}).OmitEmptyData().Update(); err != nil {
|
||||
|
||||
return ecode.Fail.Sub("审核商户失败")
|
||||
}
|
||||
if _, err = tx.Model(dao.MerchantAdmins.Table()).Where(do.MerchantAdmins{MerchantId: in.Id, IsPrimary: true}).Data(do.MerchantAdmins{
|
||||
Status: consts.MerchantAdministratorEnable,
|
||||
}).Update(); err != nil {
|
||||
return ecode.Fail.Sub("审核商户失败")
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sMerchant) Create(ctx context.Context, in *model.MerchantCreateIn) (out *model.CreateOut, err error) {
|
||||
|
||||
return
|
||||
}
|
||||
@ -1 +1,168 @@
|
||||
package merchantAdmin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
"server/internal/consts"
|
||||
"server/internal/dao"
|
||||
"server/internal/model"
|
||||
"server/internal/model/do"
|
||||
"server/internal/service"
|
||||
"server/utility/ecode"
|
||||
utility "server/utility/encrypt"
|
||||
"server/utility/jwt"
|
||||
)
|
||||
|
||||
type sMerchantAdmin struct {
|
||||
}
|
||||
|
||||
func New() service.IMerchantAdmin {
|
||||
return &sMerchantAdmin{}
|
||||
}
|
||||
func init() {
|
||||
service.RegisterMerchantAdmin(New())
|
||||
go checkMerchantRole()
|
||||
}
|
||||
|
||||
func checkMerchantRole() {
|
||||
ctx := context.Background()
|
||||
exist, err := dao.Roles.Ctx(ctx).Where(do.Roles{Code: consts.MerchantRoleCode}).Exist()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !exist {
|
||||
_, err = dao.Roles.Ctx(ctx).Insert(do.Roles{
|
||||
Name: "商户管理员",
|
||||
Code: consts.MerchantRoleCode,
|
||||
Description: "商户管理员角色",
|
||||
Status: consts.RoleEnable,
|
||||
IsDeletable: false,
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *sMerchantAdmin) Login(ctx context.Context, in *model.MerchantLoginIn) (out *model.MerchantLoginOut, err error) {
|
||||
mAdmin, err := dao.MerchantAdmins.Ctx(ctx).Where(do.MerchantAdmins{Username: in.Username}).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询商户管理员失败")
|
||||
}
|
||||
|
||||
if mAdmin.IsEmpty() {
|
||||
return nil, ecode.Params.Sub("该用户不存在")
|
||||
}
|
||||
|
||||
if mAdmin[dao.MerchantAdmins.Columns().Status].Int() == consts.MerchantAdministratorDisable {
|
||||
return nil, ecode.Params.Sub("该用户已被禁用")
|
||||
}
|
||||
if !utility.ComparePassword(mAdmin[dao.MerchantAdmins.Columns().PasswordHash].String(), in.Password) {
|
||||
return nil, ecode.Params.Sub("密码错误")
|
||||
}
|
||||
value, err := dao.Roles.Ctx(ctx).WherePri(mAdmin[dao.MerchantAdmins.Columns().RoleId].Int()).Fields(dao.Roles.Columns().Code).Value()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询角色失败")
|
||||
}
|
||||
mAdminId := mAdmin[dao.MerchantAdmins.Columns().Id].Int64()
|
||||
token, err := jwt.GenerateToken(&jwt.TokenIn{UserId: mAdminId, Role: value.String()})
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("生成token失败")
|
||||
}
|
||||
out = &model.MerchantLoginOut{
|
||||
Token: token,
|
||||
}
|
||||
go func(ctx context.Context, merchantAdminId int64) {
|
||||
// 更新商户管理员登录时间
|
||||
dao.MerchantAdmins.Ctx(ctx).WherePri(merchantAdminId).Update(do.MerchantAdmins{
|
||||
LastLoginAt: gtime.Now(),
|
||||
LastLoginIp: ghttp.RequestFromCtx(ctx).RemoteAddr,
|
||||
})
|
||||
}(ctx, mAdminId)
|
||||
return
|
||||
}
|
||||
func (s *sMerchantAdmin) Info(ctx context.Context, in *model.MerchantAdminInfoIn) (out *model.MerchantAdminInfoOut, err error) {
|
||||
return
|
||||
}
|
||||
func (s *sMerchantAdmin) Code(ctx context.Context, in *model.MerchantAdminCodeIn) (out *model.MerchantAdminCodeOut, err error) {
|
||||
exist, err := dao.MerchantAdmins.Ctx(ctx).Where(do.MerchantAdmins{Phone: in.Phone}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询商户管理员失败")
|
||||
}
|
||||
if exist {
|
||||
return nil, ecode.Fail.Sub("该手机号已被注册")
|
||||
}
|
||||
// TODO 调用验证码服务发送验证码
|
||||
// 插入缓存,过期时间为 5 分钟
|
||||
if err = g.Redis().SetEX(ctx, "merchant_admin_code:"+in.Phone, grand.Digits(6), 5*60); err != nil {
|
||||
return nil, ecode.Fail.Sub("插入验证码缓存失败")
|
||||
}
|
||||
|
||||
return &model.MerchantAdminCodeOut{}, nil
|
||||
}
|
||||
|
||||
func (s *sMerchantAdmin) VertifyPhone(ctx context.Context, in *model.MerchantAdminVertifyPhoneIn) (out *model.MerchantAdminVertifyPhoneOut, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sMerchantAdmin) Register(ctx context.Context, in *model.MerchantAdminRegisterIn) (out *model.MerchantAdminRegisterOut, err error) {
|
||||
exist, err := dao.MerchantAdmins.Ctx(ctx).Where(do.MerchantAdmins{Username: in.Username}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查询商户管理员失败")
|
||||
}
|
||||
if exist {
|
||||
return nil, ecode.Fail.Sub("该用户名已被注册")
|
||||
}
|
||||
// 验证码校验
|
||||
code, err := g.Redis().Get(ctx, "merchant_admin_code:"+in.Phone)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("获取验证码缓存失败")
|
||||
}
|
||||
if code.IsEmpty() {
|
||||
return nil, ecode.Fail.Sub("验证码已过期")
|
||||
}
|
||||
if code.String() != in.Code {
|
||||
return nil, ecode.Fail.Sub("验证码错误")
|
||||
}
|
||||
hashPass, err := utility.EncryptPassword(in.Password)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("密码加密失败")
|
||||
}
|
||||
if err = dao.MerchantAdmins.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||
// 插入商户数据
|
||||
id, err := tx.Model(dao.Merchants.Table()).Data(do.Merchants{
|
||||
Name: fmt.Sprintf("%s的商铺", in.Username),
|
||||
CreatedByType: consts.MerchantRegisterByAdmin,
|
||||
Status: consts.MerchantDisabledStatus,
|
||||
AuditStatus: consts.MerchantPendingReview,
|
||||
ContactPhone: in.Phone,
|
||||
ApplicationReason: in.ApplicationReason,
|
||||
}).InsertAndGetId()
|
||||
if err != nil {
|
||||
return ecode.Fail.Sub("插入商户数据失败")
|
||||
}
|
||||
|
||||
// 插入商户管理员数据
|
||||
if _, err = tx.Model(dao.MerchantAdmins.Table()).Data(do.MerchantAdmins{
|
||||
MerchantId: id,
|
||||
PasswordHash: hashPass,
|
||||
Phone: in.Phone,
|
||||
IsPrimary: true,
|
||||
Username: in.Username,
|
||||
Status: consts.MerchantAdministratorEnable,
|
||||
}).Insert(); err != nil {
|
||||
return ecode.Fail.Sub("插入商户管理员数据失败")
|
||||
}
|
||||
return
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
g.Redis().Del(ctx, "merchant_admin_code:"+in.Phone)
|
||||
return &model.MerchantAdminRegisterOut{Success: true}, nil
|
||||
}
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
package roleMenu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
type sRoleMenu struct {
|
||||
}
|
||||
|
||||
func New() service.IRoleMenu {
|
||||
return &sRoleMenu{}
|
||||
}
|
||||
func init() {
|
||||
service.RegisterRoleMenu(New())
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
}
|
||||
func (s *sRoleMenu) List(ctx context.Context, in *model.RoleMenuListInput) (out *model.MenuListOutput, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sRoleMenu) Save(ctx context.Context, in *model.RoleMenuSaveInput) (out *model.UpdateOut, err error) {
|
||||
return
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package storeAdmin
|
||||
@ -33,7 +33,7 @@ func checkUserRole() {
|
||||
Name: "用户",
|
||||
Code: consts.UserRoleCode,
|
||||
Description: "用户角色",
|
||||
Status: 1,
|
||||
Status: consts.RoleEnable,
|
||||
IsDeletable: false,
|
||||
}).Insert()
|
||||
if err != nil {
|
||||
|
||||
@ -1,16 +1,55 @@
|
||||
package model
|
||||
|
||||
type (
|
||||
AdminLoginIn struct {
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
// Admin 管理员信息
|
||||
type Admin struct {
|
||||
Id int64 `json:"id" orm:"id,primary"` // 管理员ID
|
||||
RoleId int64 `json:"roleId" orm:"role_id,not null"` // 角色ID
|
||||
Username string `json:"username" orm:"username,not null"` // 管理员用户名
|
||||
PasswordHash string `json:"passwordHash" orm:"password_hash,not null"` // 密码哈希
|
||||
RealName string `json:"realName" orm:"real_name"` // 真实姓名
|
||||
Phone string `json:"phone" orm:"phone"` // 手机号
|
||||
Email string `json:"email" orm:"email"` // 邮箱
|
||||
Status int `json:"status" orm:"status,default:1"` // 状态:1=正常,2=禁用
|
||||
}
|
||||
|
||||
AdminInfoIn struct {
|
||||
Id int
|
||||
}
|
||||
AdminInfoOut struct {
|
||||
Id int64
|
||||
Username string
|
||||
}
|
||||
)
|
||||
// AdminCreateIn 创建管理员请求
|
||||
type AdminCreateIn struct {
|
||||
RoleId int64
|
||||
Username string
|
||||
Password string
|
||||
RealName string
|
||||
Phone string
|
||||
Email string
|
||||
Status int
|
||||
}
|
||||
|
||||
// AdminUpdateIn 更新管理员请求
|
||||
type AdminUpdateIn struct {
|
||||
Id int64
|
||||
RoleId int64
|
||||
RealName string
|
||||
Phone string
|
||||
Email string
|
||||
Status int
|
||||
}
|
||||
|
||||
// AdminOut 管理员响应
|
||||
type AdminOut struct {
|
||||
*Admin
|
||||
}
|
||||
|
||||
type AdminLoginIn struct {
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
type AdminInfoIn struct {
|
||||
Id int64
|
||||
}
|
||||
type AdminInfoOut struct {
|
||||
Id int64
|
||||
Username string
|
||||
PasswordHash string
|
||||
RealName string
|
||||
Phone string
|
||||
Email string
|
||||
}
|
||||
|
||||
@ -25,4 +25,7 @@ type MerchantAdmins struct {
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
IsPrimary interface{} // 是否主账号:0=否,1=是
|
||||
LastLoginIp interface{} // 最后登录IP
|
||||
RoleId interface{} // 角色ID
|
||||
}
|
||||
|
||||
@ -11,18 +11,26 @@ import (
|
||||
|
||||
// Merchants is the golang structure of table merchants for DAO operations like Where/Data.
|
||||
type Merchants struct {
|
||||
g.Meta `orm:"table:merchants, do:true"`
|
||||
Id interface{} // 商户ID
|
||||
Name interface{} // 商户名称
|
||||
BusinessLicense interface{} // 营业执照号
|
||||
LegalPerson interface{} // 法人姓名
|
||||
ContactName interface{} // 联系人姓名
|
||||
ContactPhone interface{} // 联系人电话
|
||||
ContactEmail interface{} // 联系人邮箱
|
||||
Address interface{} // 商户地址
|
||||
Status interface{} // 状态:1=正常,2=禁用,3=待审核
|
||||
ExpireAt *gtime.Time // 服务到期时间
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
g.Meta `orm:"table:merchants, do:true"`
|
||||
Id interface{} // 商户ID
|
||||
Name interface{} // 商户名称
|
||||
BusinessLicense interface{} // 营业执照号
|
||||
LegalPerson interface{} // 法人姓名
|
||||
ContactName interface{} // 联系人姓名
|
||||
ContactPhone interface{} // 联系人电话
|
||||
ContactEmail interface{} // 联系人邮箱
|
||||
Address interface{} // 商户地址
|
||||
Status interface{} // 状态:1=正常,2=禁用
|
||||
ExpireAt *gtime.Time // 服务到期时间
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
ApplicationReason interface{} // 申请理由
|
||||
CreatedBy interface{} // 创建人ID
|
||||
CreatedByType interface{} // 创建人类型:1=系统管理员,2=商户注册
|
||||
AuditStatus interface{} // 审核状态:0=待审核,1=审核通过,2=审核拒绝
|
||||
AuditBy interface{} // 审核人ID
|
||||
AuditAt *gtime.Time // 审核时间
|
||||
AuditRemark interface{} // 审核备注
|
||||
RejectReason interface{} // 拒绝原因
|
||||
}
|
||||
|
||||
@ -25,4 +25,5 @@ type StoreAdmins struct {
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
RoleId interface{} // 角色ID
|
||||
}
|
||||
|
||||
@ -11,17 +11,16 @@ import (
|
||||
|
||||
// Stores is the golang structure of table stores for DAO operations like Where/Data.
|
||||
type Stores struct {
|
||||
g.Meta `orm:"table:stores, do:true"`
|
||||
Id interface{} // 门店ID
|
||||
MerchantId interface{} // 所属商户ID
|
||||
Name interface{} // 门店名称
|
||||
StoreCode interface{} // 门店编号
|
||||
Address interface{} // 门店地址
|
||||
ContactName interface{} // 联系人姓名
|
||||
ContactPhone interface{} // 联系人电话
|
||||
BusinessHours interface{} // 营业时间
|
||||
Status interface{} // 状态:1=正常营业,2=暂停营业,3=已关闭
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
g.Meta `orm:"table:stores, do:true"`
|
||||
Id interface{} // 门店ID
|
||||
MerchantId interface{} // 所属商户ID
|
||||
Name interface{} // 门店名称
|
||||
StoreCode interface{} // 门店编号
|
||||
Address interface{} // 门店地址
|
||||
ContactName interface{} // 联系人姓名
|
||||
ContactPhone interface{} // 联系人电话
|
||||
Status interface{} // 状态:1=正常营业,2=暂停营业,3=已关闭
|
||||
CreatedAt *gtime.Time // 创建时间
|
||||
UpdatedAt *gtime.Time // 更新时间
|
||||
DeletedAt *gtime.Time // 软删除时间戳
|
||||
}
|
||||
|
||||
@ -23,4 +23,7 @@ type MerchantAdmins struct {
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
|
||||
IsPrimary bool `json:"isPrimary" orm:"is_primary" description:"是否主账号:0=否,1=是"` // 是否主账号:0=否,1=是
|
||||
LastLoginIp string `json:"lastLoginIp" orm:"last_login_ip" description:"最后登录IP"` // 最后登录IP
|
||||
RoleId int64 `json:"roleId" orm:"role_id" description:"角色ID"` // 角色ID
|
||||
}
|
||||
|
||||
@ -10,17 +10,25 @@ import (
|
||||
|
||||
// Merchants is the golang structure for table merchants.
|
||||
type Merchants struct {
|
||||
Id int64 `json:"id" orm:"id" description:"商户ID"` // 商户ID
|
||||
Name string `json:"name" orm:"name" description:"商户名称"` // 商户名称
|
||||
BusinessLicense string `json:"businessLicense" orm:"business_license" description:"营业执照号"` // 营业执照号
|
||||
LegalPerson string `json:"legalPerson" orm:"legal_person" description:"法人姓名"` // 法人姓名
|
||||
ContactName string `json:"contactName" orm:"contact_name" description:"联系人姓名"` // 联系人姓名
|
||||
ContactPhone string `json:"contactPhone" orm:"contact_phone" description:"联系人电话"` // 联系人电话
|
||||
ContactEmail string `json:"contactEmail" orm:"contact_email" description:"联系人邮箱"` // 联系人邮箱
|
||||
Address string `json:"address" orm:"address" description:"商户地址"` // 商户地址
|
||||
Status int `json:"status" orm:"status" description:"状态:1=正常,2=禁用,3=待审核"` // 状态:1=正常,2=禁用,3=待审核
|
||||
ExpireAt *gtime.Time `json:"expireAt" orm:"expire_at" description:"服务到期时间"` // 服务到期时间
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
|
||||
Id int64 `json:"id" orm:"id" description:"商户ID"` // 商户ID
|
||||
Name string `json:"name" orm:"name" description:"商户名称"` // 商户名称
|
||||
BusinessLicense string `json:"businessLicense" orm:"business_license" description:"营业执照号"` // 营业执照号
|
||||
LegalPerson string `json:"legalPerson" orm:"legal_person" description:"法人姓名"` // 法人姓名
|
||||
ContactName string `json:"contactName" orm:"contact_name" description:"联系人姓名"` // 联系人姓名
|
||||
ContactPhone string `json:"contactPhone" orm:"contact_phone" description:"联系人电话"` // 联系人电话
|
||||
ContactEmail string `json:"contactEmail" orm:"contact_email" description:"联系人邮箱"` // 联系人邮箱
|
||||
Address string `json:"address" orm:"address" description:"商户地址"` // 商户地址
|
||||
Status int `json:"status" orm:"status" description:"状态:1=正常,2=禁用"` // 状态:1=正常,2=禁用
|
||||
ExpireAt *gtime.Time `json:"expireAt" orm:"expire_at" description:"服务到期时间"` // 服务到期时间
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
|
||||
ApplicationReason string `json:"applicationReason" orm:"application_reason" description:"申请理由"` // 申请理由
|
||||
CreatedBy int64 `json:"createdBy" orm:"created_by" description:"创建人ID"` // 创建人ID
|
||||
CreatedByType int `json:"createdByType" orm:"created_by_type" description:"创建人类型:1=系统管理员,2=商户注册"` // 创建人类型:1=系统管理员,2=商户注册
|
||||
AuditStatus int `json:"auditStatus" orm:"audit_status" description:"审核状态:0=待审核,1=审核通过,2=审核拒绝"` // 审核状态:0=待审核,1=审核通过,2=审核拒绝
|
||||
AuditBy int64 `json:"auditBy" orm:"audit_by" description:"审核人ID"` // 审核人ID
|
||||
AuditAt *gtime.Time `json:"auditAt" orm:"audit_at" description:"审核时间"` // 审核时间
|
||||
AuditRemark string `json:"auditRemark" orm:"audit_remark" description:"审核备注"` // 审核备注
|
||||
RejectReason string `json:"rejectReason" orm:"reject_reason" description:"拒绝原因"` // 拒绝原因
|
||||
}
|
||||
|
||||
@ -23,4 +23,5 @@ type StoreAdmins struct {
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
|
||||
RoleId int64 `json:"roleId" orm:"role_id" description:"角色ID"` // 角色ID
|
||||
}
|
||||
|
||||
@ -10,16 +10,15 @@ import (
|
||||
|
||||
// Stores is the golang structure for table stores.
|
||||
type Stores struct {
|
||||
Id int64 `json:"id" orm:"id" description:"门店ID"` // 门店ID
|
||||
MerchantId int64 `json:"merchantId" orm:"merchant_id" description:"所属商户ID"` // 所属商户ID
|
||||
Name string `json:"name" orm:"name" description:"门店名称"` // 门店名称
|
||||
StoreCode string `json:"storeCode" orm:"store_code" description:"门店编号"` // 门店编号
|
||||
Address string `json:"address" orm:"address" description:"门店地址"` // 门店地址
|
||||
ContactName string `json:"contactName" orm:"contact_name" description:"联系人姓名"` // 联系人姓名
|
||||
ContactPhone string `json:"contactPhone" orm:"contact_phone" description:"联系人电话"` // 联系人电话
|
||||
BusinessHours string `json:"businessHours" orm:"business_hours" description:"营业时间"` // 营业时间
|
||||
Status int `json:"status" orm:"status" description:"状态:1=正常营业,2=暂停营业,3=已关闭"` // 状态:1=正常营业,2=暂停营业,3=已关闭
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
|
||||
Id int64 `json:"id" orm:"id" description:"门店ID"` // 门店ID
|
||||
MerchantId int64 `json:"merchantId" orm:"merchant_id" description:"所属商户ID"` // 所属商户ID
|
||||
Name string `json:"name" orm:"name" description:"门店名称"` // 门店名称
|
||||
StoreCode string `json:"storeCode" orm:"store_code" description:"门店编号"` // 门店编号
|
||||
Address string `json:"address" orm:"address" description:"门店地址"` // 门店地址
|
||||
ContactName string `json:"contactName" orm:"contact_name" description:"联系人姓名"` // 联系人姓名
|
||||
ContactPhone string `json:"contactPhone" orm:"contact_phone" description:"联系人电话"` // 联系人电话
|
||||
Status int `json:"status" orm:"status" description:"状态:1=正常营业,2=暂停营业,3=已关闭"` // 状态:1=正常营业,2=暂停营业,3=已关闭
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
|
||||
}
|
||||
|
||||
80
internal/model/merchant.go
Normal file
80
internal/model/merchant.go
Normal file
@ -0,0 +1,80 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// Merchant 商户信息
|
||||
type Merchant struct {
|
||||
Id int64 `json:"id" orm:"id,primary"` // 商户ID
|
||||
Name string `json:"name" orm:"name,not null"` // 商户名称
|
||||
BusinessLicense string `json:"businessLicense" orm:"business_license"` // 营业执照号
|
||||
LegalPerson string `json:"legalPerson" orm:"legal_person"` // 法人姓名
|
||||
ContactName string `json:"contactName" orm:"contact_name"` // 联系人姓名
|
||||
ContactPhone string `json:"contactPhone" orm:"contact_phone"` // 联系人电话
|
||||
ContactEmail string `json:"contactEmail" orm:"contact_email"` // 联系人邮箱
|
||||
Address string `json:"address" orm:"address"` // 商户地址
|
||||
Status int `json:"status" orm:"status,default:1"` // 状态:1=正常,2=禁用
|
||||
ExpireAt *gtime.Time `json:"expireAt" orm:"expire_at"` // 服务到期时间
|
||||
ApplicationReason int64 `json:"applicationReason" orm:"application_reason"` // 申请理由
|
||||
CreatedBy int64 `json:"createdBy" orm:"created_by"` // 创建人ID
|
||||
CreatedByType int `json:"createdByType" orm:"created_by_type"` // 创建人类型:1=系统管理员,2=商户注册
|
||||
AuditStatus int `json:"auditStatus" orm:"audit_status,default:0"` // 审核状态:0=待审核,1=审核通过,2=审核拒绝
|
||||
AuditBy int64 `json:"auditBy" orm:"audit_by"` // 审核人ID
|
||||
AuditAt *gtime.Time `json:"auditAt" orm:"audit_at"` // 审核时间
|
||||
AuditRemark string `json:"auditRemark" orm:"audit_remark"` // 审核备注
|
||||
RejectReason string `json:"rejectReason" orm:"reject_reason"` // 拒绝原因
|
||||
}
|
||||
|
||||
// MerchantCreateIn 创建商户请求
|
||||
type MerchantCreateIn struct {
|
||||
Name string
|
||||
BusinessLicense string
|
||||
LegalPerson string
|
||||
ContactName string
|
||||
ContactPhone string
|
||||
ContactEmail string
|
||||
Address string
|
||||
ApplicationReason int64
|
||||
}
|
||||
|
||||
// MerchantUpdateIn 更新商户请求
|
||||
type MerchantUpdateIn struct {
|
||||
Id int64
|
||||
Name string
|
||||
BusinessLicense string
|
||||
LegalPerson string
|
||||
ContactName string
|
||||
ContactPhone string
|
||||
ContactEmail string
|
||||
Address string
|
||||
Status int
|
||||
ExpireAt *gtime.Time
|
||||
}
|
||||
|
||||
// MerchantAuditIn 审核商户请求
|
||||
type MerchantAuditIn struct {
|
||||
AdminId int64
|
||||
Id int64
|
||||
AuditStatus int
|
||||
AuditRemark string
|
||||
RejectReason string
|
||||
}
|
||||
type MerchantAuditOut struct {
|
||||
}
|
||||
|
||||
// MerchantOut 商户响应
|
||||
type MerchantOut struct {
|
||||
*Merchant
|
||||
}
|
||||
|
||||
type MerchantListIn struct {
|
||||
Page int
|
||||
Size int
|
||||
Status int
|
||||
AuditStatus int
|
||||
}
|
||||
type MerchantListOut struct {
|
||||
List []Merchant
|
||||
Total int
|
||||
}
|
||||
46
internal/model/merchant_admin.go
Normal file
46
internal/model/merchant_admin.go
Normal file
@ -0,0 +1,46 @@
|
||||
package model
|
||||
|
||||
// MerchantAdmin 商户管理员信息
|
||||
type MerchantAdmin struct {
|
||||
}
|
||||
|
||||
// MerchantLoginIn 商户登录入参
|
||||
type MerchantLoginIn struct {
|
||||
Phone string
|
||||
Username string
|
||||
Password string
|
||||
Code string
|
||||
}
|
||||
|
||||
type MerchantLoginOut struct {
|
||||
Token string
|
||||
}
|
||||
type MerchantAdminInfoIn struct {
|
||||
MerchantAdminId int64
|
||||
}
|
||||
type MerchantAdminInfoOut struct {
|
||||
*MerchantAdmin
|
||||
}
|
||||
type MerchantAdminCodeIn struct {
|
||||
Phone string
|
||||
}
|
||||
type MerchantAdminCodeOut struct {
|
||||
}
|
||||
type MerchantAdminVertifyPhoneIn struct {
|
||||
MerchantAdminId int64
|
||||
Phone string
|
||||
Code string
|
||||
}
|
||||
type MerchantAdminVertifyPhoneOut struct {
|
||||
}
|
||||
type MerchantAdminRegisterIn struct {
|
||||
Username string
|
||||
Phone string
|
||||
Password string
|
||||
Password2 string
|
||||
Code string
|
||||
ApplicationReason string
|
||||
}
|
||||
type MerchantAdminRegisterOut struct {
|
||||
Success bool
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package model
|
||||
|
||||
import "github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
type RoleMenu struct {
|
||||
g.Meta `orm:"table:role_menus"`
|
||||
Id int64 `json:"id" orm:"id" dc:"角色菜单ID"`
|
||||
RoleId int64 `json:"roleId" orm:"role_id" dc:"角色ID"`
|
||||
MenuId int64 `json:"menuId" orm:"menu_id" dc:"菜单ID"`
|
||||
}
|
||||
type RoleMenuListInput struct {
|
||||
Page int
|
||||
Size int
|
||||
RoleId int64
|
||||
}
|
||||
type RoleMenuListOutput struct {
|
||||
List []RoleMenu
|
||||
Total int
|
||||
}
|
||||
|
||||
type RoleMenuSaveInput struct {
|
||||
RoleId int
|
||||
MenuIds []int
|
||||
}
|
||||
29
internal/model/upload.go
Normal file
29
internal/model/upload.go
Normal file
@ -0,0 +1,29 @@
|
||||
package model
|
||||
|
||||
import "github.com/gogf/gf/v2/net/ghttp"
|
||||
|
||||
type UploadIn struct {
|
||||
File *ghttp.UploadFile
|
||||
}
|
||||
|
||||
type UploadOut struct {
|
||||
Url string
|
||||
}
|
||||
type OssOutput struct {
|
||||
Url string
|
||||
}
|
||||
|
||||
type OssBytesInput struct {
|
||||
Bytes []byte
|
||||
Name string
|
||||
}
|
||||
|
||||
type OssGetFileInput struct {
|
||||
FilePath string
|
||||
Name string
|
||||
}
|
||||
|
||||
type OssUploadFileInput struct {
|
||||
Filename string
|
||||
File *ghttp.UploadFile
|
||||
}
|
||||
@ -1,6 +1,58 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// User 用户信息
|
||||
type User struct {
|
||||
Id int64 `json:"id" orm:"id,primary"` // 用户ID
|
||||
Username string `json:"username" orm:"username,not null"` // 用户名
|
||||
PasswordHash string `json:"passwordHash" orm:"password_hash,not null"` // 密码哈希
|
||||
Nickname string `json:"nickname" orm:"nickname"` // 昵称
|
||||
Avatar string `json:"avatar" orm:"avatar"` // 头像
|
||||
Phone string `json:"phone" orm:"phone"` // 手机号
|
||||
Email string `json:"email" orm:"email"` // 邮箱
|
||||
Gender int `json:"gender" orm:"gender,default:0"` // 性别:0=未知,1=男,2=女
|
||||
Birthday *gtime.Time `json:"birthday" orm:"birthday"` // 生日
|
||||
Status int `json:"status" orm:"status,default:1"` // 状态:1=正常,2=禁用
|
||||
LastLoginAt *gtime.Time `json:"lastLoginAt" orm:"last_login_at"` // 最后登录时间
|
||||
LastLoginIp string `json:"lastLoginIp" orm:"last_login_ip"` // 最后登录IP
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at"` // 创建时间
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at"` // 更新时间
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at"` // 软删除时间戳
|
||||
}
|
||||
|
||||
// UserCreateIn 创建用户请求
|
||||
type UserCreateIn struct {
|
||||
Username string
|
||||
Password string
|
||||
Nickname string
|
||||
Avatar string
|
||||
Phone string
|
||||
Email string
|
||||
Gender int
|
||||
Birthday *gtime.Time
|
||||
}
|
||||
|
||||
// UserUpdateIn 更新用户请求
|
||||
type UserUpdateIn struct {
|
||||
Id int64
|
||||
Nickname string
|
||||
Avatar string
|
||||
Phone string
|
||||
Email string
|
||||
Gender int
|
||||
Birthday *gtime.Time
|
||||
Status int
|
||||
}
|
||||
|
||||
// UserOut 用户响应
|
||||
type UserOut struct {
|
||||
*User
|
||||
}
|
||||
|
||||
type LoginCache struct {
|
||||
Token string `json:"token"`
|
||||
@ -23,7 +75,5 @@ type UserInfoOut struct {
|
||||
Id int64
|
||||
}
|
||||
|
||||
type UserUpdateIn struct {
|
||||
}
|
||||
type UserBindPhoneIn struct {
|
||||
}
|
||||
|
||||
34
internal/service/merchant.go
Normal file
34
internal/service/merchant.go
Normal file
@ -0,0 +1,34 @@
|
||||
// ================================================================================
|
||||
// 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 (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
)
|
||||
|
||||
type (
|
||||
IMerchant interface {
|
||||
List(ctx context.Context, in *model.MerchantListIn) (out *model.MerchantListOut, err error)
|
||||
Audit(ctx context.Context, in *model.MerchantAuditIn) (out *model.MerchantAuditOut, err error)
|
||||
Create(ctx context.Context, in *model.MerchantCreateIn) (out *model.CreateOut, err error)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localMerchant IMerchant
|
||||
)
|
||||
|
||||
func Merchant() IMerchant {
|
||||
if localMerchant == nil {
|
||||
panic("implement not found for interface IMerchant, forgot register?")
|
||||
}
|
||||
return localMerchant
|
||||
}
|
||||
|
||||
func RegisterMerchant(i IMerchant) {
|
||||
localMerchant = i
|
||||
}
|
||||
@ -5,4 +5,32 @@
|
||||
|
||||
package service
|
||||
|
||||
type ()
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
)
|
||||
|
||||
type (
|
||||
IMerchantAdmin interface {
|
||||
Login(ctx context.Context, in *model.MerchantLoginIn) (out *model.MerchantLoginOut, err error)
|
||||
Info(ctx context.Context, in *model.MerchantAdminInfoIn) (out *model.MerchantAdminInfoOut, err error)
|
||||
Code(ctx context.Context, in *model.MerchantAdminCodeIn) (out *model.MerchantAdminCodeOut, err error)
|
||||
VertifyPhone(ctx context.Context, in *model.MerchantAdminVertifyPhoneIn) (out *model.MerchantAdminVertifyPhoneOut, err error)
|
||||
Register(ctx context.Context, in *model.MerchantAdminRegisterIn) (out *model.MerchantAdminRegisterOut, err error)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localMerchantAdmin IMerchantAdmin
|
||||
)
|
||||
|
||||
func MerchantAdmin() IMerchantAdmin {
|
||||
if localMerchantAdmin == nil {
|
||||
panic("implement not found for interface IMerchantAdmin, forgot register?")
|
||||
}
|
||||
return localMerchantAdmin
|
||||
}
|
||||
|
||||
func RegisterMerchantAdmin(i IMerchantAdmin) {
|
||||
localMerchantAdmin = i
|
||||
}
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
// ================================================================================
|
||||
// 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 (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
)
|
||||
|
||||
type (
|
||||
IRoleMenu interface {
|
||||
List(ctx context.Context, in *model.RoleMenuListInput) (out *model.MenuListOutput, err error)
|
||||
Save(ctx context.Context, in *model.RoleMenuSaveInput) (out *model.UpdateOut, err error)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localRoleMenu IRoleMenu
|
||||
)
|
||||
|
||||
func RoleMenu() IRoleMenu {
|
||||
if localRoleMenu == nil {
|
||||
panic("implement not found for interface IRoleMenu, forgot register?")
|
||||
}
|
||||
return localRoleMenu
|
||||
}
|
||||
|
||||
func RegisterRoleMenu(i IRoleMenu) {
|
||||
localRoleMenu = i
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
// ================================================================================
|
||||
// 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
|
||||
|
||||
type ()
|
||||
Reference in New Issue
Block a user