Beispiel #1
0
        public bool UpdateVipBaoYangPackage(VipBaoYangPackageViewModel package)
        {
            var success = false;

            try
            {
                var inputPackage = new VipBaoYangPackageDbModel(package);
                var dbPackage    = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectVipBaoYangPackageByPkid(conn, package.PKID));
                if (dbPackage != null)
                {
                    var oldData = JsonConvert.SerializeObject(dbPackage);
                    dbPackage.Brands = inputPackage.Brands;

                    success = dbScopeManager.Execute(conn => DALVipBaoYangPackage.UpdateVipBaoYangPackage(conn, dbPackage));
                    if (success)
                    {
                        dbPackage.LastUpdateDateTime = DateTime.Now;
                        var newData = JsonConvert.SerializeObject(dbPackage);
                        InsertLog(dbPackage.PID, oldData, newData, "Update", package.CreateUser);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(success);
        }
        public static bool UpdateVipBaoYangPackage(SqlConnection conn, VipBaoYangPackageDbModel package)
        {
            const string sql = @"UPDATE  BaoYang..VipBaoYangPackageConfig
SET     Brands = @Brands ,
        LastUpdateDateTime = GETDATE()
WHERE   PKID = @PKID;";

            return(conn.Execute(sql, new { package.PKID, package.Brands }, commandType: CommandType.Text) > 0);
        }
        public static int InsertVipBaoYangPackage(SqlConnection conn, VipBaoYangPackageDbModel package)
        {
            const string sql = @"INSERT  INTO BaoYang..VipBaoYangPackageConfig
        ( PackageName ,
          VipUserId ,
          PID ,
          Brands ,
          Price ,
          Volume ,
          CreateUser ,
          SettlementMethod ,
          SettlementVipUserId ,
          GetRuleGUID ,
          Source ,
          CreateDateTime ,
          LastUpdateDateTime
	    )
OUTPUT  Inserted.PKID
VALUES  ( @PackageName ,
          @VipUserId ,
          N'' ,
          @Brands ,
          @Price ,
          @Volume ,
          @CreateUser ,
          @SettlementMethod ,
          @SettlementVipUserId ,
          @GetRuleGUID ,
          @Source ,
          GETDATE() ,
          GETDATE()
        );";

            return(Convert.ToInt32(conn.ExecuteScalar(sql, new
            {
                package.VipUserId,
                package.PackageName,
                package.Price,
                package.Brands,
                package.Volume,
                package.CreateUser,
                package.SettlementMethod,
                package.SettlementVipUserId,
                package.GetRuleGUID,
                package.Source
            }, commandType: CommandType.Text)));
        }
Beispiel #4
0
        public bool UpdateVipBaoYangPackage(VipBaoYangPackageViewModel package)
        {
            var success = false;

            try
            {
                var inputPackage = new VipBaoYangPackageDbModel(package);
                VipBaoYangPackageDbModel dbPackage = null;
                var oldData = string.Empty;
                dbScopeManager.CreateTransaction(conn =>
                {
                    dbPackage            = DALVipBaoYangPackage.SelectVipBaoYangPackageByPkid(conn, package.PKID);
                    dbPackage.OilConfigs = DALVipBaoYangPackage.SelectBaoYangPackageOilConfigs(conn, package.PKID).ToList();
                    oldData = JsonConvert.SerializeObject(dbPackage);
                    dbPackage.OilConfigs = inputPackage.OilConfigs;
                    if (dbPackage != null)
                    {
                        var updateResult = DALVipBaoYangPackage.UpdateVipBaoYangPackage(conn, package);
                        if (updateResult > 0)
                        {
                            success = DALVipBaoYangPackage.DeleteBaoYangPackageOilConfigs(conn, package.PKID);
                            if (success)
                            {
                                dbPackage.OilConfigs.ForEach(x => DALVipBaoYangPackage.InsertBaoYangPackageOilConfig(conn, x));
                            }
                        }
                    }
                });

                if (success)
                {
                    dbPackage.LastUpdateDateTime = DateTime.Now;
                    var newData = JsonConvert.SerializeObject(dbPackage);
                    InsertLog(dbPackage.PID, oldData, newData, "Update", package.CreateUser);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(success);
        }
Beispiel #5
0
        /// <summary>
        /// 根据主键Id获取套餐详情
        /// </summary>
        /// <param name="pkid"></param>
        /// <returns></returns>
        public VipBaoYangPackageViewModel SelectVipBaoYangPackageByPkid(int pkid)
        {
            VipBaoYangPackageViewModel result = null;

            try
            {
                VipBaoYangPackageDbModel package = null;
                dbScopeReadManager.Execute(conn =>
                {
                    package            = DALVipBaoYangPackage.SelectVipBaoYangPackageByPkid(conn, pkid);
                    package.OilConfigs = DALVipBaoYangPackage.SelectBaoYangPackageOilConfigs(conn, pkid).ToList();
                });
                result = new VipBaoYangPackageViewModel(package);
                var user = BaoYangExternalService.GetCompanyUserInfo(result.VipUserId);
                result.VipUserName = user?.UserName;
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// 添加保养套餐
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public bool InsertVipBaoYangPackage(VipBaoYangPackageViewModel package)
        {
            var result    = false;
            var productId = string.Empty;

            try
            {
                dbScopeManager.CreateTransaction(conn =>
                {
                    var insertPackage = new VipBaoYangPackageDbModel(package);
                    var pkid          = DALVipBaoYangPackage.InsertVipBaoYangPackage(conn, insertPackage);
                    if (pkid > 0)
                    {
                        insertPackage.OilConfigs.ForEach(x => x.PackageId = pkid);
                        insertPackage.OilConfigs.ForEach(config => DALVipBaoYangPackage.InsertBaoYangPackageOilConfig(conn, config));
                        productId = $"BY-TUHU-BXGSDCBY|{pkid.ToString()}";
                        result    = DALVipBaoYangPackage.UpdateVipBaoYangPackagePID(conn, pkid, productId) > 0;
                    }
                    if (result)
                    {
                        package.PKID = pkid;
                        package.PID  = productId;
                        VipBaoYangPackageService.CreateProduct(pkid.ToString(), package.PackageName, package.CreateUser);
                    }
                });

                if (result)
                {
                    InsertLog(productId, null, JsonConvert.SerializeObject(package), "Insert", package.CreateUser);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(result);
        }