You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
185 lines
6.8 KiB
185 lines
6.8 KiB
using EasyBL.WebApi.Message;
|
|
using Entity.Sugar;
|
|
using Entity.ViewModels;
|
|
using SqlSugar;
|
|
using SqlSugar.Base;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace EasyBL.WEBAPP.SYS
|
|
{
|
|
public class MemberMaintain_QryService : ServiceBase
|
|
{
|
|
#region 會員類別管理(分頁查詢)
|
|
|
|
/// <summary>
|
|
/// 會員類別管理(分頁查詢)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
public ResponseMessage QueryPage(RequestMessage i_crm)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
try
|
|
{
|
|
do
|
|
{
|
|
var pml = new PageModel
|
|
{
|
|
PageIndex = _fetchInt(i_crm, @"pageIndex"),
|
|
PageSize = _fetchInt(i_crm, @"pageSize")
|
|
};
|
|
var iPageCount = 0;
|
|
var sSortField = _fetchString(i_crm, @"sortField");
|
|
var sSortOrder = _fetchString(i_crm, @"sortOrder");
|
|
var sCountryID = _fetchString(i_crm, @"CountryID");
|
|
var sArgumentID = _fetchString(i_crm, @"ArgumentID");
|
|
var sMemberID = _fetchString(i_crm, @"MemberID");
|
|
var sFirstName = _fetchString(i_crm, @"FirstName");
|
|
var sLastName = _fetchString(i_crm, @"LastName");
|
|
var sPhone = _fetchString(i_crm, @"Phone");
|
|
var bExcel = _fetchBool(i_crm, @"Excel");
|
|
|
|
pml.DataList = db.Queryable<SETB_CMS_Member, SETB_SYS_Country, OTB_SYS_Arguments>((t1, t2, t3) => new object[] {
|
|
JoinType.Left, t1.OrgID == t2.OrgID && t1.CountryID == t2.CountryID,
|
|
JoinType.Left, t1.OrgID == t3.OrgID && t1.ArgumentID == t3.ArgumentID
|
|
})
|
|
.Where((t1, t2, t3) => t1.OrgID == i_crm.ORIGID && t1.MemberID.Contains(sMemberID))
|
|
.WhereIF(!string.IsNullOrEmpty(sCountryID), (t1, t2, t3) => t1.CountryID == t2.CountryID)
|
|
.WhereIF(!string.IsNullOrEmpty(sArgumentID), (t1, t2, t3) => t1.ArgumentID == t3.ArgumentID)
|
|
|
|
|
|
.Select((t1, t2, t3) => new View_CMS_Member
|
|
{
|
|
MemberID = SqlFunc.GetSelfAndAutoFill(t1.MemberID),
|
|
CountryName = t2.CountryName,
|
|
Country_ENCode = t2.Country_ENCode,
|
|
ArgumentValue = t3.ArgumentValue
|
|
|
|
|
|
})
|
|
.OrderBy(sSortField, sSortOrder)
|
|
.ToPageList(pml.PageIndex, bExcel ? 100000 : pml.PageSize, ref iPageCount);
|
|
|
|
pml.Total = iPageCount;
|
|
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
if (bExcel)
|
|
{
|
|
const string sFileName = "會員類別";
|
|
var oHeader = new Dictionary<string, string>
|
|
{
|
|
{ "RowIndex", "項次" },
|
|
{ "MemberID", "會員編號" },
|
|
{ "FirstName", "姓氏" },
|
|
{ "LastName", "名字" },
|
|
{ "Title", "稱謂" },
|
|
{ "MemberType", "會員類別" },
|
|
{ "Account", "帳號" },
|
|
{ "Password", "密碼" },
|
|
{ "Email", "聯絡信箱" },
|
|
{ "Country_ENCode", "國碼" },
|
|
{ "Phone", "聯絡電話" },
|
|
{ "CountryName", "國別" },
|
|
{ "ArgumentValue", "偏好語系" },
|
|
{ "BirthDate", "生日" },
|
|
{ "Status", "會員狀態" },
|
|
{ "Subscribe", "是否訂閱" },
|
|
{ "CreateDate", "創建日期" },
|
|
};
|
|
|
|
var dicAlain = ExcelService.GetExportAlain(oHeader, "Effective");
|
|
var saMember = pml.DataList as List<View_CMS_Member>;
|
|
var bOk = new ExcelService().CreateExcelByList(saMember, out string sPath, oHeader, dicAlain, sFileName);
|
|
rm.DATA.Add(BLWording.REL, sPath);
|
|
}
|
|
else
|
|
{
|
|
rm.DATA.Add(BLWording.REL, pml);
|
|
}
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.ShowEasy.MemberMaintain_QryService", "", "QueryPage(會員類別管理(分頁查詢))", "", "", "");
|
|
}
|
|
|
|
finally
|
|
{
|
|
|
|
if (null != sMsg)
|
|
{
|
|
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
|
|
return rm;
|
|
|
|
|
|
}
|
|
|
|
#endregion 會員類別管理(分頁查詢)
|
|
|
|
#region 會員類別管理(以 ID 查詢)
|
|
|
|
/// <summary>
|
|
/// 會員類別管理(以 ID 查詢)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
///
|
|
|
|
public List<SETB_CMS_Member> QueryByIDs(RequestMessage i_crm, string sMemberID)
|
|
{
|
|
|
|
|
|
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
|
|
var saList = new List<SETB_CMS_Member>();
|
|
|
|
try
|
|
{
|
|
do
|
|
{
|
|
|
|
saList = db.Queryable<SETB_CMS_Member>()
|
|
.Where(t1 => t1.OrgID == i_crm.ORIGID)
|
|
.Where(t1 => t1.MemberID == sMemberID).ToList();
|
|
|
|
rm = new SuccessResponseMessage(null, i_crm);
|
|
rm.DATA.Add(BLWording.REL, saList);
|
|
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(MemberMaintain_QryService), "", "QueryByIDs 會員類別管理(以 ID 查詢)", "", "", "");
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, i_crm);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return saList;
|
|
|
|
}
|
|
|
|
#endregion 會員類別管理(以 ID 查詢)
|
|
|
|
|
|
}
|
|
}
|