|
|
|
@ -0,0 +1,206 @@
|
|
|
|
|
using Common.DJYModel;
|
|
|
|
|
using Common.Extensions;
|
|
|
|
|
using Common.Utilities;
|
|
|
|
|
using djy.IService.Report;
|
|
|
|
|
using djy.Model.Report;
|
|
|
|
|
using djy.Model.ReportDto;
|
|
|
|
|
|
|
|
|
|
using djy.Service.DjyService;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace djy.Service.Report
|
|
|
|
|
{
|
|
|
|
|
public class ReportService : ServBase, IReportService
|
|
|
|
|
{
|
|
|
|
|
#region 获取模板
|
|
|
|
|
|
|
|
|
|
public List<DS_ReportTemplate> GetTemplate()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var List = DbBus.Get(DbList.DSDB).Select<DS_ReportTemplate>().ToList();
|
|
|
|
|
return List;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 列表
|
|
|
|
|
public TableData Load(User user)
|
|
|
|
|
{
|
|
|
|
|
var result = new TableData();
|
|
|
|
|
|
|
|
|
|
var templist = DbBus.Get(DbList.DSDB).Select<DS_ReportTemplate>().ToList();
|
|
|
|
|
|
|
|
|
|
List<ReportDto> query = DbBus.Get(DbList.DSDB).Select<DS_ReportTemplate, DS_Report>().LeftJoin((temp, main) => main.TemplateID == temp.GID).
|
|
|
|
|
WhereIf(user.CompId != null, x => x.t2.CompID == user.CompId).ToList((temp, main) => new ReportDto
|
|
|
|
|
{
|
|
|
|
|
GID = main.GID,
|
|
|
|
|
UserID = main.UserID,
|
|
|
|
|
UserName = main.UserName,
|
|
|
|
|
CompID = main.CompID,
|
|
|
|
|
CompName = main.CompName,
|
|
|
|
|
TemplateID = main.TemplateID,
|
|
|
|
|
TemplateName = temp.TemplateName,
|
|
|
|
|
TemplateDescribe = temp.TemplateDescribe,
|
|
|
|
|
IsBook = main.IsBook,
|
|
|
|
|
IsWechat = main.IsWechat,
|
|
|
|
|
IsEmail = main.IsEmail,
|
|
|
|
|
DJson = main.DJson,
|
|
|
|
|
EndTime = main.EndTime,
|
|
|
|
|
CreateTime = main.CreateTime
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var item in templist)
|
|
|
|
|
{
|
|
|
|
|
var it = query.Where(x => x.TemplateID == item.GID).FirstOrDefault();
|
|
|
|
|
if (it==null) {
|
|
|
|
|
query.Add(new ReportDto
|
|
|
|
|
{
|
|
|
|
|
GID = null,
|
|
|
|
|
UserID = user.GID,
|
|
|
|
|
UserName = user.SHOWNAME,
|
|
|
|
|
CompID = user.CompId,
|
|
|
|
|
CompName = user.COMNAME,
|
|
|
|
|
TemplateID = item.GID,
|
|
|
|
|
TemplateName = item.TemplateName,
|
|
|
|
|
TemplateDescribe = item.TemplateDescribe,
|
|
|
|
|
IsBook = null,
|
|
|
|
|
IsWechat = null,
|
|
|
|
|
IsEmail = null,
|
|
|
|
|
DJson = null,
|
|
|
|
|
EndTime = null,
|
|
|
|
|
CreateTime = DateTime.Now
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.data = query;
|
|
|
|
|
result.count = (int)query.Count();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 新增编辑
|
|
|
|
|
public string SaveInfo(DS_Report dto, User user)
|
|
|
|
|
{
|
|
|
|
|
string guid = dto.GID;
|
|
|
|
|
var list = DbBus.Get(DbList.DSDB).Select<DS_Report>().WhereIf(dto.GID != null, x => x.GID != dto.GID).
|
|
|
|
|
Where(x => x.IsDel != true && x.TemplateID == dto.TemplateID && x.CompID == user.Comid).ToOne();
|
|
|
|
|
if (list != null)
|
|
|
|
|
{
|
|
|
|
|
return "-1";
|
|
|
|
|
}
|
|
|
|
|
if (dto.GID.IsNull())
|
|
|
|
|
{
|
|
|
|
|
DS_Report report = dto.MapTo<DS_Report>();
|
|
|
|
|
report.GID = Guid.NewGuid().ToString("N");
|
|
|
|
|
report.UserID = user.GID;
|
|
|
|
|
report.UserName = user.SHOWNAME;
|
|
|
|
|
report.CompID = user.CompId;
|
|
|
|
|
report.CompName = user.COMNAME;
|
|
|
|
|
report.IsBook = false;
|
|
|
|
|
report.IsEmail = false;
|
|
|
|
|
report.IsDel = false;
|
|
|
|
|
report.CreateTime = DateTime.Now;
|
|
|
|
|
report.LastUpdate = DateTime.Now;
|
|
|
|
|
DbBus.Get(DbList.DSDB).Insert(report).ExecuteAffrows();
|
|
|
|
|
guid = report.GID;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DbBus.Get(DbList.DSDB).Update<DS_Report>().Set(w => new DS_Report
|
|
|
|
|
{
|
|
|
|
|
TemplateID = dto.TemplateID,
|
|
|
|
|
IsBook = dto.IsBook,
|
|
|
|
|
IsEmail=dto.IsEmail,
|
|
|
|
|
DJson=dto.DJson,
|
|
|
|
|
LastUpdate = DateTime.Now,
|
|
|
|
|
LastUserId=user.GID
|
|
|
|
|
}).Where(w => w.GID == dto.GID).ExecuteAffrows();
|
|
|
|
|
}
|
|
|
|
|
return guid;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 取消订阅/订阅
|
|
|
|
|
|
|
|
|
|
public string IsBook(string Gid,string TemplateId, bool isbook,string DJson, User user) {
|
|
|
|
|
if (isbook) {
|
|
|
|
|
if (Gid.IsNull())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DS_Report report = new DS_Report();
|
|
|
|
|
report.GID = Guid.NewGuid().ToString("N");
|
|
|
|
|
report.UserID = user.GID;
|
|
|
|
|
report.UserName = user.SHOWNAME;
|
|
|
|
|
report.CompID = user.CompId;
|
|
|
|
|
report.CompName = user.COMNAME;
|
|
|
|
|
report.IsDel = false;
|
|
|
|
|
report.TemplateID = TemplateId;
|
|
|
|
|
report.CreateTime = DateTime.Now;
|
|
|
|
|
report.LastUpdate = DateTime.Now;
|
|
|
|
|
DbBus.Get(DbList.DSDB).Insert(report).ExecuteAffrows();
|
|
|
|
|
Gid = report.GID;
|
|
|
|
|
}
|
|
|
|
|
////订阅
|
|
|
|
|
var fin = new FinanceService();
|
|
|
|
|
var templist = DbBus.Get(DbList.DSDB).Select<DS_ReportTemplate>().
|
|
|
|
|
Where(x => x.GID==TemplateId).ToOne();
|
|
|
|
|
var getfinrs = fin.Expend(new CustFee
|
|
|
|
|
{
|
|
|
|
|
SENDUSERID = user.GID,
|
|
|
|
|
LURURENID = user.GID,
|
|
|
|
|
CtnrCount = 1,
|
|
|
|
|
CtnrInfo = string.Empty,
|
|
|
|
|
BSTYPE = 17,
|
|
|
|
|
SENDTYPE = templist.SendType,
|
|
|
|
|
BSNO = Gid,
|
|
|
|
|
}, 0);
|
|
|
|
|
if (!getfinrs.Status)
|
|
|
|
|
{
|
|
|
|
|
return getfinrs.Message;
|
|
|
|
|
}
|
|
|
|
|
DbBus.Get(DbList.DSDB).Update<DS_Report>().Set(w => new DS_Report
|
|
|
|
|
{
|
|
|
|
|
IsBook = true,
|
|
|
|
|
IsEmail=true,
|
|
|
|
|
DJson=DJson,
|
|
|
|
|
EndTime=DateTime.Now.AddMonths(1),
|
|
|
|
|
LastUpdate = DateTime.Now,
|
|
|
|
|
LastUserId = user.GID
|
|
|
|
|
}).Where(w => w.GID ==Gid).ExecuteAffrows();
|
|
|
|
|
fin.Expend(new CustFee
|
|
|
|
|
{
|
|
|
|
|
SENDUSERID = user.GID,
|
|
|
|
|
LURURENID = user.GID,
|
|
|
|
|
CtnrCount = 1,
|
|
|
|
|
CtnrInfo = string.Empty,
|
|
|
|
|
BSTYPE = 17,
|
|
|
|
|
SENDTYPE = templist.SendType,
|
|
|
|
|
BSNO = Gid,
|
|
|
|
|
}, 1);
|
|
|
|
|
return "订阅成功!";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DbBus.Get(DbList.DSDB).Update<DS_Report>().Set(w => new DS_Report
|
|
|
|
|
{
|
|
|
|
|
IsBook = false,
|
|
|
|
|
LastUpdate = DateTime.Now,
|
|
|
|
|
LastUserId = user.GID
|
|
|
|
|
}).Where(w => w.GID == Gid).ExecuteAffrows();
|
|
|
|
|
return "取消成功!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|