查询未拣货订单商品统计

This commit is contained in:
苏尹岚
2020-02-21 16:14:16 +08:00
parent 05eb9b6a8e
commit f054243c77
4 changed files with 53 additions and 0 deletions

View File

@@ -872,3 +872,5 @@ func RefreshOrdersPriceInfo(ctx *jxcontext.Context, fromTime, toTime time.Time,
}
return hint, err
}

View File

@@ -47,6 +47,12 @@ type StoresOrderSaleInfo struct {
EarningPrice int64 `json:"earningPrice"` // 预估结算给门店老板的钱
}
type OrderSkusAccept struct {
model.SkuAndName
SumWeight int `json:"sumWeight"`
SumCount int `json:"sumCount"`
}
func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID, lastHours int, isIncludeFake bool) (countInfo []*model.GoodsOrderCountInfo, err error) {
globals.SugarLogger.Debugf("GetStoreOrderCountInfo storeID:%d", storeID)
if lastHours > maxLastHours {
@@ -1138,3 +1144,25 @@ func (c *OrderManager) RefreshOrderFinancial(ctx *jxcontext.Context, fromTime, t
}
return hint, err
}
func GetOrdersAccept(ctx *jxcontext.Context, storeID int) (result []*OrderSkusAccept, err error) {
db := dao.GetDB()
sql := `
SELECT SUM(a.count) sum_count, SUM(a.weight*a.count) sum_weight, c.*, d.name, d.unit, d.prefix
FROM order_sku a
JOIN goods_order b ON b.vendor_order_id = a.vendor_order_id AND b.vendor_id = a.vendor_id
JOIN sku c ON c.id = a.sku_id
JOIN sku_name d ON d.id = c.name_id
WHERE IF(b.store_id = 0,b.jx_store_id,b.store_id) = ?
AND b.status = ?
AND b.order_created_at <= NOW() AND b.order_created_at >= ?
GROUP BY 3
`
sqlParams := []interface{}{
storeID,
model.OrderStatusAccepted,
time.Now().AddDate(0, 0, -1),
}
err = dao.GetRows(db, &result, sql, sqlParams)
return result, err
}

View File

@@ -988,3 +988,17 @@ func (c *OrderController) RefreshOrdersPriceInfo() {
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
})
}

View File

@@ -999,6 +999,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: "GetOrdersAccept",
Router: `/GetOrdersAccept`,
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: "GetOrdersSupplement",