using System;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Http.Description;
namespace GSYWApi.Controllers
{
///
/// 商户信息相关接口
///
public class MerchantController : BaseController
{
#region 获取供货商列表
///
/// 获取供货商列表
///
/// 服务区内码
/// 查询页码数
/// 每页显示数量
/// 排序字段
///
[Route("Merchant/GetSupplierList")]
[AcceptVerbs("GET")]
[ResponseType(typeof(Models.JsonMsg>))]
public IHttpActionResult GetSupplierList(int? ServerpartId = null,
int PageIndex = 1, int PageSize = 10, string SortStr = "")
{
string Parameter = "入参信息:查询页码【" + PageIndex + "】,每页显示数量【" + PageSize + "】";
try
{
int TotalCount = 0;
//获取供货商列表
List SUPPLIERList = Helper.SUPPLIERHelper.GetSUPPLIERList(
transaction, ServerpartId, ref TotalCount, PageIndex, PageSize, SortStr);
//转化json形式
Models.JsonList jsonList = Models.JsonList.Success(
SUPPLIERList, TotalCount, PageIndex, PageSize);
return Ok(Models.JsonMsg>.Success(jsonList, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetSUPPLIERList");
return Ok(Helper.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region 获取供货商明细
///
/// 获取供货商明细
///
/// 供货商内码
///
[Route("Merchant/GetSupplierDetail")]
[AcceptVerbs("GET")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult GetSupplierDetail(int SUPPLIERId)
{
string Parameter = "入参信息:供货商内码【" + SUPPLIERId + "】";
try
{
//获取供货商明细
Model.SUPPLIERModel supplierModel = Helper.SUPPLIERHelper.GetSUPPLIERDetail(transaction, SUPPLIERId);
return Ok(Models.JsonMsg.Success(supplierModel, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetSUPPLIERDetail");
return Ok(Helper.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region 同步供货商
///
/// 同步供货商
///
///
///
[Route("Merchant/SynchroSupplier")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult SynchroSupplier(Model.SUPPLIERModel supplierModel)
{
try
{
//新增供货商
bool SynchroFlag = Helper.SUPPLIERHelper.SynchroSUPPLIER(transaction, supplierModel);
if (SynchroFlag)
{
return Ok(Helper.Common.ReturnJson(100, "同步成功"));
}
else
{
return Ok(Helper.Common.ReturnJson(200, "更新失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "同步失败!失败原因:" + ex.Message,
DateTime.Now.ToString("yyyyMMdd") + "_SynchroSUPPLIER");
return Ok(Helper.Common.ReturnJson(999, "同步失败" + ex.Message));
}
}
#endregion
#region 删除供货商
///
/// 删除供货商
///
/// 供货商内码
///
[Route("Merchant/DeleteSupplier")]
[AcceptVerbs("GET", "POST")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult DeleteSupplier(int SUPPLIERId)
{
string Parameter = "入参信息:供货商内码【" + SUPPLIERId + "】";
try
{
//删除供货商
bool DeleteFlag = Helper.SUPPLIERHelper.DeleteSUPPLIER(transaction, SUPPLIERId);
if (DeleteFlag)
{
return Ok(Helper.Common.ReturnJson(100, "删除成功"));
}
else
{
return Ok(Helper.Common.ReturnJson(200, "删除失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "删除失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_DeleteSUPPLIER");
return Ok(Helper.Common.ReturnJson(999, "删除失败" + ex.Message));
}
}
#endregion
#region 获取自定义类别列表
///
/// 获取自定义类别列表
///
///
///
///
[Route("Merchant/GetAutoTypeList")]
[AcceptVerbs("GET")]
[ResponseType(typeof(Models.JsonMsg>))]
public IHttpActionResult GetAutoTypeList(int PageIndex = 1, int PageSize = 10)
{
string Parameter = "入参信息:查询页码【" + PageIndex + "】,每页显示数量【" + PageSize + "】";
try
{
int TotalCount = 0;
//获取自定义类别表列表
List AUTOTYPEList = Helper.AUTOTYPEHelper.GetAUTOTYPEList(
transaction, ref TotalCount, PageIndex, PageSize);
//转化json形式
Models.JsonList jsonList = Models.JsonList.Success(
AUTOTYPEList, TotalCount, PageIndex, PageSize);
return Ok(Models.JsonMsg>.Success(jsonList, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetAUTOTYPEList");
return Ok(Helper.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region 获取自定义类别明细
///
/// 获取自定义类别明细
///
///
///
[Route("Merchant/GetAutoTypeDetail")]
[AcceptVerbs("GET")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult GetAutoTypeDetail(int AUTOTYPEId)
{
string Parameter = "入参信息:自定义类别表内码【" + AUTOTYPEId + "】";
try
{
//获取自定义类别表明细
Model.AUTOTYPEModel autotypeModel = Helper.AUTOTYPEHelper.GetAUTOTYPEDetail(transaction, AUTOTYPEId);
return Ok(Models.JsonMsg.Success(autotypeModel, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetAUTOTYPEDetail");
return Ok(Helper.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region 同步自定义类别表
///
/// 同步自定义类别表
///
///
///
[Route("Merchant/SynchroAutoType")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult SynchroAutoType(Model.AUTOTYPEModel autotypeModel)
{
try
{
//新增自定义类别表
bool SynchroFlag = Helper.AUTOTYPEHelper.SynchroAUTOTYPE(transaction, autotypeModel);
if (SynchroFlag)
{
return Ok(Helper.Common.ReturnJson(100, "同步成功"));
}
else
{
return Ok(Helper.Common.ReturnJson(200, "更新失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "同步失败!失败原因:" + ex.Message,
DateTime.Now.ToString("yyyyMMdd") + "_SynchroAUTOTYPE");
return Ok(Helper.Common.ReturnJson(999, "同步失败" + ex.Message));
}
}
#endregion
#region 删除自定义类别表
///
/// 删除自定义类别表
///
///
///
[Route("Merchant/DeleteAutoType")]
[AcceptVerbs("GET", "POST")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult DeleteAutoType(int AUTOTYPEId)
{
string Parameter = "入参信息:自定义类别表内码【" + AUTOTYPEId + "】";
try
{
//删除自定义类别表
bool DeleteFlag = Helper.AUTOTYPEHelper.DeleteAUTOTYPE(transaction, AUTOTYPEId);
if (DeleteFlag)
{
return Ok(Helper.Common.ReturnJson(100, "删除成功"));
}
else
{
return Ok(Helper.Common.ReturnJson(200, "删除失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "删除失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_DeleteAUTOTYPE");
return Ok(Helper.Common.ReturnJson(999, "删除失败" + ex.Message));
}
}
#endregion
#region 获取商户信息列表
///
/// 获取商户信息列表
///
/// 服务区内码
/// 有效状态
/// 模糊查询条件:商户名称
/// 查询页码数
/// 每页显示行数
/// 排序字段
///
[Route("Merchant/GetMerchantsList")]
[AcceptVerbs("GET")]
[ResponseType(typeof(Models.JsonMsg>))]
public IHttpActionResult GetMerchantsList(int? ServerpartId = null, int? Merchants_State = null,
string Merchants_Name = "", int PageIndex = 1, int PageSize = 10, string SortStr = "")
{
string Parameter = "入参信息:查询页码【" + PageIndex + "】,每页显示数量【" + PageSize + "】";
try
{
int TotalCount = 0;
//获取商户信息表列表
List MERCHANTSList = Helper.MERCHANTSHelper.GetMERCHANTSList(transaction,
ServerpartId, Merchants_State, Merchants_Name, ref TotalCount, PageIndex, PageSize, SortStr);
//转化json形式
Models.JsonList jsonList = Models.JsonList.Success(
MERCHANTSList, TotalCount, PageIndex, PageSize);
return Ok(Models.JsonMsg>.Success(jsonList, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetMERCHANTSList");
return Ok(Helper.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region 获取商户信息详情
///
/// 获取商户信息详情
///
/// 商户内码
///
[Route("Merchant/GetMerchantsDetail")]
[AcceptVerbs("GET")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult GetMerchantsDetail(int MERCHANTSId)
{
string Parameter = "入参信息:商户信息表内码【" + MERCHANTSId + "】";
try
{
//获取商户信息表明细
Model.MERCHANTSModel merchantsModel = Helper.MERCHANTSHelper.GetMERCHANTSDetail(transaction, MERCHANTSId);
return Ok(Models.JsonMsg.Success(merchantsModel, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetMERCHANTSDetail");
return Ok(Helper.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region 同步商户信息表
///
/// 同步商户信息表
///
///
///
[Route("Merchant/SynchroMerchants")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult SynchroMerchants(Model.MERCHANTSModel merchantsModel)
{
try
{
//新增商户信息表
bool SynchroFlag = Helper.MERCHANTSHelper.SynchroMERCHANTS(transaction, merchantsModel);
if (SynchroFlag)
{
return Ok(Helper.Common.ReturnJson(100, "同步成功"));
}
else
{
return Ok(Helper.Common.ReturnJson(200, "更新失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "同步失败!失败原因:" + ex.Message,
DateTime.Now.ToString("yyyyMMdd") + "_SynchroMERCHANTS");
return Ok(Helper.Common.ReturnJson(999, "同步失败" + ex.Message));
}
}
#endregion
#region 删除商户信息表
///
/// 删除商户信息表
///
/// 商户内码
///
[Route("Merchant/DeleteMerchants")]
[AcceptVerbs("GET", "POST")]
[ResponseType(typeof(Models.JsonMsg))]
public IHttpActionResult DeleteMerchants(int MERCHANTSId)
{
string Parameter = "入参信息:商户信息表内码【" + MERCHANTSId + "】";
try
{
//删除商户信息表
bool DeleteFlag = Helper.MERCHANTSHelper.DeleteMERCHANTS(transaction, MERCHANTSId);
if (DeleteFlag)
{
return Ok(Helper.Common.ReturnJson(100, "删除成功"));
}
else
{
return Ok(Helper.Common.ReturnJson(200, "删除失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
Helper.LogUtil.WriteLog(null, "删除失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_DeleteMERCHANTS");
return Ok(Helper.Common.ReturnJson(999, "删除失败" + ex.Message));
}
}
#endregion
}
}