Merge remote-tracking branch 'origin/mark' into yonghui
This commit is contained in:
@@ -163,6 +163,17 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m
|
||||
isDuplicated, order, err := c.addOrderStatus(orderStatus, db)
|
||||
if err == nil {
|
||||
dao.Commit(db)
|
||||
if orderStatus.Status == model.OrderStatusWaybillTipChanged {
|
||||
if order, err2 := c.LoadOrder(orderStatus.VendorOrderID, orderStatus.VendorID); err2 == nil {
|
||||
if handler := partner.GetWaybillTipUpdater(orderStatus.RefVendorID); handler != nil {
|
||||
tipFee, err2 := handler.GetWaybillTip(jxcontext.AdminCtx, vendorOrgCode, order.VendorStoreID, orderStatus.RefVendorOrderID, orderStatus.VendorOrderID, "")
|
||||
if err2 == nil {
|
||||
order.WaybillTipMoney = tipFee
|
||||
c.UpdateOrderFields(order, []string{"WaybillTipMoney"})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !isDuplicated {
|
||||
if order != nil {
|
||||
order.Skus = c.loadOrderSku(db, order.VendorOrderID, order.VendorID)
|
||||
|
||||
@@ -236,6 +236,69 @@ func (c *BaseScheduler) ConfirmSelfTake(ctx *jxcontext.Context, vendorOrderID st
|
||||
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("小费必须是1元的整数倍")
|
||||
}
|
||||
if order.WaybillTipMoney >= tipFee {
|
||||
return fmt.Errorf("当前小费已经是%s元,想要设置%s元", jxutils.IntPrice2StandardString(order.WaybillTipMoney), jxutils.IntPrice2StandardString(tipFee))
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
storeDetail, err2 := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID)
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 如果平台支持设置配送小费,必须要成功设置
|
||||
if handler := partner.GetWaybillTipUpdater(order.VendorID); handler != nil {
|
||||
if err = handler.UpdateWaybillTip(ctx, order.VendorOrgCode, order.VendorStoreID, order.VendorOrderID, "", "", utils.Int2Str(storeDetail.CityCode), tipFee); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
order.WaybillTipMoney = tipFee
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney"})
|
||||
|
||||
waybills, err := dao.GetWayBillByOrderID(db, 0, order.VendorID, 0, order.VendorOrderID)
|
||||
if err == nil {
|
||||
var waybills2 []*model.Waybill
|
||||
for _, v := range waybills {
|
||||
// 必须是三方配送
|
||||
if !model.IsWaybillPlatformOwn(v) && isWaybillCanAddTip(v) {
|
||||
waybills2 = append(waybills2, v)
|
||||
}
|
||||
}
|
||||
if len(waybills2) > 0 {
|
||||
task := tasksch.NewParallelTask("SetOrderWaybillTipByOrder", nil, ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
waybill := batchItemList[0].(*model.Waybill)
|
||||
handler := partner.GetWaybillTipUpdater(waybill.WaybillVendorID)
|
||||
if err == nil {
|
||||
err = handler.UpdateWaybillTip(ctx, waybill.VendorOrgCode, storeDetail.VendorStoreID, waybill.VendorOrderID, waybill.VendorWaybillID, waybill.VendorWaybillID2, utils.Int2Str(storeDetail.CityCode), tipFee)
|
||||
}
|
||||
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) {
|
||||
globals.SugarLogger.Debugf("confirmSelfTake orderID:%s, selfTakeCode:%s", order.VendorOrderID, selfTakeCode)
|
||||
if order.VendorID == model.VendorIDJD {
|
||||
|
||||
@@ -459,24 +459,35 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
if !isPending {
|
||||
if order.Status > model.OrderStatusEndBegin {
|
||||
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
} else if model.IsOrderHaveWaybill(order) {
|
||||
globals.SugarLogger.Debugf("OnWaybillStatusChanged multiple waybill created, bill:%v", bill)
|
||||
if model.IsWaybillPlatformOwn(bill) { // 是购物平台运单
|
||||
if !model.IsOrderHaveOwnWaybill(order) { // 既有运单不是购物平台运单
|
||||
globals.SugarLogger.Infof("OnWaybillStatusChanged bill:%v purchase platform bill came later than others, strange!!!", bill)
|
||||
oldBill := savedOrderInfo.waybills[order.WaybillVendorID]
|
||||
if oldBill != nil {
|
||||
s.ProxyCancelWaybill(order, oldBill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("OnWaybillStatusChanged bill:%v, oldBill is null, strange!!!", bill)
|
||||
} else {
|
||||
needAddTip := order.WaybillTipMoney > 0 && !model.IsWaybillPlatformOwn(bill)
|
||||
if model.IsOrderHaveWaybill(order) {
|
||||
globals.SugarLogger.Debugf("OnWaybillStatusChanged multiple waybill created, bill:%v", bill)
|
||||
if model.IsWaybillPlatformOwn(bill) { // 是购物平台运单
|
||||
if !model.IsOrderHaveOwnWaybill(order) { // 既有运单不是购物平台运单
|
||||
globals.SugarLogger.Infof("OnWaybillStatusChanged bill:%v purchase platform bill came later than others, strange!!!", bill)
|
||||
oldBill := savedOrderInfo.waybills[order.WaybillVendorID]
|
||||
if oldBill != nil {
|
||||
s.ProxyCancelWaybill(order, oldBill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("OnWaybillStatusChanged bill:%v, oldBill is null, strange!!!", bill)
|
||||
}
|
||||
}
|
||||
s.updateOrderByBill(order, nil, false)
|
||||
if time.Now().Sub(order.OrderCreatedAt) < 2*time.Minute { // 京东一些门店设置成了接单即拣货完成,这种情况下自动调用拣货完成
|
||||
s.autoPickupGood(savedOrderInfo)
|
||||
}
|
||||
} else {
|
||||
needAddTip = false
|
||||
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
}
|
||||
}
|
||||
if needAddTip {
|
||||
if handler := partner.GetWaybillTipUpdater(bill.WaybillVendorID); handler != nil {
|
||||
if storeDetail, err2 := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID); err2 == nil {
|
||||
handler.UpdateWaybillTip(jxcontext.AdminCtx, order.VendorOrgCode, order.VendorStoreID, order.VendorOrderID, bill.VendorWaybillID, bill.VendorWaybillID2, utils.Int2Str(storeDetail.CityCode), order.WaybillTipMoney)
|
||||
}
|
||||
}
|
||||
s.updateOrderByBill(order, nil, false)
|
||||
if time.Now().Sub(order.OrderCreatedAt) < 2*time.Minute { // 京东一些门店设置成了接单即拣货完成,这种情况下自动调用拣货完成
|
||||
s.autoPickupGood(savedOrderInfo)
|
||||
}
|
||||
} else {
|
||||
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
}
|
||||
}
|
||||
flag2Clear := model.WaybillVendorID2Mask(bill.WaybillVendorID)
|
||||
@@ -1191,29 +1202,41 @@ func (s *DefScheduler) watchOrderWaybills(savedOrderInfo *WatchOrderInfo) {
|
||||
savedOrderInfo.SetOrder(order)
|
||||
if isNeedWatch3rdWaybill(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 {
|
||||
var remark string
|
||||
tipFee := getWaybillTip(order)
|
||||
vendorStatus := fmt.Sprintf("设置小费:%s", jxutils.IntPrice2StandardCurrencyString(tipFee))
|
||||
if curTipFee, err := handler.GetWaybillTip(jxcontext.AdminCtx, order.VendorOrgCode, order.VendorOrderID, order.VendorOrderID, ""); err == nil {
|
||||
tipFee2Add := tipFee - curTipFee
|
||||
vendorStatus += fmt.Sprintf(", 本次添加:%s", jxutils.IntPrice2StandardCurrencyString(tipFee2Add))
|
||||
if false { //tipFee2Add > 0 {
|
||||
err := handler.AddWaybillTip(jxcontext.AdminCtx, order.VendorOrgCode, order.VendorOrderID, order.VendorOrderID, "", "", tipFee2Add)
|
||||
if err == nil {
|
||||
vendorStatus += "成功"
|
||||
order.WaybillTipMoney += tipFee2Add
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney"})
|
||||
} else {
|
||||
vendorStatus += "失败"
|
||||
remark = fmt.Sprint(err)
|
||||
}
|
||||
tipFee2Add := tipFee - order.WaybillTipMoney
|
||||
vendorStatus += fmt.Sprintf(", 本次添加:%s", jxutils.IntPrice2StandardCurrencyString(tipFee2Add))
|
||||
if false { //tipFee2Add > 0 {
|
||||
err := handler.UpdateWaybillTip(jxcontext.AdminCtx, order.VendorOrgCode, order.VendorStoreID, order.VendorOrderID, order.VendorOrderID, "", "", tipFee)
|
||||
if err == nil {
|
||||
vendorStatus += "成功"
|
||||
order.WaybillTipMoney = tipFee
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney"})
|
||||
} else {
|
||||
vendorStatus += "空操作"
|
||||
vendorStatus += "失败"
|
||||
remark = fmt.Sprint(err)
|
||||
}
|
||||
} else {
|
||||
vendorStatus += "失败"
|
||||
remark = fmt.Sprint(err)
|
||||
vendorStatus += "空操作"
|
||||
}
|
||||
partner.CurOrderManager.OnOrderMsg(order, vendorStatus, remark)
|
||||
}
|
||||
|
||||
@@ -659,19 +659,14 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s
|
||||
if hasSensitiveWord, err := CheckHasSensitiveWord(skuNameExt.Name); hasSensitiveWord {
|
||||
return nil, err
|
||||
}
|
||||
if utils.Pointer2String(skuNameExt.Upc) == "" {
|
||||
upc := utils.Pointer2String(skuNameExt.Upc)
|
||||
if upc == "" {
|
||||
skuNameExt.Upc = nil
|
||||
} else if !jxutils.IsUpcValid(upc) {
|
||||
return nil, fmt.Errorf("upc:%s不合法,请仔细检查", upc)
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
// if skuNameExt.Upc != "" {
|
||||
// err = dao.GetEntity(db, &skuNameExt.SkuName, "Upc")
|
||||
// if err == nil {
|
||||
// return nil, fmt.Errorf("UPC:%s重复", skuNameExt.Upc)
|
||||
// } else if !dao.IsNoRowsError(err) {
|
||||
// return nil, err
|
||||
// }
|
||||
// err = nil
|
||||
// }
|
||||
skuNameExt.SkuName.Status = model.SkuStatusNormal
|
||||
if skuNameExt.IsSpu == 1 {
|
||||
return nil, fmt.Errorf("不允许创建多规格商品")
|
||||
@@ -794,21 +789,11 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
||||
if valid["Upc"] != nil {
|
||||
if upc, _ := valid["Upc"].(string); upc == "" {
|
||||
valid["Upc"] = nil
|
||||
} else if !jxutils.IsUpcValid(upc) {
|
||||
return 0, fmt.Errorf("upc:%s不合法,请仔细检查", upc)
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("UpdateSkuName valid:%s", utils.Format4Output(valid, false))
|
||||
// if upc, _ := valid["Upc"].(string); upc != "" {
|
||||
// skuName := &model.SkuName{
|
||||
// Upc: upc,
|
||||
// }
|
||||
// err = dao.GetEntity(db, skuName, "Upc")
|
||||
// if err == nil {
|
||||
// return 0, fmt.Errorf("UPC:%s重复", upc)
|
||||
// } else if !dao.IsNoRowsError(err) {
|
||||
// return 0, err
|
||||
// }
|
||||
// err = nil
|
||||
// }
|
||||
for _, imgName := range []string{"img", "img2"} {
|
||||
if valid[imgName] != nil {
|
||||
if imgStr := utils.Interface2String(valid[imgName]); imgStr != "" {
|
||||
|
||||
@@ -33,6 +33,7 @@ var (
|
||||
|
||||
OrderStatusName = map[int]string{
|
||||
OrderStatusMsg: "通知消息",
|
||||
OrderStatusWaybillTipChanged: "小费变动",
|
||||
OrderStatusRefuseFailedGetGoods: "取货失败审核驳回",
|
||||
OrderStatusAdjust: "订单调整完成",
|
||||
OrderStatusApplyUrgeOrder: "催单",
|
||||
@@ -172,6 +173,8 @@ const (
|
||||
const (
|
||||
OrderStatusMsg = -100
|
||||
|
||||
OrderStatusWaybillTipChanged = -80 // 订单小费变化
|
||||
|
||||
OrderStatusRefuseFailedGetGoods = -70 // 取货失败审核驳回
|
||||
OrderStatusAdjust = -65 // 原值-35 订单调整完成
|
||||
OrderStatusApplyUrgeOrder = -55 // 原值-15
|
||||
|
||||
@@ -394,7 +394,7 @@ func (c *DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, reson
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
|
||||
func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
|
||||
order, err := api.DadaAPI.QueryOrderInfo2(vendorOrderID)
|
||||
if err == nil {
|
||||
tipFee = jxutils.StandardPrice2Int(order.Tips)
|
||||
@@ -402,13 +402,9 @@ func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, v
|
||||
return tipFee, err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee2Add int64) (err error) {
|
||||
curTip, err := c.GetWaybillTip(ctx, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2)
|
||||
if err == nil {
|
||||
totalTip := curTip + tipFee2Add
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.DadaAPI.AddTip(vendorOrderID, jxutils.IntPrice2Standard(totalTip), cityCode, "")
|
||||
}
|
||||
func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.DadaAPI.AddTip(vendorOrderID, jxutils.IntPrice2Standard(tipFee), cityCode, "")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -287,3 +287,13 @@ func GetRidderPositionGetter(vendorID int) (handler IRidderPositionGetter) {
|
||||
handler, _ = GetPurchasePlatformFromVendorID(vendorID).(IRidderPositionGetter)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ type IPurchasePlatformOrderHandler interface {
|
||||
}
|
||||
|
||||
type IAddWaybillTip interface {
|
||||
GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error)
|
||||
AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee2Add int64) (err error)
|
||||
GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error)
|
||||
UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error)
|
||||
}
|
||||
|
||||
type IRidderPositionGetter interface {
|
||||
|
||||
@@ -660,3 +660,20 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, vendorOrgCode strin
|
||||
}
|
||||
return vendorOrderIDs, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, 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) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.ModifyTip4OrderWaybill(vendorOrderID, "", jxutils.IntPrice2Standard(tipFee), 0)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ var (
|
||||
|
||||
jdapi.OrderStatusVenderAgreeCancel: model.OrderStatusVendorAgreeCancel,
|
||||
jdapi.OrderStatusVenderRejectCancel: model.OrderStatusVendorRejectCancel,
|
||||
jdapi.CallbackMsgOrderAddTips: model.OrderStatusWaybillTipChanged,
|
||||
}
|
||||
deliveryTypeMap = map[int]string{
|
||||
jdapi.CarrierNoCrowdSourcing: model.OrderDeliveryTypePlatform,
|
||||
@@ -286,10 +287,13 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *jdapi.CallbackOrderMsg) *model
|
||||
RefVendorOrderID: msg.BillID,
|
||||
RefVendorID: model.VendorIDJD,
|
||||
VendorStatus: msg.StatusID,
|
||||
Status: c.getStatusFromVendorStatus(msg.StatusID),
|
||||
StatusTime: utils.Str2Time(msg.Timestamp),
|
||||
Remark: msg.Remark,
|
||||
}
|
||||
if msg.MsgURL == jdapi.CallbackMsgOrderAddTips {
|
||||
orderStatus.VendorStatus = jdapi.CallbackMsgOrderAddTips
|
||||
}
|
||||
orderStatus.Status = c.getStatusFromVendorStatus(orderStatus.VendorStatus)
|
||||
return orderStatus
|
||||
}
|
||||
|
||||
@@ -480,21 +484,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, vendorOrgCode strin
|
||||
return vendorOrderIDs, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (err error) {
|
||||
a := getAPI(order.VendorOrgCode)
|
||||
orderInfo, err := a.QuerySingleOrder2(order.VendorOrderID)
|
||||
if err == nil {
|
||||
tip2Add := int(tipFee) - orderInfo.Tips
|
||||
if tip2Add != 0 {
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = a.OrderAddTips(order.VendorOrderID, tip2Add, ctx.GetUserName())
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
|
||||
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
|
||||
orderInfo, err := getAPI(vendorOrgCode).QuerySingleOrder2(vendorOrderID)
|
||||
if err == nil {
|
||||
tipFee = int64(orderInfo.Tips)
|
||||
@@ -502,9 +492,14 @@ func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, v
|
||||
return tipFee, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee2Add int64) (err error) {
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = getAPI(vendorOrgCode).OrderAddTips(vendorOrderID, int(tipFee2Add), ctx.GetUserName())
|
||||
func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
|
||||
curTipFee, err := c.GetWaybillTip(ctx, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2)
|
||||
if err == nil {
|
||||
if tipFee2Add := tipFee - curTipFee; tipFee2Add > 0 {
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = getAPI(vendorOrgCode).OrderAddTips(vendorOrderID, int(tipFee2Add), ctx.GetUserName())
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -755,3 +755,18 @@ func (p *PurchaseHandler) onNumberDowngrade(msg *mtwmapi.CallbackMsg) (response
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
return response
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) {
|
||||
orderInfo, err := api.MtwmAPI.GetDistributeOrderDetail(vendorOrderID, vendorStoreID)
|
||||
if err == nil {
|
||||
tipFee = jxutils.StandardPrice2Int(orderInfo.TipAmount)
|
||||
}
|
||||
return tipFee, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.OrderModityTips(vendorOrderID, vendorStoreID, jxutils.IntPrice2Standard(tipFee))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user