This commit is contained in:
richboo111
2023-01-04 18:32:37 +08:00
parent 1bbebdb773
commit adad91cd52
9 changed files with 231 additions and 61 deletions

View File

@@ -6102,6 +6102,28 @@ func BatchCreateFreeShipTemplate(relInfo map[string][]tiktok_store.RelInfo, ship
return "", nil
}
//批量配置抖音门店自动呼叫运力
func SetStoreAutoCallRider(vendorOrgCode string, openIDs, closeIDs []int64) (string, error) {
var errList errlist.ErrList
if len(openIDs) > 0 {
for _, i := range openIDs {
if err := tiktok_store.SetStoreAutoCallRider(vendorOrgCode, tiktok_api.AutoCallRiderOpen, i); err != nil {
errList.AddErr(fmt.Errorf("%d", i))
}
}
}
if len(closeIDs) > 0 {
for _, j := range closeIDs {
if err := tiktok_store.SetStoreAutoCallRider(vendorOrgCode, tiktok_api.AutoCallRiderClose, j); err != nil {
errList.AddErr(fmt.Errorf("%d", j))
}
}
}
if errList.GetErrListAsOne() != nil {
return fmt.Sprintf("部分门店设置自动运力失败:%s", utils.Format4Output(errList.GetErrListAsOne(), false)), nil
}
return "", nil
}
func GetVendorStoreBind(vendorStoreId string, vendorId int) (int, error) {
return dao.GetCodeAndIDByMeiTuan(vendorStoreId, vendorId)
}

View File

@@ -338,6 +338,11 @@ const (
WaybillStatusDelivering = 20 // 配送中
WaybillStatusDeliverFailed = 22 // 配送中失败
//抖音配送专用
WaybillStatusRejected = 23 //收货人拒收
WaybillStatusReturning = 24 //返回中
WaybillStatusReturned = 25 //已返回
WaybillStatusEndBegin = 100 // 以下的状态就是结束状态
WaybillStatusDelivered = 105 // todo 这个应该改为110与订单对应
WaybillStatusCanceled = 115

View File

@@ -69,7 +69,7 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
if v.WaybillVendorID == model.VendorIDDada || v.WaybillVendorID == model.VendorIDFengNiao || v.WaybillVendorID == model.VendorIDDD {
riderInfo, err = handlerInfo.Handler.GetRiderInfo(v.VendorOrderID, 0, v.VendorWaybillID)
if err != nil {
globals.SugarLogger.Debug("Get Order waybill rider info err FN/DADA :%v", err)
globals.SugarLogger.Debug("Get Order waybill rider info err FN/DADA/DYPS :%v", err)
}
} else if v.WaybillVendorID == model.VendorIDMTPS {
if v.VendorWaybillID != "" {

View File

@@ -62,9 +62,6 @@ func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorSt
VendorStoreID: utils.Int64ToStr(storeInfo.StoreDetail.Store.StoreId),
CourierStatus: int(storeInfo.StoreDetail.Store.State),
}
globals.SugarLogger.Debugf("storeDetail.Store.Lng====%d,storeDetail.Store.Lat==========%d", storeDetail.Store.Lng, storeDetail.Store.Lat)
} else {
globals.SugarLogger.Debugf("GetStoreDetail err=========%s", err)
}
globals.SugarLogger.Debugf("DYPS GetStore storeDetail====%s", utils.Format4Output(storeDetail, false))
return storeDetail, err
@@ -101,7 +98,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
return nil, err
}
delivery.OnWaybillCreated(bill)
globals.SugarLogger.Debugf("DYPS CreateWaybill bill======%s", utils.Format4Output(bill, false))
return bill, nil
}
@@ -127,7 +123,6 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
if err != nil {
return nil, errors.New("获取抖音平台账号信息失败,请重试")
}
globals.SugarLogger.Debugf("relInfo.VendorStoreID======%s,order.VendorOrderID======%s", relInfo.VendorStoreID, order.VendorOrderID)
if dispatcherFee, err := getAPI(relInfo.VendorOrgCode).GetDispatcherInfo(utils.Str2Int64(relInfo.VendorStoreID), order.VendorOrderID, tiktok_api.DispatcherFeeTypeCall); err == nil {
deliveryFeeInfo = &partner.WaybillFeeInfo{}
deliveryFeeInfo.DeliveryFee = dispatcherFee
@@ -189,7 +184,6 @@ func CreateVirtualMobile(shopOrderID int64) (*superm_createVirtualMobile_respons
//订单状态回调
func OnWaybillMsg(tag, orderId string, data interface{}) (response *tiktok_api.CallbackResponse) {
req := data.(tiktok_api.ShipmentInfoData)
globals.SugarLogger.Debugf("DYPS OnWaybillMsg req============%s", utils.Format4Output(req, false))
param := &model.Waybill{
VendorOrderID: utils.Int64ToStr(req.ShopOrderID),
VendorWaybillID: req.TrackNo,
@@ -206,7 +200,6 @@ func OnWaybillMsg(tag, orderId string, data interface{}) (response *tiktok_api.C
param.StatusTime = time.Now()
}
dispatcherFee := getDispatcherFee(req.ShopID, utils.Int64ToStr(req.ShopOrderID), tiktok_api.DispatcherFeeTypeCall)
globals.SugarLogger.Debugf("DYPS OnWaybillMsg dispatcherFee=%d req.ShipmentStatus=%d", dispatcherFee, req.ShipmentStatus)
switch req.ShipmentStatus {
case tiktok_api.ShipmentStatusCalling: //1 骑手呼叫中
param.DesiredFee = dispatcherFee

View File

@@ -0,0 +1,80 @@
package uupt
const (
//errCode 错误码说明
ErrorParameter1 = -101 //参数格式校验错误
ErrorParameter2 = -199 //参数格式校验错误
ErrorTimestamp = -102 //timestamp错误
ErrorAppID = -103 //appid无效
ErrorSignatureCheck = -104 //签名校验失败
ErrorOpenIDInvalid = -105 //openid无效
ErrorUnableParseOrigin = -1001 //无法解析起始地
ErrorUnableParseDestination = -1002 //无法解析目的地
ErrorCantGetCityInformation = -1003 //无法获取订单城市相关信息
ErrorOrderCategory = -1004 //订单小类出现错误
ErrorNoUserInformation = -1005 //没有用户信息
ErrorCouponID = -1006 //优惠券ID错误
ErrorPriceToken1 = -2001 //price_token无效
ErrorPriceToken2 = -2002 //price_token无效
ErrorPushType = -2003 //push_type错误
ErrorSpecialType = -2004 //special_type错误
ErrorCallMeWithTake = -2005 //callMe_withTake错误
ErrorOrderPrice = -2006 //order_price错误
ErrorBalancePayMoney = -2007 //balance_payMoney错误
ErrorOrderTotalMoney = -2008 //订单总金额错误
ErrorPayMoney = -2009 //支付金额错误
ErrorUserNotMatch = -2010 //用户不一致
ErrorWrongPhone = -2011 //手机号错误
ErrorNotExistBind = -2012 //不存在绑定关系
ErrorCancelReasonCantEmpty = -4001 //取消原因不能为空
ErrorOrderNumber1 = -4002 //订单编号无效
ErrorOrderNumber2 = -5001 //订单编号无效
ErrorOrderNumber3 = -5002 //订单编号无效
ErrorOrderNumber4 = -5003 //订单编号无效
ErrorFrequencyTooFast = -10001 //发送频率过快,请稍候重试
ErrorNeedCommitVerificationCode = -106 //接口返回base64图片需要提交对应图片验证码
)
var ErrCode = map[int]string{
ErrorParameter1: "参数格式校验错误",
ErrorParameter2: "参数格式校验错误",
ErrorTimestamp: "timestamp错误",
ErrorAppID: "appid无效",
ErrorSignatureCheck: "签名校验失败",
ErrorOpenIDInvalid: "openid无效",
ErrorUnableParseOrigin: "无法解析起始地",
ErrorUnableParseDestination: "无法解析目的地",
ErrorCantGetCityInformation: "无法获取订单城市相关信息",
ErrorOrderCategory: "订单小类出现错误",
ErrorNoUserInformation: "没有用户信息",
ErrorCouponID: "优惠券ID错误",
ErrorPriceToken1: "price_token无效",
ErrorPriceToken2: "price_token无效",
ErrorPushType: "push_type错误",
ErrorSpecialType: "special_type错误",
ErrorCallMeWithTake: "callMe_withTake错误",
ErrorOrderPrice: "order_price错误",
ErrorBalancePayMoney: "balance_payMoney错误",
ErrorOrderTotalMoney: "订单总金额错误",
ErrorPayMoney: "支付金额错误",
ErrorUserNotMatch: "用户不一致",
ErrorWrongPhone: "手机号错误",
ErrorNotExistBind: "不存在绑定关系",
ErrorCancelReasonCantEmpty: "取消原因不能为空",
ErrorOrderNumber1: "订单编号无效",
ErrorOrderNumber2: "订单编号无效",
ErrorOrderNumber3: "订单编号无效",
ErrorOrderNumber4: "订单编号无效",
ErrorFrequencyTooFast: "发送频率过快,请稍候重试",
ErrorNeedCommitVerificationCode: "接口返回base64图片需要提交对应图片验证码",
}
var (
curDeliveryHandler *DeliveryHandler
)
type DeliveryHandler struct {
}
func init() {
//if api.
}

View File

@@ -8,7 +8,6 @@ import (
order_logisticsAdd_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_logisticsAdd/request"
order_orderDetail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response"
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
"git.rosy.net.cn/jx-callback/business/partner/delivery/tiktok_store"
"regexp"
"strings"
"time"
@@ -267,7 +266,7 @@ func (c *PurchaseHandler) onOrderMsg(msgId, orderId string, msg interface{}) (re
//抖音运单处理
if msgId == tiktokShop.CallbackShipmentInfoChange {
//msgId-骑手运单号 orderId-抖音店铺ID msg-回调运单参数
return tiktok_store.OnWaybillMsg(msgId, orderId, msg)
return c.onWaybillMsg(msgId, orderId, msg)
}
// 待支付订单将不做处理/支付订单待处理(抖音风控)
if msgId == tiktokShop.CallbackCreatedOrderMsgTagId || msgId == tiktokShop.CallbackWaitOrderMsgTagId {

View File

@@ -1,53 +1,96 @@
package tiktok_store
//
//var (
// VendorWaybillStatus2StatusMap = map[string]int{
// mtwmapi.WaybillStatusWait4Delivery: model.WaybillStatusNew,
// mtwmapi.WaybillStatusPending: model.WaybillStatusPending,
// mtwmapi.WaybillStatusAccepted: model.WaybillStatusAccepted,
// mtwmapi.WaybillStatusCourierArrived: model.WaybillStatusCourierArrived,
// mtwmapi.WaybillStatusPickedup: model.WaybillStatusDelivering,
// mtwmapi.WaybillStatusDelivered: model.WaybillStatusDelivered,
// mtwmapi.WaybillStatusCanceled: model.WaybillStatusCanceled,
// }
//)
//
//func (p *PurchaseHandler) GetWaybillStatusFromVendorStatus(vendorStatus string) int {
// if status, ok := VendorWaybillStatus2StatusMap[vendorStatus]; ok {
// return status
// }
// return model.WaybillStatusUnknown
//}
//
//func (c *PurchaseHandler) onWaybillMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) {
// waybill := c.callbackMsg2Waybill(msg)
// err := partner.CurOrderManager.OnWaybillStatusChanged(waybill)
// if err == nil && waybill.Status == model.WaybillStatusDelivering {
// c.postFakeMsg(waybill.VendorOrderID, FakeMsgType, mtwmapi.OrderStatusDelivering)
// }
// return mtwmapi.Err2CallbackResponse(err, "")
//}
//
//func (c *PurchaseHandler) callbackMsg2Waybill(msg *mtwmapi.CallbackMsg) (retVal *model.Waybill) {
// orderID := GetOrderIDFromMsg(msg)
// vendorStatus := msg.FormData.Get("logistics_status")
// retVal = &model.Waybill{
// VendorOrderID: orderID,
// OrderVendorID: model.VendorIDMTWM,
// VendorWaybillID: orderID,
// WaybillVendorID: model.VendorIDMTWM,
// CourierName: msg.FormData.Get("dispatcher_name"),
// CourierMobile: msg.FormData.Get("dispatcher_mobile"),
// VendorStatus: vendorStatus,
// Status: c.GetWaybillStatusFromVendorStatus(vendorStatus),
// StatusTime: getTimeFromTimestamp(utils.Str2Int64(msg.FormData.Get("time"))),
// Remark: "",
//
// VendorOrgCode: msg.AppID,
// }
// if retVal.StatusTime == utils.DefaultTimeValue {
// retVal.StatusTime = getTimeFromTimestamp(utils.Str2Int64(msg.FormData.Get("timestamp")))
// }
// return retVal
//}
import (
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"
"git.rosy.net.cn/baseapi/utils"
"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"
)
var (
VendorWaybillStatus2StatusMap = map[int]int{
tiktok_api.ShipmentStatusCalling: model.WaybillStatusNew,
tiktok_api.ShipmentStatusReceived: model.WaybillStatusAccepted,
tiktok_api.ShipmentStatusArrived: model.WaybillStatusCourierArrived,
tiktok_api.ShipmentStatusDelivering: model.WaybillStatusDelivering,
tiktok_api.ShipmentStatusRejected: model.WaybillStatusRejected,
tiktok_api.ShipmentStatusReturning: model.WaybillStatusReturning,
tiktok_api.ShipmentStatusReturned: model.WaybillStatusReturned,
tiktok_api.ShipmentStatusDelivered: model.WaybillStatusCanceled,
tiktok_api.ShipmentStatusCanceled: model.WaybillStatusDelivered,
}
)
func (p *PurchaseHandler) GetWaybillStatusFromVendorStatus(vendorStatus string) int {
if status, ok := VendorWaybillStatus2StatusMap[utils.Str2Int(vendorStatus)]; ok {
return status
}
return model.WaybillStatusUnknown
}
func (c *PurchaseHandler) onWaybillMsg(tag, orderId string, data interface{}) *tiktok_api.CallbackResponse {
waybill := c.callbackMsg2Waybill(tag, orderId, data)
if localOrder, _, err := dao.GetOrders(dao.GetDB(), nil, false, false, "", "", false, []int{0}, false, "",
map[string]interface{}{
"vendorOrderID": waybill.VendorOrderID,
}, 0, 0); err == nil {
err := partner.CurOrderManager.OnWaybillStatusChanged(waybill)
if err == nil && waybill.Status == model.WaybillStatusDelivering {
c.postFakeMsg(waybill.VendorOrderID, FakeMsgType, utils.Int2Str(tiktok_api.ShipmentStatusDelivering), localOrder[0].VendorStoreID)
}
return tiktok_api.Err2CallbackResponse(err, "")
}
return tiktok_api.Err2CallbackResponse(nil, "")
}
func (c *PurchaseHandler) callbackMsg2Waybill(tag, orderId string, data interface{}) (retVal *model.Waybill) {
req := data.(tiktok_api.ShipmentInfoData)
vendorOrgCode, _ := dao.GetStoreDetailForDD(dao.GetDB(), 0, model.VendorIDDD, utils.Int64ToStr(req.ShopID), "")
return &model.Waybill{
VendorOrderID: utils.Int64ToStr(req.ShopOrderID),
OrderVendorID: model.VendorIDDD,
VendorWaybillID: req.TrackNo,
WaybillVendorID: model.VendorIDDYPS,
CourierName: req.RiderName,
CourierMobile: req.RiderPhone,
VendorStatus: utils.Int64ToStr(req.ShipmentStatus),
Status: c.GetWaybillStatusFromVendorStatus(utils.Int64ToStr(req.ShipmentStatus)),
StatusTime: getTimeFromTimestamp(utils.Str2Int64(req.OccurredTime)),
Remark: "",
VendorOrgCode: vendorOrgCode.VendorOrgCode,
}
}
//设置自动呼叫运力
func SetStoreAutoCallRider(vendorOrgCode, opType string, storeID int64) error {
if opType == tiktok_api.AutoCallRiderOpen {
if err := getAPI(vendorOrgCode, 0, "").SetStoreAutoCallRider(&superm_setStoreAutoCallRider_request.SupermSetStoreAutoCallRiderParam{
StoreID: storeID,
OpType: opType,
ServiceType: tiktok_api.ServiceTypeDelayCall,
DelayTime: tiktok_api.AutoCallDelayTime15,
}); err != nil {
return err
}
} else {
if err := getAPI(vendorOrgCode, 0, "").SetStoreAutoCallRider(&superm_setStoreAutoCallRider_request.SupermSetStoreAutoCallRiderParam{
StoreID: storeID,
OpType: opType,
}); err != nil {
return err
}
}
return nil
}
//查询查询自动呼叫运力配置
func GetStoreAutoCallRiderInfo(vendorOrgCode string, storeID int64) (autoCallInfo *superm_getStoreAutoCallRiderInfo_response.AutoCallInfo, err error) {
if autoCallInfo, err = getAPI(vendorOrgCode, 0, "").GetStoreAutoCallRiderInfo(storeID); err != nil {
return nil, err
} else {
return autoCallInfo, err
}
}

View File

@@ -338,6 +338,11 @@ fnCode = "uDEyAmTbrfS2qjYbgi20Jm"
fnMerchantId= "51658"
fnCallbackURL = "http://callback.jxc4.com/fn/msg"
uuPtAppID="55c4542ae60e4d348edcfc93b06dd302"
uuPtAppKey="76b362c06b1b4baa9e47bab6387a5356"
uuPtOpenId="8d8464e7c9354c1e88a3f5afa2a7922e"
jxPrintAppID = "1000"
jxPrintAppKey = "rfBd56ti2SMtYvSg"

View File

@@ -1544,6 +1544,29 @@ func (c *StoreController) CreateFreeShipTemplates() {
})
}
// @Title 批量配置抖音门店自动呼叫运力
// @Description 批量配置抖音门店自动呼叫运力
// @Param token header string true "认证token"
// @Param vendorOrgCode formData string true "抖音总账号"
// @Param openIDs formData string true "开启自动运力门店,[]string对象"
// @Param closeIDs formData string true "关闭自动运力门店,[]string对象"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /SetStoreAutoCallRider [post]
func (c *StoreController) SetStoreAutoCallRider() {
c.callSetStoreAutoCallRider(func(params *tStoreSetStoreAutoCallRiderParams) (retVal interface{}, errCode string, err error) {
openIDs := make([]int64, 0)
closeIDs := make([]int64, 0)
if err1 := utils.UnmarshalUseNumber([]byte(params.OpenIDs), &openIDs); err1 == nil {
if err2 := utils.UnmarshalUseNumber([]byte(params.CloseIDs), &closeIDs); err2 == nil {
err = cms.SetStoreAutoCallRider(params.VendorOrgCode, openIDs, closeIDs)
return nil, "", err
}
}
return nil, "", nil
})
}
// @Title 打印机获取授权账号再京西菜市的绑定关系(其实就是根据平台门店id获取绑定门店id)
// @Description 打印机获取授权账号再京西菜市的绑定关系
// @Param token header string true "认证token"