- GetStoreOrderCountInfo2
This commit is contained in:
@@ -148,7 +148,7 @@ func (c *OrderManager) OnOrderStatusChanged(orderStatus *model.OrderStatus) (err
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
isDuplicated, err := c.addOrderStatus(orderStatus, db)
|
||||
isDuplicated, _, err := c.addOrderStatus(orderStatus, db)
|
||||
if err == nil {
|
||||
dao.Commit(db)
|
||||
if !isDuplicated {
|
||||
@@ -161,7 +161,7 @@ func (c *OrderManager) OnOrderStatusChanged(orderStatus *model.OrderStatus) (err
|
||||
}
|
||||
|
||||
func (c *OrderManager) OnOrderMsg(order *model.GoodsOrder, vendorStatus, remark string) (err error) {
|
||||
_, err = c.addOrderStatus(&model.OrderStatus{
|
||||
_, _, err = c.addOrderStatus(&model.OrderStatus{
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
VendorID: order.VendorID,
|
||||
OrderType: model.OrderTypeOrder,
|
||||
@@ -345,13 +345,13 @@ func (c *OrderManager) updateOrderOtherInfo(order *model.GoodsOrder, db *dao.Dao
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *OrderManager) addOrderStatus(orderStatus *model.OrderStatus, db *dao.DaoDB) (isDuplicated bool, err error) {
|
||||
func (c *OrderManager) addOrderStatus(orderStatus *model.OrderStatus, db *dao.DaoDB) (isDuplicated bool, order *model.GoodsOrder, err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
isDuplicated, err = addOrderOrWaybillStatus(orderStatus, db)
|
||||
if err == nil && !isDuplicated && model.IsOrderImportantStatus(orderStatus.Status) {
|
||||
order := &model.GoodsOrder{
|
||||
order = &model.GoodsOrder{
|
||||
VendorOrderID: orderStatus.VendorOrderID,
|
||||
VendorID: orderStatus.VendorID,
|
||||
}
|
||||
@@ -396,7 +396,7 @@ func (c *OrderManager) addOrderStatus(orderStatus *model.OrderStatus, db *dao.Da
|
||||
}
|
||||
}
|
||||
}
|
||||
return isDuplicated, err
|
||||
return isDuplicated, order, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) loadOrder(vendorOrderID, vendorOrderID2 string, vendorID int) (order *model.GoodsOrder, err error) {
|
||||
|
||||
@@ -27,6 +27,7 @@ type tWaybillExt struct {
|
||||
StoreID int `json:"storeID" orm:"column(store_id)"`
|
||||
}
|
||||
|
||||
//此函数会被GetStoreOrderCountInfo2取代
|
||||
func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID string, lastHours int) (countInfo []*model.GoodsOrderCountInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetStoreOrderCountInfo storeID:%s", storeID)
|
||||
if lastHours > maxLastHours {
|
||||
@@ -51,6 +52,30 @@ func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID st
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetStoreOrderCountInfo2(ctx *jxcontext.Context, storeID, lastHours int) (countInfo []*model.GoodsOrderCountInfo2, err error) {
|
||||
globals.SugarLogger.Debugf("GetStoreOrderCountInfo2 storeID:%s", storeID)
|
||||
if lastHours > maxLastHours {
|
||||
lastHours = maxLastHours
|
||||
} else if lastHours == 0 {
|
||||
lastHours = defLastHours
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
err = dao.GetRows(db, &countInfo, `
|
||||
SELECT t1.lock_status, t1.status, COUNT(*) count
|
||||
FROM goods_order t1
|
||||
WHERE t1.vendor_id <> 2 AND IF(t1.vendor_id = ?, t1.store_id, IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) ) = ?
|
||||
AND t1.order_created_at >= ?
|
||||
GROUP BY 1,2
|
||||
ORDER BY 1,2
|
||||
`, model.VendorIDWSC, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour))
|
||||
if err == nil {
|
||||
return countInfo, nil
|
||||
}
|
||||
globals.SugarLogger.Infof("GetStoreOrderCountInfo2 storeID:%s failed with error:%v", storeID, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int) (skus []*model.OrderSkuExt, err error) {
|
||||
globals.SugarLogger.Debugf("GetOrderSkuInfo orderID:%s", vendorOrderID)
|
||||
|
||||
|
||||
@@ -34,6 +34,12 @@ type GoodsOrderCountInfo struct {
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type GoodsOrderCountInfo2 struct {
|
||||
LockStatus int `json:"lockStatus"`
|
||||
Status int `json:"status"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type SkuMetaInfo struct {
|
||||
Units []string `json:"units"`
|
||||
SpecUnits []string `json:"specUnits"`
|
||||
|
||||
@@ -185,7 +185,7 @@ const (
|
||||
OrderStatusAgreeFailedGetGoods = 18 // 取货失败
|
||||
|
||||
OrderStatusDelivering = 20 // 开始配送,配送员已取货,从这里开始就是运单消息了
|
||||
OrderStatusDeliverFailed = 25 // 投递失败
|
||||
OrderStatusDeliverFailed = 22 // 投递失败
|
||||
|
||||
OrderStatusEndBegin = 100 // 以下的状态就是结束状态
|
||||
OrderStatusFinished = 110 // 订单已完成
|
||||
@@ -210,7 +210,7 @@ const (
|
||||
WaybillStatusAgreeFailedGetGoods = 18 // 取货失败
|
||||
|
||||
WaybillStatusDelivering = 20
|
||||
WaybillStatusDeliverFailed = 25
|
||||
WaybillStatusDeliverFailed = 22
|
||||
|
||||
WaybillStatusEndBegin = 100 // 以下的状态就是结束状态
|
||||
WaybillStatusDelivered = 105 // todo 这个应该改为110,与订单对应
|
||||
|
||||
@@ -125,6 +125,21 @@ func (c *OrderController) GetStoreOrderCountInfo() {
|
||||
})
|
||||
}
|
||||
|
||||
// @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.GetStoreOrderCountInfo2(params.Ctx, params.StoreID, params.LastHours)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到订单SKU信息
|
||||
// @Description 得到订单SKU信息
|
||||
// @Param token header string true "认证token"
|
||||
|
||||
@@ -655,6 +655,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetStoreOrderCountInfo2",
|
||||
Router: `/GetStoreOrderCountInfo2`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetWaybills",
|
||||
|
||||
Reference in New Issue
Block a user