- log msg refactor, add orderID to all logs.
This commit is contained in:
@@ -60,39 +60,45 @@ func GetWeixinOpenIDsFromStoreID(storeID int) (retVal []string) {
|
||||
WHERE jxstoreid = ? AND parentid = -1 AND openid IS NOT NULL
|
||||
`, storeID, storeID).ValuesList(&lists)
|
||||
if err != nil || num == 0 {
|
||||
globals.SugarLogger.Infof("can not find openid for store:%d, num:%d, error:%v", storeID, num, err)
|
||||
globals.SugarLogger.Infof("GetWeixinOpenIDsFromStoreID can not find openid for store:%d, num:%d, error:%v", storeID, num, err)
|
||||
return retVal
|
||||
}
|
||||
for _, v := range lists {
|
||||
retVal = append(retVal, v[0].(string))
|
||||
}
|
||||
// todo,调试,只发给我
|
||||
globals.SugarLogger.Debugf("GetWeixinOpenIDsFromStoreID store:%d, openids:%v", storeID, retVal)
|
||||
if storeID == 100146 {
|
||||
retVal = []string{"oYN_ust9hXKEvEv0X6Mq6nlAWs_E"}
|
||||
} else {
|
||||
retVal = []string{}
|
||||
if !globals.ReallyCallPlatformAPI {
|
||||
// todo,调试,只发给我
|
||||
globals.SugarLogger.Debugf("GetWeixinOpenIDsFromStoreID store:%d, openids:%v", storeID, retVal)
|
||||
if storeID == 100146 {
|
||||
retVal = []string{"oYN_ust9hXKEvEv0X6Mq6nlAWs_E"}
|
||||
} else {
|
||||
retVal = nil
|
||||
}
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func SendMsgToStore(storeID int, templateID, downloadURL string, data interface{}) (err error) {
|
||||
openIDs := GetWeixinOpenIDsFromStoreID(storeID)
|
||||
errCount := 0
|
||||
successCount := 0
|
||||
for _, openID := range openIDs {
|
||||
err2 := api.WeixinAPI.MessageTemplateSend(openID, templateID, downloadURL, nil, data)
|
||||
if err2 != nil {
|
||||
if err2 := api.WeixinAPI.MessageTemplateSend(openID, templateID, downloadURL, nil, data); err2 == nil {
|
||||
successCount++
|
||||
} else {
|
||||
err = err2
|
||||
errCount++
|
||||
}
|
||||
}
|
||||
if errCount < len(openIDs) {
|
||||
if successCount > 0 {
|
||||
err = nil // 只要成功一个都当成成功
|
||||
}
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("SendMsgToStore all failed storeID:%d, templateID:%s, error:%v", storeID, templateID, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func NotifyNewOrder(order *model.GoodsOrder) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyNewOrder orderID:%s", order.VendorOrderID)
|
||||
sb := new(strings.Builder)
|
||||
sb.WriteString("老板,")
|
||||
sb.WriteString(order.ConsigneeName)
|
||||
@@ -136,6 +142,7 @@ func NotifyNewOrder(order *model.GoodsOrder) (err error) {
|
||||
}
|
||||
|
||||
func NotifyWaybillStatus(bill *model.Waybill, order *model.GoodsOrder) error {
|
||||
globals.SugarLogger.Debugf("NotifyWaybillStatus bill:%v", bill)
|
||||
var title string
|
||||
var templateID string
|
||||
remark := ""
|
||||
@@ -149,14 +156,14 @@ func NotifyWaybillStatus(bill *model.Waybill, order *model.GoodsOrder) error {
|
||||
}
|
||||
titleColor = WX_HIGHLEVEL_TEMPLATE_COLOR
|
||||
remark = FormatDeliveryTime(order)
|
||||
title = fmt.Sprintf("%s %d#订单长时间无人配送,我们已安排%s配送员%s电话号码%s负责配送。^_^", model.VendorChineseNames[bill.OrderVendorID], order.OrderSeq, model.VendorChineseNames[bill.WaybillVendorID], bill.CourierName, bill.CourierMobile)
|
||||
title = fmt.Sprintf("%s 第%d号订单长时间无人配送,我们已安排%s配送员%s电话号码%s负责配送。^_^", model.VendorChineseNames[bill.OrderVendorID], order.OrderSeq, model.VendorChineseNames[bill.WaybillVendorID], bill.CourierName, bill.CourierMobile)
|
||||
case model.WaybillStatusDelivered:
|
||||
if bill.WaybillVendorID == model.VendorIDMTPS {
|
||||
templateID = WX_MTPS_DELIVERY_DONE_TEMPLATE_ID
|
||||
} else if bill.WaybillVendorID == model.VendorIDDada {
|
||||
templateID = WX_DADA_DELIVERY_DONE_TEMPLATE_ID
|
||||
}
|
||||
titleColor = venderColors[bill.WaybillVendorID]
|
||||
titleColor = venderColors[bill.OrderVendorID]
|
||||
title = fmt.Sprintf("%s 第%d号订单的配送完成", model.VendorChineseNames[bill.OrderVendorID], order.OrderSeq)
|
||||
}
|
||||
if templateID != "" {
|
||||
|
||||
Reference in New Issue
Block a user