修改了系统优惠卷 问诊类型
This commit is contained in:
parent
52888553bf
commit
7f5330361f
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"hospital-admin-api/api/model"
|
"hospital-admin-api/api/model"
|
||||||
"hospital-admin-api/utils"
|
"hospital-admin-api/utils"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CouponDto 优惠卷表
|
// CouponDto 优惠卷表
|
||||||
@ -16,7 +17,7 @@ type CouponDto struct {
|
|||||||
CouponStatus int `json:"coupon_status"` // 状态(1:正常 2:强制失效 3:结束 4:删除)
|
CouponStatus int `json:"coupon_status"` // 状态(1:正常 2:强制失效 3:结束 4:删除)
|
||||||
DistributionObject int `json:"distribution_object"` // 发放对象(1:全部用户 2:新注册用户 3:会员 4:近期消费 5:近期购药 6:存量用户 7:健康包服务用户)
|
DistributionObject int `json:"distribution_object"` // 发放对象(1:全部用户 2:新注册用户 3:会员 4:近期消费 5:近期购药 6:存量用户 7:健康包服务用户)
|
||||||
ApplicationScope int `json:"application_scope"` // 适用范围(1:全场通用 2:问诊 3:按品牌适用 4:按类别适用 5:单品使用 6:全品类药品)
|
ApplicationScope int `json:"application_scope"` // 适用范围(1:全场通用 2:问诊 3:按品牌适用 4:按类别适用 5:单品使用 6:全品类药品)
|
||||||
InquiryType string `json:"inquiry_type"` // 关联问诊类型,application_scope=问诊时存在生效,逗号分隔(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药 6:检测)
|
InquiryType []string `json:"inquiry_type"` // 关联问诊类型,application_scope=问诊时存在生效,逗号分隔(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药 6:检测)
|
||||||
BrandId string `json:"brand_id"` // 关联品牌id(如不限制品牌,此项为空)
|
BrandId string `json:"brand_id"` // 关联品牌id(如不限制品牌,此项为空)
|
||||||
IsMutex int `json:"is_mutex"` // 是否互斥(0:否 1:是)互斥情况下无法和其他优惠卷同时使用
|
IsMutex int `json:"is_mutex"` // 是否互斥(0:否 1:是)互斥情况下无法和其他优惠卷同时使用
|
||||||
IsDisplay int `json:"is_display"` // 是否展示(0:否 1:是)
|
IsDisplay int `json:"is_display"` // 是否展示(0:否 1:是)
|
||||||
@ -52,7 +53,6 @@ func GetCouponDto(m *model.Coupon) *CouponDto {
|
|||||||
CouponStatus: m.CouponStatus,
|
CouponStatus: m.CouponStatus,
|
||||||
DistributionObject: m.DistributionObject,
|
DistributionObject: m.DistributionObject,
|
||||||
ApplicationScope: m.ApplicationScope,
|
ApplicationScope: m.ApplicationScope,
|
||||||
InquiryType: m.InquiryType,
|
|
||||||
BrandId: fmt.Sprintf("%d", m.BrandId),
|
BrandId: fmt.Sprintf("%d", m.BrandId),
|
||||||
IsMutex: *m.IsMutex,
|
IsMutex: *m.IsMutex,
|
||||||
IsDisplay: m.IsDisplay,
|
IsDisplay: m.IsDisplay,
|
||||||
@ -93,7 +93,6 @@ func GetCouponListDto(m []*model.Coupon) []*CouponDto {
|
|||||||
CouponStatus: v.CouponStatus,
|
CouponStatus: v.CouponStatus,
|
||||||
DistributionObject: v.DistributionObject,
|
DistributionObject: v.DistributionObject,
|
||||||
ApplicationScope: v.ApplicationScope,
|
ApplicationScope: v.ApplicationScope,
|
||||||
InquiryType: v.InquiryType,
|
|
||||||
BrandId: fmt.Sprintf("%d", v.BrandId),
|
BrandId: fmt.Sprintf("%d", v.BrandId),
|
||||||
IsMutex: *v.IsMutex,
|
IsMutex: *v.IsMutex,
|
||||||
IsDisplay: v.IsDisplay,
|
IsDisplay: v.IsDisplay,
|
||||||
@ -117,6 +116,11 @@ func GetCouponListDto(m []*model.Coupon) []*CouponDto {
|
|||||||
UpdatedAt: v.UpdatedAt,
|
UpdatedAt: v.UpdatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载关联问诊类型
|
||||||
|
if v.InquiryType != "" {
|
||||||
|
response.LoadInquiryType(v.InquiryType)
|
||||||
|
}
|
||||||
|
|
||||||
// 将转换后的结构体添加到新切片中
|
// 将转换后的结构体添加到新切片中
|
||||||
responses[i] = response
|
responses[i] = response
|
||||||
}
|
}
|
||||||
@ -134,3 +138,13 @@ func (r *CouponDto) LoadCouponGrant(m []*model.CouponGrant) *CouponDto {
|
|||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadInquiryType 加载关联问诊类型
|
||||||
|
func (r *CouponDto) LoadInquiryType(m string) *CouponDto {
|
||||||
|
if m != "" {
|
||||||
|
inquiryType := strings.Split(m, ",")
|
||||||
|
|
||||||
|
r.InquiryType = inquiryType
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ type AddSystemCoupon struct {
|
|||||||
CouponType *int `json:"coupon_type" form:"coupon_type" label:"优惠卷类型" validate:"required,oneof=1 2 3"` // 优惠卷类型(1 :无门槛 2:满减 3:数量)
|
CouponType *int `json:"coupon_type" form:"coupon_type" label:"优惠卷类型" validate:"required,oneof=1 2 3"` // 优惠卷类型(1 :无门槛 2:满减 3:数量)
|
||||||
DistributionObject *int `json:"distribution_object" form:"distribution_object" label:"发放对象" validate:"required,oneof=1 2 3 4 5 6 7"`
|
DistributionObject *int `json:"distribution_object" form:"distribution_object" label:"发放对象" validate:"required,oneof=1 2 3 4 5 6 7"`
|
||||||
ApplicationScope *int `json:"application_scope" form:"application_scope" label:"适用范围" validate:"required,oneof=1 2 3 4 5 6"` // (1:全场通用 2:问诊 3:按品牌适用 4:按类别适用 5:单品使用 6:全品类药品)
|
ApplicationScope *int `json:"application_scope" form:"application_scope" label:"适用范围" validate:"required,oneof=1 2 3 4 5 6"` // (1:全场通用 2:问诊 3:按品牌适用 4:按类别适用 5:单品使用 6:全品类药品)
|
||||||
InquiryType *string `json:"inquiry_type" form:"inquiry_type" label:"关联问诊类型" validate:"omitempty,oneof=1 2 3 4 5 6"` // 关联问诊类型,application_scope=问诊时存在生效,逗号分隔(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药 6:检测)
|
InquiryType []string `json:"inquiry_type" form:"inquiry_type" label:"关联问诊类型"` // 关联问诊类型,application_scope=问诊时存在生效,逗号分隔(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药 6:检测)
|
||||||
BrandId *string `json:"brand_id" form:"brand_id" label:"关联品牌id"` // 关联品牌id(如不限制品牌,此项为空)
|
BrandId *string `json:"brand_id" form:"brand_id" label:"关联品牌id"` // 关联品牌id(如不限制品牌,此项为空)
|
||||||
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:是)互斥情况下无法和其他优惠卷同时使用
|
||||||
IsDisplay *int `json:"is_display" form:"is_display" label:"是否展示" validate:"required,oneof=0 1"` // 是否展示(0:否 1:是)
|
IsDisplay *int `json:"is_display" form:"is_display" label:"是否展示" validate:"required,oneof=0 1"` // 是否展示(0:否 1:是)
|
||||||
@ -63,7 +63,7 @@ type PutSystemCoupon struct {
|
|||||||
CouponName string `json:"coupon_name" form:"coupon_name" label:"优惠卷名称" validate:"required"` // 优惠卷名称
|
CouponName string `json:"coupon_name" form:"coupon_name" label:"优惠卷名称" validate:"required"` // 优惠卷名称
|
||||||
CouponIcon string `json:"coupon_icon" form:"coupon_icon" label:"头像"` // 优惠卷名称
|
CouponIcon string `json:"coupon_icon" form:"coupon_icon" label:"头像"` // 优惠卷名称
|
||||||
DistributionObject *int `json:"distribution_object" form:"distribution_object" label:"发放对象" validate:"required,oneof=1 2 3 4 5 6 7"` // (1:全部用户 2:新注册用户 3:会员 4:近期消费 5:近期购药 6:存量用户 7:健康包服务用户)
|
DistributionObject *int `json:"distribution_object" form:"distribution_object" label:"发放对象" validate:"required,oneof=1 2 3 4 5 6 7"` // (1:全部用户 2:新注册用户 3:会员 4:近期消费 5:近期购药 6:存量用户 7:健康包服务用户)
|
||||||
InquiryType *string `json:"inquiry_type" form:"inquiry_type" label:"关联问诊类型" validate:"omitempty,oneof=1 2 3 4 5 6"` // 关联问诊类型,application_scope=问诊时存在生效,逗号分隔(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药 6:检测)
|
InquiryType []string `json:"inquiry_type" form:"inquiry_type" label:"关联问诊类型"` // 关联问诊类型,application_scope=问诊时存在生效,逗号分隔(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药 6:检测)
|
||||||
BrandId *string `json:"brand_id" form:"brand_id" label:"关联品牌id"` // 关联品牌id(如不限制品牌,此项为空)
|
BrandId *string `json:"brand_id" form:"brand_id" label:"关联品牌id"` // 关联品牌id(如不限制品牌,此项为空)
|
||||||
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:是)互斥情况下无法和其他优惠卷同时使用
|
||||||
IsDisplay *int `json:"is_display" form:"is_display" label:"是否展示" validate:"required,oneof=0 1"` // 是否展示(0:否 1:是)
|
IsDisplay *int `json:"is_display" form:"is_display" label:"是否展示" validate:"required,oneof=0 1"` // 是否展示(0:否 1:是)
|
||||||
|
|||||||
@ -35,6 +35,11 @@ func (r *CouponService) GetSystemCoupon(couponId int64) (g *dto.CouponDto, err e
|
|||||||
g = g.LoadCouponGrant(coupon.CouponGrant)
|
g = g.LoadCouponGrant(coupon.CouponGrant)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载关联问诊类型
|
||||||
|
if coupon.InquiryType != "" {
|
||||||
|
g.LoadInquiryType(coupon.InquiryType)
|
||||||
|
}
|
||||||
|
|
||||||
return g, nil
|
return g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +86,7 @@ func (r *CouponService) AddSystemCoupon(req requests.AddSystemCoupon) (bool, err
|
|||||||
// 适用范围-问诊
|
// 适用范围-问诊
|
||||||
if *req.ApplicationScope == 2 {
|
if *req.ApplicationScope == 2 {
|
||||||
// 关联问诊类型
|
// 关联问诊类型
|
||||||
if req.InquiryType == nil {
|
if len(req.InquiryType) == 0 {
|
||||||
return false, errors.New("请填入关联问诊类型")
|
return false, errors.New("请填入关联问诊类型")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,8 +211,8 @@ func (r *CouponService) AddSystemCoupon(req requests.AddSystemCoupon) (bool, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 关联问诊类型
|
// 关联问诊类型
|
||||||
if req.InquiryType != nil {
|
if len(req.InquiryType) > 0 {
|
||||||
coupon.InquiryType = *req.InquiryType
|
coupon.InquiryType = strings.Join(req.InquiryType, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发放关联天数
|
// 发放关联天数
|
||||||
@ -306,8 +311,9 @@ func (r *CouponService) PutSystemCoupon(couponId int64, req requests.PutSystemCo
|
|||||||
|
|
||||||
// 关联问诊类型
|
// 关联问诊类型
|
||||||
if coupon.ApplicationScope == 2 {
|
if coupon.ApplicationScope == 2 {
|
||||||
if req.InquiryType != nil {
|
if len(req.InquiryType) > 0 {
|
||||||
if *req.InquiryType != coupon.InquiryType {
|
inquiryType := strings.Join(req.InquiryType, ",")
|
||||||
|
if inquiryType != coupon.InquiryType {
|
||||||
couponData["inquiry_type"] = req.InquiryType
|
couponData["inquiry_type"] = req.InquiryType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -663,3 +663,23 @@ func AddFinishStatusToString(i int) string {
|
|||||||
return "未知"
|
return "未知"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CouponInquiryTypeToString 关联问诊类型,application_scope=问诊时存在生效,逗号分隔(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药 6:检测)
|
||||||
|
func CouponInquiryTypeToString(i int) string {
|
||||||
|
switch i {
|
||||||
|
case 1:
|
||||||
|
return "全部"
|
||||||
|
case 2:
|
||||||
|
return "快速问诊"
|
||||||
|
case 3:
|
||||||
|
return "专家问诊"
|
||||||
|
case 4:
|
||||||
|
return "公益问诊"
|
||||||
|
case 5:
|
||||||
|
return "问诊购药"
|
||||||
|
case 6:
|
||||||
|
return "检测"
|
||||||
|
default:
|
||||||
|
return "未知"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user