/// <summary> /// 订单查询 /// </summary> public string SearchVipCard() { var form = Request("form").DeserializeJSONTo <VipCardEntity>(); VipCardBLL vipService = new VipCardBLL(CurrentUserInfo); VipCardEntity data = new VipCardEntity(); string content = string.Empty; //string order_no = FormatParamValue(form.order_no); //string sales_unit_id = ""; //string purchase_unit_id = ""; // purchase_unit_id = FormatParamValue(Request("purchase_unit_id")); //string order_status = FormatParamValue(form.order_status); int maxRowCount = PageSize; int startRowIndex = Utils.GetIntVal(FormatParamValue(Request("start"))); VipCardEntity searchInfo = new VipCardEntity(); searchInfo.VipCardCode = form.VipCardCode; searchInfo.VipName = form.VipName; searchInfo.maxRowCount = maxRowCount; searchInfo.startRowIndex = startRowIndex; searchInfo.VipCardStatusId = form.VipCardStatusId; searchInfo.VipCardGradeID = form.VipCardGradeID; data = vipService.SearchVipCard(searchInfo); content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}", data.VipCardInfoList.ToJSON(), data.ICount); return(content); }
/// <summary> /// /// </summary> public string GetVipCardInfoData() { var service = new VipCardBLL(CurrentUserInfo); string content = string.Empty; string key = string.Empty; if (Request("VipCardID") != null && Request("VipCardID") != string.Empty) { key = Request("VipCardID").ToString().Trim(); } VipCardEntity data = new VipCardEntity(); data = service.SearchTopVipCard(new VipCardEntity() { VipCardID = key }); string Lock = string.Empty; if (Request("Lock") != null && Request("Lock") != string.Empty) { Lock = Request("Lock").ToString().Trim(); if (Lock == "1") { LockVipCardInfoData(); } } content = data.ToJSON(); return(content); }
/// <summary> /// 批量处理变更 /// </summary> /// <param name="vipCardIds"></param> /// <param name="StatusIDNext"></param> /// <param name="strError"></param> /// <returns></returns> public bool SetVipCardStatusChangeBatch(string vipCardIds, int StatusIDNext, out string strError) { #region if (vipCardIds == null || vipCardIds.Trim().Equals("")) { strError = "会员卡号标识不能为空."; return(false); } if (StatusIDNext == 0 || StatusIDNext.ToString().Trim().Equals("")) { strError = "更改之后的状态标识不能为空."; return(false); } #endregion bool bReturn = true; string[] vipCardIdArr = vipCardIds.Split(','); VipCardBLL vipCardServer = new VipCardBLL(this.CurrentUserInfo); foreach (string id in vipCardIdArr) { VipCardEntity vipCardInfo = new VipCardEntity(); vipCardInfo = vipCardServer.GetByID(id); bReturn = SetVipCardStatusChange(id , Convert.ToInt32(vipCardInfo.VipCardStatusId) , StatusIDNext , this.CurrentUserInfo.CurrentUserRole.UnitId , out strError); if (!bReturn) { break; } } strError = "ok"; return(bReturn); }
/// <summary> /// 保存升降级记录 /// </summary> /// <param name="VipCardID">会员卡标识</param> /// <param name="ChangeBeforeGradeID">变动前等级</param> /// <param name="NowGradeID">最终卡等级</param> /// <param name="ChangeReason">变动原因</param> /// <param name="UnitID">操作门店</param> /// <param name="strError"></param> /// <returns></returns> public bool SetVipCardGradeChange(string VipCardID , int ChangeBeforeGradeID , int NowGradeID , string ChangeReason , string UnitID , out string strError) { try { #region if (VipCardID == null || VipCardID.Trim().Equals("")) { strError = "会员卡号标识不能为空."; return(false); } if (ChangeBeforeGradeID == 0 || ChangeBeforeGradeID.ToString().Trim().Equals("")) { strError = "变动前等级标识不能为空."; return(false); } if (NowGradeID == 0 || NowGradeID.ToString().Trim().Equals("")) { strError = "最终卡等级标识不能为空."; return(false); } if (UnitID == null || UnitID.Trim().Equals("")) { strError = "操作门店标识不能为空."; return(false); } #endregion #region 1.设置会员卡主信息的卡等级 VipCardEntity vipCardInfo = new VipCardEntity(); vipCardInfo.VipCardID = VipCardID; vipCardInfo.VipCardGradeID = NowGradeID; vipCardInfo.LastUpdateBy = this.CurrentUserInfo.UserID; vipCardInfo.LastUpdateTime = System.DateTime.Now; #endregion #region 2.设置卡等级变更记录 VipCardGradeChangeLogEntity vipCardGCInfo = new VipCardGradeChangeLogEntity(); vipCardGCInfo.ChangeLogID = JIT.CPOS.BS.BLL.BaseService.NewGuidPub(); vipCardGCInfo.VipCardID = VipCardID; vipCardGCInfo.ChangeBeforeGradeID = ChangeBeforeGradeID; vipCardGCInfo.NowGradeID = NowGradeID; vipCardGCInfo.ChangeReason = ChangeReason; vipCardGCInfo.ChangeTime = System.DateTime.Now; vipCardGCInfo.UnitID = UnitID; vipCardGCInfo.OperationUserID = this.CurrentUserInfo.UserID; vipCardGCInfo.OperationType = 2; vipCardGCInfo.CreateBy = this.CurrentUserInfo.UserID; vipCardGCInfo.LastUpdateBy = this.CurrentUserInfo.UserID; #endregion return(_currentDAO.SetVipCardStatusChange(vipCardInfo, vipCardGCInfo, out strError)); } catch (Exception ex) { strError = ex.ToString(); return(false); } }
internal void Delete(VipCardEntity dbEntity) { using (var conn = new SqlConnection(ConnectionString.XgxInsert)) { conn.Open(); conn.Delete(dbEntity); } }
internal void Create(VipCardEntity dbEntity) { using (var conn = new SqlConnection(ConnectionString.XgxInsert)) { dbEntity.CreateTime = System.DateTime.Now; dbEntity.LastUpdateTime = System.DateTime.Now; //dbEntity.CreateBy = "ERP"; conn.Open(); conn.Insert(dbEntity); } }
/// <summary> /// 状态变更 /// </summary> /// <param name="VipCardID">会员卡标识</param> /// <param name="StatusIDNow">当前状态标识</param> /// <param name="StatusIDNext">更改之后的状态标识</param> /// <param name="UnitID">门店标识</param> /// <param name="strError"></param> /// <returns></returns> public bool SetVipCardStatusChange(string VipCardID , int StatusIDNow , int StatusIDNext , string UnitID , out string strError ) { try { #region if (VipCardID == null || VipCardID.Trim().Equals("")) { strError = "会员卡号标识不能为空."; return(false); } if (StatusIDNow == 0 || StatusIDNow.ToString().Trim().Equals("")) { strError = "当前状态标识不能为空."; return(false); } if (StatusIDNext == 0 || StatusIDNext.ToString().Trim().Equals("")) { strError = "更改之后的状态标识不能为空."; return(false); } #endregion #region 1.获取修改会员卡状态信息 VipCardEntity vipCardInfo = new VipCardEntity(); vipCardInfo.VipCardID = VipCardID; vipCardInfo.VipCardStatusId = StatusIDNext; vipCardInfo.LastUpdateBy = this.CurrentUserInfo.UserID; vipCardInfo.LastUpdateTime = System.DateTime.Now; #endregion #region 2.设置状态变更记录 VipCardStatusChangeLogEntity statusChangeInfo = new VipCardStatusChangeLogEntity(); statusChangeInfo.LogID = JIT.CPOS.BS.BLL.BaseService.NewGuidPub(); statusChangeInfo.OldStatusID = StatusIDNow; statusChangeInfo.VipCardStatusID = StatusIDNext; statusChangeInfo.VipCardID = VipCardID; statusChangeInfo.CreateBy = CurrentUserInfo.UserID; statusChangeInfo.LastUpdateBy = this.CurrentUserInfo.UserID; statusChangeInfo.UnitID = UnitID; #endregion return(_currentDAO.SetVipCardStatusChange(vipCardInfo, statusChangeInfo, out strError)); } catch (Exception ex) { throw (ex); } }
/// <summary> /// 会员列表查询 /// </summary> /// <param name="searchInfo"></param> /// <returns></returns> public VipCardEntity SearchVipCard(VipCardEntity searchInfo) { VipCardEntity vipCardInfo = new VipCardEntity(); IList <VipCardEntity> vipCardInfoList = new List <VipCardEntity>(); vipCardInfo.ICount = _currentDAO.SearchVipCardCount(searchInfo); DataSet ds = _currentDAO.SearchVipCardList(searchInfo); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { vipCardInfoList = DataTableToObject.ConvertToList <VipCardEntity>(ds.Tables[0]); } vipCardInfo.VipCardInfoList = vipCardInfoList; return(vipCardInfo); }
/// <summary> /// 查询会员卡信息 /// </summary> public VipCardEntity SearchVipCardByVip(string vipid) { try { VipCardEntity vipCardInfo = new VipCardEntity(); DataSet ds = _currentDAO.SearchVipCardByVip(vipid); if (ds != null && ds.Tables[0].Rows.Count > 0) { vipCardInfo = DataTableToObject.ConvertToObject <VipCardEntity>(ds.Tables[0].Rows[0]); } return(vipCardInfo); } catch (Exception ex) { throw (ex); } }
/// <summary> /// 根据会员卡ID获取会员卡信息 /// </summary> public string GetVipCardByVipCardID() { var service = new VipCardBLL(CurrentUserInfo); var searchInfo = new VipCardEntity(); string content = string.Empty; if (Request("VipCardID") != "") { searchInfo.VipCardID = FormatParamValue(Request("VipCardID")); } int maxRowCount = PageSize; int startRowIndex = Utils.GetIntVal(FormatParamValue(Request("start"))); searchInfo.maxRowCount = maxRowCount; searchInfo.startRowIndex = startRowIndex; var data = service.SearchVipCard(searchInfo); content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}", data.VipCardInfoList.ToJSON(), data.ICount); return(content); }
public bool SetVipCardStatusChange(VipCardEntity vipCardInfo, VipCardGradeChangeLogEntity vipCardGCInfo, out string strError) { var tran = this.SQLHelper.CreateTransaction(); using (tran.Connection) { try { VipCardDAO vipCardDAO = new VipCardDAO(this.CurrentUserInfo); vipCardDAO.Update(vipCardInfo, tran); Create(vipCardGCInfo, tran); //TO-DO:实现自己的业务 tran.Commit(); strError = "卡等级变更成功."; return(true); } catch { //回滚&转抛异常 tran.Rollback(); throw; } } }
public bool SetVipCardRecjargeRpecord(VipCardEntity vipCardInfo, VipCardRechargeRecordEntity vipCardRRInfo, out string Error) { var tran = this.SQLHelper.CreateTransaction(); using (tran.Connection) { try { VipCardDAO vipCardDAO = new VipCardDAO(this.CurrentUserInfo); vipCardDAO.Update(vipCardInfo, tran); Create(vipCardRRInfo, tran); //TO-DO:实现自己的业务 tran.Commit(); Error = "充值成功."; return(true); } catch { //回滚&转抛异常 tran.Rollback(); throw; } } }
/// <summary> /// 创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> public void Create(VipCardEntity pEntity) { _currentDAO.Create(pEntity); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> public void Update(VipCardEntity pEntity) { _currentDAO.Update(pEntity); }
/// <summary> /// /// </summary> public string LockVipCardInfoData() { var service = new VipCardBLL(CurrentUserInfo); var vipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(CurrentUserInfo); string content = string.Empty; string key = string.Empty; if (Request("VipCardID") != null && Request("VipCardID") != string.Empty) { key = Request("VipCardID").ToString().Trim(); } string Lock = string.Empty; if (Request("Lock") != null && Request("Lock") != string.Empty) { Lock = Request("Lock").ToString().Trim(); } string UnitID = string.Empty; if (Request("UnitID") != null && Request("UnitID") != string.Empty) { UnitID = Request("UnitID").ToString().Trim(); } string VipCardStatusId = string.Empty; if (Request("VipCardStatusId") != null && Request("VipCardStatusId") != string.Empty) { VipCardStatusId = Request("VipCardStatusId").ToString().Trim(); } VipCardEntity data = service.GetByID(key); int? vipCardStatusId = data.VipCardStatusId; if (Lock == "1") { vipCardStatusId = 5; if (VipCardStatusId.Length > 0) { vipCardStatusId = int.Parse(VipCardStatusId); } } service.Update(new VipCardEntity() { VipCardID = key, VipCardStatusId = vipCardStatusId }, null); vipCardStatusChangeLogBLL.Create(new VipCardStatusChangeLogEntity() { LogID = Utils.NewGuid(), VipCardID = key, VipCardStatusID = vipCardStatusId, OldStatusID = data.VipCardStatusId, UnitID = UnitID }); content = data.ToJSON(); return(content); }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity"></param> public void Delete(VipCardEntity pEntity) { _currentDAO.Delete(pEntity); }
protected override SetVipCardRD ProcessRequest(DTO.Base.APIRequest <SetVipCardRP> pRequest) { var rd = new SetVipCardRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; #region 业务对象 //会员卡 var VipCardBLL = new VipCardBLL(loggingSessionInfo); //余额变动记录 var VipCardBalanceChangeBLL = new VipCardBalanceChangeBLL(loggingSessionInfo); //卡状态变更记录 var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo); //卡关系 var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); //图片 var objectImagesBLL = new ObjectImagesBLL(loggingSessionInfo); //会员 var VipBLL = new VipBLL(loggingSessionInfo); var vipCardTransLogBLL = new VipCardTransLogBLL(loggingSessionInfo); //丰收日交易记录对象示例化 var unitBLL = new TUnitBLL(loggingSessionInfo); //门店业务对象 //事务 var pTran = VipCardBLL.GetTran(); #endregion using (pTran.Connection) { try { if (string.IsNullOrWhiteSpace(para.VipCardID) || para.OperationType <= 0) { throw new APIException("卡ID或者操作类型参数不合法!") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER }; } //定位当前卡业务对象 VipCardEntity changeEntity = VipCardBLL.GetByID(para.VipCardID); if (changeEntity == null) { throw new APIException("当前卡信息对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } #region 返回卡ID rd.VipCardID = changeEntity.VipCardID; #endregion changeEntity.RechargeTotalAmount = changeEntity.RechargeTotalAmount ?? 0; changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0; string OldVipCardCode = changeEntity.VipCardCode ?? ""; //原卡号 string NewVipCardCode = ""; //新卡号,获取新卡赋值 decimal OldMoney = changeEntity.BalanceAmount.Value; //原卡当前余额 decimal NewMoney = changeEntity.BalanceAmount.Value + para.BalanceMoney; //原卡当余额+调整金额 //原卡会员映射关系 VipCardVipMappingEntity OldVipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VipCardID = para.VipCardID }, null).FirstOrDefault(); if (OldVipCardVipMappingData == null) { throw new APIException("原卡会员关系映射对象为NULL!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //门店Entity var UnitData = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId); //会员 VipEntity VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); #region 卡状态记录对象 VipCardStatusChangeLogEntity AddVCStatusEntity = new VipCardStatusChangeLogEntity(); AddVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddVCStatusEntity.VipCardID = para.VipCardID; AddVCStatusEntity.Reason = para.ChangeReason; AddVCStatusEntity.OldStatusID = changeEntity.VipCardStatusId; AddVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddVCStatusEntity.Remark = para.Remark; AddVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; #endregion #region 新卡 VipCardEntity NewChangeVipCardData = new VipCardEntity(); if (!string.IsNullOrWhiteSpace(para.NewCardCode)) { //查询参数 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; if (!string.IsNullOrEmpty(para.NewCardCode)) { complexCondition.Add(new DirectCondition("VipCardCode='" + para.NewCardCode + "' or VipCardISN='" + para.NewCardCode.ToString() + "' ")); } //新卡对象 NewChangeVipCardData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault(); if (NewChangeVipCardData == null) { throw new APIException("新卡不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //新卡号赋值 NewVipCardCode = NewChangeVipCardData.VipCardCode ?? ""; //新卡数据赋值 NewChangeVipCardData.VipCardGradeID = changeEntity.VipCardGradeID; NewChangeVipCardData.BatchNo = changeEntity.BatchNo; NewChangeVipCardData.BeginDate = changeEntity.BeginDate; NewChangeVipCardData.EndDate = changeEntity.EndDate; NewChangeVipCardData.TotalAmount = changeEntity.TotalAmount == null ? 0 : changeEntity.TotalAmount.Value; NewChangeVipCardData.BalanceAmount = changeEntity.BalanceAmount == null ? 0 : changeEntity.BalanceAmount.Value; NewChangeVipCardData.BalancePoints = changeEntity.BalancePoints == null ? 0 : changeEntity.BalancePoints.Value; NewChangeVipCardData.BalanceBonus = changeEntity.BalanceBonus == null ? 0 : changeEntity.BalanceBonus.Value; NewChangeVipCardData.CumulativeBonus = changeEntity.CumulativeBonus == null ? 0 : changeEntity.CumulativeBonus.Value; NewChangeVipCardData.PurchaseTotalAmount = changeEntity.PurchaseTotalAmount == null ? 0 : changeEntity.PurchaseTotalAmount.Value; NewChangeVipCardData.PurchaseTotalCount = changeEntity.PurchaseTotalCount == null ? 0 : changeEntity.PurchaseTotalCount.Value; NewChangeVipCardData.CheckCode = changeEntity.CheckCode; NewChangeVipCardData.SingleTransLimit = changeEntity.SingleTransLimit == null ? 0 : changeEntity.SingleTransLimit.Value; NewChangeVipCardData.IsOverrunValid = changeEntity.IsOverrunValid == null ? 0 : changeEntity.IsOverrunValid.Value; NewChangeVipCardData.RechargeTotalAmount = changeEntity.RechargeTotalAmount == null ? 0 : changeEntity.RechargeTotalAmount.Value; NewChangeVipCardData.LastSalesTime = changeEntity.LastSalesTime; NewChangeVipCardData.IsGift = changeEntity.IsGift == null ? 0 : changeEntity.IsGift.Value; NewChangeVipCardData.SalesAmount = changeEntity.SalesAmount; NewChangeVipCardData.SalesUserId = changeEntity.SalesUserId; NewChangeVipCardData.CustomerID = changeEntity.CustomerID; NewChangeVipCardData.MembershipTime = changeEntity.MembershipTime; NewChangeVipCardData.SalesUserName = changeEntity.SalesUserName == null ? "" : changeEntity.SalesUserName; NewChangeVipCardData.CreateBy = changeEntity.CreateBy; } #endregion switch (para.OperationType) { case 1: #region 调整卡余额 //卡更新 //卡内总金额 if (para.BalanceMoney > 0) { changeEntity.RechargeTotalAmount += para.BalanceMoney; if (changeEntity.RechargeTotalAmount < 0) { throw new APIException("调整后的余额小于0!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } } //changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0; // changeEntity.BalanceAmount = NewMoney; //执行更新 VipCardBLL.Update(changeEntity, pTran); //新增余额变动记录 VipCardBalanceChangeEntity AddEntity = new VipCardBalanceChangeEntity(); AddEntity.ChangeID = System.Guid.NewGuid().ToString(); AddEntity.VipCardCode = changeEntity.VipCardCode; AddEntity.ChangeAmount = para.BalanceMoney; //变动前卡内余额 AddEntity.ChangeBeforeBalance = OldMoney; //变动后卡内余额 AddEntity.ChangeAfterBalance = NewMoney; AddEntity.ChangeReason = para.ChangeReason; AddEntity.Status = 1; AddEntity.Remark = para.Remark; AddEntity.CustomerID = loggingSessionInfo.ClientID; AddEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; //执行新增 VipCardBalanceChangeBLL.Create(AddEntity, pTran); //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddEntity.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } #region 充值记录 //读取最近一次积分变更记录 List <OrderBy> lstOrder = new List <OrderBy> { }; //排序参数 lstOrder.Add(new OrderBy() { FieldName = "TransTime", Direction = OrderByDirections.Desc }); var transLogInfo = vipCardTransLogBLL.QueryByEntity(new VipCardTransLogEntity() { VipCardCode = changeEntity.VipCardCode, TransType = "C" }, lstOrder.ToArray()).FirstOrDefault(); //期末积分 int newValue = transLogInfo != null ? (transLogInfo.NewValue ?? 0) : 0; var vipCardTransLogEntity = new VipCardTransLogEntity() { VipCardCode = VipData == null ? "" : VipData.VipCode, UnitCode = UnitData == null ? "" : UnitData.UnitCode, TransContent = "余额", TransType = "C", TransTime = DateTime.Now, TransAmount = para.BalanceMoney, LastValue = newValue, //期初金额 NewValue = Convert.ToInt32(para.BalanceMoney) + newValue, //期末金额 CustomerID = loggingSessionInfo.ClientID }; vipCardTransLogBLL.Create(vipCardTransLogEntity, pTran); #endregion #endregion break; case 2: #region 卡升级 //卡类型升级 if (para.VipCardTypeId != 0) { VipCardVipMappingBLL.updateVipCardByType(VipData.VIPID, para.VipCardTypeId, para.ChangeReason, para.Remark, VipData.VipCode, pTran); } //卡号升级 else { #region 原卡 #region 更新原卡 changeEntity.VipCardStatusId = 3; //当前月,累计金额清0 //changeEntity.BalanceAmount = 0; //changeEntity.TotalAmount = 0; VipCardBLL.Update(changeEntity, pTran); //执行 #endregion #region 新增原卡状态记录 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "卡升级"; AddVCStatusEntity.Remark += "已升级为:" + NewChangeVipCardData.VipCardCode; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); //执行 #endregion #region 新增原卡余额变动记录 //if (OldMoney > 0) //{ // VipCardBalanceChangeEntity AddOldCardBalanceData = new VipCardBalanceChangeEntity(); // AddOldCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); // AddOldCardBalanceData.VipCardCode = changeEntity.VipCardCode; // AddOldCardBalanceData.ChangeAmount = -OldMoney; // //变动前卡内余额 // AddOldCardBalanceData.ChangeBeforeBalance = OldMoney; // //变动后卡内余额 // AddOldCardBalanceData.ChangeAfterBalance = 0; // AddOldCardBalanceData.ChangeReason = para.ChangeReason; // AddOldCardBalanceData.Status = 1; // AddOldCardBalanceData.Remark = para.Remark; // AddOldCardBalanceData.CustomerID = loggingSessionInfo.ClientID; // AddOldCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; // VipCardBalanceChangeBLL.Create(AddOldCardBalanceData, pTran);//执行 // //增加图片上传 // if (!string.IsNullOrEmpty(para.ImageUrl)) // { // var objectImagesEntity = new ObjectImagesEntity() // { // ImageId = Guid.NewGuid().ToString(), // ObjectId = AddOldCardBalanceData.ChangeID, // ImageURL = para.ImageUrl // }; // objectImagesBLL.Create(objectImagesEntity, pTran); // } //} #endregion #endregion #region 新卡 VipData.VipCode = para.NewCardCode; VipBLL.Update(VipData, pTran); #region 更新新卡 if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit)) { throw new APIException("该会员卡已绑定会员!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardStatusId != 0) { throw new APIException("该会员卡已激活!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardTypeID.Value == changeEntity.VipCardTypeID.Value) { throw new APIException("该卡号与原卡等级相同,请更换卡号后重新尝试!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; #region 返回新卡卡ID rd.VipCardID = NewChangeVipCardData.VipCardID; #endregion NewChangeVipCardData.MembershipUnit = changeEntity.MembershipUnit; NewChangeVipCardData.VipCardStatusId = 1; VipCardBLL.Update(NewChangeVipCardData, pTran); //执行 #endregion #region 新增新卡卡关系 VipCardVipMappingEntity AddVipCardVipMappingData = new VipCardVipMappingEntity(); AddVipCardVipMappingData.MappingID = System.Guid.NewGuid().ToString(); AddVipCardVipMappingData.VIPID = OldVipCardVipMappingData.VIPID; AddVipCardVipMappingData.VipCardID = NewChangeVipCardData.VipCardID; AddVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID; VipCardVipMappingBLL.Create(AddVipCardVipMappingData, pTran); //执行 #endregion #region 更新会员编号 //VipEntity SJ_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); //if (VipData == null) // throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; //VipData.VipCode = NewChangeVipCardData.VipCardCode; //VipBLL.Update(VipData, pTran);//执行 #endregion #region 新增新卡状态记录 //新增新卡状态记录 VipCardStatusChangeLogEntity AddNewVCStatusEntity = new VipCardStatusChangeLogEntity(); AddNewVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddNewVCStatusEntity.VipCardID = NewChangeVipCardData.VipCardID; AddNewVCStatusEntity.VipCardStatusID = 1; AddNewVCStatusEntity.Reason = para.ChangeReason; AddNewVCStatusEntity.OldStatusID = 0; AddNewVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddNewVCStatusEntity.Action = "卡升级"; AddNewVCStatusEntity.Remark = para.Remark + "由旧卡:" + changeEntity.VipCardCode + "升级"; AddNewVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardStatusChangeLogBLL.Create(AddNewVCStatusEntity, pTran); //执行 #endregion #region 新增新卡余额记录 //新增余额记录 //if (OldMoney > 0) //{ // VipCardBalanceChangeEntity AddNewCardBalanceData = new VipCardBalanceChangeEntity(); // AddNewCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); // AddNewCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode; // AddNewCardBalanceData.ChangeAmount = OldMoney; // //变动前卡内余额 // AddNewCardBalanceData.ChangeBeforeBalance = 0; // //变动后卡内余额 // AddNewCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value; // AddNewCardBalanceData.ChangeReason = para.ChangeReason; // AddNewCardBalanceData.Status = 1; // AddNewCardBalanceData.Remark = para.Remark; // AddNewCardBalanceData.CustomerID = loggingSessionInfo.ClientID; // VipCardBalanceChangeBLL.Create(AddNewCardBalanceData, pTran);//执行 // //增加图片上传 // if (!string.IsNullOrEmpty(para.ImageUrl)) // { // var objectImagesEntity = new ObjectImagesEntity() // { // ImageId = Guid.NewGuid().ToString(), // ObjectId = AddNewCardBalanceData.ChangeID, // ImageURL = para.ImageUrl // }; // objectImagesBLL.Create(objectImagesEntity, pTran); // } //} #endregion #endregion } #endregion break; case 3: #region 挂失 changeEntity.VipCardStatusId = 4; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行 AddVCStatusEntity.VipCardStatusID = 4; AddVCStatusEntity.PicUrl = para.ImageUrl; AddVCStatusEntity.Action = "挂失"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 4: #region 冻结 changeEntity.VipCardStatusId = 2; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 2; AddVCStatusEntity.Action = "冻结"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 5: #region 转卡 #region 原卡 #region 更新原卡 changeEntity.VipCardStatusId = 3; //当前月,累计金额清0 changeEntity.BalanceAmount = 0; changeEntity.TotalAmount = 0; VipCardBLL.Update(changeEntity, pTran); //执行 #endregion #region 新增原卡状态记录 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "转卡"; AddVCStatusEntity.Remark += "已转移为:" + NewChangeVipCardData.VipCardCode; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); //执行 #endregion #region 新增原卡余额变动记录 if (OldMoney > 0) { VipCardBalanceChangeEntity AddOldZKCardBalanceData = new VipCardBalanceChangeEntity(); AddOldZKCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); AddOldZKCardBalanceData.VipCardCode = changeEntity.VipCardCode; AddOldZKCardBalanceData.ChangeAmount = -OldMoney; //变动前卡内余额 AddOldZKCardBalanceData.ChangeBeforeBalance = OldMoney; //变动后卡内余额 AddOldZKCardBalanceData.ChangeAfterBalance = 0; AddOldZKCardBalanceData.ChangeReason = para.ChangeReason; AddOldZKCardBalanceData.Status = 1; AddOldZKCardBalanceData.Remark = para.Remark; AddOldZKCardBalanceData.CustomerID = loggingSessionInfo.ClientID; AddOldZKCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardBalanceChangeBLL.Create(AddOldZKCardBalanceData, pTran); //执行 //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddOldZKCardBalanceData.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } } #endregion #endregion #region 新卡 #region 更新新卡 if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit)) { throw new APIException("该会员卡已绑定会员!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardStatusId != 0) { throw new APIException("该会员卡已激活!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; if (NewChangeVipCardData.VipCardTypeID.Value != changeEntity.VipCardTypeID.Value) { throw new APIException("该卡号与原卡等级不同,请更换卡号后重新尝试!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; #region 返回新卡卡ID rd.VipCardID = NewChangeVipCardData.VipCardID; #endregion NewChangeVipCardData.MembershipUnit = changeEntity.MembershipUnit; NewChangeVipCardData.VipCardStatusId = 1; VipCardBLL.Update(NewChangeVipCardData, pTran); //执行 #endregion #region 新增新卡卡关系 VipCardVipMappingEntity AddZKVipCardVipMappingData = new VipCardVipMappingEntity(); AddZKVipCardVipMappingData.MappingID = System.Guid.NewGuid().ToString(); AddZKVipCardVipMappingData.VIPID = OldVipCardVipMappingData.VIPID; AddZKVipCardVipMappingData.VipCardID = NewChangeVipCardData.VipCardID; AddZKVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID; VipCardVipMappingBLL.Create(AddZKVipCardVipMappingData, pTran); //执行 #endregion #region 更新会员编号 //VipEntity ZK_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID); if (VipData == null) { throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } } ; VipData.VipCode = NewChangeVipCardData.VipCardCode; VipBLL.Update(VipData, pTran); //执行 #endregion #region 新增新卡状态记录 VipCardStatusChangeLogEntity AddNewZKVCStatusEntity = new VipCardStatusChangeLogEntity(); AddNewZKVCStatusEntity.LogID = System.Guid.NewGuid().ToString(); AddNewZKVCStatusEntity.VipCardID = NewChangeVipCardData.VipCardID; AddNewZKVCStatusEntity.VipCardStatusID = 1; AddNewZKVCStatusEntity.Reason = para.ChangeReason; AddNewZKVCStatusEntity.OldStatusID = 0; AddNewZKVCStatusEntity.CustomerID = loggingSessionInfo.ClientID; AddNewZKVCStatusEntity.Action = "转卡"; AddNewZKVCStatusEntity.Remark = para.Remark + para.Remark + "由旧卡:" + changeEntity.VipCardCode + "转移"; AddNewZKVCStatusEntity.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardStatusChangeLogBLL.Create(AddNewZKVCStatusEntity, pTran); //执行 #endregion #region 新增新卡余额记录 if (OldMoney > 0) { VipCardBalanceChangeEntity AddNewZKCardBalanceData = new VipCardBalanceChangeEntity(); AddNewZKCardBalanceData.ChangeID = System.Guid.NewGuid().ToString(); AddNewZKCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode; AddNewZKCardBalanceData.ChangeAmount = OldMoney; //变动前卡内余额 AddNewZKCardBalanceData.ChangeBeforeBalance = 0; //变动后卡内余额 AddNewZKCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value; AddNewZKCardBalanceData.ChangeReason = para.ChangeReason; AddNewZKCardBalanceData.Status = 1; AddNewZKCardBalanceData.Remark = para.Remark; AddNewZKCardBalanceData.CustomerID = loggingSessionInfo.ClientID; AddNewZKCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId; VipCardBalanceChangeBLL.Create(AddNewZKCardBalanceData, pTran); //执行 //增加图片上传 if (!string.IsNullOrEmpty(para.ImageUrl)) { var objectImagesEntity = new ObjectImagesEntity() { ImageId = Guid.NewGuid().ToString(), ObjectId = AddNewZKCardBalanceData.ChangeID, ImageURL = para.ImageUrl }; objectImagesBLL.Create(objectImagesEntity, pTran); } } #endregion #endregion #endregion break; case 6: #region 解挂 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "解挂"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 7: #region 解冻 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "解冻"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 8: #region 作废 changeEntity.VipCardStatusId = 3; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 3; AddVCStatusEntity.Action = "作废"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 9: #region 唤醒 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "唤醒"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; case 10: #region 激活 changeEntity.VipCardStatusId = 1; //执行更新 VipCardBLL.Update(changeEntity, pTran); //执行新增 AddVCStatusEntity.VipCardStatusID = 1; AddVCStatusEntity.Action = "激活"; VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran); #endregion break; default: throw new APIException("当前操作类型不匹配!") { ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER }; break; } ; pTran.Commit(); #region 卡升级,转卡操作转移消费记录表 if ((para.OperationType == 2 || para.OperationType == 5) && string.IsNullOrEmpty(para.VipCardTypeId.ToString())) //卡类型升级不执行此操作 { string StrSql = string.Format("update VipCardTransLog set VipCardCode='{0}',OldVipCardCode='{1}' where VipCardCode='{1}'", NewVipCardCode, OldVipCardCode); vipCardTransLogBLL.UpdateVipCardTransLog(StrSql);//执行 } #endregion var eventService = new EventService(); var vipMsg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Vip, Id = VipData.VIPID }; eventService.PublishMsg(vipMsg); } catch (APIException apiEx) { pTran.Rollback();//回滚事物 throw new APIException(apiEx.ErrorCode, apiEx.Message); } catch (Exception ex) { pTran.Rollback();//回滚事务 throw new APIException(ex.Message); } } return(rd); }
public void Delete(VipCardEntity dbEntity) { _cmd.Delete(dbEntity); }
protected override GetVIPCardRD ProcessRequest(DTO.Base.APIRequest <GetVIPCardRP> pRequest) { GetVIPCardRD Data = new GetVIPCardRD(); var rd = new GetVIPCardListRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; #region 业务对象 //会员卡 var VipCardBLL = new VipCardBLL(loggingSessionInfo); //会员 var VipBLL = new VipBLL(loggingSessionInfo); //卡状态变更记录 var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo); //卡与Vip关系 var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo); //门店 var unitBll = new t_unitBLL(loggingSessionInfo); //员工 var UserBLL = new T_UserBLL(loggingSessionInfo); //卡类型 var SysVipCardTypeBLL = new SysVipCardTypeBLL(loggingSessionInfo); //商户配置 var CustomerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo); //积分 var VipIntegralBLL = new VipIntegralBLL(loggingSessionInfo); #endregion #region 会员卡 VipCardEntity resultData = null; if (!string.IsNullOrWhiteSpace(para.VipID)) { //会员编号获取详情 VipCardVipMappingEntity m_VipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = para.VipID }, null).FirstOrDefault(); if (m_VipMappingData != null && !string.IsNullOrWhiteSpace(m_VipMappingData.VipCardID)) { resultData = VipCardBLL.GetByID(para.VipCardID); } } else { if (!string.IsNullOrWhiteSpace(para.VipCardID)) { //卡ID获取详情 resultData = VipCardBLL.GetByID(para.VipCardID); } else { //刷卡获取详情 List <IWhereCondition> complexCondition = new List <IWhereCondition> { }; if (!string.IsNullOrEmpty(para.VipCardISN)) { complexCondition.Add(new DirectCondition("VipCardCode='" + para.VipCardISN + "' or VipCardISN='" + para.VipCardISN.ToString() + "' ")); } resultData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault(); } } //try //{ // if (resultData == null) // throw new APIException("该卡不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; //} //catch (APIException apiEx) //{ // throw new APIException(apiEx.ErrorCode, apiEx.Message); //} #endregion #region 卡关系 VipCardVipMappingEntity VipCardVipMappingData = null; if (resultData != null) { VipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VipCardID = resultData.VipCardID }, null).FirstOrDefault(); } //else //{ // return Data; //} #endregion #region 门店 t_unitEntity unidData = null; if (resultData != null && !string.IsNullOrWhiteSpace(resultData.MembershipUnit)) { unidData = unitBll.GetByID(resultData.MembershipUnit); } #endregion #region 会员,积分 VipEntity VipData = null; VipIntegralEntity IntegralData = null; //string VIPID = VipCardVipMappingData == null ? "" : VipCardVipMappingData.VIPID; string VIPID = para.VipID; if (!string.IsNullOrWhiteSpace(VIPID)) { VipData = VipBLL.NewGetByID(VIPID); //IntegralData = VipIntegralBLL.GetByID(VIPID); IntegralData = VipIntegralBLL.QueryByEntity(new VipIntegralEntity() { VipID = VipData.VIPID, VipCardCode = VipData.VipCode }, null).FirstOrDefault(); } #endregion #region 员工 T_UserEntity UserData = null; if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy)) { UserData = UserBLL.GetByID(resultData.CreateBy); } #endregion #region 响应对象赋值 if (resultData != null) { //卡 Data.VipCardID = resultData.VipCardID; Data.VipCardCode = resultData.VipCardCode; Data.VipCardISN = resultData.VipCardISN; Data.CraeteUserName = UserData == null ? "" : UserData.user_name; Data.VipCardStatusId = resultData.VipCardStatusId.Value; Data.MembershipTime = resultData.MembershipTime == null ? "" : resultData.MembershipTime.Value.ToString("yyyy-MM-dd"); Data.MembershipUnitName = unidData == null ? "" : unidData.unit_name; //Data.TotalAmount = resultData.RechargeTotalAmount == null ? 0 : resultData.RechargeTotalAmount.Value; //Data.BalanceAmount = resultData.BalanceAmount == null ? 0 : resultData.BalanceAmount.Value; Data.BeginDate = resultData.BeginDate; Data.EndDate = "永久有效"; Data.SalesUserName = resultData.SalesUserName == null ? "" : resultData.SalesUserName; #region 卡类型名称 SysVipCardTypeEntity SysVipCardTypeData = SysVipCardTypeBLL.GetByID(resultData.VipCardTypeID); Data.VipCardName = SysVipCardTypeData == null ? "" : SysVipCardTypeData.VipCardTypeName; #endregion #region 状态变更记录列表 var VipCardStatusChangeLogArray = VipCardStatusChangeLogBLL.Query (new IWhereCondition[] { new EqualsCondition() { FieldName = "VipCardID", Value = resultData.VipCardID } }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).ToList(); //转换业务对象 Data.StatusLogList = (from t in VipCardStatusChangeLogArray select new VipCardStatusChangeLog() { CreateTime = t.CreateTime.Value.ToString("yyyy-MM-dd"), UnitName = t.UnitName == null ? "" : t.UnitName, Action = t.Action == null ? "" : t.Action, ChangeReason = t.Reason == null ? "" : t.Reason, Remark = t.Remark == null ? "" : t.Remark, CreateBy = t.CreateByName, ImageUrl = t.PicUrl == null ? "" : t.PicUrl }).ToList(); #endregion } #region 会员 if (VipData != null) { Data.VipID = VipData.VIPID; Data.VipCode = VipData.VipCode; if (Data.VipCardCode == null) { Data.VipCardCode = VipData.VipCode; } if (!string.IsNullOrWhiteSpace(VipData.VipRealName)) { Data.VipName = VipData.VipRealName; } else { Data.VipName = VipData.VipName ?? ""; } Data.Phone = VipData.Phone; Data.Birthday = VipData.Birthday == null ? "" : VipData.Birthday; Data.Gender = VipData.Gender ?? 0; //Data.Integration = VipData.Integration == null ? 0 : VipData.Integration.Value; //会员创建人姓名 T_UserEntity VipUserData = null; if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy)) { VipUserData = UserBLL.GetByID(resultData.CreateBy); } Data.VipCreateByName = VipUserData == null ? "" : VipUserData.user_name; Data.IDNumber = VipData.IDNumber == null ? "" : VipData.IDNumber; #region 会员生日是否可修改字段赋值 //Col22 字段赋值 ////CustomerBasicSettingEntity SettingData = CustomerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "FSR_NotTwoUpdateVipBirthday" }, null).FirstOrDefault(); ////if (SettingData != null) Data.Col22 = VipData.Col22 == null ? "Y" : VipData.Col22; #endregion } #endregion #region 积分 if (IntegralData != null) { Data.Integration = IntegralData.ValidIntegral != null ? IntegralData.ValidIntegral.Value : 0; Data.CumulativeIntegral = IntegralData.CumulativeIntegral != null ? IntegralData.CumulativeIntegral.Value : 0; } #endregion #region 余额和返现 var vipAmountBLL = new VipAmountBLL(loggingSessionInfo); var vipAmountInfo = vipAmountBLL.QueryByEntity(new VipAmountEntity() { VipId = VipData.VIPID, VipCardCode = VipData.VipCode }, null).FirstOrDefault(); if (vipAmountInfo != null) { Data.TotalAmount = vipAmountInfo.TotalAmount == null ? 0 : vipAmountInfo.TotalAmount.Value; Data.BalanceAmount = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value; Data.ValidReturnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value; Data.TotalReturnAmount = vipAmountInfo.TotalReturnAmount == null ? 0 : vipAmountInfo.TotalReturnAmount.Value; } #endregion #endregion return(Data); }
/// <summary> /// 支付完成时注册绑卡 (目前可用于绑卡列表处的绑卡升级处理) /// </summary> /// <param name="vipId"></param> /// <param name="vipCode"></param> /// <param name="unitId"></param> /// <param name="ObjecetTypeId">卡类型Id</param> /// <param name="OrderType">订单类型 SalesCard=销售 Recharge=充值</param> /// <param name="OperationType">操作类型 1-手动 2-自动</param> /// <returns></returns> public string BindVirtualItem(string vipId, string vipCode, string unitId, int ObjecetTypeId, string OrderType = "SalesCard", int OperationType = 1, string orderId = "") { var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); var sysVipCardTypeBLL = new SysVipCardTypeBLL(CurrentUserInfo); var vipCardBLL = new VipCardBLL(CurrentUserInfo); var vipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(CurrentUserInfo); string ObjectNo = string.Empty;//卡号或券号 try { UnitService unitServer = new UnitService(CurrentUserInfo); if (string.IsNullOrEmpty(unitId)) { unitId = unitServer.GetUnitByUnitTypeForWX("总部", null).Id; //获取总部门店标识 } //根据vipid查询VipCardVipMapping,判断是否有绑卡 var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = vipId }, null).FirstOrDefault(); //判断商户是否有付费的会员卡,有付费会员卡时,不自动绑卡 //List<IWhereCondition> freeCardCon = new List<IWhereCondition> { }; //freeCardCon.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); //freeCardCon.Add(new DirectCondition("Prices>0")); //var freeCardTypeInfo = sysVipCardTypeBLL.Query(freeCardCon.ToArray(), null).FirstOrDefault(); //if (freeCardTypeInfo == null) //{ ////查询最低等级的会员卡类型 //var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { CustomerID = CurrentUserInfo.ClientID, Category = 0 }, new OrderBy[] { new OrderBy() { FieldName = "vipcardlevel", Direction = OrderByDirections.Asc } }).FirstOrDefault(); //if (vipCardTypeInfo != null) //{ if (vipCardMappingInfo == null)//绑卡 { //最低等级卡类型 var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardLevel = 1 }, new OrderBy[] { new OrderBy() { FieldName = "vipcardlevel", Direction = OrderByDirections.Asc } }).FirstOrDefault(); if (vipCardTypeInfo == null) { throw new APIException("系统未创建会员卡类型") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } //查询此类型会员卡是否存在 var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardTypeID = vipCardTypeInfo.VipCardTypeID, VipCardStatusId = 0, MembershipUnit = "" }, null).FirstOrDefault(); //不存在,制卡 if (vipCardInfo == null) { vipCardInfo = new VipCardEntity(); vipCardInfo.VipCardID = Guid.NewGuid().ToString(); vipCardInfo.VipCardTypeID = vipCardTypeInfo.VipCardTypeID; //vipCardInfo.VipCardTypeName = vipCardTypeInfo.VipCardTypeName; vipCardInfo.VipCardCode = vipCode; vipCardInfo.VipCardStatusId = 1;//正常 vipCardInfo.MembershipUnit = unitId; vipCardInfo.MembershipTime = DateTime.Now; vipCardInfo.CustomerID = CurrentUserInfo.ClientID; vipCardBLL.Create(vipCardInfo); } ObjectNo = vipCardInfo.VipCardCode; //绑定会员卡和会员 var vipCardVipMappingEntity = new VipCardVipMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), VIPID = vipId, VipCardID = vipCardInfo.VipCardID, CustomerID = CurrentUserInfo.ClientID }; vipCardVipMappingBLL.Create(vipCardVipMappingEntity); vipCardMappingInfo = vipCardVipMappingEntity; //新增会员卡操作状态信息 var vipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = vipCardInfo.VipCardStatusId, VipCardID = vipCardInfo.VipCardID, Action = "注册", UnitID = unitId, CustomerID = CurrentUserInfo.ClientID }; vipCardStatusChangeLogBLL.Create(vipCardStatusChangeLogEntity); } #region 老卡业务处理 ObjectNo = vipCode; //老卡信息获取 var oldVipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardID = vipCardMappingInfo.VipCardID }, null).FirstOrDefault(); //老卡卡类型ID int oldVipCardTypeID = 0; if (oldVipCardInfo != null) { //获取老卡的类型 var oldVipCardType = sysVipCardTypeBLL.GetByID(oldVipCardInfo.VipCardTypeID); //获取即将升级卡的类型 var newVipCardType = sysVipCardTypeBLL.GetByID(ObjecetTypeId); if (newVipCardType.VipCardLevel > oldVipCardType.VipCardLevel) { //老卡卡类型ID oldVipCardTypeID = oldVipCardInfo.VipCardTypeID ?? 0; //更新卡信息 oldVipCardInfo.VipCardTypeID = ObjecetTypeId; vipCardBLL.Update(oldVipCardInfo); //老卡操作状态信息 var oldVipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = oldVipCardInfo.VipCardStatusId, VipCardID = oldVipCardInfo.VipCardID, Action = "升级处理", UnitID = unitId, CustomerID = CurrentUserInfo.ClientID }; vipCardStatusChangeLogBLL.Create(oldVipCardStatusChangeLogEntity); //入升级日志 var vipCardGradeChangeLogBll = new VipCardGradeChangeLogBLL(CurrentUserInfo); var vipCardUpgradeRuleBll = new VipCardUpgradeRuleBLL(CurrentUserInfo); var vipCardUpgradeRuleEntity = vipCardUpgradeRuleBll.QueryByEntity(new VipCardUpgradeRuleEntity() { CustomerID = CurrentUserInfo.ClientID, VipCardTypeID = ObjecetTypeId }, null).FirstOrDefault(); var VipCardGradeChangeLogEntity = new VipCardGradeChangeLogEntity() { ChangeLogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardUpgradeRuleId = vipCardUpgradeRuleEntity.VipCardUpgradeRuleId, OrderType = OrderType, VipCardID = oldVipCardInfo.VipCardID, ChangeBeforeVipCardID = oldVipCardInfo.VipCardID, ChangeBeforeGradeID = oldVipCardTypeID, NowGradeID = oldVipCardInfo.VipCardTypeID, ChangeReason = "upgrade", OperationType = OperationType, ChangeTime = DateTime.Now, UnitID = unitId, OrderId = orderId, CustomerID = CurrentUserInfo.ClientID, }; vipCardGradeChangeLogBll.Create(VipCardGradeChangeLogEntity); //开卡礼 var vipCardUpgradeRewardBll = new VipCardUpgradeRewardBLL(CurrentUserInfo); var vipCardUpgradeRewardEntityList = vipCardUpgradeRewardBll.QueryByEntity(new VipCardUpgradeRewardEntity() { VipCardTypeID = ObjecetTypeId }, null); var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL(); if (vipCardUpgradeRewardEntityList.Length > 0) { foreach (var vipCardUpgradeRewardEntity in vipCardUpgradeRewardEntityList) { for (int i = 0; i < vipCardUpgradeRewardEntity.CouponNum; i++) { redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon() { CustomerId = CurrentUserInfo.ClientID, CouponTypeId = vipCardUpgradeRewardEntity.CouponTypeId.ToString() }, vipCardUpgradeRewardEntity.CardUpgradeRewardId.ToString(), vipId, "OpenVipCard"); } } } //消费升级 if (OperationType == 2) { //群发消息表 var InnerGroupNewsBll = new InnerGroupNewsBLL(CurrentUserInfo); var innerGroupNewsEntity = new InnerGroupNewsEntity() { GroupNewsId = Guid.NewGuid().ToString().Replace("-", ""), SentType = 2, NoticePlatformType = 1, BusType = 3, Title = "升级提醒", Text = "升级成功", CustomerID = CurrentUserInfo.ClientID }; InnerGroupNewsBll.Create(innerGroupNewsEntity); //消息和用户关系表 var newsUserMappingBll = new NewsUserMappingBLL(CurrentUserInfo); var newsUserMappingEntity = new NewsUserMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), UserID = vipId, GroupNewsID = innerGroupNewsEntity.GroupNewsId, CustomerId = CurrentUserInfo.ClientID, HasRead = 0 }; newsUserMappingBll.Create(newsUserMappingEntity); } } } #endregion } catch { throw new APIException("升级失败!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; }; //记录会员信息改变,并且把旧的会员的标识也放在契约里 var eventService = new EventService(); var vipMsg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Vip, Id = vipId, }; eventService.PublishMsg(vipMsg); return(ObjectNo); }
/// <summary> /// 根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public VipCardEntity[] QueryByEntity(VipCardEntity pQueryEntity, OrderBy[] pOrderBys) { return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys)); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Update(VipCardEntity pEntity, IDbTransaction pTran) { _currentDAO.Update(pEntity, pTran); }
public void Deal(VipContract contract) { var dbEntity = Convert(contract); var facade = new VipFacade(); if (contract.Operation != OptEnum.Delete) { if (facade.GetById(contract.VipId) == null) { contract.Operation = OptEnum.Create; } else { contract.Operation = OptEnum.Update; } } switch (contract.Operation) { case OptEnum.Create: facade.Create(dbEntity); //创建卡 SysVipCardTypeFacade _SysVipCardTypeFacade = new SysVipCardTypeFacade(); //查询最低等级的会员卡类型 // SysVipCardTypeEntity vipCardTypeInfo = _SysVipCardTypeFacade.GetMinVipCardType(ConfigMgr.CustomerId); //查询某个级别的卡,都用金卡 SysVipCardTypeEntity vipCardTypeInfo = _SysVipCardTypeFacade.GetCardTypeIDByVipCardLevel(3, ConfigMgr.CustomerId); if (vipCardTypeInfo != null) { var vipCardInfo = new VipCardEntity(); vipCardInfo.VipCardID = Guid.NewGuid().ToString(); vipCardInfo.VipCardTypeID = vipCardTypeInfo.VipCardTypeID; vipCardInfo.VipCardName = vipCardTypeInfo.VipCardTypeName; vipCardInfo.VipCardCode = dbEntity.VipCode; vipCardInfo.VipCardStatusId = 1; //正常 // vipCardInfo.MembershipUnit = unitId; // vipCardInfo.MembershipTime = DateTime.Now; vipCardInfo.CustomerID = ConfigMgr.CustomerId; vipCardInfo.IsDelete = 0; var _VipCardFacade = new VipCardFacade(); //创建处理类 _VipCardFacade.Create(vipCardInfo); //创建会员与卡之间的关系 //绑定会员卡和会员 var vipCardVipMappingEntity = new VipCardVipMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), VIPID = dbEntity.VIPID, VipCardID = vipCardInfo.VipCardID, CustomerID = ConfigMgr.CustomerId, IsDelete = 0 }; var _VipCardVipMappingFacade = new VipCardVipMappingFacade(); //创建处理类 _VipCardVipMappingFacade.Create(vipCardVipMappingEntity); } break; case OptEnum.Update: facade.Update(dbEntity); break; case OptEnum.Delete: facade.Delete(dbEntity); break; } }
public void Create(VipCardEntity dbEntity) { _cmd.Create(dbEntity); }
/// <summary> /// 保存会员卡信息 /// </summary> /// <param name="vipCardID">会员卡ID</param> /// <param name="vipCardEntity">会员卡实体</param> /// <returns></returns> public bool SaveVipCardInfo(string vipCardID, VipCardEntity vipCardEntity) { try { using (TransactionScope scope = new TransactionScope()) { if (vipCardID.Trim().Length == 0) { var basicServer = new VipCardBasicBLL(this.CurrentUserInfo); //新增 vipCardEntity.VipCardID = Utils.NewGuid(); vipCardEntity.VipCardCode = basicServer.GetVipCardCode(vipCardEntity.UnitID); vipCardEntity.MembershipTime = Convert.ToDateTime(vipCardEntity.BeginDate); vipCardEntity.TotalAmount = 0; vipCardEntity.PurchaseTotalAmount = 0; vipCardEntity.PurchaseTotalCount = 0; vipCardEntity.CustomerID = CurrentUserInfo.CurrentUser.customer_id; this._currentDAO.Create(vipCardEntity); //添加会员卡与VIP关系 var vipMapping = new VipCardVipMappingBLL(this.CurrentUserInfo); var vipMappingEntity = new VipCardVipMappingEntity() { MappingID = Utils.NewGuid(), VipCardID = vipCardEntity.VipCardID, VIPID = vipCardEntity.VipId }; vipMapping.Create(vipMappingEntity); } else { //修改 vipCardEntity.VipCardID = vipCardID; this._currentDAO.Update(vipCardEntity); } var mappingServer = new VipCardUnitMappingBLL(this.CurrentUserInfo); var mappingEntity = new VipCardUnitMappingEntity() { VipCardID = vipCardEntity.VipCardID, UnitID = vipCardEntity.UnitID }; var mappingEntitys = mappingServer.QueryByEntity(mappingEntity, null); //根据会员卡ID删除会员卡与门店关系表 this._currentDAO.DeteleVipCardUnitMapping(vipCardEntity.VipCardID); if (mappingEntitys != null && mappingEntitys.Length > 0) { //更新会员卡与门店关系表 this._currentDAO.UpdateVipCardUnitMapping(vipCardEntity.VipCardID, vipCardEntity.UnitID); } else { //新增会员卡与门店关系表 mappingEntity.MappingID = Utils.NewGuid(); mappingServer.Create(mappingEntity); } scope.Complete(); } return(true); } catch (Exception) { return(false); } }
/// <summary> /// 会员微信注册绑卡 /// </summary> /// <param name="vipId"></param> /// <param name="vipCode"></param> /// <param name="unitId">会籍店</param> public void BindVipCard(string vipId, string vipCode, string unitId) { var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); var sysVipCardTypeBLL = new SysVipCardTypeBLL(CurrentUserInfo); var vipCardBLL = new VipCardBLL(CurrentUserInfo); var vipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(CurrentUserInfo); UnitService unitServer = new UnitService(CurrentUserInfo); if (string.IsNullOrEmpty(unitId)) { unitId = unitServer.GetUnitByUnitTypeForWX("总部", null).Id; //获取总部门店标识 } //根据vipid查询VipCardVipMapping,判断是否有绑卡,没绑卡默认给等级1的卡 var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VIPID = vipId }, null).FirstOrDefault(); if (vipCardMappingInfo == null) { //判断商户是否有付费的会员卡,有付费会员卡时,不自动绑卡 List <IWhereCondition> freeCardCon = new List <IWhereCondition> { }; freeCardCon.Add(new EqualsCondition() { FieldName = "CustomerID", Value = CurrentUserInfo.ClientID }); freeCardCon.Add(new DirectCondition("VipCardLevel=1")); var orderBys = new OrderBy[1]; orderBys[0] = new OrderBy() { FieldName = "VipCardLevel", Direction = OrderByDirections.Asc }; var freeCardTypeInfo = sysVipCardTypeBLL.Query(freeCardCon.ToArray(), orderBys).FirstOrDefault(); if (freeCardTypeInfo != null) { //查询最低等级的会员卡类型 var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardLevel = 1 }, new OrderBy[] { new OrderBy() { FieldName = "vipcardlevel", Direction = OrderByDirections.Asc } }).FirstOrDefault(); if (vipCardTypeInfo != null) { //查询此类型会员卡是否存在 var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardTypeID = vipCardTypeInfo.VipCardTypeID, VipCardStatusId = 0, MembershipUnit = "" }, null).FirstOrDefault(); //不存在,制卡 if (vipCardInfo == null) { vipCardInfo = new VipCardEntity(); vipCardInfo.VipCardID = Guid.NewGuid().ToString(); vipCardInfo.VipCardTypeID = vipCardTypeInfo.VipCardTypeID; vipCardInfo.VipCardTypeName = vipCardTypeInfo.VipCardTypeName; vipCardInfo.VipCardCode = vipCode; vipCardInfo.VipCardStatusId = 1;//正常 vipCardInfo.MembershipUnit = unitId; vipCardInfo.MembershipTime = DateTime.Now; vipCardInfo.CustomerID = CurrentUserInfo.ClientID; vipCardBLL.Create(vipCardInfo); } else//存在更新成现在的 { vipCardInfo.VipCardStatusId = 1;//正常 vipCardInfo.MembershipUnit = unitId; vipCardInfo.MembershipTime = DateTime.Now; vipCardInfo.VipCardTypeID = vipCardTypeInfo.VipCardTypeID; vipCardBLL.Update(vipCardInfo); //存在导入的卡时,更新当前会员的VipCode var vipbll = new VipBLL(CurrentUserInfo); List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0 }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = vipId }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = CurrentUserInfo.ClientID }); var VipInfo = vipbll.Query(wheres.ToArray(), null).FirstOrDefault(); if (VipInfo != null && !string.IsNullOrEmpty(VipInfo.VIPID)) { VipInfo.VipCode = vipCardInfo.VipCardCode; //更新VipCode信息 vipbll.Update(VipInfo); } } //新增会员卡操作状态信息 var vipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = vipCardInfo.VipCardStatusId, VipCardID = vipCardInfo.VipCardID, Action = "注册", UnitID = unitId, CustomerID = CurrentUserInfo.ClientID }; vipCardStatusChangeLogBLL.Create(vipCardStatusChangeLogEntity); //绑定会员卡和会员 var vipCardVipMappingEntity = new VipCardVipMappingEntity() { MappingID = Guid.NewGuid().ToString().Replace("-", ""), VIPID = vipId, VipCardID = vipCardInfo.VipCardID, CustomerID = CurrentUserInfo.ClientID }; vipCardVipMappingBLL.Create(vipCardVipMappingEntity); //开卡礼 var vipCardUpgradeRewardBll = new VipCardUpgradeRewardBLL(CurrentUserInfo); var vipCardUpgradeRewardEntityList = vipCardUpgradeRewardBll.QueryByEntity(new VipCardUpgradeRewardEntity() { VipCardTypeID = vipCardTypeInfo.VipCardTypeID }, null); var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL(); if (vipCardUpgradeRewardEntityList.Length > 0) { foreach (var vipCardUpgradeRewardEntity in vipCardUpgradeRewardEntityList) { for (int i = 0; i < vipCardUpgradeRewardEntity.CouponNum; i++) { redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon() { CustomerId = CurrentUserInfo.ClientID, CouponTypeId = vipCardUpgradeRewardEntity.CouponTypeId.ToString() }, vipCardUpgradeRewardEntity.CardUpgradeRewardId.ToString(), vipId, "OpenVipCard"); } } } } else { throw new APIException("系统未创建会员卡类型") { ErrorCode = ERROR_CODES.INVALID_BUSINESS } }; } } else //更新旧卡 需要确认旧卡是否为卡体系内的卡 { var oldVipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardID = vipCardMappingInfo.VipCardID, CustomerID = CurrentUserInfo.ClientID }, null).FirstOrDefault(); int oldVipCardTypeID = oldVipCardInfo.VipCardTypeID ?? 0; //查询最低等级的会员卡类型 var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardLevel = 1 }, new OrderBy[] { new OrderBy() { FieldName = "vipcardlevel", Direction = OrderByDirections.Asc } }).FirstOrDefault(); if (vipCardTypeInfo == null) { throw new APIException("系统未创建会员卡类型体系") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } if (oldVipCardInfo != null) { //旧卡不为空时,确认当前VipCardTypeID是否属于卡体系 var curvipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity() { CustomerID = CurrentUserInfo.ClientID, Category = 0, VipCardTypeID = oldVipCardInfo.VipCardTypeID }, new OrderBy[] { new OrderBy() { FieldName = "VipCardTypeID", Direction = OrderByDirections.Asc } }).FirstOrDefault(); if (curvipCardTypeInfo == null) //若为空 则更新为当前信息 { oldVipCardInfo.VipCardStatusId = 1; //正常 oldVipCardInfo.MembershipUnit = unitId; oldVipCardInfo.MembershipTime = DateTime.Now; oldVipCardInfo.VipCardTypeID = vipCardTypeInfo.VipCardTypeID; vipCardBLL.Update(oldVipCardInfo); //存在导入的卡时,更新当前会员的VipCode var vipbll = new VipBLL(CurrentUserInfo); List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0 }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = vipId }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = CurrentUserInfo.ClientID }); var VipInfo = vipbll.Query(wheres.ToArray(), null).FirstOrDefault(); if (VipInfo != null && !string.IsNullOrEmpty(VipInfo.VIPID)) { VipInfo.VipCode = oldVipCardInfo.VipCardCode; //更新VipCode信息 vipbll.Update(VipInfo); } //开卡礼 var vipCardUpgradeRewardBll = new VipCardUpgradeRewardBLL(CurrentUserInfo); var vipCardUpgradeRewardEntityList = vipCardUpgradeRewardBll.QueryByEntity(new VipCardUpgradeRewardEntity() { VipCardTypeID = vipCardTypeInfo.VipCardTypeID }, null); var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL(); if (vipCardUpgradeRewardEntityList.Length > 0) { foreach (var vipCardUpgradeRewardEntity in vipCardUpgradeRewardEntityList) { for (int i = 0; i < vipCardUpgradeRewardEntity.CouponNum; i++) { redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon() { CustomerId = CurrentUserInfo.ClientID, CouponTypeId = vipCardUpgradeRewardEntity.CouponTypeId.ToString() }, vipCardUpgradeRewardEntity.CardUpgradeRewardId.ToString(), vipId, "OpenVipCard"); } } } } } //老卡操作状态信息 var oldVipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = oldVipCardInfo.VipCardStatusId, VipCardID = oldVipCardInfo.VipCardID, Action = "注册", UnitID = unitId, CustomerID = CurrentUserInfo.ClientID }; vipCardStatusChangeLogBLL.Create(oldVipCardStatusChangeLogEntity); } //记录会员信息改变,并且把旧的会员的标识也放在契约里 var eventService = new EventService(); var vipMsg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Vip, Id = vipId, }; eventService.PublishMsg(vipMsg); }
/// <summary> /// 分页根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public PagedQueryResult <VipCardEntity> PagedQueryByEntity(VipCardEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex) { return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex)); }
public void updateVipCardByType(string vipId, int vipCardTypeId, string changeReason, string remark, string vipCode, IDbTransaction pTran) { var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); var sysVipCardTypeBLL = new SysVipCardTypeBLL(CurrentUserInfo); var vipCardBLL = new VipCardBLL(CurrentUserInfo); var vipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(CurrentUserInfo); UnitService unitServer = new UnitService(CurrentUserInfo); string unitId = unitServer.GetUnitByUnitTypeForWX("总部", null).Id; //获取总部门店标识 VipCardEntity vipCardInfo = vipCardBLL.GetVipCardByVipMapping(vipId); //更新卡信息 vipCardInfo.VipCardTypeID = vipCardTypeId; vipCardBLL.Update(vipCardInfo, pTran); //var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity() { VipCardTypeID = vipCardTypeId, VipCardStatusId = 0, MembershipUnit = "" }, null).FirstOrDefault(); //不存在,制卡 //if (vipCardInfo == null) //{ // vipCardInfo = new VipCardEntity(); // vipCardInfo.VipCardID = Guid.NewGuid().ToString(); // vipCardInfo.VipCardTypeID = vipCardTypeId; // vipCardInfo.VipCardTypeName = vipCardTypeName; // vipCardInfo.VipCardCode = vipCode; // vipCardInfo.VipCardStatusId = 1;//正常 // vipCardInfo.MembershipUnit = unitId; // vipCardInfo.MembershipTime = DateTime.Now; // vipCardInfo.CustomerID = CurrentUserInfo.ClientID; // vipCardBLL.Create(vipCardInfo, pTran); //} //新增会员卡操作状态信息 var vipCardStatusChangeLogEntity = new VipCardStatusChangeLogEntity() { LogID = Guid.NewGuid().ToString().Replace("-", ""), VipCardStatusID = vipCardInfo.VipCardStatusId, VipCardID = vipCardInfo.VipCardID, Action = "升级", Reason = changeReason, Remark = remark, UnitID = unitId, CustomerID = CurrentUserInfo.ClientID }; vipCardStatusChangeLogBLL.Create(vipCardStatusChangeLogEntity, pTran); var vipCardVipMappingEntity = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity() { VipCardID = vipCardInfo.VipCardID }, null).FirstOrDefault(); vipCardVipMappingEntity.LastUpdateTime = DateTime.Now; vipCardVipMappingBLL.Update(vipCardVipMappingEntity, pTran); //绑定会员卡和会员 //var vipCardVipMappingEntity = new VipCardVipMappingEntity() //{ // MappingID = Guid.NewGuid().ToString().Replace("-", ""), // VIPID = vipId, // VipCardID = vipCardInfo.VipCardID, // CustomerID = CurrentUserInfo.ClientID //}; //vipCardVipMappingBLL.Create(vipCardVipMappingEntity, pTran); //记录会员信息改变,并且把旧的会员的标识也放在契约里 var eventService = new EventService(); var vipMsg = new EventContract { Operation = OptEnum.Update, EntityType = EntityTypeEnum.Vip, Id = vipId, }; eventService.PublishMsg(vipMsg); }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Delete(VipCardEntity pEntity, IDbTransaction pTran) { _currentDAO.Delete(pEntity, pTran); }
public void Update(VipCardEntity dbEntity) { _cmd.Update(dbEntity); }