public int ActiveCard(APIRequest <ActiveCardRP> rp) { var cardDepositBLL = new CardDepositBLL(CurrentUserInfo); var cardDeposit = PagedSearch(new GetCardRP() { CardNo = rp.Parameters.CardNo, UseStatus = "0" }, CurrentUserInfo.ClientID); int result = 0; if (cardDeposit != null && cardDeposit.Tables.Count > 0 && cardDeposit.Tables[0].Rows.Count > 0) { DataRow dr = cardDeposit.Tables[0].Rows[0]; if (rp.Parameters.CardPassword == System.Text.Encoding.UTF8.GetString(cardDepositBLL.DecryptCardPassword((byte[])dr["CardPassword"])).Replace("\0", "")) { System.Data.SqlClient.SqlTransaction tran = GetTran(); using (tran.Connection) { string errorMessage = ""; VipAmountBLL vipAmountBLL = new VipAmountBLL(CurrentUserInfo); vipAmountBLL.SetVipAmountChange(CurrentUserInfo.ClientID, 4, rp.Parameters.VipID, decimal.Parse(dr["Amount"].ToString()) + decimal.Parse(dr["Bonus"].ToString()), dr["CardDepositId"].ToString(), "Prepaid card charge", "In", out errorMessage, tran); result = this._currentDAO.ActiveCard(rp.Parameters.CardNo, rp.Parameters.VipID, this.CurrentUserInfo.UserID, this.CurrentUserInfo.ClientID, tran); tran.Commit(); } } } return(result); }
public SuccessResponse <IAPIResponseData> VipConsume(APIRequest <VipConsumeRP> rp) { var cardDepositBLL = new CardDepositBLL(CurrentUserInfo); var registerValidationCodeBLL = new RegisterValidationCodeBLL(CurrentUserInfo); var vipBLL = new VipBLL(CurrentUserInfo); var rd = new EmptyRD(); var rsp = new SuccessResponse <IAPIResponseData>(rd); string phone = ""; var vip = vipBLL.Query(new IWhereCondition[] { new EqualsCondition() { FieldName = "VipID", Value = rp.Parameters.VipID } }, null); if (vip.Length > 0) { phone = vip[0].Phone; if (string.IsNullOrEmpty(phone)) { rsp.ResultCode = 202; rsp.Message = "会员未注册手机号!"; } else if (string.IsNullOrEmpty(rp.Parameters.SMSCode)) { //发送验证码 registerValidationCodeBLL.SendCode(phone); } else { //验证验证码 var codeEntity = registerValidationCodeBLL.Query(new IWhereCondition[] { new EqualsCondition() { FieldName = "Mobile", Value = phone } , new EqualsCondition() { FieldName = "Code", Value = rp.Parameters.SMSCode } , new EqualsCondition() { FieldName = "IsValidated", Value = 0 } , new EqualsCondition() { FieldName = "IsDelete", Value = 0 } }, new OrderBy[] { new OrderBy() { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }); if (codeEntity != null && codeEntity.Length > 0) { System.Data.SqlClient.SqlTransaction tran = GetTran(); using (tran.Connection) { registerValidationCodeBLL.DeleteByMobile(phone, 1, tran); string errorMessage = ""; VipAmountBLL vipAmountBLL = new VipAmountBLL(CurrentUserInfo); vipAmountBLL.SetVipAmountChange(CurrentUserInfo.ClientID, 5, rp.Parameters.VipID, rp.Parameters.Amount, CurrentUserInfo.CurrentUserRole.UnitId, "Prepaid card consumption" + "~" + (rp.Parameters.DocumentCode ?? ""), "Out", out errorMessage, tran); tran.Commit(); } } else { rsp.ResultCode = 203; rsp.Message = "请先获取验证码!"; } } } else { rsp.ResultCode = 201; rsp.Message = "会员不存在!"; } return(rsp); }