Esempio n. 1
0
        public void ApplyChangeGood(dm_intergralchangerecordEntity dm_IntergralchangerecordEntity, dm_userEntity dm_UserEntity)
        {
            IRepository db = BaseRepository("dm_data").BeginTrans();

            try
            {
                DM_IntergralChangeGoodService dM_IntergralChangeGoodService = new DM_IntergralChangeGoodService();
                dm_intergralchangegoodEntity  dm_IntergralchangegoodEntity  = dM_IntergralChangeGoodService.GetEntity(dm_IntergralchangerecordEntity.goodid.ToInt());
                if (dm_IntergralchangegoodEntity == null)
                {
                    throw new Exception("该商品不存在!");
                }
                if (!(dm_UserEntity.integral >= dm_IntergralchangegoodEntity.needintergral))
                {
                    throw new Exception("账户积分不足!");
                }
                db.Insert(dm_IntergralchangerecordEntity);
                dm_UserEntity.integral -= dm_IntergralchangegoodEntity.needintergral;
                dm_UserEntity.Modify(dm_UserEntity.id);
                db.Update(dm_UserEntity);
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                throw ExceptionEx.ThrowServiceException(ex);
            }
        }
Esempio n. 2
0
 public void SaveEntity(int keyValue, dm_intergralchangerecordEntity entity)
 {
     try
     {
         dM_IntergralChangeRecordService.SaveEntity(keyValue, entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         throw ExceptionEx.ThrowBusinessException(ex);
     }
 }
Esempio n. 3
0
 public void ApplyChangeGood(dm_intergralchangerecordEntity dm_IntergralchangerecordEntity, dm_userEntity dm_UserEntity)
 {
     try
     {
         dM_IntergralChangeRecordService.ApplyChangeGood(dm_IntergralchangerecordEntity, dm_UserEntity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         throw ExceptionEx.ThrowBusinessException(ex);
     }
 }
        public void ApplyChangeGood(dm_intergralchangerecordEntity dm_IntergralchangerecordEntity, dm_userEntity dm_UserEntity)
        {
            IRepository db = BaseRepository("dm_data").BeginTrans();

            try
            {
                DM_IntergralChangeGoodService dM_IntergralChangeGoodService = new DM_IntergralChangeGoodService();
                dm_intergralchangegoodEntity  dm_IntergralchangegoodEntity  = dM_IntergralChangeGoodService.GetEntity(dm_IntergralchangerecordEntity.goodid.ToInt());
                if (dm_IntergralchangegoodEntity == null)
                {
                    throw new Exception("该商品不存在!");
                }
                if (!(dm_UserEntity.integral >= dm_IntergralchangegoodEntity.needintergral))
                {
                    throw new Exception("账户积分不足!");
                }

                dm_UserEntity.integral -= dm_IntergralchangegoodEntity.needintergral;
                dm_intergraldetailEntity dm_IntergraldetailEntity = new dm_intergraldetailEntity()
                {
                    currentvalue = dm_UserEntity.integral,
                    stepvalue    = dm_IntergralchangegoodEntity.needintergral,
                    user_id      = dm_UserEntity.id,
                    type         = 6,
                    title        = "兑换商品",
                    remark       = "使用积分兑换商品--" + dm_IntergralchangegoodEntity.goodtitle,
                    profitLoss   = 2
                };
                dm_IntergraldetailEntity.Create();

                db.Insert(dm_IntergraldetailEntity);
                db.Insert(dm_IntergralchangerecordEntity);
                dm_UserEntity.Modify(dm_UserEntity.id);
                db.Update(dm_UserEntity);
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                throw ExceptionEx.ThrowServiceException(ex);
            }
        }
Esempio n. 5
0
 public void SaveEntity(int keyValue, dm_intergralchangerecordEntity entity)
 {
     try
     {
         if (keyValue > 0)
         {
             entity.Modify(keyValue);
             BaseRepository("dm_data").Update(entity);
         }
         else
         {
             entity.Create();
             BaseRepository("dm_data").Insert(entity);
         }
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         throw ExceptionEx.ThrowServiceException(ex);
     }
 }