|
@@ -398,7 +398,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
dto.FieldName = dto.FieldName.ToLower();
|
|
|
var IsCenter = _sessionContext.OrgIsCenter;
|
|
|
IsCenter = true;
|
|
|
- var query = _orderSnapshotRepository.Queryable()
|
|
|
+ var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
.LeftJoin<Order>((snapshot, order) => snapshot.Id == order.Id)
|
|
|
.LeftJoin<OrderSendBackAudit>((snapshot, order, back) => snapshot.Id == back.OrderId && back.State == ESendBackAuditState.End)
|
|
|
.LeftJoin<OrderVisit>((snapshot, order, back, visit) => snapshot.Id == visit.OrderId && visit.VisitState == EVisitState.Visited)
|
|
@@ -428,4 +428,40 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
OrderScreenStatus = SqlFunc.Subqueryable<OrderScreen>().Where(q => q.OrderId == d.Id).OrderByDesc(q => q.CreationTime).Select(q => q.Status),
|
|
|
}, true);
|
|
|
}
|
|
|
+
|
|
|
+ public ISugarQueryable<GuiderWorkStatisticsOutDto> GetGuiderWorkStatisticsAsync(GuiderWorkStatisticsInDto dto)
|
|
|
+ {
|
|
|
+ var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
+ .Where(snapshot => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime && snapshot.MemberName != null )
|
|
|
+ .GroupBy(snapshot => new { snapshot.MemberName, snapshot.MemberMobile })
|
|
|
+ .Select(snapshot => new GuiderWorkStatisticsOutDto
|
|
|
+ {
|
|
|
+ MemberMobile = snapshot.MemberMobile,
|
|
|
+ MemberName = snapshot.MemberName,
|
|
|
+ ReplyIn4HourCount = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.ReplyResultType == EGuiderSystemReplyType.Field && snapshot.GuidSystemCallBackTime.Value.AddHours(-4) <= snapshot.SendGuidSystemTime, 1, 0)),
|
|
|
+ ReplyOut4HourCount = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.ReplyResultType == EGuiderSystemReplyType.Field && snapshot.GuidSystemCallBackTime.Value.AddHours(-4) > snapshot.SendGuidSystemTime, 1, 0)),
|
|
|
+ UnReplyCount = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.ReplyResultType != EGuiderSystemReplyType.Field, 1, 0)),
|
|
|
+ });
|
|
|
+
|
|
|
+ return query;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ISugarQueryable<GuiderWorkStatisticsDetailsOutDto> GetGuiderWorkStatisticsDetails(GuiderWorkStatisticsDetailsInDto dto)
|
|
|
+ {
|
|
|
+ dto.FieldName = dto.FieldName.ToLower();
|
|
|
+ var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
+ .LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
|
|
|
+ .Where(snapshot => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime && snapshot.MemberMobile == dto.MemberMobile);
|
|
|
+
|
|
|
+ query = dto.FieldName switch
|
|
|
+ {
|
|
|
+ "replyin4hourcount" => query.Where(snapshot => snapshot.ReplyResultType == EGuiderSystemReplyType.Field && snapshot.GuidSystemCallBackTime.Value.AddHours(-4) <= snapshot.SendGuidSystemTime),
|
|
|
+ "replyout4hourcount" => query.Where(snapshot => snapshot.ReplyResultType == EGuiderSystemReplyType.Field && snapshot.GuidSystemCallBackTime.Value.AddHours(-4) > snapshot.SendGuidSystemTime),
|
|
|
+ "unreplycount" => query.Where(snapshot => snapshot.ReplyResultType != EGuiderSystemReplyType.Field),
|
|
|
+ _ => throw new UserFriendlyException($"入参: {dto.FieldName} 异常")
|
|
|
+ };
|
|
|
+ return query.Select((snapshot, order) => new GuiderWorkStatisticsDetailsOutDto
|
|
|
+ {
|
|
|
+ }, true);
|
|
|
+ }
|
|
|
}
|