Files
kami_boss/internal/service/sendNotifyMerchantService.go
danial 7f7e3b43c3 fix(service): 修改通知商户服务中的 HTTP 请求方法
- 将发送通知商户服务中的 HTTP 请求方法从 POST 改为 GET
- 在两个不同的函数中进行了此修改,以确保一致性
2025-01-20 23:51:50 +08:00

62 lines
1.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package service
import (
"boss/internal/common"
"boss/internal/datas"
"boss/internal/models/notify"
"boss/internal/models/order"
"fmt"
"github.com/beego/beego/v2/client/httplib"
"github.com/beego/beego/v2/core/logs"
"strings"
)
type SendNotifyMerchantService struct {
}
func (c *SendNotifyMerchantService) SendNotifyToMerchant(bankOrderId string) *datas.KeyDataJSON {
keyDataJSON := new(datas.KeyDataJSON)
keyDataJSON.Code = -1
orderInfo := order.GetOrderByBankOrderId(bankOrderId)
if orderInfo.Status == common.OrderStatusWait {
keyDataJSON.Msg = "该订单不是成功状态,不能回调"
} else {
notifyInfo := notify.GetNotifyInfoByBankOrderId(bankOrderId)
notifyUrl := notifyInfo.Url
logs.Info(fmt.Sprintf("boss管理后台手动触发订单回调url=%s", notifyUrl))
req := httplib.Get(notifyUrl)
response, err := req.String()
if err != nil {
logs.Error("回调发送失败fail", err)
keyDataJSON.Msg = fmt.Sprintf("该订单回调发送失败订单回调fail%s", err)
} else {
if !strings.Contains(strings.ToLower(response), "success") {
keyDataJSON.Msg = fmt.Sprintf("该订单回调发送成功但是未返回success字段 商户返回内容=%s",
response)
} else {
keyDataJSON.Code = 200
keyDataJSON.Msg = fmt.Sprintf("该订单回调发送成功")
}
}
}
return keyDataJSON
}
func (c *SendNotifyMerchantService) SelfSendNotify(bankOrderId string) *datas.KeyDataJSON {
notifyInfo := notify.GetNotifyInfoByBankOrderId(bankOrderId)
keyDataJSON := new(datas.KeyDataJSON)
keyDataJSON.Code = 200
req := httplib.Get(notifyInfo.Url)
response, err := req.String()
if err != nil {
keyDataJSON.Msg = fmt.Sprintf("订单 bankOrderId=%s已经发送回调出错%s", bankOrderId, err)
} else {
keyDataJSON.Msg = fmt.Sprintf("订单 bankOrderId=%s已经发送回调商户返回内容%s",
bankOrderId, response)
}
return keyDataJSON
}