修改了优惠卷数据
This commit is contained in:
parent
d305df4a23
commit
3dce6ebfc8
@ -11,6 +11,7 @@ import (
|
|||||||
"hepa-calc-admin-api/global"
|
"hepa-calc-admin-api/global"
|
||||||
"hepa-calc-admin-api/utils"
|
"hepa-calc-admin-api/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -84,6 +85,9 @@ func (b *Coupon) GetCoupon(c *gin.Context) {
|
|||||||
// 处理返回值
|
// 处理返回值
|
||||||
g := dto.GetCouponDto(coupon)
|
g := dto.GetCouponDto(coupon)
|
||||||
|
|
||||||
|
// 加载会员id
|
||||||
|
g.LoadSystemMemberIds(coupon.SystemMemberIds)
|
||||||
|
|
||||||
responses.OkWithData(g, c)
|
responses.OkWithData(g, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,29 +178,32 @@ func (r *Coupon) AddSystemCoupon(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 适用范围(1:全场通用 2:单项 3:会员)
|
// 适用范围(1:全场通用 2:单项 3:会员)
|
||||||
if req.ApplicationScope == 1 {
|
systemMemberIds := make([]string, len(req.SystemMemberIds))
|
||||||
// 全场通用
|
|
||||||
if req.QuestionId == nil && req.SystemMemberId == nil {
|
|
||||||
responses.FailWithMessage("请填入关联选项", c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if req.ApplicationScope == 2 {
|
|
||||||
// 单项
|
|
||||||
if req.QuestionId == nil {
|
|
||||||
responses.FailWithMessage("请填入关联算一算", c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 适用范围(1:全场通用 2:单项 3:会员)
|
|
||||||
if req.ApplicationScope == 3 {
|
if req.ApplicationScope == 3 {
|
||||||
// 会员
|
// 会员
|
||||||
if req.SystemMemberId == nil {
|
if req.SystemMemberIds == nil {
|
||||||
responses.FailWithMessage("请填入关联会员", c)
|
responses.FailWithMessage("请填入关联会员", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 关联会员id
|
||||||
|
systemMemberDao := dao.SystemMemberDao{}
|
||||||
|
|
||||||
|
for i, id := range req.SystemMemberIds {
|
||||||
|
systemMemberId, err := strconv.ParseInt(*id, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage("新增失败", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
systemMember, err := systemMemberDao.GetSystemMemberById(systemMemberId)
|
||||||
|
if err != nil || systemMember == nil {
|
||||||
|
responses.FailWithMessage("新增失败", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
systemMemberIds[i] = *id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 有效类型-绝对时效
|
// 有效类型-绝对时效
|
||||||
@ -244,8 +251,7 @@ func (r *Coupon) AddSystemCoupon(c *gin.Context) {
|
|||||||
ValidStartTime: nil,
|
ValidStartTime: nil,
|
||||||
ValidEndTime: nil,
|
ValidEndTime: nil,
|
||||||
CouponDesc: req.CouponDesc,
|
CouponDesc: req.CouponDesc,
|
||||||
QuestionId: nil,
|
SystemMemberIds: strings.Join(systemMemberIds, ","),
|
||||||
SystemMemberId: nil,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 符合满减标准金额
|
// 符合满减标准金额
|
||||||
@ -310,30 +316,6 @@ func (r *Coupon) AddSystemCoupon(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关联单项id
|
|
||||||
if req.QuestionId != nil {
|
|
||||||
questionId, err := strconv.ParseInt(*req.QuestionId, 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
tx.Rollback()
|
|
||||||
responses.FailWithMessage("新增失败", c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
coupon.QuestionId = &questionId
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关联会员id
|
|
||||||
if req.SystemMemberId != nil {
|
|
||||||
systemMemberId, err := strconv.ParseInt(*req.SystemMemberId, 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
tx.Rollback()
|
|
||||||
responses.FailWithMessage("新增失败", c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
coupon.QuestionId = &systemMemberId
|
|
||||||
}
|
|
||||||
|
|
||||||
couponDao := dao.CouponDao{}
|
couponDao := dao.CouponDao{}
|
||||||
coupon, err := couponDao.AddCoupon(tx, coupon)
|
coupon, err := couponDao.AddCoupon(tx, coupon)
|
||||||
if err != nil || coupon == nil {
|
if err != nil || coupon == nil {
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package dto
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"hepa-calc-admin-api/api/model"
|
"hepa-calc-admin-api/api/model"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CouponDto struct {
|
type CouponDto struct {
|
||||||
@ -21,6 +22,7 @@ type CouponDto struct {
|
|||||||
ValidDays int `json:"valid_days"` // 自领取之日起有效天数
|
ValidDays int `json:"valid_days"` // 自领取之日起有效天数
|
||||||
ValidStartTime *model.LocalTime `json:"valid_start_time"` // 开始使用时间
|
ValidStartTime *model.LocalTime `json:"valid_start_time"` // 开始使用时间
|
||||||
ValidEndTime *model.LocalTime `json:"valid_end_time"` // 结束使用时间
|
ValidEndTime *model.LocalTime `json:"valid_end_time"` // 结束使用时间
|
||||||
|
SystemMemberIds []*string `json:"system_member_ids"` // 会员id(适用范围为会员时生效,如果此项为null,则表示所有会员通用)
|
||||||
CouponDesc string `json:"coupon_desc"` // 优惠券描述
|
CouponDesc string `json:"coupon_desc"` // 优惠券描述
|
||||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
@ -60,6 +62,11 @@ func GetCouponListDto(m []*model.Coupon) []*CouponDto {
|
|||||||
response.ValidDays = *v.ValidDays
|
response.ValidDays = *v.ValidDays
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载会员id
|
||||||
|
if v.SystemMemberIds != "" {
|
||||||
|
response = response.LoadSystemMemberIds(v.SystemMemberIds)
|
||||||
|
}
|
||||||
|
|
||||||
// 将转换后的结构体添加到新切片中
|
// 将转换后的结构体添加到新切片中
|
||||||
responses[i] = response
|
responses[i] = response
|
||||||
}
|
}
|
||||||
@ -99,3 +106,21 @@ func GetCouponDto(m *model.Coupon) *CouponDto {
|
|||||||
|
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadSystemMemberIds 加载会员id
|
||||||
|
func (r *CouponDto) LoadSystemMemberIds(systemMemberIds string) *CouponDto {
|
||||||
|
if systemMemberIds != "" {
|
||||||
|
s := strings.Split(systemMemberIds, ",")
|
||||||
|
|
||||||
|
response := make([]*string, len(s))
|
||||||
|
|
||||||
|
for i, v := range s {
|
||||||
|
h := fmt.Sprintf("%v", v)
|
||||||
|
response[i] = &h
|
||||||
|
}
|
||||||
|
|
||||||
|
r.SystemMemberIds = response
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|||||||
@ -24,9 +24,6 @@ type QuestionDto struct {
|
|||||||
QuestionExplain string `json:"question_explain"` // 问题解释/科普
|
QuestionExplain string `json:"question_explain"` // 问题解释/科普
|
||||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
IsCollection bool `json:"is_collection"` // 用户是否收藏
|
|
||||||
FirstTimePrice *float64 `json:"first_time_price"` // 首次购买价格
|
|
||||||
BuyCount int `json:"buy_count"` // 被购买数量
|
|
||||||
BaseClass []*BaseClassDto `json:"base_class"` // 关联分类
|
BaseClass []*BaseClassDto `json:"base_class"` // 关联分类
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,76 +109,3 @@ func GetHotQuestionListDto(m []*model.Question) []*QuestionDto {
|
|||||||
|
|
||||||
return responses
|
return responses
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRecommendQuestionListDto 列表-为你推荐
|
|
||||||
func GetRecommendQuestionListDto(m []*model.Question) []*QuestionDto {
|
|
||||||
// 处理返回值
|
|
||||||
responses := make([]*QuestionDto, len(m))
|
|
||||||
|
|
||||||
if len(m) > 0 {
|
|
||||||
for i, v := range m {
|
|
||||||
response := &QuestionDto{
|
|
||||||
QuestionId: fmt.Sprintf("%d", v.QuestionId),
|
|
||||||
QuestionTitle: v.QuestionTitle,
|
|
||||||
QuestionSubtitle: v.QuestionSubtitle,
|
|
||||||
QuestionIden: v.QuestionIden,
|
|
||||||
ClickCount: v.ClickCount,
|
|
||||||
SubmitCount: v.SubmitCount,
|
|
||||||
PayCount: v.PayCount,
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将转换后的结构体添加到新切片中
|
|
||||||
responses[i] = response
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return responses
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGuessUserLikeListDto 列表-猜你喜欢
|
|
||||||
func GetGuessUserLikeListDto(m []*model.Question) []*QuestionDto {
|
|
||||||
// 处理返回值
|
|
||||||
responses := make([]*QuestionDto, len(m))
|
|
||||||
|
|
||||||
if len(m) > 0 {
|
|
||||||
for i, v := range m {
|
|
||||||
response := &QuestionDto{
|
|
||||||
QuestionId: fmt.Sprintf("%d", v.QuestionId),
|
|
||||||
QuestionTitle: v.QuestionTitle,
|
|
||||||
QuestionSubtitle: v.QuestionSubtitle,
|
|
||||||
QuestionIden: v.QuestionIden,
|
|
||||||
ClickCount: v.ClickCount,
|
|
||||||
SubmitCount: v.SubmitCount,
|
|
||||||
PayCount: v.PayCount,
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将转换后的结构体添加到新切片中
|
|
||||||
responses[i] = response
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return responses
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoadIsCollection 加载数据-是否收藏
|
|
||||||
func (r *QuestionDto) LoadIsCollection(isCollection bool) *QuestionDto {
|
|
||||||
r.IsCollection = isCollection
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoadFirstTimePrice 加载数据-首次购买价格
|
|
||||||
func (r *QuestionDto) LoadFirstTimePrice(firstTimePrice *float64) *QuestionDto {
|
|
||||||
if firstTimePrice != nil {
|
|
||||||
r.FirstTimePrice = firstTimePrice
|
|
||||||
}
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoadBuyCount 加载数据-问题被购买数量
|
|
||||||
func (r *QuestionDto) LoadBuyCount(buyCount int) *QuestionDto {
|
|
||||||
r.BuyCount = buyCount
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|||||||
@ -9,23 +9,26 @@ import (
|
|||||||
|
|
||||||
// UserDto 用户表
|
// UserDto 用户表
|
||||||
type UserDto struct {
|
type UserDto struct {
|
||||||
UserId string `json:"user_id"` // 用户id
|
UserId string `json:"user_id"` // 用户id
|
||||||
UserName string `json:"user_name"` // 用户名称
|
UserName string `json:"user_name"` // 用户名称
|
||||||
Mobile string `json:"mobile"` // 手机号
|
Mobile string `json:"mobile"` // 手机号
|
||||||
UserStatus int `json:"user_status"` // 状态(1:正常 2:禁用)
|
UserStatus int `json:"user_status"` // 状态(1:正常 2:禁用)
|
||||||
RegisterSource int `json:"register_source"` // 注册来源(1:app注册 2:公众号注册)
|
RegisterSource int `json:"register_source"` // 注册来源(1:app注册 2:公众号注册)
|
||||||
OpenId string `json:"open_id"` // 用户微信标识
|
OpenId string `json:"open_id"` // 用户微信标识
|
||||||
UnionId string `json:"union_id"` // 微信开放平台标识
|
UnionId string `json:"union_id"` // 微信开放平台标识
|
||||||
Age *uint `json:"age"` // 年龄
|
Age *uint `json:"age"` // 年龄
|
||||||
Sex uint `json:"sex"` // 性别(0:未知 1:男 2:女)
|
Sex uint `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||||||
Avatar string `json:"avatar"` // 头像
|
Avatar string `json:"avatar"` // 头像
|
||||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||||
MemberExpireDate *time.Time `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
MemberExpireDate *time.Time `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||||
LoginAt model.LocalTime `json:"login_at"` // 登陆时间
|
SingleSubmitCount int `json:"single_submit_count"` // 单项提交次数(提交个人信息进行了算算的人次)
|
||||||
LoginIp string `json:"login_ip"` // 登陆ip
|
SinglePayCount int `json:"single_pay_count"` // 单项支付次数(查看报告的人次)
|
||||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
MemberBuyCount int `json:"member_buy_count"` // 会员购买次数
|
||||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
LoginAt model.LocalTime `json:"login_at"` // 登陆时间
|
||||||
IsInfoComplete int `json:"is_info_complete"` // 信息完善状态 0:否 1:是
|
LoginIp string `json:"login_ip"` // 登陆ip
|
||||||
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
|
IsInfoComplete int `json:"is_info_complete"` // 信息完善状态 0:否 1:是
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserListDto 列表
|
// GetUserListDto 列表
|
||||||
@ -36,20 +39,23 @@ func GetUserListDto(m []*model.User) []*UserDto {
|
|||||||
if len(m) > 0 {
|
if len(m) > 0 {
|
||||||
for i, v := range m {
|
for i, v := range m {
|
||||||
response := &UserDto{
|
response := &UserDto{
|
||||||
UserId: fmt.Sprintf("%d", v.UserId),
|
UserId: fmt.Sprintf("%d", v.UserId),
|
||||||
UserName: v.UserName,
|
UserName: v.UserName,
|
||||||
Mobile: v.Mobile,
|
Mobile: v.Mobile,
|
||||||
UserStatus: v.UserStatus,
|
UserStatus: v.UserStatus,
|
||||||
RegisterSource: v.RegisterSource,
|
RegisterSource: v.RegisterSource,
|
||||||
Age: v.Age,
|
Age: v.Age,
|
||||||
Sex: uint(v.Sex),
|
Sex: uint(v.Sex),
|
||||||
Avatar: utils.AddOssDomain(v.Avatar),
|
Avatar: utils.AddOssDomain(v.Avatar),
|
||||||
IsMember: v.IsMember,
|
IsMember: v.IsMember,
|
||||||
MemberExpireDate: v.MemberExpireDate,
|
MemberExpireDate: v.MemberExpireDate,
|
||||||
LoginAt: v.LoginAt,
|
SingleSubmitCount: v.SingleSubmitCount,
|
||||||
LoginIp: v.LoginIp,
|
SinglePayCount: v.SinglePayCount,
|
||||||
CreatedAt: v.CreatedAt,
|
MemberBuyCount: v.MemberBuyCount,
|
||||||
UpdatedAt: v.UpdatedAt,
|
LoginAt: v.LoginAt,
|
||||||
|
LoginIp: v.LoginIp,
|
||||||
|
CreatedAt: v.CreatedAt,
|
||||||
|
UpdatedAt: v.UpdatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载信息完善状态
|
// 加载信息完善状态
|
||||||
@ -68,20 +74,23 @@ func GetUserListDto(m []*model.User) []*UserDto {
|
|||||||
// GetUserDto 详情-问题
|
// GetUserDto 详情-问题
|
||||||
func GetUserDto(m *model.User) *UserDto {
|
func GetUserDto(m *model.User) *UserDto {
|
||||||
return &UserDto{
|
return &UserDto{
|
||||||
UserId: fmt.Sprintf("%d", m.UserId),
|
UserId: fmt.Sprintf("%d", m.UserId),
|
||||||
UserName: m.UserName,
|
UserName: m.UserName,
|
||||||
Mobile: m.Mobile,
|
Mobile: m.Mobile,
|
||||||
UserStatus: m.UserStatus,
|
UserStatus: m.UserStatus,
|
||||||
RegisterSource: m.RegisterSource,
|
RegisterSource: m.RegisterSource,
|
||||||
Age: m.Age,
|
Age: m.Age,
|
||||||
Sex: uint(m.Sex),
|
Sex: uint(m.Sex),
|
||||||
Avatar: utils.AddOssDomain(m.Avatar),
|
Avatar: utils.AddOssDomain(m.Avatar),
|
||||||
IsMember: m.IsMember,
|
IsMember: m.IsMember,
|
||||||
MemberExpireDate: m.MemberExpireDate,
|
MemberExpireDate: m.MemberExpireDate,
|
||||||
LoginAt: m.LoginAt,
|
SingleSubmitCount: m.SingleSubmitCount,
|
||||||
LoginIp: m.LoginIp,
|
SinglePayCount: m.SinglePayCount,
|
||||||
CreatedAt: m.CreatedAt,
|
MemberBuyCount: m.MemberBuyCount,
|
||||||
UpdatedAt: m.UpdatedAt,
|
LoginAt: m.LoginAt,
|
||||||
|
LoginIp: m.LoginIp,
|
||||||
|
CreatedAt: m.CreatedAt,
|
||||||
|
UpdatedAt: m.UpdatedAt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,6 +73,9 @@ func (r *UserCouponDto) LoadCoupon(m *model.Coupon) *UserCouponDto {
|
|||||||
if m != nil {
|
if m != nil {
|
||||||
d := GetCouponDto(m)
|
d := GetCouponDto(m)
|
||||||
|
|
||||||
|
// 加载会员id
|
||||||
|
d.LoadSystemMemberIds(m.SystemMemberIds)
|
||||||
|
|
||||||
r.Coupon = d
|
r.Coupon = d
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
|
|||||||
@ -22,8 +22,7 @@ type Coupon struct {
|
|||||||
ValidDays *int `gorm:"column:valid_days;type:int(3);comment:自领取之日起有效天数" json:"valid_days"`
|
ValidDays *int `gorm:"column:valid_days;type:int(3);comment:自领取之日起有效天数" json:"valid_days"`
|
||||||
ValidStartTime *LocalTime `gorm:"column:valid_start_time;type:datetime;comment:开始使用时间" json:"valid_start_time"`
|
ValidStartTime *LocalTime `gorm:"column:valid_start_time;type:datetime;comment:开始使用时间" json:"valid_start_time"`
|
||||||
ValidEndTime *LocalTime `gorm:"column:valid_end_time;type:datetime;comment:结束使用时间" json:"valid_end_time"`
|
ValidEndTime *LocalTime `gorm:"column:valid_end_time;type:datetime;comment:结束使用时间" json:"valid_end_time"`
|
||||||
QuestionId *int64 `gorm:"column:question_id;type:bigint(19);comment:问题id(适用范围为单项时生效,如果此项为null,则表示所有单项通用)" json:"question_id"`
|
SystemMemberIds string `gorm:"column:system_member_ids;type:bigint(19);comment:会员id(适用范围为会员时生效,如果此项为null,则表示所有会员通用)" json:"system_member_ids"`
|
||||||
SystemMemberId *int64 `gorm:"column:system_member_id;type:bigint(19);comment:会员id(适用范围为会员时生效,如果此项为null,则表示所有会员通用)" json:"system_member_id"`
|
|
||||||
CouponDesc string `gorm:"column:coupon_desc;type:varchar(200);comment:优惠卷描述" json:"coupon_desc"`
|
CouponDesc string `gorm:"column:coupon_desc;type:varchar(200);comment:优惠卷描述" json:"coupon_desc"`
|
||||||
Model
|
Model
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,18 +26,17 @@ type PutCouponStatus struct {
|
|||||||
|
|
||||||
// AddSystemCoupon 新增系统优惠卷
|
// AddSystemCoupon 新增系统优惠卷
|
||||||
type AddSystemCoupon struct {
|
type AddSystemCoupon struct {
|
||||||
CouponName string `json:"coupon_name" form:"coupon_name" label:"优惠券名称" validate:"required"`
|
CouponName string `json:"coupon_name" form:"coupon_name" label:"优惠券名称" validate:"required"`
|
||||||
CouponType int `json:"coupon_type" form:"coupon_type" label:"优惠券类型" validate:"required,oneof=1 2"` // (1:无门槛 2:满减)
|
CouponType int `json:"coupon_type" form:"coupon_type" label:"优惠券类型" validate:"required,oneof=1 2"` // (1:无门槛 2:满减)
|
||||||
ApplicationScope int `json:"application_scope" form:"application_scope" label:"适用范围" validate:"required,oneof=1 2 3"` // 适用范围(1:全场通用 2:单项 3:会员)
|
ApplicationScope int `json:"application_scope" form:"application_scope" label:"适用范围" validate:"required,oneof=1 2 3"` // 适用范围(1:全场通用 2:单项 3:会员)
|
||||||
IsMutex int `json:"is_mutex" form:"is_mutex" label:"是否互斥" validate:"required,oneof=0 1"` // (0:否 1:是)
|
IsMutex int `json:"is_mutex" form:"is_mutex" label:"是否互斥" validate:"required,oneof=0 1"` // (0:否 1:是)
|
||||||
CouponCount int `json:"coupon_count" form:"coupon_count" label:"发放数量" validate:"required,number,min=1"`
|
CouponCount int `json:"coupon_count" form:"coupon_count" label:"发放数量" validate:"required,number,min=1"`
|
||||||
CouponPrice float64 `json:"coupon_price" form:"coupon_price" label:"优惠券金额" validate:"required,numeric,gt=0"`
|
CouponPrice float64 `json:"coupon_price" form:"coupon_price" label:"优惠券金额" validate:"required,numeric,gt=0"`
|
||||||
WithAmount *float64 `json:"with_amount" form:"with_amount" label:"满减条件金额" validate:"omitempty,gt=1"`
|
WithAmount *float64 `json:"with_amount" form:"with_amount" label:"满减条件金额" validate:"omitempty,gt=1"`
|
||||||
ValidType int `json:"valid_type" form:"valid_type" label:"有效类型" validate:"required,oneof=1 2"` // (1:绝对时效,xxx-xxx时间段有效 2:相对时效 n天内有效)
|
ValidType int `json:"valid_type" form:"valid_type" label:"有效类型" validate:"required,oneof=1 2"` // (1:绝对时效,xxx-xxx时间段有效 2:相对时效 n天内有效)
|
||||||
ValidDays *int `json:"valid_days" form:"valid_days" label:"有效天数" validate:"omitempty,numeric,min=1"`
|
ValidDays *int `json:"valid_days" form:"valid_days" label:"有效天数" validate:"omitempty,numeric,min=1"`
|
||||||
ValidStartTime *string `json:"valid_start_time" form:"valid_start_time" label:"开始使用时间"` // 假设转换为字符串格式
|
ValidStartTime *string `json:"valid_start_time" form:"valid_start_time" label:"开始使用时间"` // 假设转换为字符串格式
|
||||||
ValidEndTime *string `json:"valid_end_time" form:"valid_end_time" label:"结束使用时间"` // 假设转换为字符串格式
|
ValidEndTime *string `json:"valid_end_time" form:"valid_end_time" label:"结束使用时间"` // 假设转换为字符串格式
|
||||||
QuestionId *string `json:"question_id" form:"question_id" label:"问题id"` // 从int64转换为string
|
SystemMemberIds []*string `json:"system_member_ids" form:"system_member_ids" label:"会员id"` // 会员id(逗号分割)
|
||||||
SystemMemberId *string `json:"system_member_id" form:"system_member_id" label:"会员id"` // 从int64转换为string
|
CouponDesc string `json:"coupon_desc" form:"coupon_desc" label:"优惠券描述"`
|
||||||
CouponDesc string `json:"coupon_desc" form:"coupon_desc" label:"优惠券描述"`
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,8 +38,6 @@ type GetQuestionPageOrder struct {
|
|||||||
|
|
||||||
// GetQuestionList 获取问题列表
|
// GetQuestionList 获取问题列表
|
||||||
type GetQuestionList struct {
|
type GetQuestionList struct {
|
||||||
Page int `json:"page" form:"page" label:"页码"`
|
|
||||||
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
|
||||||
QuestionId string `json:"question_id" form:"question_id" label:"主键id"`
|
QuestionId string `json:"question_id" form:"question_id" label:"主键id"`
|
||||||
QuestionTitle string `json:"question_title" form:"question_title" label:"标题"`
|
QuestionTitle string `json:"question_title" form:"question_title" label:"标题"`
|
||||||
QuestionSubtitle string `json:"question_subtitle" form:"question_subtitle" label:"副标题"`
|
QuestionSubtitle string `json:"question_subtitle" form:"question_subtitle" label:"副标题"`
|
||||||
|
|||||||
@ -2,10 +2,12 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"hepa-calc-admin-api/api/dao"
|
"hepa-calc-admin-api/api/dao"
|
||||||
"hepa-calc-admin-api/api/dto"
|
"hepa-calc-admin-api/api/dto"
|
||||||
"hepa-calc-admin-api/api/model"
|
"hepa-calc-admin-api/api/model"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,10 +60,6 @@ func (r *UserCouponService) CheckUserCoupon(m *model.UserCoupon, id int64, order
|
|||||||
if m.Coupon.ApplicationScope != 1 && m.Coupon.ApplicationScope != 2 {
|
if m.Coupon.ApplicationScope != 1 && m.Coupon.ApplicationScope != 2 {
|
||||||
return false, errors.New("优惠卷无法使用")
|
return false, errors.New("优惠卷无法使用")
|
||||||
}
|
}
|
||||||
|
|
||||||
if id != *m.Coupon.QuestionId {
|
|
||||||
return false, errors.New("优惠卷无法使用")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 会员
|
// 会员
|
||||||
@ -70,7 +68,9 @@ func (r *UserCouponService) CheckUserCoupon(m *model.UserCoupon, id int64, order
|
|||||||
return false, errors.New("优惠卷无法使用")
|
return false, errors.New("优惠卷无法使用")
|
||||||
}
|
}
|
||||||
|
|
||||||
if id != *m.Coupon.SystemMemberId {
|
systemMemberIds := fmt.Sprintf("%d", id)
|
||||||
|
res := strings.Contains(m.Coupon.SystemMemberIds, systemMemberIds)
|
||||||
|
if res == false {
|
||||||
return false, errors.New("优惠卷无法使用")
|
return false, errors.New("优惠卷无法使用")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user