public void SelectProductInfoByTagRequest() { using (var client = new ProductConfigClient()) { var pidList = new List <string>() { "TR-YK-AE50|2", "TR-YK-AE50|5", "TR-GT-221|6", "BD-BO-Common|105", "BD-BO-Common|115", "BD-BO-Common|144", "BD-BO-Common|145", }; var result1 = client.SetProductCommonTagDetailsCacheAsync(ProductCommonTag.Discount, pidList).Result; // Assert.IsNotNull(result1); var request = new ProductInfoByTagRequest() { Tags = new List <ProductCommonTag>() { ProductCommonTag.Discount }, Pids = pidList }; var tags = new List <ProductCommonTag>() { ProductCommonTag.Discount }; var result = client.SelectProductInfoByTagRequestAsync(request).Result.Result; Assert.IsNotNull(result); } }
public Tuhu.Service.Product.Models.ProductConfig.CarProductFlagshipStoreConfig GetConfigByBrand(string brand) { if (string.IsNullOrWhiteSpace(brand)) { return(null); } List <string> list = new List <string>(); list.Add(brand); using (var client = new ProductConfigClient()) { var result = client.GetCarProductFlagshipStoreConfigByBrand(list); if (result.Success && result.Result != null && result.Result.Any()) { return(result.Result.FirstOrDefault()); } else { return(null); } } }
/// <summary> /// 获取商品的每单限购信息 /// </summary> /// <param name="pids"></param> /// <returns></returns> public async static Task <OperationResult <Dictionary <string, int> > > GetProductLimitCountWithPidListAsync(List <string> pids) { using (var client = new ProductConfigClient()) { var result = await client.GetProductLimitCountWithPidListAsync(pids); if (!result.Success) { Logger.Warn($"GetProductLimitCountWithPidListAsync失败,ErrorMessage:{result.ErrorMessage},pids:{string.Join(",", pids)} "); } return(result); } }
public static List <RecommendProductModel> GetTireEnforceRecommendByPids(List <string> pids) { var returnResult = new List <RecommendProductModel>(); if (pids == null || !pids.Any() || pids.Count == 0) { return(returnResult); } try { using (var client = new ProductConfigClient()) { var result = client.GetTireEnforceRecommendByPids(pids.Distinct().ToList()); result.ThrowIfException(true); if (result.Success && result.Result != null && result.Result.Any() && result.Result.Count > 0) { var recommendPids = result.Result.Where(p => !string.IsNullOrWhiteSpace(p.RecommendPID)) .Select(p => p.RecommendPID) .Distinct() .ToList(); var displayNames = DALRecommendTire.GetDisplayName(recommendPids); var displayNameDic = displayNames?.GroupBy(p => p.PID)?.ToDictionary(p => p.Key?.ToUpper(), p => p.FirstOrDefault()?.DisplayName ?? ""); result.Result.ForEach(item => { var model = new RecommendProductModel { PID = item.PId, Image = item.Image, Postion = item.Position, Reason = item.Reason, RecommendPID = item.RecommendPID, }; var ProductName = ""; if ((bool)displayNameDic?.ContainsKey(model.RecommendPID?.ToUpper())) { displayNameDic.TryGetValue(model.RecommendPID?.ToUpper(), out ProductName); } model.ProductName = ProductName; returnResult.Add(model); }); } } return(returnResult); } catch (Exception ex) { //TODO:log return(returnResult); } }
public static void RefreashTireEnforceRecommendCache(IEnumerable <string> pids) { try { using (var client = new ProductConfigClient()) { var clientResult = client.RefreashTireEnforceRecommendCache(pids); clientResult.ThrowIfException(true); } } catch (Exception ex) { //TODO:log } }
public bool UpdateConfig(Tuhu.Service.Product.Models.ProductConfig.CarProductFlagshipStoreConfig config) { if (config == null) { return(false); } using (var client = new ProductConfigClient()) { var result = client.UpdateCarProductFlagshipStoreConfig(config); if (result.Success && result.Result) { return(true); } else { return(false); } } }
public bool DeleteConfig(string brand) { if (string.IsNullOrWhiteSpace(brand)) { return(false); } using (var client = new ProductConfigClient()) { var result = client.DeleteCarProductFlagshipStoreConfigByBrand(brand); if (result.Success && result.Result) { return(true); } else { return(false); } } }
public static List <RecommendProductModel> GetTireEnforceRecommendByPids(List <string> pids) { var returnResult = new List <RecommendProductModel>(); if (pids == null || !pids.Any() || pids.Count == 0) { return(returnResult); } try { using (var client = new ProductConfigClient()) { var result = client.GetTireEnforceRecommendByPids(pids.Distinct().ToList()); result.ThrowIfException(true); if (result.Success && result.Result != null && result.Result.Any() && result.Result.Count > 0) { var recommendPids = result.Result.Where(p => !string.IsNullOrWhiteSpace(p.RecommendPID)) .Select(p => p.RecommendPID) .Distinct() .ToList(); var displayNames = DALRecommendTire.GetDisplayName(recommendPids); result.Result.ForEach(item => returnResult.Add(new RecommendProductModel { PID = item.PId, Image = item.Image, Postion = item.Position, Reason = item.Reason, RecommendPID = item.RecommendPID, ProductName = displayNames.Where(p => p.PID == item.RecommendPID).FirstOrDefault().DisplayName })); } } return(returnResult); } catch (Exception ex) { //TODO:log return(returnResult); } }
public void SelectProductDiscountFromCacheAsync() { using (var client = new ProductConfigClient()) { var pidList = new List <string>() { "TR-CP-C1|3" }; var result = client.SetProductCommonTagDetailsCacheAsync(ProductCommonTag.Discount, pidList).Result; Assert.IsNotNull(result); var request = new ProductInfoByTagRequest() { Tags = new List <ProductCommonTag>() { ProductCommonTag.Discount }, Pids = pidList }; var result11 = client.SelectProductDiscountFromCacheAsync(pidList).Result; Assert.IsNotNull(result11); } }
SelectProductInfoByTagRequestAsync(ProductInfoByTagRequest request) { try { using (var client = new ProductConfigClient()) { var selectResult = await client.SelectProductInfoByTagRequestAsync(request); if (!selectResult.Success) { Logger.Error($"SelectProductInfoByTagRequestAsync fail => " + $"ErrorCode ={selectResult.ErrorCode} & ErrorMessage ={selectResult.ErrorMessage} "); } return(selectResult.Result); } } catch (Exception ex) { Logger.Error("SelectProductInfoByTagRequestAsync 接口异常", ex); return(null); } }
public static int SaveTireEnforceRecommend(List <QZTJModel> list) { List <TireEnforceRecommend> changeList = new List <TireEnforceRecommend>(); foreach (var recommend in list) { DALRecommendTire.DeleteQZTJByPID(recommend.PID); recommend.Products.ForEach(item => changeList.Add(new TireEnforceRecommend { PId = item.PID, RecommendPID = item.RecommendPID, Reason = item.Reason, Position = item.Postion, Image = item.Image, CreateDateTime = DateTime.Now })); } try { using (var client = new ProductConfigClient()) { var clientResult = client.CreateTireEnforceRecommend(changeList); clientResult.ThrowIfException(true); if (clientResult.Success) { return(clientResult.Result); } else { return(0); } } } catch (Exception ex) { //TODO:log return(0); } }
public bool InsertConfig(Tuhu.Service.Product.Models.ProductConfig.CarProductFlagshipStoreConfig config) { if (config == null) { return(false); } List <Tuhu.Service.Product.Models.ProductConfig.CarProductFlagshipStoreConfig> list = new List <Service.Product.Models.ProductConfig.CarProductFlagshipStoreConfig>(); list.Add(config); using (var client = new ProductConfigClient()) { var result = client.CreateCarProductFlagshipStoreConfig(list); if (result.Success && result.Result > 0) { return(true); } else { return(false); } } }
public JsonResult ImportGrade() { try { if (Request.Files.Count > 0) { var file = Request.Files[0]; if (!file.FileName.Contains(".xlsx") && !file.FileName.Contains(".xls")) { return(Json(new { Status = -1, Error = "请上传.xlsx文件或者.xls文件!" }, "text/html")); } var excel = new Controls.ExcelHelper(file.InputStream, file.FileName); var dt = excel.ExcelToDataTable("sheet1", true); var pids = new List <string>(); #region 失败数据表结构 DataTable dirtyData = new DataTable(); dirtyData.Columns.Add(new DataColumn("PID", typeof(string))); dirtyData.Columns.Add(new DataColumn("产品名称(质检)", typeof(string))); dirtyData.Columns.Add(new DataColumn("产地", typeof(string))); dirtyData.Columns.Add(new DataColumn("轮辋保护", typeof(string))); dirtyData.Columns.Add(new DataColumn("载重", typeof(string))); dirtyData.Columns.Add(new DataColumn("M+S", typeof(string))); dirtyData.Columns.Add(new DataColumn("Treadwear耐磨指数", typeof(string))); dirtyData.Columns.Add(new DataColumn("Traction抓地指数", typeof(string))); dirtyData.Columns.Add(new DataColumn("Temperature温度指数", typeof(string))); dirtyData.Columns.Add(new DataColumn("胎冠结构聚酯层数", typeof(string))); dirtyData.Columns.Add(new DataColumn("胎冠结构钢丝层数", typeof(string))); dirtyData.Columns.Add(new DataColumn("胎冠结构尼龙层数", typeof(string))); dirtyData.Columns.Add(new DataColumn("胎侧结构聚酯层数", typeof(string))); dirtyData.Columns.Add(new DataColumn("轮胎标签滚动阻力", typeof(string))); dirtyData.Columns.Add(new DataColumn("轮胎标签湿滑抓地性", typeof(string))); dirtyData.Columns.Add(new DataColumn("轮胎标签噪音", typeof(string))); dirtyData.Columns.Add(new DataColumn("花纹对称", typeof(string))); dirtyData.Columns.Add(new DataColumn("导向", typeof(string))); dirtyData.Columns.Add(new DataColumn("插入数据结果", typeof(string))); #endregion foreach (DataRow dr in dt.Rows) { DataRow dirtyRow = dirtyData.NewRow(); if (null == dr["PID"] || string.IsNullOrWhiteSpace(dr["PID"].ToString())) { for (int i = 0; i < dr.ItemArray.Length; i++) { dirtyRow[i] = dr[i]; } dirtyRow["插入数据结果"] = "失败,PID缺失."; dirtyData.Rows.Add(dirtyRow); continue; } else { var existData = TireSpecParamsConfigManager.CheckPidExist(dr["PID"].ToString().Trim()); if (dr["产品名称(质检)"] != null && !string.IsNullOrWhiteSpace(dr["产品名称(质检)"].ToString())) { TireSpecParamsConfig config = new TireSpecParamsConfig(); #region generate model config.PId = dr["PID"].ToString().Trim(); config.QualityInspectionName = dr["产品名称(质检)"]?.ToString(); config.OriginPlace = dr["产地"]?.ToString(); config.RimProtection = ( null == dr["轮辋保护"] || string.IsNullOrWhiteSpace(dr["轮辋保护"].ToString()) || !IsNum(dr["轮辋保护"].ToString()) ) ? false : Convert.ToInt32(dr["轮辋保护"]) == 1 ? true : false; config.TireLoad = dr["载重"]?.ToString(); config.MuddyAndSnow = ( null == dr["M+S"] || string.IsNullOrWhiteSpace(dr["M+S"].ToString()) || !IsNum(dr["M+S"].ToString()) ) ? false : Convert.ToInt32(dr["M+S"]) == 1 ? true : false; config.ThreeT_Treadwear = dr["Treadwear耐磨指数"]?.ToString(); config.ThreeT_Traction = dr["Traction抓地指数"]?.ToString(); config.ThreeT_Temperature = dr["Temperature温度指数"]?.ToString(); config.TireCrown_Polyester = ( null == dr["胎冠结构聚酯层数"] || string.IsNullOrWhiteSpace(dr["胎冠结构聚酯层数"].ToString()) || !IsNum(dr["胎冠结构聚酯层数"].ToString()) ) ? 0 : Convert.ToInt32(dr["胎冠结构聚酯层数"]); config.TireCrown_Steel = ( null == dr["胎冠结构钢丝层数"] || string.IsNullOrWhiteSpace(dr["胎冠结构钢丝层数"].ToString()) || !IsNum(dr["胎冠结构钢丝层数"].ToString()) ) ? 0 : Convert.ToInt32(dr["胎冠结构钢丝层数"]); config.TireCrown_Nylon = ( null == dr["胎冠结构尼龙层数"] || string.IsNullOrWhiteSpace(dr["胎冠结构尼龙层数"].ToString()) || !IsNum(dr["胎冠结构尼龙层数"].ToString()) ) ? 0 : Convert.ToInt32(dr["胎冠结构尼龙层数"]); config.TireSideWall_Polyester = ( null == dr["胎侧结构聚酯层数"] || string.IsNullOrWhiteSpace(dr["胎侧结构聚酯层数"].ToString()) || !IsNum(dr["胎侧结构聚酯层数"].ToString()) ) ? 0 : Convert.ToInt32(dr["胎侧结构聚酯层数"]); config.TireLable_RollResistance = dr["轮胎标签滚动阻力"]?.ToString(); config.TireLable_WetGrip = dr["轮胎标签湿滑抓地性"]?.ToString(); config.TireLable_Noise = dr["轮胎标签噪音"]?.ToString(); config.PatternSymmetry = dr["花纹对称"]?.ToString(); config.TireGuideRotation = dr["导向"]?.ToString(); config.FactoryCode = dr["工厂编码"].ToString(); config.GrooveNum = ( null == dr["沟槽数量"] || string.IsNullOrWhiteSpace(dr["沟槽数量"].ToString()) || !IsNum(dr["沟槽数量"].ToString()) ) ? 0 : Convert.ToInt32(dr["沟槽数量"]); config.Remark = dr["备注"].ToString(); config.CreateTime = DateTime.Now; config.LastUpdateDataTime = DateTime.Now; #endregion if (!existData) { try { TireSpecParamsConfigManager.InsertTireSpecParamsConfig(config); } catch (Exception ex) { for (int i = 0; i < dr.ItemArray.Length; i++) { dirtyRow[i] = dr[i]; } dirtyRow["插入数据结果"] = "数据插入失败." + ex.Message; dirtyData.Rows.Add(dirtyRow); continue; } } else { try { TireSpecParamsConfigManager.UpdateTireSpecParamsConfig(config); } catch (Exception ex) { for (int i = 0; i < dr.ItemArray.Length; i++) { dirtyRow[i] = dr[i]; } dirtyRow["插入数据结果"] = "数据更新失败." + ex.Message; dirtyData.Rows.Add(dirtyRow); continue; } } pids.Add(config.PId); } } } //批量刷新缓存 using (var clientConfig = new ProductConfigClient()) { clientConfig.RefreashTireSpecParamsConfigCache(pids); } //Response.Clear(); //Response.Charset = "UTF-8"; //Response.Buffer = true; //Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); //Response.AppendHeader("Content-Disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode("轮胎3T指数导入失败记录", System.Text.Encoding.UTF8) + ".xls\""); //Response.ContentType = "application/ms-excel"; //string colHeaders = string.Empty; //string ls_item = string.Empty; //DataRow[] myRow = dirtyData.Select(); //int cl = dirtyData.Columns.Count; //foreach (DataRow row in myRow) //{ // for (int i = 0; i < cl; i++) // { // if (i == (cl - 1)) // { // ls_item += row[i].ToString() + "\n"; // } // else // { // ls_item += row[i].ToString() + "\t"; // } // } //} //byte[] bytes = System.Text.Encoding.UTF8.GetBytes(ls_item.ToString()); //Response.AddHeader("Content-Length", bytes.Length.ToString()); //Response.BinaryWrite(bytes); //Response.Flush(); //Response.End(); return(Json(new { Status = 0, Result = "写入完成" })); } else { return(Json(new { Status = -1, Error = "请选择文件" })); } } catch (Exception ex) { WebLog.LogException(ex); return(Json(new { Status = -2, Error = ex })); } }
public void GetProductDiscountInfoForTag() { //验证情况:传入的pid都是有活动的pid //准备参数 string userId = "333"; string activityId = "7c709b97-88cf-4a42-a364-35893721da4e"; int orderId = 0; //338; var hitRequestList = new List <DiscountActivityRequest>() //下单验证 { new DiscountActivityRequest() { Pid = "TR-ME-ENERGY-XM2|17", Num = 5, Price = 818 }, // new DiscountActivityRequest(){ Pid="LF-GiGi-G-1069|8",Num=1,Price=400,PaymentMethod=2,InstallMethod=2 } }; var pidList = new List <string>() { "TR-ME-ENERGY-XM2|17", }; var orderInfoList = new List <DiscountCreateOrderRequest>() { new DiscountCreateOrderRequest() { UserId = userId, ActivityId = activityId, Num = 2, Pid = "TR-ME-ENERGY-XM2|17", OrderId = orderId }, //new DiscountCreateOrderRequest() //{ // UserId=userid, // ActivityId=activityid, // Num=1, // Pid="BD-BO-Common|105", // OrderId=orderId //}, }; var pidCount = pidList.Distinct().Count(); //1.验证打折标签 using (var client = new ProductConfigClient()) { //刷新标签缓存 //var result1 = client.SetProductCommonTagDetailsCacheAsync(ProductCommonTag.Discount, pidList).Result; var request = new ProductInfoByTagRequest() { Tags = new List <ProductCommonTag>() { ProductCommonTag.Discount }, Pids = pidList }; var tags = new List <ProductCommonTag>() { ProductCommonTag.Discount }; var result = client.SelectProductInfoByTagRequestAsync(request).Result.Result; var descList = result.Where(a => a.Value.Count > 0).Select(a => a.Value[0].TagDescription); var hasDesc = descList.Where(a => !string.IsNullOrWhiteSpace(a)).Any(); //验证是否有标签 Assert.IsNotNull(hasDesc); } //2.供标签缓存使用的接口 using (var client = new DiscountActivityInfoClient()) { pidList = pidList.Distinct().ToList(); DateTime startTime = DateTime.Now; DateTime endTime = startTime + TimeSpan.FromHours(12); var result = client.GetProductDiscountInfoForTag(pidList, startTime, endTime).Result.ToList(); Assert.IsTrue(result.Count == pidCount); } //3.验证详情页是否有打折信息和用户限购 using (var client = new DiscountActivityInfoClient()) { var result = client.GetProductAndUserDiscountInfo(pidList, userId).Result; var resultList = result.Where(a => a.HasDiscountActivity); Assert.IsTrue(resultList.Count() == pidCount); } //3.验证是否可以下单 using (var client = new DiscountActivityInfoClient()) { var result = client.GetProductAndUserHitDiscountInfo(hitRequestList, null).Result; var resultList = result.Where(a => a.HasDiscountActivity); Assert.IsTrue(resultList?.Count() == pidCount); } if (orderId > 0) { //4.验证下单是否成功 using (var client = new DiscountActivityInfoClient()) { var result = client.SaveCreateOrderDiscountInfoAndSetCache(orderInfoList).Result; Assert.IsTrue(result); } } using (var client = new DiscountActivityInfoClient()) { //验证活动用户已购数缓存 var userByNum = client.GetOrSetUserActivityBuyNumCacheAsync(userId, new List <string>() { activityId }).Result.Result; var userByNumList = userByNum.Where(a => a.BuyNum > 0); Assert.IsTrue(userByNumList?.Count() > 0); //验证活动商品已售数量缓存 var soldNum = client.GetOrSetActivityProductSoldNumCacheAsync(activityId, pidList).Result.Result; var soldNumList = soldNum.Where(a => a.SoldNum > 0); Assert.IsTrue(soldNumList?.Count() == pidCount); } if (orderId > 0) { //5.取消订单 using (var client = new DiscountActivityInfoClient()) { var result = client.UpdateCancelOrderDiscountInfoAndSetCache(orderId).Result; Assert.IsTrue(result); } } //取消订单后验证已购数量和已售数量 using (var client = new DiscountActivityInfoClient()) { //验证活动用户已购数缓存 var userByNum = client.GetOrSetUserActivityBuyNumCacheAsync(userId, new List <string>() { activityId }).Result.Result; var userByNumList = userByNum.Where(a => a.BuyNum == 0); Assert.IsTrue(userByNumList?.Count() > 0); //验证活动商品已售数量缓存 var soldNum = client.GetOrSetActivityProductSoldNumCacheAsync(activityId, pidList).Result.Result; var soldNumList = soldNum.Where(a => a.SoldNum == 0); Assert.IsTrue(soldNumList?.Count() == pidCount); } }