diff --git a/business/jxcallback/orderman/waybill.go b/business/jxcallback/orderman/waybill.go index 246db13c5..d795ac4f6 100644 --- a/business/jxcallback/orderman/waybill.go +++ b/business/jxcallback/orderman/waybill.go @@ -5,6 +5,7 @@ import ( "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler" + "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/globals" @@ -84,6 +85,7 @@ func (w *OrderManager) onWaybillNew(bill2 *model.Waybill, db *dao.DaoDB) (isDupl func (w *OrderManager) OnWaybillStatusChanged(bill *model.Waybill) (err error) { var isDuplicated bool + bill.CourierMobile = jxutils.FormalizeMobile(bill.CourierMobile) db := dao.GetDB() dao.Begin(db) defer func() { diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 121d7bf50..14a90eac8 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -68,10 +68,9 @@ type WatchOrderInfo struct { autoPickupTimeoutMinute int // 0表示禁用,1表示用缺省值time2AutoPickupMin,其它表示分钟数 storeDeliveryType int - isDeliveryCompetition bool - pmWaybillCreatedAt time.Time - isNeedCreate3rdWaybill bool - isAddWaybillTipDisabled bool + isDeliveryCompetition bool + isNeedCreate3rdWaybill bool + watchWabillStartAt *time.Time waybills map[int]*model.Waybill // 这个waybills里的状态信息是不真实的,只使用id相关的信息 @@ -224,6 +223,8 @@ func init() { }, TimeoutAction: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) (err error) { if savedOrderInfo.storeDeliveryType == scheduler.StoreDeliveryTypeByStore && savedOrderInfo.order.DeliveryType != model.OrderDeliveryTypeSelfTake { // 自配送商家使用 + // 启动抢单TIMER + sch.saveDeliveryFeeFromAndStartWatch(savedOrderInfo, savedOrderInfo.order.StatusTime) return sch.createWaybillOn3rdProviders(savedOrderInfo, 0, nil) } return nil @@ -431,23 +432,10 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo err = partner.CurOrderManager.UpdateOrderStatusAndDeliveryFlag(order) } } - // 只有购物平台的新运单消息才会启动抢单TIMER + // 购物平台的新运单消息会启动抢单TIMER if model.IsWaybillPlatformOwn(bill) { s.resetTimer(savedOrderInfo, bill, isPending) - isFirst := utils.IsTimeZero(savedOrderInfo.pmWaybillCreatedAt) - savedOrderInfo.pmWaybillCreatedAt = bill.StatusTime - savedOrderInfo.isAddWaybillTipDisabled = false - if isFirst { - duration := savedOrderInfo.pmWaybillCreatedAt.Add(minAddWaybillTipMinute * time.Minute).Sub(time.Now()) - if duration <= 0 { - duration = 1 * time.Second - } - utils.AfterFuncWithRecover(duration, func() { - jxutils.CallMsgHandlerAsync(func() { - s.handleWaybillTip(savedOrderInfo) - }, jxutils.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID)) - }) - } + s.saveDeliveryFeeFromAndStartWatch(savedOrderInfo, bill.StatusTime) } } else { isBillExist := s.updateBillsInfo(savedOrderInfo, bill) @@ -471,7 +459,6 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo s.cancelOtherWaybillsCheckOrderDeliveryFlag(savedOrderInfo, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime) if model.IsWaybillPlatformOwn(bill) { - savedOrderInfo.isAddWaybillTipDisabled = true if bill.Status == model.WaybillStatusDelivering { // 强制将订单状态置为配送中? order.Status = model.OrderStatusDelivering @@ -619,7 +606,7 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf return nil } if maxDeliveryFee == 0 { - maxDeliveryFee = s.getMaxDeliveryFee(savedOrderInfo) + maxDeliveryFee = getMaxDeliveryFee(order) } if err = s.canOrderCreateWaybillNormally(order); err == nil { if (order.DeliveryFlag & model.OrderDeliveryFlagMaskScheduleDisabled) == 0 { @@ -1001,14 +988,9 @@ func (s *DefScheduler) autoPickupGood(savedOrderInfo *WatchOrderInfo) (err error return err } -func (s *DefScheduler) getWaybillTip(savedOrderInfo *WatchOrderInfo) (tipFee int64) { - order := savedOrderInfo.order - if order.Status == model.OrderStatusFinishedPickup && - !utils.IsTimeZero(savedOrderInfo.pmWaybillCreatedAt) { - startTime := savedOrderInfo.pmWaybillCreatedAt.Add(minAddWaybillTipMinute * time.Minute) - // if order.DeliveryFlag&model.OrderDeliveryFlagMaskAutoPickup != 0 { - // startTime = startTime.Add(5 * time.Minute) - // } +func getWaybillTip(order *model.GoodsOrder) (tipFee int64) { + if !utils.IsPtrTimeZero(order.DeliveryFeeFrom) { + startTime := order.DeliveryFeeFrom.Add(minAddWaybillTipMinute * time.Minute) timeGap1 := time.Now().Sub(startTime) if timeGap1 > 0 { timeGap := int64(timeGap1/(addWaybillTipGap*time.Minute)) + 1 @@ -1021,57 +1003,87 @@ func (s *DefScheduler) getWaybillTip(savedOrderInfo *WatchOrderInfo) (tipFee int return tipFee } -func (s *DefScheduler) getMaxDeliveryFee(savedOrderInfo *WatchOrderInfo) (maxDeliveryFee int64) { - maxDeliveryFee = baseWaybillFee + savedOrderInfo.order.DistanceFreightMoney + s.getWaybillTip(savedOrderInfo) +func getMaxDeliveryFee(order *model.GoodsOrder) (maxDeliveryFee int64) { + maxDeliveryFee = baseWaybillFee + order.DistanceFreightMoney + getWaybillTip(order) return maxDeliveryFee } -func (s *DefScheduler) handleWaybillTip(savedOrderInfo *WatchOrderInfo) { - if savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore && - savedOrderInfo.isDeliveryCompetition { +func isNeedWatchWaybillTip(order *model.GoodsOrder) bool { + return order.DeliveryFlag&model.OrderDeliveryFlagMaskPurcahseDisabled == 0 && // 没有转出 + order.DeliveryType == model.OrderDeliveryTypePlatform && // 订单配送类型为平台 + !utils.IsPtrTimeZero(order.DeliveryFeeFrom) // 已经有了开始计费时间 +} + +func isNeedWatch3rdWaybill(order *model.GoodsOrder) bool { + return (order.Status >= model.OrderStatusFinishedPickup && order.Status < model.OrderStatusDelivering) && // 订单状态 + order.DeliveryFlag&model.OrderDeliveryFlagMaskScheduleDisabled == 0 && // 没有禁止调度 + !model.IsOrderHaveWaybill(order) // 没有有效运单 +} + +func (s *DefScheduler) setWatchOrderWaybills(savedOrderInfo *WatchOrderInfo, duration time.Duration) { + if utils.IsPtrTimeZero(savedOrderInfo.watchWabillStartAt) { + savedOrderInfo.watchWabillStartAt = utils.Time2Pointer(time.Now()) + utils.AfterFuncWithRecover(5*time.Minute, func() { + jxutils.CallMsgHandlerAsync(func() { + savedOrderInfo.watchWabillStartAt = nil + s.watchOrderWaybills(savedOrderInfo) + }, jxutils.ComposeUniversalOrderID(savedOrderInfo.order.VendorOrderID, savedOrderInfo.order.VendorID)) + }) + } +} + +func (s *DefScheduler) saveDeliveryFeeFromAndStartWatch(savedOrderInfo *WatchOrderInfo, statusTime time.Time) { + order := savedOrderInfo.order + if utils.IsPtrTimeZero(order.DeliveryFeeFrom) { + order.DeliveryFeeFrom = utils.Time2Pointer(statusTime) + partner.CurOrderManager.UpdateOrderFields(order, []string{"DeliveryFeeFrom"}) + } + duration := order.DeliveryFeeFrom.Add(minAddWaybillTipMinute * time.Minute).Sub(time.Now()) + if duration <= 0 { + duration = 5 * time.Second + } + s.setWatchOrderWaybills(savedOrderInfo, duration) +} + +func (s *DefScheduler) watchOrderWaybills(savedOrderInfo *WatchOrderInfo) { + if savedOrderInfo.storeDeliveryType != scheduler.StoreDeliveryTypeByStore && savedOrderInfo.isDeliveryCompetition || + savedOrderInfo.storeDeliveryType == scheduler.StoreDeliveryTypeByStore { order2 := savedOrderInfo.order if order, err := partner.CurOrderManager.LoadOrder(order2.VendorOrderID, order2.VendorID); err == nil { savedOrderInfo.SetOrder(order) - if order.Status == model.OrderStatusFinishedPickup && - order.DeliveryFlag&model.OrderDeliveryFlagMaskScheduleDisabled == 0 { - if !utils.IsTimeZero(savedOrderInfo.pmWaybillCreatedAt) && - !savedOrderInfo.isAddWaybillTipDisabled { - if tipFee := s.getWaybillTip(savedOrderInfo); tipFee > 0 { - if handler, ok := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).(partner.IAddWaybillTip); ok && handler != nil { - var remark string - vendorStatus := fmt.Sprintf("设置小费:%s", jxutils.IntPrice2StandardCurrencyString(tipFee)) - if curTipFee, err := handler.GetWaybillTip(jxcontext.AdminCtx, order); err == nil { - tipFee2Add := tipFee - curTipFee - vendorStatus += fmt.Sprintf(", 本次添加:%s", jxutils.IntPrice2StandardCurrencyString(tipFee2Add)) - if tipFee2Add > 0 { - err := handler.AddWaybillTip(jxcontext.AdminCtx, order, tipFee2Add) - if err == nil { - vendorStatus += "成功" - order.WaybillTipMoney += tipFee2Add - partner.CurOrderManager.UpdateOrderFields(order, []string{"WaybillTipMoney"}) - } else { - vendorStatus += "失败" - remark = fmt.Sprint(err) - } + if isNeedWatch3rdWaybill(order) { + if isNeedWatchWaybillTip(order) { + 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); err == nil { + tipFee2Add := tipFee - curTipFee + vendorStatus += fmt.Sprintf(", 本次添加:%s", jxutils.IntPrice2StandardCurrencyString(tipFee2Add)) + if tipFee2Add > 0 { + err := handler.AddWaybillTip(jxcontext.AdminCtx, order, tipFee2Add) + if err == nil { + vendorStatus += "成功" + order.WaybillTipMoney += tipFee2Add + 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) - } - if savedOrderInfo.isNeedCreate3rdWaybill { - s.createWaybillOn3rdProviders(savedOrderInfo, 0, nil) + } else { + vendorStatus += "失败" + remark = fmt.Sprint(err) } + partner.CurOrderManager.OnOrderMsg(order, vendorStatus, remark) } } - utils.AfterFuncWithRecover(5*time.Minute, func() { - jxutils.CallMsgHandlerAsync(func() { - s.handleWaybillTip(savedOrderInfo) - }, jxutils.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID)) - }) + if savedOrderInfo.isNeedCreate3rdWaybill { + s.createWaybillOn3rdProviders(savedOrderInfo, 0, nil) + } + s.setWatchOrderWaybills(savedOrderInfo, 5*time.Minute) } } } diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index bc80de6b2..c0aa517e0 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -74,6 +74,7 @@ func init() { func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Act, vendorIDs []int, actStoreSku []*ActStoreSkuParam) (validVendorIDs []int, actStoreSkuList []*model.ActStoreSku, actStoreSkuMapList []*model.ActStoreSkuMap, err error) { wholeValidVendorMap := make(map[int]int) + wholeValidVendorMap[model.VendorIDJX] = 1 if len(actStoreSku) > 0 { storeIDMap := make(map[int]int) skuIDMap := make(map[int]int) @@ -161,6 +162,8 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName()) actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap) } + } else { + globals.SugarLogger.Debugf("ActStoreSkuParam2Model storeID:%d, skuID:%d没有关注", v.StoreID, v.SkuID) } } wholeValidVendorMap[vendorID] = 1 @@ -339,6 +342,10 @@ func PreCreateAct(ctx *jxcontext.Context, act *model.Act, vendorIDs []int, actRu if err != nil { return nil, err } + if len(validVendorIDs) == 0 { + dao.Rollback(db) + return nil, fmt.Errorf("没有一个合法平台可以创建活动") + } preCreateActInfo = &tPreCreateActInfo{ ValidVendorIDs: validVendorIDs, diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 13e0e565d..aae783c26 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -59,7 +59,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto district.name district_name, city.name city_name FROM store t1 - JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ? + LEFT JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ? LEFT JOIN place city ON city.code = t1.city_code LEFT JOIN place district ON district.code = t1.district_code LEFT JOIN new_config t3 ON t3.key = t2.price_percentage_pack AND t3.type = ? AND t3.deleted_at = ? @@ -72,6 +72,9 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto utils.DefaultTimeValue, utils.DefaultTimeValue, } + if vendorID != model.VendorIDJX { + sql += " AND t2.id IS NOT NULL" + } if storeID > 0 { sql += " AND t1.id = ?" sqlParams = append(sqlParams, storeID) diff --git a/business/model/order.go b/business/model/order.go index 641d2581c..7a4cb0f55 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -14,55 +14,56 @@ type ModelTimeInfo struct { } type GoodsOrder struct { - ID int64 `orm:"column(id)" json:"id"` - VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` - VendorOrderID2 string `orm:"column(vendor_order_id2);size(48);index" json:"vendorOrderID2"` - VendorID int `orm:"column(vendor_id)" json:"vendorID"` - VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` - StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid - JxStoreID int `orm:"column(jx_store_id)" json:"jxStoreID"` // 根据VendorStoreID在本地系统里查询出来的 jxstoreid - StoreName string `orm:"size(64)" json:"storeName"` - ShopPrice int64 `json:"shopPrice"` // 京西价 - VendorPrice int64 `json:"vendorPrice"` // 平台价 - SalePrice int64 `json:"salePrice"` // 售卖价 - ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付 - TotalShopMoney int64 `json:"totalShopMoney"` // 应结金额-第三方平台结算给京西的金额(包括了所有的补贴,扣除) - DiscountMoney int64 `json:"discountMoney"` // 订单总优惠金额 - PmSubsidyMoney int64 `json:"pmSubsidyMoney"` // 平台活动补贴(订单主体活动补贴+订单单条sku补贴)1+ - DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值) - WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费 - EarningPrice int64 `json:"earningPrice"` // 结算给门店老板的钱(未扣除可能的三方配送费) - Weight int `json:"weight"` // 单位为克 - VendorUserID string `orm:"column(vendor_user_id);size(48)" json:"vendorUserID"` - UserID string `orm:"column(user_id);size(48)" json:"userID"` - ConsigneeName string `orm:"size(32)" json:"consigneeName"` - ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"` - ConsigneeMobile2 string `orm:"size(32)" json:"consigneeMobile2"` - ConsigneeAddress string `orm:"size(255)" json:"consigneeAddress"` - CoordinateType int `json:"coordinateType"` - ConsigneeLng int `json:"consigneeLng"` // 坐标 * (10的六次方) - ConsigneeLat int `json:"consigneeLat"` // 坐标 * (10的六次方) - SkuCount int `json:"skuCount"` // 商品类别数量,即有多少种商品(注意在某些情况下,相同SKU的商品由于售价不同,也会当成不同商品在这个值里) - GoodsCount int `json:"goodsCount"` // 商品个数 - Status int `json:"status"` // 参见OrderStatus*相关的常量定义 - VendorStatus string `orm:"size(255)" json:"vendorStatus"` - LockStatus int `json:"lockStatus"` - LockStatusTime time.Time `orm:"type(datetime);null" json:"lockStatusTime"` // last lock status time - OrderSeq int `json:"orderSeq"` // 门店订单序号 - BuyerComment string `orm:"size(255)" json:"buyerComment"` - BusinessType int `json:"businessType"` - ExpectedDeliveredTime time.Time `orm:"type(datetime)" json:"expectedDeliveredTime"` // 预期送达时间 - CancelApplyReason string `orm:"size(255)" json:"-"` // ""表示没有申请,不为null表示用户正在取消申请 - DeliveryType string `orm:"size(32)" json:"deliveryType"` // 订单配送方式,缺省是平台配送 - VendorWaybillID string `orm:"column(vendor_waybill_id);size(48)" json:"vendorWaybillID"` - WaybillVendorID int `orm:"column(waybill_vendor_id)" json:"waybillVendorID"` // 表示当前承运商,-1表示还没有安排 - AdjustCount int8 `json:"adjustCount"` // 调整单(次数) - DeliveryFlag int8 `json:"deliveryFlag"` // 第1位为1表示禁止调度器调度三方配送 - DuplicatedCount int `json:"-"` // 重复新订单消息数,这个一般不是由于消息重发造成的(消息重发由OrderStatus过滤),一般是业务逻辑造成的 - OrderCreatedAt time.Time `orm:"type(datetime);index" json:"orderCreatedAt"` // 这里记录的是订单生效时间,即用户支付完成(货到付款即为下单时间) - OrderFinishedAt time.Time `orm:"type(datetime)" json:"orderFinishedAt"` - StatusTime time.Time `orm:"type(datetime)" json:"statusTime"` // last status time - PickDeadline time.Time `orm:"type(datetime);null" json:"pickDeadline"` + ID int64 `orm:"column(id)" json:"id"` + VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` + VendorOrderID2 string `orm:"column(vendor_order_id2);size(48);index" json:"vendorOrderID2"` + VendorID int `orm:"column(vendor_id)" json:"vendorID"` + VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` + StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid + JxStoreID int `orm:"column(jx_store_id)" json:"jxStoreID"` // 根据VendorStoreID在本地系统里查询出来的 jxstoreid + StoreName string `orm:"size(64)" json:"storeName"` + ShopPrice int64 `json:"shopPrice"` // 京西价 + VendorPrice int64 `json:"vendorPrice"` // 平台价 + SalePrice int64 `json:"salePrice"` // 售卖价 + ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付 + TotalShopMoney int64 `json:"totalShopMoney"` // 应结金额-第三方平台结算给京西的金额(包括了所有的补贴,扣除) + DiscountMoney int64 `json:"discountMoney"` // 订单总优惠金额 + PmSubsidyMoney int64 `json:"pmSubsidyMoney"` // 平台活动补贴(订单主体活动补贴+订单单条sku补贴)1+ + DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值) + WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费 + EarningPrice int64 `json:"earningPrice"` // 结算给门店老板的钱(未扣除可能的三方配送费) + Weight int `json:"weight"` // 单位为克 + VendorUserID string `orm:"column(vendor_user_id);size(48)" json:"vendorUserID"` + UserID string `orm:"column(user_id);size(48)" json:"userID"` + ConsigneeName string `orm:"size(32)" json:"consigneeName"` + ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"` + ConsigneeMobile2 string `orm:"size(32)" json:"consigneeMobile2"` + ConsigneeAddress string `orm:"size(255)" json:"consigneeAddress"` + CoordinateType int `json:"coordinateType"` + ConsigneeLng int `json:"consigneeLng"` // 坐标 * (10的六次方) + ConsigneeLat int `json:"consigneeLat"` // 坐标 * (10的六次方) + SkuCount int `json:"skuCount"` // 商品类别数量,即有多少种商品(注意在某些情况下,相同SKU的商品由于售价不同,也会当成不同商品在这个值里) + GoodsCount int `json:"goodsCount"` // 商品个数 + Status int `json:"status"` // 参见OrderStatus*相关的常量定义 + VendorStatus string `orm:"size(255)" json:"vendorStatus"` + LockStatus int `json:"lockStatus"` + LockStatusTime time.Time `orm:"type(datetime);null" json:"lockStatusTime"` // last lock status time + OrderSeq int `json:"orderSeq"` // 门店订单序号 + BuyerComment string `orm:"size(255)" json:"buyerComment"` + BusinessType int `json:"businessType"` + ExpectedDeliveredTime time.Time `orm:"type(datetime)" json:"expectedDeliveredTime"` // 预期送达时间 + CancelApplyReason string `orm:"size(255)" json:"-"` // ""表示没有申请,不为null表示用户正在取消申请 + DeliveryType string `orm:"size(32)" json:"deliveryType"` // 订单配送方式,缺省是平台配送 + VendorWaybillID string `orm:"column(vendor_waybill_id);size(48)" json:"vendorWaybillID"` + WaybillVendorID int `orm:"column(waybill_vendor_id)" json:"waybillVendorID"` // 表示当前承运商,-1表示还没有安排 + AdjustCount int8 `json:"adjustCount"` // 调整单(次数) + DeliveryFlag int8 `json:"deliveryFlag"` // 第1位为1表示禁止调度器调度三方配送 + DuplicatedCount int `json:"-"` // 重复新订单消息数,这个一般不是由于消息重发造成的(消息重发由OrderStatus过滤),一般是业务逻辑造成的 + OrderCreatedAt time.Time `orm:"type(datetime);index" json:"orderCreatedAt"` // 这里记录的是订单生效时间,即用户支付完成(货到付款即为下单时间) + OrderFinishedAt time.Time `orm:"type(datetime)" json:"orderFinishedAt"` + StatusTime time.Time `orm:"type(datetime)" json:"statusTime"` // last status time + PickDeadline time.Time `orm:"type(datetime);null" json:"pickDeadline"` + DeliveryFeeFrom *time.Time `orm:"type(datetime);null" json:"deliveryFeeFrom,omitempty"` // 三方配置费计算的开始基准时间 ModelTimeInfo `json:"-"` Flag int `json:"flag"` //非运单调整相关的其它状态 diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index a3a09cf4a..cad01ed81 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -300,8 +300,16 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI globals.SugarLogger.Debugf("jd AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt) if globals.EnableStoreWrite { err = getAPI("").OrderAcceptOperate(order.VendorOrderID, isAcceptIt, userName) + if isAcceptIt && err == nil { + c.postFakeMsg(order.VendorOrderID, jdapi.StatusIDWaitOutStore) + } } else { - c.postFakeMsg(order.VendorOrderID, jdapi.StatusIDWaitOutStore) + if isAcceptIt { + c.postFakeMsg(order.VendorOrderID, jdapi.StatusIDWaitOutStore) + } else { + + c.postFakeMsg(order.VendorOrderID, jdapi.OrderStatusCanceled) + } } return err }