Exemplo n.º 1
0
        public string GetDeptDirectSubDept(string pRequest)
        {
            var rd     = new APIResponse <GetDeptDirectSubDeptRD>();
            var rdData = new GetDeptDirectSubDeptRD();

            var rp = pRequest.DeserializeJSONTo <APIRequest <GetDeptDirectSubDeptRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                TUnitBLL unitBll = new TUnitBLL(loggingSessionInfo);
                DepartmentInfoDataAccess departmentManager = new DepartmentInfoDataAccess(loggingSessionInfo);
                rdData.DepartmentList = departmentManager.GetDeptDirectSubDept(rp.Parameters.UnitID);
                rd.ResultCode         = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
Exemplo n.º 2
0
        public string DelDept(string pRequest)
        {
            var rd     = new APIResponse <DelDeptRD>();
            var rdData = new DelDeptRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <DelDeptRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                TUnitBLL unitBll = new TUnitBLL(loggingSessionInfo);
                unitBll.Delete(rp.Parameters.UnitID, null);
                rdData.IsSuccess = true;
                rd.ResultCode    = 0;
                rd.Data          = rdData;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            return(rd.ToJSON());
        }
Exemplo n.º 3
0
        public string DelDept(string pRequest)
        {
            var rd     = new APIResponse <DelDeptRD>();
            var rdData = new DelDeptRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <DelDeptRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = new LoggingSessionManager().CurrentSession;

            try
            {
                TUnitBLL unitBll   = new TUnitBLL(loggingSessionInfo);
                string[] unitIdArr = rp.Parameters.UnitID.Split(',');
                unitBll.Delete(unitIdArr);
                rdData.IsSuccess = true;
                rd.ResultCode    = 0;
                rd.Data          = rdData;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            return(rd.ToJSON());
        }
Exemplo n.º 4
0
        public string ModifyDept(string pRequest)
        {
            var rd     = new APIResponse <ModifyDeptRD>();
            var rdData = new ModifyDeptRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <ModifyDeptRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                TUnitBLL    unitBll = new TUnitBLL(loggingSessionInfo);
                TUnitEntity entity  = unitBll.GetByID(rp.Parameters.UnitID);
                if (entity == null)
                {
                    rdData.IsSuccess = false;
                    rd.Data          = rdData;
                    rd.ResultCode    = 101;
                    rd.Message       = "部门不存在";
                    return(rd.ToJSON());
                }
                entity.UnitName = rp.Parameters.UnitName;
                entity.UnitCode = rp.Parameters.UnitCode;
                if (!string.IsNullOrEmpty(rp.Parameters.Leader))
                {
                    entity.UnitContact = rp.Parameters.Leader;
                }
                if (!string.IsNullOrEmpty(rp.Parameters.DeptDesc))
                {
                    entity.UnitRemark = rp.Parameters.DeptDesc;
                }
                entity.ModifyUserID = rp.UserID;
                entity.ModifyTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                unitBll.Update(entity);

                rdData.IsSuccess = true;
                rd.Data          = rdData;
                rd.ResultCode    = 0;
            }
            catch (Exception ex)
            {
                rdData.IsSuccess = false;
                rd.Data          = rdData;
                rd.ResultCode    = 103;
                rd.Message       = ex.Message;
            }
            return(rd.ToJSON());
        }
Exemplo n.º 5
0
 public TWindowController()
 {
     this.bll        = new TWindowBLL(this.AreaNo);
     this.winBusiBll = new TWindowBusinessBLL(this.AreaNo);
     this.dicBll     = new TDictionaryBLL(this.AreaNo);
     this.areaBll    = new TWindowAreaBLL(this.AreaNo);
     this.unitBll    = new TUnitBLL(this.AreaNo);
     this.busiBll    = new TBusinessBLL(this.AreaNo);
     this.userBll    = new TUserBLL(this.AreaNo);
 }
        /// <summary>
        /// 获取部门全部直接子部门
        /// </summary>
        /// <param name="pUnitID"></param>
        /// <returns></returns>
        public List <DepartmentInfo> GetDeptDirectSubDept(string pUnitID)
        {
            List <DepartmentInfo> listDepartment = new List <DepartmentInfo>();
            TUnitBLL  unitBll = new TUnitBLL(_loggingSessionInfo);
            DataTable dTbl    = unitBll.GetDirectSubDept(pUnitID);

            if (dTbl != null)
            {
                listDepartment = DataTableToObject.ConvertToList <DepartmentInfo>(dTbl);
            }
            return(listDepartment);
        }
Exemplo n.º 7
0
        public string GetDept(string pRequest)
        {
            var rd     = new APIResponse <GetDeptRD>();
            var rdData = new GetDeptRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <GetDeptRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = new LoggingSessionManager().CurrentSession;

            try
            {
                TUnitBLL  unitBll   = new TUnitBLL(loggingSessionInfo);
                string    typeID    = System.Configuration.ConfigurationManager.AppSettings["TypeID"].ToString();
                int       totalPage = 0;
                DataTable dTable    = unitBll.GetUnitList(rp.Parameters.UnitID, typeID, rp.Parameters.PageIndex, rp.Parameters.PageSize, rp.Parameters.Keyword, out totalPage);

                //排序
                DataView dv   = dTable.DefaultView;
                string   sort = string.IsNullOrEmpty(rp.Parameters.sort) ? "UnitName asc" : rp.Parameters.sort;
                dv.Sort = sort;
                DataTable dt2 = dv.ToTable();
                dTable = dt2;

                if (dTable != null)
                {
                    rdData.UnitList = DataTableToObject.ConvertToList <UnitInfo>(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 GetDeptAllMembers(string pRequest)
        {
            var rd     = new APIResponse <GetDeptAllMembersRD>();
            var rdData = new GetDeptAllMembersRD();

            var rp = pRequest.DeserializeJSONTo <APIRequest <GetDeptAllMembersRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                TUnitBLL unitBll = new TUnitBLL(loggingSessionInfo);
                DepartmentInfoDataAccess departmentManager = new DepartmentInfoDataAccess(loggingSessionInfo);
                TUnitEntity entity = unitBll.GetByID(rp.Parameters.UnitID);
                if (entity != null)
                {
                    rdData.Member = departmentManager.GetDeptAllMembers(entity.UnitID, entity.UnitName);
                    rd.ResultCode = 0;
                }
                else
                {
                    rd.ResultCode = 101;
                    rd.Message    = "部门不存在";
                }
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
Exemplo n.º 9
0
 public TUserController()
 {
     this.bll     = new TUserBLL("MySQL", this.AreaNo);
     this.dicBll  = new FDictionaryBLL("MySQL", this.AreaNo);
     this.unitBll = new TUnitBLL("MySQL", this.AreaNo);
 }
Exemplo n.º 10
0
        public string AddDept(string pRequest)
        {
            var rd     = new APIResponse <AddDeptRD>();
            var rdData = new AddDeptRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <AddDeptRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                TUnitBLL unitBll = new TUnitBLL(loggingSessionInfo);
                string   typeID  = System.Configuration.ConfigurationManager.AppSettings["TypeID"].ToString();
                if (!string.IsNullOrEmpty(rp.Parameters.TypeID))
                {
                    typeID = rp.Parameters.TypeID;
                }
                TUnitEntity[] unitEntityArr = unitBll.Query(new IWhereCondition[]
                {
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "customer_id", Value = rp.CustomerID
                    },
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "unit_name", Value = rp.Parameters.UnitName
                    },
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "type_id", Value = typeID
                    },
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "Status", Value = "1"
                    }
                }, null);
                if (unitEntityArr != null && unitEntityArr.Length > 0)
                {
                    rd.ResultCode = 101;
                    rd.Message    = rp.Parameters.UnitName + "已存在";
                    return(rd.ToJSON());
                }
                string      unitID     = Guid.NewGuid().ToString().Replace("-", "");
                TUnitEntity unitEntity = new TUnitEntity
                {
                    UnitID        = unitID,
                    UnitName      = rp.Parameters.UnitName,
                    UnitCode      = rp.Parameters.UnitCode,
                    UnitContact   = rp.Parameters.Leader,
                    UnitRemark    = rp.Parameters.DeptDesc,
                    TypeID        = typeID,
                    CreateTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    CreateUserID  = loggingSessionInfo.CurrentUser.User_Id,
                    ModifyTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    ModifyUserID  = loggingSessionInfo.CurrentUser.User_Id,
                    CustomerID    = loggingSessionInfo.CurrentUser.customer_id,
                    CUSTOMERLEVEL = 0,
                    Status        = "1",
                    StatusDesc    = "正常",
                    IfFlag        = "1"
                };
                unitBll.Create(unitEntity);

                rdData.UnitID = unitID;
                rd.Data       = rdData;
                rd.ResultCode = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            return(rd.ToJSON());
        }
Exemplo n.º 11
0
 public TBusinessController()
 {
     bll     = new TBusinessBLL("MySQL", this.AreaNo);
     dicBll  = new FDictionaryBLL("MySQL", this.AreaNo);
     unitBll = new TUnitBLL("MySQL", this.AreaNo);
 }
Exemplo n.º 12
0
 public SRate2Controller()
 {
     this.bll     = new BEvaluateBLL("MySQL", this.AreaNo);
     this.unitBll = new TUnitBLL("MySQL", this.AreaNo);
     this.userBll = new TUserBLL("MySQL", this.AreaNo);
 }
Exemplo n.º 13
0
        protected override SetSignInRD ProcessRequest(DTO.Base.APIRequest <SetSignInRP> pRequest)
        {
            SetSignInRD rd = new SetSignInRD();

            string customerCode = pRequest.Parameters.CustomerCode;

            string phone = pRequest.Parameters.LoginName;

            string password = pRequest.Parameters.Password;

            if (string.IsNullOrEmpty(customerCode))
            {
                throw new APIException("客户代码不能为空")
                      {
                          ErrorCode = Error_CustomerCode_NotNull
                      };
            }

            WMenuBLL menuServer = new WMenuBLL(Default.GetAPLoggingSession(""));
            string   customerId = menuServer.GetCustomerIDByCustomerCode(customerCode);

            if (string.IsNullOrEmpty(customerId))
            {
                throw new APIException("客户代码对应的客户不存在")
                      {
                          ErrorCode = Error_CustomerCode_NotExist
                      };
            }
            var currentUserInfo = Default.GetBSLoggingSession(customerId, "1");

            VipBLL vipBll = new VipBLL(currentUserInfo);

            #region 判断用户是否存在
            if (!vipBll.JudgeUserExist(phone, customerId))
            {
                throw new APIException("用户名无效")
                      {
                          ErrorCode = Error_UserName_InValid
                      };
            }

            #endregion

            #region 判断密码是否正确
            if (!vipBll.JudgeUserPasswordExist(phone, customerId, password))
            {
                throw new APIException("登录密码错误")
                      {
                          ErrorCode = Error_Password_InValid
                      };
            }

            #endregion
            #region 判断是否有登录连锁掌柜App权限
            var  userRolesDs = vipBll.GetUserRoles(phone, customerId, password);
            bool flag        = false;
            foreach (DataRow row in userRolesDs.Tables[0].Rows)
            {
                if (row["Def_App_Code"].ToString().ToUpper() == "APP")
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                throw new APIException("该账号无权登录本系统")
                      {
                          ErrorCode = Error_Password_InValid
                      };
            }
            #endregion
            #region 判断该客服人员是否有客服或操作订单的权限
            //if (!vipBll.JudgeUserRoleExist(phone, customerId, password))
            //{
            //    throw new APIException("该账号无权登录本系统") { ErrorCode = Error_Password_InValid };
            //}
            #endregion

            #region 获取UserId
            var ds = vipBll.GetUserIdByUserNameAndPassword(phone, customerId, password);
            rd.UserId     = ds.Tables[0].Rows[0]["user_id"].ToString();
            rd.UserName   = ds.Tables[0].Rows[0]["user_name"].ToString();
            rd.Status     = int.Parse(ds.Tables[0].Rows[0]["user_status"].ToString());
            rd.CustomerId = customerId;
            var T_SuperRetailTraderbll  = new T_SuperRetailTraderBLL(currentUserInfo);
            var T_SuperRetailTraderInfo = T_SuperRetailTraderbll.QueryByEntity(new T_SuperRetailTraderEntity()
            {
                CustomerId = customerId, SuperRetailTraderFromId = rd.UserId, SuperRetailTraderFrom = "User"
            }, new OrderBy[] { new OrderBy()
                               {
                                   FieldName = "CreateTime", Direction = OrderByDirections.Desc
                               } }).FirstOrDefault();
            if (T_SuperRetailTraderInfo != null)
            {
                rd.SuperRetailTraderID = T_SuperRetailTraderInfo.SuperRetailTraderID.ToString();
            }
            #endregion
            //如果状态不等于1,就说明已经停用,
            if (rd.Status != 1)
            {
                throw new APIException("该员工已经被停用,请联系管理员")
                      {
                          ErrorCode = Error_Password_InValid
                      };
            }


            #region 获取角色列表
            var roleCodeDs = vipBll.GetRoleCodeByUserId(rd.UserId, customerId);

            var tmp = roleCodeDs.Tables[0].AsEnumerable().Select(t => new RoleCodeInfo()
            {
                RoleCode = t["role_code"].ToString()
            });

            #endregion
            rd.UnitId = vipBll.GetUnitByUserId(rd.UserId);//获取会集店
            TUnitBLL tUnitBLL = new TUnitBLL(currentUserInfo);
            if (!string.IsNullOrEmpty(rd.UnitId))
            {
                rd.UnitName = tUnitBLL.GetByID(rd.UnitId).UnitName;
            }
            else
            {
                rd.UnitName = "";
            }


            //app登陆用户权限 add by henry 2015-3-26
            var roleCodeList = vipBll.GetAppMenuByUserId(rd.UserId);


            //app登陆用户权限 add by henry 2015-3-26
            List <string> lst = new List <string>();
            if (roleCodeDs.Tables[0] != null && roleCodeDs.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow item in roleCodeDs.Tables[0].Rows)
                {
                    var menuList = new JIT.CPOS.BS.DataAccess.AppSysService(currentUserInfo).GetRoleMenus(currentUserInfo.ClientID, item["role_id"] + "");
                    if (menuList != null)
                    {
                        lst.AddRange(menuList.Select(m => m.Menu_Code).Distinct().ToList());
                    }
                }
            }

            rd.MenuCodeList = new List <Menu>();
            foreach (var item in lst.Distinct().ToList())
            {
                rd.MenuCodeList.Add(new Menu()
                {
                    MenuCode = item
                });
            }

            //if (roleCodeList != null)
            //{
            //    rd.MenuCodeList = DataTableToObject.ConvertToList<Menu>(roleCodeList.Tables[0]);
            //}

            rd.RoleCodeList = tmp.ToArray();
            rd.CustomerName = currentUserInfo.ClientName;


            //销售员头像
            ObjectImagesBLL    _ObjectImagesBLL = new ObjectImagesBLL(currentUserInfo);
            ObjectImagesEntity en = new ObjectImagesEntity();
            en.ObjectId = rd.UserId;//根据获取的用户ID
            List <ObjectImagesEntity> ImgList = _ObjectImagesBLL.QueryByEntity(en, null).OrderByDescending(p => p.CreateTime).ToList();
            if (ImgList != null && ImgList.Count != 0)
            {
                // string fileDNS = customerBasicSettingBll.GetSettingValueByCode("FileDNS"); ;//http://182.254.156.57:811
                rd.HeadImg = ImgList[0].ImageURL;
            }


            #region 获取appLogo
            //基础数据初始化
            CustomerBasicSettingBLL      customerBasicSettingBLL = new CustomerBasicSettingBLL(currentUserInfo);
            List <CustomerBasicCodeInfo> customerBasicCodeList   = new List <CustomerBasicCodeInfo>();
            //查询条件
            CustomerBasicSettingEntity customerBasicSettingEntity = new CustomerBasicSettingEntity()
            {
                CustomerID  = currentUserInfo.ClientID,
                SettingCode = "WebLogo"
            };
            //执行查询
            List <CustomerBasicSettingEntity> customerBasicSettingEntityList = customerBasicSettingBLL.QueryByEntity(customerBasicSettingEntity, null).ToList();

            foreach (var a in customerBasicSettingEntityList)
            {
                CustomerBasicCodeInfo customerBasicCodeInfo = new CustomerBasicCodeInfo();

                if (a.SettingCode.Equals("WebLogo"))
                {
                    customerBasicCodeInfo.WebLogo = a.SettingValue.ToString();
                }
                customerBasicCodeList.Add(customerBasicCodeInfo);
            }

            rd.CustomerBasicCodeList = customerBasicCodeList;


            #endregion
            return(rd);
        }
        public string Export(LoggingSessionInfo pLoggingSessionInfo, string pUserID, string pCustomerID, string pPath)
        {
            string website_WWW          = System.Configuration.ConfigurationManager.AppSettings["website_WWW"].ToString();
            string customer_service_url = System.Configuration.ConfigurationManager.AppSettings["customer_service_url"].ToString();

            pPath = pPath.Replace(website_WWW, "");
            pPath = pPath.Replace(customer_service_url, "");
            pPath = pPath.Replace("http://test.o2omarketing.cn:9100/", "");

            #region 读取上传文件的excel数据
            string mapPath = System.Web.HttpContext.Current.Server.MapPath("~/");
            pPath = mapPath + pPath;
            System.IO.FileInfo exporstFile = new System.IO.FileInfo(pPath);
            if (!exporstFile.Exists)
            {
                return("0|文件不存在");
            }
            DataTable excelTable = new DataTable();
            DataSet   ds         = new DataSet();
            //Excel的连接
            OleDbConnection objConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pPath + ";" + "Extended Properties=Excel 8.0;");
            objConn.Open();
            //DataTable schemaTable = objConn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
            //string tableName = schemaTable.Rows[0][2].ToString().Trim();//获取 Excel 的表名,默认值是Sheet1$
            //string strSql = "select * from [" + tableName + "]";
            string           tableName = "Sheet1$";
            string           strSql    = "select * from [" + tableName + "]";
            OleDbCommand     objCmd    = new OleDbCommand(strSql, objConn);
            OleDbDataAdapter myData    = new OleDbDataAdapter(strSql, objConn);
            myData.Fill(ds, tableName);//填充数据
            objConn.Close();
            excelTable = ds.Tables[tableName];

            //过滤空行
            DataRow[] drs     = excelTable.Select("邮箱<>''");
            DataTable dtClone = excelTable.Clone();
            foreach (var row in drs)
            {
                dtClone.ImportRow(row);
            }
            #endregion

            #region 获取职衔、部门、角色
            DataView  _dv       = dtClone.DefaultView;
            DataTable jobFuncDT = _dv.ToTable(true, "职衔");
            DataTable deptDT    = _dv.ToTable(true, "部门");
            DataTable roleDT    = _dv.ToTable(true, "角色");
            #endregion

            #region 职衔验证
            var jobFuncBll  = new JobFunctionBLL(pLoggingSessionInfo);
            var jobFuncList = jobFuncBll.Query(new IWhereCondition[]
            {
                new EqualsCondition {
                    DateTimeAccuracy = null, FieldName = "CustomerID", Value = pCustomerID
                },
                new EqualsCondition {
                    DateTimeAccuracy = null, FieldName = "IsDelete", Value = "0"
                },
                new EqualsCondition {
                    DateTimeAccuracy = null, FieldName = "Status", Value = "1"
                }
            },
                                               null);
            foreach (DataRow row in jobFuncDT.Rows)
            {
                if (row["职衔"] == null || string.IsNullOrEmpty(row["职衔"].ToString()))
                {
                    continue;
                }
                int count = jobFuncList.Count(job => job.Name == row["职衔"].ToString().Trim());
                if (count <= 0)
                {
                    return("0|职衔不存在");
                }
            }
            #endregion

            #region 部门验证
            string   typeID   = System.Configuration.ConfigurationManager.AppSettings["TypeID"].ToString();
            TUnitBLL deptBll  = new TUnitBLL(pLoggingSessionInfo);
            var      deptList = deptBll.Query(new IWhereCondition[]
            {
                new EqualsCondition {
                    DateTimeAccuracy = null, FieldName = "customer_id", Value = pCustomerID
                },
                new EqualsCondition {
                    DateTimeAccuracy = null, FieldName = "type_id", Value = typeID
                },
                new EqualsCondition {
                    DateTimeAccuracy = null, FieldName = "Status", Value = "1"
                }
            },
                                              null);
            foreach (DataRow row in deptDT.Rows)
            {
                if (row["部门"] == null || string.IsNullOrEmpty(row["部门"].ToString()))
                {
                    continue;
                }
                int count = deptList.Count(dept => dept.UnitName == row["部门"].ToString().Trim());
                if (count <= 0)
                {
                    return("0|部门不存在");
                }
            }
            #endregion

            #region 角色验证
            RoleService       rs       = new RoleService(pLoggingSessionInfo);
            IList <RoleModel> roleList = rs.GetAllRoles();
            foreach (DataRow row in roleDT.Rows)
            {
                if (row["角色"] == null || string.IsNullOrEmpty(row["角色"].ToString()))
                {
                    continue;
                }
                int count = roleList.Count(role => role.Role_Name == row["角色"].ToString().Trim());
                if (count <= 0)
                {
                    return("0|角色不存在");
                }
            }
            #endregion

            return(ExportData(pCustomerID, pLoggingSessionInfo, dtClone, jobFuncList, deptList, roleList));
            //return "1|成功";
        }
Exemplo n.º 15
0
        protected override SetVipCardRD ProcessRequest(DTO.Base.APIRequest <SetVipCardRP> pRequest)
        {
            var rd   = new SetVipCardRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            #region 业务对象
            //会员卡
            var VipCardBLL = new VipCardBLL(loggingSessionInfo);
            //余额变动记录
            var VipCardBalanceChangeBLL = new VipCardBalanceChangeBLL(loggingSessionInfo);
            //卡状态变更记录
            var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo);
            //卡关系
            var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo);
            //图片
            var objectImagesBLL = new ObjectImagesBLL(loggingSessionInfo);
            //会员
            var VipBLL = new VipBLL(loggingSessionInfo);

            var vipCardTransLogBLL = new VipCardTransLogBLL(loggingSessionInfo); //丰收日交易记录对象示例化
            var unitBLL            = new TUnitBLL(loggingSessionInfo);           //门店业务对象
            //事务
            var pTran = VipCardBLL.GetTran();
            #endregion



            using (pTran.Connection)
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(para.VipCardID) || para.OperationType <= 0)
                    {
                        throw new APIException("卡ID或者操作类型参数不合法!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER
                              };
                    }

                    //定位当前卡业务对象
                    VipCardEntity changeEntity = VipCardBLL.GetByID(para.VipCardID);

                    if (changeEntity == null)
                    {
                        throw new APIException("当前卡信息对象为NULL!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              };
                    }
                    #region 返回卡ID
                    rd.VipCardID = changeEntity.VipCardID;
                    #endregion
                    changeEntity.RechargeTotalAmount = changeEntity.RechargeTotalAmount ?? 0;
                    changeEntity.BalanceAmount       = changeEntity.BalanceAmount ?? 0;
                    string  OldVipCardCode = changeEntity.VipCardCode ?? "";                       //原卡号
                    string  NewVipCardCode = "";                                                   //新卡号,获取新卡赋值
                    decimal OldMoney       = changeEntity.BalanceAmount.Value;                     //原卡当前余额
                    decimal NewMoney       = changeEntity.BalanceAmount.Value + para.BalanceMoney; //原卡当余额+调整金额

                    //原卡会员映射关系
                    VipCardVipMappingEntity OldVipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
                    {
                        VipCardID = para.VipCardID
                    }, null).FirstOrDefault();
                    if (OldVipCardVipMappingData == null)
                    {
                        throw new APIException("原卡会员关系映射对象为NULL!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              };
                    }

                    //门店Entity
                    var UnitData = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId);
                    //会员
                    VipEntity VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID);

                    #region 卡状态记录对象
                    VipCardStatusChangeLogEntity AddVCStatusEntity = new VipCardStatusChangeLogEntity();
                    AddVCStatusEntity.LogID       = System.Guid.NewGuid().ToString();
                    AddVCStatusEntity.VipCardID   = para.VipCardID;
                    AddVCStatusEntity.Reason      = para.ChangeReason;
                    AddVCStatusEntity.OldStatusID = changeEntity.VipCardStatusId;
                    AddVCStatusEntity.CustomerID  = loggingSessionInfo.ClientID;
                    AddVCStatusEntity.Remark      = para.Remark;
                    AddVCStatusEntity.UnitID      = loggingSessionInfo.CurrentUserRole.UnitId;
                    #endregion



                    #region 新卡
                    VipCardEntity NewChangeVipCardData = new VipCardEntity();
                    if (!string.IsNullOrWhiteSpace(para.NewCardCode))
                    {
                        //查询参数
                        List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                        };
                        if (!string.IsNullOrEmpty(para.NewCardCode))
                        {
                            complexCondition.Add(new DirectCondition("VipCardCode='" + para.NewCardCode + "' or VipCardISN='" + para.NewCardCode.ToString() + "' "));
                        }
                        //新卡对象
                        NewChangeVipCardData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault();
                        if (NewChangeVipCardData == null)
                        {
                            throw new APIException("新卡不存在!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  };
                        }
                        //新卡号赋值
                        NewVipCardCode = NewChangeVipCardData.VipCardCode ?? "";
                        //新卡数据赋值
                        NewChangeVipCardData.VipCardGradeID      = changeEntity.VipCardGradeID;
                        NewChangeVipCardData.BatchNo             = changeEntity.BatchNo;
                        NewChangeVipCardData.BeginDate           = changeEntity.BeginDate;
                        NewChangeVipCardData.EndDate             = changeEntity.EndDate;
                        NewChangeVipCardData.TotalAmount         = changeEntity.TotalAmount == null ? 0 : changeEntity.TotalAmount.Value;
                        NewChangeVipCardData.BalanceAmount       = changeEntity.BalanceAmount == null ? 0 : changeEntity.BalanceAmount.Value;
                        NewChangeVipCardData.BalancePoints       = changeEntity.BalancePoints == null ? 0 : changeEntity.BalancePoints.Value;
                        NewChangeVipCardData.BalanceBonus        = changeEntity.BalanceBonus == null ? 0 : changeEntity.BalanceBonus.Value;
                        NewChangeVipCardData.CumulativeBonus     = changeEntity.CumulativeBonus == null ? 0 : changeEntity.CumulativeBonus.Value;
                        NewChangeVipCardData.PurchaseTotalAmount = changeEntity.PurchaseTotalAmount == null ? 0 : changeEntity.PurchaseTotalAmount.Value;
                        NewChangeVipCardData.PurchaseTotalCount  = changeEntity.PurchaseTotalCount == null ? 0 : changeEntity.PurchaseTotalCount.Value;
                        NewChangeVipCardData.CheckCode           = changeEntity.CheckCode;
                        NewChangeVipCardData.SingleTransLimit    = changeEntity.SingleTransLimit == null ? 0 : changeEntity.SingleTransLimit.Value;
                        NewChangeVipCardData.IsOverrunValid      = changeEntity.IsOverrunValid == null ? 0 : changeEntity.IsOverrunValid.Value;
                        NewChangeVipCardData.RechargeTotalAmount = changeEntity.RechargeTotalAmount == null ? 0 : changeEntity.RechargeTotalAmount.Value;
                        NewChangeVipCardData.LastSalesTime       = changeEntity.LastSalesTime;
                        NewChangeVipCardData.IsGift         = changeEntity.IsGift == null ? 0 : changeEntity.IsGift.Value;
                        NewChangeVipCardData.SalesAmount    = changeEntity.SalesAmount;
                        NewChangeVipCardData.SalesUserId    = changeEntity.SalesUserId;
                        NewChangeVipCardData.CustomerID     = changeEntity.CustomerID;
                        NewChangeVipCardData.MembershipTime = changeEntity.MembershipTime;
                        NewChangeVipCardData.SalesUserName  = changeEntity.SalesUserName == null ? "" : changeEntity.SalesUserName;
                        NewChangeVipCardData.CreateBy       = changeEntity.CreateBy;
                    }
                    #endregion


                    switch (para.OperationType)
                    {
                    case 1:
                        #region 调整卡余额
                        //卡更新

                        //卡内总金额
                        if (para.BalanceMoney > 0)
                        {
                            changeEntity.RechargeTotalAmount += para.BalanceMoney;
                            if (changeEntity.RechargeTotalAmount < 0)
                            {
                                throw new APIException("调整后的余额小于0!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      };
                            }
                        }
                        //changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0;
                        //
                        changeEntity.BalanceAmount = NewMoney;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);

                        //新增余额变动记录
                        VipCardBalanceChangeEntity AddEntity = new VipCardBalanceChangeEntity();
                        AddEntity.ChangeID     = System.Guid.NewGuid().ToString();
                        AddEntity.VipCardCode  = changeEntity.VipCardCode;
                        AddEntity.ChangeAmount = para.BalanceMoney;
                        //变动前卡内余额
                        AddEntity.ChangeBeforeBalance = OldMoney;
                        //变动后卡内余额
                        AddEntity.ChangeAfterBalance = NewMoney;
                        AddEntity.ChangeReason       = para.ChangeReason;
                        AddEntity.Status             = 1;
                        AddEntity.Remark             = para.Remark;
                        AddEntity.CustomerID         = loggingSessionInfo.ClientID;
                        AddEntity.UnitID             = loggingSessionInfo.CurrentUserRole.UnitId;
                        //执行新增
                        VipCardBalanceChangeBLL.Create(AddEntity, pTran);

                        //增加图片上传
                        if (!string.IsNullOrEmpty(para.ImageUrl))
                        {
                            var objectImagesEntity = new ObjectImagesEntity()
                            {
                                ImageId  = Guid.NewGuid().ToString(),
                                ObjectId = AddEntity.ChangeID,
                                ImageURL = para.ImageUrl
                            };
                            objectImagesBLL.Create(objectImagesEntity, pTran);
                        }
                        #region 充值记录
                        //读取最近一次积分变更记录
                        List <OrderBy> lstOrder = new List <OrderBy> {
                        };                                                   //排序参数
                        lstOrder.Add(new OrderBy()
                        {
                            FieldName = "TransTime", Direction = OrderByDirections.Desc
                        });
                        var transLogInfo = vipCardTransLogBLL.QueryByEntity(new VipCardTransLogEntity()
                        {
                            VipCardCode = changeEntity.VipCardCode, TransType = "C"
                        }, lstOrder.ToArray()).FirstOrDefault();
                        //期末积分
                        int newValue = transLogInfo != null ? (transLogInfo.NewValue ?? 0) : 0;
                        var vipCardTransLogEntity = new VipCardTransLogEntity()
                        {
                            VipCardCode  = VipData == null ? "" : VipData.VipCode,
                            UnitCode     = UnitData == null ? "" : UnitData.UnitCode,
                            TransContent = "余额",
                            TransType    = "C",
                            TransTime    = DateTime.Now,
                            TransAmount  = para.BalanceMoney,
                            LastValue    = newValue,                                      //期初金额
                            NewValue     = Convert.ToInt32(para.BalanceMoney) + newValue, //期末金额
                            CustomerID   = loggingSessionInfo.ClientID
                        };
                        vipCardTransLogBLL.Create(vipCardTransLogEntity, pTran);

                        #endregion


                        #endregion
                        break;

                    case 2:
                        #region 卡升级

                        //卡类型升级
                        if (para.VipCardTypeId != 0)
                        {
                            VipCardVipMappingBLL.updateVipCardByType(VipData.VIPID, para.VipCardTypeId, para.ChangeReason, para.Remark, VipData.VipCode, pTran);
                        }
                        //卡号升级
                        else
                        {
                            #region 原卡

                            #region 更新原卡
                            changeEntity.VipCardStatusId = 3;
                            //当前月,累计金额清0
                            //changeEntity.BalanceAmount = 0;
                            //changeEntity.TotalAmount = 0;
                            VipCardBLL.Update(changeEntity, pTran);    //执行
                            #endregion

                            #region 新增原卡状态记录
                            AddVCStatusEntity.VipCardStatusID = 3;
                            AddVCStatusEntity.Action          = "卡升级";
                            AddVCStatusEntity.Remark         += "已升级为:" + NewChangeVipCardData.VipCardCode;
                            VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);    //执行
                            #endregion

                            #region 新增原卡余额变动记录
                            //if (OldMoney > 0)
                            //{
                            //    VipCardBalanceChangeEntity AddOldCardBalanceData = new VipCardBalanceChangeEntity();
                            //    AddOldCardBalanceData.ChangeID = System.Guid.NewGuid().ToString();
                            //    AddOldCardBalanceData.VipCardCode = changeEntity.VipCardCode;
                            //    AddOldCardBalanceData.ChangeAmount = -OldMoney;
                            //    //变动前卡内余额
                            //    AddOldCardBalanceData.ChangeBeforeBalance = OldMoney;
                            //    //变动后卡内余额
                            //    AddOldCardBalanceData.ChangeAfterBalance = 0;
                            //    AddOldCardBalanceData.ChangeReason = para.ChangeReason;
                            //    AddOldCardBalanceData.Status = 1;
                            //    AddOldCardBalanceData.Remark = para.Remark;
                            //    AddOldCardBalanceData.CustomerID = loggingSessionInfo.ClientID;
                            //    AddOldCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId;
                            //    VipCardBalanceChangeBLL.Create(AddOldCardBalanceData, pTran);//执行
                            //    //增加图片上传
                            //    if (!string.IsNullOrEmpty(para.ImageUrl))
                            //    {
                            //        var objectImagesEntity = new ObjectImagesEntity()
                            //        {
                            //            ImageId = Guid.NewGuid().ToString(),
                            //            ObjectId = AddOldCardBalanceData.ChangeID,
                            //            ImageURL = para.ImageUrl
                            //        };
                            //        objectImagesBLL.Create(objectImagesEntity, pTran);
                            //    }
                            //}
                            #endregion

                            #endregion

                            #region 新卡

                            VipData.VipCode = para.NewCardCode;
                            VipBLL.Update(VipData, pTran);

                            #region 更新新卡
                            if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit))
                            {
                                throw new APIException("该会员卡已绑定会员!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                            if (NewChangeVipCardData.VipCardStatusId != 0)
                            {
                                throw new APIException("该会员卡已激活!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                            if (NewChangeVipCardData.VipCardTypeID.Value == changeEntity.VipCardTypeID.Value)
                            {
                                throw new APIException("该卡号与原卡等级相同,请更换卡号后重新尝试!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;

                            #region 返回新卡卡ID
                            rd.VipCardID = NewChangeVipCardData.VipCardID;
                            #endregion
                            NewChangeVipCardData.MembershipUnit  = changeEntity.MembershipUnit;
                            NewChangeVipCardData.VipCardStatusId = 1;
                            VipCardBLL.Update(NewChangeVipCardData, pTran);    //执行
                            #endregion

                            #region 新增新卡卡关系
                            VipCardVipMappingEntity AddVipCardVipMappingData = new VipCardVipMappingEntity();
                            AddVipCardVipMappingData.MappingID  = System.Guid.NewGuid().ToString();
                            AddVipCardVipMappingData.VIPID      = OldVipCardVipMappingData.VIPID;
                            AddVipCardVipMappingData.VipCardID  = NewChangeVipCardData.VipCardID;
                            AddVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID;
                            VipCardVipMappingBLL.Create(AddVipCardVipMappingData, pTran);    //执行
                            #endregion

                            #region 更新会员编号
                            //VipEntity SJ_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID);
                            //if (VipData == null)
                            //    throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS };

                            //VipData.VipCode = NewChangeVipCardData.VipCardCode;
                            //VipBLL.Update(VipData, pTran);//执行
                            #endregion

                            #region 新增新卡状态记录
                            //新增新卡状态记录

                            VipCardStatusChangeLogEntity AddNewVCStatusEntity = new VipCardStatusChangeLogEntity();
                            AddNewVCStatusEntity.LogID           = System.Guid.NewGuid().ToString();
                            AddNewVCStatusEntity.VipCardID       = NewChangeVipCardData.VipCardID;
                            AddNewVCStatusEntity.VipCardStatusID = 1;
                            AddNewVCStatusEntity.Reason          = para.ChangeReason;
                            AddNewVCStatusEntity.OldStatusID     = 0;
                            AddNewVCStatusEntity.CustomerID      = loggingSessionInfo.ClientID;
                            AddNewVCStatusEntity.Action          = "卡升级";
                            AddNewVCStatusEntity.Remark          = para.Remark + "由旧卡:" + changeEntity.VipCardCode + "升级";
                            AddNewVCStatusEntity.UnitID          = loggingSessionInfo.CurrentUserRole.UnitId;
                            VipCardStatusChangeLogBLL.Create(AddNewVCStatusEntity, pTran);    //执行

                            #endregion

                            #region 新增新卡余额记录
                            //新增余额记录
                            //if (OldMoney > 0)
                            //{
                            //    VipCardBalanceChangeEntity AddNewCardBalanceData = new VipCardBalanceChangeEntity();
                            //    AddNewCardBalanceData.ChangeID = System.Guid.NewGuid().ToString();
                            //    AddNewCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode;
                            //    AddNewCardBalanceData.ChangeAmount = OldMoney;
                            //    //变动前卡内余额
                            //    AddNewCardBalanceData.ChangeBeforeBalance = 0;
                            //    //变动后卡内余额
                            //    AddNewCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value;
                            //    AddNewCardBalanceData.ChangeReason = para.ChangeReason;
                            //    AddNewCardBalanceData.Status = 1;
                            //    AddNewCardBalanceData.Remark = para.Remark;
                            //    AddNewCardBalanceData.CustomerID = loggingSessionInfo.ClientID;
                            //    VipCardBalanceChangeBLL.Create(AddNewCardBalanceData, pTran);//执行
                            //    //增加图片上传
                            //    if (!string.IsNullOrEmpty(para.ImageUrl))
                            //    {
                            //        var objectImagesEntity = new ObjectImagesEntity()
                            //        {
                            //            ImageId = Guid.NewGuid().ToString(),
                            //            ObjectId = AddNewCardBalanceData.ChangeID,
                            //            ImageURL = para.ImageUrl
                            //        };
                            //        objectImagesBLL.Create(objectImagesEntity, pTran);
                            //    }
                            //}
                            #endregion

                            #endregion
                        }
                        #endregion

                        break;

                    case 3:
                        #region 挂失
                        changeEntity.VipCardStatusId = 4;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行
                        AddVCStatusEntity.VipCardStatusID = 4;
                        AddVCStatusEntity.PicUrl          = para.ImageUrl;
                        AddVCStatusEntity.Action          = "挂失";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion

                        break;

                    case 4:

                        #region 冻结
                        changeEntity.VipCardStatusId = 2;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 2;
                        AddVCStatusEntity.Action          = "冻结";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 5:
                        #region 转卡
                        #region 原卡
                        #region 更新原卡
                        changeEntity.VipCardStatusId = 3;
                        //当前月,累计金额清0
                        changeEntity.BalanceAmount = 0;
                        changeEntity.TotalAmount   = 0;
                        VipCardBLL.Update(changeEntity, pTran);    //执行
                        #endregion

                        #region 新增原卡状态记录
                        AddVCStatusEntity.VipCardStatusID = 3;
                        AddVCStatusEntity.Action          = "转卡";
                        AddVCStatusEntity.Remark         += "已转移为:" + NewChangeVipCardData.VipCardCode;
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);    //执行
                        #endregion


                        #region 新增原卡余额变动记录
                        if (OldMoney > 0)
                        {
                            VipCardBalanceChangeEntity AddOldZKCardBalanceData = new VipCardBalanceChangeEntity();
                            AddOldZKCardBalanceData.ChangeID     = System.Guid.NewGuid().ToString();
                            AddOldZKCardBalanceData.VipCardCode  = changeEntity.VipCardCode;
                            AddOldZKCardBalanceData.ChangeAmount = -OldMoney;
                            //变动前卡内余额
                            AddOldZKCardBalanceData.ChangeBeforeBalance = OldMoney;
                            //变动后卡内余额
                            AddOldZKCardBalanceData.ChangeAfterBalance = 0;
                            AddOldZKCardBalanceData.ChangeReason       = para.ChangeReason;
                            AddOldZKCardBalanceData.Status             = 1;
                            AddOldZKCardBalanceData.Remark             = para.Remark;
                            AddOldZKCardBalanceData.CustomerID         = loggingSessionInfo.ClientID;
                            AddOldZKCardBalanceData.UnitID             = loggingSessionInfo.CurrentUserRole.UnitId;
                            VipCardBalanceChangeBLL.Create(AddOldZKCardBalanceData, pTran);     //执行
                            //增加图片上传
                            if (!string.IsNullOrEmpty(para.ImageUrl))
                            {
                                var objectImagesEntity = new ObjectImagesEntity()
                                {
                                    ImageId  = Guid.NewGuid().ToString(),
                                    ObjectId = AddOldZKCardBalanceData.ChangeID,
                                    ImageURL = para.ImageUrl
                                };
                                objectImagesBLL.Create(objectImagesEntity, pTran);
                            }
                        }
                        #endregion

                        #endregion
                        #region 新卡

                        #region 更新新卡
                        if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit))
                        {
                            throw new APIException("该会员卡已绑定会员!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;
                        if (NewChangeVipCardData.VipCardStatusId != 0)
                        {
                            throw new APIException("该会员卡已激活!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;
                        if (NewChangeVipCardData.VipCardTypeID.Value != changeEntity.VipCardTypeID.Value)
                        {
                            throw new APIException("该卡号与原卡等级不同,请更换卡号后重新尝试!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;

                        #region 返回新卡卡ID
                        rd.VipCardID = NewChangeVipCardData.VipCardID;
                        #endregion
                        NewChangeVipCardData.MembershipUnit  = changeEntity.MembershipUnit;
                        NewChangeVipCardData.VipCardStatusId = 1;
                        VipCardBLL.Update(NewChangeVipCardData, pTran);    //执行
                        #endregion



                        #region 新增新卡卡关系
                        VipCardVipMappingEntity AddZKVipCardVipMappingData = new VipCardVipMappingEntity();
                        AddZKVipCardVipMappingData.MappingID  = System.Guid.NewGuid().ToString();
                        AddZKVipCardVipMappingData.VIPID      = OldVipCardVipMappingData.VIPID;
                        AddZKVipCardVipMappingData.VipCardID  = NewChangeVipCardData.VipCardID;
                        AddZKVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID;
                        VipCardVipMappingBLL.Create(AddZKVipCardVipMappingData, pTran);    //执行
                        #endregion

                        #region 更新会员编号
                        //VipEntity ZK_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID);
                        if (VipData == null)
                        {
                            throw new APIException("会员不存在!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;

                        VipData.VipCode = NewChangeVipCardData.VipCardCode;
                        VipBLL.Update(VipData, pTran);    //执行
                        #endregion

                        #region 新增新卡状态记录
                        VipCardStatusChangeLogEntity AddNewZKVCStatusEntity = new VipCardStatusChangeLogEntity();
                        AddNewZKVCStatusEntity.LogID           = System.Guid.NewGuid().ToString();
                        AddNewZKVCStatusEntity.VipCardID       = NewChangeVipCardData.VipCardID;
                        AddNewZKVCStatusEntity.VipCardStatusID = 1;
                        AddNewZKVCStatusEntity.Reason          = para.ChangeReason;
                        AddNewZKVCStatusEntity.OldStatusID     = 0;
                        AddNewZKVCStatusEntity.CustomerID      = loggingSessionInfo.ClientID;
                        AddNewZKVCStatusEntity.Action          = "转卡";
                        AddNewZKVCStatusEntity.Remark          = para.Remark + para.Remark + "由旧卡:" + changeEntity.VipCardCode + "转移";
                        AddNewZKVCStatusEntity.UnitID          = loggingSessionInfo.CurrentUserRole.UnitId;
                        VipCardStatusChangeLogBLL.Create(AddNewZKVCStatusEntity, pTran);    //执行
                        #endregion

                        #region 新增新卡余额记录
                        if (OldMoney > 0)
                        {
                            VipCardBalanceChangeEntity AddNewZKCardBalanceData = new VipCardBalanceChangeEntity();
                            AddNewZKCardBalanceData.ChangeID     = System.Guid.NewGuid().ToString();
                            AddNewZKCardBalanceData.VipCardCode  = NewChangeVipCardData.VipCardCode;
                            AddNewZKCardBalanceData.ChangeAmount = OldMoney;
                            //变动前卡内余额
                            AddNewZKCardBalanceData.ChangeBeforeBalance = 0;
                            //变动后卡内余额
                            AddNewZKCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value;
                            AddNewZKCardBalanceData.ChangeReason       = para.ChangeReason;
                            AddNewZKCardBalanceData.Status             = 1;
                            AddNewZKCardBalanceData.Remark             = para.Remark;
                            AddNewZKCardBalanceData.CustomerID         = loggingSessionInfo.ClientID;
                            AddNewZKCardBalanceData.UnitID             = loggingSessionInfo.CurrentUserRole.UnitId;
                            VipCardBalanceChangeBLL.Create(AddNewZKCardBalanceData, pTran);    //执行
                            //增加图片上传
                            if (!string.IsNullOrEmpty(para.ImageUrl))
                            {
                                var objectImagesEntity = new ObjectImagesEntity()
                                {
                                    ImageId  = Guid.NewGuid().ToString(),
                                    ObjectId = AddNewZKCardBalanceData.ChangeID,
                                    ImageURL = para.ImageUrl
                                };
                                objectImagesBLL.Create(objectImagesEntity, pTran);
                            }
                        }
                        #endregion



                        #endregion
                        #endregion
                        break;

                    case 6:

                        #region 解挂
                        changeEntity.VipCardStatusId = 1;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 1;
                        AddVCStatusEntity.Action          = "解挂";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 7:

                        #region 解冻
                        changeEntity.VipCardStatusId = 1;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 1;
                        AddVCStatusEntity.Action          = "解冻";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 8:
                        #region 作废
                        changeEntity.VipCardStatusId = 3;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);


                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 3;
                        AddVCStatusEntity.Action          = "作废";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 9:
                        #region 唤醒
                        changeEntity.VipCardStatusId = 1;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 1;
                        AddVCStatusEntity.Action          = "唤醒";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 10:
                        #region 激活
                        changeEntity.VipCardStatusId = 1;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 1;
                        AddVCStatusEntity.Action          = "激活";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    default:
                        throw new APIException("当前操作类型不匹配!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER
                              };
                        break;
                    }
                    ;
                    pTran.Commit();
                    #region 卡升级,转卡操作转移消费记录表
                    if ((para.OperationType == 2 || para.OperationType == 5) && string.IsNullOrEmpty(para.VipCardTypeId.ToString())) //卡类型升级不执行此操作
                    {
                        string StrSql = string.Format("update VipCardTransLog set VipCardCode='{0}',OldVipCardCode='{1}' where VipCardCode='{1}'", NewVipCardCode, OldVipCardCode);
                        vipCardTransLogBLL.UpdateVipCardTransLog(StrSql);//执行
                    }
                    #endregion

                    var eventService = new EventService();
                    var vipMsg       = new EventContract
                    {
                        Operation  = OptEnum.Update,
                        EntityType = EntityTypeEnum.Vip,
                        Id         = VipData.VIPID
                    };
                    eventService.PublishMsg(vipMsg);
                }
                catch (APIException apiEx)
                {
                    pTran.Rollback();//回滚事物
                    throw new APIException(apiEx.ErrorCode, apiEx.Message);
                }
                catch (Exception ex)
                {
                    pTran.Rollback();//回滚事务
                    throw new APIException(ex.Message);
                }
            }
            return(rd);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 核销优惠劵
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        private string BestowCoupon(string pRequest)
        {
            RespData respData = new RespData();

            try
            {
                var reqObj = pRequest.DeserializeJSONTo <reqConunbondata>();
                if (string.IsNullOrEmpty(reqObj.userId))
                {
                    respData.ResultCode = "103";
                    respData.Message    = "登陆用户不能为空";
                }
                if (string.IsNullOrEmpty(reqObj.Parameters.doorID))
                {
                    respData.ResultCode = "103";
                    respData.Message    = "此APP版本无法核销,请升级到新版本。";
                    return(respData.ToJSON());
                }
                var loggingSessionInfo = Default.GetBSLoggingSession(reqObj.customerId, reqObj.userId);
                var couponUseBll       = new CouponUseBLL(loggingSessionInfo);             //优惠券使用BLL实例化
                var vcmBll             = new VipCouponMappingBLL(loggingSessionInfo);      //优惠券BLL实例化
                var couponTypeBll      = new CouponTypeBLL(loggingSessionInfo);            //优惠券类型
                var mappingBll         = new CouponTypeUnitMappingBLL(loggingSessionInfo); //优惠券和门店映射
                //var vcmEntity = new VipCouponMappingEntity();
                CouponBLL bll = new CouponBLL(loggingSessionInfo);



                //判断是否有权限核销优惠券
                CouponEntity couponEntity = null;
                if (!string.IsNullOrEmpty(reqObj.Parameters.couponCode))
                {
                    CouponEntity[] couponEntityArray = bll.QueryByEntity(new CouponEntity()
                    {
                        CouponCode = reqObj.Parameters.couponCode, CustomerID = reqObj.customerId
                    }, null);
                    if (couponEntityArray.Length != 0)
                    {
                        couponEntity = couponEntityArray[0];
                    }
                }
                else
                {
                    couponEntity = bll.GetByID(reqObj.Parameters.cuponID);
                }


                if (couponEntity != null)
                {
                    List <IWhereCondition> wheresOrderNo = new List <IWhereCondition>();
                    wheresOrderNo.Add(new EqualsCondition()
                    {
                        FieldName = "CouponID", Value = couponEntity.CouponID
                    });
                    var resultCouponVipID = vcmBll.Query(wheresOrderNo.ToArray(), null);

                    var couponTypeInfo = couponTypeBll.GetByID(couponEntity.CouponTypeID);
                    if (couponTypeInfo != null)
                    {
                        if (couponTypeInfo.SuitableForStore == 2)//下面的doorid传的是门店的id,如果等于1所有门店都能用,如果等于3所有分销商都能用
                        {
                            var couponTypeUnitMapping = mappingBll.QueryByEntity(new CouponTypeUnitMappingEntity()
                            {
                                CouponTypeID = new Guid(couponEntity.CouponTypeID.ToString()), ObjectID = reqObj.Parameters.doorID
                            }, null).FirstOrDefault();

                            if (couponTypeUnitMapping == null)
                            {
                                respData.ResultCode = "104";
                                respData.Message    = "请到指定门店/分销商使用";
                                return(respData.ToJSON());
                            }
                        }
                        if (couponTypeInfo.SuitableForStore == 3)//下面的doorid传的是门店的id,如果等于1所有门店都能用,如果等于3所有分销商都能用
                        {
                            //doorid必须是获取,分销商如果没数据,就报错。
                            RetailTraderBLL    _RetailTraderBLL = new RetailTraderBLL(loggingSessionInfo);
                            RetailTraderEntity en = _RetailTraderBLL.GetByID(reqObj.Parameters.doorID);
                            if (en == null)
                            {
                                respData.ResultCode = "104";
                                respData.Message    = "请到指定分销商使用";
                                return(respData.ToJSON());
                            }
                        }
                        if (couponTypeInfo.SuitableForStore == 1)//下面的doorid传的是门店的id,如果等于1所有门店都能用,如果等于3所有分销商都能用
                        {
                            //doorid必须是获取,门店如果没有数据,就报错。
                            TUnitBLL    _TUnitBLL = new TUnitBLL(loggingSessionInfo);
                            TUnitEntity en        = _TUnitBLL.GetByID(reqObj.Parameters.doorID);
                            if (en == null)
                            {
                                respData.ResultCode = "104";
                                respData.Message    = "请到指定门店使用";
                                return(respData.ToJSON());
                            }
                        }

                        int res = bll.BestowCoupon(couponEntity.CouponID, reqObj.Parameters.doorID);
                        if (res > 0) //如果没有影响一行,所以Coupon表里这条记录的status=1了,不能被使用了。
                        {
                            InoutService server = new InoutService(loggingSessionInfo);
                            var          tran   = server.GetTran();
                            using (tran.Connection)//事务
                            {
                                #region 优惠券使用记录
                                var couponUseEntity = new CouponUseEntity()
                                {
                                    CouponID = couponEntity.CouponID,
                                    VipID    = resultCouponVipID.Length == 0 ? "" : resultCouponVipID[0].VIPID,
                                    UnitID   = reqObj.Parameters.doorID,
                                    //OrderID = orderEntity.OrderID.ToString(),
                                    //CreateBy = reqObj.userId,
                                    Comment    = "核销电子券",
                                    CustomerID = reqObj.customerId
                                };
                                couponUseBll.Create(couponUseEntity);//生成优惠券使用记录
                                #endregion

                                //#region 修改优惠券数量   2016-06-03 使用了redis不用在这里更新数量
                                //couponTypeInfo.IsVoucher = couponTypeInfo.IsVoucher == null ? 1 : couponTypeInfo.IsVoucher + 1;
                                //couponTypeBll.Update(couponTypeInfo, tran);
                                //#endregion

                                respData.ResultCode = "200";
                                respData.Message    = "优惠劵使用成功";

                                tran.Commit();
                            }
                        }
                        else
                        {
                            respData.ResultCode = "103";
                            respData.Message    = "优惠劵已使用";
                        }
                    }
                }
                else
                {
                    respData.ResultCode = "104";
                    respData.Message    = "没有找到对应券。";
                    return(respData.ToJSON());
                }
            }
            catch (Exception)
            {
                respData.ResultCode = "103";
                respData.Message    = "数据库操作失败";
            }
            return(respData.ToJSON());
        }
Exemplo n.º 17
0
        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());
        }
Exemplo n.º 18
0
 public TBusinessItemController()
 {
     this.bll     = new TBusinessItemBLL("MySQL", this.AreaNo);
     this.unitBll = new TUnitBLL("MySQL", this.AreaNo);
     this.busiBll = new TBusinessBLL("MySQL", this.AreaNo);
 }
Exemplo n.º 19
0
        public string Export(LoggingSessionInfo pLoggingSessionInfo, string pPath)
        {
            try
            {
                string customerID = pLoggingSessionInfo.ClientID;
                string userID     = pLoggingSessionInfo.CurrentUser.User_Id;

                ////下载保存获取本地路径
                //string localPath = string.Empty;
                //DownloadFile(pPath, "", out localPath);
                //pPath = localPath;

                string path = HttpContext.Current.Server.MapPath(@"~");
                pPath = path + pPath;

                #region 读取Excel数据并简单过滤
                System.IO.FileInfo exporstFile = new System.IO.FileInfo(pPath);
                if (!exporstFile.Exists)
                {
                    return("0|文件不存在");
                }

                //读取Excel
                DataTable excelTable = ExcelReader.ReadExcelToDataTable(pPath);

                //return "0|" + excelTable.Rows[0][0];

                //过滤空行
                DataRow[] drs     = excelTable.Select("邮箱<>''");
                DataTable dtClone = excelTable.Clone();
                foreach (var row in drs)
                {
                    dtClone.ImportRow(row);
                }
                #endregion

                #region 获取职衔、部门、角色
                DataView  _dv       = dtClone.DefaultView;
                DataTable jobFuncDT = _dv.ToTable(true, "职衔");
                DataTable deptDT    = _dv.ToTable(true, "部门");
                DataTable roleDT    = _dv.ToTable(true, "角色");
                #endregion

                #region 职衔验证
                var jobFuncBll  = new JobFunctionBLL(pLoggingSessionInfo);
                var jobFuncList = jobFuncBll.Query(new IWhereCondition[]
                {
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "CustomerID", Value = customerID
                    },
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "IsDelete", Value = "0"
                    },
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "Status", Value = "1"
                    }
                },
                                                   null);
                foreach (DataRow row in jobFuncDT.Rows)
                {
                    if (row["职衔"] == null || string.IsNullOrEmpty(row["职衔"].ToString()))
                    {
                        continue;
                    }
                    int count = jobFuncList.Count(job => job.Name == row["职衔"].ToString().Trim());
                    if (count <= 0)
                    {
                        JobFunctionEntity entity = new JobFunctionEntity
                        {
                            Name          = row["职衔"].ToString().Trim(),
                            Description   = "",
                            JobFunctionID = Guid.NewGuid(),
                            Status        = 1,
                            IsDelete      = 0,
                            CustomerID    = customerID
                        };
                        jobFuncBll.Create(entity);
                        //return "0|职衔不存在";
                    }
                }
                #endregion

                #region 部门验证
                string   typeID   = System.Configuration.ConfigurationManager.AppSettings["TypeID"].ToString();
                TUnitBLL deptBll  = new TUnitBLL(pLoggingSessionInfo);
                var      deptList = deptBll.Query(new IWhereCondition[]
                {
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "customer_id", Value = customerID
                    },
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "type_id", Value = typeID
                    },
                    new EqualsCondition {
                        DateTimeAccuracy = null, FieldName = "Status", Value = "1"
                    }
                },
                                                  null);
                foreach (DataRow row in deptDT.Rows)
                {
                    if (row["部门"] == null || string.IsNullOrEmpty(row["部门"].ToString()))
                    {
                        continue;
                    }
                    int count = deptList.Count(dept => dept.UnitName == row["部门"].ToString().Trim());
                    if (count <= 0)
                    {
                        TUnitEntity unitEntity = new TUnitEntity
                        {
                            UnitID        = Guid.NewGuid().ToString().Replace("-", ""),
                            UnitName      = row["部门"].ToString().Trim(),
                            UnitCode      = "1",
                            UnitContact   = "",
                            UnitRemark    = "",
                            TypeID        = typeID,
                            CreateTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            CreateUserID  = pLoggingSessionInfo.CurrentUser.User_Id,
                            ModifyTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            ModifyUserID  = pLoggingSessionInfo.CurrentUser.User_Id,
                            CustomerID    = pLoggingSessionInfo.CurrentUser.customer_id,
                            CUSTOMERLEVEL = 0,
                            Status        = "1",
                            StatusDesc    = "正常",
                            IfFlag        = "1"
                        };
                        deptBll.Create(unitEntity);
                        //return "0|部门不存在";
                    }
                }
                #endregion

                #region 角色验证
                RoleService       rs       = new RoleService(pLoggingSessionInfo);
                IList <RoleModel> roleList = rs.GetAllRoles();
                foreach (DataRow row in roleDT.Rows)
                {
                    if (row["角色"] == null || string.IsNullOrEmpty(row["角色"].ToString()))
                    {
                        continue;
                    }
                    int count = roleList.Count(role => role.Role_Name == row["角色"].ToString().Trim());
                    if (count <= 0)
                    {
                        return("0|角色不存在");
                    }
                }
                #endregion

                return(ExportData(customerID, pLoggingSessionInfo, dtClone, jobFuncList, deptList, roleList));
            }
            catch (Exception ex)
            {
                return("0|" + ex.Message);
            }
        }
 public TBusinessAttributeController()
 {
     this.bll     = new TBusinessAttributeBLL(this.AreaNo);
     this.unitBll = new TUnitBLL(this.AreaNo);
     this.busiBll = new TBusinessBLL(this.AreaNo);
 }
Exemplo n.º 21
0
 public TUnitController()
 {
     this.bll = new TUnitBLL("MySQL", this.AreaNo);
 }