|
@@ -6,7 +6,9 @@ import (
|
|
|
. "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/pushpkg/p"
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/userCenter/identity"
|
|
|
+ "bytes"
|
|
|
"encoding/csv"
|
|
|
+ "encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/v2/container/garray"
|
|
@@ -19,9 +21,11 @@ import (
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
|
"github.com/gogf/gf/v2/util/guid"
|
|
|
"github.com/smartwalle/alipay/v3"
|
|
|
+ "io/ioutil"
|
|
|
"jy/src/jfw/modules/subscribepay/src/config"
|
|
|
"jy/src/jfw/modules/subscribepay/src/util"
|
|
|
"log"
|
|
|
+ "net/http"
|
|
|
"net/url"
|
|
|
"time"
|
|
|
)
|
|
@@ -199,7 +203,7 @@ func (b *bidCreditReport) ReportQuery(orderNo string) bool {
|
|
|
func (b *bidCreditReport) sendMail(userId, userMail, entName, buyer, downloadUrl, orderCode string) bool {
|
|
|
ctx := gctx.New()
|
|
|
previewUrl := fmt.Sprintf("%s/swordfish/page_big_pc/free/report/preview?url=%s", config.Config.WebDomain, url.QueryEscape(downloadUrl))
|
|
|
- content := fmt.Sprintf(g.Config().MustGet(ctx, "bidCreditReport.mailContent").String(), downloadUrl, previewUrl, entName, buyer)
|
|
|
+ content := fmt.Sprintf(g.Config().MustGet(ctx, "bidCreditReport.mailContent").String(), downloadUrl, config.Config.WebDomain, previewUrl, entName, buyer)
|
|
|
log.Println("开始给", userId, orderCode, userMail, "发送招投标企业信用报告邮件。。。")
|
|
|
if util.SendRetryMail(g.Config().MustGet(ctx, "bidCreditReport.sendMailRetry").Int(), userMail, fmt.Sprintf(g.Config().MustGet(ctx, "bidCreditReport.mailSubject").String(), entName), content, "", nil, config.GmailAuth) {
|
|
|
log.Println("给", userId, orderCode, userMail, "发送招投标企业信用报告邮件成功。。。")
|
|
@@ -407,21 +411,6 @@ func (b *bidCreditReport) NewOrderWarn() {
|
|
|
ctx := gctx.New()
|
|
|
warnStart := g.Config().MustGet(ctx, "bidCreditReport.warnStart").String()
|
|
|
warnEnd := g.Config().MustGet(ctx, "bidCreditReport.warnEnd").String()
|
|
|
- var sendMail = func(m *gmap.StrAnyMap) {
|
|
|
- entName := m.GetVar("ent_name").String()
|
|
|
- orderCode := m.GetVar("order_code").String()
|
|
|
- content := fmt.Sprintf(g.Config().MustGet(ctx, "bidCreditReport.warnMailContent").String(), config.Config.WebDomain, m.GetVar("id").Int64(), orderCode, entName, m.GetVar("buyer").String())
|
|
|
- for _, v := range g.Config().MustGet(ctx, "bidCreditReport.warnUserMail").Strings() {
|
|
|
- go func(vv string) {
|
|
|
- log.Println(orderCode, vv, "开始给运维发送有新的投标企业信用报告订单邮件。。。")
|
|
|
- if util.SendRetryMail(g.Config().MustGet(ctx, "bidCreditReport.sendMailRetry").Int(), vv, g.Config().MustGet(ctx, "bidCreditReport.warnMailSubject").String(), content, "", nil, config.GmailAuth) {
|
|
|
- log.Println(orderCode, vv, "给运维发送有新的投标企业信用报告订单邮件成功。。。")
|
|
|
- } else {
|
|
|
- log.Println(orderCode, vv, "给运维发送有新的投标企业信用报告订单邮件邮件失败。。。")
|
|
|
- }
|
|
|
- }(v)
|
|
|
- }
|
|
|
- }
|
|
|
all := map[int64]*gmap.StrAnyMap{}
|
|
|
index := 0
|
|
|
p.VarTimeTask.RunInTimeSection("有新的投标企业信用报告订单给运维发邮件", warnStart, warnEnd, 1, func(dayFirst bool) {
|
|
@@ -429,13 +418,14 @@ func (b *bidCreditReport) NewOrderWarn() {
|
|
|
ids := map[int64]bool{}
|
|
|
util.Mysql.SelectByBath(1, func(l *[]map[string]interface{}) bool {
|
|
|
v := gmap.NewStrAnyMapFrom((*l)[0])
|
|
|
- log.Println("有新的投标企业信用报告订单给运维发邮件加载到数据", v.String())
|
|
|
id := v.GetVar("id").Int64()
|
|
|
- if _, ok := all[id]; !ok {
|
|
|
- v.Set("isNew", true)
|
|
|
- sendMail(v)
|
|
|
- }
|
|
|
ids[id] = true
|
|
|
+ if _, ok := all[id]; ok {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ log.Println("有新的投标企业信用报告订单给运维发邮件加载到数据", v.String())
|
|
|
+ v.Set("isNew", true)
|
|
|
+ b.sendWarnNotice(v.GetVar("id").Int64(), v.GetVar("order_code").String(), v.GetVar("ent_name").String(), v.GetVar("buyer").String())
|
|
|
all[id] = v
|
|
|
return true
|
|
|
}, `select id,order_code,ent_name,buyer from jianyu.bid_credit_report where status=0`)
|
|
@@ -452,7 +442,54 @@ func (b *bidCreditReport) NewOrderWarn() {
|
|
|
v.Set("isNew", false)
|
|
|
continue
|
|
|
}
|
|
|
- sendMail(v)
|
|
|
+ b.sendWarnNotice(v.GetVar("id").Int64(), v.GetVar("order_code").String(), v.GetVar("ent_name").String(), v.GetVar("buyer").String())
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+// 发送企业微信机器人告警
|
|
|
+func (b *bidCreditReport) sendWarnNotice(id int64, orderCode, entName, buyer string) {
|
|
|
+ ctx := gctx.New()
|
|
|
+ message := `订单编号:%s
|
|
|
+投标企业名称:%s
|
|
|
+招标单位名称:%s
|
|
|
+点击完善信息:%s/swordfish/page_big_pc/free/report/examine?id=%d`
|
|
|
+ type WeixinMessage struct {
|
|
|
+ MsgType string `json:"msgtype"`
|
|
|
+ Text struct {
|
|
|
+ Content string `json:"content"`
|
|
|
+ } `json:"text"`
|
|
|
+ }
|
|
|
+ var msg struct {
|
|
|
+ MsgType string `json:"msgtype"`
|
|
|
+ Text struct {
|
|
|
+ Content string `json:"content"`
|
|
|
+ } `json:"text"`
|
|
|
+ }
|
|
|
+ msg.MsgType = "text"
|
|
|
+ msg.Text.Content = fmt.Sprintf(message, orderCode, entName, buyer, config.Config.WebDomain, id)
|
|
|
+ data, _ := json.Marshal(msg)
|
|
|
+ resp, err := http.Post(g.Config().MustGet(gctx.New(), "bidCreditReport.webhook").String(), "application/json", bytes.NewReader(data))
|
|
|
+ if err != nil {
|
|
|
+ log.Println(orderCode, entName, "投标企业信用报告订单 sendWebhook error", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer resp.Body.Close()
|
|
|
+ if resp.StatusCode != http.StatusOK {
|
|
|
+ b, _ := ioutil.ReadAll(resp.Body)
|
|
|
+ log.Println(orderCode, entName, "投标企业信用报告订单 sendWebhook 失败", string(b))
|
|
|
+ }
|
|
|
+ log.Println(orderCode, entName, "投标企业信用报告订单 sendWebhook 成功")
|
|
|
+ //
|
|
|
+ content := fmt.Sprintf(g.Config().MustGet(ctx, "bidCreditReport.warnMailContent").String(), config.Config.WebDomain, id, orderCode, entName, buyer)
|
|
|
+ for _, v := range g.Config().MustGet(ctx, "bidCreditReport.warnUserMail").Strings() {
|
|
|
+ go func(vv string) {
|
|
|
+ log.Println(orderCode, vv, "开始给运维发送有新的投标企业信用报告订单邮件。。。")
|
|
|
+ if util.SendRetryMail(g.Config().MustGet(ctx, "bidCreditReport.sendMailRetry").Int(), vv, g.Config().MustGet(ctx, "bidCreditReport.warnMailSubject").String(), content, "", nil, config.GmailAuth) {
|
|
|
+ log.Println(orderCode, vv, "给运维发送有新的投标企业信用报告订单邮件成功。。。")
|
|
|
+ } else {
|
|
|
+ log.Println(orderCode, vv, "给运维发送有新的投标企业信用报告订单邮件邮件失败。。。")
|
|
|
+ }
|
|
|
+ }(v)
|
|
|
+ }
|
|
|
+}
|