TG.WXCRM.V4/NetCore.BLL/qw/ww_message_bll.cs

65 lines
2.4 KiB
C#

using Dapper;
using NetCore.Model.enums;
using NetCore.Model.qw;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace NetCore.BLL
{
public class ww_message_bll
{
private string comcode;
public ww_message_bll(string _comcode)
{
comcode = _comcode;
}
/// <summary>
/// 获取数据源
/// </summary>
/// <param name="tablename"></param>
/// <param name="corpid"></param>
/// <param name="clearcount"></param>
/// <param name="seq"></param>
/// <param name="cusmsgdeedhg"></param>
/// <returns></returns>
public List<ww_message> GetList(string tablename, string corpid, int clearcount, int seq, int cusmsgdeedhg, DateTime checkdate)
{
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode))
{
if (cusmsgdeedhg == 0)//客户发得消息,不做合规
{
string sql = string.Format(@"select seq,msgid,msgtype,action,fromer,tolist,roomid,ext,content,nfile,msgtime,ctime from wework_{0}.{1} b
where seq>@seq
and ctime>@checkdate
and ctime<@checkdateNext
and msgtype in('text','voice')
and (roomid ='' or roomid is null)
and exists(select 1 from hg_orderuser a where a.external_userid=b.tolist)
and exists(select 1 from hg_jobuser a where a.corpid='{0}' and a.userid=b.fromer)
order by seq asc limit @count", corpid, tablename);//过滤掉,只执行订单客服消息
return con.Query<ww_message>(sql, new { seq, count = clearcount, checkdate, checkdateNext = checkdate.AddDays(1) }, buffered: false).ToList();
}
else
{
string sql = string.Format(@"select seq,msgid,msgtype,action,fromer,tolist,roomid,ext,content,nfile,msgtime,ctime from wework_{0}.{1} b
where seq>@seq
and ctime>@checkdate
and ctime<@checkdateNext
and msgtype in('text','voice')
and (roomid ='' or roomid is null)
and exists(select 1 from hg_orderuser a where a.external_userid=b.tolist or a.external_userid=b.fromer)
order by seq asc limit @count", corpid, tablename);//过滤掉,只执行订单客服消息
return con.Query<ww_message>(sql, new { seq, count = clearcount, checkdate, checkdateNext = checkdate.AddDays(1) }, buffered: false).ToList();
}
}
}
}
}