diff --git a/app/customer/svc/order/svc_central_kitchen_for_school_order.go b/app/customer/svc/order/svc_central_kitchen_for_school_order.go index dc7f083..1444a9f 100644 --- a/app/customer/svc/order/svc_central_kitchen_for_school_order.go +++ b/app/customer/svc/order/svc_central_kitchen_for_school_order.go @@ -14,8 +14,10 @@ import ( ) func OrderList(req md.CentralKitchenForSchoolOrderListReq, platform string) (m []model.CentralKitchenForSchoolPackageOrd, total int64, err error) { - sess := db.Db.Desc("id").Where("user_identity_id =?", req.UserIdentityId). - And("create_at >= ? And create_at <= ?", req.StartDate, req.EndDate).Limit(req.Limit, (req.Page-1)*req.Limit) + sess := db.Db.Desc("id").Where("user_identity_id =?", req.UserIdentityId).Limit(req.Limit, (req.Page-1)*req.Limit) + if req.StartDate != "" && req.EndDate != "" { + sess.And("create_at >= ? And create_at <= ?", req.StartDate, req.EndDate) + } sess.And("ord_state = ?", req.OrdState) if req.OrdState == enum.CentralKitchenForSchoolPackageOrdOrdStateForWait { if platform == "alipay_applet" { @@ -35,16 +37,28 @@ func OrderList(req md.CentralKitchenForSchoolOrderListReq, platform string) (m [ func OrderStatistic(req md.CentralKitchenForSchoolOrderListReq, platform string) (total float64, err error) { var sql = fmt.Sprintf("SELECT SUM(total_price) AS sum_total FROM central_kitchen_for_school_package_ord where "+ - "user_identity_id = '%d' and create_at >= '%s' And create_at <= '%s' and ord_state = '%d'", req.UserIdentityId, req.StartDate, req.EndDate, req.OrdState) - + "user_identity_id = '%d' and ord_state = '%d'", req.UserIdentityId, req.OrdState) + if req.StartDate != "" && req.EndDate != "" { + sql = fmt.Sprintf("SELECT SUM(total_price) AS sum_total FROM central_kitchen_for_school_package_ord where "+ + "user_identity_id = '%d' and create_at >= '%s' And create_at <= '%s' and ord_state = '%d'", req.UserIdentityId, req.StartDate, req.EndDate, req.OrdState) + } if req.OrdState == enum.CentralKitchenForSchoolPackageOrdOrdStateForWait { if platform == "alipay_applet" { sql = fmt.Sprintf("SELECT SUM(total_price) AS sum_total FROM central_kitchen_for_school_package_ord where "+ - "user_identity_id = '%d' and create_at >= '%s' And create_at <= '%s' and ord_state = '%d' and pay_way = '%d'", req.UserIdentityId, req.StartDate, req.EndDate, req.OrdState, enum2.PayWayForAli) + "user_identity_id = '%d' and ord_state = '%d' and pay_way = '%d'", req.UserIdentityId, req.OrdState, enum2.PayWayForAli) + + if req.StartDate != "" && req.EndDate != "" { + sql = fmt.Sprintf("SELECT SUM(total_price) AS sum_total FROM central_kitchen_for_school_package_ord where "+ + "user_identity_id = '%d' and create_at >= '%s' And create_at <= '%s' and ord_state = '%d' and pay_way = '%d'", req.UserIdentityId, req.StartDate, req.EndDate, req.OrdState, enum2.PayWayForAli) + } } if platform == "wx_applet" { sql = fmt.Sprintf("SELECT SUM(total_price) AS sum_total FROM central_kitchen_for_school_package_ord where "+ - "user_identity_id = '%d' and create_at >= '%s' And create_at <= '%s' and ord_state = '%d' and pay_way = '%d'", req.UserIdentityId, req.StartDate, req.EndDate, req.OrdState, enum2.PayWayForWx) + "user_identity_id = '%d' and ord_state = '%d' and pay_way = '%d'", req.UserIdentityId, req.OrdState, enum2.PayWayForWx) + if req.StartDate != "" && req.EndDate != "" { + sql = fmt.Sprintf("SELECT SUM(total_price) AS sum_total FROM central_kitchen_for_school_package_ord where "+ + "user_identity_id = '%d' and create_at >= '%s' And create_at <= '%s' and ord_state = '%d' and pay_way = '%d'", req.UserIdentityId, req.StartDate, req.EndDate, req.OrdState, enum2.PayWayForWx) + } } }