新订单消息每天只推送一次
This commit is contained in:
@@ -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 {
|
if len(mobileList) > 0 {
|
||||||
errList := errlist.New()
|
errList := errlist.New()
|
||||||
mobileList = jxutils.StringMap2List(jxutils.StringList2Map(mobileList))
|
mobileList = jxutils.StringMap2List(jxutils.StringList2Map(mobileList))
|
||||||
@@ -42,6 +42,8 @@ func SendSMSMsg(mobileList []string, signName, templateCode string, templatePara
|
|||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Infof(errMsg)
|
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) {
|
func NotifyNewOrder(order *model.GoodsOrder) (err error) {
|
||||||
|
if isPushSMS(order) {
|
||||||
err = SendSMSMsg(getOrderNotifyPhone(order), globals.SMSSignName, globals.SMSNewOrderTemplate, map[string]interface{}{
|
err = SendSMSMsg(getOrderNotifyPhone(order), globals.SMSSignName, globals.SMSNewOrderTemplate, map[string]interface{}{
|
||||||
"daySeq": order.OrderSeq,
|
"daySeq": order.OrderSeq,
|
||||||
"consigneeName": order.ConsigneeName,
|
"consigneeName": order.ConsigneeName,
|
||||||
"payMoney": jxutils.IntPrice2StandardString(order.ActualPayPrice),
|
"payMoney": jxutils.IntPrice2StandardString(order.ActualPayPrice),
|
||||||
})
|
}, order)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,6 +73,29 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
|
|||||||
"vendorName": model.VendorChineseNames[order.VendorID],
|
"vendorName": model.VendorChineseNames[order.VendorID],
|
||||||
"seq": order.OrderSeq,
|
"seq": order.OrderSeq,
|
||||||
"orderID": order.VendorOrderID,
|
"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
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,7 +279,8 @@ type Store struct {
|
|||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
AutoEnableAt *time.Time `orm:"type(datetime);null" json:"autoEnableAt"` // 自动营业时间(临时休息用)
|
AutoEnableAt *time.Time `orm:"type(datetime);null" json:"autoEnableAt"` // 自动营业时间(临时休息用)
|
||||||
ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核
|
ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核
|
||||||
SMSNotify int8 `orm:"column(sms_notify);" json:"smsNotify"` // 是否通过短信接收订单消息
|
SMSNotify int8 `orm:"column(sms_notify);" json:"smsNotify"` // 是否通过短信接收订单消息(每天只推一条)
|
||||||
|
SMSNotifyMark int8 `orm:"column(sms_notify_mark);" json:"smsNotifyMark"` //今天是否已经推送过订单消息
|
||||||
AutoReplyType int8 `json:"autoReplyType"` // 订单评价自动回复类型
|
AutoReplyType int8 `json:"autoReplyType"` // 订单评价自动回复类型
|
||||||
LinkStoreID int `orm:"column(link_store_id);default(0);index" json:"linkStoreID"` // 关联门店ID
|
LinkStoreID int `orm:"column(link_store_id);default(0);index" json:"linkStoreID"` // 关联门店ID
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user