非常感谢您的指教
weixiu-workorder表结构如下
//工单记录列表
{
"bsonType": "object",
"required": ["logistics"],
"permission": {
"read": "auth.uid != null",
"create": "auth.uid != null",
"update": "doc.user_id == auth.uid || doc.maintainer_id != null || 'maintainer' in auth.role",
"delete": false
},
"properties": {
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
"user_id": {
"bsonType": "string",
"description": "报修用户ID",
"title": "报修用户ID",
"foreignKey": "uni-id-users._id",
"defaultValue": {
"$env": "uid"
}
},
"nickname": {
"bsonType": "string",
"description": "用户名",
"title": "报修用户"
},
"mobile": {
"bsonType": "string",
"description": "手机号",
"pattern": "^\\+?[0-9-]{3,20}$",
"title": "手机号",
"trim": "both"
},
"address": {
"bsonType": "string",
"description": "用户地址",
"title": "用户地址",
"trim": "both",
"defaultValue": ""
},
"model": {
"bsonType": "string",
"description": "报修机型",
"title": "报修机型",
"trim": "both",
"defaultValue": ""
},
"number":{
"bsonType": "int",
"description": "报修数量",
"title": "报修数量",
"defaultValue": 0
},
"excerpt": {
"bsonType": "string",
"title": "故障描述",
"description": "故障描述",
"label": "故障描述",
"trim": "right"
},
"remark": {
"bsonType": "string",
"title": "报修备注",
"description": "报修备注",
"label": "报修备注",
"trim": "right"
},
"case_img": {
"bsonType": "array",
"description": "报修案例图片",
"title": "报修案例图片"
},
"logistics": {
"bsonType": "string",
"title": "报修快递",
"description": "报修快递单号",
"label": "报修快递",
"trim": "both"
},
"maintainer_id":{
"bsonType": "string",
"description": "维修人员ID",
"title": "维修人员ID",
"foreignKey": "uni-id-users._id"
},
"maintainer_nickname": {
"bsonType": "string",
"description": "维修人员名称",
"title": "维修人员名称"
},
"maintainer_mobile": {
"bsonType": "string",
"description": "维修人员手机号",
"pattern": "^\\+?[0-9-]{3,20}$",
"title": "维修人员手机号",
"trim": "both"
},
"maintainer_address": {
"bsonType": "string",
"description": "维修人员地址",
"title": "维修人员地址",
"trim": "both",
"defaultValue": ""
},
"shelf_number": {
"bsonType": "string",
"description": "所在货架号",
"title": "所在货架号",
"trim": "both",
"defaultValue": ""
},
"hitch_excerpt": {
"bsonType": "string",
"title": "诊断描述",
"description": "诊断描述",
"label": "诊断描述",
"trim": "right"
},
"hitch_imgs": {
"bsonType": "array",
"description": "诊断图片组",
"title": "诊断图片"
},
"hitch_videos": {
"bsonType": "file",
"description": "用file类型方便使用uni-file-picker组件",
"title": "诊断视频"
},
"material_replace": {
"bsonType": "string",
"title": "材料更换",
"description": "材料更换",
"label": "材料更换",
"trim": "both"
},
"back_logistics": {
"bsonType": "string",
"title": "寄回快递单号",
"description": "寄回快递单号",
"label": "寄回快递",
"trim": "both",
"defaultValue": ""
},
"need_pay": {
"bsonType": "int",
"defaultValue": 0,
"description": "报修收费:0 不需要 1 需要 ",
"title": "需要付费",
"enum": [{
"text": "不需要",
"value": 0
},
{
"text": "需要",
"value": 1
}
],
"permission": {
"read": "auth.uid != null",
"create": "doc.maintainer_id == auth.uid",
"update": "doc.maintainer_id != null",
"delete": false
}
},
"need_pay_fee": {
"bsonType": "int",
"defaultValue": 0,
"description": "维修费用(以分为单位)",
"title": "维修费用",
"permission": {
"read": "auth.uid != null",
"create": "doc.maintainer_id == auth.uid",
"update": "doc.maintainer_id != null",
"delete": false
}
},
"is_payed": {
"bsonType": "bool",
"title": "是否已支付",
"description": "是否已支付",
"defaultValue": false,
"permission": {
"read": "auth.uid != null",
"create": false,
"update": false,
"delete": false
}
},
"payed_no": {
"title": "支付单号ID",
"bsonType": "string",
"description": "支付单号(支付平台订单号,由支付平台控制唯一)",
"trim": "both",
"foreignKey": "uni-pay-orders._id",
"permission": {
"read": "auth.uid != null",
"create": false,
"update": false,
"delete": false
}
},
"payed_fee": {
"bsonType": "int",
"defaultValue": 0,
"description": "已支付费用(以分为单位)",
"title": "已支付费用",
"permission": {
"read": "auth.uid != null",
"create": false,
"update": false,
"delete": false
}
},
"add_date": {
"bsonType": "timestamp",
"title": "新增时间",
"description": "新增时间",
"defaultValue": {
"$env": "now"
}
},
"printnote_date": {
"bsonType": "timestamp",
"description": "打单时间"
},
"acceptorder_date": {
"bsonType": "timestamp",
"description": "接单时间"
},
"quotation_date": {
"bsonType": "timestamp",
"description": "报价时间"
},
"payed_date": {
"bsonType": "timestamp",
"description": "支付时间"
},
"complete_date": {
"bsonType": "timestamp",
"description": "完成时间"
},
"last_modify_date": {
"bsonType": "timestamp",
"title": "最后修改时间",
"description": "最后修改时间",
"defaultValue": {
"$env": "now"
}
},
"last_modify_ip": {
"bsonType": "string",
"description": "最后修改时 IP 地址",
"forceDefaultValue": {
"$env": "clientIP"
}
},
"work_type": {
"bsonType": "int",
"title": "工单类型",
"description": "工单状态: 0 客户报单; 1 后台报单;",
"defaultValue": 0,
"enum": [{
"value": 0,
"text": "客户报单"
}, {
"value": 1,
"text": "后台报单"
}]
},
"order_status": {
"bsonType": "int",
"title": "工单状态",
"description": "工单状态:-3 已取消并寄回; -2 已付寄返费; -1 待付寄返费; 0 待派单; 1 已派单; 2 待付维修费; 3 维修中; 4 已完成",
"defaultValue": 0,
"enum": [{
"value": -3,
"text": "已取消"
},{
"value": -2,
"text": "已付寄返费"
},{
"value": -1,
"text": "待付寄返费"
},{
"value": 0,
"text": "待派单"
}, {
"value": 1,
"text": "已派单"
}, {
"value": 2,
"text": "待付维修费"
}, {
"value": 3,
"text": "维修中"
}, {
"value": 4,
"text": "已完成"
}]
}
}
}
查询语句如下:
其中_that.datetimerange = ['时间戳1','时间戳2']
order_status是代表订单状态的int值
add_date 是新增数据的时间戳
const completedevQuery = await db.collection('weixiu-workorder').where(dbCmd.and([{
order_status: dbCmd.eq(4)
}, {
add_date: dbCmd.gte(_that.datetimerange[0])
}, {
add_date: dbCmd.lte(_that.datetimerange[1])
}]))
.orderBy('add_date desc')
.groupBy('dateToString(add(new Date(0),add_date),"%Y-%m-%d","+0800") as fordate,maintainer_id')
.groupField('sum(number) as completedevNum')
.get()
返回结果只有20条,不管开始时间戳往前调多少,返回的就是开始的20条,后面的没有返回