- GetStoreOrderCountInfo2

This commit is contained in:
gazebo
2019-04-23 09:31:36 +08:00
parent f1e900dbd5
commit 58b299de2c
6 changed files with 62 additions and 7 deletions

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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"`

View File

@@ -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与订单对应