1、接码服务返回 续费金额

This commit is contained in:
2025-09-02 14:35:53 +08:00
parent f73639a96c
commit ab61808bf1
2 changed files with 38 additions and 14 deletions

View File

@ -118,6 +118,7 @@ type SmsServicesGetListResp struct {
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 {

View File

@ -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 {
@ -131,6 +133,7 @@ func (e SmsServices) GetList(resp *[]dto.SmsServicesGetListResp) error {
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)