diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index f36005d9d..b91d3b36d 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -50,12 +50,12 @@ func (c *OrderManager) GetStoreOrderInfo(ctx *jxcontext.Context, storeID string, 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.jx_store_id != 0, t1.jx_store_id, t1.store_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 ? - `, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour), fromStatus, toStatus, pageSize, offset).QueryRows(&orders) + `, model.VendorIDWSC, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour), fromStatus, toStatus, pageSize, offset).QueryRows(&orders) if err == nil { return orders, nil } @@ -75,11 +75,11 @@ func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID st _, err = db.Raw(` SELECT t1.status, COUNT(*) count FROM goods_order t1 - WHERE t1.vendor_id <> 2 AND IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_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 >= ? GROUP BY 1 ORDER BY 1 - `, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour)).QueryRows(&countInfo) + `, model.VendorIDWSC, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour)).QueryRows(&countInfo) if err == nil { return countInfo, nil } @@ -244,14 +244,14 @@ func (c *OrderManager) ExportMTWaybills(ctx *jxcontext.Context, fromDateStr, toD toDate = toDate.Add(24 * time.Hour) var waybills []*tWaybillExt sql := ` - SELECT t1.*, t2.store_name, IF(t2.store_id <> 0, t2.store_id, t2.jx_store_id) store_id + SELECT t1.*, t2.store_name, IF(t1.vendor_id = ?, t1.store_id, IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) ) store_id FROM waybill t1 JOIN goods_order t2 ON t1.vendor_order_id = t2.vendor_order_id WHERE t1.waybill_vendor_id = 102 AND t1.status = 105 AND t1.waybill_created_at >= ? AND t1.waybill_created_at <= ? ORDER BY t1.id ` db := dao.GetDB() - if err = dao.GetRows(db, &waybills, sql, fromDate, toDate); err == nil { + if err = dao.GetRows(db, &waybills, sql, model.VendorIDWSC, fromDate, toDate); err == nil { config := []*excel.Obj2ExcelSheetConfig{ &excel.Obj2ExcelSheetConfig{ Title: "Sheet1", @@ -351,8 +351,8 @@ func (c *OrderManager) GetOrders(ctx *jxcontext.Context, fromDateStr, toDateStr return nil, err } if len(storeIDs) > 0 { - sqlWhere += " AND IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")" - sqlParams = append(sqlParams, storeIDs) + sqlWhere += " AND IF(t1.vendor_id = ?, t1.store_id, IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) ) IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")" + sqlParams = append(sqlParams, model.VendorIDWSC, storeIDs) } } if params["statuss"] != nil { @@ -424,11 +424,12 @@ func (c *OrderManager) GetWaybills(ctx *jxcontext.Context, fromDateStr, toDateSt } sqlParams := []interface{}{ + model.VendorIDWSC, fromDate, toDate, } sql := ` - SELECT SQL_CALC_FOUND_ROWS t1.*, t2.store_name, IF(t2.store_id <> 0, t2.store_id, t2.jx_store_id) store_id + SELECT SQL_CALC_FOUND_ROWS t1.*, t2.store_name, IF(t1.vendor_id = ?, t1.store_id, IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) ) store_id FROM waybill t1 JOIN goods_order t2 ON t1.vendor_order_id = t2.vendor_order_id WHERE t1.status = 105 AND t1.waybill_created_at >= ? AND t1.waybill_created_at < ?