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

This commit is contained in:
richboo111
2023-10-19 17:44:43 +08:00
17 changed files with 57 additions and 62 deletions

View File

@@ -260,11 +260,11 @@ func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, waybillVendorI
if len(wayBillList) != model.YES {
return fmt.Errorf("订单所属运单不存在,或运单为分配骑手,无法投诉")
}
p := partner.GetDeliveryPlatformFromVendorID(wayBillList[0].WaybillVendorID).Handler
if err == nil && len(wayBillList) > 0 {
for _, v := range wayBillList {
if utils.Int2Str(v.WaybillVendorID) == waybillVendorID {
err = p.ComplaintRider(wayBillList[0], complaintID, complaintReasonsMap[complaintID])
p := partner.GetDeliveryPlatformFromVendorID(wayBillList[0].WaybillVendorID).Handler
err = p.ComplaintRider(v, complaintID, complaintReasonsMap[complaintID])
}
}
}

View File

@@ -142,7 +142,7 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName
localBill, _ := partner.CurOrderManager.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID)
// 获取抖音配送状态
tiktokWayBillStatus, _ := partner.GetPurchasePlatformFromVendorID(order.VendorID).OrderLogisticsStatus(order.VendorOrderID)
if tiktokWayBillStatus != nil && tiktokWayBillStatus.LogisticsStatus >= tiktokShop.ShipmentStatusReceived {
if tiktokWayBillStatus != nil && tiktokWayBillStatus.LogisticsStatus >= tiktokShop.ShipmentStatusReceived && tiktokWayBillStatus.LogisticsStatus != tiktokShop.ShipmentStatusCanceled {
//取消抖音配送转自送
err = c.CancelWaybill(localBill, partner.CancelWaybillReasonDYPSCancel, partner.CancelWaybillReasonStrDYPSCancel+"抖音骑手已经接单,无法取消")
partner.CurOrderManager.OnOrderMsg(order, "取消抖音配送,转用门店自配送/三方配送", "抖音骑手已经接单,无法取消")

View File

@@ -48,7 +48,7 @@ func (s *DefScheduler) OnAfsOrderNew(order *model.AfsOrder, isPending bool) (err
// 京西云打印机打印数据-如果门店使用京西打印机才使用如下代码块
store, err := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode)
if err == nil && store.PrinterVendorID == model.VendorIDJxprint {
if err == nil && store.PrinterVendorID == model.VendorIDJxprint && store.IsPrintCancelOrder == model.YES {
if handler := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID); handler != nil {
orderObj, err2 := handler.GetOrder(order.VendorOrgCode, order.VendorOrderID, "")
if err2 != nil {

View File

@@ -470,7 +470,6 @@ func (s *DefScheduler) QueryOrderWaybillFeeInfoEx(ctx *jxcontext.Context, vendor
if order.DeliveryType == model.OrderDeliveryTypeSelfTake {
return nil, fmt.Errorf("订单:%s是自提单", vendorOrderID)
}
// 获取用户送货地址
storeCourierList, err := dao.GetStoreCourierList(db, []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, model.StoreStatusAll, model.StoreAuditStatusOnline)
if err != nil {
@@ -508,7 +507,8 @@ func (s *DefScheduler) QueryOrderWaybillFeeInfoEx(ctx *jxcontext.Context, vendor
if handler := partner.GetDeliveryPlatformFromVendorID(storeCourier.VendorID); handler != nil {
if handler.Use4CreateWaybill {
// 获取订单配送费用
if feeInfo, err = handler.Handler.GetWaybillFee(order); err != nil {
feeInfo, err = handler.Handler.GetWaybillFee(order)
if err != nil {
feeInfo = &partner.WaybillFeeInfo{
ErrCode: partner.WaybillFeeErrCodeCourierOthers,
ErrStr: err.Error(),

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"git.rosy.net.cn/baseapi/platformapi/autonavi"
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
"git.rosy.net.cn/jx-callback/globals"
"math"
"reflect"
"regexp"
@@ -681,6 +682,7 @@ func GetSToURidingDistance2(sLng, sLat, uLng, uLat float64, orderId string) (way
}
}
}
globals.SugarLogger.Debugf("=======================1")
// 当这个运单为假物流/门店真实自送/获取运单骑手信息为空的时候使用假的骑手信息
if (v.WaybillVendorID == model.VendorJXFakeWL || v.WaybillVendorID == model.VendorIDUnknown || v.CourierCoordinate == "") && v.OriginalData != "" {
@@ -750,26 +752,5 @@ func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, dist
polyLineList = append(polyLineList, strings.Split(v.Path, ";")...)
}
// 高德()免费次数太少暂时不用
//for {
// polyLineList, distance, duration, errCode = api.AutonaviAPI.GetCyclingPlan(origin, destination)
// if errCode != nil {
// ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "获取骑行路线:", utils.Format4Output(errCode, false))
// }
// if errCode != nil && (errCode.Error() == autonavi.DAILYQUERYOVERLIMIT || errCode.Error() == autonavi.USERDAILYQUERYOVERLIMIT) {
// AutonaviKeyIndex += model.YES
// if AutonaviKeyIndex >= len(AutonaviKeyList) {
// AutonaviKeyIndex = model.NO
// }
// api.AutonaviAPI.SetKey(AutonaviKeyList[AutonaviKeyIndex])
// } else if errCode != nil {
// return nil, 0, 0, errCode
// }
//
// if len(polyLineList) > model.NO {
// return polyLineList, distance, duration, errCode
// }
//}
return
}

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"git.rosy.net.cn/jx-callback/globals"
beego "github.com/astaxie/beego/server/web"
"time"
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
@@ -12,7 +13,6 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner"
)
// CopyOnStoreSkuToOther 将一个美团门店分类和商品复制到另一个门店
@@ -26,15 +26,18 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId
if err != nil {
return "", err
}
toApi := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, toStore.VendorOrgCode).(*mtwmapi.API)
//firstApi := api.Mtwm2API
toApi := mtwmapi.New(beego.AppConfig.DefaultString("mtwmAppID2", ""), beego.AppConfig.DefaultString("mtwmSecret2", ""), beego.AppConfig.DefaultString("mtwmCallbackURL2", ""), "")
toApi.SetToken(toStore.MtwmToken)
fromStore, err := dao.GetStoreDetailByVendorStoreID(db, utils.Int2Str(fromVendorStoreId), model.VendorIDMTWM, "")
if err != nil {
return "", err
}
fromApi := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, fromStore.VendorOrgCode).(*mtwmapi.API)
fromApi := mtwmapi.New(beego.AppConfig.DefaultString("mtwmAppID2", ""), beego.AppConfig.DefaultString("mtwmSecret2", ""), beego.AppConfig.DefaultString("mtwmCallbackURL2", ""), "")
fromApi.SetToken(fromStore.MtwmToken)
//fromApi := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, fromStore.VendorOrgCode).(*mtwmapi.API)
//fromApi.SetToken(fromStore.MtwmToken)
taskName := fmt.Sprintf("将平台门店[%d],分类和商品复制到[%d]", fromVendorStoreId, toStoreId)
config := tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(false)
@@ -49,8 +52,9 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId
//}
case 2:
// 同步分类
//fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId))
//
//fromCategoryList, err := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId))
//globals.SugarLogger.Debugf("fromCategoryList ============ %d", len(fromCategoryList))
//globals.SugarLogger.Debugf("err ============ %v", err)
//for _, v := range fromCategoryList {
// categoryErr := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
// CategoryCode: v.Code,
@@ -84,7 +88,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId
return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i)
}
if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil {
if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID, i); err != nil {
globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false))
}
if len(fromFoodList) < 100 {
@@ -158,7 +162,7 @@ type Skus struct {
}
// BatchInitData 批量创建商品
func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error {
func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string, i int) error {
foodDataList := make([]map[string]interface{}, len(fromSku))
for i, storeSku := range fromSku {
foodData := make(map[string]interface{})
@@ -238,7 +242,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt
if i == count-1 {
failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:])
if err2 != nil {
globals.SugarLogger.Debugf("RetailBatchInitData err3 :%s", utils.Format4Output(err2, false))
globals.SugarLogger.Debugf("RetailBatchInitData err3 :%v", err2)
}
if len(failedFoodList) != 0 {
globals.SugarLogger.Debugf("RetailBatchInitData err4 :%s", utils.Format4Output(failedFoodList, false))
@@ -246,7 +250,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt
} else {
failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:(i+1)*10])
if err2 != nil {
globals.SugarLogger.Debugf("RetailBatchInitData err3 :%s", utils.Format4Output(err2, false))
globals.SugarLogger.Debugf("RetailBatchInitData err3 :%v", err2)
}
if len(failedFoodList) != 0 {
globals.SugarLogger.Debugf("RetailBatchInitData err4 :%s", utils.Format4Output(failedFoodList, false))

View File

@@ -2,7 +2,6 @@ package misc
import (
"fmt"
"git.rosy.net.cn/jx-callback/business/jxcallback/auto_delivery"
"sync"
"time"
@@ -217,10 +216,10 @@ func Init() {
}, 10*time.Second, 5*time.Minute)
// (自动发单拣货,设置骑手) 刷单用
ScheduleTimerFuncByInterval(func() {
auto_delivery.Init() // 初始化骑手列表
auto_delivery.AutoSettingFakeDelivery()
}, 10*time.Second, 5*time.Minute)
//ScheduleTimerFuncByInterval(func() {
// auto_delivery.Init() // 初始化骑手列表
// auto_delivery.AutoSettingFakeDelivery()
//}, 10*time.Second, 5*time.Minute)
// 定时任务更新负责人信息
ScheduleTimerFunc("RefreshStoreOperator", func() {

View File

@@ -19,12 +19,12 @@ var enterpriseUserIdMap = map[string]string{
"18981810340": "LiuLei",
"187447 76542": "WuTingQi",
"17358644830": "ShengTianBanZi1376",
"15729837802": "ZhangShuWei",
"1": "2f43b42fd833d1e77420a8dae7419000", // 未设置号码
"15928865396": "HeJiaMeng2",
"18780171617": "TianQinXin",
"17381914617": "TianQinXin2",
"15881105234": "WenShiQi",
"17342535201": "XuXiaox",
}
// SendUserMessage 发送文本卡片

View File

@@ -106,7 +106,6 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
if orderId == "" { // 订单id为空是,是定时轮询操作,不做此状态
waybillList, _ := dao.GetWaybills(dao.GetDB(), v.VendorOrderID, nil)
if len(waybillList) > 0 && waybillList[0].Status > model.WaybillStatusEndBegin {
globals.SugarLogger.Debug("订单物流状态结束,不在推送订单状态:orderID[%s],wayBillId[%s]", v.VendorOrderID, waybillList[0].VendorWaybillID)
continue
}
}
@@ -330,6 +329,7 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *utils.RiderInfo) {
if err != nil {
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "百度地图骑行方案获取错误:", utils.Format4Output(err.Error(), false))
}
courierCoordinate := strings.Split(waybill2.CourierCoordinate, ",")
if len(courierCoordinate) < 2 && fakeWayBill.Status < model.WaybillStatusDelivered {
courierCoordinate = append(courierCoordinate, utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng)), utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat)))
@@ -400,6 +400,7 @@ func UpdateFakeWayBillToTiktok() {
//if randTimeSchedule > 500 {
// return
//}
globals.SugarLogger.Debugf("===================fakeWayBill := %s", "开始")
fakeWayBill, err := dao.GetWayBillFakeOrder()
if err != nil {
@@ -416,6 +417,7 @@ func UpdateFakeWayBillToTiktok() {
continue
}
globals.SugarLogger.Debugf("===================fakeWayBill := %s", fakeWayBill[i].VendorOrderID)
riderInfo := &utils.RiderInfo{
OrderId: fakeWayBill[i].VendorOrderID,
ThirdCarrierOrderId: fakeWayBill[i].VendorOrderID,
@@ -427,6 +429,7 @@ 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
@@ -444,6 +447,7 @@ 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 {

View File

@@ -5,6 +5,8 @@ import (
"encoding/json"
"errors"
"fmt"
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
"strings"
"time"
@@ -175,6 +177,7 @@ 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 {

View File

@@ -5,7 +5,6 @@ import (
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals/api"
@@ -49,15 +48,15 @@ func (c *PurchaseHandler) onWaybillMsg(msg *ebaiapi.CallbackMsg) (retVal *ebaiap
order.CourierMobile = utils.Interface2String(result["phone"])
}
if order.Status == model.WaybillStatusNew {
order2, _ := partner.CurOrderManager.LoadOrder(order.VendorOrderID, order.WaybillVendorID)
if order2 != nil {
if order2.Status == model.OrderStatusWaitAccepted {
order2.Status = model.OrderStatusNew
scheduler.CurrentScheduler.OnOrderNew(order2, false, false)
}
}
}
//if order.Status == model.WaybillStatusNew {
// order2, _ := partner.CurOrderManager.LoadOrder(order.VendorOrderID, order.WaybillVendorID)
// if order2 != nil {
// if order2.Status == model.OrderStatusWaitAccepted {
// order2.Status = model.OrderStatusNew
// scheduler.CurrentScheduler.OnOrderNew(order2, false, false)
// }
// }
//}
} else if order.Status == model.WaybillStatusCanceled {
utils.AfterFuncWithRecover(timeout4WaybillCancel, func() {
if localOrder, err2 := partner.CurOrderManager.LoadOrder(order.VendorOrderID, model.VendorIDEBAI); err2 == nil {

View File

@@ -13,7 +13,7 @@ import (
// OnCallbackMsg 淘宝回调接口
func OnCallbackMsg(orderStatus, orderId string, msg interface{}) (response *tao_vegetable.CallBackResult) {
if CurPurchaseHandler != nil {
jxutils.CallMsgHandler(func() {
jxutils.CallMsgHandlerAsync(func() {
response = CurPurchaseHandler.onOrderMsg(orderStatus, orderId, msg)
}, jxutils.ComposeUniversalOrderID(orderId, model.VendorIDTaoVegetable))
}

View File

@@ -112,8 +112,8 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode string, vendorOrderID int64, ve
StoreSubName: "",
Count: utils.Float64TwoInt(*extra.BuySaleQuantity),
VendorSkuID: *extra.SkuCode,
SkuID: utils.Str2Int(*extra.SkuCode),
JxSkuID: utils.Str2Int(*extra.SkuCode),
SkuID: 0,
JxSkuID: 0,
SkuName: *extra.SkuName,
ShopPrice: *extra.Price,
VendorPrice: *extra.OriginalFee / utils.Float64TwoInt64(*extra.BuySaleQuantity),
@@ -126,7 +126,11 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode string, vendorOrderID int64, ve
IsVendorAct: 0,
Upc: *extra.Barcode,
}
// extra.SkuCode 为int类型会超出长度,有时商品为平台创建
if len(*extra.SkuCode) <= 10 {
sku.SkuID = utils.Str2Int(*extra.SkuCode)
sku.JxSkuID = utils.Str2Int(*extra.SkuCode)
}
activityId := make([]int64, 0)
activityName := make([]string, 0)
if extra.Activitys != nil {

View File

@@ -581,7 +581,7 @@ func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName s
if err2 != nil {
return err2
}
if remoteWaybill.ShipmentStatus >= tiktokShop.ShipmentStatusArrived { //骑手取货后不可取消
if remoteWaybill.ShipmentStatus >= tiktokShop.ShipmentStatusArrived && remoteWaybill.ShipmentStatus != tiktokShop.ShipmentStatusCanceled { //骑手取货后不可取消
return errors.New("抖音配送骑手已取货,不可转门店自配送/三方配送")
}
if len(remoteWaybill.TrackNo) != 0 { //存在运单

View File

@@ -20,7 +20,9 @@ func (c *MtwmController) onCallbackMsg(msgType string) {
callbackResponse = mtwmapi.Err2CallbackResponse(nil, "")
}
}
c.Data["json"] = callbackResponse
c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "")
//c.Data["json"] = callbackResponse
c.ServeJSON()
}

View File

@@ -46,7 +46,7 @@ func (c *TaoBaoVegetableController) GetCode() {
// 创建或者更新账号token
param := &model.VendorOrgCode{
VendorID: model.VendorIDTaoVegetable,
VendorOrgCode: api.TaoVegetableApi.GetVendorOrgCode(),
VendorOrgCode: tokenInfo.UserId,
Comment: tokenInfo.UserNick,
VendorType: "platform",
IsJxCat: 1,

View File

@@ -82,12 +82,11 @@ func (a *APIManager) GetAPI(vendorID int, appOrgCode string) (pfAPI interface{})
}
if tokenInfo.AccessToken != "" && tokenInfo.ExpireTime > time.Now().UnixNano()/1e6 {
api2.SetToken(tokenInfo.AccessToken)
api2.SetVendorOrgCode(code.VendorOrgCode)
} else {
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "淘鲜达token过期", ",请重新授权")
}
}
api.TaoVegetableApi = api2
pfAPI = api2
case model.VendorIDEBAI:
pfAPI = api.EbaiAPI