public void ProcessRequest(HttpContext context) { string relation_id = context.Request["relation_id"]; string pms_ids = context.Request["pms_ids"]; string rel_type = context.Request["rel_type"]; int relationType = 2; if (!string.IsNullOrWhiteSpace(rel_type)) { relationType = int.Parse(rel_type); } if (string.IsNullOrWhiteSpace(pms_ids)) { pms_ids = "0"; } List <long> pms_id_list = pms_ids.Split(',').Select(p => Convert.ToInt64(p)).ToList(); List <BLLPermission.Model.PermissionRelationInfo> relOList = bllPermission.GetPermissionRelationList(relation_id, relationType); List <long> pmso_id_list = relOList.Select(p => p.PermissionID).ToList(); List <BLLPermission.Model.PermissionRelationInfo> relDelList = relOList.Where(p => !pms_id_list.Contains(p.PermissionID)).ToList(); List <BLLPermission.Model.PermissionRelationInfo> relAddList = new List <BLLPermission.Model.PermissionRelationInfo>(); foreach (long item in pms_id_list.Where(p => !pmso_id_list.Contains(p) && p != 0)) { BLLPermission.Model.PermissionRelationInfo nPerRel = new BLLPermission.Model.PermissionRelationInfo(); nPerRel.RelationType = relationType; nPerRel.PermissionID = item; nPerRel.RelationID = relation_id; relAddList.Add(nPerRel); } BLLTransaction tran = new BLLTransaction(); foreach (BLLPermission.Model.PermissionRelationInfo item in relDelList) { if (bllPermission.Delete(item, tran) < 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "删除原权限关系失败。"; bllPermission.ContextResponse(context, apiResp); return; } } foreach (BLLPermission.Model.PermissionRelationInfo item in relAddList) { if (!bllPermission.Add(item, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "保存新权限关系失败。"; bllPermission.ContextResponse(context, apiResp); return; } } tran.Commit(); apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "保存完成。"; bllPermission.ContextResponse(context, apiResp); }
/// <summary> /// 批量修改关系 /// </summary> /// <param name="relationID"></param> /// <param name="relationType"></param> /// <param name="addList"></param> /// <param name="delList"></param> /// <returns></returns> public bool UpdateMenuRelations(List <MenuRelationInfo> addList, List <MenuRelationInfo> delList, out string msg) { msg = "修改成功"; BLLTransaction tran = new BLLTransaction(); foreach (var item in delList) { if (Delete(item, tran) < 0) { msg = "删除出错"; tran.Rollback(); return(false); } } foreach (var item in addList) { if (!Add(item, tran)) { msg = "新增失败"; tran.Rollback(); return(false); } } tran.Commit(); return(true); }
public void ProcessRequest(HttpContext context) { string id = context.Request["id"]; string sort = context.Request["sort"]; string other_id = context.Request["other_id"]; string other_sort = context.Request["other_sort"]; if (sort == other_sort) { other_sort = (int.Parse(other_sort) + 1).ToString(); } BLLTransaction tran = new BLLTransaction(); if (bll.UpdateByKey <TableFieldMapping>("AutoId", id, "Sort", sort, tran) > 0 && bll.UpdateByKey <TableFieldMapping>("AutoId", other_id, "Sort", other_sort, tran) > 0) { tran.Commit(); apiResp.status = true; apiResp.msg = "排序完成"; apiResp.code = (int)APIErrCode.IsSuccess; } else { tran.Rollback(); apiResp.status = true; apiResp.msg = "排序失败"; apiResp.code = (int)APIErrCode.OperateFail; } bll.ContextResponse(context, apiResp); }
/// <summary> /// 发送验证码 /// </summary> /// <param name="phone"></param> /// <param name="verificationCode"></param> /// <param name="isSuccess"></param> /// <param name="msg"></param> public void SendSmsVerificationCode(string phone, string msgContent, string smsSignature, string verificationCode, out bool isSuccess, out string msg) { isSuccess = false; msg = ""; if (string.IsNullOrEmpty(smsSignature)) { smsSignature = "至云"; } string sendContent = string.Format("{0}【{1}】", msgContent, smsSignature); ZentCloud.ZCBLLEngine.BLLTransaction tran = new BLLTransaction(); SmsVerificationCode model = new SmsVerificationCode(); model.Phone = phone; model.InsertDate = DateTime.Now; model.VerificationCode = verificationCode; model.WebsiteOwner = WebsiteOwner; if (Add(model, tran)) { if (SendSms(WebsiteOwner, phone, sendContent)) { isSuccess = true; tran.Commit(); } else { msg = "短信发送失败"; tran.Rollback(); } } else { tran.Rollback(); } }
public void ProcessRequest(HttpContext context) { string component_model_id = context.Request["component_model_id"]; ComponentModel componentModel = bll.GetByKey <ComponentModel>("AutoId", component_model_id); if (componentModel == null) { apiResp.msg = "组件库未找到"; apiResp.code = (int)APIErrCode.IsNotFound; bll.ContextResponse(context, apiResp); return; } if (bll.DeleteByKey <ComponentModel>("AutoId", component_model_id, tran) >= 0 && bll.DeleteByKey <ComponentModelField>("ComponentModelKey", componentModel.ComponentModelKey, tran) >= 0) { tran.Commit(); apiResp.status = true; apiResp.msg = "删除完成"; apiResp.code = (int)APIErrCode.IsSuccess; } else { tran.Rollback(); apiResp.msg = "删除失败"; apiResp.code = (int)APIErrCode.OperateFail; } bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { int uid = int.Parse(context.Request["AutoID"]); UserInfo tUser = bllUser.GetUserInfoByAutoID(uid); tUser.Password = context.Request["Password"]; if (string.IsNullOrWhiteSpace(tUser.Password)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "密码不能为空"; bllUser.ContextResponse(context, apiResp); return; } BLLTransaction tran = new BLLTransaction(); if (!bllUser.Update(tUser, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "修改密码出错"; bllUser.ContextResponse(context, apiResp); return; } tran.Commit(); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.msg = "修改完成"; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string relation_id = context.Request["relation_id"]; string menu_ids = context.Request["menu_ids"]; if (string.IsNullOrWhiteSpace(menu_ids)) { menu_ids = "0"; } List <long> menu_id_list = menu_ids.Split(',').Select(p => Convert.ToInt64(p)).ToList(); List <BLLPermission.Model.MenuRelationInfo> relOList = bllMenu.GetMenuRelationList(relation_id, 5); List <long> menuo_id_list = relOList.Select(p => p.MenuID).ToList(); List <BLLPermission.Model.MenuRelationInfo> relDelList = relOList.Where(p => !menu_id_list.Contains(p.MenuID)).ToList(); List <BLLPermission.Model.MenuRelationInfo> relAddList = new List <BLLPermission.Model.MenuRelationInfo>(); foreach (long item in menu_id_list.Where(p => !menuo_id_list.Contains(p) && p != 0)) { BLLPermission.Model.MenuRelationInfo nPerRel = new BLLPermission.Model.MenuRelationInfo(); nPerRel.RelationType = 5; nPerRel.MenuID = item; nPerRel.RelationID = relation_id; relAddList.Add(nPerRel); } BLLTransaction tran = new BLLTransaction(); foreach (BLLPermission.Model.MenuRelationInfo item in relDelList) { if (bllMenu.Delete(item, tran) < 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "删除原菜单失败。"; bllMenu.ContextResponse(context, apiResp); return; } } foreach (BLLPermission.Model.MenuRelationInfo item in relAddList) { if (!bllMenu.Add(item, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "保存新菜单失败。"; bllMenu.ContextResponse(context, apiResp); return; } } tran.Commit(); apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "保存完成。"; bllMenu.ContextResponse(context, apiResp); }
private string Copy(HttpContext context) { string idStr = context.Request["id"]; long id = Convert.ToInt64(idStr); PermissionGroupInfo model = bllPms.GetPermissionGroup(null, id); string newIdStr = bllPer.GetGUID(TransacType.PermissionGroupAdd); model.GroupID = Convert.ToInt64(newIdStr); model.GroupName = model.GroupName + "—复制"; //权限组权限关系 List <PermissionRelationInfo> listPermissionRelation = bllPms.GetPermissionRelationList(idStr, 0); //权限组权限栏目关系 List <PermissionRelationInfo> listPermissionRelation3 = bllPms.GetPermissionRelationList(idStr, 3); listPermissionRelation.AddRange(listPermissionRelation3); foreach (var item in listPermissionRelation) { item.RelationID = newIdStr; } List <MenuRelationInfo> listMenuRelation = bllMenu.GetMenuRelationList(idStr, 0); foreach (var item in listMenuRelation) { item.RelationID = newIdStr; } BLLTransaction tran = new BLLTransaction(); bool result = bllPer.Add(model, tran); if (!result) { tran.Rollback(); return("复制权限组失败"); } foreach (var item in listPermissionRelation) { if (!bllPer.Add(item, tran)) { tran.Rollback(); return("复制权限组权限失败"); } } foreach (var item in listMenuRelation) { if (!bllPer.Add(item, tran)) { tran.Rollback(); return("复制权限组菜单失败"); } } tran.Commit(); return(result.ToString().ToLower()); }
public void ProcessRequest(HttpContext context) { string ids = context.Request["ids"]; string groupName = context.Request["GroupName"]; List <CompanyWebsite_ToolBar> oList = bll.GetMultListByKey <CompanyWebsite_ToolBar>("AutoID", ids); List <CompanyWebsite_ToolBar> addList = new List <CompanyWebsite_ToolBar>(); List <CompanyWebsite_ToolBar> updateList = new List <CompanyWebsite_ToolBar>(); BLLTransaction tran = new BLLTransaction(); bool result = false; foreach (CompanyWebsite_ToolBar item in oList) { if (item.IsSystem == 1) { item.IsSystem = 0; item.WebsiteOwner = bll.WebsiteOwner; item.KeyType = groupName; item.BaseID = item.AutoID; result = bll.Add(item, tran); } else { item.KeyType = groupName; result = bll.Update(item, tran); } if (!result) { tran.Rollback(); break; } } if (result) { tran.Commit(); apiResp.status = true; apiResp.msg = "编辑完成"; apiResp.code = (int)APIErrCode.IsSuccess; } else { apiResp.msg = "编辑失败"; apiResp.code = (int)APIErrCode.OperateFail; } bll.ContextResponse(context, apiResp); }
/// <summary> /// 修改页面 /// </summary> /// <param name="componentModel"></param> /// <param name="componentModelFields"></param> /// <param name="errmsg"></param> /// <returns></returns> public bool UpdateComponentModel(ComponentModel UpdateComponentModel, List <ComponentModelField> AddComponentModelFields , List <ComponentModelField> UpdateComponentModelFields, List <ComponentModelField> DeleteComponentModelFields, out string errmsg) { BLLTransaction tran = new BLLTransaction(); errmsg = ""; if (!Update(UpdateComponentModel, tran)) { errmsg = "页面修改失败"; tran.Rollback(); return(false); } foreach (var item in DeleteComponentModelFields) { if (Delete(item, tran) <= 0) { errmsg = string.Format("页面字段删除[{0}]失败", item.ComponentField); tran.Rollback(); return(false); } } foreach (var item in UpdateComponentModelFields) { if (!Update(item, tran)) { errmsg = string.Format("页面字段修改[{0}]失败", item.ComponentField); tran.Rollback(); return(false); } } foreach (var item in AddComponentModelFields) { if (!Add(item, tran)) { errmsg = string.Format("页面字段添加[{0}]失败", item.ComponentField); tran.Rollback(); return(false); } } tran.Commit(); return(true); }
/// <summary> /// 添加页面 /// </summary> /// <param name="componentModel"></param> /// <param name="componentModelFields"></param> /// <param name="errmsg"></param> /// <returns></returns> public bool AddComponentModel(ComponentModel componentModel, List <ComponentModelField> componentModelFields, out string errmsg) { BLLTransaction tran = new BLLTransaction(); errmsg = ""; if (!Add(componentModel, tran)) { errmsg = "页面添加失败"; tran.Rollback(); return(false); } foreach (var item in componentModelFields) { if (!Add(item, tran)) { errmsg = string.Format("页面字段添加[{0}]失败", item.ComponentField); tran.Rollback(); return(false); } } tran.Commit(); return(true); }
public void ProcessRequest(HttpContext context) { string ids = context.Request["ids"]; List <UserInfo> list = bllUser.GetList <UserInfo>(string.Format(" AutoID In ({0}) ", ids)); list = list.Where(p => p.MemberApplyStatus < 9 || p.AccessLevel < 1).ToList(); if (list.Count > 0) { BLLTransaction tran = new BLLTransaction(); foreach (var item in list) { if (item.AccessLevel < 1) { item.AccessLevel = 1; } item.MemberStartTime = DateTime.Now; item.MemberApplyStatus = 9; if (!bllUser.Update(item, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "提交失败"; bllUser.ContextResponse(context, apiResp); return; } } tran.Commit(); foreach (var user in list) { bllWeixin.SendTemplateMessageNotifyComm(user, "审核通过", "您已经通过会员审核"); } } apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "提交完成"; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { BLLJIMP.Model.API.Flow.PostAction requestPost = bllFlow.ConvertRequestToModel <BLLJIMP.Model.API.Flow.PostAction>(new BLLJIMP.Model.API.Flow.PostAction()); string[] limit = new string[] { "OfflineRecharge", "OfflineUpgrade" }; if (!limit.Contains(requestPost.flow_key)) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "该流程不支持"; bllFlow.ContextResponse(context, apiResp); return; } string websiteOwner = bllFlow.WebsiteOwner; BLLJIMP.Model.Flow flow = bllFlow.GetFlowByKey(requestPost.flow_key, websiteOwner); if (flow == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "流程未定义"; bllFlow.ContextResponse(context, apiResp); return; } if (flow.IsDelete == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = flow.FlowName + "已停用"; bllFlow.ContextResponse(context, apiResp); return; } List <BLLJIMP.Model.FlowStep> steps = bllFlow.GetStepList(2, 1, websiteOwner, flow.AutoID); if (steps.Count == 0) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = flow.FlowName + "环节未设置"; bllFlow.ContextResponse(context, apiResp); return; } UserInfo member = bllUser.GetUserInfo(requestPost.member_userid, websiteOwner); if (requestPost.flow_key == "OfflineUpgrade") { if (member.MemberLevel >= Convert.ToInt32(requestPost.ex2)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "所选级别低于会员当前级别"; bllFlow.ContextResponse(context, apiResp); return; } UserLevelConfig mlevelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", member.MemberLevel.ToString()); UserLevelConfig toLevelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestPost.ex2.ToString()); if (toLevelConfig == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "等级未找到"; bll.ContextResponse(context, apiResp); return; } if (toLevelConfig.IsDisable == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "级别禁止升级"; bll.ContextResponse(context, apiResp); return; } requestPost.amount = Convert.ToDecimal(toLevelConfig.FromHistoryScore) - Convert.ToDecimal(mlevelConfig.FromHistoryScore); if (requestPost.amount < 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "所选级别低于会员当前级别"; bllFlow.ContextResponse(context, apiResp); return; } requestPost.ex3 = toLevelConfig.LevelString; } WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); BLLJIMP.Model.FlowStep step1 = steps[0]; BLLJIMP.Model.FlowStep step2 = null; if (steps.Count == 2) { step2 = steps[1]; } BLLJIMP.Model.FlowAction action = new BLLJIMP.Model.FlowAction(); action.CreateDate = DateTime.Now; action.CreateUserID = currentUserInfo.UserID; action.WebsiteOwner = websiteOwner; action.StartStepID = step1.AutoID; action.FlowID = flow.AutoID; action.FlowKey = flow.FlowKey; if (requestPost.amount > 0) { action.Amount = requestPost.amount; } if (!string.IsNullOrWhiteSpace(requestPost.content)) { action.StartContent = requestPost.content; } if (!string.IsNullOrWhiteSpace(requestPost.ex1)) { action.StartEx1 = requestPost.ex1; } if (!string.IsNullOrWhiteSpace(requestPost.ex2)) { action.StartEx2 = requestPost.ex2; } if (!string.IsNullOrWhiteSpace(requestPost.ex3)) { action.StartEx3 = requestPost.ex3; } if (requestPost.select_date.HasValue) { action.StartSelectDate = requestPost.select_date.Value; } action.MemberAutoID = member.AutoID; action.MemberID = member.UserID; action.MemberName = bllUser.GetUserDispalyName(member); action.MemberAvatar = bllUser.GetUserDispalyAvatar(member); action.MemberPhone = member.Phone; ZentCloud.BLLJIMP.Model.UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", member.MemberLevel.ToString()); action.MemberLevel = levelConfig.LevelNumber; action.MemberLevelName = levelConfig.LevelString; action.FlowName = flow.FlowName; if (step2 != null) { action.StepID = step2.AutoID; action.StepName = step2.StepName; } else { action.Status = 9; action.EndDate = DateTime.Now; } BLLJIMP.Model.FlowActionDetail actionDetail1 = new BLLJIMP.Model.FlowActionDetail(); actionDetail1.WebsiteOwner = websiteOwner; actionDetail1.FlowID = flow.AutoID; actionDetail1.StepID = step1.AutoID; actionDetail1.StepName = step1.StepName; actionDetail1.HandleUserID = currentUserInfo.UserID; actionDetail1.HandleDate = DateTime.Now; if (!string.IsNullOrWhiteSpace(action.StartContent)) { actionDetail1.HandleContent = action.StartContent; } if (requestPost.select_date.HasValue) { actionDetail1.HandleSelectDate = requestPost.select_date.Value; } if (!string.IsNullOrWhiteSpace(action.StartEx1)) { actionDetail1.Ex1 = action.StartEx1; } if (!string.IsNullOrWhiteSpace(action.StartEx2)) { actionDetail1.Ex2 = action.StartEx2; } if (!string.IsNullOrWhiteSpace(action.StartEx3)) { actionDetail1.Ex3 = action.StartEx3; } List <BLLJIMP.Model.FlowActionFile> files = new List <BLLJIMP.Model.FlowActionFile>(); if (!string.IsNullOrWhiteSpace(requestPost.files)) { List <string> fileUrls = requestPost.files.Split(',').Where(p => !string.IsNullOrWhiteSpace(p)).ToList(); if (fileUrls.Count > 0) { foreach (var item in fileUrls) { files.Add(new BLLJIMP.Model.FlowActionFile() { FlowID = flow.AutoID, StepID = step1.AutoID, WebsiteOwner = websiteOwner, FilePath = item }); } } } BLLTransaction tran = new BLLTransaction(); int rId = Convert.ToInt32(bllFlow.AddReturnID(action, tran)); if (rId <= 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + "失败"; bllFlow.ContextResponse(context, apiResp); return; } actionDetail1.ActionID = rId; if (!bllFlow.Add(actionDetail1, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + ",记录失败"; bllFlow.ContextResponse(context, apiResp); return; } foreach (var item in files) { item.ActionID = rId; if (!bllFlow.Add(item, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + ",保存附件失败"; bllFlow.ContextResponse(context, apiResp); return; } } tran.Commit(); apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = flow.FlowName + "提交成功"; bllFlow.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { Add.PostModel requestModel = new Add.PostModel();//模型 List <Add.FileModel> nFiles = new List <Add.FileModel>(); try { requestModel = bllJuActivity.ConvertRequestToModel <Add.PostModel>(requestModel); nFiles = ZentCloud.Common.JSONHelper.JsonToModel <List <Add.FileModel> >(requestModel.file_list); } catch (Exception ex) { apiResp.msg = "提交格式错误"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } //数据检查 if (string.IsNullOrEmpty(requestModel.policy_name)) { apiResp.msg = "政策名称必填"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } JuActivityInfo pInfo = bllJuActivity.GetByKey <JuActivityInfo>("JuActivityID", requestModel.id.ToString()); if (pInfo == null) { apiResp.msg = "原记录不存在"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } pInfo.ActivityName = requestModel.policy_name; pInfo.Summary = requestModel.summary; pInfo.K2 = requestModel.policy_object; pInfo.K3 = requestModel.subsidy_standard; pInfo.K4 = requestModel.subsidy_period; pInfo.K5 = requestModel.policy_number; pInfo.K6 = requestModel.policy_level; pInfo.K7 = requestModel.domicile_place; pInfo.K8 = requestModel.sex; pInfo.K9 = string.IsNullOrWhiteSpace(requestModel.male_age_min) ? null : requestModel.male_age_min; pInfo.K10 = string.IsNullOrWhiteSpace(requestModel.male_age_max) ? null : requestModel.male_age_max; pInfo.K11 = string.IsNullOrWhiteSpace(requestModel.famale_age_min) ? null : requestModel.famale_age_min; pInfo.K12 = string.IsNullOrWhiteSpace(requestModel.famale_age_max) ? null : requestModel.famale_age_max; pInfo.K13 = requestModel.education; pInfo.K14 = string.IsNullOrWhiteSpace(requestModel.graduation_year_min) ? null : requestModel.graduation_year_min; pInfo.K15 = string.IsNullOrWhiteSpace(requestModel.graduation_year_max) ? null : requestModel.graduation_year_max; pInfo.K16 = requestModel.employment_status; pInfo.K17 = string.IsNullOrWhiteSpace(requestModel.current_job_life_min) ? null : requestModel.current_job_life_min; pInfo.K18 = string.IsNullOrWhiteSpace(requestModel.current_job_life_max) ? null : requestModel.current_job_life_max; pInfo.K19 = string.IsNullOrWhiteSpace(requestModel.unemployment_period_min) ? null : requestModel.unemployment_period_min; pInfo.K20 = string.IsNullOrWhiteSpace(requestModel.unemployment_period_max) ? null : requestModel.unemployment_period_max; pInfo.K21 = requestModel.company_type; pInfo.K22 = string.IsNullOrWhiteSpace(requestModel.registered_capital_min) ? null : requestModel.registered_capital_min; pInfo.K23 = string.IsNullOrWhiteSpace(requestModel.registered_capital_max) ? null : requestModel.registered_capital_max; pInfo.K24 = string.IsNullOrWhiteSpace(requestModel.personnel_size_min) ? null : requestModel.personnel_size_min; pInfo.K25 = string.IsNullOrWhiteSpace(requestModel.personnel_size_max) ? null : requestModel.personnel_size_max; pInfo.K26 = requestModel.company_size; pInfo.K27 = requestModel.industry; pInfo.Sort = requestModel.sort; pInfo.LastUpdateDate = DateTime.Now; List <JuActivityFiles> files = new List <JuActivityFiles>(); foreach (var item in nFiles.Where(p => p.id == 0)) { files.Add(new JuActivityFiles() { AddDate = DateTime.Now, FileClass = item.file_class, JuActivityID = pInfo.JuActivityID, FileName = item.file_name, FilePath = item.file_path, UserID = currentUserInfo.UserID }); } bool result = false; BLLTransaction tran = new BLLTransaction(); result = bllJuActivity.Update(pInfo, tran); if (!result) { tran.Rollback(); apiResp.msg = "提交失败"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } string noDeleteFileIds = "0"; if (nFiles.Where(p => p.id != 0).Count() > 0) { noDeleteFileIds = ZentCloud.Common.MyStringHelper.ListToStr(nFiles.Where(p => p.id != 0).Select(p => p.id).ToList(), "", ","); } result = bllJuActivity.Delete(new JuActivityFiles(), string.Format(" AutoID Not In ({0}) AND JuActivityID={1}", noDeleteFileIds, pInfo.JuActivityID.ToString()), tran) >= 0; foreach (var item in files) { if (!result) { break; } result = bllJuActivity.Add(item, tran); } if (!result) { tran.Rollback(); apiResp.msg = "提交失败"; apiResp.code = (int)APIErrCode.OperateFail; } tran.Commit(); apiResp.status = true; apiResp.msg = "提交完成"; apiResp.code = (int)APIErrCode.IsSuccess; bllJuActivity.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { PostModel requestModel = new PostModel();//订单模型 try { requestModel = bllJuActivity.ConvertRequestToModel <PostModel>(requestModel); } catch (Exception ex) { apiResp.msg = "提交格式错误"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } //数据检查 if (string.IsNullOrEmpty(requestModel.title)) { apiResp.msg = "名称必填"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } //if (string.IsNullOrEmpty(requestModel.city)) //{ // apiResp.msg = "城市必选"; // apiResp.code = (int)APIErrCode.OperateFail; // bllJuActivity.ContextResponse(context, apiResp); // return; //} //if (string.IsNullOrEmpty(requestModel.district)) //{ // apiResp.msg = "区域必选"; // apiResp.code = (int)APIErrCode.OperateFail; // bllJuActivity.ContextResponse(context, apiResp); // return; //} if (string.IsNullOrEmpty(requestModel.address)) { apiResp.msg = "地址必填"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } if (string.IsNullOrEmpty(requestModel.k4)) { apiResp.msg = "电话必填"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } if (string.IsNullOrEmpty(requestModel.longitude)) { apiResp.msg = "请选择坐标"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } if (string.IsNullOrEmpty(requestModel.latitude)) { apiResp.msg = "请选择坐标"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } JuActivityInfo pInfo = new JuActivityInfo(); pInfo.JuActivityID = int.Parse(bllJuActivity.GetGUID(BLLJIMP.TransacType.ActivityAdd)); pInfo.ActivityName = requestModel.title; pInfo.ActivityAddress = requestModel.address; pInfo.ServerTimeMsg = requestModel.server_time; pInfo.ServicesMsg = requestModel.server_msg; pInfo.ThumbnailsPath = requestModel.img; pInfo.ArticleType = "Outlets"; pInfo.CategoryId = requestModel.cate_id; pInfo.Province = requestModel.province; pInfo.ProvinceCode = requestModel.province_code; pInfo.City = requestModel.city; pInfo.CityCode = requestModel.city_code; pInfo.District = requestModel.district; pInfo.DistrictCode = requestModel.district_code; pInfo.K1 = requestModel.k1; pInfo.K4 = requestModel.k4; pInfo.K5 = requestModel.k5; pInfo.Tags = requestModel.tags; pInfo.Sort = requestModel.sort; pInfo.UserLongitude = requestModel.longitude; pInfo.UserLatitude = requestModel.latitude; pInfo.IsHide = 0; pInfo.CreateDate = DateTime.Now; pInfo.LastUpdateDate = DateTime.Now; pInfo.WebsiteOwner = bllJuActivity.WebsiteOwner; pInfo.UserID = currentUserInfo.UserID; List <string> tagList = null; if (!string.IsNullOrWhiteSpace(pInfo.Tags)) { tagList = pInfo.Tags.Split(',').ToList(); } bool result = false; BLLTransaction tran = new BLLTransaction(); result = bllJuActivity.Add(pInfo, tran); if (!result) { tran.Rollback(); apiResp.msg = "提交失败"; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } result = bllJuActivity.SetJuActivityContentTags(pInfo.JuActivityID, tagList); if (result) { tran.Commit(); apiResp.status = true; apiResp.msg = "提交完成"; apiResp.code = (int)APIErrCode.IsSuccess; string polId = ""; ZentCloud.BLLJIMP.Model.Weixin.WeixinStore model = new BLLJIMP.Model.Weixin.WeixinStore(); model.business_name = pInfo.ActivityName; model.branch_name = pInfo.ActivityName; model.province = pInfo.Province; model.city = pInfo.City; model.district = pInfo.District; model.address = pInfo.ActivityAddress; model.telephone = pInfo.K4; model.categories = new List <string>(); model.categories.Add("购物,综合商场"); model.offset_type = 1; model.longitude = double.Parse(pInfo.UserLongitude); model.latitude = double.Parse(pInfo.UserLatitude); string msg = ""; if (bllWeixinCard.CreateStore(model, out polId, out msg)) { bllJuActivity.Update(pInfo, string.Format("K30='{0}'", polId), string.Format("JuActivityID={0}", pInfo.JuActivityID)); } else { apiResp.msg = msg; apiResp.code = (int)APIErrCode.OperateFail; bllJuActivity.ContextResponse(context, apiResp); return; } } else { tran.Rollback(); apiResp.msg = "提交失败"; apiResp.code = (int)APIErrCode.OperateFail; } bllJuActivity.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { if (CurrentUserInfo.IsLock == 1) { apiResp.code = (int)APIErrCode.NoPms; apiResp.msg = "账号已被锁定"; bllUser.ContextResponse(context, apiResp); return; } if (CurrentUserInfo.MemberApplyStatus != 9) { apiResp.code = (int)APIErrCode.NoPms; apiResp.msg = "您的账号正在审核中"; bllUser.ContextResponse(context, apiResp); return; } decimal amount = Convert.ToDecimal(context.Request["amount"]); int spreadid = Convert.ToInt32(context.Request["spreadid"]); string websiteOwner = bllUser.WebsiteOwner; WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); if (amount <= 0) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = string.Format("转账{0}必须大于0", website.TotalAmountShowName); bllUser.ContextResponse(context, apiResp); return; } if (CurrentUserInfo.TotalAmount < amount) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("您的{0}不足", website.TotalAmountShowName); bllUser.ContextResponse(context, apiResp); return; } UserInfo spread = bllUser.GetUserInfoByAutoID(spreadid, websiteOwner); if (spread == null) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "会员未找到"; bllUser.ContextResponse(context, apiResp); return; } if (spread.AutoID == CurrentUserInfo.AutoID) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "禁止转账给自己"; bllUser.ContextResponse(context, apiResp); return; } string spreadname = bllUser.GetUserDispalyName(spread); string curname = bllUser.GetUserDispalyName(CurrentUserInfo); BLLTransaction tran = new BLLTransaction(); #region 消耗操作人金额 if (bllUser.AddScoreDetail(CurrentUserInfo.UserID, websiteOwner, (double)(0 - amount), string.Format("转给{0}[{1}]", spreadname, spread.Phone), "TotalAmount", (double)(CurrentUserInfo.TotalAmount - amount), "", "转账", "", "", (double)amount, 0, spread.UserID, tran) <= 0) { tran.Rollback(); apiResp.msg = "记录转账明细出错"; apiResp.code = (int)APIErrCode.OperateFail; bllUser.ContextResponse(context, apiResp); return; } if (bllUser.Update(CurrentUserInfo, string.Format("TotalAmount=ISNULL(TotalAmount,0)-{0},AccountAmountEstimate=ISNULL(AccountAmountEstimate,0)-{0}", amount), string.Format("AutoID={0} And WebsiteOwner='{1}' And ISNULL(TotalAmount,0)-{2}>=0 ", CurrentUserInfo.AutoID, websiteOwner, amount), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("消耗报单人可用{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bllUser.ContextResponse(context, apiResp); return; } #endregion #region 指定会员获得金额 if (bllUser.AddScoreDetail(spread.UserID, websiteOwner, (double)(amount), string.Format("{0}[{1}]转入", curname, CurrentUserInfo.Phone), "TotalAmount", (double)(spread.TotalAmount + amount), "", "获得转账", "", "", (double)amount, 0, CurrentUserInfo.UserID, tran) <= 0) { tran.Rollback(); apiResp.msg = "记录获得转账明细出错"; apiResp.code = (int)APIErrCode.OperateFail; bllUser.ContextResponse(context, apiResp); return; } if (bllUser.Update(spread, string.Format("TotalAmount=ISNULL(TotalAmount,0)+{0},AccountAmountEstimate=ISNULL(AccountAmountEstimate,0)+{0}", amount), string.Format("AutoID={0} And WebsiteOwner='{1}'", spread.AutoID, websiteOwner), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("增加会员可用{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bllUser.ContextResponse(context, apiResp); return; } #endregion tran.Commit(); //异步计算金额 Thread th1 = new Thread(delegate() { bll.CheckTotalAmount(spread.AutoID, websiteOwner, 7); }); th1.Start(); apiResp.msg = "转账成功"; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string id = context.Request["id"]; string forceDelete = context.Request["force_delete"]; //force_delete等于1时,则不管是否存在中奖记录,进行强制删除 if (forceDelete != "1") { if (bllLottery.GetCountByKey <WXLotteryRecordV1>("LotteryId", id) > 0) { resp.errcode = (int)APIErrCode.LotteryHaveRecord; resp.errmsg = string.Format("已经有人中奖,不能删除"); bllLottery.ContextResponse(context, resp); return; } } BLLTransaction tran = new BLLTransaction(); try { if (bllLottery.DeleteByKey <WXLotteryV1>("LotteryID", id, tran) == -1) { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "删除活动主表失败"; bllLottery.ContextResponse(context, resp); return; } if (bllLottery.DeleteByKey <WXAwardsV1>("LotteryId", id, tran) == -1) { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "删除奖项失败"; bllLottery.ContextResponse(context, resp); return; } if (bllLottery.DeleteByKey <WXLotteryRecordV1>("LotteryId", id, tran) == -1) { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "删除中奖记录失败"; bllLottery.ContextResponse(context, resp); return; } if (bllLottery.DeleteByKey <WXLotteryLogV1>("LotteryId", id, tran) == -1) { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "删除抽奖记录失败"; bllLottery.ContextResponse(context, resp); return; } if (bllLottery.DeleteByKey <WXLotteryWinningDataV1>("LotteryId", id, tran) == -1) { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "删除默认中奖设置失败"; bllLottery.ContextResponse(context, resp); return; } tran.Commit(); resp.isSuccess = true; } catch (Exception ex) { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = ex.Message; } bllLottery.ContextResponse(context, resp); }
public void ProcessRequest(HttpContext context) { string id = context.Request["id"]; string content = context.Request["content"]; if (string.IsNullOrWhiteSpace(content)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请填写申请取消原因"; bllFlow.ContextResponse(context, apiResp); return; } string websiteOwner = bllFlow.WebsiteOwner; FlowAction act = bllFlow.GetByKey <FlowAction>("AutoID", id, websiteOwner: websiteOwner); if (act.Status == 11) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "您已经申请取消"; bllFlow.ContextResponse(context, apiResp); return; } if (act.Status != 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "已经处理完成不能申请取消"; bllFlow.ContextResponse(context, apiResp); return; } if (CurrentUserInfo.UserID != act.CreateUserID) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "仅能申请人申请取消"; bllFlow.ContextResponse(context, apiResp); return; } act.CancelDate = DateTime.Now; act.Status = 11; BLLJIMP.Model.FlowActionDetail actionDetail1 = new BLLJIMP.Model.FlowActionDetail(); actionDetail1.ActionID = act.AutoID; actionDetail1.WebsiteOwner = websiteOwner; actionDetail1.FlowID = act.FlowID; actionDetail1.StepID = 0; actionDetail1.StepName = "申请取消"; actionDetail1.HandleUserID = CurrentUserInfo.UserID; actionDetail1.HandleDate = DateTime.Now; actionDetail1.HandleContent = content; BLLTransaction tran = new BLLTransaction(); if (!bllFlow.Update(act, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "申请取消失败"; bllFlow.ContextResponse(context, apiResp); return; } if (!bllFlow.Add(actionDetail1, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "记录申请取消失败"; bllFlow.ContextResponse(context, apiResp); return; } tran.Commit(); apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "申请取消成功"; bllFlow.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string data = context.Request["data"]; OrderModel orderRequestModel;//订单模型 try { orderRequestModel = JSONHelper.JsonToModel <OrderModel>(data); } catch (Exception ex) { apiResp.msg = "提交格式错误"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } WXMallProductInfo productInfo = bllMall.GetProduct(orderRequestModel.product_id.ToString()); if (productInfo == null) { apiResp.msg = "记录没有找到"; apiResp.code = (int)APIErrCode.IsNotFound; bllMall.ContextResponse(context, apiResp); return; } WXMallOrderInfo orderInfo = new WXMallOrderInfo();//订单表 orderInfo.ArticleCategoryType = productInfo.ArticleCategoryType; orderInfo.InsertDate = DateTime.Now; orderInfo.OrderUserID = CurrentUserInfo.UserID; orderInfo.WebsiteOwner = bllMall.WebsiteOwner; orderInfo.OrderMemo = orderRequestModel.buyer_memo; orderInfo.UseAmount = orderRequestModel.use_amount; if (orderRequestModel.receiver_id == 0) { orderInfo.Consignee = CurrentUserInfo.TrueName; orderInfo.Phone = CurrentUserInfo.Phone; } else { WXConsigneeAddress nUserAddress = bllMall.GetByKey <WXConsigneeAddress>("AutoID", orderRequestModel.receiver_id.ToString()); orderInfo.Consignee = nUserAddress.ConsigneeName; orderInfo.Phone = nUserAddress.Phone; orderInfo.Address = nUserAddress.Address; orderInfo.ZipCode = nUserAddress.ZipCode; orderInfo.ReceiverProvince = nUserAddress.Province; orderInfo.ReceiverProvinceCode = nUserAddress.ProvinceCode; orderInfo.ReceiverCity = nUserAddress.City; orderInfo.ReceiverCityCode = nUserAddress.CityCode; orderInfo.ReceiverDist = nUserAddress.Dist; orderInfo.ReceiverDistCode = nUserAddress.DistCode; } orderInfo.Transport_Fee = 0; orderInfo.Status = "待付款"; if (orderRequestModel.pay_type == "WEIXIN")//微信支付 { orderInfo.PaymentType = 2; } else if (orderRequestModel.pay_type == "ALIPAY")//支付宝支付 { orderInfo.PaymentType = 1; } if (orderRequestModel.skus == null || orderRequestModel.skus.Count == 0) { apiResp.msg = "Skus不能为空"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } #region 商品检查 订单详情生成 //订单详情 List <WXMallOrderDetailsInfo> detailList = new List <WXMallOrderDetailsInfo>(); //主商品订单明细 List <WXMallOrderDetailsInfo> detailAddedList = new List <WXMallOrderDetailsInfo>(); //增值服务订单明细 orderRequestModel.skus = orderRequestModel.skus.Distinct().ToList(); #region 购买的商品 foreach (var sku in orderRequestModel.skus) { ProductSku productSku = bllMall.GetProductSku(sku.sku_id); WXMallOrderDetailsInfo detailModel = new WXMallOrderDetailsInfo(); detailModel.TotalCount = sku.count; detailModel.OrderPrice = bllMall.GetSkuPrice(productSku); detailModel.SkuId = productSku.SkuId; detailModel.ArticleCategoryType = productSku.ArticleCategoryType; if (productSku.ArticleCategoryType.Contains("Added")) { WXMallProductInfo rproductInfo = bllMall.GetProduct(productSku.ProductId.ToString()); detailModel.PID = rproductInfo.PID; detailModel.ProductName = rproductInfo.PName; detailModel.Unit = rproductInfo.Unit; detailAddedList.Add(detailModel); } else { detailModel.PID = productInfo.PID; detailModel.ProductName = productInfo.PName; detailModel.StartDate = sku.start_date; detailModel.EndDate = sku.end_date; detailModel.Unit = productInfo.Unit; detailList.Add(detailModel); } } #endregion if (detailList.Count == 0) { apiResp.msg = "请选择预约时间"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } //已有订单详情 List <WXMallOrderDetailsInfo> oDetailList = bllMall.GetOrderDetailsList(null, productInfo.PID, productInfo.ArticleCategoryType, detailList.Min(p => p.StartDate), detailList.Max(p => p.EndDate)); List <string> hasOrderID_List = new List <string>(); string hasOrderIDs = ""; int maxCount = productInfo.Stock; foreach (var item in detailList) { List <WXMallOrderDetailsInfo> hasOrderDetailList = oDetailList.Where(p => !((item.StartDate >= p.EndDate && item.EndDate > p.EndDate) || (item.StartDate < p.StartDate && item.EndDate <= p.StartDate))).ToList(); if (hasOrderDetailList.Count >= maxCount) { hasOrderID_List.AddRange(hasOrderDetailList.Select(p => p.OrderID).Distinct()); } } if (hasOrderID_List.Count > 0) { hasOrderID_List = hasOrderID_List.Distinct().ToList(); hasOrderIDs = MyStringHelper.ListToStr(hasOrderID_List, "'", ","); int tempCount = 0; List <WXMallOrderInfo> tempList = bllMall.GetOrderList(0, 1, "", out tempCount, "预约成功", null, null, null, null, null, null, null, null, null, null, orderInfo.ArticleCategoryType, hasOrderIDs); if (tempCount >= maxCount) { apiResp.msg = "所选时间已有成功的预约"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } } //增值服务合并到主订单明细列表 detailList.AddRange(detailAddedList); //合计计算 orderInfo.Product_Fee = detailList.Sum(p => p.OrderPrice * p.TotalCount).Value; #region 积分计算 decimal scoreExchangeAmount = 0;//积分抵扣的金额 //积分计算 if (orderRequestModel.use_score > 0 && orderInfo.Product_Fee > 0) { orderInfo.UseScore = orderRequestModel.use_score; if (CurrentUserInfo.TotalScore < orderRequestModel.use_score) { apiResp.msg = "积分不足"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } ScoreConfig scoreConfig = bllScore.GetScoreConfig(); scoreExchangeAmount = Math.Round(orderRequestModel.use_score / (scoreConfig.ExchangeScore / scoreConfig.ExchangeAmount), 2); } //积分计算 #endregion #region 使用账户余额 if (orderRequestModel.use_amount > 0) { if (!bllMall.IsEnableAccountAmountPay()) { apiResp.msg = "未开启余额支付"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } if (CurrentUserInfo.AccountAmount < orderRequestModel.use_amount) { apiResp.msg = "您的账户余额不足"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } } #endregion orderInfo.TotalAmount = orderInfo.Product_Fee + orderInfo.Transport_Fee; orderInfo.TotalAmount -= scoreExchangeAmount; //积分优惠金额 orderInfo.TotalAmount -= orderRequestModel.use_amount; //余额抵扣金额 orderInfo.PayableAmount = orderInfo.TotalAmount - orderInfo.Transport_Fee; //应付金额 if ((orderInfo.Product_Fee + orderInfo.Transport_Fee - scoreExchangeAmount) < orderInfo.TotalAmount) { apiResp.msg = "积分兑换金额不能大于订单总金额,请减少积分兑换"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } if (orderInfo.TotalAmount < 0) { orderInfo.TotalAmount = 0; } if (orderInfo.TotalAmount == 0 && orderInfo.UseScore == 0) { orderInfo.Status = "待审核"; } else if (orderInfo.TotalAmount == 0 && (orderInfo.UseAmount > 0 || orderInfo.UseScore > 0)) { orderInfo.PaymentStatus = 1; orderInfo.PayTime = DateTime.Now; orderInfo.Status = "预约成功"; } #endregion //生成订单ID orderInfo.OrderID = bllMall.GetGUID(BLLJIMP.TransacType.AddMallOrder); BLLTransaction tran = new BLLTransaction(); if (!this.bllMall.Add(orderInfo, tran)) { tran.Rollback(); apiResp.msg = "提交失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } foreach (var item in detailList) { item.OrderID = orderInfo.OrderID; if (!this.bllMall.Add(item, tran)) { tran.Rollback(); apiResp.msg = "提交失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } } #region 积分抵扣 //积分扣除 if (orderRequestModel.use_score > 0) { CurrentUserInfo.TotalScore -= orderRequestModel.use_score; if (bllMall.Update(CurrentUserInfo, string.Format(" TotalScore-={0}", orderRequestModel.use_score), string.Format(" AutoID={0}", CurrentUserInfo.AutoID) , tran) < 0) { tran.Rollback(); apiResp.msg = "更新用户积分失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } //积分记录 UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo(); scoreRecord.AddTime = DateTime.Now; scoreRecord.Score = -orderRequestModel.use_score; scoreRecord.TotalScore = CurrentUserInfo.TotalScore; scoreRecord.ScoreType = "OrderSubmit"; scoreRecord.UserID = CurrentUserInfo.UserID; scoreRecord.AddNote = "预约-下单使用积分"; scoreRecord.RelationID = orderInfo.OrderID; scoreRecord.WebSiteOwner = CurrentUserInfo.WebsiteOwner; if (!bllMall.Add(scoreRecord)) { tran.Rollback(); apiResp.msg = "插入积分记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } } //积分扣除 #endregion #region 余额抵扣 if (orderRequestModel.use_amount > 0 && bllMall.IsEnableAccountAmountPay()) { CurrentUserInfo.AccountAmount -= orderRequestModel.use_amount; if (bllMall.Update(CurrentUserInfo, string.Format(" AccountAmount={0}", CurrentUserInfo.AccountAmount), string.Format(" AutoID={0}", CurrentUserInfo.AutoID)) < 0) { tran.Rollback(); apiResp.msg = "更新用户余额失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo(); scoreRecord.AddTime = DateTime.Now; scoreRecord.Score = -(double)orderRequestModel.use_amount; scoreRecord.TotalScore = (double)CurrentUserInfo.AccountAmount; scoreRecord.UserID = CurrentUserInfo.UserID; scoreRecord.AddNote = "账户余额变动-下单使用余额"; scoreRecord.RelationID = orderInfo.OrderID; scoreRecord.WebSiteOwner = bllMall.WebsiteOwner; scoreRecord.ScoreType = "AccountAmount"; if (!bllMall.Add(scoreRecord)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "插入余额记录失败"; context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); return; } UserCreditAcountDetails record = new UserCreditAcountDetails(); record.WebsiteOwner = bllMall.WebsiteOwner; record.Operator = CurrentUserInfo.UserID; record.UserID = CurrentUserInfo.UserID; record.CreditAcount = -orderRequestModel.use_amount; record.SysType = "AccountAmount"; record.AddTime = DateTime.Now; record.AddNote = "账户余额变动-" + orderRequestModel.use_amount; if (!bllMall.Add(record)) { tran.Rollback(); apiResp.msg = "插入余额记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } } #endregion tran.Commit();//提交订单事务 if (orderInfo.Status == "预约成功") { int tempCount = 0; if (string.IsNullOrWhiteSpace(hasOrderIDs)) { hasOrderIDs = "'0'"; } List <WXMallOrderInfo> tempList = bllMall.GetOrderList(0, 1, "", out tempCount, "预约成功", null, null, null, null, null, null, null, null, null, null, orderInfo.ArticleCategoryType, hasOrderIDs); tempCount = tempCount + 1; //加上当前订单的数量 if (tempCount >= maxCount) { tempList = bllMall.GetColOrderListInStatus("'待付款','待审核'", hasOrderIDs, "OrderID,OrderUserID,UseScore", bllMall.WebsiteOwner); if (tempList.Count > 0) { string stopOrderIds = MyStringHelper.ListToStr(tempList.Select(p => p.OrderID).ToList(), "'", ","); tempList = tempList.Where(p => p.UseScore > 0).ToList(); foreach (var item in tempList) { UserInfo orderUserInfo = bllUser.GetUserInfo(orderInfo.OrderUserID, bllMall.WebsiteOwner);//下单用户信息 if (orderUserInfo == null) { continue; } orderUserInfo.TotalScore += item.UseScore; if (bllMall.Update(orderUserInfo, string.Format(" TotalScore+={0}", item.UseScore), string.Format(" UserID='{0}'", item.OrderUserID)) > 0) { UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo(); scoreRecord.AddTime = DateTime.Now; scoreRecord.Score = item.UseScore; scoreRecord.TotalScore = orderUserInfo.TotalScore; scoreRecord.ScoreType = "OrderCancel"; scoreRecord.UserID = item.OrderUserID; scoreRecord.RelationID = item.OrderID; scoreRecord.AddNote = "预约-订单失败返还积分"; scoreRecord.WebSiteOwner = item.WebsiteOwner; bllMall.Add(scoreRecord); } } bllMall.Update(new WXMallOrderInfo(), string.Format("Status='{0}'", "预约失败"), string.Format("OrderID In ({0}) and WebsiteOwner='{1}'", stopOrderIds, bllMall.WebsiteOwner)); } } } //预约通知 bllWeiXin.SendTemplateMessageNotifyComm(CurrentUserInfo, orderInfo.Status, string.Format("预约:{2}\\n订单号:{0}\\n订单金额:{1}元", orderInfo.OrderID, orderInfo.TotalAmount, productInfo.PName)); apiResp.result = new { order_id = orderInfo.OrderID }; apiResp.msg = "提交完成"; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; bllMall.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { if (CurrentUserInfo.IsLock == 1) { apiResp.code = (int)APIErrCode.NoPms; apiResp.msg = "账号已被锁定"; bllUser.ContextResponse(context, apiResp); return; } if (CurrentUserInfo.MemberApplyStatus != 9) { apiResp.code = (int)APIErrCode.NoPms; apiResp.msg = "您的账号正在审核中"; bllUser.ContextResponse(context, apiResp); return; } BLLJIMP.Model.API.User.PayRegisterUser requestUser = bll.ConvertRequestToModel <BLLJIMP.Model.API.User.PayRegisterUser>(new BLLJIMP.Model.API.User.PayRegisterUser()); string websiteOwner = bll.WebsiteOwner; WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); if (string.IsNullOrWhiteSpace(requestUser.level.ToString())) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请选择会员级别"; bll.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(requestUser.phone)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入手机号码"; bll.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(requestUser.spreadid)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入推荐人编号"; bll.ContextResponse(context, apiResp); return; } if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(requestUser.phone)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号码格式不正确"; bll.ContextResponse(context, apiResp); return; } if (!ZentCloud.Common.MyRegex.IsIDCard(requestUser.idcard)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "身份证号码必须如实填写"; bll.ContextResponse(context, apiResp); return; } UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestUser.level.ToString()); if (levelConfig == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员级别未找到"; bll.ContextResponse(context, apiResp); return; } if (levelConfig.IsDisable == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员级别禁止注册"; bll.ContextResponse(context, apiResp); return; } decimal levelAmount = Convert.ToDecimal(levelConfig.FromHistoryScore); if (CurrentUserInfo.TotalAmount < levelAmount) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = string.Format("您的{0}不足", website.TotalAmountShowName); bll.ContextResponse(context, apiResp); return; } UserInfo spreadUser = bllUser.GetSpreadUser(requestUser.spreadid, websiteOwner); if (spreadUser == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "推荐人未找到"; bll.ContextResponse(context, apiResp); return; } requestUser.spreadid = spreadUser.UserID; //推荐人 UserInfo regUser = bllUser.GetUserInfoByPhone(requestUser.phone, websiteOwner); if (regUser != null && regUser.MemberLevel >= 10) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该手机已注册会员"; bll.ContextResponse(context, apiResp); return; } if (regUser != null && regUser.MemberLevel >= requestUser.level) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该会员有更高级别"; bll.ContextResponse(context, apiResp); return; } if (regUser == null) { regUser = new UserInfo(); regUser.UserID = string.Format("ZYUser{0}{1}", DateTime.Now.ToString("yyyyMMdd"), Guid.NewGuid().ToString("N").ToUpper()); regUser.UserType = 2; regUser.WebsiteOwner = websiteOwner; regUser.Regtime = DateTime.Now; regUser.LastLoginDate = DateTime.Parse("1970-01-01"); } regUser.TrueName = requestUser.truename; regUser.DistributionOwner = requestUser.spreadid; regUser.Phone = requestUser.phone; regUser.MemberLevel = requestUser.level; regUser.MemberApplyTime = DateTime.Now; regUser.MemberStartTime = DateTime.Now; regUser.MemberApplyStatus = 9; regUser.IdentityCard = requestUser.idcard; regUser.Province = requestUser.province; regUser.City = requestUser.city; regUser.District = requestUser.district; regUser.Town = requestUser.town; regUser.ProvinceCode = requestUser.provinceCode; regUser.CityCode = requestUser.cityCode; regUser.DistrictCode = requestUser.districtCode; regUser.TownCode = requestUser.townCode; regUser.RegIP = context.Request.UserHostAddress;//ip regUser.Password = ZentCloud.Common.Rand.Number(6); regUser.RegUserID = CurrentUserInfo.UserID; regUser.EmptyBill = 0; regUser.RegisterWay = "余额"; regUser.IsDisable = 0; int disLevel = 1; if (website.DistributionLimitLevel > 1) { disLevel = website.DistributionLimitLevel; } StringBuilder sbSql = new StringBuilder(); UserInfo upUserLevel1 = null; //分销上一级 UserInfo upUserLevel2 = null; //分销上二级 UserInfo upUserLevel3 = null; //分销上三级 UserLevelConfig levelConfig1 = null; //分销上一级规则 UserLevelConfig levelConfig2 = null; //分销上二级规则 UserLevelConfig levelConfig3 = null; //分销上三级规则 ProjectCommission modelLevel1 = new ProjectCommission(); ScoreLockInfo scoreLockLevel1Info = new ScoreLockInfo(); ProjectCommission modelLevel1ex1 = new ProjectCommission(); ScoreLockInfo scoreLockLevel1ex1Info = new ScoreLockInfo(); ProjectCommission modelLevel2 = new ProjectCommission(); ScoreLockInfo scoreLockLevel2Info = new ScoreLockInfo(); ProjectCommission modelLevel3 = new ProjectCommission(); ScoreLockInfo scoreLockLevel3Info = new ScoreLockInfo(); string projectId = bll.GetGUID(TransacType.PayRegisterOrder); //计算分佣 bll.ComputeTransfers(disLevel, regUser, projectId, levelAmount, websiteOwner, "他人代替注册", ref sbSql, ref upUserLevel1, ref upUserLevel2, ref upUserLevel3, ref levelConfig1, ref levelConfig2, ref levelConfig3, ref modelLevel1, ref scoreLockLevel1Info, ref modelLevel1ex1, ref scoreLockLevel1ex1Info, ref modelLevel2, ref scoreLockLevel2Info, ref modelLevel3, ref scoreLockLevel3Info, levelConfig.LevelString); BLLTransaction tran = new BLLTransaction(); #region 注册会员 if (regUser.AutoID == 0) { regUser.AutoID = Convert.ToInt32(bllUser.AddReturnID(regUser, tran)); if (regUser.AutoID <= 0) { tran.Rollback(); apiResp.msg = "注册用户出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } else { if (!bllUser.Update(regUser, tran)) { tran.Rollback(); apiResp.msg = "注册用户出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } #endregion #region 消耗报单人金额 if (bllUser.AddScoreDetail(CurrentUserInfo.UserID, websiteOwner, (double)(0 - levelAmount), string.Format("替{0}[{1}]注册{2}", regUser.TrueName, regUser.Phone, levelConfig.LevelString), "TotalAmount", (double)(CurrentUserInfo.TotalAmount - levelAmount), "", "替他人注册", "", "", (double)levelAmount, 0, regUser.UserID, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString) <= 0) { tran.Rollback(); apiResp.msg = "记录明细出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } if (bllUser.Update(CurrentUserInfo, string.Format("TotalAmount=ISNULL(TotalAmount,0)-{0},AccountAmountEstimate=ISNULL(AccountAmountEstimate,0)-{0}", levelAmount), string.Format("UserID='{0}' And WebsiteOwner='{1}' And TotalAmount-{2}>=0 ", CurrentUserInfo.UserID, websiteOwner, levelAmount), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("消耗报单人可用{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion #region 注册账号余额明细 //自己的消费记录 if (bllUser.AddScoreDetail(regUser.UserID, websiteOwner, (double)(levelAmount), string.Format("{0}[{1}]转入", CurrentUserInfo.TrueName, CurrentUserInfo.Phone, (double)levelAmount), "TotalAmount", (double)(levelAmount), "", "他人注册转入", "", "", (double)levelAmount, 0, CurrentUserInfo.UserID, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString) <= 0) { tran.Rollback(); apiResp.msg = "他人注册转入记录出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } int mainDetailId = bllUser.AddScoreDetail(regUser.UserID, websiteOwner, (double)(0 - levelAmount), string.Format("{0}[{1}]替您注册{2}", CurrentUserInfo.TrueName, CurrentUserInfo.Phone, levelConfig.LevelString), "TotalAmount", 0, "", "他人代替注册", "", "", (double)levelAmount, 0, CurrentUserInfo.UserID, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString); if (mainDetailId <= 0) { tran.Rollback(); apiResp.msg = "他人注册记录出错"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion bool hasProjectCommission = false; #region 记录分佣信息 if (modelLevel1.Amount > 0) { hasProjectCommission = true; int modelLevel1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1, tran)); if (modelLevel1Id <= 0) { tran.Rollback(); apiResp.msg = "一级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel1Info.ForeignkeyId2 = modelLevel1Id.ToString(); scoreLockLevel1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1Info, tran)); if (scoreLockLevel1Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "一级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel1Info.UserId, websiteOwner, (double)scoreLockLevel1Info.Score, scoreLockLevel1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1Info.Score), scoreLockLevel1Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel1.SourceAmount, (double)modelLevel1.DeductAmount, modelLevel1.CommissionUserId, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, ex5: modelLevel1.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "一级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel1ex1.Amount > 0) { hasProjectCommission = true; int modelLevel1ex1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1ex1, tran)); if (modelLevel1ex1Id <= 0) { tran.Rollback(); apiResp.msg = "一级返购房补助失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel1ex1Info.ForeignkeyId2 = modelLevel1ex1Id.ToString(); scoreLockLevel1ex1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1ex1Info, tran)); if (scoreLockLevel1ex1Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "一级返购房补助冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel1ex1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel1ex1Info.UserId, websiteOwner, (double)scoreLockLevel1ex1Info.Score, scoreLockLevel1ex1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1ex1Info.Score), scoreLockLevel1ex1Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel1ex1.SourceAmount, (double)modelLevel1ex1.DeductAmount, modelLevel1ex1.CommissionUserId, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, ex5: modelLevel1ex1.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "一级返购房补助明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel2.Amount > 0) { hasProjectCommission = true; int modelLevel2Id = Convert.ToInt32(bll.AddReturnID(modelLevel2, tran)); if (modelLevel2Id <= 0) { tran.Rollback(); apiResp.msg = "二级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel2Info.ForeignkeyId2 = modelLevel2Id.ToString(); scoreLockLevel2Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel2Info, tran)); if (scoreLockLevel2Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "二级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel2.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel2Info.UserId, websiteOwner, (double)scoreLockLevel2Info.Score, scoreLockLevel2Info.Memo, "TotalAmount", (double)(upUserLevel2.TotalAmount + scoreLockLevel2Info.Score), scoreLockLevel2Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel2.SourceAmount, (double)modelLevel2.DeductAmount, modelLevel2.CommissionUserId, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, ex5: modelLevel2.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "二级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (modelLevel3.Amount > 0) { hasProjectCommission = true; int modelLevel3Id = Convert.ToInt32(bll.AddReturnID(modelLevel3, tran)); if (!bll.Add(modelLevel3, tran)) { tran.Rollback(); apiResp.msg = "三级返利失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } scoreLockLevel3Info.ForeignkeyId2 = modelLevel3Id.ToString(); scoreLockLevel3Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel3Info, tran)); if (scoreLockLevel3Info.AutoId <= 0) { tran.Rollback(); apiResp.msg = "三级返利冻结失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } string scoreDetailEvent = modelLevel3.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; if (bllUser.AddScoreDetail(scoreLockLevel3Info.UserId, websiteOwner, (double)scoreLockLevel3Info.Score, scoreLockLevel3Info.Memo, "TotalAmount", (double)(upUserLevel3.TotalAmount + scoreLockLevel3Info.Score), scoreLockLevel3Info.AutoId.ToString(), scoreDetailEvent, "", projectId, (double)modelLevel3.SourceAmount, (double)modelLevel3.DeductAmount, modelLevel3.CommissionUserId, tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, ex5: modelLevel3.CommissionLevel) <= 0) { tran.Rollback(); apiResp.msg = "三级返利明细记录失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } if (hasProjectCommission) { if (BLLBase.ExecuteSql(sbSql.ToString(), tran) <= 0) { tran.Rollback(); apiResp.msg = string.Format("更新分佣账面{0}出错", website.TotalAmountShowName); apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } } #endregion #region 记录业绩明细 TeamPerformanceDetails perDetail = new TeamPerformanceDetails(); perDetail.AddType = "注册"; perDetail.AddNote = "注册" + levelConfig.LevelString; perDetail.AddTime = DateTime.Now; perDetail.DistributionOwner = regUser.DistributionOwner; perDetail.UserId = regUser.UserID; perDetail.UserName = regUser.TrueName; perDetail.UserPhone = regUser.Phone; perDetail.Performance = levelAmount; string yearMonthString = perDetail.AddTime.ToString("yyyyMM"); int yearMonth = Convert.ToInt32(yearMonthString); perDetail.YearMonth = yearMonth; perDetail.WebsiteOwner = websiteOwner; if (!bllUser.Add(perDetail, tran)) { tran.Rollback(); apiResp.msg = "记录业绩明细失败"; apiResp.code = (int)APIErrCode.OperateFail; bll.ContextResponse(context, apiResp); return; } #endregion tran.Commit(); if (hasProjectCommission) { //异步修改积分明细表 Thread th1 = new Thread(delegate() { //计算相关业绩 bll.BuildCurMonthPerformanceByUserID(websiteOwner, regUser.UserID); }); th1.Start(); } string msg = ""; #region 短信发送密码 BLLSMS bllSms = new BLLSMS(""); bool smsBool = false; string smsString = string.Format("恭喜您成功注册为天下华商月供宝:{1},您的初始密码为:{0}。您可关注公众号:songhetz,登录账户修改密码,并设置支付密码。", regUser.Password, levelConfig.LevelString); bllSms.SendSmsMisson(regUser.Phone, smsString, "", website.SmsSignature, out smsBool, out msg); #endregion if (string.IsNullOrWhiteSpace(msg)) { msg = "注册成功"; } apiResp.msg = msg; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.result = new { password = regUser.Password }; bll.ContextResponse(context, apiResp); }
/// <summary> /// 提交答题数据 /// </summary> /// <param name="postList">提交的答题数据</param> /// <param name="QuestionnaireIDStr">当前问卷ID</param> /// <param name="userId">用户ID</param> /// <param name="websiteOwner">站点ID</param> /// <param name="correctCount">正确数</param> /// <param name="msg">信息</param> /// <returns></returns> public bool PostQuestion(List <QuestionPostModel> postList, int questionnaireSetID, string userId, string websiteOwner, string userHostAddress, out int correctCount, out string msg, int questionnaireId) { correctCount = 0; msg = ""; List <QuestionnaireRecordDetail> listRecordDetail = new List <QuestionnaireRecordDetail>(); QuestionnaireRecord record = new QuestionnaireRecord(); #region 检查 格式化答案 if (postList == null || postList.Count == 0) { msg = "请提交答案"; return(false); } record.QuestionnaireID = questionnaireId; record.UserId = userId; record.WebsiteOwner = websiteOwner; record.AnswerCount = postList.Count; record.InsertDate = DateTime.Now; record.IP = userHostAddress; record.QuestionnaireSetID = questionnaireSetID; try { foreach (var item in postList) { if (string.IsNullOrWhiteSpace(item.Answer)) { continue; } Question nQuestion = Get <Question>(string.Format("QuestionID={0}", item.QuestionID)); if (nQuestion == null) { continue; } if (record.QuestionnaireID == 0) { record.QuestionnaireID = nQuestion.QuestionnaireID; } if (nQuestion.QuestionType == 0) { listRecordDetail.Add(new QuestionnaireRecordDetail(userId, questionnaireId, nQuestion.QuestionID, Convert.ToInt32(item.Answer), null, questionnaireSetID)); Answer nAnswer = Get <Answer>(string.Format("AnswerID={0}", item.Answer)); if (nAnswer == null) { continue; } if (nAnswer.IsCorrect == 1) { correctCount++; } } else if (nQuestion.QuestionType == 1) { List <int> pAnswers = item.Answer.Split('|').Select(p => Convert.ToInt32(p)).ToList(); foreach (var nitem in pAnswers) { listRecordDetail.Add(new QuestionnaireRecordDetail(userId, questionnaireId, nQuestion.QuestionID, nitem, null, questionnaireSetID)); } string pAnswerIDs = Common.MyStringHelper.ListToStr(pAnswers.OrderBy(p => p).ToList(), "", ","); string nAnswerIDs = Common.MyStringHelper.ListToStr(GetList <Answer>(string.Format("QuestionID={0} AND IsCorrect=1 ", item.QuestionID)) .Select(p => p.AnswerID).OrderBy(p => p).ToList(), "", ","); if (pAnswerIDs == nAnswerIDs) { correctCount++; } } else if (nQuestion.QuestionType == 2) { listRecordDetail.Add(new QuestionnaireRecordDetail(userId, questionnaireId, nQuestion.QuestionID, 0, item.Answer, questionnaireSetID)); } } record.CorrectCount = correctCount; } catch (Exception ex) { msg = "格式化提交答案出错"; return(false); } #endregion BLLTransaction tran = new BLLTransaction();//事务 try { record.RecordID = Convert.ToInt64(GetRecordGUID()); if (!Add(record, tran)) { tran.Rollback(); msg = "提交数据库出错"; return(false); } foreach (var item in listRecordDetail) { item.RecordID = record.RecordID; if (!Add(item, tran)) { tran.Rollback(); msg = "提交数据库出错"; return(false); } } } catch (Exception ex) { tran.Rollback(); msg = "提交数据库出错"; return(false); } tran.Commit(); msg = "提交完成"; return(true); }
public void ProcessRequest(HttpContext context) { RequestModel requestModel = bll.ConvertRequestToModel <RequestModel>(new RequestModel()); //bool isSuccess = false; BLLPermission.Model.PermissionGroupInfo nGroup = new BLLPermission.Model.PermissionGroupInfo(); if (requestModel.group_id > 0) { nGroup = bll.GetByKey <BLLPermission.Model.PermissionGroupInfo>("GroupID", requestModel.group_id.ToString()); if (nGroup == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "角色未找到"; bll.ContextResponse(context, apiResp); return; } if (nGroup.GroupID == requestModel.pre_id) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "上级角色不能选择自己"; bll.ContextResponse(context, apiResp); return; } if (requestModel.pre_id == 0) { nGroup.PreID = currentUserInfo.PermissionGroupID.HasValue?currentUserInfo.PermissionGroupID.Value : 0; } else { nGroup.PreID = requestModel.pre_id; } nGroup.GroupName = requestModel.group_name; nGroup.GroupDescription = requestModel.group_describe; if (!bllPermission.Update(nGroup)) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "编辑角色失败"; bll.ContextResponse(context, apiResp); return; } } else { nGroup.GroupID = Convert.ToInt64(bllPermission.GetGUID(ZentCloud.Common.TransacType.PermissionGroupAdd)); nGroup.GroupName = requestModel.group_name; nGroup.GroupDescription = requestModel.group_describe; nGroup.WebsiteOwner = bllPermission.WebsiteOwner; nGroup.GroupType = 2; if (currentUserInfo.UserType != 1 && currentUserInfo.UserID != bll.WebsiteOwner && requestModel.pre_id == 0) { if (!currentUserInfo.PermissionGroupID.HasValue) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "新增角色失败,请联系管理员设置您的角色"; bll.ContextResponse(context, apiResp); return; } nGroup.PreID = currentUserInfo.PermissionGroupID.Value; } else { nGroup.PreID = requestModel.pre_id; } if (!bllPermission.Add(nGroup)) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "新增角色失败"; bll.ContextResponse(context, apiResp); return; } } if (string.IsNullOrWhiteSpace(requestModel.col_ids)) { requestModel.col_ids = "0"; } List <long> col_id_list = requestModel.col_ids.Split(',').Select(p => Convert.ToInt64(p)).ToList(); List <BLLPermission.Model.PermissionRelationInfo> relOList = bllPermission.GetPermissionRelationList(nGroup.GroupID.ToString(), 3); List <long> colo_id_list = relOList.Select(p => p.PermissionID).ToList(); List <BLLPermission.Model.PermissionRelationInfo> relDelList = relOList.Where(p => !col_id_list.Contains(p.PermissionID)).ToList(); List <BLLPermission.Model.PermissionRelationInfo> relAddList = new List <BLLPermission.Model.PermissionRelationInfo>(); foreach (long item in col_id_list.Where(p => !colo_id_list.Contains(p) && p != 0)) { BLLPermission.Model.PermissionRelationInfo nPerRel = new BLLPermission.Model.PermissionRelationInfo(); nPerRel.RelationType = 3; nPerRel.PermissionID = item; nPerRel.RelationID = nGroup.GroupID.ToString(); relAddList.Add(nPerRel); } BLLTransaction tran = new BLLTransaction(); foreach (BLLPermission.Model.PermissionRelationInfo item in relDelList) { if (bllPermission.Delete(item, tran) < 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "删除原栏目失败。"; bllPermission.ContextResponse(context, apiResp); return; } } foreach (BLLPermission.Model.PermissionRelationInfo item in relAddList) { if (!bllPermission.Add(item, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "保存新栏目失败。"; bllPermission.ContextResponse(context, apiResp); return; } } tran.Commit(); apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "提交完成。"; bllPermission.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { BLLJIMP.Model.API.User.PayRegisterUser requestUser = bll.ConvertRequestToModel <BLLJIMP.Model.API.User.PayRegisterUser>(new BLLJIMP.Model.API.User.PayRegisterUser()); string websiteOwner = bll.WebsiteOwner; BLLJIMP.Model.Flow flow = bllFlow.GetFlowByKey(requestUser.flow_key, websiteOwner); if (flow == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "流程未定义"; bllFlow.ContextResponse(context, apiResp); return; } if (flow.IsDelete == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = flow.FlowName + "已停用"; bllFlow.ContextResponse(context, apiResp); return; } List <BLLJIMP.Model.FlowStep> steps = bllFlow.GetStepList(2, 1, websiteOwner, flow.AutoID); if (steps.Count == 0) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = flow.FlowName + "环节未设置"; bllFlow.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(requestUser.level.ToString())) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请选择会员级别"; bll.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(requestUser.phone)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入手机号码"; bll.ContextResponse(context, apiResp); return; } if (string.IsNullOrWhiteSpace(requestUser.spreadid)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入推荐人编号"; bll.ContextResponse(context, apiResp); return; } if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(requestUser.phone)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "手机号码格式不正确"; bll.ContextResponse(context, apiResp); return; } if (!ZentCloud.Common.MyRegex.IsIDCard(requestUser.idcard)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "身份证号码必须如实填写"; bll.ContextResponse(context, apiResp); return; } UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestUser.level.ToString()); if (levelConfig == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员级别未找到"; bll.ContextResponse(context, apiResp); return; } if (levelConfig.IsDisable == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员级别禁止注册"; bll.ContextResponse(context, apiResp); return; } requestUser.levelname = levelConfig.LevelString; UserInfo spreadUser = bllUser.GetSpreadUser(requestUser.spreadid, websiteOwner); if (spreadUser == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "推荐人未找到"; bll.ContextResponse(context, apiResp); return; } requestUser.spreadid = spreadUser.UserID; //推荐人 if (bllFlow.ExistsMemberPhoneAction(websiteOwner, flow.FlowKey, "0", requestUser.phone)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该手机用户正在申请会员"; bll.ContextResponse(context, apiResp); return; } UserInfo oldUserInfo = bllUser.GetUserInfoByPhone(requestUser.phone, websiteOwner); if (oldUserInfo != null && oldUserInfo.MemberLevel >= 10) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该手机已注册会员"; bll.ContextResponse(context, apiResp); return; } if (oldUserInfo != null && oldUserInfo.MemberLevel > requestUser.level) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该会员有更高级别"; bll.ContextResponse(context, apiResp); return; } if (oldUserInfo == null) { oldUserInfo = new UserInfo(); oldUserInfo.UserID = string.Format("ZYUser{0}{1}", DateTime.Now.ToString("yyyyMMdd"), Guid.NewGuid().ToString("N").ToUpper()); oldUserInfo.Regtime = DateTime.Now; } oldUserInfo.RegIP = context.Request.UserHostAddress;//ip oldUserInfo.Password = ZentCloud.Common.Rand.Number(6); oldUserInfo.UserType = 2; oldUserInfo.TrueName = requestUser.truename; oldUserInfo.WebsiteOwner = websiteOwner; oldUserInfo.DistributionOwner = requestUser.spreadid; oldUserInfo.Phone = requestUser.phone; oldUserInfo.MemberApplyTime = DateTime.Now; oldUserInfo.MemberLevel = levelConfig.LevelNumber; oldUserInfo.LastLoginDate = DateTime.Parse("1970-01-01"); oldUserInfo.IdentityCard = requestUser.idcard; oldUserInfo.Province = requestUser.province; oldUserInfo.City = requestUser.city; oldUserInfo.District = requestUser.district; oldUserInfo.Town = requestUser.town; oldUserInfo.ProvinceCode = requestUser.provinceCode; oldUserInfo.CityCode = requestUser.cityCode; oldUserInfo.DistrictCode = requestUser.districtCode; oldUserInfo.TownCode = requestUser.townCode; oldUserInfo.RegUserID = currentUserInfo.UserID; if (flow.FlowKey == "RegisterEmptyBill") { oldUserInfo.EmptyBill = 1; oldUserInfo.MemberApplyStatus = 0; } else { oldUserInfo.EmptyBill = 0; oldUserInfo.MemberApplyStatus = 1; } oldUserInfo.RegisterWay = "线下"; oldUserInfo.IsDisable = 0; BLLJIMP.Model.FlowStep step1 = steps[0]; BLLJIMP.Model.FlowStep step2 = null; if (steps.Count == 2) { step2 = steps[1]; } BLLJIMP.Model.FlowAction action = new BLLJIMP.Model.FlowAction(); action.CreateDate = DateTime.Now; action.CreateUserID = currentUserInfo.UserID; action.WebsiteOwner = websiteOwner; action.StartStepID = step1.AutoID; action.FlowID = flow.AutoID; action.FlowKey = flow.FlowKey; action.StartEx2 = JsonConvert.SerializeObject(requestUser); if (!string.IsNullOrWhiteSpace(requestUser.content)) { action.StartContent = requestUser.content; } if (!string.IsNullOrWhiteSpace(requestUser.ex1)) { action.StartEx1 = requestUser.ex1; } action.MemberAutoID = 0; action.MemberID = oldUserInfo.UserID; action.MemberName = oldUserInfo.TrueName; action.MemberPhone = oldUserInfo.Phone; action.MemberLevel = levelConfig.LevelNumber; action.MemberLevelName = levelConfig.LevelString; action.FlowName = flow.FlowName; action.Amount = Convert.ToDecimal(levelConfig.FromHistoryScore); if (step2 != null) { action.StepID = step2.AutoID; action.StepName = step2.StepName; } else { action.Status = 9; action.EndDate = DateTime.Now; } BLLJIMP.Model.FlowActionDetail actionDetail1 = new BLLJIMP.Model.FlowActionDetail(); actionDetail1.WebsiteOwner = websiteOwner; actionDetail1.FlowID = flow.AutoID; actionDetail1.StepID = step1.AutoID; actionDetail1.StepName = step1.StepName; actionDetail1.HandleUserID = currentUserInfo.UserID; actionDetail1.HandleDate = DateTime.Now; actionDetail1.Ex2 = action.StartEx2; if (!string.IsNullOrWhiteSpace(action.StartContent)) { actionDetail1.HandleContent = action.StartContent; } if (!string.IsNullOrWhiteSpace(action.StartEx1)) { actionDetail1.Ex1 = action.StartEx1; } List <BLLJIMP.Model.FlowActionFile> files = new List <BLLJIMP.Model.FlowActionFile>(); List <string> fileUrls = requestUser.files.Split(',').Where(p => !string.IsNullOrWhiteSpace(p)).ToList(); if (fileUrls.Count > 0) { foreach (var item in fileUrls) { files.Add(new BLLJIMP.Model.FlowActionFile() { FlowID = flow.AutoID, StepID = step1.AutoID, WebsiteOwner = websiteOwner, FilePath = item }); } if (fileUrls.Count > 0) { oldUserInfo.Ex6 = fileUrls[0]; } if (fileUrls.Count > 1) { oldUserInfo.Ex7 = fileUrls[1]; } if (fileUrls.Count > 2) { oldUserInfo.Ex8 = fileUrls[2]; } if (fileUrls.Count > 3) { oldUserInfo.Ex9 = fileUrls[3]; } if (fileUrls.Count > 4) { oldUserInfo.Ex10 = fileUrls[4]; } } //WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); //int disLevel = 1; //if (website.DistributionLimitLevel > 1) disLevel = website.DistributionLimitLevel; //StringBuilder sbSql = new StringBuilder(); //bool hasProjectCommission = false;//分佣是否存在 //UserInfo upUserLevel1 = null;//分销上一级 //UserInfo upUserLevel2 = null;//分销上二级 //UserInfo upUserLevel3 = null;//分销上三级 //UserLevelConfig levelConfig1 = null;//分销上一级规则 //UserLevelConfig levelConfig2 = null;//分销上二级规则 //UserLevelConfig levelConfig3 = null;//分销上三级规则 //ProjectCommission modelLevel1 = new ProjectCommission(); //ScoreLockInfo scoreLockLevel1Info = new ScoreLockInfo(); //ProjectCommission modelLevel1ex1 = new ProjectCommission(); //ScoreLockInfo scoreLockLevel1ex1Info = new ScoreLockInfo(); //ProjectCommission modelLevel2 = new ProjectCommission(); //ScoreLockInfo scoreLockLevel2Info = new ScoreLockInfo(); //ProjectCommission modelLevel3 = new ProjectCommission(); //ScoreLockInfo scoreLockLevel3Info = new ScoreLockInfo(); //string guId = bll.GetGUID(TransacType.OfflineRegister); ////计算分佣 //bll.ComputeTransfers(disLevel, oldUserInfo, guId, action.Amount, websiteOwner, "线下注册", ref sbSql, ref upUserLevel1, // ref upUserLevel2, ref upUserLevel3, ref levelConfig1, ref levelConfig2, ref levelConfig3, ref modelLevel1, ref scoreLockLevel1Info, // ref modelLevel1ex1, ref scoreLockLevel1ex1Info, ref modelLevel2, ref scoreLockLevel2Info, ref modelLevel3, ref scoreLockLevel3Info, // levelConfig.LevelString); BLLTransaction tran = new BLLTransaction(); //线下注册,扣钱,(实单审核后返) oldUserInfo.AccountAmountEstimate -= action.Amount; oldUserInfo.TotalAmount -= action.Amount; if (oldUserInfo.AutoID == 0) { oldUserInfo.AutoID = Convert.ToInt32(bllFlow.AddReturnID(oldUserInfo, tran)); if (oldUserInfo.AutoID <= 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "注册失败"; bllFlow.ContextResponse(context, apiResp); return; } action.MemberAutoID = oldUserInfo.AutoID; } else { if (!bllUser.Update(oldUserInfo, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "注册失败"; bllFlow.ContextResponse(context, apiResp); return; } action.MemberAutoID = oldUserInfo.AutoID; } int rId = Convert.ToInt32(bllFlow.AddReturnID(action, tran)); if (rId <= 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + "失败"; bllFlow.ContextResponse(context, apiResp); return; } #region 记录分佣信息 //if (modelLevel1.Amount > 0) //{ // hasProjectCommission = true; // modelLevel1.ProjectId = rId; // int modelLevel1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1, tran)); // if (modelLevel1Id <= 0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "一级返利失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } // scoreLockLevel1Info.ForeignkeyId2 = modelLevel1Id.ToString(); // scoreLockLevel1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1Info, tran)); // if (scoreLockLevel1Info.AutoId<=0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "一级返利冻结失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } // string scoreDetailEvent = modelLevel1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; // if (bllUser.AddScoreDetail(scoreLockLevel1Info.UserId, websiteOwner, (double)scoreLockLevel1Info.Score, // scoreLockLevel1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1Info.Score), // scoreLockLevel1Info.AutoId.ToString(), scoreDetailEvent, "", rId.ToString(), // (double)modelLevel1.SourceAmount, (double)modelLevel1.DeductAmount, // modelLevel1.CommissionUserId, tran, // ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, // ex5: modelLevel1.CommissionLevel) <= 0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "一级返利明细记录失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } //} //if (modelLevel1ex1.Amount > 0) //{ // hasProjectCommission = true; // modelLevel1ex1.ProjectId = rId; // int modelLevel1ex1Id = Convert.ToInt32(bll.AddReturnID(modelLevel1ex1, tran)); // if (modelLevel1ex1Id <= 0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "一级返购房补助失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } // scoreLockLevel1ex1Info.ForeignkeyId2 = modelLevel1ex1Id.ToString(); // scoreLockLevel1ex1Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel1ex1Info, tran)); // if (scoreLockLevel1ex1Info.AutoId<=0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "一级返购房补助冻结失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } // string scoreDetailEvent = modelLevel1ex1.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; // if (bllUser.AddScoreDetail(scoreLockLevel1ex1Info.UserId, websiteOwner, (double)scoreLockLevel1ex1Info.Score, // scoreLockLevel1ex1Info.Memo, "TotalAmount", (double)(upUserLevel1.TotalAmount + scoreLockLevel1ex1Info.Score), // scoreLockLevel1ex1Info.AutoId.ToString(), scoreDetailEvent, "", rId.ToString(), // (double)modelLevel1ex1.SourceAmount, (double)modelLevel1ex1.DeductAmount, // modelLevel1ex1.CommissionUserId, // tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, // ex5: modelLevel1ex1.CommissionLevel) <= 0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "一级返购房补助明细记录失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } //} //if (modelLevel2.Amount > 0) //{ // hasProjectCommission = true; // modelLevel2.ProjectId = rId; // int modelLevel2Id = Convert.ToInt32(bll.AddReturnID(modelLevel2, tran)); // if (modelLevel2Id <= 0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "二级返利失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } // scoreLockLevel2Info.ForeignkeyId2 = modelLevel2Id.ToString(); // scoreLockLevel2Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel2Info, tran)); // if (scoreLockLevel2Info.AutoId<=0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "二级返利冻结失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } // string scoreDetailEvent = modelLevel2.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; // if (bllUser.AddScoreDetail(scoreLockLevel2Info.UserId, websiteOwner, (double)scoreLockLevel2Info.Score, // scoreLockLevel2Info.Memo, "TotalAmount", (double)(upUserLevel2.TotalAmount + scoreLockLevel2Info.Score), // scoreLockLevel2Info.AutoId.ToString(), scoreDetailEvent, "", rId.ToString(), (double)modelLevel2.SourceAmount, (double)modelLevel2.DeductAmount, // modelLevel2.CommissionUserId, // tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, // ex5: modelLevel2.CommissionLevel) <= 0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "二级返利明细记录失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } //} //if (modelLevel3.Amount > 0) //{ // hasProjectCommission = true; // modelLevel3.ProjectId = rId; // int modelLevel3Id = Convert.ToInt32(bll.AddReturnID(modelLevel3, tran)); // if (modelLevel3Id<=0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "三级返利失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } // scoreLockLevel3Info.ForeignkeyId2 = modelLevel3Id.ToString(); // scoreLockLevel3Info.AutoId = Convert.ToInt32(bll.AddReturnID(scoreLockLevel3Info, tran)); // if (scoreLockLevel3Info.AutoId<=0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "三级返利冻结失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } // string scoreDetailEvent = modelLevel3.ProjectName.Contains("购房补助") ? "返购房补助" : "返利"; // if (bllUser.AddScoreDetail(scoreLockLevel3Info.UserId, websiteOwner, (double)scoreLockLevel3Info.Score, // scoreLockLevel3Info.Memo, "TotalAmount", (double)(upUserLevel3.TotalAmount + scoreLockLevel3Info.Score), // scoreLockLevel3Info.AutoId.ToString(), scoreDetailEvent, "" ,rId.ToString(), (double)modelLevel3.SourceAmount, (double)modelLevel3.DeductAmount, // modelLevel3.CommissionUserId, // tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString, // ex5: modelLevel3.CommissionLevel) <= 0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "三级返利明细记录失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } //} //if (hasProjectCommission) //{ // int result = BLLBase.ExecuteSql(sbSql.ToString(), tran); // if (result <= 0) // { // tran.Rollback(); // apiResp.code = (int)APIErrCode.OperateFail; // apiResp.msg = "更新分佣账面金额失败"; // bllFlow.ContextResponse(context, apiResp); // return; // } //} #endregion #region 记录余额明细 //自己的消费记录 string note = flow.FlowKey == "RegisterEmptyBill" ? "线下注册空单" : "线下注册"; int mainDetailId = bllUser.AddScoreDetail(oldUserInfo.UserID, websiteOwner, (double)(0 - action.Amount), string.Format("{1}{0}", levelConfig.LevelString, note), "TotalAmount", (double)oldUserInfo.TotalAmount, "", "注册会员", "", rId.ToString(), (double)action.Amount, 0, "", tran, ex3: levelConfig.LevelNumber.ToString(), ex4: levelConfig.LevelString); if (mainDetailId <= 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "注册明细失败"; bllFlow.ContextResponse(context, apiResp); return; } #endregion actionDetail1.ActionID = rId; if (!bllFlow.Add(actionDetail1, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + ",记录失败"; bllFlow.ContextResponse(context, apiResp); return; } foreach (var item in files) { item.ActionID = rId; if (!bllFlow.Add(item, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + ",保存附件失败"; bllFlow.ContextResponse(context, apiResp); return; } } tran.Commit(); string msg = ""; #region 短信发送密码 BLLSMS bllSms = new BLLSMS(""); bool smsBool = false; WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner); string smsString = string.Format("恭喜您成功注册为天下华商月供宝:{1},您的初始密码为:{0}。您可关注公众号:songhetz,登录账户修改密码,并设置支付密码。", oldUserInfo.Password, levelConfig.LevelString); bllSms.SendSmsMisson(oldUserInfo.Phone, smsString, "", website.SmsSignature, out smsBool, out msg); #endregion apiResp.msg = "注册成功" + (smsBool ? "" : ",但短信发送失败:" + msg); apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; bllFlow.ContextResponse(context, apiResp); }
/// <summary> /// 积分事件触发 /// </summary> /// <param name="websiteOwner">站点所有者</param> /// <param name="openId">openId</param> /// <param name="value">原始值</param> /// <param name="scoreEvent">事件名称</param> /// <param name="remark">备注</param> /// <param name="msg">提示信息</param> /// <param name="addScore">增加积分</param> /// <param name="showName">显示名称</param> /// <returns></returns> public bool EventUpdate(string websiteOwner, string openId, decimal value, string scoreEvent, string remark, out string msg, out int addScore, string showName = "", string serialNumber = "") { int score = 0;//最终添加的积分 addScore = 0; msg = "";//返回消息 BLLApiLog bllApiLog = new BLLApiLog(); BLLScoreDefine bllScoreDefine = new BLLScoreDefine(); ScoreDefineInfo scoreDefineInfo = bllScoreDefine.GetScoreDefineInfoByScoreEvent(scoreEvent, WebsiteOwner); if (scoreDefineInfo == null) { msg = "积分规则不存在,请检查"; return(false); } if (scoreDefineInfo.IsHide == 1) { msg = "积分规则已停用"; return(false); } UserInfo userInfo = bllUser.GetUserInfoByOpenId(openId); if (userInfo == null && (websiteOwner == "dongwu" || websiteOwner == "dongwudev")) { userInfo = bllUser.CreateNewUser(websiteOwner, openId, showName); } if (userInfo == null) { msg = "openid不存在,请检查"; return(false); } List <ScoreDefineInfoExt> scoreDefineEx = bllScoreDefine.GetScoreDefineExList(scoreDefineInfo.ScoreId); //优先级: 扩展->基本比例-一般 if (scoreDefineEx != null && scoreDefineEx.Count > 0) { DateTime dtNow = DateTime.Now; var item = scoreDefineEx.FirstOrDefault(p => p.BeginTime <= DateTime.Now && p.EndTime >= DateTime.Now); if (item != null) { //score = (double)Math.Round(value / (item.RateValue / item.RateScore), 2); score = (int)Math.Ceiling(value / (item.RateValue / item.RateScore)); } } if (score == 0) { if (scoreDefineInfo.BaseRateScore > 0 && scoreDefineInfo.BaseRateValue > 0)//基础比例 { //score = (double)Math.Round(value / (scoreDefineInfo.BaseRateValue / scoreDefineInfo.BaseRateScore), 2); score = (int)Math.Ceiling(value / (scoreDefineInfo.BaseRateValue / scoreDefineInfo.BaseRateScore)); } } if (score == 0) { score = (int)scoreDefineInfo.Score; } //if (score == 0) //{ // msg = "增加积分不能为0"; // return false; //} if (scoreDefineInfo.DayLimit > 0) { double nTotal = bllUser.GetUserDayScoreSUMEvent(userInfo.UserID, scoreEvent, true); if (scoreDefineInfo.DayLimit < nTotal + score) { msg = scoreDefineInfo.ScoreEvent + "每日所得积分超限制"; return(false); } } if (scoreDefineInfo.TotalLimit > 0) { double nTotal = bllUser.GetUserDayScoreSUMEvent(userInfo.UserID, scoreEvent, false); if (scoreDefineInfo.TotalLimit < nTotal + score) { msg = scoreDefineInfo.ScoreEvent + "所得总积分超限制"; return(false); } } //积分记录 UserScoreDetailsInfo scoreModel = new UserScoreDetailsInfo(); scoreModel.AddNote = !string.IsNullOrEmpty(remark) ? remark : scoreDefineInfo.Description; scoreModel.AddTime = DateTime.Now; scoreModel.Score = score; scoreModel.UserID = userInfo.UserID; scoreModel.OpenId = userInfo.WXOpenId; scoreModel.ScoreType = scoreDefineInfo.ScoreType; scoreModel.WebSiteOwner = WebsiteOwner; scoreModel.ScoreEvent = scoreEvent; scoreModel.SerialNumber = serialNumber; BLLTransaction tran = new BLLTransaction(); try { int historyTotalScore = 0; if (score > 0) { historyTotalScore = score; } string sql = string.Format("TotalScore+={0},HistoryTotalScore+={1}", score, historyTotalScore); if (!string.IsNullOrEmpty(showName)) { sql += string.Format(",TrueName='{0}'", showName); } if (Update(userInfo, sql, string.Format(" AutoId={0}", userInfo.AutoID), tran) == 1 && Add(scoreModel, tran)) { #region 日志记录 if (!bllApiLog.Add(userInfo.WebsiteOwner, Enums.EnumApiModule.ScoreEvent, string.Format("积分事件,事件名称:{0}原始值{1}积分值:{2}", scoreDefineInfo.ScoreEvent, value, score), userInfo.WXOpenId, userInfo.UserID, serialNumber)) { msg = "日志记录失败"; tran.Rollback(); return(false); } #endregion tran.Commit(); addScore = score; return(true); } else { msg = "操作失败"; tran.Rollback(); return(false); } } catch (Exception ex) { msg = ex.ToString(); tran.Rollback(); return(false); } }
public void ProcessRequest(HttpContext context) { Add.ProductModel productRequestModel = new Add.ProductModel();//订单模型 try { productRequestModel = bllMall.ConvertRequestToModel <Add.ProductModel>(productRequestModel); } catch (Exception ex) { apiResp.msg = "提交格式错误"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } //数据检查 if (string.IsNullOrEmpty(productRequestModel.product_title)) { apiResp.msg = "商品名称必填"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } //if (productRequestModel.price == 0) //{ // apiResp.msg = "商品价格必填"; // apiResp.code = (int)APIErrCode.OperateFail; // bllMall.ContextResponse(context, apiResp); // return; //} //if (string.IsNullOrWhiteSpace(productRequestModel.show_imgs) && !productRequestModel.article_category_type.Contains("Added")) //{ // apiResp.msg = "请上传商品图片"; // apiResp.code = (int)APIErrCode.OperateFail; // bllMall.ContextResponse(context, apiResp); // return; //} WXMallProductInfo productInfo = bllMall.GetByKey <WXMallProductInfo>("PID", productRequestModel.product_id, true); if (productInfo == null) { apiResp.msg = "数据未找到"; apiResp.code = (int)APIErrCode.IsNotFound; bllMall.ContextResponse(context, apiResp); return; } productInfo.PName = productRequestModel.product_title; productInfo.PDescription = productRequestModel.product_desc; productInfo.Price = productRequestModel.price; productInfo.CategoryId = productRequestModel.category_id; productInfo.IsOnSale = productRequestModel.is_onsale.ToString(); productInfo.Stock = productRequestModel.totalcount;//(容纳人数) productInfo.Sort = productRequestModel.sort; //productInfo.UserID = currentUserInfo.UserID; productInfo.PreviousPrice = productRequestModel.price; productInfo.Summary = productRequestModel.product_summary; productInfo.LastUpdate = DateTime.Now; productInfo.RelationProductId = productRequestModel.relation_product_id; productInfo.AccessLevel = productRequestModel.access_Level; productInfo.Unit = productRequestModel.unit; if (!string.IsNullOrWhiteSpace(productRequestModel.show_imgs)) { productInfo.ShowImage = productRequestModel.show_imgs; List <string> imgs = productRequestModel.show_imgs.Split(',').Where(p => !string.IsNullOrWhiteSpace(p)).ToList(); productInfo.RecommendImg = imgs[0]; int max = imgs.Count > 5 ? 5 : imgs.Count; for (int i = 0; i < max; i++) { if (i == 0) { productInfo.ShowImage1 = imgs[0]; } else if (i == 1) { productInfo.ShowImage2 = imgs[1]; } else if (i == 2) { productInfo.ShowImage3 = imgs[2]; } else if (i == 3) { productInfo.ShowImage4 = imgs[3]; } else if (i == 4) { productInfo.ShowImage5 = imgs[4]; } } } string dSkuIds = ""; //默认第一条sku ProductSku productSku = bllMall.GetProductSku(productRequestModel.product_id); if (productSku == null) { //增加系统默认sku productSku = new ProductSku();// productSku.InsertDate = DateTime.Now; productSku.Stock = 1; productSku.WebSiteOwner = bllMall.WebsiteOwner; productSku.ArticleCategoryType = productInfo.ArticleCategoryType; } List <ProductSku> addSkuList = new List <ProductSku>(); List <ProductSku> updateSkuList = new List <ProductSku>(); if (productRequestModel.time_set_method == 0) { productSku.Price = productInfo.Price; updateSkuList.Add(productSku); List <ProductSku> dSkuList = bllMall.GetColList <ProductSku>(int.MaxValue, 1, string.Format("ProductId={0} AND SkuId!={1} ", productInfo.PID, productSku.SkuId), "SkuId"); if (dSkuList.Count > 0) { dSkuIds = ZentCloud.Common.MyStringHelper.ListToStr(dSkuList.Select(p => p.SkuId).ToList(), "", ","); } } else if (productRequestModel.time_set_method == 1 || productRequestModel.time_set_method == 2) { List <Add.timeModel> skuModelList = JSONHelper.JsonToModel <List <Add.timeModel> >(productRequestModel.time_data); string pSkuIds = ZentCloud.Common.MyStringHelper.ListToStr(skuModelList.Select(p => p.sku_id).ToList(), "", ","); if (string.IsNullOrWhiteSpace(pSkuIds)) { pSkuIds = "0"; } List <ProductSku> dSkuList = bllMall.GetColList <ProductSku>(int.MaxValue, 1, string.Format("ProductId={0} AND SkuId Not In ({1}) ", productInfo.PID, pSkuIds), "SkuId"); if (dSkuList.Count > 0) { dSkuIds = ZentCloud.Common.MyStringHelper.ListToStr(dSkuList.Select(p => p.SkuId).ToList(), "", ","); } foreach (Add.timeModel item in skuModelList) { ProductSku nSku = (ProductSku)productSku.Clone(); if (item.sku_id != 0) { nSku = bllMall.GetByKey <ProductSku>("SkuId", item.sku_id.ToString()); } nSku.PropValueIdEx1 = item.ex1; nSku.PropValueIdEx2 = item.ex2; nSku.PropValueIdEx3 = item.ex3; nSku.Price = item.price; if (item.sku_id != 0) { updateSkuList.Add(nSku); } else { addSkuList.Add(nSku); } } } BLLTransaction tran = new BLLTransaction(); bool result = bllMall.Update(productInfo, tran); if (!result) { tran.Rollback(); apiResp.msg = "更新失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(dSkuIds)) { result = bllMall.DeleteMultByKey <ProductSku>("SkuId", dSkuIds, tran) >= 0; if (!result) { tran.Rollback(); apiResp.msg = "删除旧时间段失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } } foreach (ProductSku item in updateSkuList) { result = bllMall.Update(item, tran); if (!result) { tran.Rollback(); apiResp.msg = "修改Sku失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } } int productId = int.Parse(productInfo.PID); foreach (ProductSku item in addSkuList) { item.ProductId = productId; item.SkuId = int.Parse(bllMall.GetGUID(BLLJIMP.TransacType.AddProductSku)); result = bllMall.Add(item, tran); if (!result) { tran.Rollback(); apiResp.msg = "新增Sku失败"; apiResp.code = (int)APIErrCode.OperateFail; bllMall.ContextResponse(context, apiResp); return; } } tran.Commit(); apiResp.status = true; apiResp.msg = "更新完成"; apiResp.code = (int)APIErrCode.IsSuccess; bllMall.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { UserInfo tUser = new UserInfo(); tUser = bllUser.ConvertRequestToModel <UserInfo>(tUser); tUser.UserType = 2; tUser.RegIP = ZentCloud.Common.MySpider.GetClientIP(); tUser.Regtime = DateTime.Now; tUser.LoginTotalCount = 0; tUser.IsSubAccount = "1"; tUser.WebsiteOwner = bllUser.WebsiteOwner; tUser.LastLoginDate = DateTime.Now; if (string.IsNullOrWhiteSpace(tUser.UserID) || string.IsNullOrWhiteSpace(tUser.Password)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "账户和密码不能为空"; bllUser.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(tUser.Phone) && !ZentCloud.Common.MyRegex.PhoneNumLogicJudge(tUser.Phone)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入正确的手机号码"; bllUser.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(tUser.Phone3) && !ZentCloud.Common.MyRegex.PhoneNumLogicJudge(tUser.Phone3)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入正确的手机号码"; bllUser.ContextResponse(context, apiResp); return; } UserInfo oUser = bllUser.GetUserInfo(tUser.UserID, bllUser.WebsiteOwner); if (oUser != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "账户名已存在"; bllUser.ContextResponse(context, apiResp); return; } if (!string.IsNullOrWhiteSpace(tUser.Phone)) { oUser = bllUser.GetUserInfoByPhone(tUser.Phone, bllUser.WebsiteOwner); if (oUser != null) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "联系手机,已有账号"; bllUser.ContextResponse(context, apiResp); return; } } if (!string.IsNullOrWhiteSpace(tUser.Email) && !ZentCloud.Common.MyRegex.EmailLogicJudge(tUser.Email)) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请输入正确的邮箱地址"; bllUser.ContextResponse(context, apiResp); return; } if (!tUser.PermissionGroupID.HasValue) { apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete; apiResp.msg = "请选择角色"; bllUser.ContextResponse(context, apiResp); return; } ZentCloud.BLLPermission.Model.PermissionGroupInfo perGroup = bllUser.Get <ZentCloud.BLLPermission.Model.PermissionGroupInfo>(string.Format(" GroupID={0}", tUser.PermissionGroupID)); if (perGroup.GroupType == 4) { tUser.DistributionOwner = bllUser.WebsiteOwner; } BLLTransaction tran = new BLLTransaction(); if (!bllUser.Add(tUser, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "添加用户出错"; bllUser.ContextResponse(context, apiResp); return; } var group = new BLLPermission.Model.UserPmsGroupRelationInfo() { UserID = tUser.UserID, GroupID = tUser.PermissionGroupID.Value }; if (!bllUser.Add(group, tran))//添加权限组 { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "添加权限组出错"; bllUser.ContextResponse(context, apiResp); return; } tran.Commit(); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.msg = "添加完成"; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { int id = Convert.ToInt32(context.Request["id"]); string websiteOwner = bll.WebsiteOwner; string flow_key = context.Request["flow_key"]; string content = context.Request["content"]; BLLJIMP.Model.Flow flow = bllFlow.GetFlowByKey(flow_key, websiteOwner); if (flow == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "流程未定义"; bllFlow.ContextResponse(context, apiResp); return; } if (flow.IsDelete == 1) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = flow.FlowName + "已停用"; bllFlow.ContextResponse(context, apiResp); return; } List <BLLJIMP.Model.FlowStep> steps = bllFlow.GetStepList(2, 1, websiteOwner, flow.AutoID); if (steps.Count == 0) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = flow.FlowName + "环节未设置"; bllFlow.ContextResponse(context, apiResp); return; } UserInfo tUser = bllUser.GetUserInfoByAutoID(id, websiteOwner); if (tUser == null) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "会员未找到"; bll.ContextResponse(context, apiResp); return; } if (tUser.MemberLevel <= 0) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "该会员已经撤单"; bll.ContextResponse(context, apiResp); return; } if (bllFlow.ExistsMemberPhoneAction(websiteOwner, flow.FlowKey, "0", memberUserId: tUser.UserID)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该会员正在申请撤单"; bll.ContextResponse(context, apiResp); return; } BLLJIMP.Model.FlowStep step1 = steps[0]; BLLJIMP.Model.FlowStep step2 = null; if (steps.Count == 2) { step2 = steps[1]; } BLLJIMP.Model.FlowAction action = new BLLJIMP.Model.FlowAction(); action.CreateDate = DateTime.Now; action.CreateUserID = currentUserInfo.UserID; action.WebsiteOwner = websiteOwner; action.StartStepID = step1.AutoID; action.FlowID = flow.AutoID; action.FlowKey = flow.FlowKey; if (!string.IsNullOrWhiteSpace(content)) { action.StartContent = content; } action.MemberAutoID = tUser.AutoID; action.MemberID = tUser.UserID; action.MemberName = tUser.TrueName; action.MemberPhone = tUser.Phone; action.MemberLevel = tUser.MemberLevel; action.TrueAmount = tUser.TotalAmount; action.Amount = tUser.AccountAmountEstimate; action.DeductAmount = tUser.AccumulationFund; UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", tUser.MemberLevel.ToString()); action.MemberLevelName = levelConfig == null?"": levelConfig.LevelString; action.FlowName = flow.FlowName; if (step2 != null) { action.StepID = step2.AutoID; action.StepName = step2.StepName; } else { action.Status = 9; action.EndDate = DateTime.Now; } BLLJIMP.Model.FlowActionDetail actionDetail1 = new BLLJIMP.Model.FlowActionDetail(); actionDetail1.WebsiteOwner = websiteOwner; actionDetail1.FlowID = flow.AutoID; actionDetail1.StepID = step1.AutoID; actionDetail1.StepName = step1.StepName; actionDetail1.HandleUserID = currentUserInfo.UserID; actionDetail1.HandleDate = DateTime.Now; if (!string.IsNullOrWhiteSpace(action.StartContent)) { actionDetail1.HandleContent = action.StartContent; } BLLTransaction tran = new BLLTransaction(); if (bllUser.Update(tUser, string.Format("IsDisable=1"), string.Format("WebsiteOwner='{0}' And AutoID={1}", websiteOwner, tUser.AutoID), tran) <= 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + "冻结失败"; bllFlow.ContextResponse(context, apiResp); return; } int rId = Convert.ToInt32(bllFlow.AddReturnID(action, tran)); if (rId <= 0) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + "失败"; bllFlow.ContextResponse(context, apiResp); return; } actionDetail1.ActionID = rId; if (!bllFlow.Add(actionDetail1, tran)) { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = flow.FlowName + ",记录失败"; bllFlow.ContextResponse(context, apiResp); return; } tran.Commit(); apiResp.msg = "撤单申请提交成功"; apiResp.status = true; apiResp.code = (int)APIErrCode.IsSuccess; bllFlow.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { RequestModel requestModel = new RequestModel(); try { requestModel = JsonConvert.DeserializeObject <RequestModel>(context.Request["data"]); } catch (Exception ex) { resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = ex.Message; bllQuestion.ContextResponse(context, resp); return; } if (string.IsNullOrWhiteSpace(requestModel.questionnaire_name)) { resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete; resp.errmsg = "请输入问卷名称"; bllQuestion.ContextResponse(context, resp); return; } if (requestModel.question_list == null || requestModel.question_list.Count <= 0) { resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete; resp.errmsg = "请至少添加一个问题"; bllQuestion.ContextResponse(context, resp); return; } foreach (var item in requestModel.question_list) { if (item.question_type != 2 && (item.answer_list == null || item.answer_list.Count <= 0)) { resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete; resp.errmsg = "选择题至少需要一个选项"; bllQuestion.ContextResponse(context, resp); return; } } BLLTransaction tran = new BLLTransaction();//事务 try { Questionnaire QuestionnaireModel = new Questionnaire();//数据库问卷表模型 QuestionnaireModel.QuestionnaireID = int.Parse(bllQuestion.GetGUID(TransacType.AddQuestionnaire)); QuestionnaireModel.QuestionnaireName = requestModel.questionnaire_name; QuestionnaireModel.QuestionnaireContent = requestModel.questionnaire_content; QuestionnaireModel.QuestionnaireStopDate = requestModel.questionnaire_stopdate; QuestionnaireModel.QuestionnaireVisible = requestModel.questionnaire_visible; QuestionnaireModel.QuestionnaireImage = requestModel.questionnaire_image; QuestionnaireModel.QuestionnaireSummary = requestModel.questionnaire_summary; QuestionnaireModel.WebsiteOwner = bllQuestion.WebsiteOwner; QuestionnaireModel.InsertDate = DateTime.Now; QuestionnaireModel.AddScore = requestModel.add_score; if (!bllQuestion.Add(QuestionnaireModel, tran))//添加问卷表 { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "添加问卷失败"; bllQuestion.ContextResponse(context, resp); return; } foreach (var item in requestModel.question_list)//添加问题表 { ZentCloud.BLLJIMP.Model.Question question = new ZentCloud.BLLJIMP.Model.Question(); question.QuestionID = int.Parse(bllQuestion.GetGUID(TransacType.AddQuestion)); question.QuestionnaireID = QuestionnaireModel.QuestionnaireID; question.QuestionName = item.question_name; question.QuestionType = item.question_type; question.IsRequired = item.is_required; if (!bllQuestion.Add(question, tran)) { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "添加问题失败"; bllQuestion.ContextResponse(context, resp); return; } foreach (var AnswerItem in item.answer_list) { Answer answer = new Answer(); answer.AnswerID = int.Parse(bllQuestion.GetGUID(TransacType.AddAnswer)); answer.AnswerName = AnswerItem.answer_name; answer.IsCorrect = AnswerItem.is_correct; answer.QuestionID = question.QuestionID; answer.QuestionnaireID = QuestionnaireModel.QuestionnaireID; if (!bllQuestion.Add(answer, tran)) { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = "添加选项失败"; bllQuestion.ContextResponse(context, resp); return; } } } tran.Commit(); resp.isSuccess = true; resp.errcode = (int)APIErrCode.IsSuccess; } catch (Exception ex) { tran.Rollback(); resp.errcode = (int)APIErrCode.OperateFail; resp.errmsg = ex.Message; } bllQuestion.ContextResponse(context, resp); }
private string EditRechargeConfig(HttpContext context) { string recharge = context.Request["Recharge"]; string vipPrice = context.Request["VIPPrice"]; string sendNoticePrice = context.Request["SendNoticePrice"]; string minScore = context.Request["MinScore"]; string minWithdrawCashScore = context.Request["MinWithdrawCashScore"]; string vipPrice0 = context.Request["VIPPrice0"]; string vipDatelong = context.Request["VIPDatelong"]; string vipInterestID = context.Request["VIPInterestID"]; string vipInterestDescription = context.Request["VIPInterestDescription"]; string websiteOwner = bllkeyValueData.WebsiteOwner; KeyVauleDataInfo rechargeKeyValue = new KeyVauleDataInfo("Recharge", "100", recharge, websiteOwner, null, currentUserInfo.UserID); KeyVauleDataInfo sendNoticePriceValue = new KeyVauleDataInfo("SendNoticePrice", "1", sendNoticePrice, websiteOwner, null, currentUserInfo.UserID); KeyVauleDataInfo minScoreValue = new KeyVauleDataInfo("MinScore", "1", minScore, websiteOwner, null, currentUserInfo.UserID); KeyVauleDataInfo minWithdrawCashScoreValue = new KeyVauleDataInfo("MinWithdrawCashScore", "1", minWithdrawCashScore, websiteOwner, null, currentUserInfo.UserID); KeyVauleDataInfo VIPPriceKeyValue = new KeyVauleDataInfo("VIPPrice", "1", vipPrice, websiteOwner, null, currentUserInfo.UserID); KeyVauleDataInfo VIPPrice0KeyValue = new KeyVauleDataInfo("VIPPrice", "0", vipPrice0, websiteOwner, null, currentUserInfo.UserID); KeyVauleDataInfo VIPDatelongKeyValue = new KeyVauleDataInfo("VIPDatelong", "1", vipDatelong, websiteOwner, null, currentUserInfo.UserID); KeyVauleDataInfo VIPInterestIDKeyValue = new KeyVauleDataInfo("VIPInterestID", "1", vipInterestID, websiteOwner, null, currentUserInfo.UserID); JuActivityInfo juAct = new JuActivityInfo(); BLLJuActivity bllJuAct = new BLLJuActivity(); if (!string.IsNullOrWhiteSpace(vipInterestID) && vipInterestID != "0") { juAct = bllJuAct.GetJuActivity(Convert.ToInt32(vipInterestID)); juAct.ActivityDescription = vipInterestDescription; if (!bllJuAct.PutArticle(juAct)) { resp.Status = -1; resp.Msg = "提交VIP权益失败"; return(Common.JSONHelper.ObjectToJson(resp)); } } else if (!string.IsNullOrWhiteSpace(vipInterestDescription)) { vipInterestID = bllJuAct.GetGUID(TransacType.CommAdd); VIPInterestIDKeyValue.DataValue = vipInterestID; juAct.JuActivityID = Convert.ToInt32(vipInterestID); juAct.ActivityName = "VIP权益"; juAct.ArticleType = "ConfigContent"; juAct.UserID = currentUserInfo.UserID; juAct.WebsiteOwner = websiteOwner; juAct.CreateDate = DateTime.Now; juAct.ActivityDescription = vipInterestDescription; if (!bllJuAct.Add(juAct)) { resp.Status = -1; resp.Msg = "提交VIP权益失败"; return(Common.JSONHelper.ObjectToJson(resp)); } } BLLTransaction tran = new BLLTransaction(); if (bllkeyValueData.PutDataValue(rechargeKeyValue, tran) && bllkeyValueData.PutDataValue(sendNoticePriceValue, tran) && bllkeyValueData.PutDataValue(minScoreValue, tran) && bllkeyValueData.PutDataValue(minWithdrawCashScoreValue, tran) && bllkeyValueData.PutDataValue(VIPPriceKeyValue, tran) && bllkeyValueData.PutDataValue(VIPPrice0KeyValue, tran) && bllkeyValueData.PutDataValue(VIPDatelongKeyValue, tran) && bllkeyValueData.PutDataValue(VIPInterestIDKeyValue, tran)) { tran.Commit(); resp.Status = 1; resp.Msg = "提交成功"; } else { tran.Rollback(); resp.Status = -1; resp.Msg = "提交失败"; } return(Common.JSONHelper.ObjectToJson(resp)); }
public void ProcessRequest(HttpContext context) { int score = Convert.ToInt32(context.Request["score"]); string moduleName = "积分"; if (!string.IsNullOrWhiteSpace(context.Request["module_name"])) { moduleName = context.Request["module_name"]; } string websiteOwner = bllKeyValueData.WebsiteOwner; if (score <= 0) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = moduleName + "不能为0"; bllKeyValueData.ContextResponse(context, apiResp); return; } string rechargeValue = bllKeyValueData.GetDataVaule("Recharge", "100", websiteOwner); string minScore = bllKeyValueData.GetDataVaule("MinScore", "1", websiteOwner); string minWithdrawCashScore = bllKeyValueData.GetDataVaule("MinWithdrawCashScore", "1", websiteOwner); if (score < Convert.ToDecimal(minWithdrawCashScore)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "提现数额不能少于" + minWithdrawCashScore + moduleName; bllKeyValueData.ContextResponse(context, apiResp); return; } double curTotalScore = CurrentUserInfo.TotalScore; double sTotalScore = curTotalScore - score; double nScore = Convert.ToDouble(minScore) + score; if (sTotalScore < Convert.ToDouble(minScore)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = moduleName + "不足"; bllKeyValueData.ContextResponse(context, apiResp); return; } decimal rechargeFee = Convert.ToDecimal(rechargeValue); decimal money = rechargeFee / 100 * score; WithdrawCash model = new WithdrawCash(); model.Amount = money; model.UserId = CurrentUserInfo.UserID; model.TrueName = CurrentUserInfo.TrueName; model.WebSiteOwner = websiteOwner; model.WithdrawCashType = "ScoreOnLine"; model.TransfersType = 1; model.Status = 0; model.Score = score; model.RealAmount = money; model.ServerFee = 0; model.Phone = CurrentUserInfo.Phone; model.LastUpdateDate = DateTime.Now; model.InsertDate = DateTime.Now; model.IsPublic = 2; //积分明细 UserScoreDetailsInfo scoreModel = new UserScoreDetailsInfo(); scoreModel.AddNote = string.Format("申请提现消耗{0}{1}", score, moduleName); scoreModel.AddTime = DateTime.Now; scoreModel.Score = 0 - score; scoreModel.UserID = CurrentUserInfo.UserID; scoreModel.ScoreType = "WithdrawCash"; scoreModel.TotalScore = sTotalScore; scoreModel.WebSiteOwner = websiteOwner; //通知 BLLJIMP.Model.SystemNotice notice = new BLLJIMP.Model.SystemNotice(); notice.Ncontent = scoreModel.AddNote; notice.UserId = CurrentUserInfo.UserID; notice.Receivers = CurrentUserInfo.UserID; notice.SendType = 2; notice.SerialNum = bllKeyValueData.GetGUID(TransacType.SendSystemNotice); notice.Title = "申请提现消耗淘股币"; notice.NoticeType = 1; notice.WebsiteOwner = websiteOwner; notice.InsertTime = DateTime.Now; BLLTransaction tran = new BLLTransaction(); if (bllUser.Update(CurrentUserInfo, string.Format("TotalScore=TotalScore-{0}", score), string.Format("AutoID={0} AND WebsiteOwner='{1}' AND TotalScore>{2}", CurrentUserInfo.AutoID, websiteOwner, nScore), tran) > 0 && bllUser.Add(scoreModel, tran) && bllUser.Add(notice, tran) && bllUser.Add(model, tran)) { tran.Commit(); apiResp.code = (int)APIErrCode.IsSuccess; apiResp.msg = "申请成功"; apiResp.status = true; } else { tran.Rollback(); apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "申请失败"; } bllKeyValueData.ContextResponse(context, apiResp); }