Ejemplo n.º 1
0
        public static bool InsertLog(VehicleTypeCertificationAuditLogModel model)
        {
            var conn = ConfigurationManager.ConnectionStrings["Tuhu_log"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(conn))
            {
                using (var cmd =
                           new SqlCommand(
                               @"INSERT Tuhu_log..VehicleTypeCertificationAuditLog(CarId,Author,OldValue,NewValue,Description,CreateTime) VALUES(@carId,@author,@oldValue,@newValue,@description,GETDATE());")
                       )
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@carId", model.CarId);
                    cmd.Parameters.AddWithValue("@author", model.Author);
                    cmd.Parameters.AddWithValue("@oldValue", model.OldValue);
                    cmd.Parameters.AddWithValue("@newValue", model.NewValue);
                    cmd.Parameters.AddWithValue("@description", model.Description);
                    return(dbHelper.ExecuteNonQuery(cmd) > 0);
                }
            }
        }
Ejemplo n.º 2
0
        public static List <VehicleTypeCertificationAuditLogModel> SelectLogs(List <Guid> carIds)
        {
            if (!carIds.Any())
            {
                return(new List <VehicleTypeCertificationAuditLogModel>());
            }
            var conn = ConfigurationManager.ConnectionStrings["Tuhu_log"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(conn))
            {
                using (var cmd =
                           new SqlCommand(
                               $@"SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY CarId ORDER BY CreateTime DESC) AS N,* 
                        FROM Tuhu_log..VehicleTypeCertificationAuditLog WOTH(NOLOCK) WHERE CarId IN({string.Join(",",carIds.Select(_=>$"'{_}'"))})) AS T
                        WHERE T.N=1"))
                {
                    cmd.CommandType = CommandType.Text;
                    return(dbHelper.ExecuteDataTable(cmd).ConvertTo <VehicleTypeCertificationAuditLogModel>().ToList());
                }
            }
        }
Ejemplo n.º 3
0
        public static List <RebateConfigLog> SearchRebateConfigLog(string pkid)
        {
            const string sql  = @"
            SELECT  rcl.PKID ,
                    rcl.IdentityId ,
                    rcl.Type ,
                    rcl.Msg ,
                    rcl.Remark ,
                    rcl.IPAddress ,
                    rcl.HostName ,
                    rcl.OperateUser ,
                    rcl.CreateDateTime ,
                    rcl.UpdateDateTime
            FROM    Tuhu_log..RebateConfigLog AS rcl WITH ( NOLOCK )
            WHERE   rcl.IdentityId = @IdentityId
            Order BY rcl.PKID DESC; ";
            var          conn = ConfigurationManager.ConnectionStrings["Tuhu_log"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(conn))
            {
                var cmd = new SqlCommand(sql);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@IdentityId", pkid);
                return(dbHelper.ExecuteDataTable(cmd).ConvertTo <RebateConfigLog>().ToList());
            }
        }
Ejemplo n.º 4
0
        public static List <FlashSaleRecordsLog> SelectFlashSalRecordsLog(Guid activityId)
        {
            var conn = ConfigurationManager.ConnectionStrings["SystemLog_AlwaysOnRead"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(conn))
            {
                var cmd = new SqlCommand(@"SELECT * FROM SystemLog..tbl_FlashSaleRecords WITH (NOLOCK) WHERE ActivityID=@ActivityID ");
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@ActivityID", activityId);
                return(dbHelper.ExecuteDataTable(cmd).ConvertTo <FlashSaleRecordsLog>().ToList());
            }
        }
Ejemplo n.º 5
0
        public static List <CouponActivityLog> SelectOperationLog(string objectId, string type)
        {
            var conn = ConfigurationManager.ConnectionStrings["Tuhu_log"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(conn))
            {
                var cmd = new SqlCommand(@"SELECT * FROM Tuhu_log..CouponActivityLog WITH (NOLOCK) WHERE ObjectId=@ObjectId AND Type=@Type ORDER BY CreatedTime DESC");
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@ObjectId", objectId);
                cmd.Parameters.AddWithValue("@Type", type.ToString());
                return(dbHelper.ExecuteDataTable(cmd).ConvertTo <CouponActivityLog>().ToList());
            }
        }
Ejemplo n.º 6
0
        public static List <OrderCompletionJudgeCriteria> SelectOrderCompJudgeCriteria(string userId)
        {
            var conn = ConfigurationManager.ConnectionStrings["Gungnir_AlwaysOnRead"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            const string sql = "SELECT InstallShopId, Status, TBO.DeliveryStatus, TBO.DeliveryDatetime, InstallDatetime, TBOD.DeliveryStatus AS DeliveryStatusInLog, TBOD.DeliveryDatetime AS DeliveryDatetimeInLog FROM Gungnir..tbl_Order AS TBO WITH(NOLOCK) LEFT JOIN Gungnir.dbo.tbl_OrderDeliveryLog AS TBOD ON TBO.PKID = TBOD.OrderID WHERE TBO.UserID=@UserID";

            using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(conn))
            {
                var cmd = new SqlCommand(sql);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@UserID", userId);
                return(dbHelper.ExecuteDataTable(cmd).ConvertTo <OrderCompletionJudgeCriteria>().ToList());
            }
        }
Ejemplo n.º 7
0
        public static List <VehicleTypeCertificationAuditLogModel> SelectLogsByCarId(Guid carId)
        {
            var conn = ConfigurationManager.ConnectionStrings["Tuhu_log"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(conn))
            {
                using (var cmd =
                           new SqlCommand(
                               $@"SELECT * 
                        FROM Tuhu_log..VehicleTypeCertificationAuditLog WITH(NOLOCK) WHERE CarId=@carId ORDER BY CreateTime DESC"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@carId", carId);
                    return(dbHelper.ExecuteDataTable(cmd).ConvertTo <VehicleTypeCertificationAuditLogModel>().ToList());
                }
            }
        }
Ejemplo n.º 8
0
        public static DataTable GetTousuLog(string objectId, string objectType)
        {
            var conn = ConfigurationManager.ConnectionStrings["Tuhu_log"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(conn))
            {
                string sql =
                    @"SELECT * FROM Tuhu_log..TousuConfigLog WITH(NOLOCK) WHERE ObjectId=@ObjectId AND ObjectType=@ObjectType ORDER BY PKID DESC";

                using (var cmd = new SqlCommand(sql))
                {
                    cmd.Parameters.AddWithValue("@ObjectId", objectId);
                    cmd.Parameters.AddWithValue("@ObjectType", objectType);
                    return(dbHelper.ExecuteDataTable(cmd));
                }
            }
        }
        private string CheckPIDSamePriceInOtherActivity(ActivityProduct product)
        {
            var conn = ConfigurationManager.ConnectionStrings["Gungnir"].ConnectionString;

            if (SecurityHelp.IsBase64Formatted(conn))
            {
                conn = SecurityHelp.DecryptAES(conn);
            }
            using (var dbHelper = new Tuhu.Component.Common.SqlDbHelper(conn))
            {
                var cmd = new SqlCommand(@"SELECT	FS.ActivityID,FSP.Price,FSP.PID
                                            FROM	Activity..tbl_FlashSale AS FS WITH ( NOLOCK )
                                            JOIN	Activity..tbl_FlashSaleProducts AS FSP WITH ( NOLOCK )
		                                            ON FSP.ActivityID = FS.ActivityID
                                            WHERE	FS.EndDateTime > GETDATE()
		                                            AND FSP.PID = @PID
		                                            AND FSP.Price <> @Price
		                                            AND FS.ActivityID<>@ActivityID
		                                            AND ActiveType IN ( 0, 1 )"        );
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@PID", product.PID);
                cmd.Parameters.AddWithValue("@Price", product.Price);
                cmd.Parameters.AddWithValue("@ActivityID", product.ActivityID);
                var dt = dbHelper.ExecuteDataTable(cmd);
                if (dt == null || dt.Rows.Count == 0)
                {
                    return(null);
                }
                var wrongMsg = "";
                foreach (DataRow item in dt.Rows)
                {
                    wrongMsg += "PID:" + item["PID"].ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;活动ID:" + item["ActivityID"].ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;价格:" + Convert.ToDouble(item["Price"]).ToString("C") + "<br/>";
                }
                return(wrongMsg);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 天天秒杀保存按钮使用
        /// </summary>
        /// <param name="qiang"></param>
        /// <param name="diffs"></param>
        /// <param name="dbHelper"></param>
        /// <returns></returns>
        public static int SpikeSynchroDiffActivity(QiangGouModel qiang, List <QiangGouDiffModel> diffs, Tuhu.Component.Common.SqlDbHelper dbHelper)
        {
            var selectedDiffs = diffs.GroupBy(r => new { r.ActivityID, r.ActiveType }).Select(d => new QiangGouModel
            {
                ActivityID = d.Key.ActivityID,
                ActiveType = d.Key.ActiveType,
                Products   = d.Select(product => new QiangGouProductModel
                {
                    PID                = product.PID,
                    ProductName        = product.ProductName,
                    Price              = product.Price,
                    FalseOriginalPrice = product.FalseOriginalPrice,
                    InstallAndPay      = product.InstallAndPay,
                    IsUsePCode         = product.IsUsePCode,
                })
            });
            List <QiangGouProductModel> list = new List <QiangGouProductModel>();

            //List<QiangGouProductModel> selectedlist = new List<QiangGouProductModel>();
            foreach (var a in selectedDiffs)
            {
                var selecteddiffs = DALQiangGou.SelectSelectedDiffActivityProducts(a.ActivityID, a.ActiveType, a.Products, dbHelper);
                list.AddRange(selecteddiffs);
            }
            var aids = list.Select(_ => _.ActivityID);

            foreach (var aid in aids)
            {
                var  model         = DALQiangGou.SelectQiangGouForSynchro(aid, dbHelper);
                var  origin        = DALQiangGou.SelectQiangGouForSynchro(aid, dbHelper);
                var  needAsyncPids = list.Where(_ => _.ActivityID == aid).Select(_ => _.PID).ToList();
                var  tempProducts  = model.Products.Where(_ => !needAsyncPids.Contains(_.PID)).ToList();
                bool flag          = true;
                foreach (var pid in needAsyncPids)
                {
                    var product   = qiang.Products.FirstOrDefault(_ => _.PID == pid);
                    var y_product = model.Products.FirstOrDefault(_ => _.PID == pid);
                    y_product.ProductName        = product.ProductName;
                    y_product.Price              = product.Price;
                    y_product.FalseOriginalPrice = product.FalseOriginalPrice;
                    y_product.InstallAndPay      = product.InstallAndPay;
                    y_product.IsUsePCode         = product.IsUsePCode;

                    tempProducts.Add(y_product);
                    if (!string.IsNullOrWhiteSpace(qiang.NeedExamPids) && qiang.NeedExamPids.Split(';').Contains(pid) && flag)
                    {
                        flag = false;
                    }
                }

                model.NeedExam = !flag;
                model.Products = tempProducts;
                var result = DALQiangGou.CreateOrUpdateQianggou(dbHelper, model);
                if (result.Item1 < 0)
                {
                    dbHelper.Rollback();
                    return(-38);//同步失败
                }
                else
                {
                    var chandata    = LogChangeDataManager.GetLogChangeData(origin, model);
                    var beforeValue = QiangGouManager.GenerateSimpleQiangGouModel(chandata.Item1);
                    var afterValue  = QiangGouManager.GenerateSimpleQiangGouModel(chandata.Item2);
                    var oprLog      = new FlashSaleProductOprLog
                    {
                        OperateUser    = ThreadIdentity.Operator.Name,
                        CreateDateTime = DateTime.Now,
                        BeforeValue    = JsonConvert.SerializeObject(beforeValue),
                        AfterValue     = JsonConvert.SerializeObject(afterValue),
                        LogType        = "FlashSaleLog",
                        LogId          = result.Item2.ToString(),
                        Operation      = model.NeedExam ? "同步活动到待审核" : "同步活动"
                    };
                    LoggerManager.InsertLog("FlashSaleOprLog", oprLog);
                    LoggerManager.InsertFlashSaleLog(chandata.Item1, beforeValue.HashKey);
                    LoggerManager.InsertFlashSaleLog(chandata.Item2, afterValue.HashKey);
                }
            }
            foreach (var aid in aids)
            {
                var cache = SpikeReflashCache(aid, false);
                if (cache == false)
                {
                    return(-3);
                }
            }

            return(1);
        }