1
This commit is contained in:
@@ -172,10 +172,8 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
|
||||
|
||||
if err == nil {
|
||||
if isNewComment {
|
||||
globals.SugarLogger.Debugf("================new comment2 := %s", utils.Format4Output(comment2, false))
|
||||
err = dao.CreateEntity(db, comment2)
|
||||
} else if comment2 != nil {
|
||||
globals.SugarLogger.Debugf("================UpdateEntity comment2 := %s", utils.Format4Output(comment2, false))
|
||||
_, err = dao.UpdateEntity(db, comment2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,36 @@ func NotifyNewOrder(order *model.GoodsOrder) {
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewOrder, FlagOrder)
|
||||
}
|
||||
|
||||
// NotifyAdjustOrder 推送调整订单
|
||||
func NotifyAdjustOrder(order *model.GoodsOrder) {
|
||||
storeId := order.StoreID
|
||||
if storeId <= model.NO {
|
||||
storeId = order.JxStoreID
|
||||
}
|
||||
msg := MsgContext{}
|
||||
|
||||
storeDetail, err := dao.GetStoreDetail(dao.GetDB(), storeId, 0, "")
|
||||
if err != nil || storeDetail == nil {
|
||||
return
|
||||
}
|
||||
|
||||
cid, err := GetStoreBoosCID(storeId)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Errorf("新订单推送,获取门店老板CID错误:%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
msg.MsgType = "newOrder"
|
||||
msg.VendorName = model.VendorChineseNames[order.VendorID]
|
||||
msg.OrderSqs = utils.Int2Str(order.OrderSeq)
|
||||
msg.StoreTitle = storeDetail.Name
|
||||
msg.Context = "老板,用户修改订单信息!"
|
||||
msg.VendorOrderId = order.VendorOrderID
|
||||
context, _ := json.Marshal(msg)
|
||||
body := fmt.Sprintf("用户调整了:"+msg.Context+"(%s)", model.VendorChineseNames[order.VendorID]+"#"+msg.OrderSqs+"号订单,请注意拣货")
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewOrder, FlagOrder)
|
||||
}
|
||||
|
||||
func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
|
||||
storeId := afsOrder.StoreID
|
||||
if storeId <= model.NO {
|
||||
|
||||
@@ -3,6 +3,8 @@ package mtwm
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
push "git.rosy.net.cn/jx-callback/business/jxutils/unipush"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
|
||||
"math"
|
||||
"net/url"
|
||||
"regexp"
|
||||
@@ -362,19 +364,42 @@ func (c *PurchaseHandler) onOrderMsg(msg *mtwmapi.CallbackMsg) (response *mtwmap
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if msg.Cmd == mtwmapi.MsgTypeOrderModified {
|
||||
order, _, err2 := c.getOrder(msg.AppID, GetOrderIDFromMsg(msg), GetVendorStoreIDFromMsg(msg))
|
||||
if err = err2; err == nil {
|
||||
localOrder, _ := partner.CurOrderManager.LoadOrder(GetOrderIDFromMsg(msg), model.VendorIDMTWM)
|
||||
localOrder.ConsigneeName = order.ConsigneeName
|
||||
localOrder.ConsigneeMobile = order.ConsigneeMobile
|
||||
localOrder.BuyerComment = order.BuyerComment
|
||||
localOrder.ExpectedDeliveredTime = order.ExpectedDeliveredTime
|
||||
localOrder.ConsigneeAddress = order.ConsigneeAddress
|
||||
localOrder.ConsigneeLat = order.ConsigneeLat
|
||||
localOrder.ConsigneeLng = order.ConsigneeLng
|
||||
dao.UpdateEntity(dao.GetDB(), localOrder, "ConsigneeName", "ConsigneeMobile", "BuyerComment", "ExpectedDeliveredTime", "ConsigneeAddress", "ConsigneeLat", "ConsigneeLng")
|
||||
} else if msg.Cmd == mtwmapi.MsgTypeOrderModified || msg.Cmd == mtwmapi.MsgTypeOrderDeliveryFeeChange {
|
||||
order, orderObj, err2 := c.getOrder(msg.AppID, GetOrderIDFromMsg(msg), GetVendorStoreIDFromMsg(msg))
|
||||
localOrder, _ := partner.CurOrderManager.LoadOrder(GetOrderIDFromMsg(msg), model.VendorIDMTWM)
|
||||
if err2 == nil {
|
||||
switch msg.Cmd {
|
||||
case mtwmapi.MsgTypeOrderModified:
|
||||
// 推送订单信息变更(可能包含地址变更)
|
||||
localOrder.ConsigneeName = order.ConsigneeName
|
||||
localOrder.ConsigneeMobile = order.ConsigneeMobile
|
||||
localOrder.BuyerComment = order.BuyerComment
|
||||
localOrder.ExpectedDeliveredTime = order.ExpectedDeliveredTime
|
||||
localOrder.ConsigneeAddress = order.ConsigneeAddress
|
||||
localOrder.ConsigneeLat = order.ConsigneeLat
|
||||
localOrder.ConsigneeLng = order.ConsigneeLng
|
||||
|
||||
var changeFee int64 = 0
|
||||
if addressChangeFee, ok := orderObj["address_change_fee"]; ok {
|
||||
changeFee = utils.Float64TwoInt64(utils.Str2Float64(utils.Interface2String(addressChangeFee)) * 100)
|
||||
localOrder.TotalShopMoney += changeFee
|
||||
}
|
||||
dao.UpdateEntity(dao.GetDB(), localOrder, "TotalShopMoney", "ConsigneeName", "ConsigneeMobile", "BuyerComment", "ExpectedDeliveredTime", "ConsigneeAddress", "ConsigneeLat", "ConsigneeLng")
|
||||
weixinmsg.NotifyAdjustOrder(order)
|
||||
push.NotifyAdjustOrder(order)
|
||||
partner.CurOrderManager.OnOrderMsg(localOrder, fmt.Sprintf("订单[%s],被用户发起修改,补充运费差价[%d]", order.VendorOrderID, changeFee), "")
|
||||
case mtwmapi.MsgTypeOrderDeliveryFeeChange:
|
||||
// 推送自配订单地址变更费退款详情,当订单为自配订单且用户修改地址时支付了地址变更费,如果订单最终流转到了取消状态,当地址变更费退款成功时平台会通过此接口推送退款详情
|
||||
var changeFee int64 = 0
|
||||
if addressChangeFee, ok := orderObj["address_change_fee"]; ok {
|
||||
changeFee = utils.Float64TwoInt64(utils.Str2Float64(utils.Interface2String(addressChangeFee)) * 100)
|
||||
localOrder.TotalShopMoney -= changeFee
|
||||
}
|
||||
dao.UpdateEntity(dao.GetDB(), localOrder, "TotalShopMoney")
|
||||
partner.CurOrderManager.OnOrderMsg(localOrder, fmt.Sprintf("订单[%s],地址发送改变且订单被取消,返回推送配送差价[%s]元,{接口[%.2f]元}", order.VendorOrderID, msg.FormData.Get("money"), float64(changeFee)/float64(100)), "")
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if status != nil {
|
||||
var order *model.GoodsOrder
|
||||
|
||||
@@ -97,6 +97,10 @@ func (c *MtwmController) IMCallback() {
|
||||
c.OnIMCallback()
|
||||
}
|
||||
|
||||
func (c *MtwmController) DeliveryFeeChange() {
|
||||
c.onCallbackMsg(mtwmapi.MsgTypeOrderDeliveryFeeChange)
|
||||
}
|
||||
|
||||
func (c *MtwmController) OnIMCallback() {
|
||||
c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "")
|
||||
msg, callbackResponse := api.MtwmAPI.GetIMCallbackMsg(c.Ctx.Request)
|
||||
|
||||
Reference in New Issue
Block a user