aa
This commit is contained in:
@@ -852,3 +852,74 @@ func OrderNotifyReport(ctx *jxcontext.Context, storeIDs, brandIDs []int, vendorI
|
||||
}
|
||||
return page, err
|
||||
}
|
||||
|
||||
type OrderDeliveryReportResult struct {
|
||||
model.GoodsOrder
|
||||
DesiredFee int `json:"desiredFee"`
|
||||
}
|
||||
|
||||
func OrderDeliveryReport(ctx *jxcontext.Context, storeIDs, brandIDs []int, vendorID, deliveryVendorID int, keyword string, isFinished bool, fromTime, toTime string, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
results []*OrderDeliveryReportResult
|
||||
)
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS a.*, b.desired_fee
|
||||
FROM goods_order a
|
||||
LEFT JOIN waybill b ON a.vendor_order_id = b.vendor_order_id AND a.waybill_vendor_id = b.waybill_vendor_id
|
||||
LEFT JOIN store c ON c.id = IF(a.jx_store_id = 0, a.store_id, a.jx_store_id)
|
||||
WHERE b.status <> ? AND a.vendor_id <> a.waybill_vendor_id
|
||||
`
|
||||
sqlParams := []interface{}{model.WaybillStatusCanceled}
|
||||
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 c.brand_id IN(` + dao.GenQuestionMarks(len(brandIDs)) + `)`
|
||||
sqlParams = append(sqlParams, brandIDs)
|
||||
}
|
||||
if vendorID != -1 {
|
||||
sql += " AND a.vendor_id = ?"
|
||||
sqlParams = append(sqlParams, vendorID)
|
||||
}
|
||||
if deliveryVendorID != -1 {
|
||||
sql += " AND a.waybill_vendor_id = ?"
|
||||
sqlParams = append(sqlParams, deliveryVendorID)
|
||||
}
|
||||
if keyword != "" {
|
||||
sql += " AND (c.name LIKE ? OR c.id = ? OR a.vendor_order_id = ?)"
|
||||
sqlParams = append(sqlParams, "%"+keyword+"%", keyword, keyword)
|
||||
}
|
||||
if !utils.IsTimeZero(utils.Str2Time(fromTime)) {
|
||||
if isFinished {
|
||||
sql += " AND a.order_finished_at > ?"
|
||||
} else {
|
||||
sql += " AND a.order_created_at > ?"
|
||||
}
|
||||
sqlParams = append(sqlParams, fromTime)
|
||||
}
|
||||
if !utils.IsTimeZero(utils.Str2Time(toTime)) {
|
||||
if isFinished {
|
||||
sql += " AND a.order_finished_at < ?"
|
||||
} else {
|
||||
sql += " AND a.order_created_at < ?"
|
||||
}
|
||||
sqlParams = append(sqlParams, toTime)
|
||||
}
|
||||
sql += `
|
||||
ORDER BY a.order_create_at DESC
|
||||
LIMIT ? OFFSET ?
|
||||
`
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer dao.Commit(db, txDB)
|
||||
if err = dao.GetRowsTx(txDB, &results, sql, sqlParams...); err == nil {
|
||||
page = &model.PagedInfo{
|
||||
TotalCount: dao.GetLastTotalRowCount2(db, txDB),
|
||||
Data: results,
|
||||
}
|
||||
}
|
||||
return page, err
|
||||
}
|
||||
|
||||
@@ -184,3 +184,29 @@ func (c *ReportController) OrderNotifyReport() {
|
||||
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 deliveryVendorID query int false "配送平台ID"
|
||||
// @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 /OrderDeliveryReport [get]
|
||||
func (c *ReportController) OrderDeliveryReport() {
|
||||
c.callOrderDeliveryReport(func(params *tReportOrderDeliveryReportParams) (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.OrderDeliveryReport(params.Ctx, storeIDs, brandIDs, params.VendorID, params.DeliveryVendorID, params.Keyword, params.IsFinished, params.FromTime, params.ToTime, params.Offset, params.PageSize)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1719,6 +1719,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"],
|
||||
web.ControllerComments{
|
||||
Method: "OrderDeliveryReport",
|
||||
Router: `/OrderDeliveryReport`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"],
|
||||
web.ControllerComments{
|
||||
Method: "PriceRefer",
|
||||
|
||||
Reference in New Issue
Block a user