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.
218 lines
7.9 KiB
218 lines
7.9 KiB
|
|
using EasyBL.WebApi;
|
|
using EasyBL.WebApi.Common;
|
|
using EasyBL.WebApi.Message;
|
|
using EasyBL.WEBAPP.ShowEasy;
|
|
using EasyBL.WEBAPP.WSM;
|
|
using Entity.ShowEasyDtos;
|
|
using Entity.Sugar;
|
|
using Entity.ViewModels;
|
|
using Newtonsoft.Json;
|
|
using SqlSugar;
|
|
using SqlSugar.Base;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web;
|
|
|
|
namespace EasyBL.WEBAPP.SYS
|
|
{
|
|
//子類別查詢API (服務有包含該類別才列出)
|
|
public class BookingOnlineService : ServiceBase
|
|
{
|
|
#region 子類別查詢API (服務有包含該類別才列出)
|
|
|
|
/// <summary>
|
|
/// 子類別查詢API (服務有包含該類別才列出)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
///
|
|
public HttpResponseMessage GetBookingCategory(string Account, string LangType)
|
|
{
|
|
SuccessResponseMessage srm = null;
|
|
string sError = null;
|
|
var db = SugarBase.GetIntance();
|
|
try
|
|
{
|
|
do
|
|
{
|
|
//取Member所有的訂單
|
|
BookingMaintain_QryService booking_qry = new BookingMaintain_QryService();
|
|
var allBookingServiceList = booking_qry.FindAllByIDsAsDictionary("", "", Account).Values.ToList()
|
|
.Where(w => !string.IsNullOrEmpty(w.ServiceID))
|
|
.Select(s => s.ServiceID).ToList();
|
|
|
|
//取所有category
|
|
ServiceSubCategoryMaintain_QryService serviceSub_qry = new ServiceSubCategoryMaintain_QryService();
|
|
var subCategory = serviceSub_qry.FindAllByIDsAsDictionary("", LangType);
|
|
|
|
//取得所有OnSiteService
|
|
ONSiteMaintain_QryService onSiteService_qry = new ONSiteMaintain_QryService();
|
|
var allService = onSiteService_qry.FindAllByIDsAsDictionary(LangType, "");
|
|
|
|
var ServiceIDSet = new HashSet<string>(); //去重複值
|
|
var CategoryDic = new Dictionary<string, CategoryDTO>();
|
|
|
|
foreach (var ServiceID in allBookingServiceList)
|
|
{
|
|
|
|
SETB_PDT_ONSiteBaseInfo Service = new SETB_PDT_ONSiteBaseInfo();
|
|
|
|
if (allService.ContainsKey(ServiceID))
|
|
{
|
|
Service = allService[ServiceID];
|
|
}
|
|
|
|
var SubCategoryIDList = new List<string>();
|
|
|
|
if (!string.IsNullOrEmpty(Service.SubCategoryID))
|
|
{
|
|
SubCategoryIDList = JsonConvert.DeserializeObject<List<string>>(Service.SubCategoryID);
|
|
}
|
|
|
|
foreach (var subCategoryID in SubCategoryIDList)
|
|
{
|
|
|
|
SETB_SYS_Category category = new SETB_SYS_Category();
|
|
|
|
if (subCategory.ContainsKey(subCategoryID))
|
|
{
|
|
category = subCategory[subCategoryID]; //用subCategoryID在subCategory內找
|
|
}
|
|
|
|
CategoryDTO categoryDTO = new CategoryDTO();
|
|
|
|
categoryDTO.CategoryID = category.CategoryID;
|
|
categoryDTO.CategoryName = category.CategoryName;
|
|
|
|
CategoryDic[categoryDTO.CategoryID] = categoryDTO; //把categoryDTO.CategoryID當作key,把value(categoryDTO)存進CategoryDic
|
|
//存到Dictionary內會去重複值。不用額外用HashSet
|
|
}
|
|
}
|
|
|
|
srm = new SuccessResponseMessage(null, null);
|
|
srm.DATA.Add(BLWording.REL, CategoryDic.Values.ToList());
|
|
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sError = Util.GetLastExceptionMsg(ex);
|
|
|
|
srm = new SuccessResponseMessage(null, null)
|
|
{
|
|
STATUSCODE = (int)StatusCodeEnum.Error,
|
|
MSG = StatusCodeEnum.Error.GetEnumText()
|
|
};
|
|
srm.DATA.Add(BLWording.REL, "");
|
|
}
|
|
return HttpResponseExtension.ToJson(JsonConvert.SerializeObject(srm));
|
|
|
|
}
|
|
|
|
#endregion 子類別查詢API (服務有包含該類別才列出)
|
|
|
|
#region My Booking Card
|
|
|
|
/// <summary>
|
|
/// My Booking Card
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
///
|
|
public HttpResponseMessage BookingCardList(string sAccount, string sLanguage, List<string> SubCategoryIDs, List<string> BookingStatuses, List<string> PaymentStatuses)
|
|
{
|
|
|
|
SuccessResponseMessage srm = null;
|
|
string sError = null;
|
|
var db = SugarBase.GetIntance();
|
|
try
|
|
{
|
|
do
|
|
{
|
|
BookingMaintain_QryService bm_qry = new BookingMaintain_QryService();
|
|
|
|
var rsResult = bm_qry.QueryAllBooking(sLanguage, sAccount, SubCategoryIDs, BookingStatuses, PaymentStatuses);
|
|
|
|
srm = new SuccessResponseMessage(null, null);
|
|
srm.DATA.Add(BLWording.REL, rsResult.Values.ToList());
|
|
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sError = Util.GetLastExceptionMsg(ex);
|
|
srm = new SuccessResponseMessage(null, null)
|
|
{
|
|
STATUSCODE = (int)StatusCodeEnum.Error,
|
|
MSG = StatusCodeEnum.Error.GetEnumText()
|
|
};
|
|
srm.DATA.Add(BLWording.REL, "");
|
|
}
|
|
|
|
return HttpResponseExtension.ToJson(JsonConvert.SerializeObject(srm));
|
|
|
|
}
|
|
|
|
#endregion My Booking Card
|
|
|
|
|
|
#region Upload 上傳文件
|
|
|
|
public HttpResponseMessage UploadRemittance(string OrgID, string Account, string BookingID)
|
|
{
|
|
SuccessResponseMessage srm = null;
|
|
string sError = null;
|
|
try
|
|
{
|
|
var c = HttpContext.Current;
|
|
|
|
var sGUID = Guid.NewGuid().ToString();
|
|
|
|
SECommonService commonService = new SECommonService();
|
|
// 文件上傳
|
|
HttpResponseMessage ret = commonService.UploadRemittance(c, OrgID, Account, BookingID);
|
|
if (ret.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
|
|
var db = SugarBase.DB;
|
|
//SETB_CMS_Member i_crm = new SETB_CMS_Member();
|
|
SETB_SAL_Payment i_crm = new SETB_SAL_Payment();
|
|
|
|
string requestUrl = Common.ConfigGetValue("", "ida:RedirectUri");
|
|
|
|
var sUser = db.Queryable<SETB_SAL_Payment>()
|
|
.Where(x => x.BookingID == BookingID)
|
|
.Single();
|
|
|
|
var sFilePath = db.Queryable<OTB_SYS_Files>()
|
|
.Where(x => x.ParentID == sUser.Remittance)
|
|
.Single();
|
|
|
|
sUser.Remittance = requestUrl + "/" + sFilePath.FilePath.Replace("\\", "/");
|
|
|
|
srm = new SuccessResponseMessage(null, null);
|
|
srm.DATA.Add(BLWording.REL, sUser.Remittance);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sError = Util.GetLastExceptionMsg(ex);
|
|
srm = new SuccessResponseMessage(null, null)
|
|
{
|
|
STATUSCODE = (int)StatusCodeEnum.Error,
|
|
MSG = StatusCodeEnum.Error.GetEnumText()
|
|
};
|
|
srm.DATA.Add(BLWording.REL, "");
|
|
}
|
|
return HttpResponseExtension.ToJson(JsonConvert.SerializeObject(srm));
|
|
}
|
|
|
|
|
|
#endregion Upload 上傳文件
|
|
}
|
|
|
|
|
|
}
|