Commit 17895640 by 孙龙
parents c283afc9 6b70f89e
Showing with 42 additions and 38 deletions
......@@ -3,12 +3,12 @@ package sendEmail
import (
"encoding/json"
"github.com/ichunt2019/logger"
"go-queue-server/dal/order/OrderActionLog"
_"go-queue-server/dal/order/OrderActionLog"
"go-queue-server/util"
"go-queue-server/util/ding"
"io/ioutil"
"net/http"
"strconv"
_"strconv"
"strings"
)
......@@ -45,44 +45,48 @@ func SendPurchaseEmail(data string) (err error) {
return err
}
// 添加操作日志
var data_params *DataParams
json.Unmarshal([]byte(data), &data_params)
if data_params.OrderId == 0 {
ding.Send(util.Configs.Ding_msg.Webhook, "监控告警", "推送采购员:"+data, mobile, isAtAll)
return
}
order_id := data_params.OrderId
operator_id := data_params.OperatorId
operator_event := data_params.OperatorEvent
err = OrderActionLog.Insert(order_id, operator_id, 2, operator_event)
if err != nil {
ding.Send(util.Configs.Ding_msg.Webhook,"监控告警","添加操作日志失败", mobile, isAtAll)
return err
}
// 推送ERP
api_url := util.Configs.Api_domain.ApiUrl + "order/sysiteminfo"
params := "order_id="+strconv.Itoa(order_id)
api_header_map := map[string]string{
"Content-Type": "application/x-www-form-urlencoded",
}
err = http_post(api_url, params, api_header_map)
if err != nil {
ding.Send(util.Configs.Ding_msg.Webhook, "监控告警", "ERP同步接口请求失败,原因:" + err.Error(), mobile, isAtAll)
logger.Info(err.Error())
return err
}
ding.Send(util.Configs.Ding_msg.Webhook, "监控告警", "订单ID:" + strconv.Itoa(order_id) + "," + operator_event + ",字段同步ERP成功", mobile, isAtAll)
ding.Send(util.Configs.Ding_msg.Webhook, "监控告警", "推送采购邮件:" + data, mobile, isAtAll)
return
//// 添加操作日志
//var data_params *DataParams
//json.Unmarshal([]byte(data), &data_params)
//if data_params.OrderId == 0 {
// ding.Send(util.Configs.Ding_msg.Webhook, "监控告警", "推送采购员:"+data, mobile, isAtAll)
// return
//}
//
//order_id := data_params.OrderId
//operator_id := data_params.OperatorId
//operator_event := data_params.OperatorEvent
//
//err = OrderActionLog.Insert(order_id, operator_id, 2, operator_event)
//
//if err != nil {
// ding.Send(util.Configs.Ding_msg.Webhook,"监控告警","添加操作日志失败", mobile, isAtAll)
// return err
//}
//
//// 推送ERP
//api_url := util.Configs.Api_domain.ApiUrl + "order/sysiteminfo"
//params := "order_id="+strconv.Itoa(order_id)
//api_header_map := map[string]string{
// "Content-Type": "application/x-www-form-urlencoded",
//}
//
//err = http_post(api_url, params, api_header_map)
//
//if err != nil {
// ding.Send(util.Configs.Ding_msg.Webhook, "监控告警", "ERP同步接口请求失败,原因:" + err.Error(), mobile, isAtAll)
// logger.Info(err.Error())
// return err
//}
//
//ding.Send(util.Configs.Ding_msg.Webhook, "监控告警", "订单ID:" + strconv.Itoa(order_id) + "," + operator_event + ",字段同步ERP成功", mobile, isAtAll)
//
//return
}
func http_post(url string, data string, header map[string]string) (err error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment