Example #1
0
        public string GetRetailTraderByID(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <RetailTraderLoginRP> >();

            if (rp.Parameters.RetailTraderID == null)
            {
                throw new APIException("缺少参数【RetailTraderID】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var bll = new RetailTraderBLL(loggingSessionInfo);
            var rd  = new SaveRetailTraderRD();

            var rsp = new SuccessResponse <IAPIResponseData>(rd);
            //获取分销商的信息,包括头像等loggingSessionInfo.ClientID
            var ds = bll.getRetailTraderInfoByLogin("", rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID);
            var retailTraderInfo = new RetailTraderInfo();

            //判断账号是否存在
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                var tempDt = ds.Tables[0];
                retailTraderInfo = DataTableToObject.ConvertToObject <RetailTraderInfo>(tempDt.Rows[0]);//直接根据所需要的字段反序列化
            }



            //正确时返回分销商数据
            rd.RetailTraderInfo = retailTraderInfo;//分销商

            //获取奖励规则
            SysRetailRewardRuleEntity[] ruleList = null;
            SysRetailRewardRuleBLL      _SysRetailRewardRuleBLL = new SysRetailRewardRuleBLL(loggingSessionInfo);
            //先看该分销商自己是否有奖励规则
            SysRetailRewardRuleEntity en = new SysRetailRewardRuleEntity();

            en.IsTemplate     = 0;
            en.CooperateType  = retailTraderInfo.CooperateType;
            en.RetailTraderID = rp.Parameters.RetailTraderID;
            en.CustomerId     = rp.CustomerID;
            en.IsDelete       = 0;
            //获取奖励模板
            ruleList = _SysRetailRewardRuleBLL.QueryByEntity(en, null);


            //  SysRetailRewardRuleEntity en = new SysRetailRewardRuleEntity();
            if (ruleList == null || ruleList.Count() == 0)
            {
                SysRetailRewardRuleEntity en2 = new SysRetailRewardRuleEntity();
                en2.IsTemplate    = 1;
                en2.CooperateType = retailTraderInfo.CooperateType;
                en2.IsDelete      = 0;
                en2.CustomerId    = rp.CustomerID;                           //加上这个,否则多个客户的奖励规则一起取了
                //获取奖励模板
                ruleList = _SysRetailRewardRuleBLL.QueryByEntity(en2, null); //这里不能用en了,用en会包含之前的RetailTraderID属性了
            }

            StringBuilder sb = new StringBuilder("");

            if (ruleList != null || ruleList.Count() != 0)
            {
                for (int i = 0; i < ruleList.Count(); i++)
                {
                    if (ruleList[i].RetailTraderReward > 0)
                    {
                        sb.Append(ruleList[i].RewardTypeName);
                        int temp = (int)ruleList[i].RetailTraderReward;//判断一下小数点后面是不是0,如果是0,就不要了
                        if (ruleList[i].RetailTraderReward > temp)
                        {
                            sb.Append(ruleList[i].RetailTraderReward);
                        }
                        else
                        {
                            sb.Append(temp);
                        }
                        if (ruleList[i].AmountOrPercent == 1)
                        {
                            sb.Append("元");
                        }
                        else
                        {
                            sb.Append("%");
                        }
                        if (ruleList[i].RewardTypeCode == "AttentThreeMonth")
                        {
                            sb.Append("(不包含首笔交易)");
                        }
                        sb.Append(",");
                    }
                }
                if (sb.ToString() != "")
                {
                    sb.Replace(',', '。', sb.Length - 1, 1);
                }
            }
            else
            {
                if (retailTraderInfo.CooperateType == "TwoWay")
                {
                    sb.Append(retailTraderInfo.UnitName).Append("门店帮您发放优惠券,也可向您的门店带来潜在的顾客。 ");
                }
            }



            rd.RewardNotic = sb.ToString();//奖励规则说明



            return(rsp.ToJSON());
        }
Example #2
0
        public string RetailTraderLogin(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <RetailTraderLoginRP> >();

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

            if (rp.Parameters.RetailTraderLogin == null)
            {
                throw new APIException("缺少参数【RetailTraderLogin】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            if (rp.Parameters.RetailTraderPass == null)
            {
                throw new APIException("缺少参数【RetailTraderPass】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            // var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");

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

            //if (string.IsNullOrEmpty(customerId))
            //{
            //    throw new APIException("客户代码对应的客户不存在") { ErrorCode = Error_CustomerCode_NotExist };
            //}


            var bll2 = new RetailTraderBLL(Default.GetAPLoggingSession(""));//用空的登陆信息去查

            var ds = bll2.getRetailTraderInfoByLogin2(rp.Parameters.RetailTraderLogin, "", "");
            var retailTraderInfo = new RetailTraderInfo();


            var    rd         = new SaveRetailTraderRD();
            var    rsp        = new SuccessResponse <IAPIResponseData>(rd);
            string customerId = "";

            //判断账号是否存在
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                var tempDt = ds.Tables[0];
                retailTraderInfo = DataTableToObject.ConvertToObject <RetailTraderInfo>(tempDt.Rows[0]);//直接根据所需要的字段反序列化

                customerId = retailTraderInfo.CustomerId;
            }
            else
            {
                rsp.Message    = "登陆名不存在";
                rsp.ResultCode = 136;
                return(rsp.ToJSON());
            }



            var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");
            var bll = new RetailTraderBLL(loggingSessionInfo);



            //获取分销商的信息,包括头像等loggingSessionInfo.ClientID
            ds = bll.getRetailTraderInfoByLogin(rp.Parameters.RetailTraderLogin, "", loggingSessionInfo.ClientID);
            retailTraderInfo = new RetailTraderInfo();
            //判断账号是否存在
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                var tempDt = ds.Tables[0];
                retailTraderInfo = DataTableToObject.ConvertToObject <RetailTraderInfo>(tempDt.Rows[0]);//直接根据所需要的字段反序列化
            }
            else
            {
                rsp.Message    = "登陆名不存在";
                rsp.ResultCode = 136;
                return(rsp.ToJSON());
            }
            //判断密码是否正确
            if (retailTraderInfo.RetailTraderPass != rp.Parameters.RetailTraderPass)
            {
                rsp.Message    = "登陆密码不正确";
                rsp.ResultCode = 136;
                return(rsp.ToJSON());
            }
            //判断密码是否正确
            //if (retailTraderInfo.Status != "1")
            //{
            //    rsp.Message = "该分销商账号已经被停用";
            //    rsp.ResultCode = 136;
            //    return rsp.ToJSON();
            //}


            //正确时返回分销商数据
            rd.RetailTraderInfo = retailTraderInfo;


            return(rsp.ToJSON());
        }
Example #3
0
        public string SaveRetailTrader(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SaveRetailTraderRP> >();

            if (rp.Parameters.RetailTraderInfo == null)
            {
                throw new APIException("缺少参数【RetailTraderInfo】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            if (rp.Parameters.IsNewHeadImg == null)
            {
                throw new APIException("缺少参数【IsNewHeadImg】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var bll = new RetailTraderBLL(loggingSessionInfo);
            var rd  = new SaveRetailTraderRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);
            //判断登陆名是否有重复的,要从ap库里取
            var ds = bll.getRetailTraderInfoByLogin2(rp.Parameters.RetailTraderInfo.RetailTraderLogin, "", loggingSessionInfo.ClientID);
            var retailTraderInfo = new RetailTraderInfo();

            //判断账号是否存在
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                var tempDt = ds.Tables[0];
                retailTraderInfo = DataTableToObject.ConvertToObject <RetailTraderInfo>(tempDt.Rows[0]); //直接根据所需要的字段反序列化
                if (retailTraderInfo.RetailTraderID != rp.Parameters.RetailTraderInfo.RetailTraderID)    //如果取出来的实体的id和传过来的参数的id不一样,说明不是同一个实体
                {
                    rsp.Message    = "该登陆账号已经存在,不能重复使用";
                    rsp.ResultCode = 137;
                    return(rsp.ToJSON());//这里要返回
                }
            }


            //从RetailTraderInfo转到RetailTraderEntity
            RetailTraderEntity en = new RetailTraderEntity();

            en.RetailTraderID = rp.Parameters.RetailTraderInfo.RetailTraderID;
            if (rp.Parameters.RetailTraderInfo.RetailTraderID == null || rp.Parameters.RetailTraderInfo.RetailTraderID.ToString() == "")
            {
                en.RetailTraderID = Guid.NewGuid().ToString();
                //获取当前最大的
                //如果是新增,则取本客户下的最大编号作为分销商编号
                en.RetailTraderCode = bll.getMaxRetailTraderCode(rp.CustomerID) + 1;

                en.CreateTime = DateTime.Now;
                en.CreateBy   = rp.UserID;
            }
            en.RetailTraderName  = rp.Parameters.RetailTraderInfo.RetailTraderName;
            en.RetailTraderLogin = rp.Parameters.RetailTraderInfo.RetailTraderLogin;
            if (!string.IsNullOrEmpty(rp.Parameters.RetailTraderInfo.RetailTraderPass))
            {
                en.RetailTraderPass = MD5Helper.Encryption(rp.Parameters.RetailTraderInfo.RetailTraderPass);
            }
            en.RetailTraderMan     = rp.Parameters.RetailTraderInfo.RetailTraderMan;
            en.RetailTraderPhone   = rp.Parameters.RetailTraderInfo.RetailTraderPhone;
            en.RetailTraderAddress = rp.Parameters.RetailTraderInfo.RetailTraderAddress;
            en.CooperateType       = rp.Parameters.RetailTraderInfo.CooperateType;
            en.SalesType           = rp.Parameters.RetailTraderInfo.SalesType;
            en.SellUserID          = rp.Parameters.RetailTraderInfo.SellUserID;
            en.UnitID = rp.Parameters.RetailTraderInfo.UnitID;
            en.Status = "1";//启用状态

            en.LastUpdateTime = DateTime.Now;
            en.LastUpdateBy   = rp.UserID;
            en.IsDelete       = 0;
            en.CustomerId     = rp.CustomerID;
            if (rp.Parameters.RetailTraderInfo.RetailTraderID == null || rp.Parameters.RetailTraderInfo.RetailTraderID.ToString() == "")
            {
                bll.Create(en);
                //  rp.Parameters.RetailTraderInfo.RetailTraderID = en.RetailTraderID;//为了返回数据时使用
            }
            else
            {
                bll.Update(en, null, false);//不更新空值的字段
            }
            //另外要保存到ap库里,这样才能登陆时从ap库里统一取出分销商信息,和对应的customerid
            if (rp.Parameters.RetailTraderInfo.RetailTraderID == null || rp.Parameters.RetailTraderInfo.RetailTraderID.ToString() == "")
            {
                bll.Create2Ap(en);                                                 //ap库里的RetailTraderID和商户里的RetailTraderID是一样的
                rp.Parameters.RetailTraderInfo.RetailTraderID = en.RetailTraderID; //为了返回数据时使用,到这里才赋值***
            }
            else
            {
                bll.Update2Ap(en, null, false);//不更新空值的字段
            }

            //如果IsNewHeadImg为1时,即上传图片时,则删除之前的关联图片(逻辑删除)
            if (rp.Parameters.IsNewHeadImg == 1)
            {
                ObjectImagesBLL    _ObjectImagesBLL = new ObjectImagesBLL(loggingSessionInfo);
                ObjectImagesEntity ObjectImagesEn   = new ObjectImagesEntity();

                _ObjectImagesBLL.DeleteByObjectID(en.RetailTraderID.ToString());
            }

            rd.RetailTraderInfo = rp.Parameters.RetailTraderInfo;


            return(rsp.ToJSON());
        }