From c22581636d8b7ac2dff95f881649630a46eb3345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 26 Dec 2019 17:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=95=E8=AF=89=E9=AA=91=E6=89=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/dao_order.go | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 76e3a1e3a..7dadf5c58 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1032,7 +1032,7 @@ func GetWayBillByOrderID(db *DaoDB, orderStatus, vendorID, waybillVendorID int, sql := ` SELECT b.* FROM goods_order a - JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id AND b.vendor_id = a.vendor_id + JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id AND b.order_vendor_id = a.vendor_id WHERE a.vendor_order_id = ? AND a.vendor_id = ? ` @@ -1051,3 +1051,52 @@ func GetWayBillByOrderID(db *DaoDB, orderStatus, vendorID, waybillVendorID int, err = GetRows(db, &wayBillList, sql, sqlParams...) return wayBillList, err } + +func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID string, fromTime, toTime time.Time, status, stype, offset, pageSize int) (orderSupplementFee []*model.OrderSupplementFee, totalCount int, err error) { + sql := ` + SELECT SQL_CALC_FOUND_ROWS * + FROM order_supplement_fee + WHERE 1=1 + AND deleted_at = ? + ` + sqlParams := []interface{}{ + utils.DefaultTimeValue, + } + if !utils.IsTimeZero(fromTime) { + sql += " AND supplement_time >= ?" + sqlParams = append(sqlParams, fromTime) + } + if !utils.IsTimeZero(toTime) { + sql += " AND supplement_time <= ?" + sqlParams = append(sqlParams, toTime) + } + if len(storIDs) > 0 { + sql += " AND store_id IN (" + GenQuestionMarks(len(storIDs)) + ")" + sqlParams = append(sqlParams, storIDs) + } + if len(vendorIDs) > 0 { + sql += " AND store_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")" + sqlParams = append(sqlParams, vendorIDs) + } + if vendorOrderID != "" { + sql += " AND vendor_order_id = ?" + sqlParams = append(sqlParams, vendorOrderID) + } + if status >= 0 { + sql += " AND status = ?" + sqlParams = append(sqlParams, status) + } + if stype >= 0 { + sql += " AND type = ?" + sqlParams = append(sqlParams, stype) + } + sql += ` + LIMIT ? OFFSET ?` + sqlParams = append(sqlParams, pageSize, offset) + Begin(db) + defer Commit(db) + if err = GetRows(db, &orderSupplementFee, sql, sqlParams...); err == nil { + totalCount = GetLastTotalRowCount(db) + } + return orderSupplementFee, totalCount, err +}