Esempio n. 1
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// <param name="keyValue">主键</param>
 /// <summary>
 /// <returns></returns>
 public void SaveEntity(int keyValue, dm_taskEntity entity)
 {
     try
     {
         if (keyValue > 0)
         {
             entity.Modify(keyValue);
             this.BaseRepository("dm_data").Update(entity);
         }
         else
         {
             entity.Create();
             this.BaseRepository("dm_data").Insert(entity);
         }
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowServiceException(ex);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// web端发布任务不用扣除余额,直接发就好
        /// </summary>
        /// <param name="entity"></param>
        public void ReleaseTaskByWeb(dm_taskEntity entity)
        {
            try
            {
                if (entity.singlecommission <= 0)
                {
                    throw new Exception("任务佣金不能小于0!");
                }
                if (entity.needcount <= 0)
                {
                    throw new Exception("任务参与数不能小于0!");
                }

                if (entity.id > 0)
                {
                    entity.Modify(entity.id);
                    this.BaseRepository("dm_data").Update(entity);
                }
                else
                {
                    UserInfo userInfo = LoginUserInfo.Get();

                    entity.totalcommission = entity.singlecommission * entity.needcount;                                             //需要从用户账户扣除的金额
                    dm_basesettingEntity dm_BaseSettingEntity = dm_BaseSettingService.GetEntityByCache(userInfo.companyId);
                    entity.seniorcommission = Math.Round((entity.singlecommission * dm_BaseSettingEntity.task_do_senior) / 100, 2);  //高级代理佣金
                    entity.juniorcommission = Math.Round((entity.singlecommission * dm_BaseSettingEntity.task_do_junior) / 100, 2);  //初级代理佣金
                    entity.servicefee       = Math.Round((entity.singlecommission * dm_BaseSettingEntity.task_servicefee) / 100, 2); //任务服务费(奖励在服务费中分发)
                    entity.task_no          = DateTime.Now.ToString("yyyyMMddHHmmssfff") + entity.user_id.ToString().PadLeft(6, '0');
                    entity.sort             = GetSort(null, entity.totalcommission);
                    entity.appid            = userInfo.companyId;
                    entity.Create();
                    entity.plaform     = 0;
                    entity.task_status = 0;

                    this.BaseRepository("dm_data").Insert(entity);
                }
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 发布任务
        /// </summary>
        /// <param name="entity"></param>
        public void ReleaseTask(dm_taskEntity entity)
        {
            IRepository db = null;

            try
            {
                if (entity.singlecommission <= 0)
                {
                    throw new Exception("任务佣金不能小于0!");
                }
                if (entity.needcount <= 0)
                {
                    throw new Exception("任务参与数不能小于0!");
                }
                dm_userEntity dm_UserEntity = dm_UserService.GetEntity(entity.user_id);

                entity.totalcommission = entity.singlecommission * entity.needcount;//需要从用户账户扣除的金额
                if (dm_UserEntity.accountprice < entity.totalcommission)
                {
                    throw new Exception("账户余额不足,请充值后重新发布!");
                }

                dm_user_relationEntity dm_User_RelationEntity = dm_UserRelationService.GetEntityByUserID(entity.user_id);
                if (dm_User_RelationEntity.IsEmpty())
                {
                    throw new Exception("用户数据异常!");
                }

                dm_basesettingEntity dm_BaseSettingEntity = dm_BaseSettingService.GetEntityByCache(entity.appid);
                entity.seniorcommission = Math.Round((entity.singlecommission * dm_BaseSettingEntity.task_do_senior) / 100, 2);  //高级代理佣金
                entity.juniorcommission = Math.Round((entity.singlecommission * dm_BaseSettingEntity.task_do_junior) / 100, 2);  //初级代理佣金
                entity.servicefee       = Math.Round((entity.singlecommission * dm_BaseSettingEntity.task_servicefee) / 100, 2); //任务服务费(奖励在服务费中分发)
                entity.task_no          = DateTime.Now.ToString("yyyyMMddHHmmssfff") + entity.user_id.ToString().PadLeft(6, '0');
                entity.sort             = GetSort(dm_User_RelationEntity, entity.totalcommission);

                if (dm_BaseSettingEntity.taskchecked == 1)
                {
                    entity.task_status = -2;
                }
                else
                {
                    entity.task_status = 0;
                }

                entity.Create();
                dm_UserEntity.accountprice -= entity.totalcommission;
                dm_UserEntity.Modify(dm_UserEntity.id);
                dm_User_RelationEntity.taskcount += 1;
                dm_User_RelationEntity.Modify(dm_User_RelationEntity.id);


                dm_accountdetailEntity dm_AccountdetailEntity = new dm_accountdetailEntity
                {
                    createtime   = DateTime.Now,
                    remark       = "发布任务扣除" + entity.task_no,
                    stepvalue    = entity.totalcommission,
                    currentvalue = dm_UserEntity.accountprice,
                    title        = "发布任务",
                    type         = 12,
                    profitLoss   = CommonHelper.GetProfitLoss(12),
                    user_id      = entity.user_id
                };

                db = BaseRepository("dm_data").BeginTrans();
                db.Insert(entity);
                db.Update(dm_UserEntity);
                db.Insert(dm_AccountdetailEntity);
                db.Update(dm_User_RelationEntity);
                db.Commit();
            }
            catch (Exception ex)
            {
                if (db != null)
                {
                    db.Rollback();
                }

                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }