private async Task <bool> CreateOrUpdateTireInstallmentAsync(TireInstallmentModel m) { try { string userNo = HttpContext.User.Identity.Name; using (var productclient = new Tuhu.Service.Product.ProductConfigClient()) { string content = await GetModifyLogStringAsync(m); var log = new TireInstallmentConfigLog() { PID = m.PID, User = userNo, Content = content }; var createresult = await productclient.CreateOrUpdateTireInstallmentAsync(m); createresult.ThrowIfException(true); var logresult = await productclient.LogTireInstallmentConfigAsync(log); return(true); } } catch (System.Exception ex) { return(false); } }
public PartialViewResult InstallmentList(TireInstallmentQueryRequest query) { using (var client = new Tuhu.Service.Product.ProductConfigClient()) { if (!string.IsNullOrEmpty(Request.QueryString["IsOnSale"])) { query.IsOnSale = Request.QueryString["IsOnSale"] == "1"; } if (!string.IsNullOrEmpty(Request.QueryString["IsInstallmentOpen"])) { query.IsInstallmentOpen = Request.QueryString["IsInstallmentOpen"] == "1"; } Service.OperationResult <Tuhu.Models.PagedModel <Service.Product.Response.TireInstallmentQueryResponse> > result = null; string categoryName = query.CategoryName ?? "Tires"; switch (categoryName) { case "Tires": result = client.QueryTireInstallment(query); break; default: query.CategoryName = categoryName; result = client.QueryInstallmentByCategoryName(query); break; } result.ThrowIfException(true); ViewBag.Query = query; ViewBag.CategoryName = categoryName; return(PartialView(result.Result)); } }
public ActionResult ShowTireInstallmentLog(string pid) { using (var client = new Tuhu.Service.Product.ProductConfigClient()) { var result = client.SelectTireInstallmentLogs(pid); result.ThrowIfException(true); var datas = result.Result; return(View(datas)); } }
public async Task <JsonResult> BatchSaveTireInstallmentConfigAsync(TireInstallmentModel model, IEnumerable <string> pids) { JsonResult jr = new JsonResult(); try { foreach (var pid in pids) { using (var logclient = new Tuhu.Service.Product.ProductConfigClient()) { using (var client = new Tuhu.Service.Product.ProductConfigClient()) { model.PID = pid; string userNo = HttpContext.User.Identity.Name; string content = await GetModifyLogStringAsync(model); var log = new TireInstallmentConfigLog() { PID = pid, User = userNo, Content = content }; var result = await client.CreateOrUpdateTireInstallmentAsync(model); result.ThrowIfException(true); var logresult = await logclient.LogTireInstallmentConfigAsync(log); } } } jr.Data = new { code = 1, msg = "操作成功" }; return(jr); } catch (System.Exception ex) { jr.Data = new { code = 0, msg = $"操作失败....ex:{ex}" }; return(jr); } }
private async Task <string> GetModifyLogStringAsync(TireInstallmentModel model) { using (var client = new Tuhu.Service.Product.ProductConfigClient()) { var queryresult = await client.SelectTireInstallmentByPIDAsync(model.PID); queryresult.ThrowIfException(true); var originmodel = queryresult.Result; if (originmodel == null) { return("创建"); } var props = typeof(TireInstallmentModel).GetProperties(); Dictionary <string, string> propnames = new Dictionary <string, string>() { { "IsInstallmentOpen", "分期是否打开" }, { "ThreePeriods", "三期" }, { "SixPeriods", "六期" }, { "TwelvePeriods", "十二期" }, }; StringBuilder sb = new StringBuilder(); foreach (var prop in props) { if (propnames.ContainsKey(prop.Name)) { var ogiginvalue = prop.GetValue(originmodel); var modifyvalue = prop.GetValue(model); if (!string.Equals(ogiginvalue, modifyvalue)) { sb.Append($" {propnames[prop.Name]} => 修改前:{(string.IsNullOrEmpty(ogiginvalue?.ToString()) ? "无" : ogiginvalue)}. " + $"修改后:{(string.IsNullOrEmpty(modifyvalue?.ToString()) ? "无" : modifyvalue)}"); } } } return(sb.ToString()); } }
public async Task <JsonResult> SaveTireInstallmentConfigAsync(TireInstallmentModel model) { JsonResult jr = new JsonResult(); try { using (var logclient = new Tuhu.Service.Product.ProductConfigClient()) { using (var client = new Tuhu.Service.Product.ProductConfigClient()) { string userNo = HttpContext.User.Identity.Name; string content = await GetModifyLogStringAsync(model); var log = new TireInstallmentConfigLog() { PID = model.PID, User = userNo, Content = content }; var result = await client.CreateOrUpdateTireInstallmentAsync(model); result.ThrowIfException(true); jr.Data = new { code = result.Result > 0 ? 1 : 0, msg = result.Result > 0 ? "操作成功" : "操作失败..." }; var logresult = await logclient.LogTireInstallmentConfigAsync(log); logresult.ThrowIfException(true); return(jr); } } } catch (System.Exception ex) { jr.Data = new { code = 0, msg = $"操作失败....ex:{ex}" }; return(jr); } }
public async System.Threading.Tasks.Task <JsonResult> EditCanUseCoupon(IEnumerable <string> pids, bool canUseCoupon) { JsonResult jr = new JsonResult(); var checkresults = ThirdShopManager.SelectProductCouponPrice(pids); var exists = pids.Where(x => checkresults.ContainsKey(x)); if (exists.Any()) { jr.Data = new { code = 0, msg = $"已配置券后价.pid:{string.Join(" , ", exists)}" }; return(jr); } Dictionary <string, bool> beforvalues = new Dictionary <string, bool>(); List <ProductExtraProperties> models = new List <ProductExtraProperties>(); using (var client = new Tuhu.Service.Product.ProductConfigClient()) { var getresult = client.SelectProductExtraPropertiesByPids(pids); getresult.ThrowIfException(true); foreach (var pid in pids) { var item = getresult.Result.FirstOrDefault(x => x.PID == pid) ?? new ProductExtraProperties() { PID = pid, CanUseCoupon = true }; beforvalues[pid] = item.CanUseCoupon; item.CanUseCoupon = canUseCoupon; models.Add(item); } if (models.Any()) { var updateresult = client.BatchCreateOrUpdateProductExtraProperties(models); updateresult.ThrowIfException(true); jr.Data = new { code = updateresult.Result > 0 ? 1 : 0, msg = updateresult.Result > 0 ? "保存成功" : "保存失败" }; var logs = pids.Select(x => new TireModifyConfigLog() { Pid = x, Type = "CanUseCoupon", UserId = HttpContext.User.Identity.Name, Before = (beforvalues.ContainsKey(x) ? beforvalues[x] : true).ToString(), After = canUseCoupon.ToString() }); await TireInsuranceYearsManager.WriteLogsAsync(logs); return(jr); } else { jr.Data = new { code = 0, msg = "数据错误" }; return(jr); } } }