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 { /// /// 销售数据相关接口 /// public class SellDataController : BaseController { #region 获取交易流水订单表列表 /// /// 获取交易流水订单表列表 /// /// 是否显示商品明细 /// [Route("Revenue/GetGZSellMasterList")] [AcceptVerbs("POST")] [ResponseType(typeof(Models.JsonMsg>))] public IHttpActionResult GetGZSellMasterList(Models.ParamsModel 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 YSSELLMASTERList = new List(); if (sellParamsModel.ServerpartCode.StartsWith("52")) { YSSELLMASTERList = Method.SellDataHelper.GetYSSELLMASTERList( transaction, sellParamsModel.ServerpartCode, sellParamsModel.ShopCode, sellParamsModel.StartDate, sellParamsModel.EndDate, sellParamsModel.ShowDetail); } //转化json形式 Models.JsonList jsonList = Models.JsonList.Success( YSSELLMASTERList, YSSELLMASTERList.Count, 1, YSSELLMASTERList.Count); LogUtil.WriteLog(null, "查询成功!" + Parameter, DateTime.Now.ToString("yyyyMMdd") + "_GetGZSellMasterList"); return Ok(Models.JsonMsg>.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 } }