public string SaveRetailTraderItemMapping(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <RetailTraderItemMappingRP> >(); var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); var bll = new RetailTraderItemMappingBLL(loggingSessionInfo); var rd = new EmptyRD(); var rsp = new SuccessResponse <IAPIResponseData>(rd); var itemService = new ItemService(loggingSessionInfo); var bllTrader = new RetailTraderBLL(loggingSessionInfo); var entityTrader = bllTrader.GetByID(rp.Parameters.RetailTraderId); entityTrader.SalesType = "Sales"; bllTrader.Update(entityTrader, null, false); bll.DeleteData(rp.Parameters.RetailTraderId); if (rp.Parameters.ItemList.Count() > 0) { foreach (var item in rp.Parameters.ItemList) { RetailTraderItemMappingEntity entityRTIM = new RetailTraderItemMappingEntity(); entityRTIM.ItemId = item.ItemId; entityRTIM.RetailTraderId = rp.Parameters.RetailTraderId; entityRTIM.CustomerID = rp.CustomerID; bll.Create(entityRTIM); itemService.CreateTraderQRCode(rp.CustomerID, item.ItemId, item.ItemName, rp.Parameters.RetailTraderId, entityRTIM.MappingId.ToString()); } } return(rsp.ToJSON()); }
public string ToggleRetailStatus(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <ToggleRetailStatusRP> >(); if (string.IsNullOrEmpty(rp.Parameters.RetailTraderID)) { throw new APIException("缺少参数【RetailTraderID】或参数值为空") { ErrorCode = 135 }; } if (string.IsNullOrEmpty(rp.Parameters.Status)) { throw new APIException("缺少参数【Status】或参数值为空") { ErrorCode = 135 }; } var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var bll = new RetailTraderBLL(loggingSessionInfo); RetailTraderEntity en = new RetailTraderEntity(); en.RetailTraderID = rp.Parameters.RetailTraderID; en.Status = rp.Parameters.Status; bll.Update(en, null, false); var rd = new EmptyRD(); var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }
//修改分销商密码 private string RetailSetPassWord(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <RetailSetPassWordRP> >(); var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); string pNewPass = MD5Helper.Encryption(rp.Parameters.pNewPWD); //pOldPWD = MD5Helper.Encryption(pOldPWD); rp.Parameters.pOldPWD = EncryptManager.Hash(rp.Parameters.pOldPWD, HashProviderType.MD5); //组装参数 var rd = new RetailSetPassWordRD(); var rsp = new SuccessResponse <IAPIResponseData>(rd); var serviceBll = new RetailTraderBLL(loggingSessionInfo); var entity = serviceBll.GetByID(rp.Parameters.pID);//获取分销商实体 //if (pOldPWD == entity.User_Password) if (rp.Parameters.pOldPWD == entity.RetailTraderPass) { entity.RetailTraderPass = pNewPass; entity.LastUpdateBy = "1"; entity.LastUpdateTime = DateTime.Now; //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error); serviceBll.Update(entity); rsp.Message = ""; } else { rsp.ResultCode = 135; rsp.Message = "旧密码不正确"; } return(rsp.ToJSON()); }
/// <summary> /// 用户接受协议成为分经销商 /// </summary> /// <param name="pRequest"></param> /// <returns></returns> public string SetPreRetailTraderToNomal(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <RetailTraderRP> >(); if (string.IsNullOrEmpty(rp.UserID)) { throw new APIException("缺少参数【UserID】或参数值为空") { ErrorCode = 135 }; } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); var RetailTraderBLL = new RetailTraderBLL(loggingSessionInfo); var VipBLL = new VipBLL(loggingSessionInfo); var Data = RetailTraderBLL.GetByID(rp.UserID); if (Data == null) { throw new APIException("参数【rp.Parameters.RetailTraderID】错误找不到对应经销商") { ErrorCode = 136 }; } var vipData = VipBLL.GetByID(Data.MultiLevelSalerFromVipId); if (vipData != null) { if (!string.IsNullOrWhiteSpace(vipData.SetoffUserId))//经销商二维码扫码关注的会员,成为经销商时,自动被集客 { DataSet ds = RetailTraderBLL.GetMultiLevelBeAddNode(vipData.SetoffUserId); if (ds.Tables[0].Rows.Count > 0) { Data.HigheRetailTraderID = ds.Tables[0].Rows[0]["BeAddNode"].ToString(); if (ds.Tables[0].Rows[0]["BeAddNodeFlag"] != DBNull.Value) { int Flag = Convert.ToInt32(ds.Tables[0].Rows[0]["BeAddNodeFlag"]); if (Flag == 1)//添加经销商拓展节点记录 { var T_HierarchySystemExNodeBLL = new T_HierarchySystemExNodeBLL(loggingSessionInfo); T_HierarchySystemExNodeBLL.AddHierarchySystemExNode(Data.RetailTraderID); } } } } } Data.Status = "1"; RetailTraderBLL.Update(Data); var response = new EmptyRD(); var rsp = new SuccessResponse <IAPIResponseData>(response); return(rsp.ToJSON()); }
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()); }
public string SaveRetailRewardRule(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <SaveRetailRewardRuleRP> >(); var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var bll = new SysRetailRewardRuleBLL(loggingSessionInfo); var rd = new SaveRetailRewardRuleRD(); var rsp = new SuccessResponse <IAPIResponseData>(rd); if (rp.Parameters.IsTemplate == null) { throw new APIException("缺少参数【IsTemplate】或参数值为空") { ErrorCode = 135 }; } //if (string.IsNullOrEmpty(rp.Parameters.CooperateType)) //{ // throw new APIException("缺少参数【CooperateType】或参数值为空") { ErrorCode = 135 }; //} if (rp.Parameters.IsTemplate == 0 && string.IsNullOrEmpty(rp.Parameters.RetailTraderID)) { throw new APIException("缺少参数【RetailTraderID】或参数值为空") { ErrorCode = 135 }; } if (rp.Parameters.SysRetailRewardRuleList == null) { throw new APIException("缺少参数【SysRetailRewardRuleList】或参数值为空") { ErrorCode = 135 }; } //如果是分销商,需要改变分销商的相关数据 RetailTraderBLL _RetailTraderBLL = new RetailTraderBLL(loggingSessionInfo); //先要删除相关的数据 //如果是模板的就设置该合作方式下的分销商的上次使用的相关数据为已经被删除isdelete=0 //如果是分销商,就删除该分销商下上次使用的相关数据。 //bll.UpdateSysRetailRewardRule(rp.Parameters.IsTemplate, rp.Parameters.CooperateType, rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID); if (rp.Parameters.IsTemplate == 0)//非模板时 { bll.UpdateSysRetailRewardRule(rp.Parameters.IsTemplate, "", "", rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID); RetailTraderEntity enRT = new RetailTraderEntity(); enRT.RetailTraderID = rp.Parameters.RetailTraderID; enRT.CooperateType = ""; //修改合作方式 enRT.SalesType = ""; //修改销售方式 _RetailTraderBLL.Update(enRT, null, false); //不更新空的 } else { bll.UpdateSysRetailRewardRule(rp.Parameters.IsTemplate, "", "", rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID); } //获取分销商的信息,loggingSessionInfo.ClientID foreach (var item in rp.Parameters.SysRetailRewardRuleList) { if (rp.Parameters.IsTemplate == 0 && !string.IsNullOrEmpty(rp.Parameters.RetailTraderID))// { if (item.CooperateType != "Sales") { RetailTraderEntity enRT = new RetailTraderEntity(); enRT.RetailTraderID = rp.Parameters.RetailTraderID; enRT.CooperateType = item.CooperateType; //修改合作方式 _RetailTraderBLL.Update(enRT, null, false); //不更新空的 } else { RetailTraderEntity enRT = new RetailTraderEntity(); enRT.RetailTraderID = rp.Parameters.RetailTraderID; enRT.SalesType = item.CooperateType; //修改销售方式 _RetailTraderBLL.Update(enRT, null, false); //不更新空的 } } SysRetailRewardRuleEntity en = new SysRetailRewardRuleEntity(); en.RetailRewardRuleID = Guid.NewGuid().ToString(); //每次都创建新的 en.CooperateType = item.CooperateType; //合作方式 en.RewardTypeName = item.RewardTypeName; en.RewardTypeCode = item.RewardTypeCode; en.IsTemplate = rp.Parameters.IsTemplate;//是否模板 en.SellUserReward = item.SellUserReward; en.RetailTraderReward = item.RetailTraderReward; en.ItemSalesPriceRate = (item.ItemSalesPriceRate == null ? 0 : item.ItemSalesPriceRate);//销售设置 en.AmountOrPercent = item.AmountOrPercent; en.CreateTime = DateTime.Now; en.CreateBy = loggingSessionInfo.UserID; en.LastUpdateTime = DateTime.Now; en.LastUpdateBy = loggingSessionInfo.UserID; if (item.CooperateType == "Sales" && item.ItemSalesPriceRate == 0) { en.Status = "0"; } else { en.Status = "1"; } en.IsDelete = 0; en.CustomerId = loggingSessionInfo.ClientID; en.BeginTime = DateTime.Now;//开始时间 en.EndTime = null; en.RetailTraderID = rp.Parameters.RetailTraderID; //如果是模板的就不要加 bll.Create(en); //保存奖励规则 } return(rsp.ToJSON()); }