1
This commit is contained in:
@@ -933,7 +933,7 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
}
|
||||
|
||||
//2020-11-16 预计收益-配送费 > 0 再发
|
||||
if order.EarningType == model.EarningTypeQuote && order.VendorID != model.VendorIDTaoVegetable { // 淘宝是第二天更新结算信息的
|
||||
if order.EarningType == model.EarningTypeQuote && order.VendorID != model.VendorIDTaoVegetable && order.VendorID != model.VendorIDDD { // 淘宝,抖店 是第二天更新结算信息的
|
||||
for _, vendorID := range waybillVendorIDs {
|
||||
handler := partner.GetDeliveryPlatformFromVendorID(vendorID)
|
||||
if deliveryFeeInfo, err := handler.Handler.GetWaybillFee(order); err == nil {
|
||||
|
||||
@@ -195,7 +195,7 @@ func Init() {
|
||||
orderman.UpdateTiktokShopTotalMoney()
|
||||
}, []string{
|
||||
"03:35:00",
|
||||
"09:35:00",
|
||||
"16:35:00",
|
||||
})
|
||||
/// 更新淘鲜达结算信息
|
||||
ScheduleTimerFunc("UpdateTaoTotalMoney", func() {
|
||||
@@ -210,10 +210,10 @@ func Init() {
|
||||
delivery.UpdateFakeWayBillToTiktok()
|
||||
}, 10*time.Second, 2*time.Minute)
|
||||
|
||||
// 每五分钟轮询一次推送骑手信息坐标给美团(真的订单)
|
||||
// 每五分钟轮询一次推送骑手信息坐标给美团/抖音 (真的订单)[抖音建议小于六十秒]
|
||||
ScheduleTimerFuncByInterval(func() {
|
||||
delivery.GetOrderRiderInfoToPlatform("", 0)
|
||||
}, 10*time.Second, 5*time.Minute)
|
||||
}, 10*time.Second, 2*time.Minute)
|
||||
|
||||
// (自动发单拣货,设置骑手) 刷单用
|
||||
//ScheduleTimerFuncByInterval(func() {
|
||||
|
||||
@@ -134,10 +134,11 @@ func tiktokStatusPush(order *model.Waybill, status int) {
|
||||
ThirdCarrierOrderId: order.VendorOrderID,
|
||||
CourierName: order.CourierName,
|
||||
CourierPhone: order.CourierMobile,
|
||||
LogisticsProviderCode: "10002",
|
||||
LogisticsStatus: order.Status,
|
||||
OpCode: "",
|
||||
LogisticsProviderCode: utils.DaDaCode,
|
||||
}
|
||||
|
||||
switch status {
|
||||
case dadaapi.OrderStatusWaitingForAccept: // 待接单,召唤骑手
|
||||
result.LogisticsStatus = model.WaybillStatusNew
|
||||
|
||||
@@ -327,10 +327,11 @@ func tiktokStatusPush(order *model.Waybill, orderStatus int64) {
|
||||
ThirdCarrierOrderId: order.VendorOrderID,
|
||||
CourierName: order.CourierName,
|
||||
CourierPhone: order.CourierMobile,
|
||||
LogisticsProviderCode: "10002",
|
||||
LogisticsStatus: order.Status,
|
||||
OpCode: "",
|
||||
LogisticsProviderCode: utils.FnPsCode,
|
||||
}
|
||||
|
||||
switch orderStatus {
|
||||
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 待接单,召唤骑手
|
||||
result.LogisticsStatus = model.WaybillStatusNew
|
||||
|
||||
@@ -158,10 +158,11 @@ func pushMTPSToTiktok(msgStatus int, order *model.Waybill) {
|
||||
ThirdCarrierOrderId: order.VendorOrderID,
|
||||
CourierName: order.CourierName,
|
||||
CourierPhone: order.CourierMobile,
|
||||
LogisticsProviderCode: "10032",
|
||||
LogisticsProviderCode: utils.MTPsCode,
|
||||
LogisticsStatus: order.Status,
|
||||
OpCode: "",
|
||||
}
|
||||
|
||||
switch msgStatus {
|
||||
case mtpsapi.OrderStatusWaitingForSchedule: // 待接单,召唤骑手
|
||||
result.LogisticsStatus = model.WaybillStatusNew
|
||||
|
||||
@@ -95,9 +95,9 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
|
||||
//3.当同一个订单已经上传了一次配送信息,如再次同步会更新配送信息,以最新的一次为准。
|
||||
//4.如订单已完成、已取消等状态发货将失败。
|
||||
for _, v := range orders {
|
||||
if orderId == "" && v.VendorID == model.VendorIDDD { // 抖音门店订单除了三方配送回调时推送,不在主动推送配送消息
|
||||
continue
|
||||
}
|
||||
//if orderId == "" && v.VendorID == model.VendorIDDD { // 抖音门店订单除了三方配送回调时推送,不在主动推送配送消息
|
||||
// continue
|
||||
//}
|
||||
// 非三方配送订单不同步消息
|
||||
if v.WaybillVendorID < 100 {
|
||||
continue
|
||||
@@ -134,7 +134,7 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
|
||||
if wayBillStatus == model.OrderStatusNew || wayBillStatus == model.OrderStatusCanceled || (v.WaybillVendorID == -1 && v.DeliveryType == "store") { // 真商家自送
|
||||
riderInfo.OrderId = v.VendorOrderID
|
||||
riderInfo.CourierName = "门店老板"
|
||||
riderInfo.LogisticsProviderCode = "10017"
|
||||
riderInfo.LogisticsProviderCode = "10015"
|
||||
riderInfo.LogisticsStatus = v.Status
|
||||
}
|
||||
|
||||
@@ -229,7 +229,11 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
|
||||
case model.VendorIDWSC: // 微盟微商城
|
||||
continue
|
||||
case model.VendorIDDD: // 抖店小时达
|
||||
continue
|
||||
if handler := partner.GetPurchaseOrderHandlerFromVendorID(v.VendorID); handler != nil {
|
||||
if err := handler.GetOrderRider(v.VendorOrgCode, v.VendorStoreID, utils.Struct2Map(riderInfo, "", true)); err != nil {
|
||||
globals.SugarLogger.Debugf("Error pushing meituan rider information :%s--%s--%v", v.VendorOrderID, utils.Format4Output(riderInfo, false), err)
|
||||
}
|
||||
}
|
||||
case model.VendorIDJX: // 京西平台
|
||||
continue
|
||||
case model.VendorIDTaoVegetable: // 淘鲜达
|
||||
@@ -395,13 +399,6 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *utils.RiderInfo) {
|
||||
|
||||
// UpdateFakeWayBillToTiktok 轮询更新假订单到抖音(抖音/美团/饿百)
|
||||
func UpdateFakeWayBillToTiktok() {
|
||||
//scheduleTimer, _ := rand.Int(rand.Reader, big.NewInt(1000))
|
||||
//randTimeSchedule := scheduleTimer.Int64()
|
||||
//if randTimeSchedule > 500 {
|
||||
// return
|
||||
//}
|
||||
globals.SugarLogger.Debugf("===================fakeWayBill := %s", "开始")
|
||||
|
||||
fakeWayBill, err := dao.GetWayBillFakeOrder()
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("Get Fake Order Err : %s", err.Error())
|
||||
@@ -417,7 +414,6 @@ func UpdateFakeWayBillToTiktok() {
|
||||
continue
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("===================fakeWayBill := %s", fakeWayBill[i].VendorOrderID)
|
||||
riderInfo := &utils.RiderInfo{
|
||||
OrderId: fakeWayBill[i].VendorOrderID,
|
||||
ThirdCarrierOrderId: fakeWayBill[i].VendorOrderID,
|
||||
@@ -429,7 +425,6 @@ func UpdateFakeWayBillToTiktok() {
|
||||
|
||||
// 设置骑手和下一状态时间
|
||||
makeRiderInfo(fakeWayBill[i], riderInfo)
|
||||
globals.SugarLogger.Debugf("===================makeRiderInfo := %s", utils.Format4Output(fakeWayBill[i], false))
|
||||
if riderInfo.CourierName == "" && fakeWayBill[i].CourierName != "" {
|
||||
riderInfo.CourierName = fakeWayBill[i].CourierName
|
||||
riderInfo.CourierPhone = fakeWayBill[i].CourierMobile
|
||||
@@ -447,7 +442,6 @@ func UpdateFakeWayBillToTiktok() {
|
||||
handler := partner.GetPurchaseOrderHandlerFromVendorID(fakeWayBill[i].OrderVendorID)
|
||||
if handler != nil {
|
||||
order, _ := partner.CurOrderManager.LoadOrder(fakeWayBill[i].VendorOrderID, fakeWayBill[i].OrderVendorID)
|
||||
globals.SugarLogger.Debugf("===================paramsMap := %s", utils.Format4Output(paramsMap, false))
|
||||
if err := handler.GetOrderRider(fakeWayBill[i].VendorOrgCode, order.VendorStoreID, paramsMap); err != nil {
|
||||
partner.CurOrderManager.OnOrderMsg(order, tao_vegetable.OrderStatusDelivery, fmt.Sprintf("Fake Pull Rider Info Err :%s--%s--%v", riderInfo.OrderId, riderInfo.ThirdCarrierOrderId, err))
|
||||
} else {
|
||||
|
||||
@@ -224,11 +224,12 @@ func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeison
|
||||
return nil, err
|
||||
}
|
||||
param := &utils.RiderInfo{
|
||||
OrderId: orderId,
|
||||
ThirdCarrierOrderId: waybill.OrderCode,
|
||||
CourierName: waybill.DriverName,
|
||||
CourierPhone: waybill.DriverMobile,
|
||||
LogisticsProviderCode: utils.UUPTCode,
|
||||
OrderId: orderId,
|
||||
ThirdCarrierOrderId: waybill.OrderCode,
|
||||
CourierName: waybill.DriverName,
|
||||
CourierPhone: waybill.DriverMobile,
|
||||
//LogisticsProviderCode: utils.UUPTCode,
|
||||
LogisticsProviderCode: "UU",
|
||||
LogisticsStatus: utils.Str2Int(waybill.State),
|
||||
}
|
||||
if len(waybill.DriverLastloc) == 0 {
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -177,7 +175,6 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) error {
|
||||
//3 cid推送新消息
|
||||
if err = PushMsgByCid(vendorStoreID, vendorID, string(msg)); err != nil {
|
||||
errList.AddErr(fmt.Errorf("向商家cid推送新消息错误:%v", err))
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "向商家cid推送新消息错误: ", err.Error())
|
||||
}
|
||||
|
||||
if errList.GetErrListAsOne() != nil {
|
||||
|
||||
@@ -127,7 +127,7 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode string, vendorOrderID int64, ve
|
||||
Upc: *extra.Barcode,
|
||||
}
|
||||
// extra.SkuCode 为int类型会超出长度,有时商品为平台创建
|
||||
if len(*extra.SkuCode) <= 10 {
|
||||
if len(*extra.SkuCode) < 10 {
|
||||
sku.SkuID = utils.Str2Int(*extra.SkuCode)
|
||||
sku.JxSkuID = utils.Str2Int(*extra.SkuCode)
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode string, vendorOrderID int64, ve
|
||||
}
|
||||
|
||||
if len(activityId) > 0 {
|
||||
sku.StoreSubID = activityId[0]
|
||||
//sku.StoreSubID = activityId[0]
|
||||
sku.StoreSubName = strings.Join(activityName, ",")
|
||||
}
|
||||
if sku.Weight == 0 {
|
||||
@@ -354,6 +354,9 @@ func (c *PurchaseHandler) onOrderMsg(orderStatus, orderId string, orderCallback
|
||||
utils.CallFuncAsync(func() {
|
||||
if msg.OrderStatus == tao_vegetable.OrderStatusPayFinsh {
|
||||
c.OnOrderDetail(orderMap, partner.CreatedPeration)
|
||||
if handler := partner.GetPurchaseOrderHandlerFromVendorID(model.VendorIDTaoVegetable); handler != nil {
|
||||
handler.AcceptOrRefuseOrder(order, true, "jxAdmin")
|
||||
}
|
||||
} else {
|
||||
c.OnOrderDetail(orderMap, partner.UpdatedPeration)
|
||||
}
|
||||
@@ -521,7 +524,7 @@ func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bo
|
||||
}
|
||||
if err2 == nil {
|
||||
c.postFakeMsg(order.VendorOrderID, tao_vegetable.OrderStatusPickedUp, tao_vegetable.OrderStatusPickedUp)
|
||||
break
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode, vendorOrderID, vendorStoreID s
|
||||
func (p *PurchaseHandler) GetOrderRider(vendorOrgCode, vendorStoreID string, param map[string]interface{}) (err error) {
|
||||
appKey := `7152420904331429407` // 暂时定死
|
||||
appSecret := `cc7ba367-2394-4cbb-81c6-26f0e929d1c6` //暂时定死
|
||||
return tiktokShop.NewExpress(appKey, appSecret, "").OrderStatusAndPsInfo(param)
|
||||
return tiktokShop.NewExpress(appKey, appSecret, "").OrderStatusAndPsInfoNew(param)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetOrder(vendorOrgCode, vendorOrderID, vendorStoreID string) (order *model.GoodsOrder, err error) {
|
||||
@@ -287,7 +287,6 @@ func (c *PurchaseHandler) onOrderMsg(msgId, orderId string, msg interface{}) (re
|
||||
//抖音运单处理
|
||||
if msgId == tiktokShop.CallbackShipmentInfoChange {
|
||||
//msgId-骑手运单号 orderId-抖音店铺ID msg-回调运单参数
|
||||
|
||||
return c.onWaybillMsg(msgId, orderId, msg)
|
||||
}
|
||||
// 待支付订单将不做处理/支付订单待处理(抖音风控)
|
||||
@@ -577,16 +576,15 @@ func (c *PurchaseHandler) CanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan
|
||||
// Swtich2SelfDeliver 抖音转自送的时候就是通知抖音发货了
|
||||
func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
||||
api := getAPI(order.VendorOrgCode, 0, "")
|
||||
remoteWaybill, err2 := c.GetDYPSRiderInfo(order.VendorOrderID)
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
if remoteWaybill.ShipmentStatus >= tiktokShop.ShipmentStatusArrived && remoteWaybill.ShipmentStatus != tiktokShop.ShipmentStatusCanceled { //骑手取货后不可取消
|
||||
return errors.New("抖音配送骑手已取货,不可转门店自配送/三方配送")
|
||||
}
|
||||
if len(remoteWaybill.TrackNo) != 0 { //存在运单
|
||||
if err := api.ShopOrderDispatcher(utils.Str2Int64(order.VendorStoreID), order.VendorOrderID, tiktokShop.DispatcherFeeTypeCancel); err != nil {
|
||||
return err
|
||||
remoteWaybill, _ := c.GetDYPSRiderInfo(order.VendorOrderID)
|
||||
if remoteWaybill != nil {
|
||||
if remoteWaybill.Status >= tiktokShop.ShipmentStatusArrived && remoteWaybill.Status != tiktokShop.ShipmentStatusCanceled { //骑手取货后不可取消
|
||||
return errors.New("抖音配送骑手已取货,不可转门店自配送/三方配送")
|
||||
}
|
||||
if remoteWaybill.Status < tiktokShop.ShipmentStatusArrived || remoteWaybill.Status == tiktokShop.ShipmentStatusCanceled { //存在运单
|
||||
if err := api.ShopOrderDispatcher(utils.Str2Int64(order.VendorStoreID), order.VendorOrderID, tiktokShop.DispatcherFeeTypeCancel); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -996,13 +994,13 @@ func (c *PurchaseHandler) OrderLogisticsStatus(orderId string) (data *utils.Ride
|
||||
}
|
||||
|
||||
result := &utils.RiderInfo{
|
||||
OrderId: utils.Int64ToStr(waybill.ShopOrderID),
|
||||
ThirdCarrierOrderId: waybill.TrackNo,
|
||||
OrderId: waybill.ShopOrderId,
|
||||
ThirdCarrierOrderId: waybill.ShopOrderId,
|
||||
CourierName: waybill.RiderName,
|
||||
CourierPhone: waybill.RiderPhone,
|
||||
LogisticsStatus: int(waybill.ShipmentStatus),
|
||||
Latitude: waybill.RiderLatitude,
|
||||
Longitude: waybill.RiderLongitude,
|
||||
LogisticsStatus: int(waybill.Status),
|
||||
Latitude: waybill.RiderLat,
|
||||
Longitude: waybill.RiderLng,
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package tiktok_store
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
instantShopping_getDeliveryListByOrderId_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/instantShopping_getDeliveryListByOrderId/response"
|
||||
|
||||
superm_getShipmentInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getShipmentInfo/response"
|
||||
superm_getStoreAutoCallRiderInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getStoreAutoCallRiderInfo/response"
|
||||
superm_setStoreAutoCallRider_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_setStoreAutoCallRider/request"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
@@ -55,22 +55,21 @@ func (c *PurchaseHandler) onWaybillMsg(tag, orderId string, data interface{}) *t
|
||||
func (c *PurchaseHandler) callbackMsg2Waybill(tag, orderId string, data interface{}) (retVal *model.Waybill) {
|
||||
req := data.(tiktok_api.ShipmentInfoData)
|
||||
tempRemark := ""
|
||||
if req.ShipmentStatus == tiktok_api.ShipmentStatusReceived {
|
||||
if req.Status == tiktok_api.ShipmentStatusReceived {
|
||||
tempRemark = req.RiderName + "," + req.RiderPhone
|
||||
}
|
||||
return &model.Waybill{
|
||||
VendorOrderID: utils.Int64ToStr(req.ShopOrderID),
|
||||
OrderVendorID: model.VendorIDDD,
|
||||
VendorWaybillID: req.TrackNo,
|
||||
VendorWaybillID: utils.Int64ToStr(req.ShopOrderID),
|
||||
WaybillVendorID: model.VendorIDDD,
|
||||
CourierName: req.RiderName,
|
||||
CourierMobile: req.RiderPhone,
|
||||
VendorStatus: utils.Int64ToStr(req.ShipmentStatus),
|
||||
Status: c.GetWaybillStatusFromVendorStatus(utils.Int64ToStr(req.ShipmentStatus)),
|
||||
StatusTime: utils.Str2Time(req.OccurredTime),
|
||||
//StatusTime: getTimeFromTimestamp(utils.Str2Int64(req.OccurredTime)),
|
||||
Remark: tempRemark,
|
||||
VendorOrgCode: utils.Int64ToStr(req.ShopID), //为抖音账号ID
|
||||
VendorStatus: utils.Int64ToStr(req.Status),
|
||||
Status: c.GetWaybillStatusFromVendorStatus(utils.Int64ToStr(req.Status)),
|
||||
StatusTime: utils.Str2Time(req.OperateTime),
|
||||
Remark: tempRemark,
|
||||
VendorOrgCode: utils.Int64ToStr(req.ShopID), //为抖音账号ID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +137,7 @@ func (c *PurchaseHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int,
|
||||
}
|
||||
|
||||
//查询运力状态
|
||||
func (c *PurchaseHandler) GetDYPSRiderInfo(orderId string) (*superm_getShipmentInfo_response.ShipmentInfo, error) {
|
||||
func (c *PurchaseHandler) GetDYPSRiderInfo(orderId string) (*instantShopping_getDeliveryListByOrderId_response.InstantShoppingGetDeliveryListByOrderIdData, error) {
|
||||
params := map[string]interface{}{
|
||||
"vendorOrderID": orderId,
|
||||
}
|
||||
@@ -146,9 +145,11 @@ func (c *PurchaseHandler) GetDYPSRiderInfo(orderId string) (*superm_getShipmentI
|
||||
if err != nil {
|
||||
return nil, errors.New("获取本地门店账号信息失败,请重试")
|
||||
}
|
||||
if waybill, err := getAPI(orderInfo[0].VendorOrgCode, 0, "").GetShipmentInfo(utils.Str2Int64(orderId), 0, tiktok_api.ShipmentTypeInvoice); err != nil {
|
||||
|
||||
waybill, err := getAPI(orderInfo[0].VendorOrgCode, 0, "").GetShipmentInfo(utils.Str2Int64(orderId), 0, tiktok_api.ShipmentTypeInvoice)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return waybill, nil
|
||||
}
|
||||
|
||||
return waybill, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user