197 lines
6.9 KiB
C#
197 lines
6.9 KiB
C#
using Dapper;
|
|
using NetCore.Common;
|
|
using NetCore.Model.crm;
|
|
using NetCore.Model.enums;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace NetCore.BLL
|
|
{
|
|
public class crm_callrecord_bll
|
|
{
|
|
/// <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<crm_callrecord> GetList(int clearcount, decimal seq, DateTime checkdate)
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.crmContext, comcode))
|
|
{
|
|
string sql = string.Format(@"select * from (select pkid,filename,servicenumber,saleseid,timestart,resid,timelength from csvr_callrecord t
|
|
where t.timestart>:checkdate
|
|
and t.timestart<:checkdateNext
|
|
and t.pkid>:seq
|
|
and exists (select 1 from hg_orderresid a where a.resid=t.resid)
|
|
) where rownum<={0}
|
|
", clearcount);//过滤掉,只执行订单客服消息
|
|
|
|
return con.Query<crm_callrecord>(sql, new { seq, checkdate, checkdateNext = checkdate.AddDays(1) }, buffered: false).ToList();
|
|
|
|
}
|
|
}
|
|
|
|
private List<hg_order_record> _ordrecord { get; set; }
|
|
private string comcode { get; set; }
|
|
public crm_callrecord_bll(string _comcode)
|
|
{
|
|
comcode = _comcode;
|
|
_ordrecord = new List<hg_order_record>();
|
|
}
|
|
public void Clear()
|
|
{
|
|
_ordrecord = new List<hg_order_record>();
|
|
}
|
|
/// <summary>
|
|
/// 新增数据
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public bool Add(hg_order_record model)
|
|
{
|
|
_ordrecord.Add(model);
|
|
return true;
|
|
}
|
|
|
|
public void StartInsert()
|
|
{
|
|
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.crmContext, comcode))
|
|
{
|
|
foreach (var model in _ordrecord)
|
|
{
|
|
try
|
|
{
|
|
hg_order_record getmodel = con.QueryFirstOrDefault<hg_order_record>("select pkid,filename from HG_ORDER_RECORD where pkid=:pkid", new { model.pkid });
|
|
|
|
if (getmodel == null || string.IsNullOrEmpty(getmodel.filename))//无数据,需要插入数据
|
|
{
|
|
//无数据
|
|
con.Execute(@"insert into hg_order_record
|
|
(id, pkid, checkdate, ctime, transstatus, ishg, voiceurl, resid, saleseid, filename,timelength)
|
|
values
|
|
(pack_base.Seq_smallid_get,:pkid,:checkdate,sysdate, 0, 0,:voiceurl,:resid,:saleseid,:filename,:timelength)", model);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine("普通合规消息入库失败:" + JsonConvert.SerializeObject(model));
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取需要翻译的数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<hg_order_record> GetNeedTransList(int clearcount)
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.crmContext, comcode))
|
|
{
|
|
|
|
string sql = string.Format(@"select * from (select * from hg_order_record b
|
|
where transstatus=0
|
|
and ctime>:mintime
|
|
order by pkid asc)where rownum<={0}", clearcount);
|
|
|
|
return con.Query<hg_order_record>(sql, new { mintime = Convert.ToDateTime(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")) }, buffered: false).ToList();
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取需要翻译的数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<hg_order_record> GetNeedHegList(int clearcount)
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.crmContext, comcode))
|
|
{
|
|
|
|
string sql = string.Format(@"select * from(select * from hg_order_record b
|
|
where transstatus=1
|
|
and ishg=0
|
|
order by pkid asc)where rownum<={0}", clearcount);
|
|
|
|
return con.Query<hg_order_record>(sql, buffered: false).ToList();
|
|
|
|
}
|
|
}
|
|
|
|
public void UpdateHgStatus(List<int> ids)
|
|
{
|
|
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.crmContext, comcode))
|
|
{
|
|
foreach (var item in ids)
|
|
{
|
|
con.Execute("update hg_order_record set ishg=1,hgtime=sysdate where id=:id", new { id = item });
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 调用了翻译
|
|
/// </summary>
|
|
/// <param name="transcontent"></param>
|
|
/// <param name="id"></param>
|
|
/// <param name="transstatus"></param>
|
|
public bool ToTrans(int id, int transstatus)
|
|
{
|
|
bool result = true;
|
|
try
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.crmContext, comcode))
|
|
{
|
|
string sql = string.Format(@"update hg_order_record set transstatus=:transstatus,transtime=sysdate where id=:id");//过滤掉,只执行订单客服消息
|
|
con.Execute(sql, new { transstatus = transstatus, id = id });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.Error(e.ToString());
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 翻译数据
|
|
/// </summary>
|
|
/// <param name="transcontent"></param>
|
|
/// <param name="id"></param>
|
|
/// <param name="transstatus"></param>
|
|
public bool TransBack(string transcontent, int id, int transstatus)
|
|
{
|
|
bool result = true;
|
|
try
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.crmContext, comcode))
|
|
{
|
|
DynamicParameters dp = new DynamicParameters();
|
|
dp.Add(":transstatus", transstatus);
|
|
dp.Add(":transcontent", transcontent);
|
|
dp.Add(":id", id);
|
|
string sql = string.Format(@"update hg_order_record set transstatus=:transstatus,transtime=sysdate,transcontent=:transcontent where id=:id");//过滤掉,只执行订单客服消息
|
|
con.Execute(sql, dp);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.Error(e.ToString());
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
}
|
|
}
|