/// <summary> /// 根据置换订单信息,生成任务 /// </summary> /// <param name="tran"></param> /// <param name="model">置换订单信息</param> /// <returns>返回任务ID</returns> public long InsertByOrder(SqlTransaction tran, Entities.OrderRelpaceCarLog model) { Entities.OrderTask otModel = new Entities.OrderTask(); otModel.Source = 2;//1新车,2置换 otModel.TaskStatus = (int)TaskStatus.NoAllocation; otModel.RelationID = model.RecID; otModel.BGID = int.Parse(ConfigurationUtil.GetAppSettingValue("GenTaskDefaultGroupID")); otModel.AssignUserID = null; otModel.AssignTime = null; otModel.UserName = model.UserName; otModel.IsSelectDMSMember = null; otModel.Status = 0; otModel.SubmitTime = null; otModel.CreateTime = DateTime.Now; otModel.CreateUserID = null; otModel.NoDealerReasonID = -2; otModel.NoDealerReason = ""; otModel.DealerID = model.DealerID; return(Insert(tran, otModel)); }
/// <summary> /// 初始化置换订单日志信息 /// </summary> /// <param name="dr"></param> /// <returns></returns> private Entities.OrderRelpaceCarLog InitOrderRelpaceCarLog(DataRow dr) { Entities.OrderRelpaceCarLog model = new Entities.OrderRelpaceCarLog(); try { model.YPOrderID = int.Parse(dr["OrderBusinessOpportunityID"].ToString()); model.UserName = dr["UserName"].ToString().Trim(); model.UserPhone = dr["UserPhone"].ToString().Trim(); model.UserMobile = dr["UserMobile"].ToString().Trim(); model.UserMail = dr["UserMail"].ToString().Trim(); int userGender = -1; if (int.TryParse(dr["UserGender"].ToString(), out userGender)) { model.UserGender = userGender; } else { model.UserGender = null; } int locationID = -1; if (int.TryParse(dr["LocationID"].ToString(), out locationID)) { model.LocationID = locationID; } else { model.LocationID = null; } model.LocationName = dr["LocationName"].ToString().Trim(); model.UserAddress = dr["UserAddress"].ToString().Trim(); model.OrderCreateTime = DateTime.Parse(dr["OrderBusinessOpportunityCreateTime"].ToString()); decimal orderPrice = -1; if (decimal.TryParse(dr["OrderPrice"].ToString(), out orderPrice)) { model.OrderPrice = orderPrice; } else { model.OrderPrice = null; } int orderQuantity = -1; if (int.TryParse(dr["OrderQuantity"].ToString(), out orderQuantity)) { model.OrderQuantity = orderQuantity; } else { model.OrderQuantity = null; } model.OrderRemark = dr["OrderRemark"].ToString().Trim(); int carID = -1; if (int.TryParse(dr["CarID"].ToString(), out carID)) { model.CarID = carID; } else { model.CarID = null; } model.CarFullName = dr["CarFullName"].ToString().Trim(); decimal carPrice = -1; if (decimal.TryParse(dr["CarPrice"].ToString(), out carPrice)) { model.CarPrice = carPrice; } else { model.CarPrice = null; } model.CarColor = dr["CarColor"].ToString().Trim(); model.CarPromotions = dr["CarPromotions"].ToString().Trim(); int replacementCarId = -1; if (int.TryParse(dr["ReplacementCarId"].ToString(), out replacementCarId)) { model.ReplacementCarId = replacementCarId; } else { model.ReplacementCarId = null; } int replacementCarBuyYear = -1; if (int.TryParse(dr["ReplacementCarBuyYear"].ToString(), out replacementCarBuyYear)) { model.ReplacementCarBuyYear = replacementCarBuyYear; } else { model.ReplacementCarBuyYear = null; } int replacementCarBuyMonth = -1; if (int.TryParse(dr["ReplacementCarBuyMonth"].ToString(), out replacementCarBuyMonth)) { model.ReplacementCarBuyMonth = replacementCarBuyMonth; } else { model.ReplacementCarBuyMonth = null; } model.ReplacementCarColor = dr["ReplacementCarColor"].ToString().Trim(); decimal replacementCarUsedMiles = -1; if (decimal.TryParse(dr["ReplacementCarUsedMiles"].ToString(), out replacementCarUsedMiles)) { model.ReplacementCarUsedMiles = replacementCarUsedMiles; } else { model.ReplacementCarUsedMiles = null; } decimal saleprice = 0; if (decimal.TryParse(dr["SalePrice"].ToString(), out saleprice)) { model.SalePrice = saleprice; } else { model.SalePrice = null; } int replacementCarLocationID = -1; if (int.TryParse(dr["ReplacementCarLocationID"].ToString(), out replacementCarLocationID)) { model.ReplacementCarLocationID = replacementCarLocationID; } else { model.ReplacementCarLocationID = null; } int dealerID = -1; if (int.TryParse(dr["DealerID"].ToString(), out dealerID)) { model.DealerID = dealerID; } else { model.DealerID = null; } BLL.Loger.Log4Net.Info(string.Format("初始化置换订单单号{0}数据:订单价格:{1},购车价格:{2},行驶里程:{3},出售价格:{4},经销商ID:{5}", model.YPOrderID, model.OrderPrice, model.CarPrice, model.ReplacementCarUsedMiles, model.SalePrice, dealerID)); } catch (Exception ex) { BLL.Util.InsertUserLogNoUser("初始化置换订单信息失败!失败原因:" + ex.Message); return(null); } return(model); }
/// <summary> /// 生成任务 /// </summary> /// <param name="dt"></param> public void GenTask(DataTable dt) { int taskCount = 0; int existCount = 0; BLL.Loger.Log4Net.Info("生成_易湃_置换订单_开始:"); DateTime dtNow = DateTime.Now; DataTable dtNew = dt.Clone(); for (int i = 0; i < dt.Rows.Count; i++) { int YPOrderID = int.Parse(dt.Rows[i]["OrderBusinessOpportunityID"].ToString()); int dealerID = -1; int.TryParse(dt.Rows[i]["DealerID"].ToString(), out dealerID); if (BLL.OrderRelpaceCarLog.Instance.IsExistsByYPOrderID(YPOrderID))//存在 { BLL.Util.InsertUserLogNoUser("(置换)易湃订单ID:" + YPOrderID + "的记录已经存在,不在生成任务!"); } else if (dealerID > 0)//Add=Masj,Date=2013-08-26,去掉免费订单的相关数据 { BLL.Loger.Log4Net.Info("(置换)易湃订单ID:" + YPOrderID + "的记录经销商为" + dealerID + "(免费订单),不生成任务!"); } else//不存在 { dtNew.ImportRow(dt.Rows[i]); } } BLL.Loger.Log4Net.Info("检测拿到的置换订单数据中有" + existCount + "条数据在呼叫中心库中已经存在了"); string connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC"); SqlConnection connection = new SqlConnection(connectionstrings); connection.Open(); SqlTransaction tran = connection.BeginTransaction("OrderRelpaceCarLogTransaction"); try { for (int i = 0; i < dtNew.Rows.Count; i++) { Entities.OrderRelpaceCarLog model = InitOrderRelpaceCarLog(dtNew.Rows[i]); if (model != null) { long OrderRelpaceCarLogID = Insert(tran, model); //插入OrderRelpaceCarLog表 if (model.CarID != Constant.INT_INVALID_VALUE && model.CarID != 0) { //Add By Chybin At 2013.2.13 如果Carid和OrderQuantity为空,就只插入OrderRelpaceCarLog 表,不生成任务,不插入OrderRelpaceCar 表 //Add By Masj At 2013.7.26 OrderQuantity为空去掉限制了 long taskID = BLL.OrderTask.Instance.InsertByOrder(tran, model); if (BLL.OrderRelpaceCar.Instance.IsExistsByTaskID(taskID)) { BLL.Util.InsertUserLogNoUser(tran, "(置换)任务ID" + taskID + "的记录已经存在,不在生成任务!"); } else if (BLL.OrderRelpaceCar.Instance.InsertByTaskID(tran, taskID, model)) { BLL.Util.InsertUserLogNoUser(tran, "(置换)任务ID" + taskID + "的记录生成成功!"); taskCount++; } } } } //事务提交 tran.Commit(); } catch (Exception ex) { tran.Rollback(); string msg = "(置换)生成任务失败!失败原因:" + ex.Message; BLL.Util.InsertUserLogNoUser(msg); BLL.Loger.Log4Net.Error(msg, ex); } finally { connection.Close(); } string msgTitle = "一共生成(置换)任务:" + taskCount + "个"; BLL.Util.InsertUserLogNoUser(msgTitle); BLL.Loger.Log4Net.Error(msgTitle); TimeSpan ts = new TimeSpan(); ts = DateTime.Now - dtNow; BLL.Loger.Log4Net.Info("生成_易湃_置换订单_结束:" + msgTitle + ",用时" + ts.TotalSeconds + "秒。"); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(SqlTransaction sqltran, Entities.OrderRelpaceCarLog model) { return(Dal.OrderRelpaceCarLog.Instance.Update(sqltran, model)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(Entities.OrderRelpaceCarLog model) { return(Dal.OrderRelpaceCarLog.Instance.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public long Insert(SqlTransaction sqltran, Entities.OrderRelpaceCarLog model) { return(Dal.OrderRelpaceCarLog.Instance.Insert(sqltran, model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Insert(Entities.OrderRelpaceCarLog model) { return(Dal.OrderRelpaceCarLog.Instance.Insert(model)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(SqlTransaction sqltran, Entities.OrderRelpaceCarLog model) { SqlParameter[] parameters = { new SqlParameter("@RecID", SqlDbType.BigInt, 8), new SqlParameter("@YPOrderID", SqlDbType.Int, 4), new SqlParameter("@UserName", SqlDbType.NVarChar, 64), new SqlParameter("@UserPhone", SqlDbType.NVarChar, 64), new SqlParameter("@UserMobile", SqlDbType.NVarChar, 64), new SqlParameter("@UserMail", SqlDbType.NVarChar, 64), new SqlParameter("@UserGender", SqlDbType.Int, 4), new SqlParameter("@LocationID", SqlDbType.Int, 4), new SqlParameter("@LocationName", SqlDbType.NVarChar, 64), new SqlParameter("@UserAddress", SqlDbType.NVarChar, 1024), new SqlParameter("@OrderCreateTime", SqlDbType.SmallDateTime), new SqlParameter("@OrderPrice", SqlDbType.Decimal, 9), new SqlParameter("@OrderQuantity", SqlDbType.Int, 4), new SqlParameter("@OrderRemark", SqlDbType.NVarChar, 1024), new SqlParameter("@CarID", SqlDbType.Int, 4), new SqlParameter("@CarFullName", SqlDbType.NVarChar, 1024), new SqlParameter("@CarPrice", SqlDbType.Decimal, 9), new SqlParameter("@CarColor", SqlDbType.NVarChar, 16), new SqlParameter("@CarPromotions", SqlDbType.NVarChar, 1024), new SqlParameter("@ReplacementCarId", SqlDbType.Int, 4), new SqlParameter("@ReplacementCarBuyYear", SqlDbType.SmallInt, 2), new SqlParameter("@ReplacementCarBuyMonth", SqlDbType.SmallInt, 2), new SqlParameter("@ReplacementCarColor", SqlDbType.NVarChar, 16), new SqlParameter("@ReplacementCarUsedMiles", SqlDbType.Decimal, 9), new SqlParameter("@ReplacementCarLocationID", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@SalePrice", SqlDbType.Decimal, 9) }; parameters[0].Value = model.RecID; parameters[1].Value = model.YPOrderID; parameters[2].Value = model.UserName; parameters[3].Value = model.UserPhone; parameters[4].Value = model.UserMobile; parameters[5].Value = model.UserMail; parameters[6].Value = model.UserGender; parameters[7].Value = model.LocationID; parameters[8].Value = model.LocationName; parameters[9].Value = model.UserAddress; parameters[10].Value = model.OrderCreateTime; parameters[11].Value = model.OrderPrice; parameters[12].Value = model.OrderQuantity; parameters[13].Value = model.OrderRemark; parameters[14].Value = model.CarID; parameters[15].Value = model.CarFullName; parameters[16].Value = model.CarPrice; parameters[17].Value = model.CarColor; parameters[18].Value = model.CarPromotions; parameters[19].Value = model.ReplacementCarId; parameters[20].Value = model.ReplacementCarBuyYear; parameters[21].Value = model.ReplacementCarBuyMonth; parameters[22].Value = model.ReplacementCarColor; parameters[23].Value = model.ReplacementCarUsedMiles; parameters[24].Value = model.ReplacementCarLocationID; parameters[25].Value = model.CreateTime; parameters[26].Value = model.SalePrice; return(SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_ORDERRELPACECARLOG_UPDATE, parameters)); }
private Entities.OrderRelpaceCarLog LoadSingleOrderRelpaceCarLog(DataRow row) { Entities.OrderRelpaceCarLog model = new Entities.OrderRelpaceCarLog(); if (row["RecID"].ToString() != "") { model.RecID = long.Parse(row["RecID"].ToString()); } if (row["YPOrderID"].ToString() != "") { model.YPOrderID = int.Parse(row["YPOrderID"].ToString()); } model.UserName = row["UserName"].ToString(); model.UserPhone = row["UserPhone"].ToString(); model.UserMobile = row["UserMobile"].ToString(); model.UserMail = row["UserMail"].ToString(); if (row["UserGender"].ToString() != "") { model.UserGender = int.Parse(row["UserGender"].ToString()); } if (row["LocationID"].ToString() != "") { model.LocationID = int.Parse(row["LocationID"].ToString()); } model.LocationName = row["LocationName"].ToString(); model.UserAddress = row["UserAddress"].ToString(); if (row["OrderCreateTime"].ToString() != "") { model.OrderCreateTime = DateTime.Parse(row["OrderCreateTime"].ToString()); } if (row["OrderPrice"].ToString() != "") { model.OrderPrice = decimal.Parse(row["OrderPrice"].ToString()); } if (row["OrderQuantity"].ToString() != "") { model.OrderQuantity = int.Parse(row["OrderQuantity"].ToString()); } model.OrderRemark = row["OrderRemark"].ToString(); if (row["CarID"].ToString() != "") { model.CarID = int.Parse(row["CarID"].ToString()); } model.CarFullName = row["CarFullName"].ToString(); if (row["CarPrice"].ToString() != "") { model.CarPrice = decimal.Parse(row["CarPrice"].ToString()); } model.CarColor = row["CarColor"].ToString(); model.CarPromotions = row["CarPromotions"].ToString(); if (row["ReplacementCarId"].ToString() != "") { model.ReplacementCarId = int.Parse(row["ReplacementCarId"].ToString()); } if (row["ReplacementCarBuyYear"].ToString() != "") { model.ReplacementCarBuyYear = int.Parse(row["ReplacementCarBuyYear"].ToString()); } if (row["ReplacementCarBuyMonth"].ToString() != "") { model.ReplacementCarBuyMonth = int.Parse(row["ReplacementCarBuyMonth"].ToString()); } model.ReplacementCarColor = row["ReplacementCarColor"].ToString(); if (row["ReplacementCarUsedMiles"].ToString() != "") { model.ReplacementCarUsedMiles = decimal.Parse(row["ReplacementCarUsedMiles"].ToString()); } if (row["SalePrice"].ToString() != "") { model.SalePrice = decimal.Parse(row["SalePrice"].ToString()); } if (row["ReplacementCarLocationID"].ToString() != "") { model.ReplacementCarLocationID = int.Parse(row["ReplacementCarLocationID"].ToString()); } if (row["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(row["CreateTime"].ToString()); } return(model); }
/// <summary> /// 根据易湃置换订单实体信息,插入表OrderRelpaceCar信息 /// </summary> /// <param name="tran"></param> /// <param name="taskID">任务ID</param> /// <param name="model">易湃置换订单实体信息</param> /// <returns></returns> public bool InsertByTaskID(SqlTransaction tran, long taskID, Entities.OrderRelpaceCarLog model) { Entities.OrderRelpaceCar orModel = new Entities.OrderRelpaceCar(); orModel.TaskID = taskID; orModel.YPOrderID = model.YPOrderID; orModel.UserName = model.UserName; orModel.UserPhone = model.UserPhone; orModel.UserMobile = model.UserMobile; orModel.UserMail = model.UserMail; if (model.UserGender != null && model.UserGender.Value == 0) { orModel.UserGender = 2;//性别“女” } else { orModel.UserGender = model.UserGender; } orModel.ProvinceID = null; orModel.CityID = null; orModel.CountyID = null; if (model.LocationID != null) { string locationName = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaStrByAreaID(model.LocationID.Value.ToString()); switch (locationName.Split(',').Length) { case 1: orModel.ProvinceID = int.Parse(locationName.Split(',')[0]); break; case 2: orModel.ProvinceID = int.Parse(locationName.Split(',')[0]); orModel.CityID = int.Parse(locationName.Split(',')[1]); break; case 3: orModel.ProvinceID = int.Parse(locationName.Split(',')[0]); orModel.CityID = int.Parse(locationName.Split(',')[1]); orModel.CountyID = int.Parse(locationName.Split(',')[2]); break; default: break; } } orModel.AreaID = null; orModel.UserAddress = model.UserAddress; orModel.OrderCreateTime = model.OrderCreateTime; orModel.OrderRemark = model.OrderRemark; orModel.CarMasterID = null; orModel.CarSerialID = null; orModel.CarTypeID = null; if (model.CarID != null) { orModel.CarTypeID = model.CarID; int CarMasterID = 0; int CarSerialID = 0; int brandID = 0; BLL.CarTypeAPI.Instance.GetSerialIDAndMasterBrandIDByCarTypeID(model.CarID.Value, out CarSerialID, out CarMasterID, out brandID); //orModel.CarMasterID = CarMasterID; //orModel.CarSerialID = CarSerialID; if (CarMasterID > 0) { orModel.CarMasterID = CarMasterID; } if (CarSerialID > 0) { orModel.CarSerialID = CarSerialID; } } orModel.CarPrice = model.CarPrice; orModel.CarColor = model.CarColor; orModel.RepCarMasterID = null; orModel.RepCarSerialID = null; orModel.RepCarTypeId = null; if (model.ReplacementCarId != null) { orModel.RepCarTypeId = model.ReplacementCarId; int CarMasterID = 0; int CarSerialID = 0; int brandID = 0; BLL.CarTypeAPI.Instance.GetSerialIDAndMasterBrandIDByCarTypeID(model.ReplacementCarId.Value, out CarSerialID, out CarMasterID, out brandID); //orModel.RepCarMasterID = CarMasterID; //orModel.RepCarSerialID = CarSerialID; if (CarMasterID > 0) { orModel.RepCarMasterID = CarMasterID; } if (CarSerialID > 0) { orModel.RepCarSerialID = CarSerialID; } } orModel.ReplacementCarBuyYear = model.ReplacementCarBuyYear; orModel.ReplacementCarBuyMonth = model.ReplacementCarBuyMonth; orModel.ReplacementCarColor = model.ReplacementCarColor; orModel.ReplacementCarUsedMiles = model.ReplacementCarUsedMiles; orModel.SalePrice = model.SalePrice; orModel.RepCarProvinceID = null; orModel.RepCarCityID = null; orModel.RepCarCountyID = null; if (model.ReplacementCarLocationID != null) { string locationName = BitAuto.YanFa.Crm2009.BLL.AreaInfo.Instance.GetAreaStrByAreaID(model.ReplacementCarLocationID.Value.ToString()); switch (locationName.Split(',').Length) { case 1: orModel.RepCarProvinceID = int.Parse(locationName.Split(',')[0]); break; case 2: orModel.RepCarProvinceID = int.Parse(locationName.Split(',')[0]); orModel.RepCarCityID = int.Parse(locationName.Split(',')[1]); break; case 3: orModel.RepCarProvinceID = int.Parse(locationName.Split(',')[0]); orModel.RepCarCityID = int.Parse(locationName.Split(',')[1]); orModel.RepCarCountyID = int.Parse(locationName.Split(',')[2]); break; default: break; } } orModel.DMSMemberCode = string.Empty; orModel.DMSMemberName = string.Empty; orModel.CallRecord = string.Empty; orModel.Status = 0; orModel.CreateTime = DateTime.Now; orModel.DealerID = model.DealerID; int recid = Insert(tran, orModel); if (recid > 0) { return(true); } return(false); }