new
This commit is contained in:
@@ -302,6 +302,12 @@ func (s *BaiduOCRService) parseBusinessLicenseResult(result map[string]interface
|
||||
registeredCapital = registeredCapitalObj["words"].(string)
|
||||
}
|
||||
|
||||
// 提取企业地址
|
||||
address := ""
|
||||
if addressObj, ok := wordsResult["地址"].(map[string]interface{}); ok {
|
||||
address = addressObj["words"].(string)
|
||||
}
|
||||
|
||||
// 计算置信度(这里简化处理,实际应该从OCR结果中获取)
|
||||
confidence := 0.9 // 默认置信度
|
||||
|
||||
@@ -309,8 +315,11 @@ func (s *BaiduOCRService) parseBusinessLicenseResult(result map[string]interface
|
||||
CompanyName: companyName,
|
||||
UnifiedSocialCode: unifiedSocialCode,
|
||||
LegalPersonName: legalPersonName,
|
||||
LegalPersonID: "", // 营业执照上没有法人身份证号
|
||||
RegisteredCapital: registeredCapital,
|
||||
Address: address,
|
||||
Confidence: confidence,
|
||||
ProcessedAt: time.Now(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
||||
"go.uber.org/zap"
|
||||
@@ -64,6 +65,73 @@ func (s *AliSMSService) SendVerificationCode(ctx context.Context, phone string,
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendBalanceAlert 发送余额预警短信
|
||||
func (s *AliSMSService) SendBalanceAlert(ctx context.Context, phone string, balance float64, threshold float64, alertType string, enterpriseName ...string) error {
|
||||
request := dysmsapi.CreateSendSmsRequest()
|
||||
request.Scheme = "https"
|
||||
request.PhoneNumbers = phone
|
||||
request.SignName = s.config.SignName
|
||||
|
||||
var templateCode string
|
||||
var templateParam string
|
||||
|
||||
if alertType == "low_balance" {
|
||||
// 低余额预警也使用欠费预警模板
|
||||
templateCode = "SMS_494605047" // 阿里云欠费预警模板
|
||||
|
||||
// 使用传入的企业名称,如果没有则使用默认值
|
||||
name := "天远数据用户"
|
||||
if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
||||
name = enterpriseName[0]
|
||||
}
|
||||
|
||||
templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
||||
name, time.Now().Format("2006-01-02 15:04:05"), threshold)
|
||||
} else if alertType == "arrears" {
|
||||
// 欠费预警模板
|
||||
templateCode = "SMS_494605047" // 阿里云欠费预警模板
|
||||
|
||||
// 使用传入的企业名称,如果没有则使用默认值
|
||||
name := "天远数据用户"
|
||||
if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
||||
name = enterpriseName[0]
|
||||
}
|
||||
|
||||
templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
||||
name, time.Now().Format("2006-01-02 15:04:05"), balance)
|
||||
} else {
|
||||
return fmt.Errorf("不支持的预警类型: %s", alertType)
|
||||
}
|
||||
|
||||
request.TemplateCode = templateCode
|
||||
request.TemplateParam = templateParam
|
||||
|
||||
response, err := s.client.SendSms(request)
|
||||
if err != nil {
|
||||
s.logger.Error("发送余额预警短信失败",
|
||||
zap.String("phone", phone),
|
||||
zap.String("alert_type", alertType),
|
||||
zap.Error(err))
|
||||
return fmt.Errorf("短信发送失败: %w", err)
|
||||
}
|
||||
|
||||
if response.Code != "OK" {
|
||||
s.logger.Error("余额预警短信发送失败",
|
||||
zap.String("phone", phone),
|
||||
zap.String("alert_type", alertType),
|
||||
zap.String("code", response.Code),
|
||||
zap.String("message", response.Message))
|
||||
return fmt.Errorf("短信发送失败: %s - %s", response.Code, response.Message)
|
||||
}
|
||||
|
||||
s.logger.Info("余额预警短信发送成功",
|
||||
zap.String("phone", phone),
|
||||
zap.String("alert_type", alertType),
|
||||
zap.String("bizId", response.BizId))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GenerateCode 生成验证码
|
||||
func (s *AliSMSService) GenerateCode(length int) string {
|
||||
if length <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user