新订单消息每天只推送一次

This commit is contained in:
苏尹岚
2020-03-23 09:48:51 +08:00
parent 5c5c88e3bf
commit a8bdd93727
2 changed files with 36 additions and 8 deletions

View File

@@ -23,7 +23,7 @@ var (
}
)
func SendSMSMsg(mobileList []string, signName, templateCode string, templateParam map[string]interface{}) (err error) {
func SendSMSMsg(mobileList []string, signName, templateCode string, templateParam map[string]interface{}, order *model.GoodsOrder) (err error) {
if len(mobileList) > 0 {
errList := errlist.New()
mobileList = jxutils.StringMap2List(jxutils.StringList2Map(mobileList))
@@ -42,6 +42,8 @@ func SendSMSMsg(mobileList []string, signName, templateCode string, templatePara
} else {
globals.SugarLogger.Infof(errMsg)
}
} else {
err = updateStoreSMSNotifyMark(order)
}
}
}
@@ -56,11 +58,13 @@ func getOrderNotifyPhone(order *model.GoodsOrder) (phoneList []string) {
}
func NotifyNewOrder(order *model.GoodsOrder) (err error) {
err = SendSMSMsg(getOrderNotifyPhone(order), globals.SMSSignName, globals.SMSNewOrderTemplate, map[string]interface{}{
"daySeq": order.OrderSeq,
"consigneeName": order.ConsigneeName,
"payMoney": jxutils.IntPrice2StandardString(order.ActualPayPrice),
})
if isPushSMS(order) {
err = SendSMSMsg(getOrderNotifyPhone(order), globals.SMSSignName, globals.SMSNewOrderTemplate, map[string]interface{}{
"daySeq": order.OrderSeq,
"consigneeName": order.ConsigneeName,
"payMoney": jxutils.IntPrice2StandardString(order.ActualPayPrice),
}, order)
}
return err
}
@@ -69,6 +73,29 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
"vendorName": model.VendorChineseNames[order.VendorID],
"seq": order.OrderSeq,
"orderID": order.VendorOrderID,
})
}, order)
return err
}
func isPushSMS(order *model.GoodsOrder) bool {
stores, _ := dao.GetStoreList(dao.GetDB(), []int{order.StoreID}, nil, nil, nil, "")
if len(stores) > 0 {
if stores[0].SMSNotifyMark == model.NO {
return true
} else {
return false
}
} else {
return false
}
}
func updateStoreSMSNotifyMark(order *model.GoodsOrder) (err error) {
var db = dao.GetDB()
stores, _ := dao.GetStoreList(db, []int{order.StoreID}, nil, nil, nil, "")
if len(stores) > 0 {
stores[0].SMSNotifyMark = model.YES
_, err = dao.UpdateEntity(db, stores[0], "SMSNotifyMark")
}
return err
}