public dynamic SignIn(int userid) { IRepository db = null; try { dm_userEntity dm_UserEntity = GetEntityByCache(userid); if (dm_UserEntity.IsEmpty()) { throw new Exception("用户信息异常!"); } dm_basesettingEntity dm_BasesettingEntity = dm_BaseSettingService.GetEntityByCache(dm_UserEntity.appid); if (dm_BasesettingEntity.IsEmpty()) { throw new Exception("获取基础配置信息异常!"); } int?currentIntegral = 0; int signCount = 0; dm_intergraldetailEntity dm_IntergraldetailEntity = dM_IntergralDetailService.GetLastSignData(userid); if (dm_IntergraldetailEntity == null) { currentIntegral = dm_BasesettingEntity.firstsign; signCount = 1; } else { if (dm_IntergraldetailEntity.createtime.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) { throw new Exception("今日已签到!"); } if (dm_IntergraldetailEntity.createtime.ToString("yyyy-MM-dd") == DateTime.Now.AddDays(-1.0).ToString("yyyy-MM-dd")) { int?todayIntegral = dm_IntergraldetailEntity.stepvalue + dm_BasesettingEntity.signscrement; currentIntegral = ((todayIntegral > dm_BasesettingEntity.signcapping) ? dm_BasesettingEntity.signcapping : todayIntegral); signCount = int.Parse(dm_IntergraldetailEntity.remark) + 1; } else { currentIntegral = dm_BasesettingEntity.firstsign; signCount = 1; } } dm_UserEntity.integral += currentIntegral; dm_UserEntity.Modify(dm_UserEntity.id); db = BaseRepository("dm_data").BeginTrans(); db.Update(dm_UserEntity); db.Insert(new dm_intergraldetailEntity { currentvalue = dm_UserEntity.integral, stepvalue = currentIntegral, user_id = userid, title = "签到奖励", remark = signCount.ToString(), type = 2, createtime = DateTime.Now }); db.Commit(); return(new { CurrentIntegral = currentIntegral, SignCount = signCount }); } catch (Exception ex) { if (db != null) { db.Rollback(); } if (ex is ExceptionEx) { throw; } throw ExceptionEx.ThrowServiceException(ex); } }
public dm_task_reviceEntity ReviceTask(dm_task_reviceEntity dm_Task_ReviceEntity, string appid) { lock (_object) { IRepository db = null; try { dm_basesettingEntity dm_BasesettingEntity = dM_BaseSettingService.GetEntityByCache(appid); if (dm_BasesettingEntity.IsEmpty()) { throw new Exception("配置信息获取错误!"); } dm_taskEntity dm_TaskEntity = dm_TaskService.GetEntity(dm_Task_ReviceEntity.task_id); if (dm_TaskEntity.IsEmpty()) { throw new Exception("任务id错误!"); } if (dm_TaskEntity.task_status == -2) { throw new Exception("任务正在审核中,暂时无法接受!"); } if (dm_TaskEntity.task_status == 1) { throw new Exception("您来晚了一步,当前任务已抢光!"); } if (dm_TaskEntity.task_status == 2) { throw new Exception("当前任务已取消,您可接受其他任务!"); } if (dm_TaskEntity.task_status == 3) { throw new Exception("当前任务已下架,您可接受其他任务!"); } if (dm_TaskEntity.revicecount >= dm_TaskEntity.needcount) { throw new Exception("您来晚了一步,当前任务已抢光!"); } /*一个任务可重复接受 2020-07-27*/ dm_task_reviceEntity reviceEntity = GetReviceEntity(dm_Task_ReviceEntity.user_id, dm_Task_ReviceEntity.task_id); if (!reviceEntity.IsEmpty()) { //throw new Exception("请勿重复接受该任务!"); throw new Exception("您已接受该任务,请勿重复接受!!"); } dm_userEntity dm_UserEntity = dM_UserService.GetEntity(dm_Task_ReviceEntity.user_id); if (dm_UserEntity.userlevel != 1 && dm_UserEntity.userlevel != 2) { throw new Exception("当前等级无法接受任务,请升级后重试!"); } //判断当前未在审核状态的任务数量 int noFinishCount = BaseRepository("dm_data").IQueryable <dm_task_reviceEntity>(t => (t.status == 1 || t.status == 2) && t.user_id == dm_Task_ReviceEntity.user_id).Count(); if (noFinishCount >= dm_BasesettingEntity.revicetaskcountlimit) { throw new Exception("同时接单任务数已达到上限,请先完成其他任务后再来接单!"); } dm_Task_ReviceEntity.revice_time = DateTime.Now; dm_Task_ReviceEntity.status = 1; dm_Task_ReviceEntity.Create(); dm_TaskEntity.revicecount += 1; dm_TaskEntity.Modify(dm_TaskEntity.id); db = BaseRepository("dm_data").BeginTrans(); db.Update(dm_TaskEntity); db.Insert(dm_Task_ReviceEntity); db.Commit(); return(dm_Task_ReviceEntity); } catch (Exception ex) { if (db != null) { db.Rollback(); } if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } } }