2025-03-28 09:49:56 +08:00

92 lines
4.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web.Http;
using System.Web.Http.Description;
using Newtonsoft.Json;
using HZQR.Common;
using RedisHelp;
namespace OpenApi.Controllers
{
/// <summary>
/// 销售数据相关接口
/// </summary>
public class SellDataController : BaseController
{
#region
/// <summary>
/// 获取交易流水订单表列表
/// </summary>
/// <param name="paramsModel">是否显示商品明细</param>
/// <returns></returns>
[Route("Revenue/GetGZSellMasterList")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<Model.YSSELLMASTERModel>>))]
public IHttpActionResult GetGZSellMasterList(Models.ParamsModel<Models.SellParamsModel> paramsModel)
{
if (!Method.Common.VerifyCode(paramsModel))
{
return Ok(Method.Common.ReturnJson(201, "查询失败,请传入正确的授权码信息!"));
}
Models.SellParamsModel sellParamsModel = paramsModel.jsonString;
if (sellParamsModel == null)
{
return Ok(Method.Common.ReturnJson(200, "查询失败,请传入正确的查询条件!"));
}
if (string.IsNullOrWhiteSpace(sellParamsModel.ServerpartCode))
{
return Ok(Method.Common.ReturnJson(200, "查询失败,请传入服务区编码和门店编码进行查询!"));
}
if (string.IsNullOrWhiteSpace(sellParamsModel.StartDate) || string.IsNullOrWhiteSpace(sellParamsModel.EndDate) ||
(DateTime.Parse(sellParamsModel.EndDate) - DateTime.Parse(sellParamsModel.StartDate)).Days > 30)
{
return Ok(Method.Common.ReturnJson(200, "查询失败查询时间间隔不能超过30天"));
}
RedisHelper redisHelper = new RedisHelper(12);
if (redisHelper.KeyExists("GetGZSellMasterList"))
{
return Ok(Method.Common.ReturnJson(200, "查询失败请于1分钟后再次查询数据"));
}
else
{
redisHelper.StringSet("GetGZSellMasterList", DateTime.Now.ToString());
redisHelper.KeyExpire("GetGZSellMasterList", new TimeSpan(0, 1, 0));
}
string Parameter = "入参信息:" + JsonConvert.SerializeObject(paramsModel);
try
{
//获取交易流水订单表列表
List<Model.YSSELLMASTERModel> YSSELLMASTERList = new List<Model.YSSELLMASTERModel>();
if (sellParamsModel.ServerpartCode.StartsWith("52"))
{
YSSELLMASTERList = Method.SellDataHelper.GetYSSELLMASTERList(
transaction, sellParamsModel.ServerpartCode, sellParamsModel.ShopCode,
sellParamsModel.StartDate, sellParamsModel.EndDate, sellParamsModel.ShowDetail);
}
//转化json形式
Models.JsonList<Model.YSSELLMASTERModel> jsonList = Models.JsonList<Model.YSSELLMASTERModel>.Success(
YSSELLMASTERList, YSSELLMASTERList.Count, 1, YSSELLMASTERList.Count);
LogUtil.WriteLog(null, "查询成功!" + Parameter, DateTime.Now.ToString("yyyyMMdd") + "_GetGZSellMasterList");
return Ok(Models.JsonMsg<Models.JsonList<Model.YSSELLMASTERModel>>.Success(jsonList, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetGZSellMasterListError");
return Ok(Method.Common.ReturnJson(999, "查询失败!接口异常,请联系管理员"));
}
}
#endregion
}
}