/// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(CustomerBasicSettingEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(CustomerBasicSettingEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pTran);
 }
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public CustomerBasicSettingEntity[] QueryByEntity(CustomerBasicSettingEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <CustomerBasicSettingEntity> PagedQueryByEntity(CustomerBasicSettingEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
        public void setJiKeGift(string UserID, string vipID)
        {
            //如果扫码用户有上线会员就不给扫码奖励。
            VipDAO vipDao = new VipDAO(loggingSessionInfo);
            var    vip    = vipDao.QueryByEntity(
                new VipEntity()
            {
                VIPID = vipID
            },
                null
                ).FirstOrDefault();

            if (vip != null && !string.IsNullOrWhiteSpace(vip.CouponInfo))
            {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "集客反还积分:返回"
                });
                return;
            }

            ////查询集客奖励设置
            //int GiftIntegral = 0;

            //CustomerBasicSettingDAO CustomerBasicSettingDao = new CustomerBasicSettingDAO(loggingSessionInfo);
            //CustomerBasicSettingEntity CustomerBasicSettingEntity = CustomerBasicSettingDao.GetBasicSettings(UserID, "GetVipIntegral").FirstOrDefault();

            //if (CustomerBasicSettingEntity!=null&&!string.IsNullOrWhiteSpace(CustomerBasicSettingEntity.SettingValue))
            //{
            //    int.TryParse(CustomerBasicSettingEntity.SettingValue, out GiftIntegral);
            //}

            //if (GiftIntegral == 0)
            //{
            //    GiftIntegral = 100;
            //}

            ////积分换算为金额
            //decimal GiftAmount = GiftIntegral / 100;

            ////保存
            //VipAmountDAO VipAmountDao = new VipAmountDAO(loggingSessionInfo);
            //VipAmountDetailDAO VipAmountDetailDao = new VipAmountDetailDAO(loggingSessionInfo);


            //VipAmountEntity amountEntity = VipAmountDao.QueryByEntity(
            //        new VipAmountEntity()
            //        {
            //            VipId = UserID
            //        }
            //        , null
            //    ).FirstOrDefault();

            //if (amountEntity==null)
            //{
            //    VipAmountDao.Create(
            //        new VipAmountEntity(){
            //            VipId = UserID,
            //            BeginAmount = 0,
            //            EndAmount = GiftAmount,
            //            InAmount = GiftAmount,
            //            OutAmount = 0,
            //            IsLocking =0,
            //            TotalAmount = GiftAmount
            //        }
            //    );
            //}
            //else
            //{
            //    try
            //    {
            //        Loggers.Debug(new DebugLogInfo()
            //        {
            //            Message = "集客反积分:" + "集客信息有" + amountEntity.TotalAmount == null ? "00000" : amountEntity.TotalAmount.ToString()
            //        });

            //        amountEntity.TotalAmount = amountEntity.TotalAmount + GiftAmount;
            //        amountEntity.InAmount = amountEntity.InAmount + GiftAmount;
            //        amountEntity.EndAmount = amountEntity.EndAmount + GiftAmount;
            //        VipAmountDao.Update(amountEntity);
            //    }
            //    catch (Exception ex)
            //    {
            //        Loggers.Debug(new DebugLogInfo()
            //        {
            //            Message = "集客反还积分:" + ex.Message.ToString()
            //        }); ;
            //    }

            //}

            //VipAmountDetailDao.Create(
            //    new VipAmountDetailEntity(){
            //        VipAmountDetailId = Guid.NewGuid(),
            //        VipId = UserID,
            //        Amount = GiftAmount,
            //        AmountSourceId = "12",
            //        ObjectId = string.Empty,
            //        Remark ="集客反积分兑换为余额"
            //    }
            //);


            //查询集客奖励设置
            int GiftIntegral = 0;

            CustomerBasicSettingDAO    CustomerBasicSettingDao    = new CustomerBasicSettingDAO(loggingSessionInfo);
            CustomerBasicSettingEntity CustomerBasicSettingEntity = CustomerBasicSettingDao.GetBasicSettings(UserID, "GetVipIntegral").FirstOrDefault();

            if (CustomerBasicSettingEntity != null && !string.IsNullOrWhiteSpace(CustomerBasicSettingEntity.SettingValue))
            {
                int.TryParse(CustomerBasicSettingEntity.SettingValue, out GiftIntegral);
            }

            if (GiftIntegral == 0)
            {
                GiftIntegral = 100;
            }


            Loggers.Debug(new DebugLogInfo()
            {
                Message = "集客反还积分:得到积分" + GiftIntegral.ToString()
            });

            //保存
            VipIntegralDAO       VipIntegralDao       = new VipIntegralDAO(loggingSessionInfo);
            VipIntegralDetailDAO vipIntegralDetailDao = new VipIntegralDetailDAO(loggingSessionInfo);


            VipIntegralEntity integralEntity = VipIntegralDao.QueryByEntity(
                new VipIntegralEntity()
            {
                VipID = UserID
            }
                , null
                ).FirstOrDefault();

            if (integralEntity == null)
            {
                VipIntegralDao.Create(
                    new VipIntegralEntity()
                {
                    VipID           = UserID,
                    BeginIntegral   = GiftIntegral,
                    InIntegral      = GiftIntegral,
                    OutIntegral     = 0,
                    EndIntegral     = GiftIntegral,
                    InvalidIntegral = 0,
                    ValidIntegral   = 0,
                    IsDelete        = 0
                }
                    );
            }
            else
            {
                try
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "集客反积分:" + "集客信息有" + integralEntity.EndIntegral == null ? "00000" : integralEntity.EndIntegral.ToString()
                    });

                    integralEntity.BeginIntegral   += GiftIntegral;
                    integralEntity.InvalidIntegral += GiftIntegral;
                    integralEntity.EndIntegral     += GiftIntegral;
                    VipIntegralDao.Update(integralEntity);
                }
                catch (Exception ex)
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "集客反还积分:" + ex.Message.ToString()
                    });
                }
            }

            try
            {
                vipIntegralDetailDao.Create(
                    new VipIntegralDetailEntity()
                {
                    VipIntegralDetailID = Guid.NewGuid().ToString().Replace("-", ""),
                    VIPID            = UserID,
                    SalesAmount      = 0,
                    Integral         = GiftIntegral,
                    IntegralSourceID = "25",
                    IsDelete         = 0
                }
                    );
            }
            catch (Exception ex)
            {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "集客反还积分:" + ex.Message.ToString()
                });
            }
        }
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(CustomerBasicSettingEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
        /// <summary>
        /// 获取社会化销售配置和积分返现配置
        /// </summary>
        /// <param name="salesPrice"></param>
        /// <param name="channelId"></param>
        /// <returns></returns>
        public Hashtable GetSocialSetting()
        {
            //所有商户配置
            //var settingList =this._currentDAO.QueryByEntity(new CustomerBasicSettingEntity() { CustomerID = this.CurrentUserInfo.ClientID }, null);

            RedisOperationBLL.BasicSetting.BasicSettingBLL bllBasicSetting = new RedisOperationBLL.BasicSetting.BasicSettingBLL();
            var settingList = bllBasicSetting.GetBasicSetting(this.CurrentUserInfo.ClientID);

            if (settingList == null && settingList.Count == 0)
            {
                bllBasicSetting.SetBasicSetting(this.CurrentUserInfo.ClientID);
            }
            else
            {
                settingList = this._currentDAO.QueryByEntity(new CustomerBasicSettingEntity()
                {
                    CustomerID = this.CurrentUserInfo.ClientID
                }, null).ToList();
            }
            #region 社会化销售配置
            //社会化销售设置类型 0=按订单;1=按商品
            int socialSalesType        = 0;
            var socialSalesTypeSetting = settingList.Where(t => t.SettingCode == "SocialSalesType").FirstOrDefault();
            //启用员工分销设置(0=不启用;1=启用)
            int enableEmployeeSales = 0;
            CustomerBasicSettingEntity enableEmployeeSalesSetting = settingList.Where(t => t.SettingCode == "EnableEmployeeSales").FirstOrDefault();
            //员工的商品分销价比例
            decimal eDistributionPricePer = 0;
            CustomerBasicSettingEntity EDistributionPricePerSetting = settingList.Where(t => t.SettingCode == "EDistributionPricePer").FirstOrDefault();
            //启用会员分销设置(0=不启用;1=启用)
            int enableVipSales        = 0;
            var EnableVipSalesSetting = settingList.Where(t => t.SettingCode == "EnableVipSales").FirstOrDefault();
            //会员的商品分销价比例
            decimal vDistributionPricePer        = 0;
            var     VDistributionPricePerSetting = settingList.Where(t => t.SettingCode == "VDistributionPricePer").FirstOrDefault();
            //员工的订单金额提成比例
            decimal eOrderCommissionPer        = 0;
            var     eOrderCommissionPerSetting = settingList.Where(t => t.SettingCode == "EOrderCommissionPer").FirstOrDefault();
            //会员的订单金额提成比例
            decimal vOrderCommissionPer        = 0;
            var     vOrderCommissionPerSetting = settingList.Where(t => t.SettingCode == "VOrderCommissionPer").FirstOrDefault();

            if (socialSalesTypeSetting != null)
            {
                socialSalesType = int.Parse(socialSalesTypeSetting.SettingValue);
            }

            if (enableEmployeeSalesSetting != null)
            {
                enableEmployeeSales = int.Parse(enableEmployeeSalesSetting.SettingValue);
            }

            if (EDistributionPricePerSetting != null)
            {
                eDistributionPricePer = decimal.Parse(EDistributionPricePerSetting.SettingValue);
            }

            if (EnableVipSalesSetting != null)
            {
                enableVipSales = int.Parse(EnableVipSalesSetting.SettingValue);
            }

            if (VDistributionPricePerSetting != null)
            {
                vDistributionPricePer = decimal.Parse(VDistributionPricePerSetting.SettingValue);
            }

            if (eOrderCommissionPerSetting != null)
            {
                eOrderCommissionPer = decimal.Parse(eOrderCommissionPerSetting.SettingValue);
            }
            if (vOrderCommissionPerSetting != null)
            {
                vOrderCommissionPer = decimal.Parse(vOrderCommissionPerSetting.SettingValue);
            }
            #endregion

            #region 积分返现配置
            //奖励类型 0=按订单;1=按商品
            var rewardsTypeSetting = settingList.Where(t => t.SettingCode == "RewardsType").FirstOrDefault();
            //积分启用配置
            var enableIntegralSetting = settingList.Where(t => t.SettingCode == "EnableIntegral").FirstOrDefault();
            //返现启用配置
            var enableRewardCashSetting = settingList.Where(t => t.SettingCode == "EnableRewardCash").FirstOrDefault();
            //返回积分比例
            var rewardPointsPerSetting = settingList.Where(t => t.SettingCode == "RewardPointsPer").FirstOrDefault();
            //积分最低使用限制
            var pointsRedeemLowestLimitSetting = settingList.Where(t => t.SettingCode == "PointsRedeemLowestLimit").FirstOrDefault();
            //每单赠送积分上限
            var pointsOrderUpLimitSetting = settingList.Where(t => t.SettingCode == "PointsOrderUpLimit").FirstOrDefault();
            //返现比例
            var rewardCashPerSetting = settingList.Where(t => t.SettingCode == "RewardCashPer").FirstOrDefault();
            //返现最低使用限制
            var cashRedeemLowestLimitSetting = settingList.Where(t => t.SettingCode == "CashRedeemLowestLimit").FirstOrDefault();
            //每单返现上限
            var cashOrderUpLimitSetting = settingList.Where(t => t.SettingCode == "CashOrderUpLimit").FirstOrDefault();
            //积分使用上限比例
            var pointsRedeemUpLimitSetting = settingList.Where(t => t.SettingCode == "PointsRedeemUpLimit").FirstOrDefault();
            //返现使用上限比例
            var cashRedeemUpLimitSetting = settingList.Where(t => t.SettingCode == "CashRedeemUpLimit").FirstOrDefault();

            int     rewardsType             = 0;
            int     enableIntegral          = 0;
            int     enableRewardCash        = 0;
            decimal rewardPointsPer         = 0;
            decimal rewardCashPer           = 0;
            decimal pointsRedeemLowestLimit = 0;
            decimal cashRedeemLowestLimit   = 0;
            int     pointsOrderUpLimit      = 0;
            decimal cashOrderUpLimit        = 0;
            decimal pointsRedeemUpLimit     = 0;
            decimal cashRedeemUpLimit       = 0;


            if (rewardsTypeSetting != null)
            {
                rewardsType = int.Parse(rewardsTypeSetting.SettingValue);
            }
            if (enableIntegralSetting != null)
            {
                enableIntegral = int.Parse(enableIntegralSetting.SettingValue);
            }
            if (enableRewardCashSetting != null)
            {
                enableRewardCash = int.Parse(enableRewardCashSetting.SettingValue);
            }
            if (rewardPointsPerSetting != null)
            {
                rewardPointsPer = decimal.Parse(rewardPointsPerSetting.SettingValue);
            }
            if (rewardCashPerSetting != null)
            {
                rewardCashPer = decimal.Parse(rewardCashPerSetting.SettingValue);
            }
            if (pointsRedeemLowestLimitSetting != null)
            {
                pointsRedeemLowestLimit = decimal.Parse(pointsRedeemLowestLimitSetting.SettingValue);
            }
            if (cashRedeemLowestLimitSetting != null)
            {
                cashRedeemLowestLimit = decimal.Parse(cashRedeemLowestLimitSetting.SettingValue);
            }
            if (pointsOrderUpLimitSetting != null)
            {
                pointsOrderUpLimit = int.Parse(pointsOrderUpLimitSetting.SettingValue);
            }
            if (cashOrderUpLimitSetting != null)
            {
                cashOrderUpLimit = decimal.Parse(cashOrderUpLimitSetting.SettingValue);
            }
            if (pointsRedeemUpLimitSetting != null)
            {
                pointsRedeemUpLimit = decimal.Parse(pointsRedeemUpLimitSetting.SettingValue);
            }
            if (cashRedeemUpLimitSetting != null)
            {
                cashRedeemUpLimit = decimal.Parse(cashRedeemUpLimitSetting.SettingValue);
            }

            #endregion


            Hashtable htSetting = new Hashtable();
            htSetting["socialSalesType"]       = socialSalesType;
            htSetting["enableEmployeeSales"]   = enableEmployeeSales;
            htSetting["eDistributionPricePer"] = eDistributionPricePer;
            htSetting["enableVipSales"]        = enableVipSales;
            htSetting["vDistributionPricePer"] = vDistributionPricePer;
            htSetting["eOrderCommissionPer"]   = eOrderCommissionPer;
            htSetting["vOrderCommissionPer"]   = vOrderCommissionPer;

            htSetting["rewardsType"]             = rewardsType;
            htSetting["enableIntegral"]          = enableIntegral;
            htSetting["enableRewardCash"]        = enableRewardCash;
            htSetting["rewardPointsPer"]         = rewardPointsPer;
            htSetting["rewardCashPer"]           = rewardCashPer;
            htSetting["pointsRedeemLowestLimit"] = pointsRedeemLowestLimit;
            htSetting["cashRedeemLowestLimit"]   = cashRedeemLowestLimit;

            htSetting["pointsOrderUpLimit"] = pointsOrderUpLimit;
            htSetting["cashOrderUpLimit"]   = cashOrderUpLimit;

            htSetting["pointsRedeemUpLimit"] = pointsRedeemUpLimit;
            htSetting["cashRedeemUpLimit"]   = cashRedeemUpLimit;
            return(htSetting);
        }
Exemplo n.º 8
0
        /// <summary>
        ///保存送货到家配置信息
        /// </summary>
        /// <param name="DeliveryStrategyEntity"></param>
        /// <param name="BasicSettingEntity"></param>
        /// add by donal 2014-10-22 13:29:07
        public void SaveDeliveryStrategyAndBasicSetting(CustomerDeliveryStrategyEntity DeliveryStrategyEntity, CustomerBasicSettingEntity BasicSettingEntity, LoggingSessionInfo loggingSessionInfo, string deliveryId)
        {
            TransactionHelper tranHelper = new TransactionHelper(loggingSessionInfo);
            IDbTransaction    tran       = tranHelper.CreateTransaction();

            CustomerBasicSettingBLL basicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo);

            #region  除信息

            //此商户下送货到家信息
            CustomerDeliveryStrategyEntity[] DeliveryStrategyList = QueryByEntity(
                new CustomerDeliveryStrategyEntity
            {
                CustomerId = loggingSessionInfo.ClientID,
                DeliveryId = DeliveryStrategyEntity.DeliveryId
            },
                null
                );

            //此商户下基数设置(描述)信息
            CustomerBasicSettingEntity[] BasicSettingList = basicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity
            {
                SettingCode = "DeliveryStrategy",
                CustomerID  = loggingSessionInfo.ClientID
            },
                                                                                          null
                                                                                          );

            //除本次保存数据的此商户下送货到家信息
            CustomerDeliveryStrategyEntity[] DeliveryStrategyList_d = DeliveryStrategyList.Where(m => m.Id != DeliveryStrategyEntity.Id).ToArray();
            //除本次保存数据的此商户下基数设置(描述)信息
            CustomerBasicSettingEntity[] BasicSettingList_d = BasicSettingList.Where(m => m.SettingID != BasicSettingEntity.SettingID).ToArray();

            if (DeliveryStrategyList_d != null && DeliveryStrategyList_d.Count() > 0)
            {
                Delete(DeliveryStrategyList_d, tran);
            }
            if (BasicSettingList_d != null && BasicSettingList_d.Count() > 0)
            {
                basicSettingBLL.Delete(BasicSettingList_d, tran);
            }
            #endregion

            #region 保存

            if (DeliveryStrategyEntity.Id == null || string.IsNullOrWhiteSpace(DeliveryStrategyEntity.Id.ToString()))
            {
                DeliveryStrategyEntity.Id = Guid.NewGuid();
                Create(DeliveryStrategyEntity, tran);
            }
            else
            {
                Update(DeliveryStrategyEntity, tran);
            }

            if (BasicSettingEntity.SettingID == null || string.IsNullOrWhiteSpace(BasicSettingEntity.SettingID.ToString()))
            {
                BasicSettingEntity.SettingID = Guid.NewGuid();
                basicSettingBLL.Create(BasicSettingEntity, tran);
            }
            else
            {
                basicSettingBLL.Update(BasicSettingEntity, tran);
            }

            //修改配送方式状态
            DeliveryBLL deliveryBll = new DeliveryBLL(loggingSessionInfo);
            deliveryBll.Update(
                new DeliveryEntity()
            {
                DeliveryId = deliveryId,
                Status     = DeliveryStrategyEntity.Status
            }
                , tran
                );
            #endregion
            tran.Commit();
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 制卡
        /// </summary>
        /// <param name="p_Data"></param>
        public void BatchMakeVipCard(VipCardBatchEntity p_Data)
        {
            if (p_Data.Qty > 0)
            {
                SqlConnection sqlCon = new SqlConnection(CurrentUserInfo.CurrentLoggingManager.Connection_String);
                sqlCon.Open();
                SqlTransaction sqlTran = sqlCon.BeginTransaction(); // 开始事务
                SqlBulkCopy    sqlBC   = new SqlBulkCopy(sqlCon, SqlBulkCopyOptions.Default, sqlTran);
                sqlBC.DestinationTableName = "VipCard";
                sqlBC.BatchSize            = p_Data.Qty.Value;

                try
                {
                    #region 特殊值处理
                    //卡类型ID
                    int?CardTypeID = null;
                    var Result     = new SysVipCardTypeDAO(CurrentUserInfo).QueryByEntity(new SysVipCardTypeEntity()
                    {
                        VipCardTypeCode = p_Data.VipCardTypeCode
                    }, null);
                    if (Result.Length > 0)
                    {
                        CardTypeID = Result[0].VipCardTypeID;
                    }
                    if (CardTypeID == null)
                    {
                        throw new Exception("卡类型ID为null!");
                    }
                    #endregion

                    #region 获取卡号
                    int m_VipCardCode = int.Parse(p_Data.CardPrefix.Substring(p_Data.CardPrefix.Length - 1) + GetVipCardCode(CurrentUserInfo.ClientID));
                    #endregion

                    DataTable dataTable = new DataTable();
                    #region 列名
                    dataTable.Columns.Add("VipCardID");
                    dataTable.Columns.Add("VipCardTypeID", typeof(Int32));
                    dataTable.Columns.Add("VipCardGradeID", typeof(Int32));
                    dataTable.Columns.Add("VipCardCode");
                    dataTable.Columns.Add("VipCardISN");
                    dataTable.Columns.Add("VipCardName");
                    dataTable.Columns.Add("BatchNo");
                    dataTable.Columns.Add("VipCardStatusId", typeof(Int32));
                    dataTable.Columns.Add("MembershipTime", typeof(DateTime));
                    dataTable.Columns.Add("MembershipUnit");
                    dataTable.Columns.Add("BeginDate");
                    dataTable.Columns.Add("EndDate");
                    dataTable.Columns.Add("TotalAmount", typeof(decimal));
                    dataTable.Columns.Add("BalanceAmount", typeof(decimal));
                    dataTable.Columns.Add("BalancePoints", typeof(decimal));
                    dataTable.Columns.Add("BalanceBonus", typeof(decimal));
                    dataTable.Columns.Add("CumulativeBonus", typeof(decimal));
                    dataTable.Columns.Add("PurchaseTotalAmount", typeof(decimal));
                    dataTable.Columns.Add("PurchaseTotalCount", typeof(Int32));
                    dataTable.Columns.Add("CheckCode");
                    dataTable.Columns.Add("SingleTransLimit", typeof(decimal));
                    dataTable.Columns.Add("IsOverrunValid", typeof(Int32));
                    dataTable.Columns.Add("RechargeTotalAmount", typeof(decimal));
                    dataTable.Columns.Add("LastSalesTime", typeof(DateTime));
                    dataTable.Columns.Add("IsGift", typeof(Int32));
                    dataTable.Columns.Add("SalesAmount");
                    dataTable.Columns.Add("SalesUserId");
                    dataTable.Columns.Add("CreateTime", typeof(DateTime));
                    dataTable.Columns.Add("CreateBy");
                    dataTable.Columns.Add("LastUpdateTime", typeof(DateTime));
                    dataTable.Columns.Add("LastUpdateBy");
                    dataTable.Columns.Add("IsDelete", typeof(Int32));
                    dataTable.Columns.Add("CustomerID");
                    dataTable.Columns.Add("SalesUserName");
                    #endregion
                    for (int i = 0; i < p_Data.Qty; i++)
                    {
                        #region 属性赋值
                        DataRow dataRow = dataTable.NewRow();
                        dataRow["VipCardID"]           = System.Guid.NewGuid().ToString();
                        dataRow["VipCardTypeID"]       = CardTypeID.Value;
                        dataRow["VipCardGradeID"]      = DBNull.Value;
                        dataRow["VipCardCode"]         = p_Data.CardPrefix + m_VipCardCode.ToString();
                        dataRow["VipCardISN"]          = "";
                        dataRow["VipCardName"]         = "";
                        dataRow["BatchNo"]             = p_Data.BatchNo.Value.ToString();
                        dataRow["VipCardStatusId"]     = 0;
                        dataRow["MembershipTime"]      = DBNull.Value;
                        dataRow["MembershipUnit"]      = "";
                        dataRow["BeginDate"]           = "";
                        dataRow["EndDate"]             = "";
                        dataRow["TotalAmount"]         = 0;
                        dataRow["BalanceAmount"]       = 0;
                        dataRow["BalancePoints"]       = 0;
                        dataRow["BalanceBonus"]        = 0;
                        dataRow["CumulativeBonus"]     = 0;
                        dataRow["PurchaseTotalAmount"] = 0;
                        dataRow["PurchaseTotalCount"]  = 0;
                        dataRow["CheckCode"]           = "";
                        dataRow["SingleTransLimit"]    = 0;
                        dataRow["IsOverrunValid"]      = 0;
                        dataRow["RechargeTotalAmount"] = 0;
                        dataRow["LastSalesTime"]       = DBNull.Value;
                        dataRow["IsGift"]         = DBNull.Value;
                        dataRow["SalesAmount"]    = "";
                        dataRow["SalesUserId"]    = "";
                        dataRow["CreateTime"]     = DateTime.Now;
                        dataRow["CreateBy"]       = CurrentUserInfo.UserID;
                        dataRow["LastUpdateTime"] = DateTime.Now;
                        dataRow["LastUpdateBy"]   = CurrentUserInfo.UserID;
                        dataRow["IsDelete"]       = 0;
                        dataRow["CustomerID"]     = CurrentUserInfo.ClientID;
                        dataRow["SalesUserName"]  = "";
                        #endregion
                        //
                        dataTable.Rows.Add(dataRow);
                        m_VipCardCode++;
                    }

                    //执行
                    sqlBC.WriteToServer(dataTable); //此处报错
                    sqlTran.Commit();

                    #region 修改卡号配置数量
                    var m_CustomerBasicSettingDAO = new CustomerBasicSettingDAO(CurrentUserInfo);
                    var UpResult = m_CustomerBasicSettingDAO.QueryByEntity(new CustomerBasicSettingEntity()
                    {
                        SettingCode = "VipCardCode", CustomerID = CurrentUserInfo.ClientID
                    }, null);
                    if (UpResult.Length > 0)
                    {
                        CustomerBasicSettingEntity UpDate = UpResult[0];
                        string m_NewVipCardCode           = (m_VipCardCode - 1).ToString();
                        UpDate.SettingValue = m_NewVipCardCode.Substring(1, m_NewVipCardCode.Length - 1);
                        m_CustomerBasicSettingDAO.Update(UpDate);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    sqlTran.Rollback();
                    throw ex;
                }
                finally
                {
                    sqlBC.Close();
                    sqlCon.Close();
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 保存配送信息
        /// </summary>
        private string SaveDelivery(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <DeliveryInfoRp> >();
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            if (string.IsNullOrWhiteSpace(rp.Parameters.DeliveryId) ||
                (rp.Parameters.DeliveryId != "1" && rp.Parameters.DeliveryId != "2" && rp.Parameters.DeliveryId != "4"))
            {
                throw new APIException("请求参数中缺少DeliveryId或值为空.")
                      {
                          ErrorCode = 121
                      };
            }

            if (loggingSessionInfo == null)
            {
                throw new APIException("请重新登录")
                      {
                          ErrorCode = 122
                      };
            }

            if (rp.Parameters.DeliveryId == "1")
            //保存送货到家信息
            {
                CustomerDeliveryStrategyBLL deliveryStrategyBLL = new CustomerDeliveryStrategyBLL(loggingSessionInfo);
                CustomerBasicSettingBLL     basicSettingBLL     = new CustomerBasicSettingBLL(loggingSessionInfo);

                //if (rp.Parameters.AmountEnd<=0)
                //{
                //    throw new APIException("请求参数中AmountEnd值为空,或者不正确") { ErrorCode = 123 };
                //}
                //if (rp.Parameters.DeliveryAmount<=0)
                //{
                //    throw new APIException("请求参数中DeliveryAmount值为空,或者不正确") { ErrorCode = 124 };
                //}
                if (rp.Parameters.Status != 0 && rp.Parameters.Status != 1)
                {
                    throw new APIException("请求参数中Status值为空,或者不正确")
                          {
                              ErrorCode = 125
                          };
                }
                if (string.IsNullOrWhiteSpace(rp.Parameters.Description))
                {
                    throw new APIException("请求参数中Description值为空,或者不正确")
                          {
                              ErrorCode = 126
                          };
                }

                //要保存的送货到家信息
                CustomerDeliveryStrategyEntity DeliveryStrategyEntity = new CustomerDeliveryStrategyEntity()
                {
                    CustomerId     = loggingSessionInfo.ClientID,
                    AmountBegin    = 0m,
                    AmountEnd      = rp.Parameters.AmountEnd,
                    DeliveryAmount = rp.Parameters.DeliveryAmount,
                    Status         = rp.Parameters.Status,
                    DeliveryId     = "1"
                };

                if (!string.IsNullOrWhiteSpace(rp.Parameters.DeliveryStrategyId))
                {
                    DeliveryStrategyEntity.Id = new Guid(rp.Parameters.DeliveryStrategyId);
                }

                //要保存的基数设置(描述)信息
                CustomerBasicSettingEntity BasicSettingEntity = new CustomerBasicSettingEntity()
                {
                    CustomerID   = loggingSessionInfo.ClientID,
                    SettingCode  = "DeliveryStrategy",
                    SettingValue = rp.Parameters.Description
                };

                if (!string.IsNullOrWhiteSpace(rp.Parameters.SettingId))
                {
                    BasicSettingEntity.SettingID = new Guid(rp.Parameters.SettingId);
                }

                deliveryStrategyBLL.SaveDeliveryStrategyAndBasicSetting(DeliveryStrategyEntity, BasicSettingEntity, loggingSessionInfo, rp.Parameters.DeliveryId);
            }

            if (rp.Parameters.DeliveryId == "2" || rp.Parameters.DeliveryId == "4")
            //保存到店提货信息
            {
                //if (rp.Parameters.StockUpPeriod<=0)
                //{
                //    throw new APIException("请求参数中StockUpPeriod值为空,或者不正确") { ErrorCode = 127 };
                //}

                //if (rp.Parameters.BeginWorkTime==null)
                //{
                //     throw new APIException("请求参数中BeginWorkTime值为空,或者不正确") { ErrorCode = 127 };
                //}

                //if (rp.Parameters.EndWorkTime==null)
                //{
                //    throw new APIException("请求参数中EndWorkTime值为空,或者不正确") { ErrorCode = 127 };
                //}

                //if (rp.Parameters.MaxDelivery <= 0)
                //{
                //    throw new APIException("请求参数中MaxDelivery值为空,或者不正确") { ErrorCode = 127 };
                //}

                //if (rp.Parameters.Status!=1&&rp.Parameters.Status!=0)
                //{
                //    throw new APIException("请求参数中Status值为空,或者不正确") { ErrorCode = 127 };
                //}

                CustomerTakeDeliveryEntity takeDeliveryEntity = new CustomerTakeDeliveryEntity()
                {
                    CustomerId    = loggingSessionInfo.ClientID,
                    StockUpPeriod = rp.Parameters.StockUpPeriod,
                    BeginWorkTime = rp.Parameters.BeginWorkTime,
                    EndWorkTime   = rp.Parameters.EndWorkTime,
                    MaxDelivery   = rp.Parameters.MaxDelivery,
                    Status        = rp.Parameters.Status,
                    DeliveryId    = rp.Parameters.DeliveryId
                };

                #region 配送时间段

                SysTimeQuantumBLL      sysTimeQuantumBll         = new SysTimeQuantumBLL(loggingSessionInfo);
                SysTimeQuantumEntity[] sysTimeQuantumEntityArray = sysTimeQuantumBll.QueryByEntity(new SysTimeQuantumEntity()
                {
                    CustomerID = loggingSessionInfo.ClientID
                }, null);

                if (rp.Parameters.QuantumList.Count != 0)
                {
                    for (int i = 0; i < sysTimeQuantumEntityArray.Length; i++)
                    {
                        if (i < rp.Parameters.QuantumList.Count)
                        {
                            sysTimeQuantumEntityArray[i].Quantum = rp.Parameters.QuantumList[i].Quantum;
                            sysTimeQuantumBll.Update(sysTimeQuantumEntityArray[i]);
                        }
                        else
                        {
                            sysTimeQuantumBll.Delete(sysTimeQuantumEntityArray[i]);
                        }
                    }
                    if (sysTimeQuantumEntityArray.Length < rp.Parameters.QuantumList.Count)
                    {
                        for (int i = sysTimeQuantumEntityArray.Length; i < rp.Parameters.QuantumList.Count; i++)
                        {
                            SysTimeQuantumEntity sysTimeQuantumEntity = new SysTimeQuantumEntity()
                            {
                                QuantumID  = Guid.NewGuid().ToString(),
                                Quantum    = rp.Parameters.QuantumList[i].Quantum,
                                Type       = 10,
                                CustomerID = loggingSessionInfo.ClientID,
                                DeliveryId = rp.Parameters.DeliveryId
                            };
                            sysTimeQuantumBll.Create(sysTimeQuantumEntity);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < sysTimeQuantumEntityArray.Length; i++)
                    {
                        sysTimeQuantumBll.Delete(sysTimeQuantumEntityArray[i]);
                    }
                }
                #endregion

                if (!string.IsNullOrWhiteSpace(rp.Parameters.TakeDeliveryId))
                {
                    takeDeliveryEntity.Id = new Guid(rp.Parameters.TakeDeliveryId);
                }

                //查询提货配置信息
                CustomerTakeDeliveryBLL takeDeliveryBLL = new CustomerTakeDeliveryBLL(loggingSessionInfo);
                takeDeliveryBLL.SaveCustomerTakeDelivery(takeDeliveryEntity, loggingSessionInfo, rp.Parameters.DeliveryId);
            }

            var rsp = new SuccessResponse <IAPIResponseData>(new EmptyResponseData());
            return(rsp.ToJSON());
        }