- 去掉重复函数GetGetStoreOrderInfo

- GetOrders中将orderID改为vendorOrderID
This commit is contained in:
gazebo
2019-04-19 10:06:47 +08:00
parent 1ca4d9aef2
commit 976d02727b
3 changed files with 21 additions and 70 deletions

View File

@@ -27,42 +27,6 @@ type tWaybillExt struct {
StoreID int `json:"storeID" orm:"column(store_id)"`
}
// todo 此函数可被GetOrders取代
func (c *OrderManager) GetStoreOrderInfo(ctx *jxcontext.Context, storeID string, lastHours int, fromStatus, toStatus, offset, pageSize int) (orders []*model.GoodsOrderExt, err error) {
globals.SugarLogger.Debugf("GetStoreOrderInfo storeID:%s", storeID)
if lastHours > maxLastHours {
lastHours = maxLastHours
} else if lastHours == 0 {
lastHours = defLastHours
}
if toStatus == 0 {
toStatus = fromStatus
}
if offset < 0 {
offset = 0
}
pageSize = jxutils.FormalizePageSize(pageSize)
db := orm.NewOrm()
_, err = db.Raw(`
SELECT t1.*,
t2.status waybill_status, t2.courier_name, t2.courier_mobile,
t2.actual_fee, t2.desired_fee, t2.waybill_created_at, t2.waybill_finished_at
FROM goods_order t1
LEFT JOIN waybill t2 ON t1.vendor_waybill_id = t2.vendor_waybill_id AND t1.waybill_vendor_id = t2.waybill_vendor_id
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 >= ?
AND t1.Status >= ? AND t1.Status <= ?
ORDER BY t1.status, t1.order_created_at
LIMIT ? OFFSET ?
`, model.VendorIDWSC, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour), fromStatus, toStatus, pageSize, offset).QueryRows(&orders)
if err == nil {
return orders, nil
}
globals.SugarLogger.Infof("GetStoreOrderInfo storeID:%s failed with error:%v", storeID, err)
return nil, err
}
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 {
@@ -252,14 +216,18 @@ func (c *OrderManager) GetOrders(ctx *jxcontext.Context, fromDateStr, toDateStr
// 如果搜索关键字可能为订单号,则当成订单号查询
if params["keyword"] != nil {
if jxutils.GetPossibleVendorIDFromVendorOrderID(params["keyword"].(string)) > model.VendorIDUnknown {
params["orderID"] = params["keyword"]
params["vendorOrderID"] = params["keyword"]
}
}
if params["orderID"] != nil {
if params["orderID"] != nil || params["vendorOrderID"] != nil {
sqlWhere = " WHERE (t1.vendor_order_id = ? OR t1.vendor_order_id2 = ?)"
vendorOrderID := params["vendorOrderID"]
if vendorOrderID == nil {
vendorOrderID = params["orderID"]
}
sqlParams = []interface{}{
params["orderID"],
params["orderID"],
vendorOrderID,
vendorOrderID,
}
} else {
fromDate, err2 := utils.TryStr2Time(fromDateStr)
@@ -338,6 +306,16 @@ func (c *OrderManager) GetOrders(ctx *jxcontext.Context, fromDateStr, toDateStr
sqlParams = append(sqlParams, statuss)
}
}
if params["lockStatuss"] != nil {
var lockStatuss []int
if err = utils.UnmarshalUseNumber([]byte(params["lockStatuss"].(string)), &lockStatuss); err != nil {
return nil, err
}
if len(lockStatuss) > 0 {
sqlWhere += " AND t1.lock_status IN (" + dao.GenQuestionMarks(len(lockStatuss)) + ")"
sqlParams = append(sqlParams, lockStatuss)
}
}
if params["cities"] != nil {
var cities []int
if err = utils.UnmarshalUseNumber([]byte(params["cities"].(string)), &cities); err != nil {