Пример #1
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());
        }
        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());
        }
Пример #3
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());
        }
Пример #4
0
 public void Update(TUnitEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField, pTran);
 }
Пример #5
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);
            }
        }
Пример #6
0
 /// <summary>
 /// 在事务内创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Create(TUnitEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Create(pEntity, pTran);
 }
Пример #7
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(TUnitEntity pEntity, IDbTransaction pTran)
 {
     Update(pEntity, true, pTran);
 }
Пример #8
0
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <TUnitEntity> PagedQueryByEntity(TUnitEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
Пример #9
0
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(TUnitEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
Пример #10
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Delete(TUnitEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Delete(pEntity, pTran);
 }
Пример #11
0
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public TUnitEntity[] QueryByEntity(TUnitEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
Пример #12
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(TUnitEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
Пример #13
0
 public void Update(TUnitEntity pEntity, bool pIsUpdateNullField)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField);
 }
Пример #14
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(TUnitEntity pEntity)
 {
     Update(pEntity, true);
 }
Пример #15
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());
        }
Пример #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());
        }