Merge branch 'mark' of e.coding.net:rosydev/jx-callback into mark
This commit is contained in:
@@ -6,11 +6,14 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
|
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/smsmsg"
|
"git.rosy.net.cn/jx-callback/business/jxutils/smsmsg"
|
||||||
"git.rosy.net.cn/jx-callback/business/msghub"
|
"git.rosy.net.cn/jx-callback/business/msghub"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/basesch"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/basesch"
|
||||||
@@ -1275,6 +1278,7 @@ func (s *DefScheduler) notifyNewOrder(order *model.GoodsOrder) {
|
|||||||
netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order)
|
netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order)
|
||||||
weixinmsg.NotifyNewOrder(order)
|
weixinmsg.NotifyNewOrder(order)
|
||||||
smsmsg.NotifyNewOrder(order)
|
smsmsg.NotifyNewOrder(order)
|
||||||
|
OrderProfitWarning(order)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1311,3 +1315,42 @@ func isOrderCanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool) {
|
|||||||
}
|
}
|
||||||
return isCan
|
return isCan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//订单预计利润若低于0,则向门店运营负责人发送钉钉消息
|
||||||
|
func OrderProfitWarning(order *model.GoodsOrder) {
|
||||||
|
var (
|
||||||
|
operatorName string
|
||||||
|
operatorPhone string
|
||||||
|
noticeMsg string
|
||||||
|
profit float64
|
||||||
|
storeID int
|
||||||
|
)
|
||||||
|
db := dao.GetDB()
|
||||||
|
if order == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
storeID = jxutils.GetShowStoreIDFromOrder(order)
|
||||||
|
storeDetail, err := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||||
|
if storeDetail != nil && err == nil {
|
||||||
|
payPercentage := storeDetail.PayPercentage
|
||||||
|
if payPercentage >= 50 {
|
||||||
|
profit = utils.Str2Float64(utils.Int64ToStr(order.TotalShopMoney-order.EarningPrice-order.DistanceFreightMoney-order.WaybillTipMoney)) / 100
|
||||||
|
} else {
|
||||||
|
profit = utils.Str2Float64(utils.Int64ToStr(order.TotalShopMoney*int64(payPercentage)/200)) / 100
|
||||||
|
}
|
||||||
|
if profit < 0 {
|
||||||
|
if storeDetail.OperatorPhone != "" {
|
||||||
|
operatorName = storeDetail.OperatorName
|
||||||
|
operatorPhone = storeDetail.OperatorPhone
|
||||||
|
} else if storeDetail.OperatorPhone2 != "" {
|
||||||
|
operatorName = storeDetail.OperatorName2
|
||||||
|
operatorPhone = storeDetail.OperatorPhone2
|
||||||
|
}
|
||||||
|
noticeMsg = fmt.Sprintf("订单号:[%v],利润 :[%v],运营负责人:[%v]", order.VendorOrderID, profit, operatorName)
|
||||||
|
user, err := dao.GetUserByID(db, "mobile", operatorPhone)
|
||||||
|
if user != nil && err == nil {
|
||||||
|
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!此订单利润低于0", noticeMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user