From ab61808bf1d410d94f30890712e36d9e518e8042 Mon Sep 17 00:00:00 2001 From: hucan <951870319@qq.com> Date: Tue, 2 Sep 2025 14:35:53 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=8E=A5=E7=A0=81=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=20=E7=BB=AD=E8=B4=B9=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/dto/sms_services.go | 15 ++++++----- app/admin/service/sms_services.go | 37 ++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/app/admin/service/dto/sms_services.go b/app/admin/service/dto/sms_services.go index a70218e..12ff593 100644 --- a/app/admin/service/dto/sms_services.go +++ b/app/admin/service/dto/sms_services.go @@ -111,13 +111,14 @@ func (s *SmsServicesDeleteReq) GetId() interface{} { } type SmsServicesGetListResp struct { - PlatformCode string `json:"platformCode" comment:"平台编码"` - PlatformName string `json:"platformName" comment:"平台名称"` - Code string `json:"code" comment:"编码"` - Name string `json:"name" comment:"服务名称"` - Status int `json:"status" comment:"状态"` - Price decimal.Decimal `json:"price" comment:"价格"` - LongPrice decimal.Decimal `json:"longPrice" comment:"长号码价格"` + PlatformCode string `json:"platformCode" comment:"平台编码"` + PlatformName string `json:"platformName" comment:"平台名称"` + Code string `json:"code" comment:"编码"` + Name string `json:"name" comment:"服务名称"` + Status int `json:"status" comment:"状态"` + Price decimal.Decimal `json:"price" comment:"价格"` + LongPrice decimal.Decimal `json:"longPrice" comment:"长号码价格"` + RenewLongPrice decimal.Decimal `json:"renewLongPrice" comment:"续费长号码价格"` } type SmsGetPriceReq struct { diff --git a/app/admin/service/sms_services.go b/app/admin/service/sms_services.go index 2030aeb..8109a44 100644 --- a/app/admin/service/sms_services.go +++ b/app/admin/service/sms_services.go @@ -115,7 +115,9 @@ func (e SmsServices) GetList(resp *[]dto.SmsServicesGetListResp) error { dictService := SysDictData{Service: e.Service} dictDatas, _ := dictService.GetMapByType("sms_platform") - keys := []string{"number_premium_daisysms", "number_premium_textverified", "long_number_premium_daisysms", "long_number_premium_textverified"} + keys := []string{"number_premium_daisysms", "number_premium_textverified", + "long_number_premium_daisysms", "long_number_premium_textverified", + "renew_number_premium_daisysms", "renew_number_premium_textverified"} configService := SysConfig{Service: e.Service} mapConfigs, err := configService.GetWithKeyForMap(keys) if err != nil { @@ -125,12 +127,13 @@ func (e SmsServices) GetList(resp *[]dto.SmsServicesGetListResp) error { for _, item := range data { respItem := dto.SmsServicesGetListResp{ - Name: item.Name, - Code: item.Code, - Status: item.Status, - PlatformCode: item.PlatformCode, - Price: item.Price, - LongPrice: item.LongPrice, + Name: item.Name, + Code: item.Code, + Status: item.Status, + PlatformCode: item.PlatformCode, + Price: item.Price, + LongPrice: item.LongPrice, + RenewLongPrice: item.LongPrice, } if dict, ok := dictDatas[respItem.PlatformCode]; ok { @@ -157,6 +160,15 @@ func (e SmsServices) GetList(resp *[]dto.SmsServicesGetListResp) error { respItem.LongPrice = respItem.LongPrice.Mul(decimal.NewFromInt(100).Add(premium).Div(decimal.NewFromInt(100))).Truncate(2) } } + + if config, ok := mapConfigs["renew_number_premium_daisysms"]; ok { + premium, err := decimal.NewFromString(config.ConfigValue) + if err != nil || premium.IsZero() { + e.Log.Errorf("浮动百分比为0,或者是转换错误 %s", config.ConfigValue) + } + + respItem.RenewLongPrice = respItem.LongPrice.Mul(decimal.NewFromInt(100).Add(premium).Div(decimal.NewFromInt(100))).Truncate(2) + } case global.SmsPlatformTextVerified: if config, ok := mapConfigs["number_premium_textverified"]; ok { premium, err := decimal.NewFromString(config.ConfigValue) @@ -176,6 +188,17 @@ func (e SmsServices) GetList(resp *[]dto.SmsServicesGetListResp) error { respItem.LongPrice = respItem.LongPrice.Mul(decimal.NewFromInt(100).Add(premium).Div(decimal.NewFromInt(100))).Truncate(2) } } + + //续期价格浮动 + if config, ok := mapConfigs["renew_number_premium_textverified"]; ok { + premium, err := decimal.NewFromString(config.ConfigValue) + + if err != nil || premium.IsZero() { + e.Log.Errorf("浮动百分比为0,或者是转换错误 %s", config.ConfigValue) + } + + respItem.RenewLongPrice = respItem.LongPrice.Mul(decimal.NewFromInt(100).Add(premium).Div(decimal.NewFromInt(100))).Truncate(2) + } } *resp = append(*resp, respItem)