public ActionResult Index() { int aid = Context.GetRequestInt("aid", 0); ViewBag.appId = aid; XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcxrelation == null) { _returnData.Msg = "还未开通小未平台模板"; return(Json(_returnData)); } AccountRelation accountrelation = AccountRelationBLL.SingleModel.GetModelByAccountId(xcxrelation.AccountId.ToString()); Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(xcxrelation.AccountId.ToString()); ApplyAppView model = new ApplyAppView(); model.Deposit = accountrelation.Deposit; model.IsAgent = agentinfo != null; model.ExitLog = AgentdepositLogBLL.SingleModel.ExitLogByacid(accountrelation.Id); model.AccountRId = accountrelation.Id; return(View(model)); }
public Ignored(AccountRelation relation, WorldAccount account, bool session, Character character) { this.Relation = relation; this.Session = session; this.Account = account; this.Character = character; }
public Ignored(AccountRelation relation, WorldAccount account, bool session, Character character) { Relation = relation; Session = session; Account = account; Character = character; }
public ActionResult DepositLog(string act = "list", int aid = 0, int pageSize = 10, int pageIndex = 1, string name = "", int type = 0, string starttime = "", string endtime = "") { ViewBag.appId = aid; if (act == "list") { return(View()); } _returnData = new Return_Msg(); XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcxrelation == null) { _returnData.Msg = "还未开通小未平台模板"; return(Json(_returnData)); } AccountRelation accountRelation = AccountRelationBLL.SingleModel.GetModelByAccountId(xcxrelation.AccountId.ToString()); int count = 0; List <AgentdepositLog> list = AgentdepositLogBLL.SingleModel.GetList(0, "", type, starttime, endtime, pageSize, pageIndex, out count, accountRelation.Id); _returnData.dataObj = new { data = list, count = count }; _returnData.isok = true; return(Json(_returnData)); }
public bool AddFriend(WorldAccount friendAccount) { var result = CanAddFriend(friendAccount); if (result != null) { FriendHandler.SendFriendAddFailureMessage(Owner.Client, result.Value); return(false); } var relation = new AccountRelation { AccountId = Owner.Client.Account.Id, TargetId = friendAccount.Id, Type = AccountRelationType.Friend }; m_relations.AddOrUpdate(relation.TargetId, relation, (key, value) => { value.Type = AccountRelationType.Friend; return(value); }); Friend friend; var isConnected = friendAccount.ConnectedCharacter.HasValue; if (isConnected) { var character = World.Instance.GetCharacter(friendAccount.ConnectedCharacter.Value); friend = new Friend(relation, friendAccount, character); } else { friend = new Friend(relation, friendAccount); } var success = m_friends.TryAdd(friendAccount.Id, friend); if (success && isConnected) { OnFriendOnline(friend); } else { friend.SetOffline(); } FriendHandler.SendFriendAddedMessage(Owner.Client, friend); return(success); }
public ActionResult Index() { int aid = Context.GetRequestInt("appId", 0); if (aid <= 0) { aid = Context.GetRequestInt("aid", 0); } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); AccountRelation accountRelation = AccountRelationBLL.SingleModel.GetModelByAccountId(xcxrelation.AccountId.ToString()); string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); RedisUtil.Set <string>(string.Format(PlatStatisticalFlowBLL._redis_PlatVisiteTimeKey, aid), nowTime); return(View()); }
public bool AddIgnored(WorldAccount ignoredAccount, bool session = false) { var result = CanAddIgnored(ignoredAccount); if (result != null) { FriendHandler.SendIgnoredAddFailureMessage(Owner.Client, result.Value); return(false); } var relation = new AccountRelation { AccountId = Owner.Client.Account.Id, TargetId = ignoredAccount.Id, Type = AccountRelationType.Ignored }; if (!session) { m_relations.AddOrUpdate(relation.TargetId, relation, (key, value) => { value.Type = AccountRelationType.Ignored; return(value); }); } Ignored ignored; if (ignoredAccount.ConnectedCharacter.HasValue) { var character = World.Instance.GetCharacter(ignoredAccount.ConnectedCharacter.Value); ignored = new Ignored(relation, ignoredAccount, session, character); } else { ignored = new Ignored(relation, ignoredAccount, session); } var success = m_ignoreds.TryAdd(ignoredAccount.Id, ignored); FriendHandler.SendIgnoredAddedMessage(Owner.Client, ignored, session); return(success); }
public bool AddFriend(WorldAccount friendAccount) { ListAddFailureEnum?listAddFailureEnum = this.CanAddFriend(friendAccount); bool result; if (listAddFailureEnum.HasValue) { FriendHandler.SendFriendAddFailureMessage(this.Owner.Client, listAddFailureEnum.Value); result = false; } else { AccountRelation accountRelation = new AccountRelation { AccountId = this.Owner.Client.Account.Id, TargetId = friendAccount.Id, Type = AccountRelationType.Friend }; this.m_relations.AddOrUpdate(accountRelation.TargetId, accountRelation, delegate(int key, AccountRelation value) { value.Type = AccountRelationType.Friend; return(value); }); bool flag; if (friendAccount.ConnectedCharacter.HasValue) { Character character = Singleton <World> .Instance.GetCharacter(friendAccount.ConnectedCharacter.Value); Friend friend = new Friend(accountRelation, friendAccount, character); if (flag = this.m_friends.TryAdd(friendAccount.Id, friend)) { this.OnFriendOnline(friend); } } else { flag = this.m_friends.TryAdd(friendAccount.Id, new Friend(accountRelation, friendAccount)); } FriendHandler.SendFriendsListMessage(this.Owner.Client, this.Friends); result = flag; } return(result); }
public bool AddIgnored(WorldAccount ignoredAccount, bool session = false) { ListAddFailureEnum?listAddFailureEnum = this.CanAddIgnored(ignoredAccount); bool result; if (listAddFailureEnum.HasValue) { FriendHandler.SendIgnoredAddFailureMessage(this.Owner.Client, listAddFailureEnum.Value); result = false; } else { AccountRelation accountRelation = new AccountRelation { AccountId = this.Owner.Client.Account.Id, TargetId = ignoredAccount.Id, Type = AccountRelationType.Ignored }; if (!session) { this.m_relations.AddOrUpdate(accountRelation.TargetId, accountRelation, delegate(int key, AccountRelation value) { value.Type = AccountRelationType.Ignored; return(value); }); } bool flag; if (ignoredAccount.ConnectedCharacter.HasValue) { Character character = Singleton <World> .Instance.GetCharacter(ignoredAccount.ConnectedCharacter.Value); flag = this.m_ignoreds.TryAdd(ignoredAccount.Id, new Ignored(accountRelation, ignoredAccount, session, character)); } else { flag = this.m_ignoreds.TryAdd(ignoredAccount.Id, new Ignored(accountRelation, ignoredAccount, session)); } FriendHandler.SendIgnoredListMessage(this.Owner.Client, this.Ignoreds); result = flag; } return(result); }
public Account WeiXinRegister(string OpenId, int usertype, string Unionid = null, bool ismobilereg = false, string address = "", string phone = "", string sourcefrom = "", string password = "******") { Account account = null; if ((Unionid != null && !string.IsNullOrEmpty(Unionid)) || ismobilereg) { account = GetModel(string.Format(" Unionid='{0}' ", Unionid)); //Account account = bllAccount.GetModel(string.Format(" OpenId='{0}' ", OpenId)); if (account != null && !ismobilereg) { return(account); } account = new Account(); account.OpenId = OpenId; account.UnionId = Unionid; account.ConsigneePhone = phone; ////判断是否是普通用户注册,如果是0普通用户注册,则必须要验证手机号码,才能启用账号 //account.Status = usertype == 1 ? false : true; //--生成随机唯一登录ID account.LoginId = GenerateRandomLoginId("vzan", 8); //---密码加密MD5 account.Password = DESEncryptTools.GetMd5Base32(password); Member member = new Member() { AccountId = account.Id }; member.ConsigneePhone1 = phone; member.CompanyRemark = address; member.Avatar = sourcefrom; //--随机唯一登录ID 座位默认昵称 member.MemberName = account.LoginId; base.Add(account); //添加用户账户表 MemberBLL.SingleModel.Add(member); //添加用户信息表 //建立关联 AccountRelation accountrelaton = new AccountRelation(); accountrelaton.AccountId = account.Id.ToString(); accountrelaton.AddTime = DateTime.Now; AccountRelationBLL.SingleModel.Add(accountrelaton); } return(account); }
// GET: public ActionResult Index() { int aid = Context.GetRequestInt("appId", 0); if (aid <= 0) { aid = Context.GetRequestInt("aid", 0); } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); AccountRelation accountrelation = AccountRelationBLL.SingleModel.GetModelByAccountId(xcxrelation.AccountId.ToString()); QiyeStore qiyeStore = QiyeStoreBLL.SingleModel.GetModelByAId(aid); if (qiyeStore == null) { qiyeStore = new QiyeStore(); qiyeStore.Aid = aid; qiyeStore.AddTime = DateTime.Now; qiyeStore.UpdateTime = DateTime.Now; qiyeStore.SwitchModel = new QiyeStoreSwitchModel(); qiyeStore.SwitchConfig = JsonConvert.SerializeObject(qiyeStore.SwitchModel); int id = Convert.ToInt32(QiyeStoreBLL.SingleModel.Add(qiyeStore)); if (id <= 0) { return(View("PageError", new QiyeReturnMsg() { Msg = "初始化数据失败!", code = "500" })); } } return(View()); }
public Friend(AccountRelation relation, WorldAccount account, Character character) { this.Relation = relation; this.Account = account; this.Character = character; }
public Friend(AccountRelation relation, WorldAccount account) { this.Relation = relation; this.Account = account; }
/// <summary> /// 续期 /// </summary> /// <param name="platApplyAppModel"></param> /// <param name="accountid"></param> /// <param name="uselength"></param> /// <param name="tid"></param> /// <param name="msg"></param> /// <returns></returns> public bool AddTimeLength(PlatApplyApp platApplyAppModel, string accountid, int uselength, int tid, ref string msg) { DateTime nowtime = DateTime.Now; TransactionModel tran = new TransactionModel(); #region 基础验证 bool success = false; if (platApplyAppModel == null) { msg = "申请记录为空"; return(false); } //名片管理登陆账号 PlatMyCard mycardmodel = PlatMyCardBLL.SingleModel.GetModel(platApplyAppModel.MycardId); if (mycardmodel == null) { msg = "名片过期"; return(false); } //判断是否已开通 if (string.IsNullOrEmpty(mycardmodel.LoginId)) { msg = "该用户还没开通小程序"; return(false); } //店铺数据 PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(platApplyAppModel.StoreId); if (platStore == null) { msg = "店铺过期,请刷新重试"; return(false); } #endregion #region 使用中的模板数据 XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(platStore.Aid); if (xcxrelation == null) { msg = "模板数据过期"; return(false); } if (xcxrelation.outtime < nowtime) { xcxrelation.outtime = nowtime.AddYears(uselength); } else { xcxrelation.outtime = xcxrelation.outtime.AddYears(uselength); } tran.Add($"update XcxAppAccountRelation set outtime='{xcxrelation.outtime}',state=1 where id={xcxrelation.Id}"); #endregion //用户基础数据,获取普通预存款 AccountRelation accountrelation = AccountRelationBLL.SingleModel.GetModelByAccountId(accountid); //代理数据 Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(accountid); #region 模板跟模板价格 XcxTemplate tempinfo = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版); if (tempinfo != null && agentinfo != null) { List <XcxTemplate> xcxlist = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tempinfo.Id})", agentinfo.id); if (xcxlist != null && xcxlist.Count > 0) { //代理过期检验 AgentinfoBLL.SingleModel.CheckOutTime(ref xcxlist, agentinfo, 0, ref msg); tempinfo = xcxlist[0]; } } if (tempinfo == null) { msg = "模板数据为空"; return(false); } #endregion #region 扣费 //扣除总费用 int sum = tempinfo.Price * uselength; //变更前金额 int deposit = 0; //变更后的金额 int afterdeposit = 0; //扣除代理费用 if (agentinfo != null) { //变更前金额 deposit = agentinfo.deposit; //判断余额是否满足扣费 if (deposit + accountrelation.Deposit < sum) { msg = "余额不足"; return(false); } //变更后金额 if (deposit >= sum) { afterdeposit = deposit - sum; tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}"); } else if (accountrelation.Deposit >= sum) { afterdeposit = accountrelation.Deposit - sum; tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}"); } else { //先扣除普通用户预存,再扣除代理商预存 afterdeposit = agentinfo.deposit - (sum - accountrelation.Deposit); tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}"); tran.Add($"UPDATE AccountRelation set deposit=0 ,updatetime='{nowtime}' where id={accountrelation.Id}"); } } //扣除普通账号预存款 else { sum = 100 * uselength; //变更前金额 deposit = accountrelation.Deposit; //判断余额是否满足扣费 if (deposit < sum) { msg = "余额不足"; return(false); } //变更后金额 afterdeposit = deposit - sum; tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}"); } #endregion #region 开通流水 AgentdepositLog agentLog = new AgentdepositLog(); agentLog.agentid = agentinfo != null ? agentinfo.id : 0; agentLog.addtime = nowtime; agentLog.templateCount = 1; agentLog.customerid = xcxrelation.AccountId.ToString(); agentLog.tid = tempinfo.Id; agentLog.type = agentinfo != null ? (int)AgentDepositLogType.代理商续费 : (int)AgentDepositLogType.普通用户续费模板; agentLog.templateCount = 1; agentLog.beforeDeposit = deposit; agentLog.cost = sum; agentLog.acid = agentinfo != null ? 0 : accountrelation.Id; agentLog.Rid = platApplyAppModel.BindAId; agentLog.afterDeposit = afterdeposit; string desc = $"客户:{mycardmodel.Name} 续期模板:{tempinfo.TName} 续期年限:{uselength}年"; agentLog.costdetail = desc; tran.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentLog)); #endregion success = base.ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray); //清除缓存 XcxAppAccountRelationBLL.SingleModel.RemoveRedis(xcxrelation.Id); return(success); }
/// <summary> /// 开通独立小程序 /// </summary> /// <param name="platApplyAppModel"></param> /// <param name="accountid"></param> /// <param name="uselength"></param> /// <param name="tid"></param> /// <param name="msg"></param> /// <returns></returns> public bool OpenStore(PlatApplyApp platApplyAppModel, string accountid, int uselength, int tid, ref string msg) { DateTime nowtime = DateTime.Now; TransactionModel tran = new TransactionModel(); bool success = false; if (platApplyAppModel == null) { msg = "申请记录为空"; return(false); } //用户基础数据,获取普通预存款 AccountRelation accountrelation = AccountRelationBLL.SingleModel.GetModelByAccountId(accountid); Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(accountid); #region 模板跟模板价格 XcxTemplate tempinfo = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版); if (tempinfo != null && agentinfo != null) { List <XcxTemplate> xcxlist = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tempinfo.Id})", agentinfo.id); if (xcxlist != null && xcxlist.Count > 0) { //代理过期检验 AgentinfoBLL.SingleModel.CheckOutTime(ref xcxlist, agentinfo, 0, ref msg); tempinfo = xcxlist[0]; } } if (tempinfo == null) { msg = "模板数据为空"; return(false); } #endregion #region 扣费 //扣除总费用 int sum = tempinfo.Price * uselength; //变更前金额 int deposit = 0; //变更后的金额 int afterdeposit = 0; //扣除代理费用 if (agentinfo != null) { //首次开通免费 if (AgentdepositLogBLL.SingleModel.IsFirstOpen(agentinfo.id, 2, 0)) { sum = 0; uselength = 1; } //变更前金额 deposit = agentinfo.deposit; //判断余额是否满足扣费 if (deposit + accountrelation.Deposit < sum) { msg = "余额不足"; return(false); } //变更后金额,先扣除普通用户账号预存款 if (accountrelation.Deposit > 0) { if (accountrelation.Deposit >= sum) { afterdeposit = accountrelation.Deposit - sum; tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}"); } else { //先扣除普通用户预存,再扣除代理商预存 afterdeposit = agentinfo.deposit - (sum - accountrelation.Deposit); tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}"); tran.Add($"UPDATE AccountRelation set deposit=0 ,updatetime='{nowtime}' where id={accountrelation.Id}"); } } else { afterdeposit = deposit - sum; tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}"); } } //扣除普通账号预存款 else { //首次开通免费 if (AgentdepositLogBLL.SingleModel.IsFirstOpen(0, 13, accountrelation.Id)) { sum = 0; } else { sum = 100 * uselength; } //变更前金额 deposit = accountrelation.Deposit; //判断余额是否满足扣费 if (deposit < sum) { msg = "余额不足"; return(false); } //变更后金额 afterdeposit = deposit - sum; tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}"); } #endregion //名片管理登陆账号 PlatMyCard mycardmodel = PlatMyCardBLL.SingleModel.GetModel(platApplyAppModel.MycardId); if (mycardmodel == null) { msg = "名片过期"; return(false); } //判断是否已开通 if (!string.IsNullOrEmpty(mycardmodel.LoginId)) { msg = "该用户已开通过,请刷新看看"; return(false); } //开通后台账号 Account account = AccountBLL.SingleModel.WeiXinRegister("", 0, "", true, "", "", "小未平台开通独立小程序"); if (account == null) { msg = "注册后台账号失败"; return(false); } mycardmodel.LoginId = account.LoginId; mycardmodel.UpdateTime = nowtime; tran.Add(PlatMyCardBLL.SingleModel.BuildUpdateSql(mycardmodel, "LoginId,UpdateTime")); //申请开通记录 platApplyAppModel.UserId = mycardmodel.UserId; platApplyAppModel.OpenState = 1; platApplyAppModel.OpenTime = nowtime; platApplyAppModel.UpdateTime = nowtime; tran.Add(base.BuildUpdateSql(platApplyAppModel, "OpenState,OpenTime,UpdateTime,UserId")); //开通独立小程序模板 tran.Add($@"insert into XcxAppAccountRelation(TId,AccountId,AddTime,Url,price,outtime,agentid) values({tempinfo.Id}, '{account.Id}', '{nowtime}', '{tempinfo.Link}', {tempinfo.Price}, '{nowtime.AddYears(uselength)}',{(agentinfo != null ? agentinfo.id : 0)})"); //绑定店铺 PlatStore platstoremodel = PlatStoreBLL.SingleModel.GetModel(platApplyAppModel.StoreId); if (platstoremodel == null) { msg = "店铺已过期,请刷新重试"; return(false); } tran.Add($"update PlatStore set aid=(select last_insert_id()),UpdateTime='{nowtime}' where id={platstoremodel.Id}"); #region 开通流水 AgentdepositLog agentLog = new AgentdepositLog(); agentLog.agentid = agentinfo != null ? agentinfo.id : 0; agentLog.addtime = nowtime; agentLog.templateCount = 1; agentLog.customerid = account.Id.ToString(); agentLog.tid = tempinfo.Id; agentLog.type = agentinfo != null ? (int)AgentDepositLogType.开通客户模板 : (int)AgentDepositLogType.普通用户开通模板; agentLog.templateCount = 1; agentLog.beforeDeposit = deposit; agentLog.cost = sum; agentLog.Rid = platApplyAppModel.BindAId; agentLog.acid = agentinfo != null ? 0 : accountrelation.Id; agentLog.afterDeposit = afterdeposit; string desc = $"客户:{mycardmodel.Name} 开通模板:{tempinfo.TName} 开通数量:1"; agentLog.costdetail = desc; tran.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentLog)); #endregion //执行事务 success = base.ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray); return(success); }
public Friend(AccountRelation relation, WorldAccount account) { Relation = relation; Account = account; }
public Ignored(AccountRelation relation, WorldAccount account, bool session) { Relation = relation; Session = session; Account = account; }
public Ignored(AccountRelation relation, WorldAccount account, bool session) { this.Relation = relation; this.Session = session; this.Account = account; }
public async Task Process(SetAccountRelation rel) { if (!IsLoggedIn) { return; } if (string.IsNullOrEmpty(rel.TargetName) && string.IsNullOrEmpty(rel.SteamID)) { return; } using (var db = new ZkDataContext()) { ulong steamId = 0; var srcAccount = db.Accounts.Find(User.AccountID); ulong.TryParse(rel.SteamID, out steamId); var trgtAccount = Account.AccountByName(db, rel.TargetName) ?? db.Accounts.FirstOrDefault(x => x.SteamID == steamId); if (trgtAccount == null) { if (!string.IsNullOrEmpty(rel.TargetName)) { await Respond("No such account found"); // only warn if name is set and not just steam id } return; } var friendAdded = false; var entry = srcAccount.RelalationsByOwner.FirstOrDefault(x => x.TargetAccountID == trgtAccount.AccountID); if ((rel.Relation == Relation.None) && (entry != null)) { db.AccountRelations.Remove(entry); } if (rel.Relation != Relation.None) { if (entry == null) { if (rel.Relation == Relation.Friend) { friendAdded = true; } entry = new AccountRelation() { Owner = srcAccount, Target = trgtAccount, Relation = rel.Relation }; srcAccount.RelalationsByOwner.Add(entry); } else { entry.Relation = rel.Relation; } } db.SaveChanges(); ConnectedUser targetConnectedUser; if (server.ConnectedUsers.TryGetValue(trgtAccount.Name, out targetConnectedUser)) { targetConnectedUser.LoadFriendsIgnores(); // update partner's mutual lists if (friendAdded) // friend added, sync new friend to me (user, battle and channels) { await server.TwoWaySyncUsers(Name, new List <string>() { targetConnectedUser.Name }); foreach (var chan in server.Channels.Values.Where( x => (x != null) && x.Users.ContainsKey(Name) && x.Users.ContainsKey(targetConnectedUser.Name))) { await SendCommand(new ChannelUserAdded() { ChannelName = chan.Name, UserName = targetConnectedUser.Name }); } } } LoadFriendsIgnores(); await SendCommand(new FriendList() { Friends = FriendEntries.ToList() }); await SendCommand(new IgnoreList() { Ignores = Ignores.ToList() }); } }
public Friend(AccountRelation relation, WorldAccount account, Character character) { Relation = relation; Account = account; Character = character; }