Ver código fonte

Merge branch 'dev/v4.8.93_fuwencai' of qmx/jy into feature/v4.8.93

fuwencai 1 ano atrás
pai
commit
fa55137f05

+ 29 - 1
src/jfw/modules/subscribepay/src/config.json

@@ -159,5 +159,33 @@
     "key": "powercheck.rpc"
   },
   "taskStartTime": 1698020000,
-  "financeMail": "wanghao@topnet.net.cn"
+  "financeMail": "wanghao@topnet.net.cn",
+  "equityActive": {
+    "open": true,
+    "siteMsg": {
+      "callPlatform": "subscribepay",
+      "msgType": 2,
+      "title": "%s已到账,戳我解锁!",
+      "content": "购买%s产品赠送%s已到账。兑换码%s。兑换截止日期:%s,请前往腾讯视频进行兑换解锁福利。",
+      "link": "",
+      "androidUrl": "",
+      "iosUrl": "",
+      "weChatUrl": ""
+    },
+    "mailAlarm": {
+      "to": [
+        "328974233@qq.com"
+      ],
+      "title": "视频会员权益码数据告警",
+      "reTry": 3,
+      "threshold": 30
+    },
+    "sms": {
+      "args": [
+        "%s。兑换码%s。兑换截止日期:%s",
+        "腾讯视频"
+      ],
+      "tid":"04"
+    }
+  }
 }

+ 23 - 0
src/jfw/modules/subscribepay/src/config/config.go

@@ -118,6 +118,29 @@ type config struct {
 	BreakRenewTipTime string
 	TaskStartTime     int64
 	FinanceMail       string
+	EquityActive      struct {
+		Open    bool `json:"open"` // 活动开关
+		SiteMsg struct {
+			CallPlatform string `json:"callPlatform"`
+			MsgType      int    `json:"msgType"`
+			Title        string `json:"title"`
+			Content      string `json:"content"`
+			Link         string `json:"link"`
+			AndroidUrl   string `json:"androidUrl"`
+			IosUrl       string `json:"iosUrl"`
+			WeChatUrl    string `json:"weChatUrl"`
+		} `json:"siteMsg"` // 站内信内容配置
+		MailAlarm struct {
+			To        []string `json:"to"`
+			Title     string   `json:"title"`
+			ReTry     int      `json:"reTry"`
+			Threshold int      `json:"threshold"` // 库存剩余阈值
+		} `json:"mailAlarm"` // 库存告警
+		Sms struct {
+			Args []string `json:"args"` // 短信部分可配置参数
+			Tid  string   `json:"tid"`  // 短信模板id
+		} `json:"sms"` // 短信配置
+	} `json:"equityActive"` // p459赠送视频权益活动配置
 }
 type mgoConf struct {
 	Address           string

+ 242 - 0
src/jfw/modules/subscribepay/src/entity/equityActive.go

@@ -0,0 +1,242 @@
+package entity
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jybase/redis"
+	"app.yhyue.com/moapp/jybase/sms"
+	"fmt"
+	"gopkg.in/mgo.v2/bson"
+	"jy/src/jfw/modules/subscribepay/src/config"
+	"jy/src/jfw/modules/subscribepay/src/util"
+	"log"
+	"regexp"
+	"strings"
+	"sync"
+)
+
+const (
+	TableEquityInfo       = "jyactivities.equity_info"   // 营销权益信息表
+	TableEquityActive     = "jyactivities.equity_active" // 营销权益活动表
+	TableOrder            = "jianyu.dataexport_order"    // 订单表
+	TablebasePosition     = "base_service.base_position" // 用户职位表
+	valueStateGifted      = 1                            // 已赠送状态值
+	valueMoldMonth        = 0                            // 月度
+	valueMoldYear         = 1                            // 年度
+	valueOrderTypeCreate  = 1                            // 超级订阅订单类型: 购买
+	valueOrderTypeRenew   = 2                            // 续费
+	valueOrderTypeUpgrade = 3                            // 升级
+	valueCycleUnitYear    = 1                            // 周期单位为年
+	valueAreaCountAll     = -1                           //  全国
+
+)
+
+var equityStockLock = sync.Mutex{} // 赠送视频权益码库存锁
+// EquityActive 赠送视频会员活动
+type EquityActive struct {
+	UserId           string // id 这边取到的id可能是职位id也可能是mongo库id
+	mgoId            string // mongo库id
+	positionId       string // 职位id
+	Phone            string // 手机号 用于发短信
+	OrderCode        string // 订单号
+	OrderType        int    // 1购买 2升级 3续费
+	CycleUnit        int    // 单位  1-年
+	CycleCount       int    // 数量
+	AreaCount        int    // -1 是全国
+	ProductType      string // 消息中的产品类型
+	OrderProductType string // 订单中的产品类型
+}
+
+// GiftVip 赠送腾讯视频会员
+func (e *EquityActive) GiftVip() {
+	//1. 判断活动是否开启
+	open, activeId, activeName := e.activityStart()
+	if !open || activeId <= 0 {
+		return
+	}
+	// 获取 缓存中的用户信息
+	e.setUserID()
+	if e.mgoId == "" {
+		log.Println("equityActive 未获取到有效的mgoId", e.OrderCode)
+		return
+	}
+	//2. 判断是否符合赠送条件
+	ok, mold := e.matchOrder()
+	if !ok {
+		return
+	}
+	equityStockLock.Lock()
+	defer func() {
+		equityStockLock.Unlock()
+	}()
+	//3. 判断库存
+	eInfo := e.findVipStock(activeId, mold)
+	if eInfo == nil || len(*eInfo) == 0 {
+		// 没有库存
+		go e.sendAlarmMail(activeName, activeId, mold, 0)
+		return
+	}
+	if len(*eInfo) <= config.Config.EquityActive.MailAlarm.Threshold {
+		// 发库存告警时这减去1是因为这一次马上会消耗一个
+		go e.sendAlarmMail(activeName, activeId, mold, len(*eInfo)-1)
+	}
+	eId := common.IntAll((*eInfo)[0]["id"])
+	//4. 更新库存
+	if !e.updateVipStock(eId) {
+		log.Println("equityActive  更新库存信息失败:", eId, e.OrderCode)
+		return
+	}
+	//6. 发送短信、站内信
+	eName := common.ObjToString((*eInfo)[0]["name"])
+	code := common.ObjToString((*eInfo)[0]["code"])
+	exEndTime := common.ObjToString((*eInfo)[0]["ex_end_time"])
+	go e.sendVipMsg(eName, code, exEndTime)
+}
+
+// txActivityStart 判断活动是否开启 开启则返回活动id
+func (e *EquityActive) activityStart() (open bool, id int, name string) {
+	now := date.NowFormat(date.Date_Full_Layout)
+	query := fmt.Sprintf("SELECT id,name FROM %s where state=0 and start_time<=? and end_time>=?;", TableEquityActive)
+	rs := util.Mysql.SelectBySql(query, now, now)
+	if rs != nil && len(*rs) > 0 {
+		open = true
+		id = common.IntAll((*rs)[0]["id"])
+		name = common.ObjToString((*rs)[0]["name"])
+		return
+	}
+	return
+}
+
+// 判断订单是否符合条件
+func (e *EquityActive) matchOrder() (ok bool, mold int) {
+	//(购买||续费)
+	if (e.OrderType == valueOrderTypeCreate || e.OrderType == valueOrderTypeRenew) && e.CycleCount > 0 {
+		// 判断购买是否为年度订单
+		if e.CycleUnit != valueCycleUnitYear {
+			return
+		}
+		// 为年度订单则判断是否为全国
+		if e.AreaCount == valueAreaCountAll {
+			ok = true
+			mold = valueMoldYear //全国赠送1年
+		} else {
+			ok = true
+			mold = valueMoldMonth //非全国赠送1月
+		}
+		//其他不赠送	// 升级
+		// 判断是否是年度会员  不是年度会员则不赠送 是则赠送1月
+		return
+	} else if e.OrderType == valueOrderTypeUpgrade {
+		// 升级
+		// 判断是否是年度会员  不是年度会员则不赠送 是则赠送1月
+		if e.isYearVip() {
+			ok = true
+			mold = valueMoldMonth
+		}
+	}
+	return
+}
+
+// 查看兑换权益码信息
+func (e *EquityActive) findVipStock(activeId, mold int) (data *[]map[string]interface{}) {
+	query := fmt.Sprintf("SELECT id,name,code,date_format(ex_end_time,'%%Y-%%m-%%d') as ex_end_time  FROM %s where state= 0 and mold=? and active_id=? ;", TableEquityInfo)
+	data = util.Mysql.SelectBySql(query, mold, activeId)
+	return
+}
+
+// 根据订单号获取缓存里面的用户id等信息
+func (e *EquityActive) setUserID() (mgoId string, positionId string) {
+	orderKey := fmt.Sprintf("order_%s", e.OrderCode)
+	rs := redis.Get("other", orderKey)
+	info := common.ObjToMap(rs)
+	if info == nil || len(*info) == 0 {
+		log.Println("equityActive 未获取到redis保存的用户身份信息:", orderKey, info)
+		return
+	}
+	mgoId = common.ObjToString((*info)["mgoId"])
+	positionId = fmt.Sprintf("%v", common.IntAll((*info)["positionId"]))
+	phone := common.ObjToString((*info)["phone"])
+	if phone != "" {
+		e.Phone = phone
+	}
+	e.mgoId = mgoId
+	e.positionId = positionId
+	if mgoId == "" && bson.IsObjectIdHex(e.UserId) {
+		// 如果没有redis取到说明是代用户下单的订单
+		// 代用户下单的现在只有个人版的 所以可以直接从订单里面取用户mgoId
+		if bson.IsObjectIdHex(e.UserId) {
+			mgoId = e.UserId
+		}
+	}
+	return
+}
+
+// 更新库存
+func (e *EquityActive) updateVipStock(eInfoId int) bool {
+	update := fmt.Sprintf("update %s set order_code=?,state=?,update_time=? where id=? ", TableEquityInfo)
+	return util.Mysql.UpdateOrDeleteBySql(update, e.OrderCode, valueStateGifted, date.NowFormat(date.Date_Full_Layout), eInfoId) > 0
+}
+
+// 发送消息
+func (e *EquityActive) sendVipMsg(eName, code, ex_end_time string) {
+	// 发送短信
+	//  04 短信模板:用户{1}您好,购买{2}产品赠送您{3},请前往{4}进行兑换解锁福利。
+	// 手机号处理
+	if e.Phone != "" {
+		phone := e.Phone
+		var PhoneReg = regexp.MustCompile(`^(100\d{8}|1[3-9]\d{9})$`)
+		if PhoneReg.MatchString(e.Phone) {
+			phone = string(phone[0:3]) + "****" + string(phone[(len(phone)-4):])
+		}
+		smsconfig := config.Config.EquityActive.Sms
+		args3, args4 := "", ""
+		if len(smsconfig.Args) == 2 {
+			args3 = fmt.Sprintf(smsconfig.Args[0], eName, code, ex_end_time)
+		} else {
+			log.Println("equityActive 视频会员活动短信模板内容参数配置异常,请检查配置文件。")
+			return
+		}
+		params := []string{phone, e.ProductType, args3, args4}
+		sms.SendSms(config.Config.SmsServiceRpc, smsconfig.Tid, e.Phone, params...)
+	} else {
+		log.Println("equityActive 未获取到用户手机号,不再发送短信:", e.OrderCode, e.UserId, e.Phone)
+	}
+	siteMsg := config.Config.EquityActive.SiteMsg
+	// 发送站内信
+	p := util.MessageParam{
+		UserIds:     e.mgoId,
+		PositionIds: e.positionId,
+		Title:       fmt.Sprintf(siteMsg.Title, eName),
+		Content:     fmt.Sprintf(siteMsg.Content, e.ProductType, eName, code, ex_end_time),
+		MsgType:     siteMsg.MsgType,
+		SendMode:    2,
+	}
+	util.EquityActiveSend.SendStationMessages(p)
+
+}
+
+// 库存告警
+func (e *EquityActive) sendAlarmMail(activeName string, activeId, mold, count int) {
+	ma := config.Config.EquityActive.MailAlarm
+	if len(ma.To) == 0 {
+		log.Println("未配置视频会员权益码活动库存告警邮箱")
+		return
+	}
+	to := strings.Join(ma.To, ",")
+	m := ""
+	if mold == valueMoldYear {
+		m = "年度"
+	} else {
+		m = "月度"
+	}
+	content := fmt.Sprintf("活动:%s(活动id:%d),%s权益当前库存:%d", activeName, activeId, m, count)
+	util.SendRetryMailMany(ma.ReTry, to, ma.Title, content, "", "", config.GmailAuth)
+}
+
+// 判断是否年度会员
+func (e *EquityActive) isYearVip() bool {
+	query := fmt.Sprintf("select count(*) from %s where user_id=? and order_status=1 and product_type =? and (timestampdiff(day,vip_starttime,vip_endtime)>=365) order by create_time desc limit 1", TableOrder)
+	count := util.Mysql.CountBySql(query, e.UserId, e.OrderProductType)
+	log.Println("isYearVip 判断是否为年度订单:", query, e.UserId, count)
+	return count > 0
+}

+ 63 - 47
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -130,6 +130,7 @@ func (this *vipSubscribeStruct) PayCallBack(param *CallBackParam) bool {
 		return false //
 	}
 	userId := qutil.ObjToString((*orderdata)["user_id"])
+	phone := qutil.ObjToString((*orderdata)["user_phone"])
 	//优惠码
 	orderCode := qutil.ObjToString((*orderdata)["order_code"])
 	dis_word := qutil.ObjToString((*orderdata)["dis_word"])
@@ -269,6 +270,20 @@ func (this *vipSubscribeStruct) PayCallBack(param *CallBackParam) bool {
 				}
 			}(userId, userLotteryId, orderCode)
 		}
+		//  p459赠送
+		if config.Config.EquityActive.Open {
+			equityActive := EquityActive{UserId: userId,
+				Phone:            phone,
+				OrderCode:        orderCode,
+				OrderType:        vmsg.OrderType,
+				CycleUnit:        vmsg.Cycleunit,
+				ProductType:      "超级订阅",
+				OrderProductType: "VIP订阅",
+				CycleCount:       vmsg.Cyclecount,
+				AreaCount:        vmsg.NewBuyset.AreaCount,
+			}
+			equityActive.GiftVip()
+		}
 	}
 	return flag
 }
@@ -474,59 +489,60 @@ func (this *vipSubscribeStruct) UpgradeSubVip(userId string, vmsg VipSimpleMsg,
 }
 
 // 超级订阅获取购买项
-//func (this *vipSubscribeStruct) NewBuySet(area *map[string]interface{}, industry []string, isUpgrade bool) *SubvipBuySet {
-//	pCount := -1
-//	citys := []int{}
-//	if area != nil {
-//		if (*area)["全国"] != nil {
-//			area = &map[string]interface{}{}
-//		} else if pCount_tmp := qutil.IntAll((*area)["areacount"]); pCount_tmp > 0 {
-//			pCount = pCount_tmp
+//
+//	func (this *vipSubscribeStruct) NewBuySet(area *map[string]interface{}, industry []string, isUpgrade bool) *SubvipBuySet {
+//		pCount := -1
+//		citys := []int{}
+//		if area != nil {
+//			if (*area)["全国"] != nil {
+//				area = &map[string]interface{}{}
+//			} else if pCount_tmp := qutil.IntAll((*area)["areacount"]); pCount_tmp > 0 {
+//				pCount = pCount_tmp
+//			}
 //		}
-//	}
-//	buyset := SubvipBuySet{}
-//	if !isUpgrade {
-//		buyset.Upgrade = 0 //升级版超级订阅标识
-//		if len(*area) > 0 {
-//			pCount = 0
-//			for _, v := range *area {
-//				tmp := v.([]interface{})
-//				if len(tmp) == 0 || len(tmp) > SubVipPrice.Old.CityMaxCount { //省份
-//					pCount++
-//				} else { //城市
-//					citys = append(citys, len(tmp))
+//		buyset := SubvipBuySet{}
+//		if !isUpgrade {
+//			buyset.Upgrade = 0 //升级版超级订阅标识
+//			if len(*area) > 0 {
+//				pCount = 0
+//				for _, v := range *area {
+//					tmp := v.([]interface{})
+//					if len(tmp) == 0 || len(tmp) > SubVipPrice.Old.CityMaxCount { //省份
+//						pCount++
+//					} else { //城市
+//						citys = append(citys, len(tmp))
+//					}
+//				}
+//				//省份数量自动转换全国
+//				if pCount > SubVipPrice.Old.ProvinceMaxCount {
+//					pCount = -1
+//					citys = []int{}
 //				}
 //			}
-//			//省份数量自动转换全国
-//			if pCount > SubVipPrice.Old.ProvinceMaxCount {
-//				pCount = -1
-//				citys = []int{}
-//			}
-//		}
-//		buyset.NewCitys = citys
-//		buyset.AreaCount = pCount //地区
-//		//行业数量自动转换全行业
-//		buyset.BuyerclassCount = len(industry)
-//		if len(industry) > SubVipPrice.Old.BuyerClassMaxCount || len(industry) == 0 {
-//			buyset.BuyerclassCount = -1
-//		}
-//	} else {
-//		buyset.Upgrade = 1 //升级版超级订阅标识
-//		if len(*area) > 0 {
-//			pCount = len(*area)
-//			//省份数量自动转换全国
-//			if pCount > SubVipPrice.New.ProvinceMaxCount {
-//				pCount = -1
+//			buyset.NewCitys = citys
+//			buyset.AreaCount = pCount //地区
+//			//行业数量自动转换全行业
+//			buyset.BuyerclassCount = len(industry)
+//			if len(industry) > SubVipPrice.Old.BuyerClassMaxCount || len(industry) == 0 {
+//				buyset.BuyerclassCount = -1
 //			}
 //		} else {
-//			buyset.AreaCount = -1 //全国
+//			buyset.Upgrade = 1 //升级版超级订阅标识
+//			if len(*area) > 0 {
+//				pCount = len(*area)
+//				//省份数量自动转换全国
+//				if pCount > SubVipPrice.New.ProvinceMaxCount {
+//					pCount = -1
+//				}
+//			} else {
+//				buyset.AreaCount = -1 //全国
+//			}
+//			buyset.AreaCount = pCount   //地区
+//			buyset.NewCitys = citys     //城市,4.4改版不支持购买城市
+//			buyset.BuyerclassCount = -1 //行业,4.4改版只能购买全行业
 //		}
-//		buyset.AreaCount = pCount   //地区
-//		buyset.NewCitys = citys     //城市,4.4改版不支持购买城市
-//		buyset.BuyerclassCount = -1 //行业,4.4改版只能购买全行业
+//		return &buyset
 //	}
-//	return &buyset
-//}
 func (this *vipSubscribeStruct) NewBuySet(area *map[string]interface{}, areaCount int, industry []string, isUpgrade bool) *SubvipBuySet {
 	pCount := -1
 	citys := []int{}
@@ -1104,7 +1120,7 @@ func (this *vipSubscribeStruct) GetNewUpgradeDetail(userId string, newBuySet, ol
 	return totalPrice, subtotals
 }
 
-//获取新版超级订阅升级价格、清单
+// 获取新版超级订阅升级价格、清单
 func getNewUpgradeDetail(userId string, newBuySet, oldBuySet *SubvipBuySet, oldEndtime int64, count, unit int) (totalPrice int, subtotals []map[string]interface{}) {
 	rResult, ok := util.MQFW.Find("vip_upgrade", &bson.M{"s_userid": userId, "i_isvalid": 0}, `{"l_validtime":1}`, `{"o_buyset":1,"l_validtime":1}`, false, -1, -1)
 	if !ok {

+ 16 - 3
src/jfw/modules/subscribepay/src/service/commonAction.go

@@ -26,7 +26,7 @@ import (
 	"github.com/SKatiyar/qr"
 )
 
-//付费公用方法
+// 付费公用方法
 type CommonAction struct {
 	*xweb.Action
 	getwxSdkSign         xweb.Mapper `xweb:"/wx/getwxSdkSign"`             //微信js参数
@@ -105,7 +105,7 @@ func (this *CommonAction) SendMailNote(mailType string) {
 	this.ServeJson(NewResult(rData, errMsg))
 }
 
-//----------------------------申请发票------------------------------------
+// ----------------------------申请发票------------------------------------
 func (d *CommonAction) ApplyInvoice() error {
 	var applyBill_status int
 	var order_code, applyBill_company, applyBill_taxnum, applyBill_type string
@@ -174,7 +174,8 @@ func (d *CommonAction) ApplyInvoice() error {
 	return nil
 }
 
-/**
+/*
+*
 
 根据 id+openid 删除
 */
@@ -493,6 +494,9 @@ func (this *CommonAction) SaveTransferAccounts() {
 func (this *CommonAction) Createorder() {
 	sessVal := this.Session().GetMultiple()
 	userid, _ := sessVal["userId"].(string)
+	phone := qutil.ObjToString(sessVal["phone"])
+	positionId := qutil.IntAll(sessVal["positionId"])
+	mgoId := qutil.ObjToString(sessVal["mgoUserId"])
 	rData, errMsg := func() (interface{}, error) {
 		//参数接收
 		infoMap := map[string]interface{}{}
@@ -616,6 +620,15 @@ func (this *CommonAction) Createorder() {
 		if orderid <= 0 {
 			return nil, fmt.Errorf("创建订单异常")
 		}
+		if product == "VIP订阅" {
+			orderKey := fmt.Sprintf("order_%s", inserMap.OrderCode)
+			uInfo := map[string]interface{}{
+				"mgoId":      mgoId,
+				"positionId": positionId,
+				"phone":      phone,
+			}
+			redis.Put("other", orderKey, uInfo, 60*24*3)
+		}
 		if activityType >= 2 {
 			util.FindUserLotteryId(userid, orderid, i_discountId)
 		}

+ 78 - 0
src/jfw/modules/subscribepay/src/util/send.go

@@ -0,0 +1,78 @@
+package util
+
+import (
+	"app.yhyue.com/moapp/jybase/date"
+	"encoding/json"
+	"fmt"
+	"io/ioutil"
+	"jy/src/jfw/modules/subscribepay/src/config"
+	"log"
+	"net/http"
+	"net/url"
+)
+
+type StationMessage struct {
+	Action       string
+	Addr         string
+	CallPlatform string
+}
+type MessageParam struct {
+	UserIds     string // 用户mongo库id   用户userId用英文逗号拼接
+	SendTime    string // 发送时间 暂时无用 (2022-03-31 09:08:08  仅发送模式为定时时有效)
+	Title       string // 通知消息	消息标题
+	Content     string // 消息内容
+	Link        string // pc消息链接
+	AndroidUrl  string // 安卓消息链接
+	IosUrl      string // IOS消息链接
+	WeChatUrl   string // 微信消息链接
+	SendMode    int    // 发送模式  1- 定时 2-实时 (所调接口未支持定时)
+	PositionIds string // 职位id 与userIds 对应
+	MsgType     int    // message_class 里的消息分类
+}
+
+var EquityActiveSend *StationMessage
+
+func init() {
+	wp := config.Config.WebSiteParameter
+	callPlatform := config.Config.EquityActive.SiteMsg.CallPlatform
+	EquityActiveSend = NewStationMessage(wp.Addr, wp.Action, callPlatform)
+
+}
+func NewStationMessage(addr string, action string, callPlatform string) *StationMessage {
+	return &StationMessage{
+		Addr:         addr,
+		Action:       action,
+		CallPlatform: callPlatform,
+	}
+}
+
+func (s *StationMessage) SendStationMessages(p MessageParam) {
+	var (
+		ret  MessageRet
+		cont []byte
+	)
+	parms := fmt.Sprintf("_action=%s&userIds=%s&msgType=%v&title=%s&content=%s&link=%s&sendMode=2&sendTime=%s&androidUrl=%s&iosUrl=%s&weChatUrl=%s&_token=12311&reqSource=1&callPlatform=%s&positionIds=%s&menuname=message",
+		s.Action, p.UserIds, p.MsgType, p.Title, p.Content, p.Link, date.NowFormat(date.Date_Short_Layout), p.AndroidUrl, p.IosUrl, p.WeChatUrl, s.CallPlatform, p.PositionIds)
+	paramsEncode := url.PathEscape(parms)
+	url2 := fmt.Sprintf("%s?%s", s.Addr, paramsEncode)
+	resp, err := http.Get(url2)
+	if err != nil {
+		log.Println("发送消息失败:", err)
+		return
+	}
+	defer resp.Body.Close()
+	cont, err = ioutil.ReadAll(resp.Body)
+	if err != nil {
+		log.Println("发送消息错误信息:", string(cont), err)
+		return
+	}
+	err = json.Unmarshal(cont, &ret)
+	if err != nil {
+		log.Println("发送消息反序列化错误信息:", err)
+		return
+	}
+	if ret.Data.Status != 1 {
+		log.Println("发送消息失败:Status != 1", ret)
+	}
+
+}

+ 23 - 5
src/jfw/modules/subscribepay/src/util/sendMail.go

@@ -3,10 +3,10 @@ package util
 //发送邮件
 
 import (
-	"jy/src/jfw/modules/subscribepay/src/config"
+	"app.yhyue.com/moapp/jybase/mail"
 	"fmt"
+	"jy/src/jfw/modules/subscribepay/src/config"
 	"log"
-	"app.yhyue.com/moapp/jybase/mail"
 	"regexp"
 	"time"
 )
@@ -28,7 +28,7 @@ func SendRetryMail(retry int, userMail, subject, content, fName string, bt []byt
 	return false
 }
 
-//发送异常提醒
+// 发送异常提醒
 func SendErrNoteToMail(errContent string) bool {
 	sendSuccess := true
 	for _, audit := range config.ExConf.ErrNote_emails {
@@ -42,7 +42,7 @@ func SendErrNoteToMail(errContent string) bool {
 	return sendSuccess
 }
 
-//发送邮箱验证码
+// 发送邮箱验证码
 func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
 	html := fmt.Sprintf(`<div>
             <div>
@@ -59,7 +59,7 @@ func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
             <div>
                   <p>此致</p>
                   <p>剑鱼标讯</p>
-            </div>      
+            </div>
       </div>`, to, code)
 
 	for k, v := range auth {
@@ -77,3 +77,21 @@ func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
 
 	return false
 }
+
+// SendRetryMailMany 发送邮件  收件人多个使用英文逗号分割
+func SendRetryMailMany(retry int, user_mail, subject, content, fname string, rename string, auth []*mail.GmailAuth) bool {
+	for i := 1; i <= retry; i++ {
+		for _, v := range auth { //使用多个邮箱尝试发送
+			if mail.GSendMail_q("剑鱼标讯", user_mail, "", "", subject, content, fname, rename, v) {
+				return true
+			}
+			t := time.Duration(i) * 30 * time.Second
+			log.Println(user_mail, fmt.Sprintf("第%d轮,使用%s发送邮件失败!%v后重试", i, v.User, t))
+			time.Sleep(t)
+		}
+		if i == retry {
+			log.Println(user_mail, fmt.Sprintf("发送邮件失败"))
+		}
+	}
+	return false
+}