Files
jx-callback/controllers/jx_order.go

688 lines
32 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 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 forceCreate formData bool false "是否强制创建(忽略订单状态检查及其它参数)"
// @Param maxAddFee formData int false "最大加价单位为分为0时为缺省值"
// @Param maxDiffFee2Mtps formData int false "最大与美团配送差价单位为分maxAddFee不为0时才可能有效"
// @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.MaxAddFee), int64(params.MaxDiffFee2Mtps))
}
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 "最近多少小时的信息(缺省为两天)"
// @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)
return retVal, "", err
})
}
// @Title 得到门店订单信息2
// @Description 得到门店订单信息2
// @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 /GetStoreOrderCountInfo2 [get]
func (c *OrderController) GetStoreOrderCountInfo2() {
c.callGetStoreOrderCountInfo2(func(params *tOrderGetStoreOrderCountInfo2Params) (retVal interface{}, errCode string, err error) {
retVal, err = orderman.FixedOrderManager.GetStoreOrderCountInfo(params.Ctx, params.StoreID, params.LastHours)
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 "是否只是没有结束的运单"
// @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)
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 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 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]
func (c *OrderController) GetOrders() {
c.callGetOrders(func(params *tOrderGetOrdersParams) (retVal interface{}, errCode string, err error) {
retVal, err = orderman.FixedOrderManager.GetOrders(params.Ctx, params.FromDate, params.ToDate, 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 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]
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 []int
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.AppealTypes, &appealTypeList,
params.StoreIDs, &storeIDList, params.Statuss, &statusList); err == nil {
retVal, err = orderman.FixedOrderManager.GetAfsOrders(params.Ctx, params.Keyword, params.AfsOrderID,
params.VendorOrderID, vendorIDList, appealTypeList, storeIDList, statusList, timeList[0], timeList[1],
params.Offset, params.PageSize)
}
}
return retVal, "", err
})
}
// @Title 得到售后单SKU信息
// @Description 得到售后单SKU信息
// @Param token header string true "认证token"
// @Param afsOrderID query string true "售后单ID"
// @Param vendorID query int true "售后单所属的厂商ID"
// @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 = orderman.FixedOrderManager.GetAfsOrderSkuInfo(params.Ctx, params.AfsOrderID, params.VendorID)
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 同步商家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) (skuMap map[int]*model.OrderSku) {
skuMap = make(map[int]*model.OrderSku)
for _, sku := range skuList {
skuID := jxutils.GetSkuIDFromOrderSku(sku)
if sku.SkuID > 0 {
if skuMap[skuID] == nil {
skuMap[skuID] = sku
} else {
skuMap[skuID].Count += sku.Count
}
}
}
return skuMap
}
// @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 {
var order *model.GoodsOrder
order, err = partner.CurOrderManager.LoadOrder(params.VendorOrderID, params.VendorID)
if err == nil {
orderSkuMap := skuList2Map(order.Skus)
removeSkuMap := skuList2Map(skuList)
for _, sku := range removeSkuMap {
skuID := jxutils.GetSkuIDFromOrderSku(sku)
if orderSkuMap[skuID] == nil {
err = fmt.Errorf("找不到SKU:%d", skuID)
} else if sku.Count > orderSkuMap[skuID].Count {
err = fmt.Errorf("SKU:%d调整数量:%d大于实际数量:%d", skuID, sku.Count, orderSkuMap[skuID].Count)
}
if err != nil {
break
} else {
count := sku.Count
*sku = *orderSkuMap[skuID]
sku.Count = count
}
}
if err == nil {
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
})
}