|
|
@@ -10,50 +10,54 @@ import (
|
|
|
|
|
|
type UnreadMessageRequest struct {
|
|
|
Type string `json:"type"`
|
|
|
- Id int32 `json:"id"`
|
|
|
+ ShopId int32 `json:"id"`
|
|
|
+ UserId int32 `json:"userId"`
|
|
|
MsgCount int `json:"msgCount"`
|
|
|
}
|
|
|
|
|
|
// 请求函数 -- 根据请求项目选择请求方式
|
|
|
-func RequestToPHP(receiverType string, receiverID int32, count int) error {
|
|
|
+func RequestToPHP(receiver string, shopId int32, userId int32, count int) error {
|
|
|
var project string
|
|
|
- if receiverType == "shop" {
|
|
|
+ if receiver == "shop" {
|
|
|
project = "huaZhangGui"
|
|
|
- } else if receiverType == "customer" {
|
|
|
+ } else if receiver == "customer" {
|
|
|
project = "huaHuiBao"
|
|
|
}
|
|
|
|
|
|
ctx := context.Background()
|
|
|
switch project {
|
|
|
case "huaZhangGui":
|
|
|
- url := os.Getenv("HUA_ZHANG_GUI_URL")
|
|
|
+ //url := os.Getenv("HUA_ZHANG_GUI_URL")
|
|
|
+ url := os.Getenv("HUA_HUI_BAO_URL")
|
|
|
reqData := UnreadMessageRequest{
|
|
|
Type: "shop",
|
|
|
- Id: receiverID,
|
|
|
+ ShopId: shopId,
|
|
|
+ UserId: userId,
|
|
|
MsgCount: count,
|
|
|
}
|
|
|
huaZhangGuiClient := NewHuaZhangGuiClient(url)
|
|
|
res, err := huaZhangGuiClient.PostUnReadMessage(ctx, reqData)
|
|
|
if err != nil {
|
|
|
- log.Error().Str("receiverType", receiverType).Int32("receiverID", receiverID).Int("count", count).Err(err).Msg("向 PHP 服务发送未读消息通知失败")
|
|
|
+ log.Error().Str("receiverType", receiver).Int32("receiverID", shopId).Int("count", count).Err(err).Msg("向 PHP 服务发送未读消息通知失败")
|
|
|
return err
|
|
|
}
|
|
|
- log.Info().Str("receiverType", receiverType).Int32("receiverID", receiverID).Int("count", count).Str("res", res).Msg("向 PHP 服务发送未读消息通知成功")
|
|
|
+ log.Info().Str("receiverType", receiver).Int32("receiverID", shopId).Int("count", count).Str("res", res).Msg("向 PHP 服务发送未读消息通知成功")
|
|
|
|
|
|
case "huaHuiBao":
|
|
|
- url := os.Getenv("HUA_HUI_BAO_URL")
|
|
|
- reqData := UnreadMessageRequest{
|
|
|
- Type: "customer",
|
|
|
- Id: receiverID,
|
|
|
- MsgCount: count,
|
|
|
- }
|
|
|
- huaHuiBaoClient := NewHuaHuiBaoClient(url)
|
|
|
- res, err := huaHuiBaoClient.PostUnReadMessage(ctx, reqData)
|
|
|
- if err != nil {
|
|
|
- log.Error().Str("receiverType", receiverType).Int32("receiverID", receiverID).Int("count", count).Err(err).Msg("向 PHP 服务发送未读消息通知失败")
|
|
|
- return err
|
|
|
- }
|
|
|
- log.Info().Str("receiverType", receiverType).Int32("receiverID", receiverID).Int("count", count).Str("res", res).Msg("向 PHP 服务发送未读消息通知成功")
|
|
|
+ ////url := os.Getenv("HUA_HUI_BAO_URL")
|
|
|
+ // url := os.Getenv("HUA_ZHANG_GUI_URL")
|
|
|
+ // reqData := UnreadMessageRequest{
|
|
|
+ // Type: "customer",
|
|
|
+ // Id: receiverID,
|
|
|
+ // MsgCount: count,
|
|
|
+ // }
|
|
|
+ // huaHuiBaoClient := NewHuaHuiBaoClient(url)
|
|
|
+ // res, err := huaHuiBaoClient.PostUnReadMessage(ctx, reqData)
|
|
|
+ // if err != nil {
|
|
|
+ // log.Error().Str("receiverType", receiverType).Int32("receiverID", receiverID).Int("count", count).Err(err).Msg("向 PHP 服务发送未读消息通知失败")
|
|
|
+ // return err
|
|
|
+ // }
|
|
|
+ // log.Info().Str("receiverType", receiverType).Int32("receiverID", receiverID).Int("count", count).Str("res", res).Msg("向 PHP 服务发送未读消息通知成功")
|
|
|
}
|
|
|
|
|
|
return nil
|