/// <summary> /// /// </summary> public string SaveTags() { var service = new VipTagsMappingBLL(this.CurrentUserInfo); string content = string.Empty; string error = ""; var responseData = new ResponseData(); string key = string.Empty; string MappingId = string.Empty; var item = Request("item"); if (FormatParamValue(item) != null && FormatParamValue(item) != string.Empty) { key = FormatParamValue(item).ToString().Trim(); } if (FormatParamValue(Request("MappingId")) != null && FormatParamValue(Request("MappingId")) != string.Empty) { MappingId = FormatParamValue(Request("MappingId")).ToString().Trim(); } var tagsEntity = key.DeserializeJSONTo <VipTagsMappingEntity>(); if (tagsEntity.TagsId == null || tagsEntity.TagsId.Trim().Length == 0) { responseData.success = false; responseData.msg = "TagsId不能为空"; return(responseData.ToJSON()); } if (tagsEntity.VipId == null || tagsEntity.VipId.Trim().Length == 0) { responseData.success = false; responseData.msg = "VipId不能为空"; return(responseData.ToJSON()); } if (MappingId == null || MappingId.Trim().Length == 0) { tagsEntity.MappingId = Utils.NewGuid(); tagsEntity.CreateBy = CurrentUserInfo.CurrentUser.User_Id; tagsEntity.CreateTime = DateTime.Now; tagsEntity.LastUpdateBy = CurrentUserInfo.CurrentUser.User_Id; tagsEntity.LastUpdateTime = DateTime.Now; service.Create(tagsEntity); } else { tagsEntity.MappingId = MappingId; tagsEntity.LastUpdateBy = CurrentUserInfo.CurrentUser.User_Id; tagsEntity.LastUpdateTime = DateTime.Now; service.Update(tagsEntity, false); } responseData.success = true; responseData.msg = error; content = responseData.ToJSON(); return(content); }
protected override SetVipCardRD ProcessRequest(DTO.Base.APIRequest <OpenVipCardRP> pRequest) { var rd = new SetVipCardRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; //登录状态信息 var vipBLL = new VipBLL(loggingSessionInfo); //会员业务对象实例化 var vipTagsMappingBLL = new VipTagsMappingBLL(loggingSessionInfo); //会员和标签关系业务对象实例化 var vipCardBLL = new VipCardBLL(loggingSessionInfo); //会员卡业务对象实例化 var vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); //会员和会员卡关系业务对象实例化 var vipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo); //会员卡状态变更业务对象实例化 var vipAddressBLL = new VipAddressBLL(loggingSessionInfo); //会员地址信息业务对象实例化 var pTran = vipCardBLL.GetTran(); //事务 using (pTran.Connection) { try { //创建会员信息 var vipEntity = new VipEntity() { VIPID = Guid.NewGuid().ToString().Replace("-", ""), VipName = para.VipName, VipRealName = para.VipName, //VipCode = "Vip" + vipBLL.GetNewVipCode(loggingSessionInfo.ClientID), //获取会员编号 VipCode = para.VipCardCode, //会员卡号 CouponInfo = loggingSessionInfo.CurrentUserRole.UnitId, //原会集店字段 MembershipStore = loggingSessionInfo.CurrentUserRole.UnitId, //新增的会集店字段 Phone = para.Phone, Birthday = para.Birthday, Gender = para.Gender, Email = para.Email, Col18 = para.IDCard, //身份证 Status = 2, //已注册状态 VipSourceId = "20", //来源开卡 ClientID = loggingSessionInfo.ClientID }; vipBLL.Create(vipEntity, pTran); //保存年龄段标签 var vipTagsMappingEntity = new VipTagsMappingEntity() { MappingId = Guid.NewGuid().ToString().Replace("-", ""), VipId = vipEntity.VIPID, TagsId = para.TagsID }; vipTagsMappingBLL.Create(vipTagsMappingEntity, pTran); //保存会员地址信息 //var vipAddressEntity = new VipAddressEntity() //{ // VIPID = vipEntity.VIPID, // LinkMan = para.VipName, // LinkTel = para.Phone, // CityID = para.CityID, // Address = para.Address, // IsDefault = 1 //}; //vipAddressBLL.Create(vipAddressEntity, pTran); //更新会员卡信息 var vipCardEntity = vipCardBLL.GetByID(para.VipCardID); if (vipCardEntity != null) { #region 返回卡ID rd.VipCardID = vipCardEntity.VipCardID; #endregion //vipCardEntity.VipCardStatusId = 1; if (!string.IsNullOrEmpty(vipCardEntity.MembershipUnit)) { throw new APIException("此会员卡已绑定会员") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (vipCardEntity.VipCardStatusId > 0) { throw new APIException("此会员卡状态异常") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; vipCardEntity.MembershipTime = DateTime.Now; vipCardEntity.MembershipUnit = loggingSessionInfo.CurrentUserRole.UnitId; vipCardEntity.IsGift = para.IsGift; //vipCardEntity.SalesUserId = para.SalesUserId; vipCardEntity.SalesUserName = para.SalesUserName; //用户输入名称,后期需要根据姓名查找用户ID,更新到SalesUserId vipCardEntity.CreateBy = loggingSessionInfo.UserID; //开卡人,即入会员工 vipCardBLL.Update(vipCardEntity, pTran); } else { throw new APIException("查不到此会员卡") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } }; //新增会员卡操作状态信息 var vipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = vipCardEntity.VipCardStatusId, VipCardID = para.VipCardID, Action = "开卡", //Reason = "", UnitID = loggingSessionInfo.CurrentUserRole.UnitId, CustomerID = loggingSessionInfo.ClientID }; vipCardStatusChangeLogBLL.Create(vipCardStatusChangeLogEntity, pTran); //绑定会员卡和会员 var vipCardVipMappingEntity = new VipCardVipMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), VIPID = vipEntity.VIPID, VipCardID = para.VipCardID, CustomerID = loggingSessionInfo.ClientID }; vipCardVipMappingBLL.Create(vipCardVipMappingEntity, pTran); pTran.Commit(); //提交事物 } catch (APIException apiEx) { pTran.Rollback();//回滚事物 throw new APIException(apiEx.ErrorCode, apiEx.Message); } catch (Exception ex) { pTran.Rollback();//回滚事物 throw new Exception(ex.Message); } } return(rd); }
public string SetVipTags(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <SetVipTagsRP> >(); LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID); var rd = new SetVipTagsRD();//返回值 if (string.IsNullOrEmpty(rp.Parameters.VIPID)) { throw new APIException("缺少参数【VIPID】或参数值为空") { ErrorCode = 135 }; } VipTagsMappingBLL _VipTagsMappingBLL = new VipTagsMappingBLL(loggingSessionInfo); TagsBLL _TagsBLL = new TagsBLL(loggingSessionInfo); //删除之前该会员的标签 //ItemCategoryMappingBLL itemCategoryMappingBLL=new itemCategoryMappingBLL() // itemCategoryMappingBLL.DeleteByItemID(rp.Parameters.VIPID); _VipTagsMappingBLL.DeleteByVipID(rp.Parameters.VIPID); //这里不应该删除之前的促销分组,而应该根据商品的id和促销分组的id找一找,如果有isdelete=0的,就不要加,没有就加 foreach (var tagsInfo in rp.Parameters.IdentityTagsList) { //如果该标签的id为空//创建一条记录 if (string.IsNullOrEmpty(tagsInfo.TagsId)) { TagsEntity en = new TagsEntity(); en.TagsId = Guid.NewGuid().ToString(); en.TagsName = tagsInfo.TagsName; en.TagsDesc = tagsInfo.TagsName; en.CreateTime = DateTime.Now; en.CreateBy = rp.UserID; en.LastUpdateTime = DateTime.Now; en.LastUpdateBy = rp.UserID; en.IsDelete = 0; en.CustomerId = rp.CustomerID; // en.TypeId _TagsBLL.Create(en); tagsInfo.TagsId = en.TagsId;// } //创建vip的年龄标签 VipTagsMappingEntity TagsEn = new VipTagsMappingEntity(); TagsEn.MappingId = Guid.NewGuid().ToString(); TagsEn.VipId = rp.Parameters.VIPID; TagsEn.TagsId = tagsInfo.TagsId;//标签的id TagsEn.CreateTime = DateTime.Now; TagsEn.CreateBy = rp.UserID; TagsEn.LastUpdateTime = DateTime.Now; TagsEn.LastUpdateBy = rp.UserID; TagsEn.IsDelete = 0; _VipTagsMappingBLL.Create(TagsEn); } var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }