UpdateOrderWaybillTip
This commit is contained in:
@@ -163,6 +163,19 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m
|
|||||||
isDuplicated, order, err := c.addOrderStatus(orderStatus, db)
|
isDuplicated, order, err := c.addOrderStatus(orderStatus, db)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
|
if orderStatus.Status == model.OrderStatusWaybillTipChanged {
|
||||||
|
if handler := partner.GetWaybillTipUpdater(orderStatus.RefVendorID); handler != nil {
|
||||||
|
tipFee, err2 := handler.GetWaybillTip(jxcontext.AdminCtx, vendorOrgCode, orderStatus.RefVendorOrderID, orderStatus.VendorOrderID, "")
|
||||||
|
if err2 == nil {
|
||||||
|
c.UpdateOrderFields(&model.GoodsOrder{
|
||||||
|
VendorOrderID: orderStatus.RefVendorOrderID,
|
||||||
|
VendorID: orderStatus.RefVendorID,
|
||||||
|
VendorOrgCode: vendorOrgCode,
|
||||||
|
WaybillTipMoney: tipFee,
|
||||||
|
}, []string{"WaybillTipMoney"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if !isDuplicated {
|
if !isDuplicated {
|
||||||
if order != nil {
|
if order != nil {
|
||||||
order.Skus = c.loadOrderSku(db, order.VendorOrderID, order.VendorID)
|
order.Skus = c.loadOrderSku(db, order.VendorOrderID, order.VendorID)
|
||||||
|
|||||||
@@ -236,6 +236,61 @@ func (c *BaseScheduler) ConfirmSelfTake(ctx *jxcontext.Context, vendorOrderID st
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *BaseScheduler) SetOrderWaybillTip(ctx *jxcontext.Context, vendorOrderID string, vendorID int, tipFee int64) (err error) {
|
||||||
|
order, err2 := partner.CurOrderManager.LoadOrder(vendorOrderID, vendorID)
|
||||||
|
if err = err2; err == nil {
|
||||||
|
err = c.SetOrderWaybillTipByOrder(ctx, order, tipFee)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func isWaybillCanAddTip(waybill *model.Waybill) (isCan bool) {
|
||||||
|
isCan = waybill.Status >= model.WaybillStatusNew && waybill.Status < model.WaybillStatusAccepted && partner.GetWaybillTipUpdater(waybill.WaybillVendorID) != nil
|
||||||
|
return isCan
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (err error) {
|
||||||
|
roundTipFee := tipFee / 100 * 100
|
||||||
|
if roundTipFee != tipFee {
|
||||||
|
return fmt.Errorf("小费必须是元的整数倍")
|
||||||
|
}
|
||||||
|
if order.WaybillTipMoney >= tipFee {
|
||||||
|
return fmt.Errorf("当前小费已经是%s元,想要设置%s元", jxutils.IntPrice2StandardString(roundTipFee), jxutils.IntPrice2StandardString(tipFee))
|
||||||
|
}
|
||||||
|
order.WaybillTipMoney = roundTipFee
|
||||||
|
partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney"})
|
||||||
|
|
||||||
|
db := dao.GetDB()
|
||||||
|
waybills, err := dao.GetWayBillByOrderID(db, 0, order.VendorID, 0, order.VendorOrderID)
|
||||||
|
if err == nil {
|
||||||
|
var waybills2 []*model.Waybill
|
||||||
|
for _, v := range waybills {
|
||||||
|
if isWaybillCanAddTip(v) {
|
||||||
|
waybills2 = append(waybills2, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(waybills2) > 0 {
|
||||||
|
task := tasksch.NewParallelTask("setOrderWaybillTip", nil, ctx,
|
||||||
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
waybill := batchItemList[0].(*model.Waybill)
|
||||||
|
handler := partner.GetWaybillTipUpdater(waybill.WaybillVendorID)
|
||||||
|
curTipFee, err := handler.GetWaybillTip(ctx, waybill.VendorOrgCode, waybill.VendorOrderID, waybill.VendorWaybillID, waybill.VendorWaybillID2)
|
||||||
|
if err == nil {
|
||||||
|
tip2Add := order.WaybillTipMoney - curTipFee
|
||||||
|
storeDetail, err2 := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID)
|
||||||
|
if err = err2; err == nil {
|
||||||
|
err = handler.AddWaybillTip(ctx, waybill.VendorOrgCode, waybill.VendorOrderID, waybill.VendorWaybillID, waybill.VendorWaybillID2, utils.Int2Str(storeDetail.CityCode), tip2Add)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}, waybills2)
|
||||||
|
tasksch.HandleTask(task, nil, false).Run()
|
||||||
|
_, err = task.GetResult(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (c *BaseScheduler) confirmSelfTake(ctx *jxcontext.Context, order *model.GoodsOrder, selfTakeCode string) (err error) {
|
func (c *BaseScheduler) confirmSelfTake(ctx *jxcontext.Context, order *model.GoodsOrder, selfTakeCode string) (err error) {
|
||||||
globals.SugarLogger.Debugf("confirmSelfTake orderID:%s, selfTakeCode:%s", order.VendorOrderID, selfTakeCode)
|
globals.SugarLogger.Debugf("confirmSelfTake orderID:%s, selfTakeCode:%s", order.VendorOrderID, selfTakeCode)
|
||||||
if order.VendorID == model.VendorIDJD {
|
if order.VendorID == model.VendorIDJD {
|
||||||
|
|||||||
@@ -1191,6 +1191,23 @@ func (s *DefScheduler) watchOrderWaybills(savedOrderInfo *WatchOrderInfo) {
|
|||||||
savedOrderInfo.SetOrder(order)
|
savedOrderInfo.SetOrder(order)
|
||||||
if isNeedWatch3rdWaybill(order) {
|
if isNeedWatch3rdWaybill(order) {
|
||||||
if isNeedWatchWaybillTip(order) {
|
if isNeedWatchWaybillTip(order) {
|
||||||
|
// tipFee := getWaybillTip(order)
|
||||||
|
// if tipFee > order.WaybillTipMoney {
|
||||||
|
// vendorStatus := fmt.Sprintf("应设置小费:%s", jxutils.IntPrice2StandardCurrencyString(tipFee))
|
||||||
|
// remark := ""
|
||||||
|
// if false {
|
||||||
|
// err = s.SetOrderWaybillTipByOrder(jxcontext.AdminCtx, order, tipFee)
|
||||||
|
// if err == nil {
|
||||||
|
// vendorStatus += "成功"
|
||||||
|
// } else {
|
||||||
|
// vendorStatus += "失败"
|
||||||
|
// remark = fmt.Sprint(err)
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// vendorStatus += "空操作"
|
||||||
|
// }
|
||||||
|
// partner.CurOrderManager.OnOrderMsg(order, vendorStatus, remark)
|
||||||
|
// }
|
||||||
if handler, ok := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).(partner.IAddWaybillTip); ok && handler != nil {
|
if handler, ok := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).(partner.IAddWaybillTip); ok && handler != nil {
|
||||||
var remark string
|
var remark string
|
||||||
tipFee := getWaybillTip(order)
|
tipFee := getWaybillTip(order)
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ const (
|
|||||||
const (
|
const (
|
||||||
OrderStatusMsg = -100
|
OrderStatusMsg = -100
|
||||||
|
|
||||||
|
OrderStatusWaybillTipChanged = -80 // 订单小费变化
|
||||||
|
|
||||||
OrderStatusRefuseFailedGetGoods = -70 // 取货失败审核驳回
|
OrderStatusRefuseFailedGetGoods = -70 // 取货失败审核驳回
|
||||||
OrderStatusAdjust = -65 // 原值-35 订单调整完成
|
OrderStatusAdjust = -65 // 原值-35 订单调整完成
|
||||||
OrderStatusApplyUrgeOrder = -55 // 原值-15
|
OrderStatusApplyUrgeOrder = -55 // 原值-15
|
||||||
|
|||||||
@@ -287,3 +287,13 @@ func GetRidderPositionGetter(vendorID int) (handler IRidderPositionGetter) {
|
|||||||
handler, _ = GetPurchasePlatformFromVendorID(vendorID).(IRidderPositionGetter)
|
handler, _ = GetPurchasePlatformFromVendorID(vendorID).(IRidderPositionGetter)
|
||||||
return handler
|
return handler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetWaybillTipUpdater(vendorID int) (handler IAddWaybillTip) {
|
||||||
|
if handlerInfo := GetDeliveryPlatformFromVendorID(vendorID); handlerInfo != nil {
|
||||||
|
if handler, _ = handlerInfo.Handler.(IAddWaybillTip); handler != nil {
|
||||||
|
return handler
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handler, _ = GetPurchasePlatformFromVendorID(vendorID).(IAddWaybillTip)
|
||||||
|
return handler
|
||||||
|
}
|
||||||
|
|||||||
@@ -660,3 +660,23 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, vendorOrgCode strin
|
|||||||
}
|
}
|
||||||
return vendorOrderIDs, err
|
return vendorOrderIDs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
|
||||||
|
orderInfo, err := api.EbaiAPI.GetStoreOrderInfo(vendorOrderID)
|
||||||
|
if err == nil {
|
||||||
|
if orderBasic, _ := orderInfo["order_basic"].(map[string]interface{}); orderBasic != nil {
|
||||||
|
tipFee = jxutils.StandardPrice2Int(utils.Interface2Float64WithDefault(orderBasic["delivery_tip_amount"], 0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tipFee, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee2Add int64) (err error) {
|
||||||
|
tipFee, err := c.GetWaybillTip(ctx, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2)
|
||||||
|
if err == nil {
|
||||||
|
if globals.EnableEbaiStoreWrite {
|
||||||
|
err = api.EbaiAPI.ModifyTip4OrderWaybill(vendorOrderID, "", jxutils.IntPrice2Standard(tipFee), 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ var (
|
|||||||
|
|
||||||
jdapi.OrderStatusVenderAgreeCancel: model.OrderStatusVendorAgreeCancel,
|
jdapi.OrderStatusVenderAgreeCancel: model.OrderStatusVendorAgreeCancel,
|
||||||
jdapi.OrderStatusVenderRejectCancel: model.OrderStatusVendorRejectCancel,
|
jdapi.OrderStatusVenderRejectCancel: model.OrderStatusVendorRejectCancel,
|
||||||
|
jdapi.CallbackMsgOrderAddTips: model.OrderStatusWaybillTipChanged,
|
||||||
}
|
}
|
||||||
deliveryTypeMap = map[int]string{
|
deliveryTypeMap = map[int]string{
|
||||||
jdapi.CarrierNoCrowdSourcing: model.OrderDeliveryTypePlatform,
|
jdapi.CarrierNoCrowdSourcing: model.OrderDeliveryTypePlatform,
|
||||||
@@ -286,10 +287,13 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *jdapi.CallbackOrderMsg) *model
|
|||||||
RefVendorOrderID: msg.BillID,
|
RefVendorOrderID: msg.BillID,
|
||||||
RefVendorID: model.VendorIDJD,
|
RefVendorID: model.VendorIDJD,
|
||||||
VendorStatus: msg.StatusID,
|
VendorStatus: msg.StatusID,
|
||||||
Status: c.getStatusFromVendorStatus(msg.StatusID),
|
|
||||||
StatusTime: utils.Str2Time(msg.Timestamp),
|
StatusTime: utils.Str2Time(msg.Timestamp),
|
||||||
Remark: msg.Remark,
|
Remark: msg.Remark,
|
||||||
}
|
}
|
||||||
|
if msg.MsgURL == jdapi.CallbackMsgOrderAddTips {
|
||||||
|
orderStatus.VendorStatus = jdapi.CallbackMsgOrderAddTips
|
||||||
|
}
|
||||||
|
orderStatus.Status = c.getStatusFromVendorStatus(orderStatus.VendorStatus)
|
||||||
return orderStatus
|
return orderStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -212,3 +212,7 @@ func (c *DjswController) nullOperation() {
|
|||||||
func (c *DjswController) UpdateSku() {
|
func (c *DjswController) UpdateSku() {
|
||||||
c.nullOperation()
|
c.nullOperation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *DjswController) OrderAddTips() {
|
||||||
|
c.orderStatus()
|
||||||
|
}
|
||||||
|
|||||||
@@ -231,6 +231,22 @@ func (c *OrderController) GetOrderWaybillInfo() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 补全遗漏的订单
|
||||||
|
// @Description 补全遗漏的订单
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param vendorOrderID formData string true "订单ID"
|
||||||
|
// @Param vendorID formData int true "订单所属的厂商ID"
|
||||||
|
// @Param tipFee formData int true "小费"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /UpdateOrderWaybillTip [post]
|
||||||
|
func (c *OrderController) UpdateOrderWaybillTip() {
|
||||||
|
c.callUpdateOrderWaybillTip(func(params *tOrderUpdateOrderWaybillTipParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
err = defsch.FixedScheduler.SetOrderWaybillTip(params.Ctx, params.VendorOrderID, params.VendorID, int64(params.TipFee))
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// @Title 导出美团运单
|
// @Title 导出美团运单
|
||||||
// @Description 导出美团运单(excel文件),注意时间跨度不要太长,最多只能是一个月
|
// @Description 导出美团运单(excel文件),注意时间跨度不要太长,最多只能是一个月
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
|||||||
@@ -1071,6 +1071,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "UpdateOrderWaybillTip",
|
||||||
|
Router: `/UpdateOrderWaybillTip`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "PriceRefer",
|
Method: "PriceRefer",
|
||||||
|
|||||||
Reference in New Issue
Block a user