- test test miniprogram
- support WSC vendor order id
This commit is contained in:
@@ -78,6 +78,8 @@ func SplitUniversalOrderID(universalOrderID string) (orderID string, vendorID in
|
|||||||
vendorID = model.VendorIDEBAI
|
vendorID = model.VendorIDEBAI
|
||||||
} else if orderIDLen == len("33437032333978492") {
|
} else if orderIDLen == len("33437032333978492") {
|
||||||
vendorID = model.VendorIDMTWM
|
vendorID = model.VendorIDMTWM
|
||||||
|
} else if orderIDLen == len("5287873015048") {
|
||||||
|
vendorID = model.VendorIDWSC
|
||||||
} else {
|
} else {
|
||||||
// globals.SugarLogger.Errorf("unkown order type:%v", universalOrderID)
|
// globals.SugarLogger.Errorf("unkown order type:%v", universalOrderID)
|
||||||
panic(fmt.Sprintf("unkown order type:%v, orderIDLen:%d", universalOrderID, orderIDLen))
|
panic(fmt.Sprintf("unkown order type:%v, orderIDLen:%d", universalOrderID, orderIDLen))
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ const (
|
|||||||
WX_TO_SHOW_COMMENTS_DETAIL_URL = "http://wx.jxc4.com/#/assess-list?jxStoreId=" //展示差评详情的页面
|
WX_TO_SHOW_COMMENTS_DETAIL_URL = "http://wx.jxc4.com/#/assess-list?jxStoreId=" //展示差评详情的页面
|
||||||
WX_TO_SHOW_MSG = "http://wx.jxc4.com/#/message-detail?msgID=%d&msgStatusID=%d"
|
WX_TO_SHOW_MSG = "http://wx.jxc4.com/#/message-detail?msgID=%d&msgStatusID=%d"
|
||||||
|
|
||||||
|
WX_MINI_TO_ORDER_PAGE_URL = "pages/order-manager/main"
|
||||||
|
WX_MINI_TO_STORE_SKU_PAGE_URL = "pages/goods-manager/main"
|
||||||
|
WX_MINI_TO_SHOW_COMMENTS_DETAIL_URL = "pages/store-comment/main"
|
||||||
|
WX_MINI_TO_SHOW_MSG = ""
|
||||||
|
|
||||||
//新订单模板消息文字颜色
|
//新订单模板消息文字颜色
|
||||||
WX_NEW_ORDER_TEMPLATE_COLOR = "#173177"
|
WX_NEW_ORDER_TEMPLATE_COLOR = "#173177"
|
||||||
WX_HIGHLEVEL_TEMPLATE_COLOR = "#FF0000" //红色
|
WX_HIGHLEVEL_TEMPLATE_COLOR = "#FF0000" //红色
|
||||||
@@ -88,17 +93,17 @@ func GetWeixinOpenIDsFromStoreID(storeID int) (retVal []string) {
|
|||||||
return retVal
|
return retVal
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendMsgToStore(storeID int, templateID, downloadURL string, data interface{}) (err error) {
|
func SendMsgToStore(storeID int, templateID, downloadURL, miniPageURL string, data interface{}) (err error) {
|
||||||
globals.SugarLogger.Debugf("SendMsgToStore storeID:%d, templateID:%s, downloadURL:%s", storeID, templateID, downloadURL)
|
globals.SugarLogger.Debugf("SendMsgToStore storeID:%d, templateID:%s, downloadURL:%s, miniPageURL:%s", storeID, templateID, downloadURL, miniPageURL)
|
||||||
if globals.ReallySendWeixinMsg {
|
if globals.ReallySendWeixinMsg {
|
||||||
if storeID == 0 { // 测试,只发给我
|
if storeID == 0 { // 测试,只发给我
|
||||||
// api.WeixinAPI.MessageTemplateSend("oYN_ust9hXKEvEv0X6Mq6nlAWs_E", templateID, downloadURL, nil, data)
|
// SmartMessageTemplateSend("oYN_ust9hXKEvEv0X6Mq6nlAWs_E", templateID, downloadURL, miniPageURL, data)
|
||||||
} else {
|
} else {
|
||||||
openIDs := GetWeixinOpenIDsFromStoreID(storeID)
|
openIDs := GetWeixinOpenIDsFromStoreID(storeID)
|
||||||
successCount := 0
|
successCount := 0
|
||||||
for _, openID := range openIDs {
|
for _, openID := range openIDs {
|
||||||
globals.SugarLogger.Debugf("SendMsgToStore storeID:%d, openID:%s, templateID:%s, downloadURL:%s", storeID, openID, templateID, downloadURL)
|
globals.SugarLogger.Debugf("SendMsgToStore storeID:%d, openID:%s, templateID:%s, downloadURL:%s", storeID, openID, templateID, downloadURL)
|
||||||
if err2 := api.WeixinAPI.MessageTemplateSend(openID, templateID, downloadURL, nil, data); err2 == nil {
|
if err2 := SmartMessageTemplateSend(openID, templateID, downloadURL, miniPageURL, data); err2 == nil {
|
||||||
successCount++
|
successCount++
|
||||||
} else {
|
} else {
|
||||||
err = err2
|
err = err2
|
||||||
@@ -115,6 +120,22 @@ func SendMsgToStore(storeID int, templateID, downloadURL string, data interface{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SmartMessageTemplateSend(userOpenID, templateID, downloadURL, miniPageURL string, data interface{}) (err error) {
|
||||||
|
const (
|
||||||
|
DebugOpenID = "oYN_usk0AeGc_C6VEZfmFQP5VHMQ"
|
||||||
|
)
|
||||||
|
if userOpenID == DebugOpenID && miniPageURL != "" {
|
||||||
|
if err2 := api.WeixinAPI.MessageTemplateSend(userOpenID, templateID, downloadURL, map[string]interface{}{
|
||||||
|
"appid": api.WeixinMiniAPI.GetAppID(),
|
||||||
|
"pagepath": miniPageURL,
|
||||||
|
}, data); err2 != nil {
|
||||||
|
globals.SugarLogger.Infof("SmartMessageTemplateSend failed with error:%v", err2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = api.WeixinAPI.MessageTemplateSend(userOpenID, templateID, downloadURL, nil, data)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func NotifyNewOrder(order *model.GoodsOrder) (err error) {
|
func NotifyNewOrder(order *model.GoodsOrder) (err error) {
|
||||||
globals.SugarLogger.Debugf("NotifyNewOrder orderID:%s", order.VendorOrderID)
|
globals.SugarLogger.Debugf("NotifyNewOrder orderID:%s", order.VendorOrderID)
|
||||||
if order.VendorID == model.VendorIDELM {
|
if order.VendorID == model.VendorIDELM {
|
||||||
@@ -164,7 +185,7 @@ func NotifyNewOrder(order *model.GoodsOrder) (err error) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
storeID := jxutils.GetJxStoreIDFromOrder(order)
|
storeID := jxutils.GetJxStoreIDFromOrder(order)
|
||||||
return SendMsgToStore(storeID, WX_NEWORDER_TEMPLATE_ID, fmt.Sprintf("%s%d", WX_TO_ORDER_PAGE_URL, storeID), data)
|
return SendMsgToStore(storeID, WX_NEWORDER_TEMPLATE_ID, fmt.Sprintf("%s%d", WX_TO_ORDER_PAGE_URL, storeID), WX_MINI_TO_ORDER_PAGE_URL, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NotifyWaybillStatus(bill *model.Waybill, order *model.GoodsOrder, isBillAlreadyCandidate bool) error {
|
func NotifyWaybillStatus(bill *model.Waybill, order *model.GoodsOrder, isBillAlreadyCandidate bool) error {
|
||||||
@@ -228,7 +249,7 @@ func NotifyWaybillStatus(bill *model.Waybill, order *model.GoodsOrder, isBillAlr
|
|||||||
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return SendMsgToStore(jxutils.GetJxStoreIDFromOrder(order), templateID, "", data)
|
return SendMsgToStore(jxutils.GetJxStoreIDFromOrder(order), templateID, "", "", data)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -262,7 +283,7 @@ func PushJDBadCommentToWeiXin(comment *legacymodel.JxBadComments) (err error) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
storeID := int(utils.Str2Int64(comment.Jxstoreid))
|
storeID := int(utils.Str2Int64(comment.Jxstoreid))
|
||||||
return SendMsgToStore(storeID, WX_BAD_COMMENT_PUSH_TEMPLATE_ID, fmt.Sprintf("%s%d", WX_TO_SHOW_COMMENTS_DETAIL_URL, storeID), data)
|
return SendMsgToStore(storeID, WX_BAD_COMMENT_PUSH_TEMPLATE_ID, fmt.Sprintf("%s%d", WX_TO_SHOW_COMMENTS_DETAIL_URL, storeID), WX_MINI_TO_SHOW_COMMENTS_DETAIL_URL, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NotifySaleBill(storeID int, title, fileURL string) (err error) {
|
func NotifySaleBill(storeID int, title, fileURL string) (err error) {
|
||||||
@@ -289,7 +310,7 @@ func NotifySaleBill(storeID int, title, fileURL string) (err error) {
|
|||||||
"value": "手机买菜上京西,极速到家送惊喜",
|
"value": "手机买菜上京西,极速到家送惊喜",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return SendMsgToStore(storeID, WX_SALE_BILL_TEMPLATE_ID, fileURL, data)
|
return SendMsgToStore(storeID, WX_SALE_BILL_TEMPLATE_ID, fileURL, "", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NotifyStoreOpRequestStatus(isAccepted bool, storeID, nameID int, spuName string, originalUnitPrice, unitPrice int, rejectReason string) (err error) {
|
func NotifyStoreOpRequestStatus(isAccepted bool, storeID, nameID int, spuName string, originalUnitPrice, unitPrice int, rejectReason string) (err error) {
|
||||||
@@ -336,7 +357,7 @@ func NotifyStoreOpRequestStatus(isAccepted bool, storeID, nameID int, spuName st
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SendMsgToStore(storeID, templateID, fileURL, data)
|
return SendMsgToStore(storeID, templateID, fileURL, WX_MINI_TO_STORE_SKU_PAGE_URL, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NotifyStoreMessage(storeID, msgID, msgStatusID int, title, content string) (err error) {
|
func NotifyStoreMessage(storeID, msgID, msgStatusID int, title, content string) (err error) {
|
||||||
@@ -364,7 +385,7 @@ func NotifyStoreMessage(storeID, msgID, msgStatusID int, title, content string)
|
|||||||
"value": "",
|
"value": "",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return SendMsgToStore(storeID, templateID, fileURL, data)
|
return SendMsgToStore(storeID, templateID, fileURL, WX_MINI_TO_SHOW_MSG, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FormatDeliveryTime(order *model.GoodsOrder) string {
|
func FormatDeliveryTime(order *model.GoodsOrder) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user