fnps
This commit is contained in:
@@ -784,7 +784,7 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
if err = s.canOrderCreateWaybillNormally(order, savedOrderInfo); err == nil {
|
||||
if (order.DeliveryFlag & model.OrderDeliveryFlagMaskScheduleDisabled) == 0 {
|
||||
if savedOrderInfo.retryCount <= maxWaybillRetryCount {
|
||||
var waybillVendorIDs = []int{model.VendorIDMTPS, model.VendorIDDada}
|
||||
var waybillVendorIDs = []int{model.VendorIDMTPS, model.VendorIDDada, model.VendorIDFengNiao}
|
||||
savedOrderInfo.isNeedCreate3rdWaybill = true
|
||||
excludeVendorIDs := savedOrderInfo.GetWaybillVendorIDs()
|
||||
//TODO 取消京西不自动发美团 2020-06-02
|
||||
|
||||
@@ -102,9 +102,10 @@ var (
|
||||
VendorIDWSC: "微盟微商城",
|
||||
VendorIDJX: "京西商城",
|
||||
|
||||
VendorIDDada: "达达众包",
|
||||
VendorIDMTPS: "美团配送",
|
||||
VendorIDJDWL: "京东物流",
|
||||
VendorIDDada: "达达众包",
|
||||
VendorIDMTPS: "美团配送",
|
||||
VendorIDJDWL: "京东物流",
|
||||
VendorIDFengNiao: "蜂鸟配送",
|
||||
|
||||
VendorIDFeiE: "飞鹅",
|
||||
VendorIDXiaoWM: "外卖管家",
|
||||
|
||||
62
business/partner/delivery/fn/store.go
Normal file
62
business/partner/delivery/fn/store.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package fn
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/fnpsapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
|
||||
err = api.FnAPI.CreateStore(&fnpsapi.CreateStoreParam{
|
||||
ChainStoreCode: utils.Int2Str(storeDetail.ID),
|
||||
ChainStoreName: storeDetail.Name,
|
||||
ContactPhone: storeDetail.Tel1,
|
||||
Address: storeDetail.Address,
|
||||
PositionSource: 3,
|
||||
Longitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng)),
|
||||
Latitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat)),
|
||||
})
|
||||
if err == nil {
|
||||
vendorStoreID = utils.Int2Str(storeDetail.ID)
|
||||
}
|
||||
return vendorStoreID, status, err
|
||||
}
|
||||
|
||||
func shopStatus2JX(status int) (jxStatus int) {
|
||||
if status == 1 {
|
||||
return 0
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeDetail *dao.StoreDetail2, err error) {
|
||||
shopInfo, err := api.FnAPI.GetStore(storeID)
|
||||
if err == nil {
|
||||
storeDetail = &dao.StoreDetail2{
|
||||
Store: model.Store{
|
||||
Name: shopInfo.ChainStoreName,
|
||||
Tel1: shopInfo.ContactPhone,
|
||||
Address: shopInfo.Address,
|
||||
Lng: jxutils.StandardCoordinate2Int(utils.Str2Float64(shopInfo.Longitude)),
|
||||
Lat: jxutils.StandardCoordinate2Int(utils.Str2Float64(shopInfo.Latitude)),
|
||||
},
|
||||
VendorID: model.VendorIDFengNiao,
|
||||
VendorStoreID: shopInfo.ChainStoreCode,
|
||||
CourierStatus: shopStatus2JX(shopInfo.Status),
|
||||
}
|
||||
}
|
||||
return storeDetail, err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) IsErrStoreExist(err error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) IsErrStoreNotExist(err error) bool {
|
||||
return false
|
||||
}
|
||||
116
business/partner/delivery/fn/waybill.go
Normal file
116
business/partner/delivery/fn/waybill.go
Normal file
@@ -0,0 +1,116 @@
|
||||
package fn
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/delivery"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/fnpsapi"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
var (
|
||||
curDeliveryHandler *DeliveryHandler
|
||||
)
|
||||
|
||||
type DeliveryHandler struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
if api.FnAPI != nil {
|
||||
curDeliveryHandler = new(DeliveryHandler)
|
||||
partner.RegisterDeliveryPlatform(curDeliveryHandler, true)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetVendorID() int {
|
||||
return model.VendorIDFengNiao
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
||||
err = api.FnAPI.CancelOrder(&fnpsapi.CancelOrderParam{
|
||||
PartnerOrderCode: bill.VendorOrderID,
|
||||
OrderCancelReasonCode: 1, //用户取消
|
||||
OrderCancelCode: fnpsapi.OrderCancelReson8,
|
||||
OrderCancelTime: time.Now().UnixNano() / 1e6,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
storeDetail, err := dao.GetStoreDetail(db, order.StoreID, order.VendorID, order.VendorOrgCode)
|
||||
deliveryFee, _, err := delivery.CalculateOrderDeliveryFee(order, time.Now(), db)
|
||||
if err == nil {
|
||||
if err = delivery.CallCreateWaybillPolicy(deliveryFee, maxDeliveryFee, order, model.VendorIDFengNiao); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
params := &fnpsapi.CreateOrderParam{
|
||||
PartnerOrderCode: order.VendorOrderID,
|
||||
NotifyURL: globals.FnNotifyURL,
|
||||
ChainStoreCode: order.VendorStoreID,
|
||||
OrderType: 1, //即时达
|
||||
TransportInfo: &fnpsapi.TransportInfo{
|
||||
TransportName: order.StoreName,
|
||||
TransportAddress: storeDetail.Address,
|
||||
TransportLongitude: jxutils.IntCoordinate2Standard(storeDetail.Lng),
|
||||
TransportLatitude: jxutils.IntCoordinate2Standard(storeDetail.Lat),
|
||||
PositionSource: 3,
|
||||
TransportTel: storeDetail.Tel1,
|
||||
},
|
||||
OrderAddTime: order.OrderCreatedAt.UnixNano() / 1e6,
|
||||
OrderTotalAmount: jxutils.IntPrice2Standard(order.SalePrice),
|
||||
OrderActualAmount: jxutils.IntPrice2Standard(order.ActualPayPrice),
|
||||
OrderWeight: float64(jxutils.IntWeight2Float(order.Weight)),
|
||||
OrderRemark: utils.FilterMb4("客户电话:" + order.ConsigneeMobile + "," + order.BuyerComment + ",取货失败或配送遇到问题请联系18048531223,禁止未配送直接完成定单!"),
|
||||
IsInvoiced: 0,
|
||||
OrderPaymentStatus: 1,
|
||||
OrderPaymentMethod: 1,
|
||||
IsAgentPayment: 0,
|
||||
GoodsCount: order.GoodsCount,
|
||||
ReceiverInfo: &fnpsapi.ReceiverInfo{
|
||||
ReceiverName: order.ConsigneeName,
|
||||
ReceiverAddress: order.ConsigneeAddress,
|
||||
ReceiverLongitude: jxutils.IntCoordinate2Standard(order.ConsigneeLng),
|
||||
ReceiverLatitude: jxutils.IntCoordinate2Standard(order.ConsigneeLat),
|
||||
ReceiverPrimaryPhone: order.ConsigneeMobile,
|
||||
ReceiverSecondPhone: order.ConsigneeMobile2,
|
||||
PositionSource: 3,
|
||||
},
|
||||
SerialNumber: model.VendorNames[order.VendorID] + " #" + utils.Int2Str(order.OrderSeq),
|
||||
}
|
||||
var skuInfo []*fnpsapi.ItemsJSON
|
||||
for _, v := range order.Skus {
|
||||
skuInfo = append(skuInfo, &fnpsapi.ItemsJSON{
|
||||
ItemID: utils.Int2Str(v.SkuID),
|
||||
ItemName: v.SkuName,
|
||||
ItemQuantity: v.Count,
|
||||
ItemPrice: jxutils.IntPrice2Standard(v.SalePrice),
|
||||
ItemActualPrice: jxutils.IntPrice2Standard(v.SalePrice),
|
||||
})
|
||||
}
|
||||
err = api.FnAPI.CreateOrder(params)
|
||||
}
|
||||
return bill, err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *partner.WaybillFeeInfo, err error) {
|
||||
|
||||
return deliveryFeeInfo, err
|
||||
}
|
||||
@@ -265,6 +265,7 @@ pushMasterSecret= "dGZcR0XGGg7H5Pd7FR3n47"
|
||||
|
||||
fnAppID = "6a3e2073-1850-413b-9eb7-6c342ec36e1c"
|
||||
fnAppSecret = "a8248088-a742-4c33-a0db-03aeae00ca7d"
|
||||
fnCallbackURL = "http://callback.jxc4.com/fn/msg"
|
||||
|
||||
[jxgy]
|
||||
httpport = 8088
|
||||
|
||||
21
controllers/fn_callback.go
Normal file
21
controllers/fn_callback.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
type FnController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *FnController) Msg() {
|
||||
if c.Ctx.Input.Method() == http.MethodPost {
|
||||
|
||||
c.Data["json"] = ""
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
c.Abort("404")
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ var (
|
||||
|
||||
WxpayNotifyURL string
|
||||
TLPayNotifyURL string
|
||||
FnNotifyURL string
|
||||
|
||||
JdOrgCode string
|
||||
Jd2OrgCode string
|
||||
@@ -132,6 +133,7 @@ func Init() {
|
||||
|
||||
WxpayNotifyURL = beego.AppConfig.DefaultString("wxpayNotifyURL", "")
|
||||
TLPayNotifyURL = beego.AppConfig.DefaultString("tonglianPayNotifyURL", "")
|
||||
FnNotifyURL = beego.AppConfig.DefaultString("fnCallbackURL", "")
|
||||
JdOrgCode = beego.AppConfig.DefaultString("jdOrgCode", "")
|
||||
Jd2OrgCode = beego.AppConfig.DefaultString("jd2OrgCode", "")
|
||||
Jd3OrgCode = beego.AppConfig.DefaultString("jd3OrgCode", "")
|
||||
|
||||
@@ -163,6 +163,7 @@ func init() {
|
||||
beego.AutoRouter(&controllers.TongLianController{})
|
||||
beego.AutoRouter(&controllers.EclpController{})
|
||||
beego.AutoRouter(&controllers.JdsController{})
|
||||
beego.AutoRouter(&controllers.FnController{})
|
||||
|
||||
// 如下都是用于检测存活的空接口
|
||||
beego.Any("/", func(ctx *beecontext.Context) {
|
||||
|
||||
Reference in New Issue
Block a user