public List <RebateConfigModel> UpsertOldRebateApply(List <RebateConfigModel> data, string user) { var result = new List <RebateConfigModel>(); try { dbScopeManager.CreateTransaction(conn => { foreach (var item in data) { item.RebateTime = item.CreateTime; item.RebateMoney = 58; item.Status = Status.Complete; var pkid = DALRebateConfig.InsertRebateConfig(conn, item); result.Add(new RebateConfigModel() { OrderId = item.OrderId, Remarks = "插入成功" }); InsertLog(pkid.ToString(), "UploadFile", pkid > 0 ? "导入成功" : "导入失败", JsonConvert.SerializeObject(item), string.Empty, string.Empty, user); } }); } catch (Exception ex) { logger.Error(ex); } return(result); }
public Tuple <bool, string> InsertRebateConfig(RebateConfigModel data, string user) { var result = 0; var msg = string.Empty; try { dbScopeManager.Execute(conn => { var existedData = DALRebateConfig.SelectRebateApplyConfigByParam(conn, data); existedData = existedData.Where(_ => String.Equals(_.Source, "爱卡") || String.Equals(_.Source, "汽车之家")).ToList(); if (existedData?.Where(x => String.Equals(x.OrderId, data.OrderId)).Count() > 0 || existedData?.Where(x => String.Equals(x.UserPhone, data.UserPhone)).Count() > 0) { msg = "每个客户只能参与一次(包含手机号、订单号、微信号)均视为同一客户"; } else { data.RebateMoney = 58M; data.Status = Status.Applying; result = DALRebateConfig.InsertRebateConfig(conn, data); } }); } catch (Exception ex) { logger.Error(ex); } InsertLog(result.ToString(), "InsertRebateConfig", result > 0 ? "添加成功" : "添加失败", $"PKID:{result.ToString()},Status:Applying", string.Empty, string.Empty, user); return(Tuple.Create(result > 0, msg)); }
public Tuple <bool, string> InsertRebateConfig(RebateConfigModel data, string user) { var result = 0; var msg = string.Empty; try { dbScopeManager.CreateTransaction(conn => { var existedData = DALRebateConfig.SelectRebateApplyConfigByParam(conn, data); if (String.Equals(data.Source, "Rebate25")) { existedData = existedData.Where(_ => String.Equals(_.Source, "Rebate25")).ToList(); if (existedData?.Where(x => String.Equals(x.OrderId, data.OrderId)).Count() > 0 || existedData?.Where(x => String.Equals(x.UserPhone, data.UserPhone)).Count() > 0) { data.Remarks += " 重复返现"; } data.RebateMoney = 25M; data.Status = Status.Complete; data.RebateTime = DateTime.Now; data.InstallShopId = OrderService.FetchOrderByOrderId(data.OrderId)?.InstallShopId ?? 0; data.PKID = DALRebateConfig.InsertRebateConfig(conn, data); if (data.PKID > 0 && data.ImgList != null && data.ImgList.Any()) { foreach (var item in data.ImgList) { DALRebateConfig.InsertRebateImgConfig(conn, data.PKID, item.ImgUrl, ImgSource.UserImg, string.Empty); } } result = data.PKID; } else { existedData = existedData.Where(_ => String.Equals(_.Source, "爱卡") || String.Equals(_.Source, "汽车之家")).ToList(); if (existedData?.Where(x => String.Equals(x.OrderId, data.OrderId)).Count() > 0 || existedData?.Where(x => String.Equals(x.UserPhone, data.UserPhone)).Count() > 0) { msg = "每个客户只能参与一次(包含手机号、订单号、微信号)均视为同一客户"; } else { data.RebateMoney = 58M; data.Status = Status.Applying; data.InstallShopId = OrderService.FetchOrderByOrderId(data.OrderId)?.InstallShopId ?? 0; result = DALRebateConfig.InsertRebateConfig(conn, data); } } }); } catch (Exception ex) { logger.Error(ex); } InsertLog(result.ToString(), "InsertRebateConfig", result > 0 ? "添加成功" : "添加失败", $"PKID:{result.ToString()},Status:Applying", string.Empty, string.Empty, user); return(Tuple.Create(result > 0, msg)); }