From 577bed2d926d4e487fb8ab4e740cebf7fcb9d22e Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Fri, 27 Aug 2021 14:57:50 +0800 Subject: [PATCH] aa --- business/jxstore/report/report.go | 71 +++++++++++++++++++++++++++++++ controllers/jx_report.go | 26 +++++++++++ 2 files changed, 97 insertions(+) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 3b4662034..1d1d07034 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -776,3 +776,74 @@ func UserMemberReport(ctx *jxcontext.Context, vendorID int, keyword string, offs } return page, err } + +type OrderNotifyReportResult struct { +} + +func OrderNotifyReport(ctx *jxcontext.Context, storeIDs, brandIDs []int, vendorID, notifyType int, keyword string, isFinished bool, fromTime, toTime string, offset, pageSize int) (page *model.PagedInfo, err error) { + var ( + db = dao.GetDB() + results []*OrderNotifyReportResult + ) + sql := ` + SELECT * + FROM goods_order a + LEFT JOIN store b ON IF(a.store_id = 0 ,a.jx_store_id, a.store_id) = b.id + LEFT JOIN user c ON c.mobile = b.market_man_phone + LEFT JOIN user d ON d.mobile = b.operator_phone + WHERE a.status = ? AND a.notify_type <> ? +` + sqlParams := []interface{}{ + model.OrderStatusFinished, 0, + } + if len(storeIDs) > 0 { + sql += ` AND IF(a.jx_store_id != 0, a.jx_store_id, a.store_id) IN(` + dao.GenQuestionMarks(len(storeIDs)) + `)` + sqlParams = append(sqlParams, storeIDs) + } + if len(brandIDs) > 0 { + sql += ` AND b.brand_id IN(` + dao.GenQuestionMarks(len(brandIDs)) + `)` + sqlParams = append(sqlParams, brandIDs) + } + if vendorID != -1 { + sql += " AND a.vendor_id = ?" + sqlParams = append(sqlParams, vendorID) + } + if notifyType != -1 { + sql += " AND a.notify_type = ?" + sqlParams = append(sqlParams, notifyType) + } + if keyword != "" { + sql += " AND (b.name LIKE ? OR c.name LIKE ? OR d.name LIKE ? OR b.id = ? OR a.vendor_order_id = ?)" + sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", keyword, keyword) + } + if !utils.IsTimeZero(utils.Str2Time(fromTime)) { + if isFinished { + sql += " AND a.order_finished_at > ?" + } else { + sql += " AND a.order_created_at > ?" + } + } + if !utils.IsTimeZero(utils.Str2Time(toTime)) { + if isFinished { + sql += " AND a.order_finished_at < ?" + } else { + sql += " AND a.order_created_at < ?" + } + } + sql += ` + LIMIT ? OFFSET ? + ` + pageSize = jxutils.FormalizePageSize(pageSize) + sqlParams = append(sqlParams, pageSize, offset) + txDB, _ := dao.Begin(db) + defer dao.Commit(db, txDB) + fmt.Println(sql) + fmt.Println(sqlParams) + if err = dao.GetRowsTx(txDB, &results, sql, sqlParams...); err == nil { + page = &model.PagedInfo{ + TotalCount: dao.GetLastTotalRowCount2(db, txDB), + Data: results, + } + } + return nil, err +} diff --git a/controllers/jx_report.go b/controllers/jx_report.go index f8d3b15c3..0a5567af4 100644 --- a/controllers/jx_report.go +++ b/controllers/jx_report.go @@ -158,3 +158,29 @@ func (c *ReportController) UserMemberReport() { return retVal, "", err }) } + +// @Title 统计语音短信收费 +// @Description 统计语音短信收费 +// @Param token header string true "认证token" +// @Param storeIDs query string false "门店ID列表[1,2,3]" +// @Param brandIDs query string false "品牌ID列表[1,2,3]" +// @Param vendorID query int false "平台ID" +// @Param notifyType query int false "-1 表示全部,1表示短信,2表示语音" +// @Param keyword query string false "关键字" +// @Param fromTime query string true "开始日期(包含),格式(2006-01-02 00:00:00)" +// @Param toTime query string true "结束日期(包含),格式(2006-01-02 00:00:00)" +// @Param isFinished query bool false "默认下单时间,true是订单完成时间" +// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" +// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /OrderNotifyReport [get] +func (c *ReportController) OrderNotifyReport() { + c.callOrderNotifyReport(func(params *tReportOrderNotifyReportParams) (retVal interface{}, errCode string, err error) { + var storeIDs, brandIDs []int + if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.BrandIDs, &brandIDs); err == nil { + retVal, err = report.OrderNotifyReport(params.Ctx, storeIDs, brandIDs, params.VendorID, params.NotifyType, params.Keyword, params.IsFinished, params.FromTime, params.ToTime, params.Offset, params.PageSize) + } + return retVal, "", err + }) +}