Пример #1
0
        /// <summary>
        /// 初始化团购订单日志信息
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        private Entities.GroupOrderOrg InitOrderNewCarLog(DataRow dr)
        {
            Entities.GroupOrderOrg model = new Entities.GroupOrderOrg();

            try
            {
                model.OrderID         = int.Parse(dr["OrderID"].ToString());
                model.OrderCode       = int.Parse(dr["OrderCode"].ToString().Trim());
                model.CarMasterID     = (int?)GetColumnDefaultValue(dr, "CarMasterID", typeof(int));
                model.CarMasterName   = dr["CarMasterName"].ToString().Trim();
                model.CarSerialID     = (int?)GetColumnDefaultValue(dr, "CarSerialID", typeof(int));
                model.CarSerialName   = dr["CarSerialName"].ToString().Trim();
                model.CarID           = (int?)GetColumnDefaultValue(dr, "CarID", typeof(int));
                model.CarName         = dr["CarName"].ToString().Trim();
                model.Price           = (decimal?)GetColumnDefaultValue(dr, "Price", typeof(decimal));
                model.DealerID        = (int?)GetColumnDefaultValue(dr, "DealerID", typeof(int));
                model.DealerName      = dr["DealerName"].ToString().Trim();
                model.CustomerName    = dr["CustomerName"].ToString().Trim();
                model.CustomerTel     = dr["CustomerTel"].ToString().Trim();
                model.OrderCreateTime = DateTime.Parse(dr["CreateDateTime"].ToString());
                model.ProvinceID      = (int?)GetColumnDefaultValue(dr, "ProvinceID", typeof(int));
                model.ProvinceName    = dr["ProvinceName"].ToString().Trim();
                model.CityID          = (int?)GetColumnDefaultValue(dr, "CityID", typeof(int));
                model.CityName        = dr["CityName"].ToString().Trim();
            }
            catch (Exception ex)
            {
                BLL.Util.InsertUserLogNoUser("初始化团购订单信息失败!失败原因:" + ex.Message);
                return(null);
            }
            return(model);
        }
Пример #2
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public long Insert(SqlTransaction sqltran, Entities.GroupOrderOrg model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@RecID",           SqlDbType.BigInt,      8),
                new SqlParameter("@OrderID",         SqlDbType.Int,         4),
                new SqlParameter("@OrderCode",       SqlDbType.Int,         4),
                new SqlParameter("@CustomerName",    SqlDbType.NVarChar,  100),
                new SqlParameter("@CustomerTel",     SqlDbType.NVarChar,   50),
                new SqlParameter("@ProvinceID",      SqlDbType.Int,         4),
                new SqlParameter("@ProvinceName",    SqlDbType.NVarChar,  100),
                new SqlParameter("@CityID",          SqlDbType.Int,         4),
                new SqlParameter("@CityName",        SqlDbType.NVarChar,  100),
                new SqlParameter("@OrderCreateTime", SqlDbType.DateTime),
                new SqlParameter("@Price",           SqlDbType.Decimal,    18),
                new SqlParameter("@CarMasterID",     SqlDbType.Int,         4),
                new SqlParameter("@CarMasterName",   SqlDbType.NVarChar,  100),
                new SqlParameter("@CarSerialID",     SqlDbType.Int,         4),
                new SqlParameter("@CarSerialName",   SqlDbType.NVarChar,  100),
                new SqlParameter("@CarID",           SqlDbType.Int,         4),
                new SqlParameter("@CarName",         SqlDbType.NVarChar,  100),
                new SqlParameter("@DealerID",        SqlDbType.Int,         4),
                new SqlParameter("@DealerName",      SqlDbType.NVarChar, 100)
            };
            //new SqlParameter("@CreateTime", SqlDbType.DateTime),
            //new SqlParameter("@CreateUserID", SqlDbType.Int,4)};
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.OrderID;
            parameters[2].Value     = model.OrderCode;
            parameters[3].Value     = model.CustomerName;
            parameters[4].Value     = model.CustomerTel;
            parameters[5].Value     = model.ProvinceID;
            parameters[6].Value     = model.ProvinceName;
            parameters[7].Value     = model.CityID;
            parameters[8].Value     = model.CityName;
            parameters[9].Value     = model.OrderCreateTime;
            parameters[10].Value    = model.Price;
            parameters[11].Value    = model.CarMasterID;
            parameters[12].Value    = model.CarMasterName;
            parameters[13].Value    = model.CarSerialID;
            parameters[14].Value    = model.CarSerialName;
            parameters[15].Value    = model.CarID;
            parameters[16].Value    = model.CarName;
            parameters[17].Value    = model.DealerID;
            parameters[18].Value    = model.DealerName;
            //parameters[19].Value = model.CreateTime;
            //parameters[20].Value = model.CreateUserID;

            SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_GROUPORDERORG_INSERT, parameters);
            return((long)parameters[0].Value);
        }
Пример #3
0
        /// <summary>
        /// 根据易湃团购订单实体信息,插入表GroupOrder信息
        /// </summary>
        /// <param name="tran"></param>
        /// <param name="taskID">任务ID</param>
        /// <param name="model">易湃团购订单实体信息</param>
        /// <returns></returns>
        public bool InsertByTaskID(SqlTransaction tran, long taskID, Entities.GroupOrderOrg model)
        {
            Entities.GroupOrder onModel = new Entities.GroupOrder();
            onModel.TaskID       = taskID;
            onModel.OrderID      = model.OrderID;
            onModel.OrderCode    = model.OrderCode;
            onModel.CustomerName = model.CustomerName.Trim();
            onModel.CustomerTel  = model.CustomerTel.Trim();
            onModel.ProvinceID   = model.ProvinceID;
            onModel.ProvinceName = model.ProvinceName;
            onModel.CityID       = model.CityID;
            onModel.CityName     = model.CityName;

            //修改大区 强斐 2014-12-17
            BitAuto.YanFa.Crm2009.Entities.AreaInfo info = Util.GetAreaInfoByPCC(
                CommonFunction.ObjectToString(model.ProvinceID),
                CommonFunction.ObjectToString(model.CityID),
                null);
            onModel.AreaID = info == null ? "" : info.District;

            onModel.OrderCreateTime  = model.OrderCreateTime;
            onModel.CarMasterID      = model.CarMasterID;
            onModel.CarMasterName    = model.CarMasterName;
            onModel.CarSerialID      = model.CarSerialID;
            onModel.CarSerialName    = model.CarSerialName;
            onModel.CarID            = model.CarID;
            onModel.CarName          = model.CarName;
            onModel.DealerID         = model.DealerID;
            onModel.DealerName       = model.DealerName;
            onModel.OrderPrice       = model.Price;
            onModel.CreateTime       = DateTime.Now;
            onModel.CreateUserID     = null;
            onModel.LastUpdateTime   = null;
            onModel.LastUpdateUserID = null;
            onModel.UserName         = null;


            long recid = Insert(tran, onModel);

            if (recid > 0)
            {
                BLL.Loger.Log4Net.Info(string.Format("团购任务生成表GroupOrder成功,主键ID为:{0},无主订单ID为:{1},车款ID:{2},子品牌ID:{3},主品牌ID为:{4}",
                                                     recid, onModel.OrderID,
                                                     onModel.CarID == null ? 0 : onModel.CarID.Value,
                                                     onModel.CarSerialID == null ? 0 : onModel.CarSerialID.Value,
                                                     onModel.CarMasterID == null ? 0 : onModel.CarMasterID.Value
                                                     ));
                return(true);
            }
            return(false);
        }
Пример #4
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public int Update(Entities.GroupOrderOrg model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@RecID",           SqlDbType.BigInt,      8),
                new SqlParameter("@OrderID",         SqlDbType.Int,         4),
                new SqlParameter("@OrderCode",       SqlDbType.Int,         4),
                new SqlParameter("@CustomerName",    SqlDbType.NVarChar,  100),
                new SqlParameter("@CustomerTel",     SqlDbType.NVarChar,   50),
                new SqlParameter("@ProvinceID",      SqlDbType.Int,         4),
                new SqlParameter("@ProvinceName",    SqlDbType.NVarChar,  100),
                new SqlParameter("@CityID",          SqlDbType.Int,         4),
                new SqlParameter("@CityName",        SqlDbType.NVarChar,  100),
                new SqlParameter("@OrderCreateTime", SqlDbType.DateTime),
                new SqlParameter("@Price",           SqlDbType.Decimal,     9),
                new SqlParameter("@CarMasterID",     SqlDbType.Int,         4),
                new SqlParameter("@CarMasterName",   SqlDbType.NVarChar,  100),
                new SqlParameter("@CarSerialID",     SqlDbType.Int,         4),
                new SqlParameter("@CarSerialName",   SqlDbType.NVarChar,  100),
                new SqlParameter("@CarID",           SqlDbType.Int,         4),
                new SqlParameter("@CarName",         SqlDbType.NVarChar,  100),
                new SqlParameter("@DealerID",        SqlDbType.Int,         4),
                new SqlParameter("@DealerName",      SqlDbType.NVarChar,  100),
                new SqlParameter("@CreateTime",      SqlDbType.DateTime),
                new SqlParameter("@CreateUserID",    SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.RecID;
            parameters[1].Value  = model.OrderID;
            parameters[2].Value  = model.OrderCode;
            parameters[3].Value  = model.CustomerName;
            parameters[4].Value  = model.CustomerTel;
            parameters[5].Value  = model.ProvinceID;
            parameters[6].Value  = model.ProvinceName;
            parameters[7].Value  = model.CityID;
            parameters[8].Value  = model.CityName;
            parameters[9].Value  = model.OrderCreateTime;
            parameters[10].Value = model.Price;
            parameters[11].Value = model.CarMasterID;
            parameters[12].Value = model.CarMasterName;
            parameters[13].Value = model.CarSerialID;
            parameters[14].Value = model.CarSerialName;
            parameters[15].Value = model.CarID;
            parameters[16].Value = model.CarName;
            parameters[17].Value = model.DealerID;
            parameters[18].Value = model.DealerName;
            parameters[19].Value = model.CreateTime;
            parameters[20].Value = model.CreateUserID;

            return(SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_GROUPORDERORG_UPDATE, parameters));
        }
Пример #5
0
        /// <summary>
        /// 根据团购订单信息,生成任务
        /// </summary>
        /// <param name="tran"></param>
        /// <param name="model">团购订单信息</param>
        /// <returns>返回任务ID</returns>
        public long InsertByOrder(SqlTransaction tran, Entities.GroupOrderOrg model)
        {
            Entities.GroupOrderTask otModel = new Entities.GroupOrderTask();
            otModel.TaskStatus       = (int)Entities.GroupTaskStatus.NoAllocation;
            otModel.OrderID          = model.OrderID;
            otModel.BGID             = int.Parse(ConfigurationUtil.GetAppSettingValue("GenTaskDefaultGroupID"));
            otModel.SCID             = int.Parse(ConfigurationUtil.GetAppSettingValue("GenTaskDefaultCategoryID"));
            otModel.AssignUserID     = null;
            otModel.AssignTime       = null;
            otModel.SubmitTime       = null;
            otModel.CreateTime       = DateTime.Now;
            otModel.CreateUserID     = null;
            otModel.LastUpdateTime   = null;
            otModel.LastUpdateUserID = null;

            return(Insert(tran, otModel));
        }
Пример #6
0
        /// <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]["OrderID"].ToString());
                if (BLL.GroupOrderOrg.Instance.IsExistsByYPOrderID(YPOrderID))//存在
                {
                    BLL.Util.InsertUserLogNoUser("易湃团购订单ID:" + YPOrderID + "的记录已经存在,不在生成任务!"); existCount++;
                }
                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("GroupOrderOrgTransaction");

            try
            {
                for (int i = 0; i < dtNew.Rows.Count; i++)
                {
                    Entities.GroupOrderOrg model = InitOrderNewCarLog(dtNew.Rows[i]);
                    if (model != null)
                    {
                        long GroupOrderOrgID = Insert(tran, model); //插入 GroupOrderOrg 表
                        BLL.Loger.Log4Net.Info(string.Format("团购任务生成表GroupOrderOrg成功,主键ID为:{0},易湃订单ID为:{1},车款ID:{2}",
                                                             GroupOrderOrgID, model.OrderID, model.CarID));

                        if (model.CarMasterID != null && model.CarMasterID.Value > 0 &&
                            model.CarSerialID != null && model.CarSerialID.Value > 0 &&
                            model.CarID != null && model.CarID.Value > 0)
                        {
                            //Add By Masj At 2013.12.4 车型为空,就只插入GroupOrderOrg 表,不生成任务,不插入GroupOrder 表
                            long taskID = BLL.GroupOrderTask.Instance.InsertByOrder(tran, model); //根据接口得到的原始数据生成任务
                            if (BLL.GroupOrder.Instance.IsExistsByTaskID(taskID))
                            {
                                BLL.Util.InsertUserLogNoUser(tran, "团购任务ID" + taskID + "的记录已经存在,不在生成任务!");
                            }
                            else if (BLL.GroupOrder.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);
            TimeSpan ts = new TimeSpan();

            ts = DateTime.Now - dtNow;
            BLL.Loger.Log4Net.Info("生成_易湃_团购订单_结束:" + msgTitle + ",用时" + ts.TotalSeconds + "秒。");
        }
Пример #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(SqlTransaction sqltran, Entities.GroupOrderOrg model)
 {
     return(Dal.GroupOrderOrg.Instance.Update(sqltran, model));
 }
Пример #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Entities.GroupOrderOrg model)
 {
     return(Dal.GroupOrderOrg.Instance.Update(model));
 }
Пример #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public long Insert(SqlTransaction sqltran, Entities.GroupOrderOrg model)
 {
     return(Dal.GroupOrderOrg.Instance.Insert(sqltran, model));
 }
Пример #10
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Insert(Entities.GroupOrderOrg model)
 {
     return(Dal.GroupOrderOrg.Instance.Insert(model));
 }
Пример #11
0
        private Entities.GroupOrderOrg LoadSingleGroupOrderOrg(DataRow row)
        {
            Entities.GroupOrderOrg model = new Entities.GroupOrderOrg();

            if (row["RecID"].ToString() != "")
            {
                model.RecID = long.Parse(row["RecID"].ToString());
            }
            if (row["OrderID"].ToString() != "")
            {
                model.OrderID = int.Parse(row["OrderID"].ToString());
            }
            if (row["OrderCode"].ToString() != "")
            {
                model.OrderCode = int.Parse(row["OrderCode"].ToString());
            }
            model.CustomerName = row["CustomerName"].ToString();
            model.CustomerTel  = row["CustomerTel"].ToString();
            if (row["ProvinceID"].ToString() != "")
            {
                model.ProvinceID = int.Parse(row["ProvinceID"].ToString());
            }
            model.ProvinceName = row["ProvinceName"].ToString();
            if (row["CityID"].ToString() != "")
            {
                model.CityID = int.Parse(row["CityID"].ToString());
            }
            model.CityName = row["CityName"].ToString();
            if (row["OrderCreateTime"].ToString() != "")
            {
                model.OrderCreateTime = DateTime.Parse(row["OrderCreateTime"].ToString());
            }
            if (row["Price"].ToString() != "")
            {
                model.Price = decimal.Parse(row["Price"].ToString());
            }
            if (row["CarMasterID"].ToString() != "")
            {
                model.CarMasterID = int.Parse(row["CarMasterID"].ToString());
            }
            model.CarMasterName = row["CarMasterName"].ToString();
            if (row["CarSerialID"].ToString() != "")
            {
                model.CarSerialID = int.Parse(row["CarSerialID"].ToString());
            }
            model.CarSerialName = row["CarSerialName"].ToString();
            if (row["CarID"].ToString() != "")
            {
                model.CarID = int.Parse(row["CarID"].ToString());
            }
            model.CarName = row["CarName"].ToString();
            if (row["DealerID"].ToString() != "")
            {
                model.DealerID = int.Parse(row["DealerID"].ToString());
            }
            model.DealerName = row["DealerName"].ToString();
            if (row["CreateTime"].ToString() != "")
            {
                model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
            }
            if (row["CreateUserID"].ToString() != "")
            {
                model.CreateUserID = int.Parse(row["CreateUserID"].ToString());
            }
            return(model);
        }