177 lines
6.8 KiB
C#
177 lines
6.8 KiB
C#
using CRM.Core.BLL.Base;
|
|
using CRM.Core.BLL.EventBus.Events;
|
|
using CRM.Core.BLL.Res;
|
|
using CRM.Core.Common.EventBus;
|
|
using MySql.Data.MySqlClient;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.Common;
|
|
using ZXDService.Dao;
|
|
|
|
namespace ZXDService.Services
|
|
{
|
|
public class UserCenterEventServices
|
|
{
|
|
static bool runnding = false;
|
|
|
|
private readonly BAS_PARAMETER_BL _para = new BAS_PARAMETER_BL();
|
|
private readonly RES_RESOURCEMOBILE_BL _resourceMobile = new RES_RESOURCEMOBILE_BL();
|
|
private ValidationErrors errors = new ValidationErrors();
|
|
public void Load()
|
|
{
|
|
if (runnding)
|
|
return;
|
|
|
|
runnding = true;
|
|
|
|
try
|
|
{
|
|
var id1 = 0;
|
|
//var id2 = 0;
|
|
|
|
var eventmax1 = _para.GetModel("UserCenterEvent1");
|
|
//var eventmax2 = _para.GetModel("UserCenterEvent2");
|
|
|
|
if (eventmax1 != null)
|
|
{
|
|
id1 = int.Parse(eventmax1.PARAVALUE);
|
|
}
|
|
//if (eventmax2 != null)
|
|
//{
|
|
// id2 = int.Parse(eventmax2.PARAVALUE);
|
|
//}
|
|
|
|
using (var db = new UserConterContext())
|
|
{
|
|
//var prams1 = new List<MySqlParameter>
|
|
//{
|
|
// new MySqlParameter("@arg_id", id1)
|
|
//};
|
|
|
|
var sql = @"select s.id, s.eventid, s.eventmemo, s.appid, s.appuserid, s.channel ,u.unionid ,u.mobile ,u.resid
|
|
from actionlogdb.saleclue s
|
|
join usercenter.userinfo u on s.appid = u.appid and s.appuserid = u.appuserid
|
|
where eventid in(1, 7, 8, 17, 20, 31) and s.id > " + id1;
|
|
//LogHelper.Info(sql);
|
|
//var list = db.Database.SqlQuery<UserCenterEventDto>("call getEventToday(@arg_id)", prams1.ToArray());
|
|
var list = db.Database.SqlQuery<UserCenterEventDto>(sql);
|
|
LogHelper.Info("list:" + list.Count().ToString());
|
|
if (list.Any())
|
|
{
|
|
id1 = list.Max(p => p.Id);
|
|
foreach (var item in list)
|
|
{
|
|
var resid = string.Empty;
|
|
if (!string.IsNullOrEmpty(item.Mobile))
|
|
{
|
|
resid = ResUtil.CreateResId(item.Mobile);
|
|
}
|
|
else
|
|
{
|
|
if(!string.IsNullOrEmpty(item.ResId))
|
|
{
|
|
var mobile = _resourceMobile.GetNumberByResId(item.ResId);
|
|
if (!string.IsNullOrEmpty(mobile))
|
|
{
|
|
item.Mobile = mobile;
|
|
}
|
|
}
|
|
}
|
|
if (item.Channel > 0)
|
|
{
|
|
EventBus.Instance.Publish(new UserCenterEventEvent(resid, item.AppId, item.AppUserId, item.UnionId, item.EventMemo, item.EventId, item.Channel, item.Mobile));
|
|
}
|
|
}
|
|
}
|
|
|
|
//var prams2 = new List<MySqlParameter>
|
|
//{
|
|
// new MySqlParameter("@arg_id", id2)
|
|
//};
|
|
|
|
//var list2 = db.Database.SqlQuery<UserCenterEventDto>("call getEventQwFriend(@arg_id)", prams2.ToArray());
|
|
//LogHelper.Info("list2:" + list2.Count().ToString());
|
|
//if (list2.Any())
|
|
//{
|
|
// id2 = list2.Max(p => p.Id);
|
|
// foreach (var item in list2)
|
|
// {
|
|
// var resid = string.Empty;
|
|
// if (!string.IsNullOrEmpty(item.Mobile))
|
|
// {
|
|
// resid = ResUtil.CreateResId(item.Mobile);
|
|
// }
|
|
// if (item.Channel > 0)
|
|
// {
|
|
// EventBus.Instance.Publish(new UserCenterEventEvent(resid, item.AppId, item.AppUserId, item.UnionId, item.EventMemo, item.EventId, item.Channel, item.Mobile));
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
}
|
|
|
|
if (eventmax1 == null)
|
|
{
|
|
eventmax1 = new CRM.Core.Model.Entity.BAS_PARAMETER
|
|
{
|
|
PARAKEY = "UserCenterEvent1",
|
|
PARANAME = "用户中心事件提醒",
|
|
GROUPID = "SystemConfig",
|
|
PARATYPE = "string",
|
|
REMARK = "用户中心事件提醒",
|
|
CREATEUSER = 600000207,
|
|
PARAVALUE = id1.ToString()
|
|
};
|
|
}
|
|
else
|
|
{
|
|
eventmax1.PARAVALUE = id1.ToString();
|
|
}
|
|
|
|
//if (eventmax2 == null)
|
|
//{
|
|
// eventmax2 = new CRM.Core.Model.Entity.BAS_PARAMETER
|
|
// {
|
|
// PARAKEY = "UserCenterEvent2",
|
|
// PARANAME = "用户中心加好友事件提醒",
|
|
// GROUPID = "SystemConfig",
|
|
// PARATYPE = "string",
|
|
// REMARK = "用户中心加好友事件提醒",
|
|
// CREATEUSER = 600000207,
|
|
// PARAVALUE = id2.ToString()
|
|
// };
|
|
//}
|
|
//else
|
|
//{
|
|
// eventmax2.PARAVALUE = id2.ToString();
|
|
//}
|
|
|
|
_para.SetValue_Parameter(eventmax1, ref errors);
|
|
//_para.SetValue_Parameter(eventmax2, ref errors);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.Error(e);
|
|
}
|
|
finally
|
|
{
|
|
runnding = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class UserCenterEventDto
|
|
{
|
|
public string Mobile { get; set; }
|
|
public string AppId { get; set; }
|
|
public string AppUserId { get; set; }
|
|
public string UnionId { get; set; }
|
|
public string EventMemo { get; set; }
|
|
public int EventId { get; set; }
|
|
public int Channel { get; set; }
|
|
public int Id { get; set; }
|
|
public string ResId { get; set; }
|
|
}
|
|
} |