package controllers import ( "fmt" "strings" "time" "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" "git.rosy.net.cn/jx-callback/business/jxstore/misc" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils/netprinter" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/globals" "github.com/astaxie/beego" ) // 订单相关API type OrderController struct { beego.Controller } func (c *OrderController) URLMapping() { c.Mapping("GetOrderSkuInfo", c.GetOrderSkuInfo) c.Mapping("FinishedPickup", c.FinishedPickup) c.Mapping("SelfDelivering", c.SelfDelivering) c.Mapping("CreateWaybillOnProviders", c.CreateWaybillOnProviders) c.Mapping("SelfDelivered", c.SelfDelivered) } // @Title 完成拣货 // @Description 完成拣货 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属的厂商ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /FinishedPickup [post] func (c *OrderController) FinishedPickup() { c.callFinishedPickup(func(params *tOrderFinishedPickupParams) (retVal interface{}, errCode string, err error) { err = defsch.FixedScheduler.PickupGoodsAndUpdateStatus(params.Ctx, params.VendorOrderID, params.VendorID, params.Ctx.GetUserName()) return nil, "", err }) } // @Title 转自送 // @Description 转自送,对于配送类型为纯自送的,就是表示自送开始 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属的厂商ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /SelfDelivering [post] func (c *OrderController) SelfDelivering() { c.callSelfDelivering(func(params *tOrderSelfDeliveringParams) (retVal interface{}, errCode string, err error) { err = defsch.FixedScheduler.SelfDeliveringAndUpdateStatus(params.Ctx, params.VendorOrderID, params.VendorID, params.Ctx.GetUserName()) return nil, "", err }) } // @Title 自送送达 // @Description 自送送达 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属的厂商ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /SelfDelivered [post] func (c *OrderController) SelfDelivered() { c.callSelfDelivered(func(params *tOrderSelfDeliveredParams) (retVal interface{}, errCode string, err error) { err = defsch.FixedScheduler.SelfDeliveredAndUpdateStatus(params.Ctx, params.VendorOrderID, params.VendorID, params.Ctx.GetUserName()) return nil, "", err }) } // @Title 自送送达 // @Description 自送送达 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属的厂商ID" // @Param selfTakeCode formData string true "自提码" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /ConfirmSelfTake [post] func (c *OrderController) ConfirmSelfTake() { c.callConfirmSelfTake(func(params *tOrderConfirmSelfTakeParams) (retVal interface{}, errCode string, err error) { err = defsch.FixedScheduler.ConfirmSelfTake(params.Ctx, params.VendorOrderID, params.VendorID, params.SelfTakeCode) return retVal, "", err }) } // @Title 查询三方运单费用信息 // @Description 查询三方运单费用信息 // @Param token header string true "认证token" // @Param vendorOrderID query string true "订单ID" // @Param vendorID query int true "订单所属的厂商ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /QueryOrderWaybillFeeInfo [get] func (c *OrderController) QueryOrderWaybillFeeInfo() { c.callQueryOrderWaybillFeeInfo(func(params *tOrderQueryOrderWaybillFeeInfoParams) (retVal interface{}, errCode string, err error) { retVal, err = defsch.FixedScheduler.QueryOrderWaybillFeeInfoEx(params.Ctx, params.VendorOrderID, params.VendorID) return retVal, "", err }) } // @Title 创建三方运单 // @Description 创建三方运单 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属的厂商ID" // @Param courierVendorIDs formData string false "运单厂商ID(缺省全部)" // @Param maxDeliveryFee formData int false "最高限价(为0时为缺省最大值)" // @Param forceCreate formData bool false "是否强制创建(忽略订单状态检查及其它参数)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /CreateWaybillOnProviders [post] func (c *OrderController) CreateWaybillOnProviders() { c.callCreateWaybillOnProviders(func(params *tOrderCreateWaybillOnProvidersParams) (retVal interface{}, errCode string, err error) { var courierVendorIDs []int if err = jxutils.Strings2Objs(params.CourierVendorIDs, &courierVendorIDs); err == nil { retVal, err = defsch.FixedScheduler.CreateWaybillOnProvidersEx(params.Ctx, params.VendorOrderID, params.VendorID, courierVendorIDs, params.ForceCreate, int64(params.MaxDeliveryFee)) } return retVal, "", err }) } // @Title 取消所有三方运单 // @Description 取消所有三方运单 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属的厂商ID" // @Param isStopSchedule formData bool false "是否停止运单调度" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /CancelAll3rdWaybills [post] func (c *OrderController) CancelAll3rdWaybills() { c.callCancelAll3rdWaybills(func(params *tOrderCancelAll3rdWaybillsParams) (retVal interface{}, errCode string, err error) { err = defsch.FixedScheduler.CancelAll3rdWaybills(params.Ctx, params.VendorOrderID, params.VendorID, params.IsStopSchedule) return retVal, "", err }) } // @Title 取消三方运单 // @Description 取消三方运单 // @Param token header string true "认证token" // @Param vendorWaybillID formData string true "运单ID" // @Param waybillVendorID formData int true "运单所属的厂商ID" // @Param reasonID formData int false "原因ID" // @Param reason formData string false "取消原因" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /CancelWaybill [post] func (c *OrderController) CancelWaybill() { c.callCancelWaybill(func(params *tOrderCancelWaybillParams) (retVal interface{}, errCode string, err error) { reasonID := params.ReasonID if reasonID == 0 { reasonID = partner.CancelWaybillReasonOther } err = defsch.FixedScheduler.CancelWaybillByID(params.Ctx, params.VendorWaybillID, params.WaybillVendorID, reasonID, params.Reason) return retVal, "", err }) } // @Title 得到门店订单信息 // @Description 得到门店订单信息 // @Param token header string true "认证token" // @Param storeID query int true "京西门店ID" // @Param lastHours query int false "最近多少小时的信息(缺省为两天)" // @Param lastMinutes query int false "最近多少分钟的信息(缺省为不传)" // @Param isIncludeFake query bool false "是否包括假订单" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetStoreOrderCountInfo [get] func (c *OrderController) GetStoreOrderCountInfo() { c.callGetStoreOrderCountInfo(func(params *tOrderGetStoreOrderCountInfoParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.FixedOrderManager.GetStoreOrderCountInfo(params.Ctx, params.StoreID, params.LastHours, params.LastMinutes, params.IsIncludeFake) return retVal, "", err }) } // @Title 得到订单SKU信息 // @Description 得到订单SKU信息 // @Param token header string true "认证token" // @Param vendorOrderID query string true "订单ID" // @Param vendorID query int true "订单所属的厂商ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetOrderSkuInfo [get] func (c *OrderController) GetOrderSkuInfo() { c.callGetOrderSkuInfo(func(params *tOrderGetOrderSkuInfoParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.FixedOrderManager.GetOrderSkuInfo(params.Ctx, params.VendorOrderID, params.VendorID) return retVal, "", err }) } // @Title 得到订单详情 // @Description 得到订单详情 // @Param token header string true "认证token" // @Param vendorOrderID query string true "订单ID" // @Param vendorID query int true "订单所属的厂商ID" // @Param refresh query bool false "是否从购物平台刷新数据" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetOrderInfo [get] func (c *OrderController) GetOrderInfo() { c.callGetOrderInfo(func(params *tOrderGetOrderInfoParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.FixedOrderManager.GetOrderInfo(params.Ctx, params.VendorOrderID, params.VendorID, params.Refresh) return retVal, "", err }) } // @Title 得到订单运单信息 // @Description 得到订单运单信息 // @Param token header string true "认证token" // @Param vendorOrderID query string true "订单ID" // @Param vendorID query int true "订单所属的厂商ID" // @Param isNotEnded query bool false "是否只是没有结束的运单" // @Param isGetPos query bool false "是否得到骑手位置" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetOrderWaybillInfo [get] func (c *OrderController) GetOrderWaybillInfo() { c.callGetOrderWaybillInfo(func(params *tOrderGetOrderWaybillInfoParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.FixedOrderManager.GetOrderWaybillInfo(params.Ctx, params.VendorOrderID, params.VendorID, params.IsNotEnded, params.IsGetPos) return retVal, "", err }) } // @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 导出美团运单 // @Description 导出美团运单(excel文件),注意时间跨度不要太长,最多只能是一个月 // @Param token header string true "认证token" // @Param fromDate query string true "开始日期(包含),格式(2006-01-02)" // @Param toDate query string false "结束日期(包含),格式(2006-01-02)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /ExportMTWaybills [get] func (c *OrderController) ExportMTWaybills() { var content []byte var fromDate, toDate string c.callExportMTWaybills(func(params *tOrderExportMTWaybillsParams) (retVal interface{}, errCode string, err error) { fromDate = params.FromDate toDate = params.ToDate if toDate == "" { toDate = fromDate } content, err = orderman.FixedOrderManager.ExportMTWaybills(params.Ctx, params.FromDate, params.ToDate) globals.SugarLogger.Debug(err) return retVal, model.ErrorCodeIgnore, err }) if content != nil { c.Ctx.ResponseWriter.Header().Set("Content-Type", "application/vnd.ms-excel") fileName := strings.Replace(fmt.Sprintf("attachment;filename=美团运单表%s至%sat%s.xlsx", fromDate, toDate, utils.Time2Str(time.Now())), " ", "-", 1) c.Ctx.ResponseWriter.Header().Set("content-disposition", fileName) c.Ctx.ResponseWriter.Write(content) } } // @Title 查询订单 // @Description 查询订单 // @Param token header string true "认证token" // @Param orderID query string false "订单号,如果此项不为空,忽略其它所有查询条件(此项会废弃,用vendorOderID)" // @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件" // @Param keyword query string false "查询关键字" // @Param fromDate query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" // @Param toDate query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" // @Param isDateFinish query bool false "是否fromDate与toDate指的是订单结束日期,缺省不是" // @Param vendorIDs query string false "订单所属厂商列表[1,2,3],缺省不限制" // @Param waybillVendorIDs query string false "承运人所属厂商列表[1,2,3],缺省不限制" // @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制" // @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" // @Param lockStatuss query string false "订单锁定状态列表[1,2,3],缺省不限制" // @Param cities query string false "城市code列表[1,2,3],缺省不限制" // @Param isIncludeFake query bool false "是否包括假订单" // @Param skuIDs query string false "包含的skuID列表,或的关系" // @Param isJxFirst query bool false "排序是否京西订单优先(缺省为否)" // @Param adjustCount query int false "最小调整次数" // @Param mustInvoice query bool false "是否必须要求开发票" // @Param offset query int false "结果起始序号(以0开始,缺省为0)" // @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetOrders [get,post] func (c *OrderController) GetOrders() { c.callGetOrders(func(params *tOrderGetOrdersParams) (retVal interface{}, errCode string, err error) { var skuIDs []int if err = jxutils.Strings2Objs(params.SkuIDs, &skuIDs); err == nil { retVal, err = orderman.FixedOrderManager.GetOrders(params.Ctx, params.IsIncludeFake, params.FromDate, params.ToDate, params.IsDateFinish, skuIDs, params.IsJxFirst, params.MapData, params.Offset, params.PageSize) } return retVal, "", err }) } // @Title 导出订单(包括SKU信息) // @Description 导出订单(包括SKU信息) // @Param token header string true "认证token" // @Param orderID query string false "订单号,如果此项不为空,忽略其它所有查询条件(此项会废弃,用vendorOderID)" // @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件" // @Param keyword query string false "查询关键字" // @Param fromDate query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" // @Param toDate query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" // @Param vendorIDs query string false "订单所属厂商列表[1,2,3],缺省不限制" // @Param waybillVendorIDs query string false "承运人所属厂商列表[1,2,3],缺省不限制" // @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制" // @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" // @Param lockStatuss query string false "订单锁定状态列表[1,2,3],缺省不限制" // @Param cities query string false "城市code列表[1,2,3],缺省不限制" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /ExportOrders [get] func (c *OrderController) ExportOrders() { c.callExportOrders(func(params *tOrderExportOrdersParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.FixedOrderManager.ExportOrders(params.Ctx, params.FromDate, params.ToDate, params.MapData) return retVal, "", err }) } // @Title 查询售后单 // @Description 查询售后单 // @Param token header string true "认证token" // @Param afsOrderID query string false "售后单号,如果此项不为空,忽略其它所有查询条件" // @Param vendorOrderID query string false "订单号,如果此项不为空,忽略其它所有查询条件" // @Param vendorIDs query string false "订单所属厂商列表[1,2,3],缺省不限制" // @Param appealTypes query string false "售后处理s方式列表" // @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制" // @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" // @Param keyword query string false "查询关键字" // @Param fromTime query string false "开始时间,如果订单号为空此项必须要求" // @Param toTime query string false "结束时间,如果订单号为空此项必须要求" // @Param skuIDs query string false "包含的skuID列表,或的关系" // @Param offset query int false "结果起始序号(以0开始,缺省为0)" // @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetAfsOrders [get,post] func (c *OrderController) GetAfsOrders() { c.callGetAfsOrders(func(params *tOrderGetAfsOrdersParams) (retVal interface{}, errCode string, err error) { timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime) if err == nil { var vendorIDList, appealTypeList, storeIDList, statusList, skuIDs []int if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.AppealTypes, &appealTypeList, params.StoreIDs, &storeIDList, params.Statuss, &statusList, params.SkuIDs, &skuIDs); err == nil { retVal, err = orderman.FixedOrderManager.GetAfsOrders(params.Ctx, params.Keyword, params.AfsOrderID, params.VendorOrderID, vendorIDList, appealTypeList, storeIDList, statusList, skuIDs, timeList[0], timeList[1], params.Offset, params.PageSize) } } return retVal, "", err }) } // @Title 得到售后单SKU信息 // @Description 得到售后单SKU信息(订单与售后单必填一项) // @Param token header string true "认证token" // @Param vendorID query int true "售后单所属的厂商ID" // @Param vendorOrderID query string false "订单ID" // @Param afsOrderID query string false "售后单ID" // @Param isNotFaild query bool false "是否查非失败的" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetAfsOrderSkuInfo [get] func (c *OrderController) GetAfsOrderSkuInfo() { c.callGetAfsOrderSkuInfo(func(params *tOrderGetAfsOrderSkuInfoParams) (retVal interface{}, errCode string, err error) { retVal, err = dao.GetAfsOrderSkuInfo(dao.GetDB(), params.VendorOrderID, params.AfsOrderID, params.VendorID, params.IsNotFaild) return retVal, "", err }) } // @Title 查询运单 // @Description 查询运单 // @Param token header string true "认证token" // @Param keyword query string false "查询关键字" // @Param fromDate query string true "开始日期(包含),格式(2006-01-02)" // @Param toDate query string false "结束日期(包含),格式(2006-01-02)" // @Param waybillVendorIDs query string false "承运人所属厂商列表[1,2,3],缺省不限制" // @Param statuss query string false "运单状态列表[1,2,3],缺省不限制" // @Param offset query int false "结果起始序号(以0开始,缺省为0)" // @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetWaybills [get] func (c *OrderController) GetWaybills() { c.callGetWaybills(func(params *tOrderGetWaybillsParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.FixedOrderManager.GetWaybills(params.Ctx, params.FromDate, params.ToDate, params.MapData, params.Offset, params.PageSize) return retVal, "", err }) } // @Title 查询订单/运单事件 // @Description 查询订单/运单事件 // @Param token header string true "认证token" // @Param vendorOrderID query string true "订单/运单ID" // @Param vendorID query int true "订单/运单所属厂商ID)" // @Param orderType query int true "订单:1;运单:2;订单+运单:-1" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetOrderStatusList [get] func (c *OrderController) GetOrderStatusList() { c.callGetOrderStatusList(func(params *tOrderGetOrderStatusListParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.FixedOrderManager.GetOrderStatusList(params.Ctx, params.VendorOrderID, params.VendorID, params.OrderType) return retVal, "", err }) } // @Title 查询门店营业数据 // @Description 查询门店营业数据 // @Param token header string true "认证token" // @Param storeIDs query string false "京西门店ID列表[1,2,3],缺省不限制" // @Param fromTime query string true "起始时间" // @Param toTime query string true "结束时间" // @Param statuss query string false "订单状态列表[1,2,3],缺省不限制" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetStoresOrderSaleInfo [get] func (c *OrderController) GetStoresOrderSaleInfo() { c.callGetStoresOrderSaleInfo(func(params *tOrderGetStoresOrderSaleInfoParams) (retVal interface{}, errCode string, err error) { timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime) if err == nil { var storeIDList []int var statusList []int if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.Statuss, &statusList); err == nil { retVal, err = orderman.FixedOrderManager.GetStoresOrderSaleInfo(params.Ctx, storeIDList, timeList[0], timeList[1], statusList) } } return retVal, "", err }) } // @Title 刷新订单真实手机号 // @Description 刷新订单真实手机号 // @Param token header string true "认证token" // @Param vendorID formData int true "厂商ID" // @Param fromTime formData string true "起始时间" // @Param toTime formData string false "结束时间" // @Param isAsync formData bool true "是否异步操作" // @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /RefreshOrderRealMobile [put] func (c *OrderController) RefreshOrderRealMobile() { c.callRefreshOrderRealMobile(func(params *tOrderRefreshOrderRealMobileParams) (retVal interface{}, errCode string, err error) { timeList, err2 := jxutils.BatchStr2Time(params.FromTime, params.ToTime) if err = err2; err == nil { retVal, err = misc.RefreshRealMobile(params.Ctx, params.VendorID, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) } return retVal, "", err }) } // @Title 刷新订单平台结算信息 // @Description 刷新订单平台结算信息 // @Param token header string true "认证token" // @Param fromTime formData string true "起始时间" // @Param toTime formData string false "结束时间" // @Param isAsync formData bool true "是否异步操作" // @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /RefreshOrderFinancial [put] func (c *OrderController) RefreshOrderFinancial() { c.callRefreshOrderFinancial(func(params *tOrderRefreshOrderFinancialParams) (retVal interface{}, errCode string, err error) { timeList, err2 := jxutils.BatchStr2Time(params.FromTime, params.ToTime) if err = err2; err == nil { retVal, err = orderman.FixedOrderManager.RefreshOrderFinancial(params.Ctx, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) } return retVal, "", err }) } // @Title 设置订单打印状态 // @Description 同步商家SKU类别 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单/运单ID" // @Param vendorID formData int true "订单/运单所属厂商ID)" // @Param isPrinted formData bool true "是否打印" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /SetOrderPrintStatus [put] func (c *OrderController) SetOrderPrintStatus() { c.callSetOrderPrintStatus(func(params *tOrderSetOrderPrintStatusParams) (retVal interface{}, errCode string, err error) { err = dao.SetOrderPrintFlag(dao.GetDB(), params.Ctx.GetUserName(), params.VendorOrderID, params.VendorID, params.IsPrinted) return retVal, "", err }) } // @Title 网络打印订单 // @Description 网络打印订单 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单/运单ID" // @Param vendorID formData int true "订单/运单所属厂商ID)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /PrintOrder [put] func (c *OrderController) PrintOrder() { c.callPrintOrder(func(params *tOrderPrintOrderParams) (retVal interface{}, errCode string, err error) { retVal, err = netprinter.PrintOrder(params.Ctx, params.VendorOrderID, params.VendorID) return retVal, "", err }) } // @Title 查询网络打印机状态 // @Description 查询网络打印机状态 // @Param token header string true "认证token" // @Param storeID query int true "门店ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetPrinterStatus [get] func (c *OrderController) GetPrinterStatus() { c.callGetPrinterStatus(func(params *tOrderGetPrinterStatusParams) (retVal interface{}, errCode string, err error) { retVal, err = netprinter.GetNetPrinterStatus(params.Ctx, params.StoreID) return retVal, "", err }) } func skuList2Map(skuList []*model.OrderSku) (skuCount int, skuMap map[int64]*model.OrderSku, outSkuList []*model.OrderSku) { skuMap = make(map[int64]*model.OrderSku) for _, sku := range skuList { skuCount += sku.Count skuID := jxutils.GetSkuIDFromOrderSku(sku) if sku.SkuID > 0 { index := jxutils.Combine2Int(skuID, sku.StoreSubID) if skuMap[index] == nil { tmpSku := *sku skuMap[index] = &tmpSku outSkuList = append(outSkuList, skuMap[index]) } else { skuMap[index].Count += sku.Count } } } return skuCount, skuMap, outSkuList } func getSkuFromMap(skuMap map[int64]*model.OrderSku, skuID, actID int) (sku *model.OrderSku) { if sku = skuMap[jxutils.Combine2Int(skuID, actID)]; sku == nil && actID != 0 { sku = skuMap[jxutils.Combine2Int(skuID, 0)] } return sku } // @Title 调整订单 // @Description 调整订单 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属厂商ID" // @Param removedSkuInfo formData string true "要去除的商品信息,只有skuID与Count字段有效" // @Param reason formData string true "调整原因" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /AdjustOrder [put] func (c *OrderController) AdjustOrder() { c.callAdjustOrder(func(params *tOrderAdjustOrderParams) (retVal interface{}, errCode string, err error) { var skuList []*model.OrderSku err = jxutils.Strings2Objs(params.RemovedSkuInfo, &skuList) if err == nil { _, _, skuList = skuList2Map(skuList) var order *model.GoodsOrder order, err = partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) if err == nil { removedAll, err2 := fillSkuList(skuList, order.Skus) if err = err2; err == nil { if removedAll { err = fmt.Errorf("至少要保留一个商品") } else { err = defsch.FixedScheduler.AdjustOrder(params.Ctx, order, skuList, params.Reason) } } } } return retVal, "", err }) } // @Title 取消订单 // @Description 取消订单 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属厂商ID" // @Param reason formData string false "取消原因" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /CancelOrder [put] func (c *OrderController) CancelOrder() { c.callCancelOrder(func(params *tOrderCancelOrderParams) (retVal interface{}, errCode string, err error) { order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) if err == nil { err = defsch.FixedScheduler.CancelOrder(params.Ctx, order, params.Reason) } return retVal, "", err }) } // @Title 审核取货失败 // @Description 审核取货失败 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属厂商ID" // @Param acceptIt formData bool true "是否批准" // @Param reason formData string false "原因" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /AcceptOrRefuseFailedGetOrder [put] func (c *OrderController) AcceptOrRefuseFailedGetOrder() { c.callAcceptOrRefuseFailedGetOrder(func(params *tOrderAcceptOrRefuseFailedGetOrderParams) (retVal interface{}, errCode string, err error) { order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) if err == nil { err = defsch.FixedScheduler.AcceptOrRefuseFailedGetOrder(params.Ctx, order, params.AcceptIt, params.Reason) } return retVal, "", err }) } // @Title 取货失败后再次招唤平台配送 // @Description 取货失败后再次招唤平台配送 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属厂商ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /CallPMCourier [put] func (c *OrderController) CallPMCourier() { c.callCallPMCourier(func(params *tOrderCallPMCourierParams) (retVal interface{}, errCode string, err error) { order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) if err == nil { err = defsch.FixedScheduler.CallPMCourier(params.Ctx, order) } return retVal, "", err }) } // @Title 投递失败后确认收到退货 // @Description 投递失败后确认收到退货 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属厂商ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /ConfirmReceiveGoods [put] func (c *OrderController) ConfirmReceiveGoods() { c.callConfirmReceiveGoods(func(params *tOrderConfirmReceiveGoodsParams) (retVal interface{}, errCode string, err error) { order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) if err == nil { err = defsch.FixedScheduler.ConfirmReceiveGoods(params.Ctx, order) } return retVal, "", err }) } // @Title 同意或拒绝用户取消订单申请 // @Description 同意或拒绝用户取消订单申请 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属厂商ID" // @Param acceptIt formData bool true "是否批准" // @Param reason formData string false "原因" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /AgreeOrRefuseCancel [put] func (c *OrderController) AgreeOrRefuseCancel() { c.callAgreeOrRefuseCancel(func(params *tOrderAgreeOrRefuseCancelParams) (retVal interface{}, errCode string, err error) { order, err := partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) if err == nil { if err = defsch.FixedScheduler.AgreeOrRefuseCancel(params.Ctx, order, params.AcceptIt, params.Reason); err == nil /*&& params.AcceptIt*/ { order.LockStatus = model.OrderStatusUnknown err = partner.CurOrderManager.UpdateOrderFields(order, []string{"LockStatus"}) } } return retVal, "", err }) } // @Title 审核售后单申请 // @Description 审核售后单申请 // @Param token header string true "认证token" // @Param afsOrderID formData string true "售后ID" // @Param vendorID formData int true "订单所属厂商ID" // @Param approveType formData int true "操作类型" // @Param reason formData string false "原因" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /AgreeOrRefuseRefund [put] func (c *OrderController) AgreeOrRefuseRefund() { c.callAgreeOrRefuseRefund(func(params *tOrderAgreeOrRefuseRefundParams) (retVal interface{}, errCode string, err error) { err = defsch.FixedScheduler.AgreeOrRefuseRefund(params.Ctx, params.AfsOrderID, params.VendorID, params.ApproveType, params.Reason) return retVal, "", err }) } // @Title 确认收到售后退货 // @Description 确认收到售后退货 // @Param token header string true "认证token" // @Param afsOrderID formData string true "售后ID" // @Param vendorID formData int true "订单所属厂商ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /ConfirmReceivedReturnGoods [put] func (c *OrderController) ConfirmReceivedReturnGoods() { c.callConfirmReceivedReturnGoods(func(params *tOrderConfirmReceivedReturnGoodsParams) (retVal interface{}, errCode string, err error) { err = defsch.FixedScheduler.ConfirmReceivedReturnGoods(params.Ctx, params.AfsOrderID, params.VendorID) return retVal, "", err }) } // @Title 得到门店售后单信息 // @Description 得到门店售后单信息 // @Param token header string true "认证token" // @Param storeID query int true "京西门店ID" // @Param lastHours query int false "最近多少小时的信息(缺省为两天)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetStoreAfsOrderCountInfo [get] func (c *OrderController) GetStoreAfsOrderCountInfo() { c.callGetStoreAfsOrderCountInfo(func(params *tOrderGetStoreAfsOrderCountInfoParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.FixedOrderManager.GetStoreAfsOrderCountInfo(params.Ctx, params.StoreID, params.LastHours) return retVal, "", err }) } // @Title 补全遗漏的订单 // @Description 补全遗漏的订单 // @Param token header string true "认证token" // @Param fromDate formData string true "订单起始日期" // @Param toDate formData string false "订单结束日期" // @Param vendorIDs formData string false "订单所属的厂商ID列表" // @Param storeID formData int false "门店ID" // @Param isAsync formData bool false "是否异步操作" // @Param isContinueWhenError formData bool false "单个失败是否继续,缺省true" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /AmendMissingOrders [post] func (c *OrderController) AmendMissingOrders() { c.callAmendMissingOrders(func(params *tOrderAmendMissingOrdersParams) (retVal interface{}, errCode string, err error) { timeList, err := jxutils.BatchStr2Time(params.FromDate, params.ToDate) if err == nil { var vendorIDs []int if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs); err == nil { retVal, err = orderman.FixedOrderManager.AmendMissingOrders(params.Ctx, vendorIDs, params.StoreID, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) } } return retVal, "", err }) } // @Title 同步刷新历史订单的结算价按订单 // @Description 同步刷新历史订单的结算价按订单 // @Param token header string true "认证token" // @Param fromTime formData string false "订单起始时间 (yyyy-mm-dd hh:ms:ss)" // @Param toTime formData string false "订单结束时间 (yyyy-mm-dd hh:ms:ss)" // @Param vendorOrderID formData string false "订单号" // @Param vendorIDs formData string false "平台ID列表[0,1,3]" // @Param actID formData int false "活动ID" // @Param storeID formData int false "门店ID" // @Param isAsync formData bool false "是否异步操作" // @Param isContinueWhenError formData bool false "单个失败是否继续,缺省true" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /RefreshHistoryOrdersEarningPrice [post] func (c *OrderController) RefreshHistoryOrdersEarningPrice() { c.callRefreshHistoryOrdersEarningPrice(func(params *tOrderRefreshHistoryOrdersEarningPriceParams) (retVal interface{}, errCode string, err error) { var vendorIDList []int if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil { retVal, errCode, err = orderman.FixedOrderManager.RefreshHistoryOrdersEarningPrice(params.Ctx, params.VendorOrderID, params.ActID, vendorIDList, params.StoreID, params.FromTime, params.ToTime, params.IsAsync, params.IsContinueWhenError) } return retVal, errCode, err }) } // @Title 商家主动发起部分退款售后 // @Description 商家主动发起部分退款售后 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属厂商ID" // @Param refundSkuList formData string true "要去除的商品信息,只有skuID与Count字段有效" // @Param reason formData string true "原因" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /PartRefundOrder [put] func (c *OrderController) PartRefundOrder() { c.callPartRefundOrder(func(params *tOrderPartRefundOrderParams) (retVal interface{}, errCode string, err error) { var skuList []*model.OrderSku err = jxutils.Strings2Objs(params.RefundSkuList, &skuList) if err == nil { _, _, skuList = skuList2Map(skuList) var order *model.GoodsOrder order, err = partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) if err == nil { removedAll, err2 := fillSkuList(skuList, order.Skus) if err = err2; err == nil { if removedAll { err = defsch.FixedScheduler.RefundOrder(params.Ctx, order, params.Reason) } else { err = defsch.FixedScheduler.PartRefundOrder(params.Ctx, order, skuList, params.Reason) } } } } return retVal, "", err }) } func fillSkuList(skuList, orderSkuList []*model.OrderSku) (isSame bool, err error) { skuCount, orderSkuMap, _ := skuList2Map(orderSkuList) skuCount2 := 0 for _, sku := range skuList { skuCount2 += sku.Count skuID := jxutils.GetSkuIDFromOrderSku(sku) actID := sku.StoreSubID sku2 := getSkuFromMap(orderSkuMap, skuID, actID) if sku2 == nil { err = fmt.Errorf("找不到SKU:%d", skuID) } else if sku.Count > sku2.Count { err = fmt.Errorf("SKU:%d调整数量:%d大于实际数量:%d", skuID, sku.Count, sku2.Count) } if err != nil { break } else { count := sku.Count *sku = *sku2 sku.Count = count } } return skuCount == skuCount2, err } // @Title 商家主动发起全额退款售后 // @Description 商家主动发起全额退款售后 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属厂商ID" // @Param reason formData string false "退款原因" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /RefundOrder [put] func (c *OrderController) RefundOrder() { c.callRefundOrder(func(params *tOrderRefundOrderParams) (retVal interface{}, errCode string, err error) { order, err := orderman.FixedOrderManager.LoadOrder(params.VendorOrderID, params.VendorID) if err != nil { return nil, "", err } afsSkuList, err := dao.GetAfsOrderSkuInfo(dao.GetDB(), params.VendorOrderID, "", params.VendorID, false) if err != nil { return nil, "", err } order = jxutils.RemoveSkuFromOrder(order, afsSkus2OrderSkus(afsSkuList)) err = defsch.FixedScheduler.RefundOrder(params.Ctx, order, params.Reason) return retVal, "", err }) } func afsSkus2OrderSkus(afsSkuList []*model.OrderFinancialSkuExt) (skuList []*model.OrderSku) { for _, v := range afsSkuList { if v.IsAfsOrder == 1 { skuList = append(skuList, &model.OrderSku{ SkuID: v.SkuID, VendorSkuID: v.VendorSkuID, Count: v.Count, }) } } return skuList } // @Title 订单门店归属补漏 // @Description 订单门店归属补漏 // @Param token header string true "认证token" // @Param fromDate formData string false "开始日期" // @Param toDate formData string false "结束日期(缺省不限制)" // @Param isAsync formData bool false "是否异步操作" // @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /RefreshOrdersWithoutJxStoreID [post] func (c *OrderController) RefreshOrdersWithoutJxStoreID() { c.callRefreshOrdersWithoutJxStoreID(func(params *tOrderRefreshOrdersWithoutJxStoreIDParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.RefreshOrdersWithoutJxStoreID(params.Ctx, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError) return retVal, "", err }) } // @Title 获取投诉原因 // @Description 获取投诉原因 // @Param token header string true "认证token" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetComplaintReasons [get] func (c *OrderController) GetComplaintReasons() { c.callGetComplaintReasons(func(params *tOrderGetComplaintReasonsParams) (retVal interface{}, errCode string, err error) { retVal = orderman.GetComplaintReasons() return retVal, "", err }) } // @Title 投诉骑手(三方运送) // @Description 投诉骑手(三方运送) // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单所属厂商ID" // @Param waybillVendorID formData int true "运单所属厂商ID" // @Param complaintID formData int true "投诉原因ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /ComplaintRider [post] func (c *OrderController) ComplaintRider() { c.callComplaintRider(func(params *tOrderComplaintRiderParams) (retVal interface{}, errCode string, err error) { err = orderman.ComplaintRider(params.Ctx, params.VendorOrderID, params.VendorID, params.WaybillVendorID, params.ComplaintID) return retVal, "", err }) } // @Title 查询门店订单扣款记录 // @Description 查询门店订单扣款记录 // @Param token header string true "认证token" // @Param storeIDs query string false "门店ID列表" // @Param vendorOrderID query string false "订单ID" // @Param vendorIDs query string false "订单所属厂商ID列表" // @Param fromTime query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" // @Param toTime query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" // @Param statuss query string false "账单状态列表,0是未结账,1是已结账,-1为作废" // @Param type query int false "扣款类型,1为差评补贴,2为优惠券" // @Param isReverse query int false "只查冲账记录,0为默认都查,1为只查冲账,-1为不查冲账" // @Param offset query int false "结果起始序号(以0开始,缺省为0)" // @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetOrdersSupplement [get] func (c *OrderController) GetOrdersSupplement() { var vendorIDList, storeIDList, statusList []int c.callGetOrdersSupplement(func(params *tOrderGetOrdersSupplementParams) (retVal interface{}, errCode string, err error) { if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList, params.Statuss, &statusList); err == nil { retVal, err = orderman.GetOrdersSupplement(params.Ctx, storeIDList, vendorIDList, statusList, params.VendorOrderID, params.FromTime, params.ToTime, params.Type, params.IsReverse, params.Offset, params.PageSize) } return retVal, "", err }) } // @Title 新增修改扣款记录 // @Description 新增修改扣款记录 // @Param token header string true "认证token" // @Param payload formData string true "json数据,格式为OrdersSupplement" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /AddUpdateOrdersSupplement [post] func (c *OrderController) AddUpdateOrdersSupplement() { c.callAddUpdateOrdersSupplement(func(params *tOrderAddUpdateOrdersSupplementParams) (retVal interface{}, errCode string, err error) { ordersSupplement := &model.OrderSupplementFee{} if err = utils.UnmarshalUseNumber([]byte(params.Payload), ordersSupplement); err == nil { retVal, err = orderman.AddUpdateOrdersSupplement(params.Ctx, ordersSupplement) } return retVal, "", err }) } // @Title 重新计算订单结算信息 // @Description 重新计算订单结算信息 // @Param token header string true "认证token" // @Param fromTime formData string true "订单起始时间" // @Param toTime formData string false "订单结束时间" // @Param isAsync formData bool false "是否异步操作" // @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /RefreshOrdersPriceInfo [post] func (c *OrderController) RefreshOrdersPriceInfo() { c.callRefreshOrdersPriceInfo(func(params *tOrderRefreshOrdersPriceInfoParams) (retVal interface{}, errCode string, err error) { timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime) if err == nil { retVal, err = orderman.RefreshOrdersPriceInfo(params.Ctx, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError) } return retVal, "", err }) } // @Title 获取某个门店订单中待拣货商品 // @Description 获取某个门店订单中待拣货商品 // @Param token header string true "认证token" // @Param storeID query int true "门店ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetOrdersAccept [get] func (c *OrderController) GetOrdersAccept() { c.callGetOrdersAccept(func(params *tOrderGetOrdersAcceptParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.GetOrdersAccept(params.Ctx, params.StoreID) return retVal, "", err }) } // @Title 获取某个门店上次申请物料到现在的销量 // @Description 获取某个门店上次申请物料到现在的销量 // @Param token header string false "认证token" // @Param storeID query int true "门店ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetMatterStoreOrderCount [get] func (c *OrderController) GetMatterStoreOrderCount() { c.callGetMatterStoreOrderCount(func(params *tOrderGetMatterStoreOrderCountParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.GetMatterStoreOrderCount(params.Ctx, params.StoreID) return retVal, "", err }) } // @Title 刷新京东商城订单结算价 // @Description 刷新京东商城订单结算价 // @Param token header string true "认证token" // @Param fromTime formData string true "订单起始时间 格式:20060102" // @Param toTime formData string true "订单结束时间" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /RefreshJdShopOrdersEarningPrice [put] func (c *OrderController) RefreshJdShopOrdersEarningPrice() { c.callRefreshJdShopOrdersEarningPrice(func(params *tOrderRefreshJdShopOrdersEarningPriceParams) (retVal interface{}, errCode string, err error) { err = orderman.RefreshJdShopOrdersEarningPrice(params.Ctx, params.FromTime, params.ToTime) return retVal, "", err }) } // @Title 根据订单号查询一些信息 // @Description 根据订单号查询一些信息 // @Param token header string false "认证token" // @Param vendorOrderID query string true "订单号" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetOrderSimpleInfo [get] func (c *OrderController) GetOrderSimpleInfo() { c.callGetOrderSimpleInfo(func(params *tOrderGetOrderSimpleInfoParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.GetOrderSimpleInfo(params.Ctx, params.VendorOrderID) return retVal, "", err }) } // @Title 根据订单号查询用户是否是第一次购买 // @Description 根据订单号查询用户是否是第一次购买 // @Param token header string true "认证token" // @Param vendorOrderID query string true "订单号" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetOrderUserBuyFirst [get] func (c *OrderController) GetOrderUserBuyFirst() { c.callGetOrderUserBuyFirst(func(params *tOrderGetOrderUserBuyFirstParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.GetOrderUserBuyFirst(params.Ctx, params.VendorOrderID) return retVal, "", err }) } // @Title 京东商城订单转移 // @Description 京东商城订单转移 // @Param token header string true "认证token" // @Param storeID formData int true "转移的门店ID" // @Param vendorOrderID formData string true "转移的订单号" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /TransferJdsOrder [post] func (c *OrderController) TransferJdsOrder() { c.callTransferJdsOrder(func(params *tOrderTransferJdsOrderParams) (retVal interface{}, errCode string, err error) { retVal, err = orderman.TransferJdsOrder(params.Ctx, params.VendorOrderID, params.StoreID) return retVal, "", err }) } // @Title 合并订单(京东商城用) // @Description 合并订单(京东商城用) // @Param token header string true "认证token" // @Param vendorOrderIDs formData string true "订单号s" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /MergeJdsOrders [post] func (c *OrderController) MergeJdsOrders() { c.callMergeJdsOrders(func(params *tOrderMergeJdsOrdersParams) (retVal interface{}, errCode string, err error) { var vendorOrderIDs []string if err = jxutils.Strings2Objs(params.VendorOrderIDs, &vendorOrderIDs); err == nil { retVal, err = orderman.MergeJdsOrders(params.Ctx, vendorOrderIDs) } return retVal, "", err }) } // @Title 京东商城订单发送京东物流 // @Description 京东商城订单发送京东物流 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单号" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /SendJdwlForJdsOrder [post] func (c *OrderController) SendJdwlForJdsOrder() { c.callSendJdwlForJdsOrder(func(params *tOrderSendJdwlForJdsOrderParams) (retVal interface{}, errCode string, err error) { err = orderman.SendJdwlForJdsOrder(params.Ctx, params.VendorOrderID) return retVal, "", err }) } // @Title 手动拉取京东商城订单 // @Description 手动拉取京东商城订单 // @Param token header string true "认证token" // @Param fromTime formData string true "订单起始时间" // @Param toTime formData string true "订单结束时间" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /SaveJdsOrders [post] func (c *OrderController) SaveJdsOrders() { c.callSaveJdsOrders(func(params *tOrderSaveJdsOrdersParams) (retVal interface{}, errCode string, err error) { err = orderman.SaveJdsOrders(params.Ctx, utils.Str2Time(params.FromTime), utils.Str2Time(params.ToTime)) return retVal, "", err }) } // @Title 针对京东商城进行简单的售前删除操作 // @Description 针对京东商城进行简单的售前删除操作 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单号" // @Param skuID formData int true "商品ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /AdjustJdsOrderSimple [post] func (c *OrderController) AdjustJdsOrderSimple() { c.callAdjustJdsOrderSimple(func(params *tOrderAdjustJdsOrderSimpleParams) (retVal interface{}, errCode string, err error) { err = orderman.AdjustJdsOrderSimple(params.Ctx, params.VendorOrderID, params.SkuID) return retVal, "", err }) } // @Title 修改订单运费 // @Description 修改订单运费 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单号" // @Param desiredFee formData int true "运费" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /UpdateWaybillDesiredFee [put] func (c *OrderController) UpdateWaybillDesiredFee() { c.callUpdateWaybillDesiredFee(func(params *tOrderUpdateWaybillDesiredFeeParams) (retVal interface{}, errCode string, err error) { err = orderman.UpdateWaybillDesiredFee(params.Ctx, params.VendorOrderID, params.DesiredFee) return retVal, "", err }) } // @Title 接单或拒单 // @Description 接单或拒单 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Param vendorID formData int true "订单平台ID" // @Param isAccept formData bool true "接单或者拒单" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /AcceptOrRefuseOrder [post] func (c *OrderController) AcceptOrRefuseOrder() { c.callAcceptOrRefuseOrder(func(params *tOrderAcceptOrRefuseOrderParams) (retVal interface{}, errCode string, err error) { err = orderman.AcceptOrRefuseOrder(params.Ctx, params.VendorOrderID, params.VendorID, params.IsAccept) return retVal, "", err }) } // @Title 刷新京东商城订单收货人信息 // @Description 刷新京东商城订单收货人信息 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /RefreshJdsOrderConsigneeInfo [put] func (c *OrderController) RefreshJdsOrderConsigneeInfo() { c.callRefreshJdsOrderConsigneeInfo(func(params *tOrderRefreshJdsOrderConsigneeInfoParams) (retVal interface{}, errCode string, err error) { err = orderman.RefreshJdsOrderConsigneeInfo(params.Ctx, params.VendorOrderID) return retVal, "", err }) } // @Title 修改订单信息 // @Description 修改订单信息 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单号" // @Param vendorID formData int true "平台ID" // @Param payload formData string true "json数据,格式为goodsOrder" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /UpdateOrderInfo [put] func (c *OrderController) UpdateOrderInfo() { c.callUpdateOrderInfo(func(params *tOrderUpdateOrderInfoParams) (retVal interface{}, errCode string, err error) { payload := make(map[string]interface{}) if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil { retVal, err = orderman.UpdateOrderInfo(params.Ctx, params.VendorOrderID, params.VendorID, payload) } return retVal, "", err }) }