|
@@ -31,10 +31,12 @@ func (p *PushKcJob) LoadAllOrder() {
|
|
|
Tidb_Main.SelectByBath(1, func(l *[]map[string]interface{}) bool {
|
|
|
if user_phone := util.ObjToString((*l)[0]["user_phone"]); user_phone == "" || strings.HasPrefix(user_phone, "9") {
|
|
|
return true
|
|
|
+ } else if vip_starttime := util.ObjToString((*l)[0]["vip_starttime"]); strings.HasPrefix(vip_starttime, "2099") {
|
|
|
+ return true
|
|
|
}
|
|
|
p.AllOrder[util.Int64All((*l)[0]["id"])] = true
|
|
|
return true
|
|
|
- }, `select id,user_phone from jianyu.dataexport_order where order_status=1 and autoUpdate<?`, TaskConfig.OrderEachTime)
|
|
|
+ }, `select id,user_phone,vip_starttime from jianyu.dataexport_order where order_status=1 and autoUpdate<?`, TaskConfig.OrderEachTime)
|
|
|
}
|
|
|
|
|
|
//
|
|
@@ -64,12 +66,15 @@ func (p *PushKcJob) Execute() {
|
|
|
id := util.Int64All((*l)[0]["id"])
|
|
|
user_phone := util.ObjToString((*l)[0]["user_phone"])
|
|
|
user_id := util.ObjToString((*l)[0]["user_id"])
|
|
|
+ vip_starttime := util.ObjToString((*l)[0]["vip_starttime"])
|
|
|
if user_id == "" {
|
|
|
return true
|
|
|
} else if p.AllOrder[id] {
|
|
|
return true
|
|
|
} else if user_phone == "" || strings.HasPrefix(user_phone, "9") {
|
|
|
return true
|
|
|
+ } else if strings.HasPrefix(vip_starttime, "2099") {
|
|
|
+ return true
|
|
|
}
|
|
|
order_code := util.ObjToString((*l)[0]["order_code"])
|
|
|
if exists, err := redis.Exists(RedisCode, fmt.Sprintf(RedisKcOrderTip, id)); exists {
|
|
@@ -104,16 +109,22 @@ func (p *PushKcJob) Execute() {
|
|
|
orderCodes = append(orderCodes, order_code)
|
|
|
orderInfos = append(orderInfos, &OrderInfo{
|
|
|
Id: id,
|
|
|
+ CompanyName: util.ObjToString((*l)[0]["company_name"]),
|
|
|
UserId: user_id,
|
|
|
ProductType: product_type,
|
|
|
OrderCode: order_code,
|
|
|
- OrderMoney: util.Float64All((*l)[0]["order_money"]) / 100,
|
|
|
+ PayMoney: util.Float64All((*l)[0]["pay_money"]) / 100,
|
|
|
+ ReturnMoney: util.Float64All((*l)[0]["return_money"]) / 100,
|
|
|
UserPhone: user_phone,
|
|
|
StartEnd: fmt.Sprintf("%s--%s", strings.Split(util.ObjToString((*l)[0]["vip_starttime"]), " ")[0], strings.Split(util.ObjToString((*l)[0]["vip_endtime"]), " ")[0]),
|
|
|
SeriveList: serviceList,
|
|
|
+ SaleName: util.ObjToString((*l)[0]["create_person"]),
|
|
|
})
|
|
|
return true
|
|
|
- }, `select id,order_code,order_money,user_phone,vip_starttime,vip_endtime,product_type,filter,user_id,ent_id from jianyu.dataexport_order where autoUpdate>=? and autoUpdate<? and order_status=1 and (product_type='大会员' or product_type='大会员-子账号') order by autoUpdate`, TaskConfig.OrderEachTime, nowFormat)
|
|
|
+ }, `SELECT a.id,a.order_code,a.pay_money,a.user_phone,a.vip_starttime,a.vip_endtime,a.product_type,a.filter,a.user_id,a.ent_id,a.company_name,a.create_person,SUM(b.return_money) AS return_money FROM jianyu.dataexport_order a
|
|
|
+ LEFT JOIN return_money_record b ON (a.order_code=b.order_code)
|
|
|
+ WHERE a.autoUpdate>=? AND a.autoUpdate<? AND a.order_status=1 AND (a.product_type='大会员' OR a.product_type='大会员-子账号')
|
|
|
+ GROUP BY a.id ORDER BY a.autoUpdate`, TaskConfig.OrderEachTime, nowFormat)
|
|
|
//}, `select id,order_code,order_money,user_phone,vip_starttime,vip_endtime,product_type,filter,user_id,ent_id from jianyu.dataexport_order where id=256858`)
|
|
|
logger.Info(p.TaskName, count, "个订单需要发送提醒", orderCodes)
|
|
|
if len(orderCodes) > 0 {
|
|
@@ -127,17 +138,20 @@ func (p *PushKcJob) Execute() {
|
|
|
clueInfo[util.ObjToString((*l)[0]["phone"])] = &ClueInfo{
|
|
|
KcName: util.ObjToString((*l)[0]["name"]),
|
|
|
UserName: util.ObjToString((*l)[0]["bname"]),
|
|
|
+ //SaleName: util.ObjToString((*l)[0]["sname"]),
|
|
|
}
|
|
|
return true
|
|
|
- }, `select a.phone,c.ent_id,c.name,b.name as bname from dwd_f_userbase_contacts a
|
|
|
+ }, `select a.phone,c.ent_id,c.name,b.name as bname,d.name AS sname from dwd_f_userbase_contacts a
|
|
|
inner join dwd_f_crm_clue_info b on (a.phone in (`+whs+`) and a.baseinfo_id=b.uid)
|
|
|
- left join dwd_f_csm_customer_info c on (b.id=c.clue_id AND c.is_transfer=0) LIMIT 1`, args...)
|
|
|
+ left join dwd_f_csm_customer_info c on (b.id=c.clue_id AND c.is_transfer=0)
|
|
|
+ left join dwd_f_crm_personnel_management d on (b.position_id=d.position_id)`, args...)
|
|
|
for k, v := range orderInfos {
|
|
|
if ci := clueInfo[v.UserPhone]; ci == nil || ci.KcName == "" {
|
|
|
continue
|
|
|
}
|
|
|
v.DisKcName = clueInfo[v.UserPhone].KcName
|
|
|
v.UserName = clueInfo[v.UserPhone].UserName
|
|
|
+ //v.SaleName = clueInfo[v.UserPhone].SaleName
|
|
|
if k == len(orderInfos)-1 {
|
|
|
break L
|
|
|
}
|
|
@@ -151,13 +165,17 @@ func (p *PushKcJob) Execute() {
|
|
|
}
|
|
|
}
|
|
|
for _, v := range orderInfos {
|
|
|
- tableServiceList, messageServiceList := "", ""
|
|
|
+ tableAppend, messageAppend := "", ""
|
|
|
if len(v.SeriveList) > 0 {
|
|
|
- tableServiceList = fmt.Sprintf(Config.KeCheng.Mail.ServiceList, strings.Join(v.SeriveList, ","))
|
|
|
- messageServiceList = fmt.Sprintf(Config.KeCheng.MessageServiceList, strings.Join(v.SeriveList, ","))
|
|
|
+ tableAppend = fmt.Sprintf(Config.KeCheng.Mail.ServiceList, strings.Join(v.SeriveList, ","))
|
|
|
+ messageAppend = fmt.Sprintf(Config.KeCheng.MessageServiceList, strings.Join(v.SeriveList, ","))
|
|
|
+ }
|
|
|
+ if v.ReturnMoney > 0 {
|
|
|
+ tableAppend += fmt.Sprintf(Config.KeCheng.Mail.ReturnMoney, v.ReturnMoney)
|
|
|
+ messageAppend += fmt.Sprintf(Config.KeCheng.MessageReturnMoney, v.ReturnMoney)
|
|
|
}
|
|
|
- table += fmt.Sprintf(Config.KeCheng.Mail.Table, v.ProductType, v.UserPhone, v.UserName, v.OrderCode, v.OrderMoney, v.StartEnd, v.DisKcName, tableServiceList)
|
|
|
- messageConents = append(messageConents, fmt.Sprintf(Config.KeCheng.Message, v.ProductType, v.UserPhone, v.UserName, v.OrderCode, v.OrderMoney, v.StartEnd, v.DisKcName, messageServiceList))
|
|
|
+ table += fmt.Sprintf(Config.KeCheng.Mail.Table, v.ProductType, v.CompanyName, v.UserPhone, v.UserName, v.OrderCode, v.PayMoney, v.StartEnd, v.DisKcName, v.SaleName, tableAppend)
|
|
|
+ messageConents = append(messageConents, fmt.Sprintf(Config.KeCheng.Message, v.ProductType, v.CompanyName, v.UserPhone, v.UserName, v.OrderCode, v.PayMoney, v.StartEnd, v.DisKcName, v.SaleName, messageAppend))
|
|
|
redis.PutCKV(RedisCode, fmt.Sprintf(RedisKcOrderTip, v.Id), 1)
|
|
|
}
|
|
|
if table != "" {
|
|
@@ -185,7 +203,7 @@ func (p *PushKcJob) Execute() {
|
|
|
logger.Info(p.TaskName, "邮箱推送结束", isPushOk, v)
|
|
|
}
|
|
|
}
|
|
|
- phones = append(phones, Config.TestMails...)
|
|
|
+ phones = append(phones, Config.TestPhones...)
|
|
|
if len(phones) > 0 { //发送站内信
|
|
|
logger.Info(p.TaskName, "开始站内信推送", phones)
|
|
|
users, ok := Mgo.Find("user", map[string]interface{}{
|