Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop

This commit is contained in:
richboo111
2023-06-12 14:16:05 +08:00
24 changed files with 251 additions and 170 deletions

View File

@@ -80,13 +80,14 @@ func (c *DeliveryHandler) OnWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap
}
func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaapi.CallbackResponse) {
order := c.callbackMsg2Waybill(msg)
order, goodsOrder := c.callbackMsg2Waybill(msg)
store, _ := dao.GetStoreDetail(dao.GetDB(), goodsOrder.JxStoreID, goodsOrder.VendorID, goodsOrder.VendorOrgCode)
switch msg.OrderStatus {
case dadaapi.OrderStatusWaitingForAccept:
dadaOrder, err := api.DadaAPI.QueryOrderInfo(msg.OrderID)
if err == nil {
order.ActualFee = jxutils.StandardPrice2Int(dadaOrder.ActualFee)
order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee)
order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + int64(store.FreightMarkup)
}
order.Status = model.WaybillStatusNew
case dadaapi.OrderStatusAccepted:
@@ -94,7 +95,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap
order.Remark = order.CourierName + "" + order.CourierMobile
if dadaOrder, err := api.DadaAPI.QueryOrderInfo(msg.OrderID); err == nil {
order.ActualFee = jxutils.StandardPrice2Int(dadaOrder.ActualFee)
order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee)
order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + int64(store.FreightMarkup)
}
case dadaapi.OrderStatusReturningInOrder:
order.Status = model.WaybillStatusCourierArrived
@@ -161,7 +162,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap
return err
}
func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal *model.Waybill) {
func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal *model.Waybill, goods *model.GoodsOrder) {
retVal = &model.Waybill{
VendorWaybillID: msg.ClientID,
WaybillVendorID: model.VendorIDDada,
@@ -179,12 +180,11 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal
retVal.StatusTime = utils.Timestamp2Time(updateTime)
retVal.VendorOrderID, retVal.OrderVendorID = jxutils.SplitUniversalOrderID(msg.OrderID)
var good *model.GoodsOrder
sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0`
sqlParams := []interface{}{msg.OrderID}
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
retVal.OrderVendorID = good.VendorID
return retVal
dao.GetRow(dao.GetDB(), &goods, sql, sqlParams)
retVal.OrderVendorID = goods.VendorID
return retVal, goods
}
func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.ShopInfo) {

View File

@@ -148,7 +148,7 @@ func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.S
// 蜂鸟门店状态改变
func OnStoreStatus(msg *fnpsapi.ChainstoreStatusNotify) (retVal *fnpsapi.CallbackResponse) {
return curDeliveryHandler.OnStoreStatus(msg)
return CurDeliveryHandler.OnStoreStatus(msg)
}
// 修改本地门店审核状态

View File

@@ -5,6 +5,7 @@ import (
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"strings"
"time"
@@ -35,7 +36,7 @@ const (
)
var (
curDeliveryHandler *DeliveryHandler
CurDeliveryHandler *DeliveryHandler
complaintReson2FnResonMap = map[int]int{
model.ComplaintReasons1: ComplaintReasonsFn160,
model.ComplaintReasons2: ComplaintReasonsFn130,
@@ -53,10 +54,8 @@ type DeliveryHandler struct {
}
func init() {
if api.FnAPI != nil {
curDeliveryHandler = new(DeliveryHandler)
partner.RegisterDeliveryPlatform(curDeliveryHandler, true)
}
CurDeliveryHandler = new(DeliveryHandler)
partner.RegisterDeliveryPlatform(CurDeliveryHandler, true)
}
func (c *DeliveryHandler) GetVendorID() int {
@@ -249,14 +248,17 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta
}
order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(cc.PartnerOrderCode)
order.OrderVendorID = good.VendorID
store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode)
orderStatus := utils.Str2Int64(order.VendorStatus)
switch orderStatus {
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 0 创建订单
order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
order.Status = model.WaybillStatusNew //5 带调度
order.DesiredFee += int64(store.FreightMarkup) // 运营加价
order.Status = model.WaybillStatusNew //5 带调度
case fnpsapi.OrderStatusAssigned: //20分配骑手
//order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
order.DesiredFee += int64(store.FreightMarkup)
order.Status = model.WaybillStatusCourierAssigned //12
order.Remark = order.CourierName + "" + order.CourierMobile
case fnpsapi.OrderStatusArrived: // 80 到店
@@ -323,7 +325,7 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta
// 异常报备
func OnWaybillExceptFn(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) {
return curDeliveryHandler.OnWaybillExcept(msg)
return CurDeliveryHandler.OnWaybillExcept(msg)
}
func (c *DeliveryHandler) OnWaybillExcept(msg *fnpsapi.AbnormalReportNotify) (retVal *fnpsapi.CallbackResponse) {
@@ -487,3 +489,31 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId
}
return vendorPrice, nil
}
func (c *DeliveryHandler) GetRidderPosition(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (lng, lat float64, err error) {
order, err := api.FnAPI.GetKnightInfo(&fnpsapi.GetOrderDetailReq{
PartnerOrderCode: vendorOrderID,
})
if err == nil {
lng = utils.Str2Float64WithDefault(order.CarrierDriverLongitude, 0)
lat = utils.Str2Float64WithDefault(order.CarrierDriverLatitude, 0)
}
return lng, lat, err
}
func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
return api.FnAPI.AddTip(&fnpsapi.AddTipRes{
OrderId: "",
PartnerOrderCode: vendorOrderID,
AddTipAmountCent: tipFee,
ThirdIndexId: time.Now().Unix(),
})
}
func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
order, err := api.FnAPI.QueryOrder(vendorOrderID)
if err == nil {
tipFee = order.OrderTipAmountCent
}
return tipFee, err
}

View File

@@ -85,7 +85,7 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *mtpsapi.CallbackOrderExceptionMsg
}
func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *mtpsapi.CallbackResponse) {
order := c.callbackMsg2Waybill(msg)
order, goodsOrder := c.callbackMsg2Waybill(msg)
// 多次取消,只处理第一次
if msg.Status == mtpsapi.OrderStatusCanceled {
orderStatus, _ := orderman.FixedOrderManager.GetWayBillStatusList(msg.OrderID, msg.MtPeisongID, model.VendorIDMTPS)
@@ -96,6 +96,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
}
}
store, _ := dao.GetStoreDetail(dao.GetDB(), goodsOrder.JxStoreID, goodsOrder.VendorID, goodsOrder.VendorOrgCode)
switch msg.Status {
case mtpsapi.OrderStatusWaitingForSchedule:
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
@@ -104,6 +105,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
}
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
order.DesiredFee += int64(store.FreightMarkup)
order.Status = model.WaybillStatusNew
case mtpsapi.OrderStatusAccepted: // 已接单
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
@@ -112,6 +114,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
}
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
order.DesiredFee += int64(store.FreightMarkup)
order.Status = model.WaybillStatusCourierAssigned
order.Remark = order.CourierName + "" + order.CourierMobile
case mtpsapi.OrderStatusPickedUp: // 已取货
@@ -230,7 +233,7 @@ func signParams(params url.Values) string {
return fmt.Sprintf("%x", sha1.Sum([]byte(finalStr)))
}
func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (retVal *model.Waybill) {
func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (retVal *model.Waybill, good2 *model.GoodsOrder) {
retVal = &model.Waybill{
VendorWaybillID: msg.MtPeisongID,
VendorWaybillID2: utils.Int64ToStr(msg.DeliveryID),
@@ -250,7 +253,7 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (re
} else {
retVal.OrderVendorID = good.VendorID
}
return retVal
return retVal, good
}
// 老方法是自己计算
@@ -548,3 +551,13 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId
}
return 0, err
}
func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
// 无法获取已经添加的小费金额
return fmt.Errorf("美团暂不支持添加小费")
//return api.MtpsAPI.AddTip(vendorOrderID, vendorWaybillID, tipFee)
}
func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
return tipFee, err
}

View File

@@ -140,9 +140,10 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
return nil, err
}
//+0.2
// 系统加价
desiredFee := utils.Float64TwoInt(sfTotalPrice) + utils.WayBillDeliveryMarkUp
// 运营加价
desiredFee += store.FreightMarkup
bill = &model.Waybill{
VendorOrderID: order.VendorOrderID,
OrderVendorID: order.VendorID,
@@ -222,8 +223,6 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
}
deliveryFeeInfo = &partner.WaybillFeeInfo{}
price, err := api.SfPsAPI.PreCreateOrder(param)
//+0.2
//deliveryFee := utils.Float64TwoInt(price) + utils.WayBillDeliveryMarkUp
deliveryFeeInfo.DeliveryFee = utils.Float64TwoInt64(price)
globals.SugarLogger.Debugf("GetWaybillFee deliveryFeeInfo.DeliveryFee=%d", deliveryFeeInfo.DeliveryFee)
return deliveryFeeInfo, err
@@ -343,8 +342,7 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons
order.CourierMobile = sfOrder.RiderPhone
}
//+0.2
sfTotalPrice := utils.Float64TwoInt(sfOrder.TotalPrice) + utils.WayBillDeliveryMarkUp
sfTotalPrice := utils.Float64TwoInt(sfOrder.TotalPrice)
sfActualPrice := utils.Float64TwoInt64(sfOrder.RealPayMoney)
globals.SugarLogger.Debugf("SFPS OnWaybillMsg,sfTotalPrice=%d,sfActualPrice=%d", sfTotalPrice, sfActualPrice)
@@ -354,6 +352,9 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
order.OrderVendorID = good.VendorID
store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode)
sfTotalPrice += store.FreightMarkup
orderStatus := utils.Str2Int64(order.VendorStatus)
switch orderStatus {
case sfps2.OrderStatusNewOrder: //1订单创建

View File

@@ -341,6 +341,10 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
} else {
reallyPrice = int64(utils.Str2Float64(uuPrice.OrderPrice) * 100)
}
store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode)
reallyPrice += int64(store.FreightMarkup)
actualFee := int64((utils.Str2Float64(uuPrice.OrderPrice)-utils.Str2Float64(uuPrice.PriceOff))*100) - int64(utils.WayBillDeliveryMarkUp)
switch req.State {
case uuptapi.StateConfirmSuccess: