private string GetUsers(string reqContent) { var rd = new APIResponse <UserInfoListRD>(); try { var rp = reqContent.DeserializeJSONTo <APIRequest <UserInfoListRP> >(); if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); T_UserBLL bll = new T_UserBLL(loggingSessionInfo); DataSet ds = bll.GetUserInfo(rp.CustomerID, rp.Parameters.Email, rp.Parameters.Phone, rp.Parameters.UserCode, rp.Parameters.UserName, rp.Parameters.PageIndex, rp.Parameters.PageSize); if (ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { var rdData = new UserInfoListRD(); rdData.UserInfo = DataTableToObject.ConvertToList <T_UserEntity>(ds.Tables[0]); rd.Data = rdData; rd.Message = "获取成功"; } else { rd.Message = "获取失败"; } } catch (Exception) { throw; } return(rd.ToJSON()); }
private void btnOK_Click(object sender, EventArgs e) { string oldpwd = txtOldPwd.Text; string newpwd = txtNewPwd.Text; string newpwdrep = txtNewPwdRep.Text; if (newpwd != newpwdrep) { MessageBox.Show("两次输入的新密码不相等!"); return; } T_UserBLL userBll = new T_UserBLL(); try { userBll.ChangePassword(Globals.CurrentUserId, oldpwd, newpwd); MessageBox.Show("修改成功"); Close(); } catch (Exception ex) { // ex.ToString()是包含错误信息、调用堆栈的东西 MessageBox.Show("发生错误:" + ex.Message); } }
/// <summary> /// 消息列表数据 接口 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> protected override GetInnerGroupNewsListRD ProcessRequest(DTO.Base.APIRequest <GetInnerGroupNewsListRP> pRequest) { var parameter = pRequest.Parameters; LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID); InnerGroupNewsBLL bll = new InnerGroupNewsBLL(loggingSessionInfo); var rd = new GetInnerGroupNewsListRD(); //分页查找消息列表 DateTime CreateTime = DateTime.Now; var vipinfo = new VipBLL(loggingSessionInfo).GetByID(loggingSessionInfo.CurrentUser.User_Id); if (vipinfo != null) //按照时间过滤 { CreateTime = Convert.ToDateTime(vipinfo.CreateTime); } var userinfo = new T_UserBLL(loggingSessionInfo).GetByID(loggingSessionInfo.CurrentUser.User_Id); if (userinfo != null) { CreateTime = Convert.ToDateTime(userinfo.create_time); } if (vipinfo == null && userinfo == null) { var T_SuperRetailTrader = new T_SuperRetailTraderBLL(loggingSessionInfo).GetByID(loggingSessionInfo.CurrentUser.User_Id); if (T_SuperRetailTrader != null) { CreateTime = Convert.ToDateTime(T_SuperRetailTrader.CreateTime); userinfo = new T_UserBLL(loggingSessionInfo).GetByID(T_SuperRetailTrader.SuperRetailTraderFromId); if (userinfo != null) { CreateTime = Convert.ToDateTime(userinfo.create_time); } vipinfo = new VipBLL(loggingSessionInfo).GetByID(T_SuperRetailTrader.SuperRetailTraderFromId); if (vipinfo != null) //按照时间过滤 { CreateTime = Convert.ToDateTime(vipinfo.CreateTime); } } } PagedQueryResult <InnerGroupNewsEntity> lst = bll.GetVipInnerGroupNewsList(parameter.PageIndex, parameter.PageSize, pRequest.UserID, pRequest.CustomerID, parameter.NoticePlatformTypeId, parameter.BusType, CreateTime); rd.InnerGroupNewsList = lst.Entities.Select(m => new InnerGroupNewsInfo() { Title = m.Title, IsRead = m.IsRead == "0" ? 0 : 1, BusType = m.BusType, GroupNewsId = m.GroupNewsId, MsgTime = m.CreateTime + "", Text = m.Text }).ToList(); rd.TotalCount = lst.RowCount; rd.TotalPages = lst.PageCount; return(rd); }
/// 内部消息 /// </summary> public string GetGroupNewsByID(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <GetGroupNewsByIDRP> >();//不需要参数 string userId = rp.UserID; string customerId = rp.CustomerID; if (string.IsNullOrEmpty(rp.Parameters.GroupNewsID)) { throw new APIException("缺少参数【GroupNewsID】或参数值为空") { ErrorCode = 135 }; } LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); // var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; InnerGroupNewsBLL bll = new InnerGroupNewsBLL(loggingSessionInfo); var rd = new GetGroupNewsByIDRD(); var ds = bll.GetByID(rp.Parameters.GroupNewsID); // if (ds != null && !string.IsNullOrEmpty(ds.CreateBy)) { //t_user从取创建用户 T_UserBLL bll2 = new T_UserBLL(loggingSessionInfo); //更新为已读 T_UserEntity t_user = bll2.GetByID(ds.CreateBy); if (t_user != null) { ds.CreateBy = t_user.user_name; } else { ds.CreateBy = ""; } //把该条信息设置为已经读过 NewsUserMappingBLL bll3 = new NewsUserMappingBLL(loggingSessionInfo); NewsUserMappingEntity en = new NewsUserMappingEntity(); en.UserID = rp.UserID; en.GroupNewsID = rp.Parameters.GroupNewsID; NewsUserMappingEntity[] lsen = bll3.QueryByEntity(en, null); if (lsen != null && lsen.Length != 0) { en = lsen[0]; en.HasRead = 1; bll3.Update(en, null); } } rd.InnerGroupNewsInfo = ds; var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }
/// <summary> /// 保存当前用户权限列表到Cookie /// </summary> public static void SetUserRightToCache(T_User user) { string rightKey = user.LoginName + "_right"; List <T_Rights> rightList = CacheHelp.GetCache <List <T_Rights> >(rightKey); if (rightList == null) { rightList = new T_UserBLL().GetUserRights(user); //CacheHelp.AddAbsoluteExpireCache(rightKey, rightList, 24 * 6); } }
public string DisableUser(string pRequest) { var rd = new APIResponse <DisableUserRD>(); var rdData = new DisableUserRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <DisableUserRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = new LoggingSessionManager().CurrentSession; T_UserBLL bll = new T_UserBLL(loggingSessionInfo); try { string[] staffIdArr = rp.Parameters.UserID.Split(','); T_UserEntity entity = null; for (int i = 0; i < staffIdArr.Length; i++) { entity = bll.GetByID(staffIdArr[i]); if (entity == null) { continue; } entity.user_status = "0"; entity.user_status_desc = "离职"; entity.modify_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); entity.modify_user_id = rp.UserID; bll.Update(entity); } rdData.IsSuccess = true; rd.ResultCode = 0; } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } rd.Data = rdData; return(rd.ToJSON()); }
/// <summary> /// 从Cookie中获取当前用户权限列表 /// </summary> /// <returns></returns> public static List <T_Rights> GetUserRightForCache(T_User user) { try { string rightKey = user.LoginName + "_right"; List <T_Rights> rightList = CacheHelp.GetCache <List <T_Rights> >(rightKey); if (rightList == null) { rightList = new T_UserBLL().GetUserRights(user); //CacheHelp.AddAbsoluteExpireCache(rightKey, rightList, 24 * 6); } return(rightList); } catch (Exception ex) { return(null); } }
public string QiXinManageLogin(string pRequest) { var rd = new APIResponse <QiXinManageLoginRD>(); var rdData = new QiXinManageLoginRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <QiXinManageLoginRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); T_UserBLL tubll = new T_UserBLL(loggingSessionInfo); DataSet ds = tubll.ManageUserInfo(rp.Parameters.Email); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { string pwd = ds.Tables[0].Rows[0]["UserPassword"] == null ? "" : ds.Tables[0].Rows[0]["UserPassword"].ToString(); if (pwd.ToLower() == rp.Parameters.Pwd.ToLower()) { rdData.LoginUserInfo = DataTableToObject.ConvertToObject <ManageUserInfo>(ds.Tables[0].Rows[0]); rd.ResultCode = 0; } else { rd.ResultCode = 101; rd.Message = "密码错误"; } } else { rd.ResultCode = 101; rd.Message = "管理用户不存在"; } rd.Data = rdData; return(rd.ToJSON()); }
public string SearchIMGroupCreator(string pRequest) { var rd = new APIResponse <SearchIMGroupCreatorRD>(); var rdData = new SearchIMGroupCreatorRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <SearchIMGroupCreatorRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); try { T_UserBLL bll = new T_UserBLL(loggingSessionInfo); DataTable dTbl = bll.GetIMGroupCreatorByUserName(rp.Parameters.Keyword, UserRightCode.USER_CREATE_GROUP_RIGHT_CODE); if (dTbl != null) { rdData.IMGroupCreatorList = DataTableToObject.ConvertToList <PersonDetailInfo>(dTbl); foreach (var item in rdData.IMGroupCreatorList) { item.IsIMGroupCreator = true; } } rd.ResultCode = 0; } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } rd.Data = rdData; return(rd.ToJSON()); }
public string DelUser(string pRequest) { var rd = new APIResponse <DelUserRD>(); var rdData = new DelUserRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <DelUserRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = new LoggingSessionManager().CurrentSession; T_UserBLL bll = new T_UserBLL(loggingSessionInfo); try { T_UserEntity entity = bll.GetByID(rp.Parameters.UserID); entity.user_status = "-1"; entity.user_status_desc = "已删除"; entity.modify_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); entity.modify_user_id = rp.UserID; bll.Update(entity); rdData.IsSuccess = true; rd.ResultCode = 0; } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } rd.Data = rdData; return(rd.ToJSON()); }
private void btnLogin_Click(object sender, EventArgs e) { string userName = this.txtUserName.Text; string userPwd = this.txtPwd.Text; //string userType = this.cboUserType.Text; if (userName == "") { MessageBox.Show("用户名不能为空"); } else if (userPwd == "") { MessageBox.Show("用户密码不能为空"); } //else if (userType == "") //{ // MessageBox.Show("请输入用户类型"); //} else if (new T_UserBLL().ValidateUser(txtUserName.Text, txtPwd.Text))// && this.cboUserType.Text == "一般用户") { T_User user = new T_UserBLL().GetByUserName(userName); Globals.CurrentUserId = user.Id; //Close(); //MessageBox.Show("OK"); DialogResult = DialogResult.OK; } else { //DialogResult = DialogResult.Cancel; MessageBox.Show("输入信息有误"); } //if (txtUserName.Text == "admin" && txtPwd.Text == "888888") //{ // FormMain fm = new FormMain(); // //fm.Show(); // fm.ShowDialog(); //} }
public string GetUserDict(string pRequest) { var rd = new APIResponse <GetUserDictRD>(); var rdData = new GetUserDictRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <GetUserDictRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = new LoggingSessionManager().CurrentSession; try { T_UserBLL userBll = new T_UserBLL(loggingSessionInfo); DataTable dTable = userBll.GetStaffDict(rp.Parameters.UserID, rp.Parameters.UserName.Trim()); if (dTable != null) { rdData.UserList = DataTableToObject.ConvertToList <UserDict>(dTable); } rd.Data = rdData; rd.ResultCode = 0; } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } return(rd.ToJSON()); }
/// <summary> /// 门店内员工排名 /// 排名规则: /// 1.取出打赏金额大于零的员工 /// 2.比较打赏金额,(金额高的往前排) /// 3.金额相同,比较评价等级 (等级高的往前排) /// 4.如果还相同,比较打赏时间(时间靠前,往前排) /// </summary> /// <param name="pRequest"></param> /// <returns></returns> protected override GetTopRewardListRD ProcessRequest(DTO.Base.APIRequest <GetTopRewardListRP> pRequest) { var rd = new GetTopRewardListRD(); var customerId = CurrentUserInfo.ClientID; var trrBll = new T_RewardRecordBLL(CurrentUserInfo); var userBll = new T_UserBLL(CurrentUserInfo); //获取员工列表(门店内) var userList = userBll.QueryByEntity(new T_UserEntity() { customer_id = customerId }, null); var userService = new cUserService(CurrentUserInfo); CurrentUserInfo.CurrentUserRole.UnitId = string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId) ? "" : CurrentUserInfo.CurrentUserRole.UnitId; var para_unit_id = CurrentUserInfo.CurrentUserRole.UnitId; var maxRowCount = Utils.GetIntVal(Request("limit")); var startRowIndex = Utils.GetIntVal(Request("start")); var rowCount = maxRowCount > 0 ? maxRowCount : 999; //每页行数 var startIndex = startRowIndex > 0 ? startRowIndex : 0; //当前页的起始行数 var userdata = new JIT.CPOS.BS.Entity.User.UserInfo(); if (string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId)) { userdata = userService.SearchUserListByUnitID(string.Empty, string.Empty, string.Empty, string.Empty, rowCount, startIndex, CurrentUserInfo.CurrentUserRole.UnitId, para_unit_id, string.Empty, string.Empty); } else { userdata = userService.SearchUserListByUnitID(string.Empty, string.Empty, string.Empty, string.Empty, rowCount, startIndex, CurrentUserInfo.CurrentUserRole.UnitId, para_unit_id, string.Empty, string.Empty); } var orderBys = new OrderBy[1]; orderBys[0] = new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Asc }; var trrList = trrBll.QueryByEntity(new T_RewardRecordEntity() { PayStatus = 2, CustomerId = customerId }, orderBys); var oeBll = new ObjectEvaluationBLL(CurrentUserInfo); var oeList = oeBll.QueryByEntity(new ObjectEvaluationEntity() { Type = 4, CustomerID = customerId }, null); var allOE = (from p in oeList.AsEnumerable() group p by p.ObjectID into g select new { g.Key, SumValue = g.Average(p => p.StarLevel) }); var allRewards = (from p in trrList.AsEnumerable() group p by p.RewardedOP into g select new { g.Key, SumValue = g.Sum(p => p.RewardAmount) }).Where(g => g.SumValue > 0).OrderByDescending(g => g.SumValue); var rewardCount = allRewards.ToList().Count; //var top10Rewards = allRewards.Take(10); //金额相同,比较评价等级 (等级高的往前排) rd.RewardList = new List <RewardInfo>(); rd.MyReward = new RewardInfo(); var index = 1; foreach (var item in allRewards) { var tmpRewardInfo = new RewardInfo(); //var userinfo = userList.Where(t => t.user_id == item.Key).ToArray().FirstOrDefault(); var userinfo = userdata.UserInfoList.Where(t => t.User_Id == item.Key).ToArray().FirstOrDefault(); var oeinfo = allOE.Where(t => t.Key == item.Key).ToArray().FirstOrDefault(); if (userinfo != null) { tmpRewardInfo = new RewardInfo() { UserID = userinfo.User_Id, UserName = userinfo.User_Name, UserPhoto = userinfo.imageUrl, StarLevel = oeinfo != null?Convert.ToInt32(oeinfo.SumValue) : 0, Rank = index, RewardIncome = item.SumValue }; rd.RewardList.Add(tmpRewardInfo); if (userinfo.User_Id == pRequest.UserID) { rd.MyReward = tmpRewardInfo; } index++; } } if (string.IsNullOrEmpty(rd.MyReward.UserID))//Top10之外 { //var userinfo = userList.Where(t => t.user_id == pRequest.UserID).ToArray().FirstOrDefault(); var userinfo = userdata.UserInfoList.Where(t => t.User_Id == pRequest.UserID).ToArray().FirstOrDefault(); var oeinfo = allOE.Where(t => t.Key == pRequest.UserID).ToArray().FirstOrDefault(); var myReward = allRewards.Where(t => t.Key == pRequest.UserID).FirstOrDefault(); decimal?myRewardIncome = 0; if (myReward != null) { myRewardIncome = myReward.SumValue != null ? myReward.SumValue : 0; rewardCount = allRewards.Where(g => g.SumValue > myReward.SumValue).ToList().Count; } var myStarLevel = oeinfo != null?Convert.ToInt32(oeinfo.SumValue) : 0; if (userinfo != null) { rd.MyReward = new RewardInfo() { UserID = userinfo.User_Id, UserName = userinfo.User_Name, UserPhoto = userinfo.imageUrl, StarLevel = myStarLevel, Rank = myRewardIncome > 0 ? rewardCount + 1 : 0, RewardIncome = myRewardIncome }; } } return(rd); }
public string AddUser(string pRequest) { var rd = new APIResponse <AddUserRD>(); var rdData = new AddUserRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <AddUserRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); T_UserBLL bll = new T_UserBLL(loggingSessionInfo); try { string email = rp.Parameters.UserEmail, customerID = rp.CustomerID; T_UserEntity tue = new T_UserEntity(); tue = bll.GetUserEntityByEmail(rp.Parameters.UserEmail, customerID); if (tue == null) { DateTime dt = DateTime.Now; #region 保存用户 string userId = Guid.NewGuid().ToString().Replace("-", "").ToUpper(); tue = new T_UserEntity() { user_id = userId, user_code = rp.Parameters.UserCode, user_name = rp.Parameters.UserName, user_name_en = rp.Parameters.UserNameEn, user_email = rp.Parameters.UserEmail, user_password = MD5Helper.Encryption("123"),//默认密码 user_gender = rp.Parameters.UserGender, user_birthday = rp.Parameters.UserBirthday, user_telephone = rp.Parameters.UserTelephone, user_cellphone = rp.Parameters.UserCellphone, user_status = "1", user_status_desc = "正常", fail_date = string.IsNullOrEmpty(rp.Parameters.FailDate) == true ? "2020-01-01" : rp.Parameters.FailDate, customer_id = customerID, create_time = dt.ToString("yyyy-MM-dd HH:mm:ss"), create_user_id = rp.UserID, modify_time = dt.ToString("yyyy-MM-dd HH:mm:ss"), modify_user_id = rp.UserID }; //T_User表 //Create(tue, tran); bll.Create(tue); #endregion #region 保存用户角色 //T_User_Role 表 TUserRoleEntity ture = new TUserRoleEntity { user_role_id = Guid.NewGuid().ToString(), user_id = userId, role_id = rp.Parameters.RoleID, unit_id = rp.Parameters.UnitID, status = "1", create_time = dt, create_user_id = rp.UserID, modify_time = dt, modify_user_id = rp.UserID, default_flag = "1" }; bll.InsertUserRole(ture); #endregion #region 保存部门、职衔 UserDeptJobMappingBLL deptJobMapBll = new UserDeptJobMappingBLL(loggingSessionInfo); //UserDeptJobMapping表 UserDeptJobMappingEntity udjme = new UserDeptJobMappingEntity { UserDeptID = Guid.NewGuid(), UserID = userId, JobFunctionID = rp.Parameters.JobFunctionID, USERID = userId, CustomerID = customerID, CreateTime = dt, CreateUserID = rp.UserID, LastUpdateTime = dt, LastUpdateUserID = rp.UserID, IsDelete = 0, UnitID = rp.Parameters.UnitID, LineManagerID = rp.Parameters.LineManagerID, UserLevel = "0"//默认0 }; deptJobMapBll.Create(udjme); #endregion rdData.UserID = userId; rd.ResultCode = 0; } else { rd.ResultCode = 101; rd.Message = "邮箱已存在"; } rd.Data = rdData; } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } return(rd.ToJSON()); }
public string ExportData(string pCustomerID, LoggingSessionInfo pLoggingSessionInfo, DataTable pExportData, JobFunctionEntity[] pJobFuncE, TUnitEntity[] pDeptE, IList <RoleModel> pRoleE) { T_UserBLL tubll = new T_UserBLL(pLoggingSessionInfo); UserDeptJobMappingBLL deptJobMapBll = new UserDeptJobMappingBLL(pLoggingSessionInfo); //客户id string customerID = pCustomerID; //var tran = this.SQLHelper.CreateTransaction(); //using (tran.Connection) //{ try { string createUserID = pLoggingSessionInfo.CurrentUser.User_Id; string lastUpdateUserID = pLoggingSessionInfo.CurrentUser.User_Id; DateTime dt = DateTime.Now; int existsEmaliNum = 0, notExistsEmailNum = 0; string email = string.Empty; if (pExportData != null && pExportData.Rows.Count > 0) { DataTable dTable = pExportData; T_UserEntity tue = null; foreach (DataRow row in dTable.Rows) { dt = DateTime.Now; //检测邮箱是否存在 if (row["邮箱"] == null || string.IsNullOrEmpty(row["邮箱"].ToString())) { continue; } email = row["邮箱"].ToString().Trim().ToLower(); tue = tubll.GetUserEntityByEmail(email, customerID); if (tue != null) { //存在 existsEmaliNum++; continue; } else { //不存在 notExistsEmailNum++; #region 保存用户 tue = new T_UserEntity(); string userId = Guid.NewGuid().ToString().Replace("-", "").ToUpper(); tue.user_id = userId; if (email != null && !string.IsNullOrEmpty(email)) { tue.user_email = email; } tue.user_name = row["用户名称"].ToString(); tue.user_name_en = row["英文名"].ToString(); if (row["性别"] != null && !string.IsNullOrEmpty(row["性别"].ToString())) { if (row["性别"].ToString().Trim() == "男") { tue.user_gender = "1"; } else if (row["性别"].ToString().Trim() == "女") { tue.user_gender = "2"; } else { tue.user_gender = "0"; //未知 } } else { tue.user_gender = "0"; } if (row["生日"] != null && !string.IsNullOrEmpty(row["生日"].ToString())) { tue.user_birthday = Convert.ToDateTime(row["生日"]).ToString("yyyy-MM-dd"); } if (row["手机"] != null && !string.IsNullOrEmpty(row["手机"].ToString())) { tue.user_telephone = row["手机"].ToString(); } if (row["固话"] != null && !string.IsNullOrEmpty(row["固话"].ToString())) { tue.user_cellphone = row["固话"].ToString(); } if (row["用户编码"] != null && !string.IsNullOrEmpty(row["用户编码"].ToString())) { tue.user_code = row["用户编码"].ToString(); } tue.user_status = "1"; tue.user_status_desc = "正常"; tue.fail_date = "2020-01-02"; tue.user_address = ""; tue.user_password = MD5Helper.Encryption("123");//默认密码 tue.customer_id = customerID; tue.create_user_id = tue.modify_user_id = createUserID; tue.create_time = tue.modify_time = dt.ToString("yyyy-MM-dd HH:mm:ss"); tue.msn = ""; tue.qq = ""; tue.blog = ""; tue.user_postcode = ""; tue.user_remark = ""; //T_User表 //Create(tue, tran); tubll.Create(tue); #endregion #region 保存用户角色 //T_User_Role 表 string deptID = pDeptE.Where(a => a.UnitName == row["部门"].ToString().Trim()).First().UnitID.ToString(); RoleModel rm = pRoleE.Where(a => a.Role_Name == row["角色"].ToString().Trim()).First(); TUserRoleEntity ture = new TUserRoleEntity { user_role_id = Guid.NewGuid().ToString(), user_id = userId, role_id = rm.Role_Id, unit_id = deptID, status = "1", create_time = dt, create_user_id = createUserID, modify_time = dt, modify_user_id = lastUpdateUserID, default_flag = "1" }; tubll.InsertUserRole(ture); #endregion #region 保存部门、职衔 //UserDeptJobMapping表 string jobFuncID = pJobFuncE.Where(a => a.Name == row["职衔"].ToString().Trim()).First().JobFunctionID.ToString(); UserDeptJobMappingEntity udjme = new UserDeptJobMappingEntity { UserDeptID = Guid.NewGuid(), UserID = userId, JobFunctionID = jobFuncID, USERID = userId, CustomerID = customerID, CreateTime = dt, CreateUserID = createUserID, LastUpdateTime = dt, LastUpdateUserID = lastUpdateUserID, IsDelete = 0, UnitID = deptID }; deptJobMapBll.Create(udjme); #endregion } } Loggers.DEFAULT.Debug(new DebugLogInfo() { Message = "重复:" + existsEmaliNum + "条,新增:" + notExistsEmailNum + "条,共:" + dTable.Rows.Count }); } //tran.Commit(); } catch (Exception ex) { //回滚&转抛异常 //tran.Rollback(); throw; } return("1|成功"); //} }
public string ModifyUserPersonalInfo(string pRequest) { var rd = new APIResponse <ModifyUserPersonalInfoRD>(); var rdData = new ModifyUserPersonalInfoRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <ModifyUserPersonalInfoRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); try { T_UserBLL bll = new T_UserBLL(loggingSessionInfo); T_UserEntity entity = bll.GetUserEntityByID(rp.Parameters.UserID); if (entity != null) { entity.user_code = rp.Parameters.UserCode; entity.user_name = rp.Parameters.UserName; entity.user_gender = rp.Parameters.UserGender; entity.user_email = rp.Parameters.UserEmail; entity.user_telephone = rp.Parameters.UserTelephone; entity.user_status = rp.Parameters.UserStatus; if (!string.IsNullOrEmpty(rp.Parameters.UserNameEn)) { entity.user_name_en = rp.Parameters.UserNameEn; } if (!string.IsNullOrEmpty(rp.Parameters.UserBirthday)) { entity.user_birthday = rp.Parameters.UserBirthday; } if (!string.IsNullOrEmpty(rp.Parameters.UserPassword)) { entity.user_password = rp.Parameters.UserPassword; } if (!string.IsNullOrEmpty(rp.Parameters.UserCellphone)) { entity.user_cellphone = rp.Parameters.UserCellphone; } if (!string.IsNullOrEmpty(rp.Parameters.FailDate)) { entity.fail_date = rp.Parameters.FailDate; } bll.Update(entity); //更新LineManagerID UserDeptJobMappingBLL mappingBll = new UserDeptJobMappingBLL(loggingSessionInfo); UserDeptJobMappingEntity mappingEntity = mappingBll.GetByUserID(entity.user_id); if (mappingEntity != null) { mappingEntity.LineManagerID = rp.Parameters.LineManagerID; mappingBll.Update(mappingEntity); } rdData.IsSuccess = true; rd.ResultCode = 0; } else { rdData.IsSuccess = false; rd.ResultCode = 101; rd.Message = "用户不存在"; } } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } rd.Data = rdData; return(rd.ToJSON()); }
/// <summary> /// 消息详情展示{业务:查看详情信息并且标识为已读账户} /// </summary> /// <param name="pRequest"></param> /// <returns></returns> protected override GetInnerGroupNewsByIdRD ProcessRequest(DTO.Base.APIRequest <GetInnerGroupNewsByIdRP> pRequest) { #region 设置参数 var parameter = pRequest.Parameters; var rd = new GetInnerGroupNewsByIdRD(); //返回数据 LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID); InnerGroupNewsBLL bll = new InnerGroupNewsBLL(loggingSessionInfo); NewsUserMappingBLL newsusermappingService = new NewsUserMappingBLL(loggingSessionInfo); #endregion //分页查找消息列表 DateTime CreateTime = DateTime.Now; var vipinfo = new VipBLL(loggingSessionInfo).GetByID(loggingSessionInfo.CurrentUser.User_Id); if (vipinfo != null) //按照时间过滤 { CreateTime = Convert.ToDateTime(vipinfo.CreateTime); } var userinfo = new T_UserBLL(loggingSessionInfo).GetByID(loggingSessionInfo.CurrentUser.User_Id); if (userinfo != null) { CreateTime = Convert.ToDateTime(userinfo.create_time); } if (vipinfo == null && userinfo == null) { var T_SuperRetailTrader = new T_SuperRetailTraderBLL(loggingSessionInfo).GetByID(loggingSessionInfo.CurrentUser.User_Id); if (T_SuperRetailTrader != null) { userinfo = new T_UserBLL(loggingSessionInfo).GetByID(T_SuperRetailTrader.SuperRetailTraderFromId); if (userinfo != null) { CreateTime = Convert.ToDateTime(userinfo.create_time); } else { vipinfo = new VipBLL(loggingSessionInfo).GetByID(T_SuperRetailTrader.SuperRetailTraderFromId); if (vipinfo != null) //按照时间过滤 { CreateTime = Convert.ToDateTime(vipinfo.CreateTime); } } } } var model = bll.GetVipInnerGroupNewsDetailsByPaging(parameter.Operationtype, pRequest.CustomerID, parameter.NoticePlatformTypeId, parameter.GroupNewsID, CreateTime); if (model == null || String.IsNullOrEmpty(model.GroupNewsId)) { if (parameter.Operationtype == 1) //0=当前消息 1=下一条消息 2=上一条消息 { throw new APIException("已经是最后一条消息啦。") { ErrorCode = 135 }; } else if (parameter.Operationtype == 2) { throw new APIException("已经是第一条消息啦。") { ErrorCode = 135 }; } } List <IWhereCondition> lstWhereCondition = new List <IWhereCondition>(); lstWhereCondition.Add(new EqualsCondition() { FieldName = "CustomerID", Value = pRequest.CustomerID }); lstWhereCondition.Add(new EqualsCondition() { FieldName = "NoticePlatformType", Value = parameter.NoticePlatformTypeId }); lstWhereCondition.Add(new EqualsCondition() { FieldName = "IsDelete", Value = "0" }); lstWhereCondition.Add(new DirectCondition() { Expression = "BusType <> 3 " }); lstWhereCondition.Add(new DirectCondition() { Expression = "CreateTime>='" + CreateTime + "'" }); var MessageList = bll.PagedQuery(lstWhereCondition.ToArray(), null, 1, 1); //分页获取数据 rd.TotalPageCount = MessageList.RowCount; //获取总数据 if (model != null) { //获取上一条数据 或者下一条 数据 rd.NewsInfo = new InnerGroupNewsInfo() { Title = model.Title, Text = model.Text, CreateTime = model.CreateTime, GroupNewsId = model.GroupNewsId }; bool IsRead = bll.CheckUserIsReadMessage(pRequest.UserID, pRequest.CustomerID, rd.NewsInfo.GroupNewsId); if (IsRead) { NewsUserMappingEntity _model = new NewsUserMappingEntity() { CustomerId = pRequest.CustomerID, UserID = pRequest.UserID, GroupNewsID = rd.NewsInfo.GroupNewsId, HasRead = 1, IsDelete = 0 }; _model.GroupNewsID = rd.NewsInfo.GroupNewsId; newsusermappingService.Create(_model); } if (parameter.Operationtype == 1) //0=当前消息 1=下一条消息 2=上一条消息 { rd.PageIndex = -(model.PageIndex - rd.TotalPageCount) + 1; } else if (parameter.Operationtype == 2 || parameter.Operationtype == 0) { rd.PageIndex = model.PageIndex; } } return(rd); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetSalesReturnRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var salesReturnBLL = new T_SalesReturnBLL(CurrentUserInfo); var historyBLL = new T_SalesReturnHistoryBLL(CurrentUserInfo); var pTran = salesReturnBLL.GetTran();//事务 T_SalesReturnEntity salesReturnEntity = null; T_SalesReturnHistoryEntity historyEntity = null; var vipBll = new VipBLL(CurrentUserInfo); //会员BLL实例化 var userBll = new T_UserBLL(CurrentUserInfo); //店员BLL实例化 VipEntity vipEntity = null; //会员信息 T_UserEntity userEntity = null; //店员信息 using (pTran.Connection) { try { switch (para.OperationType) { case 1: //申请 salesReturnEntity = new T_SalesReturnEntity(); salesReturnEntity.SalesReturnNo = DateTime.Now.ToString("yyyyMMddHHmmssfff"); salesReturnEntity.VipID = CurrentUserInfo.UserID; salesReturnEntity.ServicesType = para.ServicesType; salesReturnEntity.DeliveryType = para.DeliveryType; salesReturnEntity.OrderID = para.OrderID; salesReturnEntity.ItemID = para.ItemID; salesReturnEntity.SkuID = para.SkuID; salesReturnEntity.Qty = para.Qty; salesReturnEntity.ActualQty = para.Qty; salesReturnEntity.UnitID = para.UnitID; salesReturnEntity.UnitName = para.UnitName; salesReturnEntity.UnitTel = para.UnitTel; salesReturnEntity.Address = para.Address; salesReturnEntity.Contacts = para.Contacts; salesReturnEntity.Phone = para.Phone; salesReturnEntity.Reason = para.Reason; salesReturnEntity.Status = 1; //待审核 salesReturnEntity.CustomerID = CurrentUserInfo.ClientID; salesReturnBLL.Create(salesReturnEntity, pTran); vipEntity = vipBll.GetByID(CurrentUserInfo.UserID); historyEntity = new T_SalesReturnHistoryEntity() { SalesReturnID = salesReturnEntity.SalesReturnID, OperationType = 1, OperationDesc = "申请", OperatorID = CurrentUserInfo.UserID, HisRemark = "申请", OperatorName = vipEntity.VipName, OperatorType = 0 }; historyBLL.Create(historyEntity, pTran); break; case 2: //取消 salesReturnEntity = salesReturnBLL.GetByID(para.SalesReturnID); vipEntity = vipBll.GetByID(CurrentUserInfo.UserID); if (salesReturnEntity != null) { salesReturnEntity.Status = 2; //取消申请 salesReturnBLL.Update(salesReturnEntity, pTran); historyEntity = new T_SalesReturnHistoryEntity() { SalesReturnID = salesReturnEntity.SalesReturnID, OperationType = 2, OperationDesc = "取消申请", OperatorID = CurrentUserInfo.UserID, HisRemark = "取消申请", OperatorName = vipEntity.VipName, OperatorType = 0 }; historyBLL.Create(historyEntity, pTran); } break; default: break; } pTran.Commit(); //提交事物 } catch (Exception ex) { pTran.Rollback();//回滚事务 throw new APIException(ex.Message); } } return(rd); }
/// <summary> /// api获取当前门店核销过的电子券 /// </summary> protected override GetApiCouponUserListRD ProcessRequest(DTO.Base.APIRequest <GetCouponUseRP> pRequest) { var rd = new GetApiCouponUserListRD(); var para = pRequest.Parameters; var CouponUseBLL = new CouponUseBLL(CurrentUserInfo); var VipBLL = new VipBLL(CurrentUserInfo); var CouponBLL = new CouponBLL(CurrentUserInfo); var UserBLL = new T_UserBLL(CurrentUserInfo); //查询参数 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; #region 门店条件处理 string UnitId = ""; if (CurrentUserInfo.CurrentUserRole != null) { if (!string.IsNullOrWhiteSpace(CurrentUserInfo.CurrentUserRole.UnitId)) { UnitId = CurrentUserInfo.CurrentUserRole.UnitId; } } if (!string.IsNullOrWhiteSpace(UnitId)) { complexCondition.Add(new EqualsCondition() { FieldName = "UnitID", Value = CurrentUserInfo.CurrentUserRole.UnitId }); } else { return(rd); } #endregion //排序参数 List <OrderBy> lstOrder = new List <OrderBy> { }; lstOrder.Add(new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc }); var Result = CouponUseBLL.PagedQuery(complexCondition.ToArray(), lstOrder.ToArray(), para.pageSize, para.pageIndex); rd.TotalPageCount = Result.PageCount; rd.TotalCount = Result.RowCount; rd.ApiCouponDataList = Result.Entities.Select(t => new CouponUserData() { VipID = t.VipID, VipName = "", CreateTime = t.CreateTime.ToString(), CouponID = t.CouponID, CouponName = "", CouponCode = "", CreateBy = t.CreateBy }).ToList(); foreach (var item in rd.ApiCouponDataList) { //会员名称 var VipData = VipBLL.GetByID(item.VipID); if (VipData != null) { item.VipName = VipData.VipName ?? ""; item.HeadImgUrl = VipData.HeadImgUrl ?? ""; } //券名称,券号 var CouponData = CouponBLL.GetByID(item.CouponID); if (CouponData != null) { item.CouponName = CouponData.CouponName ?? ""; item.CouponCode = CouponData.CouponCode ?? ""; } //员工名称 var UserData = UserBLL.GetByID(item.CreateBy); if (UserData != null) { item.CreateByName = UserData.user_name ?? ""; } } return(rd); }
public string GetUserList(string pRequest) { var rd = new APIResponse <GetUserRD>(); var rdData = new GetUserRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <GetUserRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = new LoggingSessionManager().CurrentSession; try { //获取普通员工employee角色标识 string roleId = string.Empty; var appSysService = new AppSysService(loggingSessionInfo); RoleModel list = new RoleModel(); string key = "D8C5FF6041AA4EA19D83F924DBF56F93"; list = appSysService.GetRolesByAppSysId(key, 1000, 0, "", "", ""); foreach (var item in list.RoleInfoList) { if (item.Role_Code.ToLower() == "employee") { roleId = item.Role_Id; break; } } if (string.IsNullOrEmpty(roleId) || roleId == "") { throw new APIException("employee的roleId未获取到") { ErrorCode = 103 } } ; T_UserBLL userBll = new T_UserBLL(loggingSessionInfo); //string typeID = System.Configuration.ConfigurationManager.AppSettings["TypeID"].ToString(); int totalPage = 0; QueryUserEntity entity = new QueryUserEntity(); entity.QUserName = rp.Parameters.Keyword; entity.QUnitID = rp.Parameters.UnitID; entity.QJobFunctionID = rp.Parameters.JobFunctionID; entity.QRoleID = roleId; DataTable dTable = userBll.GetUserList(rp.Parameters.UserID, rp.Parameters.PageIndex, rp.Parameters.PageSize, out totalPage, entity); //排序 DataView dv = dTable.DefaultView; string sort = string.IsNullOrEmpty(rp.Parameters.sort) ? "UserEmail asc" : rp.Parameters.sort; sort = "UserStatus desc," + sort; dv.Sort = sort; DataTable dt2 = dv.ToTable(); dTable = dt2; if (dTable != null) { rdData.UserList = DataTableToObject.ConvertToList <UserInfo>(dTable); } rdData.TotalPage = totalPage; rd.Data = rdData; rd.ResultCode = 0; } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } return(rd.ToJSON()); }
public string ExportStaff(string pRequest) { var rd = new APIResponse <ExportStaffRD>(); var rdData = new ExportStaffRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <ExportStaffRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = new LoggingSessionManager().CurrentSession; try { //获取普通员工employee角色标识 string roleId = string.Empty; var appSysService = new AppSysService(loggingSessionInfo); RoleModel list = new RoleModel(); string key = "D8C5FF6041AA4EA19D83F924DBF56F93"; list = appSysService.GetRolesByAppSysId(key, 1000, 0, "", "", ""); foreach (var item in list.RoleInfoList) { if (item.Role_Code.ToLower() == "employee") { roleId = item.Role_Id; break; } } if (string.IsNullOrEmpty(roleId) || roleId == "") { throw new APIException("employee的roleId未获取到") { ErrorCode = 103 } } ; rp.Parameters.ExportType = rp.Parameters.ExportType.ToLower(); //所有页 if (rp.Parameters.ExportType == "allpage") { rp.Parameters.PageIndex = 0; rp.Parameters.PageSize = 5000; } //数据获取 T_UserBLL userBll = new T_UserBLL(loggingSessionInfo); int totalPage = 0; QueryUserEntity entity = new QueryUserEntity(); entity.QUserName = rp.Parameters.Keyword; entity.QUnitID = rp.Parameters.UnitID; entity.QJobFunctionID = rp.Parameters.JobFunctionID; entity.QRoleID = roleId; DataTable dTable = userBll.GetUserList(rp.Parameters.UserID, rp.Parameters.PageIndex, rp.Parameters.PageSize, out totalPage, entity); //过滤选择的员工 if (rp.Parameters.ExportType == "select") { string[] ids = rp.Parameters.StaffIds.Split(','); string strIds = "'',"; for (int i = 0; i < ids.Length; i++) { strIds += "'" + ids[i] + "',"; } strIds = strIds.Substring(0, strIds.Length - 1); DataRow[] drs = dTable.Select("UserID in (" + strIds + ")"); DataTable d = dTable.Clone(); foreach (var item in drs) { d.ImportRow(item); } dTable = d; } else if (rp.Parameters.ExportType == "noselect") { dTable = dTable.Clone(); } //排序 DataView dv = dTable.DefaultView; string sort = string.IsNullOrEmpty(rp.Parameters.sort) ? "UserEmail asc" : rp.Parameters.sort; sort = "UserStatus desc," + sort; dv.Sort = sort; DataTable dt2 = dv.ToTable(); dTable = dt2; //表格标题设置 DataTable lastTable = dTable.DefaultView.ToTable(false, "UserCode", "UserName", "UserNameEn", "UserEmail", "UserGenderT", "UserBirthday", "UserTelephone", "UserCellphone", "DeptName", "JobFuncName", "UserStatusDesc"); //重置标题名称 lastTable.Columns["UserCode"].ColumnName = "用户编码"; lastTable.Columns["UserName"].ColumnName = "姓名"; lastTable.Columns["UserNameEn"].ColumnName = "英文名"; lastTable.Columns["UserEmail"].ColumnName = "邮箱"; lastTable.Columns["UserGenderT"].ColumnName = "性别"; lastTable.Columns["UserBirthday"].ColumnName = "生日"; lastTable.Columns["UserTelephone"].ColumnName = "手机"; lastTable.Columns["UserCellphone"].ColumnName = "电话"; lastTable.Columns["DeptName"].ColumnName = "部门"; lastTable.Columns["JobFuncName"].ColumnName = "职务"; lastTable.Columns["UserStatusDesc"].ColumnName = "状态"; //数据获取 Workbook wb = DataTableExporter.WriteXLS(lastTable, 0); string savePath = HttpContext.Current.Server.MapPath(@"~/File/Excel"); if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } savePath = savePath + "\\企信员工-" + lastTable.TableName + ".xls"; wb.Save(savePath);//保存Excel文件 new ExcelCommon().OutPutExcel(HttpContext.Current, savePath); HttpContext.Current.Response.End(); rd.ResultCode = 0; } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } return(rd.ToJSON()); }
public string GetPersonDetailInfo(string pRequest) { var rd = new APIResponse <GetPersonDetailInfoRD>(); var rdData = new GetPersonDetailInfoRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <GetPersonDetailInfoRP> >(); if (rp.Parameters == null) { throw new ArgumentException(); } if (rp.Parameters != null) { rp.Parameters.Validate(); } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); try { T_UserBLL bll = new T_UserBLL(loggingSessionInfo); T_UserEntity entity = bll.GetUserEntityByID(rp.Parameters.UserID); PersonDetailInfo detail = null; if (entity != null) { //用户信息 detail = new PersonDetailInfo { UserID = entity.user_id, UserCode = entity.user_code, UserName = entity.user_name, UserGender = entity.user_gender, UserBirthday = entity.user_birthday, UserEmail = entity.user_email, UserCellphone = entity.user_telephone, UserTelephone = entity.user_telephone }; //获取UnitID,UnitName UserDeptJobMappingBLL mappingBll = new UserDeptJobMappingBLL(loggingSessionInfo); UserDeptJobMappingEntity mappingEntity = mappingBll.GetByUserID(entity.user_id); if (mappingEntity != null) { detail.UnitID = mappingEntity.UnitID; TUnitBLL unitBll = new TUnitBLL(loggingSessionInfo); TUnitEntity unitEntity = unitBll.GetByID(mappingEntity.UnitID); if (unitEntity != null) { detail.UnitName = unitEntity.UnitName; } } //获取是否有建群权限 detail.IsIMGroupCreator = bll.IsHasPower(entity.user_id, UserRightCode.USER_CREATE_GROUP_RIGHT_CODE); } rdData.DetailInfo = detail; rd.ResultCode = 0; } catch (Exception ex) { rd.ResultCode = 103; rd.Message = ex.Message; } rd.Data = rdData; return(rd.ToJSON()); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <GetRefundOrderDetailRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var salesReturnBLL = new T_SalesReturnBLL(loggingSessionInfo); var historyBLL = new T_SalesReturnHistoryBLL(loggingSessionInfo); var refundOrderBLL = new T_RefundOrderBLL(loggingSessionInfo); var vipAmountBLL = new VipAmountBLL(loggingSessionInfo); //余额返现BLL实例化 var vipAmountDetailBLL = new VipAmountDetailBLL(loggingSessionInfo); //余额返现BLL实例化 var pTran = salesReturnBLL.GetTran();//事务 T_SalesReturnEntity salesReturnEntity = null; T_SalesReturnHistoryEntity historyEntity = null; T_RefundOrderEntity refundEntity = null; var vipBll = new VipBLL(loggingSessionInfo); //会员BLL实例化 var userBll = new T_UserBLL(loggingSessionInfo); //店员BLL实例化 T_UserEntity userEntity = null; //店员信息 var unitBLL = new t_unitBLL(loggingSessionInfo); refundEntity = refundOrderBLL.GetByID(para.RefundID); userEntity = userBll.GetByID(loggingSessionInfo.UserID); using (pTran.Connection) { try { if (refundEntity != null) { //获取会员信息 var vipInfo = vipBll.GetByID(refundEntity.VipID); //获取会员的会员上线 VipEntity userInfo = vipBll.GetByID(vipInfo.HigherVipID); if (userInfo == null) { //获取会员的员工上线 var tempUser = userBll.GetByID(vipInfo.SetoffUserId); if (tempUser != null) { userInfo = new VipEntity(); userInfo.VIPID = tempUser.user_id; } } //获取门店信息 t_unitEntity unitInfo = null; if (!string.IsNullOrEmpty(refundEntity.UnitID)) { unitInfo = unitBLL.GetByID(refundEntity.UnitID); } userEntity = userBll.GetByID(loggingSessionInfo.UserID); refundEntity.Status = 2;//已退款 refundOrderBLL.Update(refundEntity, pTran); salesReturnEntity = salesReturnBLL.GetByID(refundEntity.SalesReturnID); if (salesReturnEntity != null) { salesReturnEntity.Status = 7;//已完成 salesReturnBLL.Update(salesReturnEntity, pTran); historyEntity = new T_SalesReturnHistoryEntity() { SalesReturnID = salesReturnEntity.SalesReturnID, OperationType = 7, OperationDesc = "退款", OperatorID = loggingSessionInfo.UserID, HisRemark = "您的服务单财务已退款,请注意查收", OperatorName = userEntity.user_name, OperatorType = 1 }; historyBLL.Create(historyEntity, pTran); } #region 退回集客订单分润 //上线员工和线上会员不为空 if (userInfo != null) { var vipAmountEntity = vipAmountBLL.QueryByEntity(new VipAmountEntity() { VipId = userInfo.VIPID, VipCardCode = userInfo.VipCode }, null).FirstOrDefault(); var vipAmountDetail = vipAmountDetailBLL.QueryByEntity(new VipAmountDetailEntity() { ObjectId = refundEntity.OrderID, AmountSourceId = "20" }, null).FirstOrDefault(); if (vipAmountDetail != null) { var detailInfo = new VipAmountDetailEntity() { Amount = -vipAmountDetail.Amount.Value, ObjectId = refundEntity.RefundID.ToString(), AmountSourceId = "25" }; var vipAmountDetailId = vipAmountBLL.AddVipAmount(userInfo, unitInfo, ref vipAmountEntity, detailInfo, pTran, loggingSessionInfo); } } #endregion } pTran.Commit(); //提交事物 } catch (Exception ex) { pTran.Rollback();//回滚事务 throw new APIException(ex.Message); } } return(rd); }
protected override GetVIPCardRD ProcessRequest(DTO.Base.APIRequest <GetVIPCardRP> pRequest) { GetVIPCardRD Data = new GetVIPCardRD(); var rd = new GetVIPCardListRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; #region 业务对象 //会员卡 var VipCardBLL = new VipCardBLL(loggingSessionInfo); //会员 var VipBLL = new VipBLL(loggingSessionInfo); //卡状态变更记录 var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo); //卡与Vip关系 var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); //门店 var unitBll = new t_unitBLL(loggingSessionInfo); //员工 var UserBLL = new T_UserBLL(loggingSessionInfo); //卡类型 var SysVipCardTypeBLL = new SysVipCardTypeBLL(loggingSessionInfo); //商户配置 var CustomerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo); //积分 var VipIntegralBLL = new VipIntegralBLL(loggingSessionInfo); #endregion #region 会员卡 VipCardEntity resultData = null; if (!string.IsNullOrWhiteSpace(para.VipID)) { //会员编号获取详情 VipCardVipMappingEntity m_VipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = para.VipID }, null).FirstOrDefault(); if (m_VipMappingData != null && !string.IsNullOrWhiteSpace(m_VipMappingData.VipCardID)) { resultData = VipCardBLL.GetByID(para.VipCardID); } } else { if (!string.IsNullOrWhiteSpace(para.VipCardID)) { //卡ID获取详情 resultData = VipCardBLL.GetByID(para.VipCardID); } else { //刷卡获取详情 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; if (!string.IsNullOrEmpty(para.VipCardISN)) { complexCondition.Add(new DirectCondition("VipCardCode='" + para.VipCardISN + "' or VipCardISN='" + para.VipCardISN.ToString() + "' ")); } resultData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault(); } } //try //{ // if (resultData == null) // throw new APIException("该卡不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; //} //catch (APIException apiEx) //{ // throw new APIException(apiEx.ErrorCode, apiEx.Message); //} #endregion #region 卡关系 VipCardVipMappingEntity VipCardVipMappingData = null; if (resultData != null) { VipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VipCardID = resultData.VipCardID }, null).FirstOrDefault(); } //else //{ // return Data; //} #endregion #region 门店 t_unitEntity unidData = null; if (resultData != null && !string.IsNullOrWhiteSpace(resultData.MembershipUnit)) { unidData = unitBll.GetByID(resultData.MembershipUnit); } #endregion #region 会员,积分 VipEntity VipData = null; VipIntegralEntity IntegralData = null; //string VIPID = VipCardVipMappingData == null ? "" : VipCardVipMappingData.VIPID; string VIPID = para.VipID; if (!string.IsNullOrWhiteSpace(VIPID)) { VipData = VipBLL.NewGetByID(VIPID); //IntegralData = VipIntegralBLL.GetByID(VIPID); IntegralData = VipIntegralBLL.QueryByEntity(new VipIntegralEntity() { VipID = VipData.VIPID, VipCardCode = VipData.VipCode }, null).FirstOrDefault(); } #endregion #region 员工 T_UserEntity UserData = null; if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy)) { UserData = UserBLL.GetByID(resultData.CreateBy); } #endregion #region 响应对象赋值 if (resultData != null) { //卡 Data.VipCardID = resultData.VipCardID; Data.VipCardCode = resultData.VipCardCode; Data.VipCardISN = resultData.VipCardISN; Data.CraeteUserName = UserData == null ? "" : UserData.user_name; Data.VipCardStatusId = resultData.VipCardStatusId.Value; Data.MembershipTime = resultData.MembershipTime == null ? "" : resultData.MembershipTime.Value.ToString("yyyy-MM-dd"); Data.MembershipUnitName = unidData == null ? "" : unidData.unit_name; //Data.TotalAmount = resultData.RechargeTotalAmount == null ? 0 : resultData.RechargeTotalAmount.Value; //Data.BalanceAmount = resultData.BalanceAmount == null ? 0 : resultData.BalanceAmount.Value; Data.BeginDate = resultData.BeginDate; Data.EndDate = "永久有效"; Data.SalesUserName = resultData.SalesUserName == null ? "" : resultData.SalesUserName; #region 卡类型名称 SysVipCardTypeEntity SysVipCardTypeData = SysVipCardTypeBLL.GetByID(resultData.VipCardTypeID); Data.VipCardName = SysVipCardTypeData == null ? "" : SysVipCardTypeData.VipCardTypeName; #endregion #region 状态变更记录列表 var VipCardStatusChangeLogArray = VipCardStatusChangeLogBLL.Query (new IWhereCondition[] { new EqualsCondition() { FieldName = "VipCardID", Value = resultData.VipCardID } }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).ToList(); //转换业务对象 Data.StatusLogList = (from t in VipCardStatusChangeLogArray select new VipCardStatusChangeLog() { CreateTime = t.CreateTime.Value.ToString("yyyy-MM-dd"), UnitName = t.UnitName == null ? "" : t.UnitName, Action = t.Action == null ? "" : t.Action, ChangeReason = t.Reason == null ? "" : t.Reason, Remark = t.Remark == null ? "" : t.Remark, CreateBy = t.CreateByName, ImageUrl = t.PicUrl == null ? "" : t.PicUrl }).ToList(); #endregion } #region 会员 if (VipData != null) { Data.VipID = VipData.VIPID; Data.VipCode = VipData.VipCode; if (Data.VipCardCode == null) { Data.VipCardCode = VipData.VipCode; } if (!string.IsNullOrWhiteSpace(VipData.VipRealName)) { Data.VipName = VipData.VipRealName; } else { Data.VipName = VipData.VipName ?? ""; } Data.Phone = VipData.Phone; Data.Birthday = VipData.Birthday == null ? "" : VipData.Birthday; Data.Gender = VipData.Gender ?? 0; //Data.Integration = VipData.Integration == null ? 0 : VipData.Integration.Value; //会员创建人姓名 T_UserEntity VipUserData = null; if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy)) { VipUserData = UserBLL.GetByID(resultData.CreateBy); } Data.VipCreateByName = VipUserData == null ? "" : VipUserData.user_name; Data.IDNumber = VipData.IDNumber == null ? "" : VipData.IDNumber; #region 会员生日是否可修改字段赋值 //Col22 字段赋值 ////CustomerBasicSettingEntity SettingData = CustomerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "FSR_NotTwoUpdateVipBirthday" }, null).FirstOrDefault(); ////if (SettingData != null) Data.Col22 = VipData.Col22 == null ? "Y" : VipData.Col22; #endregion } #endregion #region 积分 if (IntegralData != null) { Data.Integration = IntegralData.ValidIntegral != null ? IntegralData.ValidIntegral.Value : 0; Data.CumulativeIntegral = IntegralData.CumulativeIntegral != null ? IntegralData.CumulativeIntegral.Value : 0; } #endregion #region 余额和返现 var vipAmountBLL = new VipAmountBLL(loggingSessionInfo); var vipAmountInfo = vipAmountBLL.QueryByEntity(new VipAmountEntity() { VipId = VipData.VIPID, VipCardCode = VipData.VipCode }, null).FirstOrDefault(); if (vipAmountInfo != null) { Data.TotalAmount = vipAmountInfo.TotalAmount == null ? 0 : vipAmountInfo.TotalAmount.Value; Data.BalanceAmount = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value; Data.ValidReturnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value; Data.TotalReturnAmount = vipAmountInfo.TotalReturnAmount == null ? 0 : vipAmountInfo.TotalReturnAmount.Value; } #endregion #endregion return(Data); }
//<summary> //Pos订单入库 //</summary> //<param name="pRequest"></param> //<returns></returns> protected override SetPosOrderRD ProcessRequest(APIRequest <SetPosOrderRP> pRequest) { //请求参数 var rp = pRequest.Parameters; //返回参数 var rd = new SetPosOrderRD(); //订单 var inoutBll = new T_InoutBLL(CurrentUserInfo); var inoutDetail = new T_Inout_DetailBLL(CurrentUserInfo); //商品 var itemCategoryBll = new T_Item_CategoryBLL(CurrentUserInfo); var itemBll = new T_ItemBLL(CurrentUserInfo); var porpBll = new T_PropBLL(CurrentUserInfo); var itemSkuPropBll = new T_ItemSkuPropBLL(CurrentUserInfo); var skuBll = new T_SkuBLL(CurrentUserInfo); var skuPriceBll = new T_Sku_PriceBLL(CurrentUserInfo); var skuProperty = new T_Sku_PropertyBLL(CurrentUserInfo); //获取会员信息 var vipBll = new VipBLL(CurrentUserInfo); var vipInfo = vipBll.GetByID(pRequest.UserID); var vipCardVipMappingBll = new VipCardVipMappingBLL(CurrentUserInfo); var vipCardBll = new VipCardBLL(CurrentUserInfo); var vipCardVipMappingEntity = vipCardVipMappingBll.QueryByEntity(new VipCardVipMappingEntity() { VIPID = vipInfo.VIPID, CustomerID = CurrentUserInfo.ClientID }, null).FirstOrDefault(); string VipCardTypeID = ""; //卡类型Id if (vipCardVipMappingEntity != null) { var vipCardEntity = vipCardBll.GetByID(vipCardVipMappingEntity.VipCardID); VipCardTypeID = vipCardEntity.VipCardTypeID.ToString(); } //员工 var userBll = new T_UserBLL(CurrentUserInfo); //获取门店信息 var unitBll = new t_unitBLL(CurrentUserInfo); t_unitEntity unitInfo = null; if (!string.IsNullOrEmpty(rp.UnitCode)) { unitInfo = unitBll.QueryByEntity(new t_unitEntity() { unit_code = rp.UnitCode, customer_id = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (unitInfo == null) { throw new APIException("请在正念商户后台录入相应门店") { ErrorCode = 100 }; } } else { throw new APIException("缺少请求参数:门店编码") { ErrorCode = 102 }; } //获取员工信息 T_UserEntity userEntity = null; if (!string.IsNullOrEmpty(rp.MobliePhone)) { userEntity = userBll.QueryByEntity(new T_UserEntity() { user_telephone = rp.MobliePhone, customer_id = CurrentUserInfo.ClientID }, null).FirstOrDefault(); //没有员工,新增默认员工(店员APP) if (userEntity == null) { var roleBll = new T_RoleBLL(CurrentUserInfo); var roleEntity = roleBll.QueryByEntity(new T_RoleEntity() { role_code = "clerkAPP", customer_id = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (roleEntity == null) { throw new APIException("请在正念商户后台录入相应角色") { ErrorCode = 100 }; } userEntity = new T_UserEntity(); userEntity.user_telephone = rp.MobliePhone; userEntity.user_code = rp.UserCode; userEntity.user_name = rp.UserCode; userEntity.user_birthday = rp.Birthday; userEntity.user_email = rp.EmailAddress; userEntity.user_address = rp.Address; userEntity.user_postcode = rp.Zip; userBll.AddUser(ref userEntity, unitInfo, roleEntity); } } else { throw new APIException("缺少请求参数:员工手机号") { ErrorCode = 102 }; } //获取会员折扣 var sysVipCardGradeBLL = new SysVipCardGradeBLL(CurrentUserInfo); decimal vipDiscount = sysVipCardGradeBLL.GetVipDiscount() * 10; //订单号 string orderId = BaseService.NewGuidPub(); T_InoutEntity tInoutEntity = new T_InoutEntity(); tInoutEntity.order_id = orderId; tInoutEntity.order_no = rp.OrderNo; //拼接ItemCodes //StringBuilder ItemCodes = new StringBuilder(); //for (int j = 0; j < pRequest.Parameters.OrderDetailList.Count(); j++) //{ // if (j != 0) // { // ItemCodes.Append(","); // } // ItemCodes.Append(string.Format("{0}", pRequest.Parameters.OrderDetailList[j].ItemCode)); //} ////通过itemCodes取出商品价格 //SkuPriceService skuPriceService = new SkuPriceService(CurrentUserInfo); //List<SkuPrice> skuPriceList = skuPriceService.GetPriceListByItemCodes(ItemCodes.ToString(), CurrentUserInfo.ClientID); //if(skuPriceList.Count == 0) //{ // throw new APIException("未找到商品") { ErrorCode = 100 }; //} //订单总金额 decimal totalAmount = rp.TotalAmount; //订单实付金额 decimal ActualAmount = rp.DiscountAmount; //订单折扣后金额 decimal DiscountAmount = rp.DiscountAmount; //订单明细显示顺序 int i = 1; //商品价格重新计算 foreach (var item in pRequest.Parameters.OrderDetailList) { T_ItemEntity itemEntity = null; //商品 T_SkuEntity skuEntity = null; //sku if (!string.IsNullOrEmpty(item.ItemCode)) { itemEntity = itemBll.QueryByEntity(new T_ItemEntity() { item_code = item.ItemCode, CustomerId = CurrentUserInfo.ClientID }, null).FirstOrDefault(); if (itemEntity == null) { if (string.IsNullOrEmpty(item.ItemCategoryCode)) { throw new APIException("缺少参数:商品类别名称") { ErrorCode = 200 }; } itemEntity = new T_ItemEntity(); itemEntity.item_code = item.ItemCode; itemEntity.item_name = item.ItemName; itemBll.AddItem(itemEntity, out skuEntity, item.ItemCategoryName, item.ItemCategoryCode, item.SkuOriginPrice, item.SkuSalesPrice); } else { skuEntity = skuBll.QueryByEntity(new T_SkuEntity() { item_id = itemEntity.item_id }, null).FirstOrDefault(); } } else { throw new APIException("缺少参数:商品编码") { ErrorCode = 300 }; } //订单明细相关处理 T_Inout_DetailBLL inoutDetailBll = new T_Inout_DetailBLL(CurrentUserInfo); T_Inout_DetailEntity inoutDetailEntity = new T_Inout_DetailEntity() { order_detail_id = BaseService.NewGuidPub(), order_id = orderId, //订单Id sku_id = skuEntity.sku_id, //skuId unit_id = unitInfo.unit_id, //门店Id order_qty = item.Qty, //订单qty enter_qty = item.Qty, //实际qty enter_price = item.price, //折扣价 enter_amount = item.price * item.Qty, //折扣价 std_price = item.price, //原价 discount_rate = vipDiscount, //折扣 retail_price = item.price * item.Qty, //零售价 retail_amount = item.price * item.Qty, //零售价 order_detail_status = "1", display_index = i, if_flag = 0 }; inoutDetailBll.Create(inoutDetailEntity); i++; } //优惠券使用 if (!string.IsNullOrEmpty(rp.CouponId)) { #region 判断优惠券是否是该会员的 var vipcouponMappingBll = new VipCouponMappingBLL(CurrentUserInfo); var vipcouponmappingList = vipcouponMappingBll.QueryByEntity(new VipCouponMappingEntity() { VIPID = pRequest.UserID, CouponID = rp.CouponId }, null); if (vipcouponmappingList == null || vipcouponmappingList.Length == 0) { throw new APIException("此张优惠券不是该会员的") { ErrorCode = 103 }; } #endregion #region 判断优惠券是否有效 var couponBll = new CouponBLL(CurrentUserInfo); var couponEntity = couponBll.GetByID(rp.CouponId); if (couponEntity == null) { throw new APIException("无效的优惠券") { ErrorCode = 103 }; } if (couponEntity.Status == 1) { throw new APIException("优惠券已使用") { ErrorCode = 103 }; } if (couponEntity.EndDate < DateTime.Now) { throw new APIException("优惠券已过期") { ErrorCode = 103 }; } var couponTypeBll = new CouponTypeBLL(CurrentUserInfo); var couponTypeEntity = couponTypeBll.GetByID(couponEntity.CouponTypeID); if (couponTypeEntity == null) { throw new APIException("无效的优惠券类型") { ErrorCode = 103 }; } #endregion #region 优惠券核销 var couponUseBll = new CouponUseBLL(CurrentUserInfo); var couponUseEntity = new CouponUseEntity() { CouponUseID = Guid.NewGuid(), CouponID = rp.CouponId, VipID = pRequest.UserID, UnitID = unitInfo.unit_id, OrderID = orderId, Comment = "商城使用电子券", CustomerID = pRequest.CustomerID, CreateBy = pRequest.UserID, CreateTime = DateTime.Now, LastUpdateBy = pRequest.UserID, LastUpdateTime = DateTime.Now, IsDelete = 0 }; couponUseBll.Create(couponUseEntity); #endregion #region 更新CouponType数量 var conponTypeBll = new CouponTypeBLL(CurrentUserInfo); var conponTypeEntity = conponTypeBll.QueryByEntity(new CouponTypeEntity() { CouponTypeID = new Guid(couponEntity.CouponTypeID), CustomerId = pRequest.CustomerID }, null).FirstOrDefault(); conponTypeEntity.IsVoucher += 1; conponTypeBll.Update(conponTypeEntity); #endregion #region 更新优惠券状态 couponEntity.Status = 1; couponBll.Update(couponEntity); #endregion ActualAmount -= couponTypeEntity.ParValue ?? 0; } #region 使用积分 //使用积分 if (rp.IntegralFlag == 1) { var vipIntegralBll = new VipIntegralBLL(CurrentUserInfo); string sourceId = "20"; //积分抵扣 var IntegralDetail = new VipIntegralDetailEntity() { Integral = -Convert.ToInt32(rp.Integral), IntegralSourceID = sourceId, ObjectId = orderId }; if (IntegralDetail.Integral != 0) { //变动前积分 string OldIntegral = (vipInfo.Integration ?? 0).ToString(); //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); var vipIntegralDetailId = vipIntegralBll.AddIntegral(ref vipInfo, unitInfo, IntegralDetail, CurrentUserInfo); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, CurrentUserInfo); } } tInoutEntity.pay_points = rp.Integral; tInoutEntity.receive_points = rp.Integral; ActualAmount -= rp.IntegralAmount; } #endregion #region 余额和返现修改 var vipAmountBll = new VipAmountBLL(CurrentUserInfo); var vipAmountDetailBll = new VipAmountDetailBLL(CurrentUserInfo); var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity() { VipId = pRequest.UserID, VipCardCode = vipInfo.VipCode }, null).FirstOrDefault(); if (vipAmountEntity != null) { //判断该会员账户是否被冻结 if (vipAmountEntity.IsLocking == 1) { throw new APIException("账户已被冻结,请先解冻") { ErrorCode = 103 } } ; //判断该会员的账户余额是否大于本次使用的余额 if (vipAmountEntity.EndAmount < rp.EndAmount) { throw new APIException(string.Format("账户余额不足,当前余额为【{0}】", vipAmountEntity.EndAmount)) { ErrorCode = 103 } } ; } //使用余额 if (rp.EndAmountFlag == 1) { var detailInfo = new VipAmountDetailEntity() { Amount = -rp.EndAmount, AmountSourceId = "1", ObjectId = orderId }; var vipAmountDetailId = vipAmountBll.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, CurrentUserInfo); if (!string.IsNullOrWhiteSpace(vipAmountDetailId)) {//发送微信账户余额变动模板消息 var CommonBLL = new CommonBLL(); CommonBLL.BalanceChangedMessage(tInoutEntity.order_no, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, CurrentUserInfo); } tInoutEntity.Field3 = rp.EndAmount.ToString(); } #endregion //订单主表更新 tInoutEntity.VipCardCode = vipInfo.VipCardCode;//会员卡号 tInoutEntity.order_reason_id = "2F6891A2194A4BBAB6F17B4C99A6C6F5"; tInoutEntity.order_type_id = "1F0A100C42484454BAEA211D4C14B80F"; tInoutEntity.warehouse_id = "67bb4c12785c42d4912aff7d34606592"; tInoutEntity.data_from_id = ""; tInoutEntity.red_flag = "1"; tInoutEntity.order_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //订单时间 tInoutEntity.create_unit_id = unitInfo.unit_id; //门店 tInoutEntity.unit_id = unitInfo.unit_id; //门店 tInoutEntity.sales_unit_id = unitInfo.unit_id; //门店 tInoutEntity.purchase_unit_id = unitInfo.unit_id; tInoutEntity.sales_user = userEntity.user_id; tInoutEntity.total_amount = totalAmount; //订单金额 tInoutEntity.discount_rate = vipDiscount; //会员折扣 tInoutEntity.actual_amount = ActualAmount; //实付金额 tInoutEntity.total_qty = rp.qty; tInoutEntity.total_retail = totalAmount; //订单金额 tInoutEntity.vip_no = vipInfo.VIPID; tInoutEntity.Field6 = vipInfo.Phone; tInoutEntity.Field14 = vipInfo.VipName; tInoutEntity.Field17 = VipCardTypeID; tInoutEntity.Field12 = DiscountAmount.ToString(); tInoutEntity.Field11 = "知行易"; tInoutEntity.customer_id = CurrentUserInfo.ClientID; tInoutEntity.Field1 = "1"; //支付完成 tInoutEntity.Field7 = "700"; //已完成 tInoutEntity.status = "700"; //已完成 tInoutEntity.status_desc = "已完成"; tInoutEntity.Field10 = "已完成"; rd.Amount = ActualAmount - rp.EndAmount; inoutBll.Create(tInoutEntity); //订单奖励 new SendOrderRewardMsgBLL().OrderReward(tInoutEntity, this.CurrentUserInfo, null);//存入到缓存 rd.orderId = orderId; return(rd); } } }
protected override UnitDayReportRD ProcessRequest(APIRequest <UnitDayReportRP> pRequest) { // var rd = new UnitDayReportRD(); var rp = pRequest.Parameters; // var aggUnitDailyEmplBLL = new Agg_UnitDaily_EmplBLL(CurrentUserInfo); var aggUnitDailyBLL = new Agg_UnitDailyBLL(CurrentUserInfo); var rUnitProductDaySalesTopBLL = new R_UnitProductDaySalesTopBLL(CurrentUserInfo); var t_UserBLL = new T_UserBLL(CurrentUserInfo); // var currentAggUnitDailyEntity = default(Agg_UnitDailyEntity); // 当日 var oldAggUnitDailyEntity = default(Agg_UnitDailyEntity); // 昨日 var rUnitProductDaySalesTopEntities = default(R_UnitProductDaySalesTopEntity[]); //销量榜 var aggUnitDailyEmplEntities = default(Agg_UnitDaily_EmplEntity[]); // 业绩榜 //var aggUnitDailyEmplEntities2 = default(Agg_UnitDaily_EmplEntity[]); // 集客榜 var t_UserEntities = default(T_UserEntity[]); //门店员工 // var tasks = new List <Task>(); tasks.Add(Task.Factory.StartNew(() => { currentAggUnitDailyEntity = aggUnitDailyBLL.QueryByEntity(new Agg_UnitDailyEntity { DateCode = Convert.ToDateTime(rp.Date), UnitId = rp.UnitID, CustomerId = rp.CustomerID }, null).FirstOrDefault(); })); tasks.Add(Task.Factory.StartNew(() => { oldAggUnitDailyEntity = aggUnitDailyBLL.QueryByEntity(new Agg_UnitDailyEntity { DateCode = Convert.ToDateTime(rp.Date).AddDays(-1), UnitId = rp.UnitID, CustomerId = rp.CustomerID }, null).FirstOrDefault(); })); tasks.Add(Task.Factory.StartNew(() => { rUnitProductDaySalesTopEntities = rUnitProductDaySalesTopBLL.PagedQueryByEntity(new R_UnitProductDaySalesTopEntity { DateCode = Convert.ToDateTime(rp.Date), UnitId = rp.UnitID, CustomerId = rp.CustomerID }, new OrderBy[] { new OrderBy { FieldName = "TopIndex", Direction = OrderByDirections.Asc } }, 10, 1).Entities; })); tasks.Add(Task.Factory.StartNew(() => { aggUnitDailyEmplEntities = aggUnitDailyEmplBLL.QueryByEntity(new Agg_UnitDaily_EmplEntity { DateCode = Convert.ToDateTime(rp.Date), UnitId = rp.UnitID, CustomerId = rp.CustomerID }, null); })); //tasks.Add(Task.Factory.StartNew(() => //{ // aggUnitDailyEmplEntities2 = aggUnitDailyEmplBLL.PagedQueryByEntity(new Agg_UnitDaily_EmplEntity // { // DateCode = Convert.ToDateTime(rp.Date), // UnitId = rp.UnitID, // CustomerId = rp.CustomerID // }, new OrderBy[] // { // new OrderBy // { // FieldName="SetoffCount", // Direction=OrderByDirections.Desc // }, // new OrderBy // { // FieldName="EmplName", // Direction=OrderByDirections.Asc // } // }, 10, 1).Entities; //})); tasks.Add(Task.Factory.StartNew(() => { t_UserEntities = t_UserBLL.GetEntitiesByCustomerIdUnitId(rp.CustomerID, rp.UnitID); })); Task.WaitAll(tasks.ToArray()); // 当日 if (currentAggUnitDailyEntity != null) { rd.UnitCurrentDaySalesAmount = currentAggUnitDailyEntity.SalesAmount; rd.UnitCurrentDayNewVipCount = currentAggUnitDailyEntity.NewVipCount; rd.UnitCurrentDayOldVipBackCount = currentAggUnitDailyEntity.OldVipBackCount; rd.UnitCurrentDayUseCouponCount = currentAggUnitDailyEntity.UseCouponCount; } // 昨日 if (oldAggUnitDailyEntity != null) { rd.UnitYestodyDaySalesAmount = oldAggUnitDailyEntity.SalesAmount; rd.UnitYestodyDayNewVipCount = oldAggUnitDailyEntity.NewVipCount; rd.UnitYestodyDayOldVipBackCount = oldAggUnitDailyEntity.OldVipBackCount; rd.UnitYestodyDayUseCouponCount = oldAggUnitDailyEntity.UseCouponCount; } // 增减 rd.UnitCurrentDaySalesAmountDoD = ReportCommonBLL.Instance.CalcuDoD(oldAggUnitDailyEntity == null ? null : oldAggUnitDailyEntity.SalesAmount, currentAggUnitDailyEntity == null ? null : currentAggUnitDailyEntity.SalesAmount); rd.UnitCurrentDayNewVipCountDoD = ReportCommonBLL.Instance.CalcuDoD(oldAggUnitDailyEntity == null ? null : oldAggUnitDailyEntity.NewVipCount, currentAggUnitDailyEntity == null ? null : currentAggUnitDailyEntity.NewVipCount); rd.UnitCurrentDayOldVipBackCountDoD = ReportCommonBLL.Instance.CalcuDoD(oldAggUnitDailyEntity == null ? null : oldAggUnitDailyEntity.OldVipBackCount, currentAggUnitDailyEntity == null ? null : currentAggUnitDailyEntity.OldVipBackCount); rd.UnitCurrentDayUseCouponCountDoD = ReportCommonBLL.Instance.CalcuDoD(oldAggUnitDailyEntity == null ? null : oldAggUnitDailyEntity.UseCouponCount, currentAggUnitDailyEntity == null ? null : currentAggUnitDailyEntity.UseCouponCount); // 销量榜 rd.UnitCurrentDayProductSalesTopList = new List <UnitProductSalesTop>(); if (rUnitProductDaySalesTopEntities != null && rUnitProductDaySalesTopEntities.Length > 0) { var list = rUnitProductDaySalesTopEntities.ToList(); list.ForEach(it => { rd.UnitCurrentDayProductSalesTopList.Add(new UnitProductSalesTop { TopIndex = it.TopIndex, ProductName = it.item_name, ProductSKU = it.SkuName, SalesAmount = it.SalesQty }); }); } // 业绩榜 rd.UnitCurrentDaySalesAmountEmplTopList = new List <UnitSalesAmountEmplTop>(); if (aggUnitDailyEmplEntities != null && aggUnitDailyEmplEntities.Length > 0) { var list = aggUnitDailyEmplEntities.OrderByDescending(p => p.SalesAmount).ThenBy(p => p.EmplName).ToList(); var i = 1; foreach (var item in list) { var user = t_UserEntities.Where(p => p.user_id == item.EmplID).FirstOrDefault(); if (user == null) { continue; } rd.UnitCurrentDaySalesAmountEmplTopList.Add(new UnitSalesAmountEmplTop { TopIndex = i, EmplName = item.EmplName, SalesAmount = item.SalesAmount }); i++; if (i > 10) { break; } } } // 集客榜 rd.UnitCurrentDaySetoffEmplTopList = new List <UnitDaySetoffEmplTop>(); if (aggUnitDailyEmplEntities != null && aggUnitDailyEmplEntities.Length > 0) { var list = aggUnitDailyEmplEntities.OrderByDescending(p => p.SetoffCount).ThenBy(p => p.EmplName).ToList(); var i = 1; foreach (var item in list) { var user = t_UserEntities.Where(p => p.user_id == item.EmplID).FirstOrDefault(); if (user == null) { continue; } rd.UnitCurrentDaySetoffEmplTopList.Add(new UnitDaySetoffEmplTop { TopIndex = i, EmplName = item.EmplName, SetoffCount = item.SetoffCount }); i++; if (i > 10) { break; } } } // return(rd); }
protected override UnitWeekReportRD ProcessRequest(APIRequest <UnitWeekReportRP> pRequest) { // var rd = new UnitWeekReportRD(); var rp = pRequest.Parameters; // var aggUnitDailyBLL = new Agg_UnitDailyBLL(CurrentUserInfo); var aggUnitWeeklyEmplBLL = new Agg_UnitWeekly_EmplBLL(CurrentUserInfo); var aggUnitWeeklyBLL = new Agg_UnitWeeklyBLL(CurrentUserInfo); var rUnitProductWeekSalesTopBLL = new R_UnitProductWeekSalesTopBLL(CurrentUserInfo); var aggUnitMonthlyEmplBLL = new Agg_UnitMonthly_EmplBLL(CurrentUserInfo); var t_UserBLL = new T_UserBLL(CurrentUserInfo); // var aggUnitWeeklyEntity = default(Agg_UnitWeeklyEntity); // 本周 var lastAggUnitWeeklyEntity = default(Agg_UnitWeeklyEntity); // 上周 var aggUnitDailyEntities = default(Agg_UnitDailyEntity[]); // 七天门店 var lastAggUnitDailyEntities = default(Agg_UnitDailyEntity[]); // 上七天门店 var rUnitProductWeekSalesTopEntities = default(R_UnitProductWeekSalesTopEntity[]); // 商品销量榜 var salesAggUnitWeeklyEmplEntities = default(Agg_UnitWeekly_EmplEntity[]); // 本周员工业绩 //var setoffAggUnitWeeklyEmplEntities = default(Agg_UnitWeekly_EmplEntity[]); // 本周员工集客 var aggUnitMonthlyEmplEntities = default(Agg_UnitMonthly_EmplEntity[]); // 本月员工 var t_UserEntities = default(T_UserEntity[]); //门店员工 // var tasks = new List <Task>(); tasks.Add(Task.Factory.StartNew(() => { aggUnitWeeklyEntity = aggUnitWeeklyBLL.QueryByEntity(new Agg_UnitWeeklyEntity { DateCode = Convert.ToDateTime(rp.Date), UnitId = rp.UnitID, CustomerId = rp.CustomerID }, null).FirstOrDefault(); })); tasks.Add(Task.Factory.StartNew(() => { lastAggUnitWeeklyEntity = aggUnitWeeklyBLL.QueryByEntity(new Agg_UnitWeeklyEntity { DateCode = Convert.ToDateTime(rp.Date).AddDays(-7), UnitId = rp.UnitID, CustomerId = rp.CustomerID }, null).FirstOrDefault(); })); tasks.Add(Task.Factory.StartNew(() => { var wheres = new IWhereCondition[] { new EqualsCondition { FieldName = "CustomerId", Value = rp.CustomerID }, new EqualsCondition { FieldName = "unitid", Value = rp.UnitID }, new DirectCondition("datecode>='" + Convert.ToDateTime(rp.Date).AddDays(-7).ToString("yyyy-MM-dd") + "' "), new DirectCondition("datecode<'" + Convert.ToDateTime(rp.Date).ToString("yyyy-MM-dd") + "' ") }; var orderbys = new OrderBy[] { new OrderBy { FieldName = "datecode", Direction = OrderByDirections.Asc } }; aggUnitDailyEntities = aggUnitDailyBLL.Query(wheres, orderbys); })); tasks.Add(Task.Factory.StartNew(() => { var lastWheres = new IWhereCondition[] { new EqualsCondition { FieldName = "CustomerId", Value = rp.CustomerID }, new EqualsCondition { FieldName = "unitid", Value = rp.UnitID }, new DirectCondition("datecode>='" + Convert.ToDateTime(rp.Date).AddDays(-14).ToString("yyyy-MM-dd") + "' "), new DirectCondition("datecode<'" + Convert.ToDateTime(rp.Date).AddDays(-7).ToString("yyyy-MM-dd") + "' ") }; var lastOrderBys = new OrderBy[] { new OrderBy { FieldName = "datecode", Direction = OrderByDirections.Asc } }; lastAggUnitDailyEntities = aggUnitDailyBLL.Query(lastWheres, lastOrderBys); })); tasks.Add(Task.Factory.StartNew(() => { rUnitProductWeekSalesTopEntities = rUnitProductWeekSalesTopBLL.PagedQueryByEntity(new R_UnitProductWeekSalesTopEntity { CustomerId = rp.CustomerID, UnitId = rp.UnitID, DateCode = Convert.ToDateTime(rp.Date) }, new OrderBy[] { new OrderBy { FieldName = "salesqty", Direction = OrderByDirections.Desc } }, 10, 1).Entities; })); tasks.Add(Task.Factory.StartNew(() => { salesAggUnitWeeklyEmplEntities = aggUnitWeeklyEmplBLL.QueryByEntity(new Agg_UnitWeekly_EmplEntity { CustomerId = rp.CustomerID, UnitId = rp.UnitID, DateCode = Convert.ToDateTime(rp.Date) }, null); })); //tasks.Add(Task.Factory.StartNew(() => //{ // setoffAggUnitWeeklyEmplEntities = aggUnitWeeklyEmplBLL.PagedQueryByEntity(new Agg_UnitWeekly_EmplEntity // { // CustomerId = rp.CustomerID, // UnitId = rp.UnitID, // DateCode = Convert.ToDateTime(rp.Date) // }, new OrderBy[] // { // new OrderBy // { // FieldName="setoffcount", // Direction= OrderByDirections.Desc // }, // new OrderBy // { // FieldName="EmplName", // Direction=OrderByDirections.Asc // } // }, 10, 1).Entities; //})); tasks.Add(Task.Factory.StartNew(() => { var date = Convert.ToDateTime(rp.Date); aggUnitMonthlyEmplEntities = aggUnitMonthlyEmplBLL.QueryByEntity(new Agg_UnitMonthly_EmplEntity { CustomerId = rp.CustomerID, UnitId = rp.UnitID, DateCode = Convert.ToDateTime(date.Year.ToString() + "-" + date.Month.ToString() + "-01") }, null); })); tasks.Add(Task.Factory.StartNew(() => { t_UserEntities = t_UserBLL.GetEntitiesByCustomerIdUnitId(rp.CustomerID, rp.UnitID); })); Task.WaitAll(tasks.ToArray()); // 本周 if (aggUnitWeeklyEntity != null) { rd.UnitCurrentWeekSalesAmount = aggUnitWeeklyEntity.SalesAmount; rd.UnitCurrentWeekNewVipCount = aggUnitWeeklyEntity.NewVipCount; rd.UnitCurrentWeekOldVipBackCount = aggUnitWeeklyEntity.OldVipBackCount; rd.UnitCurrentWeekUseCouponCount = aggUnitWeeklyEntity.UseCouponCount; } // 上周 if (lastAggUnitWeeklyEntity != null) { rd.UnitLastWeekSalesAmount = lastAggUnitWeeklyEntity.SalesAmount; rd.UnitLastWeekNewVipCount = lastAggUnitWeeklyEntity.NewVipCount; rd.UnitLastWeekOldVipBackCount = lastAggUnitWeeklyEntity.OldVipBackCount; rd.UnitLastWeekUseCouponCount = lastAggUnitWeeklyEntity.UseCouponCount; } // 增减 rd.UnitCurrentWeekSalesAmountWoW = ReportCommonBLL.Instance.CalcuDoD(lastAggUnitWeeklyEntity == null ? null : lastAggUnitWeeklyEntity.SalesAmount, aggUnitWeeklyEntity == null ? null : aggUnitWeeklyEntity.SalesAmount); rd.UnitCurrentWeekNewVipCountWoW = ReportCommonBLL.Instance.CalcuDoD(lastAggUnitWeeklyEntity == null ? null : lastAggUnitWeeklyEntity.NewVipCount, aggUnitWeeklyEntity == null ? null : aggUnitWeeklyEntity.NewVipCount); rd.UnitCurrentWeekOldVipBackCountWoW = ReportCommonBLL.Instance.CalcuDoD(lastAggUnitWeeklyEntity == null ? null : lastAggUnitWeeklyEntity.OldVipBackCount, aggUnitWeeklyEntity == null ? null : aggUnitWeeklyEntity.OldVipBackCount); rd.UnitCurrentWeekUseCouponCountWoW = ReportCommonBLL.Instance.CalcuDoD(lastAggUnitWeeklyEntity == null ? null : lastAggUnitWeeklyEntity.UseCouponCount, aggUnitWeeklyEntity == null ? null : aggUnitWeeklyEntity.UseCouponCount); // var startTime = Convert.ToDateTime(rp.Date).AddDays(-7); // 七天销售额 var unitCurrentWeekSalesAmountList = new List <UnitDaySalesAmount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, aggUnitDailyEntities, ref unitCurrentWeekSalesAmountList, (s, d) => { return(new UnitDaySalesAmount { Date = s.DateCode.ToString(), SalesAmount = s.SalesAmount }); }); rd.UnitCurrentWeekSalesAmountList = unitCurrentWeekSalesAmountList; // 七天新增会员 var unitCurrentWeekNewVipCountList = new List <UnitDayNewVipCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, aggUnitDailyEntities, ref unitCurrentWeekNewVipCountList, (s, d) => { return(new UnitDayNewVipCount { Date = s.DateCode.ToString(), NewVipCount = s.NewVipCount }); }); rd.UnitCurrentWeekNewVipCountList = unitCurrentWeekNewVipCountList; // 七天老会员回店数 var unitCurrentWeekOldVipBackCountList = new List <UnitDayOldVipBackCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, aggUnitDailyEntities, ref unitCurrentWeekOldVipBackCountList, (s, d) => { return(new UnitDayOldVipBackCount { Date = s.DateCode.ToString(), OldVipBackCount = s.OldVipBackCount }); }); rd.UnitCurrentWeekOldVipBackCountList = unitCurrentWeekOldVipBackCountList; // 七天优惠券使用数 var unitCurrentWeekUseCouponCountList = new List <UnitDayUseCouponCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, aggUnitDailyEntities, ref unitCurrentWeekUseCouponCountList, (s, d) => { return(new UnitDayUseCouponCount { Date = s.DateCode.ToString(), UseCouponCount = s.OldVipBackCount }); }); rd.UnitCurrentWeekUseCouponCountList = unitCurrentWeekUseCouponCountList; // startTime = Convert.ToDateTime(rp.Date).AddDays(-14); // 上七天销售额 var unitLastWeekSalesAmountList = new List <UnitDaySalesAmount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, lastAggUnitDailyEntities, ref unitLastWeekSalesAmountList, (s, d) => { return(new UnitDaySalesAmount { Date = s.DateCode.ToString(), SalesAmount = s.SalesAmount }); }); rd.UnitLastWeekSalesAmountList = unitLastWeekSalesAmountList; // 上七天新增会员 var unitLastWeekNewVipCountList = new List <UnitDayNewVipCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, lastAggUnitDailyEntities, ref unitLastWeekNewVipCountList, (s, d) => { return(new UnitDayNewVipCount { Date = s.DateCode.ToString(), NewVipCount = s.NewVipCount }); }); rd.UnitLastWeekNewVipCountList = unitLastWeekNewVipCountList; // 上七天老会员回店数 var unitLastWeekOldVipBackCountList = new List <UnitDayOldVipBackCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, lastAggUnitDailyEntities, ref unitLastWeekOldVipBackCountList, (s, d) => { return(new UnitDayOldVipBackCount { Date = s.DateCode.ToString(), OldVipBackCount = s.OldVipBackCount }); }); rd.UnitLastWeekOldVipBackCountList = unitLastWeekOldVipBackCountList; // 上七天优惠券使用数 var unitLastWeekUseCouponCountList = new List <UnitDayUseCouponCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, lastAggUnitDailyEntities, ref unitLastWeekUseCouponCountList, (s, d) => { return(new UnitDayUseCouponCount { Date = s.DateCode.ToString(), UseCouponCount = s.OldVipBackCount }); }); rd.UnitLastWeekUseCouponCountList = unitLastWeekUseCouponCountList; // 商品销量榜 rd.UnitCurrentWeekProductSalesTopList = new List <UnitProductSalesTop>(); if (rUnitProductWeekSalesTopEntities != null && rUnitProductWeekSalesTopEntities.Length > 0) { var list = rUnitProductWeekSalesTopEntities.ToList(); foreach (var item in list) { rd.UnitCurrentWeekProductSalesTopList.Add(new UnitProductSalesTop { TopIndex = item.TopIndex, ProductName = item.item_name, ProductSKU = item.SkuName, SalesAmount = item.SalesQty }); } } // rd.UnitCurrentWeekSalesAmountEmplTopList = new List <UnitSalesAmountEmplTop>(); // 员工业绩榜 if (salesAggUnitWeeklyEmplEntities != null && salesAggUnitWeeklyEmplEntities.Length > 0) { var list = salesAggUnitWeeklyEmplEntities.OrderByDescending(p => p.SalesAmount).ThenBy(p => p.EmplName).ToList(); var i = 1; foreach (var item in list) { var user = t_UserEntities.Where(p => p.user_id == item.EmplID).FirstOrDefault(); if (user == null) { continue; } rd.UnitCurrentWeekSalesAmountEmplTopList.Add(new UnitSalesAmountEmplTop { TopIndex = i, EmplName = item.EmplName, SalesAmount = item.SalesAmount }); i++; if (i > 10) { break; } } } // rd.UnitCurrentWeekSetoffEmplTopList = new List <UnitWeekSetoffEmplTop>(); // 员工集客榜 if (salesAggUnitWeeklyEmplEntities != null && salesAggUnitWeeklyEmplEntities.Length > 0) { var list = salesAggUnitWeeklyEmplEntities.OrderByDescending(p => p.SetoffCount).ThenBy(p => p.EmplName).ToList(); var i = 1; foreach (var item in list) { var user = t_UserEntities.Where(p => p.user_id == item.EmplID).FirstOrDefault(); if (user == null) { continue; } var empMothData = aggUnitMonthlyEmplEntities.FirstOrDefault(it => it.EmplID == item.EmplID); rd.UnitCurrentWeekSetoffEmplTopList.Add(new UnitWeekSetoffEmplTop { TopIndex = i, EmplName = item.EmplName, WeekSetoffCount = item.SetoffCount, MonthSetoffCount = empMothData != null ? empMothData.SetoffCount : 0 }); i++; if (i > 10) { break; } } } // return(rd); }
public HttpResponseMessage ScanQRCode([FromBody] ScanQRCodeRequestModel requestParameter) { var json = new JavaScriptSerializer().Serialize(requestParameter); Loggers.Debug(new DebugLogInfo() { Message = $"[api/Order/ScanQRCode]接口,参数:\"{json}\"" }); try { #region MyRegion string customerId = ConfigurationManager.AppSettings["CustomerId"].Trim(); string content = string.Empty; #endregion #region var loggingSessionInfo = Default.GetLoggingSession(customerId, "1"); if (string.IsNullOrWhiteSpace(requestParameter.ParaTmp)) { throw new APIException("paraTmp不能为空") { ErrorCode = 302 }; } #endregion #region 创建临时匹配表 VipDCodeBLL vipDCodeServer = new VipDCodeBLL(loggingSessionInfo); VipDCodeEntity info = new VipDCodeEntity(); //由于CodeId有重复的概率,因此只取出最新的一条记录 info = vipDCodeServer.QueryByEntity( new VipDCodeEntity() { DCodeId = ToStr(requestParameter.ParaTmp.Replace(" ", "")) } //又去掉了中间的空格 , new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } } )[0]; string status = string.Empty; string vipId = string.Empty; string openId = string.Empty; if (info == null || info.DCodeId == null) { throw new APIException("不存在对应的记录") { ErrorCode = 303 }; } else { status = info.Status; openId = info.OpenId; vipId = info.VipId; } string mode = "Inbound"; //if ((RP.Parameters.special.Mode == null || (!string.IsNullOrEmpty(RP.Parameters.special.Mode) && RP.Parameters.special.Mode.Equals("Inbound"))) && !string.IsNullOrEmpty(info.VipId) && info.VipId != RP.UserID) if ((mode == null || (!string.IsNullOrEmpty(mode) && mode.Equals("Inbound"))) && !string.IsNullOrEmpty(info.VipId) && info.VipId != requestParameter.UserId) { VipBLL vipBll = new VipBLL(loggingSessionInfo); var unitBll = new t_unitBLL(loggingSessionInfo); var UserBll = new T_UserBLL(loggingSessionInfo); var vipInfo = vipBll.GetByID(info.VipId); var tt = vipBll.GetUnitByUserId(requestParameter.UserId); //获取员工的会集店**** var UserEntity = UserBll.GetByID(vipInfo.SetoffUserId); //当前会员集客员工 // string UserStatus = ""; if (UserEntity != null) { UserStatus = UserEntity.user_status; } #region 会员会籍店、集客员工变动处理 //string.IsNullOrWhiteSpace(vipInfo.CouponInfo) || string.IsNullOrWhiteSpace(vipInfo.SetoffUserId) 目前未用到 if (string.IsNullOrWhiteSpace(vipInfo.HigherVipID) && string.IsNullOrWhiteSpace(vipInfo.SetoffUserId)) { //当会员会籍店、集客员工为空时 if (!string.IsNullOrEmpty(tt)) { vipInfo.CouponInfo = tt; //设为门店 vipInfo.SetoffUserId = requestParameter.UserId; //设为门店员工 vipInfo.Col21 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //集客时间***** vipInfo.Col23 = "1"; } if (vipInfo != null && vipInfo.SetoffUserId == requestParameter.UserId) { //rsp.Message = "恭喜你集客成功。会员需要用心经营才会有订单哦!"; } } else { if (vipInfo != null && !string.IsNullOrEmpty(vipInfo.CouponInfo) && vipInfo.SetoffUserId != requestParameter.UserId) { //rsp.Message = "此客户已是会员,无需再集客。老会员更要服务好哦!"; } else if (vipInfo != null && vipInfo.SetoffUserId == requestParameter.UserId && !string.IsNullOrEmpty(vipInfo.Col21) && Convert.ToDateTime(vipInfo.Col21).AddSeconds(3) < DateTime.Now) //col21:员工集客/或者分销商集客时间 { //rsp.Message = "此客户此前已经被您集客,无需重复集客。!"; } } if (UserStatus.Trim().Equals("-1")) { // 当前会员的集客员工离职时 if (!string.IsNullOrEmpty(tt)) { vipInfo.CouponInfo = tt; //设为门店 vipInfo.SetoffUserId = requestParameter.UserId; //设为门店员工 vipInfo.Col21 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //集客时间***** vipInfo.Col23 = "1"; } } #endregion vipBll.Update(vipInfo); } #endregion var responseModel = new ScanQRCodeResponseModel() { IsSucess = true, Status = status, VipId = vipId }; return(Request.CreateResponse(HttpStatusCode.OK, responseModel)); } catch (Exception ex) { var responseModel = new ScanQRCodeResponseModel() { IsSucess = false, ErrorMessage = ex.Message }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, "error")); } }
protected void Button1_Click(object sender, EventArgs e) { string customerID = "e703dbedadd943abacf864531decdac1"; string userID = "7c292994c45143028cbf0b60c9555aec"; string strUserID = "DD9ADDE3553F4D87AB8C619BF4AA0690,1FD5AD09E69A40B8A4375A12735EC283,AFF07CF7C5284854A39188AB4205AE1E,A85F922FE74C4FB99B69EB3C8FA00A2E"; strUserID = @"0184281DFCAA41B5A5677FBC44BC12A1, 02AA1B9C39E941F498B2D406D4EB32F7, 039C8E9739824317A0FBC672E99F9E2A, 04839D77E7A543AFBE7F74BDCE2ADD33, 0DBC9929C91043939B92F979C251DCA1, 0EA09800A5D64A4AB40B42B0C4EFB29E, 11A41E03B17E485687C1C210E5D33B3A, 180AB32388684E019DC6FA600408A121, 1A2B719047F34154832EF158A3D7F06E, 1A555A9FE379406BBCA11F811DAB0FF0, 1DC2216D9B9D4B499AB6713C5A66AD5D, 242070129F97437F862D2C601FBCD0C1, 24F8C88D6DF142EE864FE0660DCD64BF"; //10 strUserID = @"29B190D43C9748E1BC06449EE51897D0, 2C2282DB10EB4447AB137C2576C2EF20, 2EF28338AC3A48CFAE973F9900C912AF, 35072C3E9BDC483FA9A81CF872438878, 357B20FE14E64FE99D6D544A42DA43AE, 3AA6D6F373644120BC2C068D7224E34C, 3B1AA8BA629544FF80A1F7621EE114D2, 3EA3112E383F4FA3BF87B6E7756FC4E5, 45EBAAC968B045958F155E90981ACF79, 47E5B4C196044C119787E7D7E3FA5917"; //10 strUserID = @"4C2BCFC00D014ABB9BC5D8B5E9AB88C7, 4E7218E3238D41D8AFEC1A668605F3E9, 51C982115B424607BF05571F165E3F49, 55650665A3A243B0AABD1F334D7B26FF, 5780E53AD70D4B60BD2603321B3E9410, 62AACF0614594CEDAC639E90B62AC96B, 721C3FF043A84E6A9787553FAB022AF9, 724995905F844B6B82A511366F9707FE, 76EC9C0C7D0947C8A017E95C1F05B98C, 7A013BB3FCDE4B0CB0138EF8D9679AE3"; //20 strUserID = @"7DCBA541DEFA4029BA78D46DCD582851, 7E6541C688B2498B8CF3C5782EE8FCEE, 84C01AA65E5847F3A3E276B1A8EA2D21, 88A606E463364A5180ED7B672C3CF9D2, 896486B41D004D07A908CD0FF61B9FC2, 8B449CB46C9C468DAD4F8066AE839077, 8E898BFDC6D643ED92D716881C43E1B8, 97149F4837D24F6CA2CB4FFEE96519B2, 9A6F53293DD44A14B10743AFED93C9FD, 9BE6DECFE39947AD97403A095EC044D8, 9FB82E8189D14C49A3106F197B5699FD, A01A651BD0064BB98A237BD6EBE61394, A0D828CB14A9416F9C858ACD00FDA2AE, A47BBE39B65845DD8BAB608DFCACA763, A5236A553C5D45439C208A16BF071F93, A70809FD0CEB4A00AADDC23C26F77606, A891E4A460344419B9D0D8E4372D39EE, ADB60ECA82884A738DA373F1DAC037B8, AF6BA62E618A4613AB479A71B460DBCE, B6AF1C32356942E89BD9BC4A8035BDE5"; //17 strUserID = @"B6EAD054631B4FD0856378E759E066D6, B7C15CCD21BF48DB9464622AB801C3A7, BCE7451C86A0499C8C985F10E2A0EC1A, BD493AFCE1AE4221868110109D8DB1C6, C33D2F0EB4744ACCBE4ED90C0388BDA1, C824F2FB61744CAEB6C4779018887901, D38BB2A5831A4605B334322BA38B0153, D882A720F21D4264B1321D1BEF02F133, DC15B0B0AB1A4CF8BB7EB92BAB62CEDB, DEB9EF7124F245888486F77B4C75EB26, EEEE5C893D684D049A4832B5304EF511, F2008EC7AEE44A9EB07DFC558F39B007, F59E5C834BC04D1691F0E74E04CC32F5, F6A8C513BE8A47278D0DAAB7F456441F, FAA27FDC1FD64058A12A0E350CE0BC7E, FBDA86854E5A4D1DB7346D92BB36918A, FED8394E94D54D8CAC66AB15DE69F403"; strUserID = "DD9ADDE3553F4D87AB8C619BF4AA0691"; strUserID = strUserID.Replace("\r\n", "").Replace(" ", ""); string[] arrUserID = strUserID.Split(','); var loggingSessionInfo = Default.GetBSLoggingSession(customerID, userID); T_UserBLL bll = new T_UserBLL(loggingSessionInfo); //验证是否在第三方注册 TUserThirdPartyMappingBLL tutpmBll = new TUserThirdPartyMappingBLL(loggingSessionInfo); int index = 0; System.Text.StringBuilder strBuilder = new System.Text.StringBuilder(); foreach (string itemUserID in arrUserID) { Loggers.DEFAULT.Debug(new DebugLogInfo() { Message = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "userID:" + itemUserID }); try { TUserThirdPartyMappingEntity tutpmEntiy = tutpmBll.GetByID(itemUserID); if (tutpmEntiy == null) { ThirdUserViewModel userViewModel = null; CloudRequestFactory factory = new CloudRequestFactory(); //调用云通讯创建子账户 string retData = factory.CreateSubAccount("sandboxapp.cloopen.com", "8883", "ff8080813bbcae3f013bcc39c18a0022", "8f32e2023d804e1390a3b0b8b36d6e28", "aaf98f893e7df943013e8728b2b400c7", itemUserID); //string jsonData = getDictionaryData(retData); strBuilder.AppendLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "create userID:" + itemUserID + "=====" + retData); userViewModel = CWHelper.Deserialize <ThirdUserViewModel>(retData); if (userViewModel.statusCode == MessageStatusCode.Success) { tutpmEntiy = CreateThirdUser(tutpmEntiy, userViewModel, itemUserID); tutpmBll.Create(tutpmEntiy); } } else { Loggers.DEFAULT.Debug(new DebugLogInfo() { Message = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "云通讯已注册userID:" + itemUserID }); } index++; } catch (Exception ex) { Loggers.DEFAULT.Exception(new ExceptionLogInfo(ex)); } } //记录云通讯创建子账号 Loggers.DEFAULT.Debug(new DebugLogInfo() { Message = strBuilder.ToString() }); Response.Write(index); //Response.Write("<script>alert('完成批量注册!');</script>"); }
protected override GetConfigRD ProcessRequest(DTO.Base.APIRequest <GetConfigRP> pRequest) { var rd = new GetConfigRD(); var customerId = CurrentUserInfo.ClientID; var trrBll = new T_RewardRecordBLL(CurrentUserInfo);//打赏记录 var userBll = new T_UserBLL(CurrentUserInfo); var cbsBll = new CustomerBasicSettingBLL(CurrentUserInfo); var trcBll = new T_RewardConfigBLL(CurrentUserInfo); var cbsEntity = cbsBll.QueryByEntity(new CustomerBasicSettingEntity() { CustomerID = customerId }, null).FirstOrDefault(); var trcEntitys = trcBll.QueryByEntity(new T_RewardConfigEntity() { CustomerId = customerId }, null); //获取员工 var userInfo = new T_UserEntity(); var employeeId = pRequest.Parameters.EmployeeID; if (!string.IsNullOrEmpty(employeeId)) { userInfo = userBll.QueryByEntity(new T_UserEntity() { user_id = employeeId, customer_id = customerId }, null).FirstOrDefault(); //员工头像 var _ObjectImagesBLL = new ObjectImagesBLL(CurrentUserInfo); var userImg = _ObjectImagesBLL.QueryByEntity(new ObjectImagesEntity() { ObjectId = employeeId, CustomerId = customerId }, null).OrderByDescending(p => p.CreateTime).FirstOrDefault(); //星级 var oeBll = new ObjectEvaluationBLL(CurrentUserInfo); var oeList = oeBll.QueryByEntity(new ObjectEvaluationEntity() { ObjectID = employeeId, Type = 4, CustomerID = customerId }, null); var oeinfo = (from p in oeList.AsEnumerable() group p by p.ObjectID into g select new { g.Key, SumValue = g.Average(p => p.StarLevel) }).ToArray().FirstOrDefault(); //打赏数据 var rewardCount = trrBll.QueryByEntity(new T_RewardRecordEntity() { RewardedOP = employeeId, PayStatus = 2, CustomerId = customerId }, null).Length; //员工信息 rd.UserInfo = new List <UserInfo>(); rd.UserInfo.Add(new UserInfo() { UserName = userInfo.user_name, UserPhoto = userImg != null ? userImg.ImageURL : string.Empty, StarLevel = oeinfo != null ? Convert.ToInt32(oeinfo.SumValue) : 0, RewardCount = rewardCount }); } //打赏类型 if (cbsEntity != null) { switch (cbsEntity.SettingValue) { case "1": rd.Type = 1; break; case "2": rd.Type = 2; break; default: rd.Type = 0; //0或空(null)为两者 break; } } else { rd.Type = 0;//两者 } //打赏金额列表 rd.AmountList = new List <RewardAmountInfo>(); foreach (var item in trcEntitys) { rd.AmountList.Add(new RewardAmountInfo() { Amount = item.RewardAmount }); } return(rd); }