/// <summary> /// 免费版全部显示小未平台水印 /// </summary> /// <param name="xcxrelationModel"></param> /// <param name="agentinfo"></param> /// <param name="agentConfig"></param> /// <param name="bottomLogHost"></param> /// <param name="bottomLogImg"></param> /// <param name="bottomLogChildTitle"></param> /// <param name="bottomLogTitle"></param> /// <returns></returns> public bool CheckFeeTemplateShuiying(XcxAppAccountRelation xcxrelationModel, Agentinfo agentinfo, ref AgentConfig agentConfig, string bottomLogHost, string bottomLogImg, string bottomLogChildTitle, string bottomLogTitle) { //如果是子模板,则另外处理,所有免费版都挂上公司自己的logo switch (xcxrelationModel.Type) { case (int)TmpType.小未平台子模版: case (int)TmpType.小程序单页模板: case (int)TmpType.小程序企业模板: case (int)TmpType.小程序专业模板: //判断代理是否开启免费也能自定义水印 if (GetAgentFeeOpenShuiying(agentinfo)) { break; } //只有专业基础版才是免费的 if (xcxrelationModel.Type == (int)TmpType.小程序专业模板 && xcxrelationModel.VersionId != 3) { break; } agentConfig.IsOpenAdv = 1; agentConfig.LogoHost = bottomLogHost; agentConfig.LogoImgUrl = bottomLogImg; agentConfig.LogoTitle = xcxrelationModel.Type == (int)TmpType.小未平台子模版 ? bottomLogChildTitle : bottomLogTitle; return(true); } return(false); }
public ActionResult GetUserData() { Return_Msg msg = new Return_Msg(); ViewModelMyWorkbench model = new ViewModelMyWorkbench(); model._Member = MemberBLL.SingleModel.GetModel(string.Format("AccountId='{0}'", dzuserId)); model._Account = AccountBLL.SingleModel.GetModel(dzuserId); if (model._Member != null) { if (model._Account != null) { Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(model._Account.Id.ToString()); msg.isok = true; msg.Msg = "成功"; msg.dataObj = new { userinfo = model._Account, agentinfo = agentinfo, isagent = agentinfo != null ? 1 : 0 }; return(Json(msg, JsonRequestBehavior.AllowGet)); } else { CookieHelper.Remove("dz_UserCookieNew"); return(RedirectToAction("Login", "dzhome")); } } else { CookieHelper.Remove("dz_UserCookieNew"); return(RedirectToAction("Login", "dzhome")); } }
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)); }
/// <summary> /// 发送验证码修改密码 /// </summary> /// <returns></returns> public ActionResult GetVaildCode() { Return_Msg data = new Return_Msg(); string phoneNum = Context.GetRequest("phonenum", ""); //修改密码 type=0 注册type=1 int type = Context.GetRequestInt("type", 0); Account account = AccountBLL.SingleModel.GetModelByPhone(phoneNum); //代理分销,判断是否已开通过代理,开通过代理就不给他开通 int agentqrcodeid = Context.GetRequestInt("agentqrcodeid", 0); if (agentqrcodeid > 0 && account != null) { Agentinfo agentmodel = AgentinfoBLL.SingleModel.GetModelByAccoundId(account.Id.ToString(), -1); if (agentmodel != null) { data.Msg = "该手机号已经绑定了代理商账号"; return(Json(data, JsonRequestBehavior.AllowGet)); } } data = CommondHelper.GetVaildCode(agentqrcodeid, phoneNum, account, type); return(Json(data)); }
/// <summary> /// 获取用户更新日志 /// </summary> /// <returns></returns> public List <SystemUpdateMessage> GetSystemUpdateMessageList(string accountid, string accountaddtime) { RedisModel <SystemUpdateMessage> model = new RedisModel <SystemUpdateMessage>(); model = RedisUtil.Get <RedisModel <SystemUpdateMessage> >(string.Format(_redis_systempupdatelogkey, accountid)); int dataversion = RedisUtil.GetVersion(_redis_systempupdatelogversion); if (model == null || model.DataList == null || model.DataList.Count <= 0 || model.DataVersion != dataversion) { int agentid = 0; //判断是否是代理商 Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(accountid); if (agentinfo != null) { agentid = agentinfo.id; } model = new RedisModel <SystemUpdateMessage>(); List <SystemUpdateMessage> list = new List <SystemUpdateMessage>(); //系统更新日志数量 int smessagecount = GetSystemMessageCount(0); //用户查看日志数量 int smessageuserlogcount = SystemUpdateUserLogBLL.SingleModel.GetSMessageUserLogCount(accountid); //判断用户是否有未查看的更新日志 if (!(smessagecount > 0 && smessagecount == smessageuserlogcount)) { string sqlwhere = $"state=0 and (type in (0,1) and updatetime>='{accountaddtime}' or (type=2 and accountid='{accountid}'))"; //如果不是代理商,查询相对应的系统更新 if (agentid <= 0) { sqlwhere = $"state=0 and ((type=0 and updatetime>='{accountaddtime}') or (type=2 and accountid='{accountid}'))"; //获取查询用户开通模板最小时间查询语句, string tids = XcxAppAccountRelationBLL.SingleModel.GetListXcxappListSQL(accountid); if (!string.IsNullOrEmpty(tids)) { sqlwhere = $"state=0 and ((type=0 and updatetime>='{accountaddtime}') or (type=2 and accountid='{accountid}') {tids})"; } } List <SystemUpdateUserLog> logs = SystemUpdateUserLogBLL.SingleModel.GetList($"state = 1 and accountid = '{accountid}'"); if (logs != null && logs.Count > 0) { sqlwhere += string.Format(" and id not in({0})", string.Join(",", logs.Select(s => s.UpdateMessageId).Distinct())); } //获取还未查看的系统更新日志 list = GetList(sqlwhere, 10000, 1, "", "updatetime desc"); } model.DataList = list; model.DataVersion = dataversion; RedisUtil.Set <RedisModel <SystemUpdateMessage> >(string.Format(_redis_systempupdatelogkey, accountid), model); } return(model.DataList); }
/// <summary> /// 赠送代理平台模板 /// </summary> /// <param name="accountModel"></param> public void AddTemplate(Account accountModel, Agentinfo agentInfo) { if (agentInfo == null && agentInfo.userLevel == 0) { return; } string typeids = $"{(int)TmpType.小未平台}"; List <XcxTemplate> templist = XcxTemplateBLL.SingleModel.GetListByTypes(typeids); if (templist == null || templist.Count <= 0 || accountModel == null) { return; } List <XcxAppAccountRelation> usertemplate = GetListByTidAccountId($"'{accountModel.Id.ToString()}'", templist[0].Id); if (usertemplate != null && usertemplate.Count > 0) { return; } TransactionModel tran = new TransactionModel(); DateTime nowtime = DateTime.Now; foreach (XcxTemplate item in templist) { tran.Add($@"insert into XcxAppAccountRelation(TId,AccountId,AddTime,Url,price,outtime,agentid) values({item.Id}, '{accountModel.Id}', '{nowtime}', '{item.Link}', {item.Price}, '{agentInfo.addtime.AddYears(1)}',0)"); AgentdepositLog pricemodellog = new AgentdepositLog(); pricemodellog.addtime = DateTime.Now; pricemodellog.afterDeposit = 0; pricemodellog.agentid = 0; pricemodellog.beforeDeposit = 0; pricemodellog.cost = 0; pricemodellog.costdetail = $"客户免费使用小程序模板:" + item.TName; pricemodellog.type = 0; pricemodellog.tid = item.Id; tran.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(pricemodellog)); } if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)) { log4net.LogHelper.WriteInfo(this.GetType(), "赠送免费版:失败," + Newtonsoft.Json.JsonConvert.SerializeObject(tran)); } }
public ActionResult GetDataList() { _returnData = new Return_Msg(); int pageSize = Context.GetRequestInt("pageSize", 10); int pageIndex = Context.GetRequestInt("pageIndex", 1); int aid = Context.GetRequestInt("aid", 0); int openState = Context.GetRequestInt("openstate", -1); int xcxappState = Context.GetRequestInt("xcxappstate", -2); int dayLength = Context.GetRequestInt("daylength", 0); string customerName = Context.GetRequest("customername", string.Empty); string storeName = Context.GetRequest("storename", string.Empty); string loginId = Context.GetRequest("loginid", string.Empty); if (aid <= 0) { _returnData.Msg = "参数错误"; return(Json(_returnData)); } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcxrelation == null) { _returnData.Msg = "还未开通小未平台模板"; return(Json(_returnData)); } Agentinfo agentinfoModel = AgentinfoBLL.SingleModel.GetModelByAccoundId(xcxrelation.AccountId.ToString()); int count = 0; List <PlatApplyApp> list = PlatApplyAppBLL.SingleModel.GetDataList(xcxrelation.AppId, dayLength, customerName, loginId, storeName, openState, xcxappState, aid, pageSize, pageIndex, ref count); XcxTemplate tempInfo = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版); if (tempInfo != null && agentinfoModel != null) { List <XcxTemplate> xcxList = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tempInfo.Id})", agentinfoModel.id); if (xcxList != null && xcxList.Count > 0) { tempInfo = xcxList[0]; } } _returnData.isok = true; _returnData.dataObj = new { data = list, count = count, tempinfo = tempInfo }; return(Json(_returnData)); }
public bool UpdateState(Distribution distribution, Agentinfo dagentInfo) { TransactionModel tranModel = new TransactionModel(); bool result = false; tranModel.Add($"update Distribution set state={distribution.state},modifyDate='{distribution.modifyDate}' where id={distribution.id}"); tranModel.Add($"update Agentinfo set state={dagentInfo.state},updateitme='{dagentInfo.updateitme}' where id={dagentInfo.id}"); try { result = base.ExecuteTransactionDataCorect(tranModel.sqlArray, tranModel.ParameterArray); } catch (Exception) { log4net.LogHelper.WriteInfo(this.GetType(), Newtonsoft.Json.JsonConvert.SerializeObject(tranModel.sqlArray)); } return(result); }
/// <summary> /// 代理是否开启了免费版也可以自定义水印 /// </summary> /// <param name="agentinfo"></param> /// <returns></returns> public bool GetAgentFeeOpenShuiying(Agentinfo agentinfo) { if (agentinfo != null) { //判断代理是否开启免费也能自定义水印 if (!string.IsNullOrEmpty(agentinfo.configjson)) { AgentConfig agentConfig = JsonConvert.DeserializeObject <AgentConfig>(agentinfo.configjson); if (agentConfig.OpenFeeShuiying == 1) { return(true); } } } return(false); }
public bool AddagentinfoLogV2(Agentinfo agentinfo, Distribution distribution, List <XcxTemplate> xcxList, string userName, string userId, ref TransactionModel trans, int openType = 0, int aid = 0, int isDistribut = 0) { if (xcxList == null || xcxList.Count <= 0) { return(false); } AgentdepositLog agentLog = new AgentdepositLog(); DateTime date = DateTime.Now; agentLog.agentid = agentinfo.id; agentLog.addtime = date; agentLog.templateCount = 1; agentLog.customerid = userId; agentLog.Rid = aid; string desc = ""; int cost = 0; int tempOpenType = openType; foreach (XcxTemplate xcx in xcxList) { openType = tempOpenType; cost = 0; desc = $"客户:{userName} 开通模板:{xcx.TName} 开通数量:" + xcx.buycount; if (isDistribut == 1) { desc = $"分销商:{distribution.name} 开通模板:{xcx.TName} 开通数量:" + xcx.buycount; } //整理消费日志 GetCommondLog(ref openType, ref cost, ref desc, ref agentLog, xcx, userName, "", isDistribut); agentLog.tid = xcx.Id; agentLog.type = openType > 0 ? openType : 2; agentLog.templateCount = openType > 0 ? xcx.storecount : xcx.buycount; agentLog.beforeDeposit = agentinfo.deposit; agentLog.cost = xcx.sumprice; agentLog.afterDeposit = agentinfo.deposit - xcx.sumprice; agentLog.costdetail = desc; trans.Add(base.BuildAddSql(agentLog)); agentinfo.deposit -= xcx.sumprice; } return(true); }
public ActionResult GetDataList() { _agentDistributionRelationBLL = new AgentDistributionRelationBLL(); _returnData = new Return_Msg(); int pageSize = Context.GetRequestInt("pageSize", 10); int pageIndex = Context.GetRequestInt("pageIndex", 1); int aid = Context.GetRequestInt("aid", 0); int opensyncData = Context.GetRequestInt("opensyncdata", 0); string dname = Context.GetRequest("dname", string.Empty); string aname = Context.GetRequest("aname", string.Empty); if (aid <= 0) { _returnData.Msg = "参数错误"; return(Json(_returnData)); } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcxrelation == null) { _returnData.Msg = "模板不存在"; return(Json(_returnData)); } Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(xcxrelation.AccountId.ToString()); if (agentinfo == null) { _returnData.Msg = "您还未成为代理商"; return(Json(_returnData)); } int count = 0; List <AgentDistributionRelation> list = _agentDistributionRelationBLL.GetSysnDataList(dname, aname, agentinfo.id, opensyncData, pageSize, pageIndex, ref count); _returnData.isok = true; _returnData.dataObj = new { data = list, count = count }; return(Json(_returnData)); }
/// <summary> /// 代理商免费体验所有付费模板30天 /// </summary> public ActionResult OpenFreeExperience() { Return_Msg data = new Return_Msg(); Account account = AccountBLL.SingleModel.GetModel(dzuserId); int daylength = WebSiteConfig.ExperienceDayLength; if (account == null) { return(RedirectToAction("login", "dzhome")); } Agentinfo agentmodel = AgentinfoBLL.SingleModel.GetModelByAccoundId(dzuserId.ToString()); if (agentmodel == null) { data.Msg = "您还不是代理商"; return(Json(data)); } string tids = Context.GetRequest("tids", ""); if (string.IsNullOrEmpty(tids)) { data.Msg = "请选择开通的模板"; return(Json(data)); } string errormsg = "开通成功"; bool isSuccess = XcxAppAccountRelationBLL.SingleModel.OpenExperience(agentmodel, tids, account, ref errormsg, daylength); if (!isSuccess) { errormsg = "开通失败"; } data.isok = isSuccess; data.Msg = errormsg; return(Json(data)); }
public bool AddDistribution(Account account, int parentAgentId, int agenttype, string username, List <XcxTemplate> templateList, int deposit, string remark, ref string msg) { bool result = false; TransactionModel tranModel = new TransactionModel(); MySqlParameter[] pone = null; //代理商扣费 Agentinfo agentinfop = AgentinfoBLL.SingleModel.GetModel(parentAgentId); if (agentinfop == null) { msg = "代理商不存在"; return(false); } List <Distribution> dlist = GetListByAgentId(agentinfop.id); if (dlist != null && dlist.Count > 0) { string agentids = string.Join(",", dlist.Select(s => s.AgentId)); List <Agentinfo> cagentinfolist = AgentinfoBLL.SingleModel.GetListByIds(agentids); if (cagentinfolist != null && cagentinfolist.Count > 0) { int cost = cagentinfolist.Sum(s => s.deposit) + deposit; if (agentinfop.deposit <= cost && deposit > 0) { msg = "代理商预存款不足"; return(false); } } } //tranModel.Add($"update Agentinfo set deposit={cost} where id={agentinfop.id}"); //AgentdepositLog agentdepositLog = new AgentdepositLog(); //agentdepositLog.agentid = agentinfop.id; //agentdepositLog.addtime = DateTime.Now; //agentdepositLog.beforeDeposit = agentinfop.deposit; //agentdepositLog.cost = deposit; //agentdepositLog.afterDeposit = cost; //agentdepositLog.type = 13; //agentdepositLog.customerid = agentinfop.useraccountid; //agentdepositLog.costdetail = $"为分销代理商{username}充值{(deposit*0.01).ToString("0.00")}"; //tranModel.Add(_agentdepositLogBll.BuildAddSql(agentdepositLog, out pone), pone); //插入代理表 Agentinfo agent = new Agentinfo(); agent.state = 1; agent.deposit = deposit; agent.addtime = DateTime.Now; agent.updateitme = DateTime.Now; agent.useraccountid = account.Id.ToString(); agent.userLevel = 1; agent.AgentType = agenttype; agent.id = Convert.ToInt32(AgentinfoBLL.SingleModel.Add(agent)); if (agent.id <= 0) { return(result); } tranModel.Add($"update Agentinfo set deposit={deposit} where id={agent.id}"); AgentdepositLog agentdepositLog = new AgentdepositLog(); agentdepositLog.agentid = agent.id; agentdepositLog.addtime = DateTime.Now; agentdepositLog.beforeDeposit = 0; agentdepositLog.cost = agent.deposit; agentdepositLog.afterDeposit = agentdepositLog.beforeDeposit + agent.deposit; agentdepositLog.type = 1; tranModel.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentdepositLog, out pone), pone); //插入小程序模板与代理关系表 自定义价格 foreach (var template in templateList) { Xcxtemplate_Price xcxtemplate_Price = Xcxtemplate_PriceBLL.SingleModel.GetModel($"tid={template.Id} and agentid={agent.id} and VersionId={template.VersionId}"); if (xcxtemplate_Price == null) { xcxtemplate_Price = new Xcxtemplate_Price(); xcxtemplate_Price.price = template.Price; xcxtemplate_Price.tid = template.Id.ToString(); xcxtemplate_Price.agentid = agent.id.ToString(); xcxtemplate_Price.VersionId = template.VersionId; if (template.Price <= 0) { xcxtemplate_Price.LimitCount = template.LimitCount <= 0?10: template.LimitCount; } tranModel.Add(Xcxtemplate_PriceBLL.SingleModel.BuildAddSql(xcxtemplate_Price, out pone), pone); } else { tranModel.Add($"update xcxtemplate_Price set price={template.Price} where tid={template.Id} and agentid={agent.id} and VersionId={template.VersionId}"); } } //插入分销商表 Distribution distribution = new Distribution(); distribution.name = username; distribution.AgentId = agent.id; distribution.useraccountid = account.Id.ToString(); distribution.parentAgentId = parentAgentId; distribution.state = 1; distribution.remark = remark; distribution.addtime = DateTime.Now; distribution.modifyDate = DateTime.Now; tranModel.Add(base.BuildAddSql(distribution, out pone), pone); try { result = base.ExecuteTransactionDataCorect(tranModel.sqlArray, tranModel.ParameterArray); } catch (Exception) { log4net.LogHelper.WriteInfo(this.GetType(), Newtonsoft.Json.JsonConvert.SerializeObject(tranModel.sqlArray)); } if (!result) { agent.state = -2; AgentinfoBLL.SingleModel.Update(agent, "state"); } return(result); }
/// <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); }
public ActionResult AddStore() { returnObj = new Return_Msg_APP(); returnObj.code = "200"; string appId = Context.GetRequest("appId", string.Empty); int userId = Context.GetRequestInt("myCardId", 0); int agentInfoId = Context.GetRequestInt("agentInfoId", 0); if (string.IsNullOrEmpty(appId) || userId <= 0) { returnObj.Msg = "参数错误"; return(Json(returnObj)); } XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (r == null) { returnObj.Msg = "小程序未授权"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(r.AccountId.ToString()); //if (agentinfo == null)//本平台代理信息 //{ // returnObj.Msg = "入驻异常"; // return Json(returnObj, JsonRequestBehavior.AllowGet); //} string banners = Context.GetRequest("banners", string.Empty); if (string.IsNullOrEmpty(banners) || banners.Split(',').Length <= 0) { returnObj.Msg = "轮播图至少一张"; return(Json(returnObj)); } string storeName = Context.GetRequest("storeName", string.Empty); if (string.IsNullOrEmpty(storeName) || storeName.Length >= 20) { returnObj.Msg = "店铺名称不能为空并且不能超过20字符"; return(Json(returnObj)); } string lngStr = Context.GetRequest("lng", string.Empty); string latStr = Context.GetRequest("lat", string.Empty); double lng = 0.00; double lat = 0.00; if (!double.TryParse(lngStr, out lng) || !double.TryParse(latStr, out lat)) { returnObj.Msg = "地址坐标错误"; return(Json(returnObj)); } string location = Context.GetRequest("location", string.Empty); if (string.IsNullOrEmpty(location)) { returnObj.Msg = "地址不能为空"; return(Json(returnObj)); } string storeService = Context.GetRequest("storeService", string.Empty); //if (string.IsNullOrEmpty(storeService) || storeService.Split(',').Length <= 0) //{ // returnObj.Msg = "提供服务不能为空"; // return Json(returnObj); //} string openTime = Context.GetRequest("openTime", string.Empty); //if (string.IsNullOrEmpty(openTime)) //{ // returnObj.Msg = "营业时间不能为空"; // return Json(returnObj); //} //TODO 需要验证手机+电话 string phone = Context.GetRequest("phone", string.Empty); if (string.IsNullOrEmpty(phone)) { returnObj.Msg = "请填写正确的号码"; return(Json(returnObj)); } string businessDescription = Context.GetRequest("businessDescription", string.Empty); if (string.IsNullOrEmpty(businessDescription)) { returnObj.Msg = "业务简述不能为空"; return(Json(returnObj)); } string storeDescription = Context.GetRequest("storeDescription", string.Empty); string storeImgs = Context.GetRequest("storeImgs", string.Empty); int category = Context.GetRequestInt("category", 0);//店铺类别 if (PlatStoreCategoryBLL.SingleModel.GetModel(category) == null) { returnObj.Msg = "类别选择错误!"; return(Json(returnObj)); } PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(userId, 1); if (platStore == null) { platStore = new PlatStore(); } AddressApi addressinfo = AddressHelper.GetAddressByApi(lngStr, latStr); if (addressinfo == null || addressinfo.result == null || addressinfo.result.address_component == null) { returnObj.Msg = "地址出错!"; return(Json(returnObj)); } if (!storeService.Contains("ServiceState")) { //表示旧版本的数据,设施服务给初始化新值 List <StoreServiceModel> list = new List <StoreServiceModel>(); list.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "WIFI" }); list.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "停车位" }); list.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "支付宝支付" }); list.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "微信支付" }); list.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "刷卡支付" }); list.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "空调雅座" }); list.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "付费停车" }); list.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "接送服务" }); storeService = Newtonsoft.Json.JsonConvert.SerializeObject(list); } string storeRemark = Context.GetRequest("storeRemark", string.Empty); platStore.StoreRemark = storeRemark; string provinceName = addressinfo.result.address_component.province; string cityName = addressinfo.result.address_component.city; string countryName = addressinfo.result.address_component.district; platStore.ProvinceCode = C_AreaBLL.SingleModel.GetCodeByName(provinceName); platStore.CityCode = C_AreaBLL.SingleModel.GetCodeByName(cityName); platStore.CountryCode = C_AreaBLL.SingleModel.GetCodeByName(countryName); platStore.AddTime = DateTime.Now; platStore.Banners = banners; platStore.BindPlatAid = r.Id; platStore.BusinessDescription = businessDescription; platStore.Category = category; platStore.Lat = lat; platStore.Lng = lng; platStore.Location = location; platStore.MyCardId = userId; platStore.Name = storeName; platStore.OpenTime = openTime; platStore.Phone = phone; platStore.StoreDescription = storeDescription; platStore.StoreImgs = storeImgs; platStore.StoreService = storeService; platStore.UpdateTime = DateTime.Now; TransactionModel TranModel = new TransactionModel(); if (platStore.Id > 0) { //表示更新 TranModel.Add(PlatStoreBLL.SingleModel.BuildUpdateSql(platStore)); PlatStoreRelation platStoreRelation = PlatStoreRelationBLL.SingleModel.GetPlatStoreRelationOwner(r.Id, platStore.Id); if (platStoreRelation == null) { returnObj.Msg = "更新异常(店铺关系找不到数据)"; return(Json(returnObj)); } platStoreRelation.Category = platStore.Category; platStoreRelation.UpdateTime = DateTime.Now; TranModel.Add(PlatStoreRelationBLL.SingleModel.BuildUpdateSql(platStoreRelation, "Category,UpdateTime")); //2.查找上级代理 #region 步代理商店铺 暂时先屏蔽 //AgentDistributionRelation agentDistributionRelationFirst = new AgentDistributionRelationBLL().GetModel(agentinfo.id); //if (agentDistributionRelationFirst != null) //{ // Agentinfo agentinfoFirst = _agentinfoBll.GetModel(agentDistributionRelationFirst.ParentAgentId); // if (agentinfoFirst != null) // { // XcxAppAccountRelation xcxAppAccountRelationFirst = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoFirst.useraccountid, (int)TmpType.小未平台); // if (xcxAppAccountRelationFirst != null) // { // PlatStoreRelation platStoreRelationFist = _platStoreRelationBLL.GetPlatStoreRelationOwner(xcxAppAccountRelationFirst.Id, platStore.Id, agentinfo.id); // if (platStoreRelationFist != null) // { // platStoreRelationFist.Category = platStore.Category; // platStoreRelationFist.UpdateTime = DateTime.Now; // TranModel.Add(_platStoreRelationBLL.BuildUpdateSql(platStoreRelationFist, "Category,UpdateTime")); // } // //3.查找上级的上级代理 // AgentDistributionRelation agentDistributionRelationSecond = new AgentDistributionRelationBLL().GetModel(agentinfoFirst.id); // if (agentDistributionRelationSecond != null) // { // Agentinfo agentinfoSecond = _agentinfoBll.GetModel(agentDistributionRelationSecond.ParentAgentId); // if (agentinfoSecond != null) // { // XcxAppAccountRelation xcxAppAccountRelationSecond = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoSecond.useraccountid, (int)TmpType.小未平台); // if (xcxAppAccountRelationSecond != null) // { // PlatStoreRelation platStoreRelationSecond = _platStoreRelationBLL.GetPlatStoreRelationOwner(xcxAppAccountRelationSecond.Id, platStore.Id, agentinfo.id); // platStoreRelationSecond.Category = platStore.Category; // platStoreRelationSecond.UpdateTime = DateTime.Now; // TranModel.Add(_platStoreRelationBLL.BuildUpdateSql(platStoreRelationSecond, "Category,UpdateTime")); // } // } // } // } // } //} #endregion if (TranModel.sqlArray != null && TranModel.sqlArray.Length > 0 && PlatStoreRelationBLL.SingleModel.ExecuteTransactionDataCorect(TranModel.sqlArray)) { returnObj.isok = true; returnObj.Msg = "操作成功"; return(Json(returnObj)); } else { returnObj.Msg = "更新失败"; return(Json(returnObj)); } } else { //平台入驻模式 PlatStoreAddSetting platStoreAddSetting = PlatStoreAddSettingBLL.SingleModel.GetPlatStoreAddSetting(r.Id); int addWay = platStoreAddSetting != null ? platStoreAddSetting.AddWay : 0; PlatStoreAddRules rule = new PlatStoreAddRules(); if (addWay == 1) { platStore.State = -1; int ruleId = Context.GetRequestInt("ruleId", 0); rule = PlatStoreAddRulesBLL.SingleModel.getRule(r.Id, ruleId); if (rule == null) { returnObj.Msg = "入驻套餐不存在!"; return(Json(returnObj)); } platStore.YearCount = rule.YearCount; platStore.CostPrice = rule.CostPrice; } //表示入驻平台 需要将该入驻店铺同步到平台的1 2级代理商 int storeId = Convert.ToInt32(PlatStoreBLL.SingleModel.Add(platStore)); if (storeId > 0) { #region 数据同步 //插入关系表 才算成功 店铺数据都是从关系表获取才算有效的 //1.先将入驻到平台的插入 PlatStoreRelation platStoreRelation = new PlatStoreRelation(); platStoreRelation.StoreId = storeId; platStoreRelation.State = 1; platStoreRelation.FromType = 0; platStoreRelation.Aid = r.Id; platStoreRelation.Category = platStore.Category; platStoreRelation.AgentId = agentinfo != null ? agentinfo.id : agentInfoId; platStoreRelation.AddTime = DateTime.Now; platStoreRelation.UpdateTime = DateTime.Now; TranModel.Add(PlatStoreRelationBLL.SingleModel.BuildAddSql(platStoreRelation)); //2.查找上级代理 #region 暂时先屏蔽 //AgentDistributionRelation agentDistributionRelationFirst = new AgentDistributionRelationBLL().GetModel(agentinfo.id); //if (agentDistributionRelationFirst != null) //{ // Agentinfo agentinfoFirst = _agentinfoBll.GetModel(agentDistributionRelationFirst.ParentAgentId); // if (agentinfoFirst != null) // { // XcxAppAccountRelation xcxAppAccountRelationFirst = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoFirst.useraccountid, (int)TmpType.小未平台); // if (xcxAppAccountRelationFirst != null) // { // PlatStoreRelation platStoreRelationFist = new PlatStoreRelation(); // platStoreRelationFist.StoreId = storeId; // platStoreRelationFist.State = 0; // platStoreRelationFist.FromType = 1; // platStoreRelationFist.Aid = xcxAppAccountRelationFirst.Id; // platStoreRelationFist.Category = platStore.Category; // platStoreRelationFist.AgentId = agentinfo.id; // platStoreRelationFist.AddTime = DateTime.Now; // platStoreRelationFist.UpdateTime = DateTime.Now; // TranModel.Add(_platStoreRelationBLL.BuildAddSql(platStoreRelationFist)); // //3.查找上级的上级代理 // AgentDistributionRelation agentDistributionRelationSecond = new AgentDistributionRelationBLL().GetModel(agentinfoFirst.id); // if (agentDistributionRelationSecond != null) // { // Agentinfo agentinfoSecond = _agentinfoBll.GetModel(agentDistributionRelationSecond.ParentAgentId); // if (agentinfoSecond != null) // { // XcxAppAccountRelation xcxAppAccountRelationSecond = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoSecond.useraccountid, (int)TmpType.小未平台); // if (xcxAppAccountRelationSecond != null) // { // PlatStoreRelation platStoreRelationSecond = new PlatStoreRelation(); // platStoreRelationSecond.StoreId = storeId; // platStoreRelationSecond.State = 0; // platStoreRelationSecond.FromType = 1; // platStoreRelationSecond.Aid = xcxAppAccountRelationSecond.Id; // platStoreRelationSecond.Category = platStore.Category; // platStoreRelationSecond.AgentId = agentinfo.id; // platStoreRelationSecond.AddTime = DateTime.Now; // platStoreRelationSecond.UpdateTime = DateTime.Now; // TranModel.Add(_platStoreRelationBLL.BuildAddSql(platStoreRelationSecond)); // } // } // } // } // } //} #endregion #endregion int orderid = 0; if (addWay == 1) { CityMorders order = new CityMorders() { FuserId = storeId, Fusername = storeName, TuserId = 0, OrderType = (int)ArticleTypeEnum.PlatAddStorePay, ActionType = (int)miniAppBuyMode.微信支付, Addtime = DateTime.Now, Percent = 99,//不收取服务费 userip = WebHelper.GetIP(), payment_status = 0, Status = 0, CitySubId = 0,//无分销,默认为0 PayRate = 1, appid = appId, Articleid = rule.Id, CommentId = platStore.YearCount, MinisnsId = r.Id, payment_free = platStore.CostPrice, ShowNote = $"平台版店铺入驻收费付款{platStore.CostPrice * 0.01}元" }; string no = WxPayApi.GenerateOutTradeNo(); order.orderno = no; order.trade_no = no; orderid = Convert.ToInt32(_cityMordersBLL.Add(order)); } if (TranModel.sqlArray != null && TranModel.sqlArray.Length > 0) { if (PlatStoreRelationBLL.SingleModel.ExecuteTransactionDataCorect(TranModel.sqlArray)) { if (orderid <= 0 && addWay == 1) { returnObj.Msg = "入驻失败(订单生成失败)"; return(Json(returnObj)); } returnObj.dataObj = new { storeId = storeId, orderid = orderid }; returnObj.isok = true; returnObj.Msg = "入驻成功"; return(Json(returnObj)); } else { platStore.State = -1; platStore.UpdateTime = DateTime.Now; PlatStoreBLL.SingleModel.Update(platStore, "State,UpdateTime"); returnObj.Msg = "入驻失败"; return(Json(returnObj)); } } else { returnObj.dataObj = storeId; returnObj.isok = true; returnObj.Msg = "入驻成功"; return(Json(returnObj)); } } else { returnObj.Msg = "入驻失败(请联系客服)"; return(Json(returnObj)); } } }
public bool OpenCustomBotton(Agentinfo agentInfo, Agentinfo parentInfo, string userName, XcxAppAccountRelation xcxrelation, int cost, string parm) { bool success = false; if (agentInfo == null) { return(success); } TransactionModel tran = new TransactionModel(); DateTime date = DateTime.Now; //代理商扣费 tran.Add($"UPDATE Agentinfo set deposit={agentInfo.deposit-cost} ,updateitme='{date}' where id={agentInfo.id}"); //添加自定义水印数据 ConfParam model = new ConfParam(); model.AppId = xcxrelation.AppId; model.Param = parm; model.Value = ""; model.State = 0; model.UpdateTime = date; model.AddTime = date; model.RId = xcxrelation.Id; tran.Add(ConfParamBLL.SingleModel.BuildAddSql(model)); //扣费记录 AgentdepositLog agentLog = new AgentdepositLog(); agentLog.agentid = agentInfo.id; agentLog.addtime = date; agentLog.templateCount = 1; agentLog.customerid = xcxrelation.AccountId.ToString(); agentLog.Rid = xcxrelation.Id; agentLog.OutTime = date; agentLog.tid = 0; agentLog.type = (int)AgentDepositLogType.开启水印; agentLog.templateCount = 0; agentLog.beforeDeposit = agentInfo.deposit; agentLog.cost = cost; agentLog.afterDeposit = agentInfo.deposit - cost; agentLog.costdetail = $"客户:{userName}开启自定义小程序水印"; tran.Add(base.BuildAddSql(agentLog)); //判断是否是二级分销商 if (agentInfo.userLevel > 0) { if (parentInfo == null) { return(success); } //上级代理商扣费 tran.Add($"UPDATE Agentinfo set deposit={parentInfo.deposit - cost} ,updateitme='{date}' where id={parentInfo.id}"); agentLog = new AgentdepositLog(); agentLog.agentid = parentInfo.id; agentLog.addtime = date; agentLog.templateCount = 1; agentLog.customerid = xcxrelation.AccountId.ToString(); agentLog.Rid = xcxrelation.Id; agentLog.OutTime = date; agentLog.tid = 0; agentLog.type = (int)AgentDepositLogType.开启水印; agentLog.templateCount = 0; agentLog.beforeDeposit = parentInfo.deposit; agentLog.cost = cost; agentLog.afterDeposit = parentInfo.deposit - cost; agentLog.costdetail = $"分销商{parentInfo.name}为客户{userName}开启自定义小程序水印"; tran.Add(base.BuildAddSql(agentLog)); } success = base.ExecuteTransactionDataCorect(tran.sqlArray); 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 void AddagentinfoLog(Agentinfo agentinfo, List <XcxTemplate> xcxList, int deposit, int parentDeposit, string userName, string userId, int openType = 0, int aid = 0) { if (xcxList == null || xcxList.Count <= 0) { return; } StringBuilder sb = new StringBuilder(); AgentdepositLog agentLog = new AgentdepositLog(); DateTime date = DateTime.Now; agentLog.agentid = agentinfo.id; agentLog.addtime = date; agentLog.templateCount = 1; agentLog.customerid = userId; agentLog.Rid = aid; foreach (XcxTemplate xcx in xcxList) { int cost = xcx.Price * xcx.year * xcx.buycount; if (xcx.Type == (int)TmpType.小程序专业模板) { xcx.TName += GetVerName(xcx.VersionId); } string desc = $"客户:{userName} 开通模板:{xcx.TName} 开通数量:" + xcx.buycount; //整理消费日志 GetCommondLog(ref openType, ref cost, ref desc, ref agentLog, xcx, userName, "", 0); agentLog.tid = xcx.Id; agentLog.type = openType > 0 ? openType : 2; agentLog.templateCount = openType > 0 ? xcx.storecount : xcx.buycount; agentLog.beforeDeposit = deposit; agentLog.cost = cost; agentLog.afterDeposit = deposit - cost; deposit = deposit - cost; agentLog.costdetail = desc; sb.Append(base.BuildAddSql(agentLog)); } if (agentinfo.userLevel == 1) { try { Distribution distribution = DistributionBLL.SingleModel.GetModel($"agentid={agentinfo.id}"); string tids = string.Join(",", xcxList.Select(x => x.Id).ToArray()); List <XcxTemplate> parent_xcxlist = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tids})", distribution.parentAgentId); AgentdepositLog parent_agentLog = new AgentdepositLog(); parent_agentLog.agentid = distribution.parentAgentId; parent_agentLog.addtime = date; parent_agentLog.templateCount = 1; parent_agentLog.customerid = agentinfo.id.ToString(); foreach (XcxTemplate xcx in parent_xcxlist) { XcxTemplate model = xcxList.Where(w => w.Id == xcx.Id).FirstOrDefault(); xcx.year = model != null ? model.year : 1; xcx.storecount = model.storecount; xcx.buycount = model.buycount; xcx.VersionId = model.VersionId; xcx.SCount = model.SCount; if (xcx.Type == (int)TmpType.小程序专业模板) { xcx.TName += GetVerName(xcx.VersionId); } int cost = xcx.Price * xcx.year * xcx.buycount; if (xcx.Type == (int)TmpType.小程序专业模板) { //重新计算价格专业版版本级别 VersionType m = XcxTemplateBLL.SingleModel.GetRealPriceVersionTemplateList(xcx.Type, distribution.parentAgentId).FirstOrDefault(x => x.VersionId == xcx.VersionId); cost = Convert.ToInt32(m.VersionPrice) * xcx.year * xcx.buycount; } string desc = $"分销商:{distribution.name} 开通模板:{xcx.TName} 开通数量:" + xcx.buycount; //整理消费日志 GetCommondLog(ref openType, ref cost, ref desc, ref agentLog, xcx, userName, distribution.name, 1); parent_agentLog.tid = xcx.Id; parent_agentLog.type = openType > 0 ? openType : 3; parent_agentLog.templateCount = xcx.buycount; parent_agentLog.beforeDeposit = parentDeposit; parent_agentLog.cost = cost; parent_agentLog.afterDeposit = parentDeposit - cost; parentDeposit = parentDeposit - cost; parent_agentLog.costdetail = desc; sb.Append(base.BuildAddSql(parent_agentLog)); } } catch (Exception ex) { log4net.LogHelper.WriteInfo(this.GetType(), ex.Message); } } base.ExecuteNonQuery(sb.ToString()); }
public ActionResult CaseTemplate() { int opensinglepagefree = Context.GetRequestInt("opensinglepagefree", 0); ViewBag.testxcxType = _testxcxtype; ViewBag.freexcxType = _freexcxtype; ViewBag.Phone = "未绑定"; ViewBag.BindPhone = 0; Return_Msg msg = new Return_Msg(); ViewModelMyWorkbench model = GetUserInfo(); if (opensinglepagefree > 0) { TestTemplate(); } if (model._Member == null || model._Account == null) { CookieHelper.Remove("dz_UserCookieNew"); return(Redirect("/dzhome/Login")); } //判断是否子帐号登陆 AuthRole role = RouteAuthCheck.GetAdminAuth(); if (role != null) { int pageType = XcxAppAccountRelationBLL.SingleModel.GetXcxTemplateType(role.AId); string redirectUrl = string.Empty; Dictionary <int, string> pageTypeIndex = new Dictionary <int, string> { { (int)TmpType.小程序专业模板, $"/SubAccount/Welcome?appId={role.AId}&pageType={pageType}" }, { (int)TmpType.小未平台, $"/Plat/admin/Index?Id={role.AId}&appId={role.AId}&pageType={pageType}" }, { (int)TmpType.拼享惠, $"/Pin/main/Index?Id={role.AId}&appId={role.AId}&pageType={pageType}" }, }; //禁止专业版子帐号,进入小程序管理列表页 if (pageTypeIndex.TryGetValue(pageType, out redirectUrl) && !string.IsNullOrWhiteSpace(redirectUrl)) { return(Redirect(redirectUrl)); } } //判断是否是代理商 Agentinfo agentmodel = AgentinfoBLL.SingleModel.GetModelByAccoundId(model._Account.Id.ToString());//GetModel($"useraccountid='{model._Account.Id.ToString()}'"); if (agentmodel != null) { //赠送一年免费的平台版 if (agentmodel.userLevel == 0 && agentmodel.addtime <= DateTime.Parse("2018-06-21")) { XcxAppAccountRelationBLL.SingleModel.AddTemplate(model._Account, agentmodel); } return(View(model)); } //判断是否是代理商开通的用户 AgentCustomerRelation agentcutomer = AgentCustomerRelationBLL.SingleModel.GetModel($"useraccountid='{model._Account.Id.ToString()}'"); if (agentcutomer != null) { return(View(model)); } //判断是否有用户未绑定手机号码 if (string.IsNullOrEmpty(model._Account.ConsigneePhone)) { ViewBag.BindPhone = 1; } else { //用户已绑定手机号,判断是否有单页版 XcxAppAccountRelation usertemplate = XcxAppAccountRelationBLL.SingleModel.GetModel($"accountid='{model._Account.Id}'"); if (usertemplate == null) { //免费开通单页版 XcxAppAccountRelationBLL.SingleModel.AddFreeTemplate(model._Account); } } return(View(model)); }
public bool UpdateDistribution(Distribution distribution, int deposit, List <XcxTemplate> list, out string errormsg) { TransactionModel tranModel = new TransactionModel(); MySqlParameter[] pone = null; bool result = false; errormsg = string.Empty; tranModel.Add($"update Distribution set name='{distribution.name}',remark ='{distribution.remark}' where id={distribution.id}"); //分销商预存款 Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModel(distribution.AgentId); if (agentinfo.deposit != deposit) { //充值 int cost = Math.Abs(deposit - agentinfo.deposit); //if (agentinfo == null) //{ // errormsg = "分销商代理数据不存在"; // return result; //} //if (cost <= 0) //{ // errormsg = "预存款充值不能小于0"; // return result; //} tranModel.Add($"update Agentinfo set deposit={deposit} where id={distribution.AgentId}"); AgentdepositLog agentdepositLog = new AgentdepositLog(); agentdepositLog.agentid = agentinfo.id; agentdepositLog.addtime = DateTime.Now; agentdepositLog.beforeDeposit = agentinfo.deposit; agentdepositLog.cost = cost; agentdepositLog.afterDeposit = deposit; agentdepositLog.type = 1; tranModel.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentdepositLog, out pone), pone); //代理商预存款 Agentinfo agentinfop = AgentinfoBLL.SingleModel.GetModel(distribution.parentAgentId); if (agentinfo == null) { errormsg = "代理商数据不存在"; return(result); } List <Distribution> dlist = GetListByAgentId(agentinfop.id); if (dlist != null && dlist.Count > 0) { string agentids = string.Join(",", dlist.Select(s => s.AgentId)); List <Agentinfo> cagentinfolist = AgentinfoBLL.SingleModel.GetListByIds(agentids); if (cagentinfolist != null && cagentinfolist.Count > 0) { List <Agentinfo> otheragent = cagentinfolist.Where(w => w.id != agentinfo.id).ToList(); int tempcost = deposit; //其他分销代理的预存款 if (otheragent != null && otheragent.Count > 0) { tempcost += otheragent.Sum(s => s.deposit); } if (agentinfop.deposit <= tempcost && deposit > 0) { errormsg = "代理商预存款不足"; return(false); } } } //tranModel.Add($"update Agentinfo set deposit={agentinfop.deposit - cost} where id={agentinfop.id}"); //agentdepositLog = new AgentdepositLog(); //agentdepositLog.agentid = agentinfop.id; //agentdepositLog.addtime = DateTime.Now; //agentdepositLog.beforeDeposit = agentinfop.deposit; //agentdepositLog.cost = cost; //agentdepositLog.afterDeposit = agentinfop.deposit - cost; //agentdepositLog.type = 13; //agentdepositLog.customerid = agentinfop.useraccountid; //agentdepositLog.costdetail = $"为分销代理商{distribution.name}充值{(cost * 0.01).ToString("0.00")}"; //tranModel.Add(_agentdepositLogBll.BuildAddSql(agentdepositLog, out pone), pone); } foreach (var template in list) { Xcxtemplate_Price xcxtemplatePrice = Xcxtemplate_PriceBLL.SingleModel.GetModel($"tid ={template.Id} and agentid={distribution.AgentId} and VersionId={template.VersionId}"); if (xcxtemplatePrice == null) { xcxtemplatePrice = new Xcxtemplate_Price(); xcxtemplatePrice.price = template.Price; xcxtemplatePrice.agentid = distribution.AgentId.ToString(); xcxtemplatePrice.tid = template.Id.ToString(); xcxtemplatePrice.state = 0; xcxtemplatePrice.VersionId = template.VersionId; if (template.Type == (int)TmpType.小程序多门店模板 || template.Type == (int)TmpType.小程序餐饮多门店模板 || template.Type == (int)TmpType.智慧餐厅) { xcxtemplatePrice.SPrice = template.SPrice; xcxtemplatePrice.SCount = template.SCount; } Xcxtemplate_PriceBLL.SingleModel.Add(xcxtemplatePrice); continue; } tranModel.Add($"update xcxtemplate_Price set price={template.Price} {((template.Type == (int)TmpType.小程序多门店模板 || template.Type == (int)TmpType.小程序餐饮多门店模板 || template.Type == (int)TmpType.智慧餐厅) ? $",SPrice={template.SPrice},SCount={template.SCount}" : "")} where tid ={template.Id} and agentid={distribution.AgentId} and VersionId={template.VersionId}"); } try { result = base.ExecuteTransactionDataCorect(tranModel.sqlArray, tranModel.ParameterArray); } catch (Exception) { log4net.LogHelper.WriteInfo(this.GetType(), Newtonsoft.Json.JsonConvert.SerializeObject(tranModel.sqlArray)); } return(result); }
/// <summary> /// 代理商开通体验版 /// </summary> /// <param name="agentInfo"></param> /// <param name="tIds"></param> /// <param name="userAccount"></param> /// <param name="erroMsg"></param> /// <param name="dayLength"></param> /// <returns></returns> public bool OpenExperience(Agentinfo agentInfo, string tIds, Account userAccount, ref string erroMsg, int dayLength) { TransactionModel tranModel = new TransactionModel(); //判断要开通的模板是否还没体验过 bool canopen = IsOpenExperience(tIds, userAccount.Id.ToString()); if (canopen) { erroMsg = "模板已开通过,请刷新重试"; return(false); } //添加客户 AgentCustomerRelation agentcustomerrelation = AgentCustomerRelationBLL.SingleModel.GetModelByAccountId(agentInfo.id, userAccount.Id.ToString()); if (agentcustomerrelation == null) { agentcustomerrelation = new AgentCustomerRelation() { username = userAccount.LoginId, addtime = DateTime.Now, agentid = agentInfo.id, useraccountid = userAccount.Id.ToString(), state = 1, }; agentcustomerrelation.id = Convert.ToInt32(AgentCustomerRelationBLL.SingleModel.Add(agentcustomerrelation)); if (agentcustomerrelation.id <= 0) { erroMsg = "添加客户关联失败"; return(false); } } List <XcxTemplate> xcxlist = XcxTemplateBLL.SingleModel.GetListByIds(tIds); //添加模板记录 foreach (XcxTemplate xcx in xcxlist) { AgentdepositLog agentLog = new AgentdepositLog(); agentLog.agentid = agentInfo.id; agentLog.addtime = DateTime.Now; agentLog.templateCount = 1; agentLog.customerid = agentcustomerrelation.id.ToString(); agentLog.tid = xcx.Id; agentLog.type = 2; agentLog.templateCount = 1; agentLog.costdetail = $"开通体验{xcx.TName}模板"; tranModel.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentLog)); XcxAppAccountRelation xcxappaccountrelation = new XcxAppAccountRelation() { TId = xcx.Id, AccountId = userAccount.Id, AddTime = DateTime.Now, agentId = agentInfo.id, Url = xcx.Link, price = xcx.Price, TimeLength = xcx.year, outtime = DateTime.Now.AddDays(dayLength), SCount = xcx.SCount, IsExperience = true, }; xcxappaccountrelation.Id = Convert.ToInt32(base.Add(xcxappaccountrelation)); if (xcx.Type == (int)TmpType.小程序多门店模板) { tranModel.Add(FootBathBLL.SingleModel.GetAddFootbathSQL(xcxappaccountrelation.AccountId, xcx.SCount - 1, xcxappaccountrelation.Id, xcxappaccountrelation.outtime).ToArray()); } } //执行事务 bool success = false; try { success = base.ExecuteTransactionDataCorect(tranModel.sqlArray, tranModel.ParameterArray); } catch (Exception ex) { erroMsg = ex.Message; } return(success); }
public List <DistributionModel> GetDistributionList(int parentAgentId, string loginId, string username, int state, int pagesize, int pageindex, out int count, out string errormsg) { errormsg = string.Empty; string sqlwhere = $"parentAgentId={parentAgentId}"; count = -1; Account useraccount = null; if (!string.IsNullOrEmpty(loginId)) { useraccount = AccountBLL.SingleModel.GetModel($" loginId='{loginId}'"); if (useraccount == null) { return(null); } //accountIds = $"and useraccountid='{useraccount.Id.ToString()}'"; sqlwhere += $" and useraccountid='{useraccount.Id}'"; } if (!string.IsNullOrEmpty(username)) { sqlwhere += $" and name like '%{username}%'"; } if (state > -2) { sqlwhere += $" and state ={state}"; } errormsg = sqlwhere; List <DistributionModel> modellist = null; List <Distribution> list = base.GetList(sqlwhere, pagesize, pageindex, "*", "addtime desc"); count = base.GetCount(sqlwhere); if (list != null && list.Count > 0) { modellist = new List <DistributionModel>(); string agentIds = string.Join(",", list.Select(s => s.AgentId).Distinct()); List <Agentinfo> agentInfoList = AgentinfoBLL.SingleModel.GetListByIds(agentIds); string accountIds = $"'{string.Join("','",list.Select(s=>s.useraccountid).Distinct())}'"; List <Account> accountList = AccountBLL.SingleModel.GetListByAccountids(accountIds); foreach (var distribution in list) { DistributionModel model = new DistributionModel(); Agentinfo agentInfo = agentInfoList?.FirstOrDefault(f => f.id == distribution.AgentId); if (agentInfo == null) { agentInfo = new Agentinfo(); } Account account = accountList?.FirstOrDefault(f => f.Id.ToString() == agentInfo.useraccountid); if (account == null) { continue; } model.createCustomerCount = AgentCustomerRelationBLL.SingleModel.GetCount($"agentid ={distribution.AgentId}"); model.buyTemplateCount = XcxAppAccountRelationBLL.SingleModel.GetCount($"agentid={distribution.AgentId}"); model.addtime = distribution.addtime; model.AgentId = distribution.AgentId; model.deposit = agentInfo.deposit; model.LoginId = account.LoginId; model.modifyDate = distribution.modifyDate; model.name = distribution.name; model.parentAgentId = distribution.parentAgentId; model.remark = distribution.remark; model.state = distribution.state; modellist.Add(model); } } return(modellist); }
/// <summary> /// 在平台店铺列表里新增没有主人的店铺 /// </summary> /// <returns></returns> public ActionResult CreateStore(int aid = 0) { int storeId = Utility.IO.Context.GetRequestInt("storeId", 0); PlatStoreCategoryConfig platStoreCategoryConfig = PlatStoreCategoryConfigBLL.SingleModel.GetModelByAid(aid); if (platStoreCategoryConfig == null) { platStoreCategoryConfig = new PlatStoreCategoryConfig() { Aid = aid, AddTime = DateTime.Now, Level = 1, SyncSwitch = 0 }; int id = Convert.ToInt32(PlatStoreCategoryConfigBLL.SingleModel.Add(platStoreCategoryConfig)); if (id <= 0) { return(View("PageError", new PlatReturnMsg() { Msg = "初始化数据异常!", code = "500" })); } } List <PlatStoreCategory> list = new List <PlatStoreCategory>(); list.Add(new PlatStoreCategory() { Id = 0, Name = "请选择" }); int totalCount = 0; ViewBag.firstCategoryId = 0; ViewBag.appId = aid; list.AddRange(PlatStoreCategoryBLL.SingleModel.getListByaid(aid, out totalCount, platStoreCategoryConfig.Level == 1 ? 2 : 1, 100, 1)); ViewBag.CategoryList = list; ViewBag.CategoryLevel = platStoreCategoryConfig.Level; Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(dzuserId.ToString()); ViewBag.AgentinfoId = agentinfo == null ? 0 : agentinfo.id; PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(storeId); bool isHave = false; if (platStore == null) { platStore = new PlatStore(); platStore.BindPlatAid = aid; isHave = true; } else { PlatStoreCategory platStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(platStore.Category); if (platStoreCategory != null) { ViewBag.firstCategoryId = platStoreCategory.ParentId; } if (!string.IsNullOrEmpty(platStore.StoreService)) { platStore.StoreServiceModelList = JsonConvert.DeserializeObject <List <StoreServiceModel> >(platStore.StoreService); } else { isHave = true; } } if (isHave) { List <StoreServiceModel> listService = new List <StoreServiceModel>(); listService.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "WIFI" }); listService.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "停车位" }); listService.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "支付宝支付" }); listService.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "微信支付" }); listService.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "刷卡支付" }); listService.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "空调雅座" }); listService.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "付费停车" }); listService.Add(new StoreServiceModel() { ServiceState = true, ServiceName = "接送服务" }); platStore.StoreServiceModelList = listService; } if (!string.IsNullOrEmpty(platStore.SwitchConfig)) { platStore.SwitchModel = Newtonsoft.Json.JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig); } else { platStore.SwitchModel = new PlatStoreSwitchModel(); } return(View(platStore)); }
public ActionResult GetFreeExperienceTemplate() { Return_Msg data = new Return_Msg(); Account account = AccountBLL.SingleModel.GetModel(dzuserId); if (account == null) { return(RedirectToAction("login", "dzhome")); } Agentinfo agentmodel = AgentinfoBLL.SingleModel.GetModelByAccoundId(dzuserId.ToString()); if (agentmodel == null) { data.Msg = "您还不是代理商"; return(Json(data)); } //付费模板 List <XcxTemplate> xlist = XcxTemplateBLL.SingleModel.GetListByPriceType(1); if (xlist == null || xlist.Count == 0) { return(Json(data)); } //已开通过的体验模板 List <XcxAppAccountRelation> userlist = XcxAppAccountRelationBLL.SingleModel.GetListByAccountId(agentmodel.useraccountid, agentmodel.id, 1); xlist.ForEach(f => { XcxAppAccountRelation xmodel = userlist?.FirstOrDefault(x => x.TId == f.Id); //state字段暂时用来表示该模板是否已被体验过,0:未体验,1:已体验 f.State = 0; f.statename = "未开通"; f.year = WebSiteConfig.ExperienceDayLength; if (xmodel != null) { f.State = 1; f.outtime = xmodel.outtime.ToString("yyyy-MM-dd HH:mm:ss"); if (xmodel.outtime <= DateTime.Now) { f.State = 0; f.year = 0; f.statename = "已过期"; } else { TimeSpan sp = xmodel.outtime.Subtract(DateTime.Now); f.year = sp.Days; f.statename = "已开通"; } if (xmodel.State == -1) { f.State = -1; f.statename = "已停用"; } } }); data.dataObj = xlist; return(Json(data)); }
/// <summary> /// /// </summary> /// <param name="aid">平台小程序appId</param> /// <param name="totalCount"></param> /// <param name="storeName">店铺名称</param> /// <param name="appName">绑定的小程序名称</param> /// <param name="agentName">分销代理商名称</param> /// <param name="categoryName">原平台类别名称</param> /// <param name="storeState">店铺状态</param> /// <param name="haveAid">是否绑定了小程序0 未绑定 1绑定了</param> /// <param name="fromType">数据来源0 店铺入驻 1代理分销商同步</param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="orderWhere"></param> /// <returns></returns> public List <PlatStoreRelation> GetListStore(int aid, out int totalCount, string storeName = "", string appName = "", string agentName = "", string categoryName = "", int storeState = -1, int haveAid = -1, int fromType = -1, int pageSize = 10, int pageIndex = 1, string orderWhere = "AddTime desc", string storeOwnerPhone = "", int isFirstType = 0, int categoryId = 0, string appId = "") { List <PlatStore> list = new List <PlatStore>(); List <PlatStoreRelation> listPlatStoreRelation = new List <PlatStoreRelation>(); List <MySqlParameter> parameters = new List <MySqlParameter>(); string strWhere = $" psr.Aid={aid} and s.Id>0 and s.state<>-1 and s.MyCardId in({PlatMyCardBLL.SingleModel.GetCardIds(aid, appId)})"; if (storeState != -1) { strWhere += $" and psr.State={storeState}"; } if (haveAid != -1) { if (haveAid == 0) { strWhere += $" and s.Aid=0"; } else { strWhere += $" and s.Aid<>0"; //表示店铺已经绑定独立小程序 } } if (fromType != -1) { strWhere += $" and psr.FromType={fromType}"; } if (!string.IsNullOrEmpty(storeOwnerPhone)) { parameters.Add(new MySqlParameter("@storeOwnerPhone", $"%{storeOwnerPhone}%")); strWhere += " and c.Phone like @storeOwnerPhone"; } if (!string.IsNullOrEmpty(storeName)) { parameters.Add(new MySqlParameter("@storeName", $"%{storeName}%")); strWhere += " and s.Name like @storeName"; } if (!string.IsNullOrEmpty(appName))//根据店铺绑定的小程序名称模糊查询 { List <int> listRids = OpenAuthorizerConfigBLL.SingleModel.GetRidByAppName(appName); if (listRids == null || listRids.Count <= 0) { listRids.Add(0); } strWhere += $" and s.Aid in ({string.Join(",", listRids)})"; } if (!string.IsNullOrEmpty(agentName))//根据分销代理商名称模糊查询 { List <int> listAgentId = AgentinfoBLL.SingleModel.GetAgentIdByAgentName(agentName); if (listAgentId == null || listAgentId.Count <= 0) { listAgentId.Add(0); } strWhere += $" and psr.AgentId in ({string.Join(",", listAgentId)})"; } if (!string.IsNullOrEmpty(categoryName))//根据类别名称(小类 因为店铺最终属于某个小类)模糊查询 { List <int> listCategoryId = PlatStoreCategoryBLL.SingleModel.GetCategoryIdName(categoryName); if (listCategoryId == null || listCategoryId.Count <= 0) { listCategoryId.Add(0); } strWhere += $" and s.Category in ({string.Join(",", listCategoryId)})"; } if (isFirstType == 1 && categoryId > 0) { //表示传过来的是店铺大类 先查询出其下面的小类id strWhere += $" and s.Category in ({PlatStoreCategoryBLL.SingleModel.GetChildIds(aid, categoryId)})"; } if (isFirstType == 2 && categoryId > 0) { //表示传过来的是店铺大类 先查询出其下面的小类id strWhere += $" and s.Category in ({categoryId})"; } string sql = $"select psr.*,s.YearCount,s.CostPrice,s.Id as sId,s.Aid as sAid,s.Category as sCategory,s.MyCardId as sMyCardId,s.StorePV,s.StoreVirtualPV,s.Name,c.Phone as StoreOwnerPhone from PlatStoreRelation psr left join PlatStore s on psr.StoreId=s.Id left join PlatMyCard c on s.MyCardId=c.Id where {strWhere} order by {orderWhere} LIMIT {(pageIndex - 1) * pageSize},{pageSize}"; using (var dr = SqlMySql.ExecuteDataReader(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql, parameters.ToArray())) { listPlatStoreRelation = new List <PlatStoreRelation>(); while (dr.Read()) { PlatStoreRelation platStoreRelation = PlatStoreRelationBLL.SingleModel.GetModel(dr); if (platStoreRelation != null) { if (dr["sCategory"] != DBNull.Value) { PlatStoreCategory OwnerPlatStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(Convert.ToInt32(dr["sCategory"])); if (OwnerPlatStoreCategory != null) { platStoreRelation.OwnerSecondCategoryName = OwnerPlatStoreCategory.Name; PlatStoreCategory firstplatStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(OwnerPlatStoreCategory.ParentId); if (firstplatStoreCategory != null) { platStoreRelation.OwnerFirstCategoryName = firstplatStoreCategory.Name; } } } PlatStoreCategory CurPlatStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(platStoreRelation.Category); if (CurPlatStoreCategory != null) { platStoreRelation.CurSecondCategoryName = CurPlatStoreCategory.Name; PlatStoreCategory firstplatStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(CurPlatStoreCategory.ParentId); if (firstplatStoreCategory != null) { platStoreRelation.CurFirstCategoryName = firstplatStoreCategory.Name; platStoreRelation.FirstCategory = CurPlatStoreCategory.ParentId; } } platStoreRelation.StoreOwnerPhone = dr["StoreOwnerPhone"].ToString(); if (dr["sMyCardId"] != DBNull.Value) { platStoreRelation.MyCardId = Convert.ToInt32(dr["sMyCardId"]); } Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModel(platStoreRelation.AgentId); platStoreRelation.FromTypeStr = platStoreRelation.FromType == 0 ? "平台入驻" : (agentinfo != null ? agentinfo.name : "分销代理商"); if (dr["sAid"] != DBNull.Value) { XcxAppAccountRelation xcxAppAccountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel(Convert.ToInt32(dr["sAid"])); if (xcxAppAccountRelation == null) { platStoreRelation.BindAppIdName = "无"; } else { OpenAuthorizerConfig openAuthorizerConfig = OpenAuthorizerConfigBLL.SingleModel.GetModelByAppids(xcxAppAccountRelation.AppId, xcxAppAccountRelation.Id); platStoreRelation.BindAppIdName = openAuthorizerConfig?.nick_name + "id:" + xcxAppAccountRelation.Id; } } platStoreRelation.StoreName = Convert.ToString(dr["Name"]); if (dr["StorePV"] != DBNull.Value) { platStoreRelation.StorePV = Convert.ToInt32(dr["StorePV"]); } if (dr["StoreVirtualPV"] != DBNull.Value) { platStoreRelation.StorePV += Convert.ToInt32(dr["StoreVirtualPV"]); } if (dr["sId"] != DBNull.Value) { platStoreRelation.StoreId = Convert.ToInt32(dr["sId"]); } if (dr["sAid"] != DBNull.Value) { platStoreRelation.StoreAid = Convert.ToInt32(dr["sAid"]); } platStoreRelation.YearCount = Convert.ToInt32(dr["YearCount"]); platStoreRelation.CostPrice = Convert.ToInt32(dr["CostPrice"]); listPlatStoreRelation.Add(platStoreRelation); } } } totalCount = 0; object obj = SqlMySql.ExecuteScalar(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, $"select Count(psr.Id) from PlatStoreRelation psr left join PlatStore s on psr.StoreId=s.Id left join PlatMyCard c on s.MyCardId=c.Id where {strWhere}", parameters.ToArray()); if (obj != null) { totalCount = Convert.ToInt32(obj); } ; return(listPlatStoreRelation); }
public readonly string _redis_AgentDistributionRelationVersion = "redis_AgentDistributionRelationVersion_{0}";//版本控制 public string CreateDistributionAgent(string accountid, int agentqrcodeid, int opentype = 0, string username = "", string appid = "") { int followState = 0; //免费版,用户提交的资料直接分配给小未 if (!string.IsNullOrEmpty(appid)) { XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(appid); if (xcxrelation != null) { //int xcxType = XcxAppAccountRelationBLL.SingleModel.GetXcxTemplateType(xcxrelation.Id); followState = xcxrelation.Type == (int)TmpType.小程序企业模板 || xcxrelation.Type == (int)TmpType.小程序单页模板 ? 1 : 0; } } Agentinfo agentmodel = AgentinfoBLL.SingleModel.GetModelByAccoundId(accountid); if (agentmodel != null) { return("您已经是代理商了"); } AgentQrCode agentqrmodel = AgentQrCodeBLL.SingleModel.GetModel(agentqrcodeid); if (agentqrmodel == null) { return("代理分销二维码已失效"); } Agentinfo pagentmodel = AgentinfoBLL.SingleModel.GetModel(agentqrmodel.AgentId); if (pagentmodel == null || pagentmodel.id <= 0) { return("该代理已被停用"); } AgentDistributionRelation relation = new AgentDistributionRelation(); relation.AddTime = DateTime.Now; relation.State = 1; relation.QrCodeId = agentqrcodeid; relation.UpdateTime = DateTime.Now; relation.FollowState = followState; relation.OpenType = opentype; relation.Id = Convert.ToInt32(base.Add(relation)); if (relation.Id <= 0) { return("添加代理分销关联数据出错"); } TransactionModel tran = new TransactionModel(); agentmodel = new Agentinfo(); agentmodel.addtime = DateTime.Now; agentmodel.updateitme = DateTime.Now; agentmodel.useraccountid = accountid; agentmodel.userLevel = 0; agentmodel.name = username; agentmodel.state = -1; agentmodel.IsOpenDistribution = 1; tran.Add(AgentinfoBLL.SingleModel.BuildAddSql(agentmodel)); tran.Add($"update AgentDistributionRelation set ParentAgentId={pagentmodel.id},AgentId=(select last_insert_id()) where id={relation.Id}"); tran.Add($"update agentinfo set AuthCode=CONCAT({agentmodel.addtime.ToString("yyyyMMdd")},(select last_insert_id())) where id=(select last_insert_id())"); if (!base.ExecuteTransactionDataCorect(tran.sqlArray)) { return("保存出错"); } //清除缓存 RemoveCache(pagentmodel.id); AgentQrCodeBLL.SingleModel.RemoveCache(pagentmodel.id); return(""); }
/// <summary> /// 同步产品到 店铺所属平台 以及 所属平台的一级 二级代理商平台 /// </summary> /// <param name="id"></param> /// <param name="platStore"></param> /// <param name="agentinfo"></param> /// <returns></returns> public bool SyncProduct(int id, PlatStore platStore, Agentinfo agentinfo) { TransactionModel tramModelGoodsRelation = new TransactionModel(); #region 当前新增产品插入关系表 PlatGoodsRelation platGoodsRelation = new PlatGoodsRelation(); platGoodsRelation.AddTime = DateTime.Now; platGoodsRelation.Aid = platStore.BindPlatAid; platGoodsRelation.GoodsId = id; PlatStoreCategoryConfig platStoreCategoryConfig = PlatStoreCategoryConfigBLL.SingleModel.GetModelByAid(platStore.BindPlatAid); if (platStoreCategoryConfig != null) { platGoodsRelation.Synchronized = platStoreCategoryConfig.SyncSwitch; } tramModelGoodsRelation.Add(PlatGoodsRelationBLL.SingleModel.BuildAddSql(platGoodsRelation)); #endregion #region //2.查找上级代理 暂时先屏蔽 //AgentDistributionRelation agentDistributionRelationFirst = new AgentDistributionRelationBLL().GetModel(agentinfo.id); //if (agentDistributionRelationFirst != null) //{ // Agentinfo agentinfoFirst = _agentinfoBll.GetModel(agentDistributionRelationFirst.ParentAgentId); // if (agentinfoFirst != null) // { // XcxAppAccountRelation xcxAppAccountRelationFirst = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoFirst.useraccountid, (int)TmpType.小未平台); // if (xcxAppAccountRelationFirst != null) // { // PlatGoodsRelation platGoodsRelationFist = new PlatGoodsRelation(); // platGoodsRelationFist.GoodsId = id; // platGoodsRelationFist.AddTime = DateTime.Now; // platGoodsRelationFist.Aid = xcxAppAccountRelationFirst.Id; // PlatStoreCategoryConfig platStoreCategoryConfigFist = _platStoreCategoryConfigBLL.GetModelByAid(xcxAppAccountRelationFirst.Id); // if (platStoreCategoryConfigFist != null) // { // platGoodsRelationFist.Synchronized = platStoreCategoryConfigFist.SyncSwitch; // } // tramModelGoodsRelation.Add(_platGoodsRelationBLL.BuildAddSql(platGoodsRelationFist)); // //3.查找上级的上级代理 // AgentDistributionRelation agentDistributionRelationSecond = new AgentDistributionRelationBLL().GetModel(agentinfoFirst.id); // if (agentDistributionRelationSecond != null) // { // Agentinfo agentinfoSecond = _agentinfoBll.GetModel(agentDistributionRelationSecond.ParentAgentId); // if (agentinfoSecond != null) // { // XcxAppAccountRelation xcxAppAccountRelationSecond = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoSecond.useraccountid, (int)TmpType.小未平台); // if (xcxAppAccountRelationSecond != null) // { // PlatGoodsRelation platGoodsRelationSecond = new PlatGoodsRelation(); // platGoodsRelationSecond.GoodsId = id; // platGoodsRelationSecond.AddTime = DateTime.Now; // platGoodsRelationSecond.Aid = xcxAppAccountRelationSecond.Id; // PlatStoreCategoryConfig platStoreCategoryConfigSecond = _platStoreCategoryConfigBLL.GetModelByAid(xcxAppAccountRelationSecond.Id); // if (platStoreCategoryConfigSecond != null) // { // platGoodsRelationSecond.Synchronized = platStoreCategoryConfigSecond.SyncSwitch; // } // tramModelGoodsRelation.Add(_platGoodsRelationBLL.BuildAddSql(platGoodsRelationSecond)); // } // } // } // } // } //} #endregion return(base.ExecuteTransactionDataCorect(tramModelGoodsRelation.sqlArray)); }
public List <AgentDistributionRelation> GetSysnDataList(string dname, string aname, int agentid, int opensyncdata, int pageSize, int pageIndex, ref int count) { List <MySqlParameter> parms = new List <MySqlParameter>(); List <AgentDistributionRelation> list = new List <AgentDistributionRelation>(); string sql = $@"select {"{0}"} from ( select * from AgentDistributionRelation where parentagentid = {agentid} or parentagentid in (select agentid from AgentDistributionRelation where parentagentid = {agentid}) ) ad left join agentinfo a on ad.agentid = a.id"; string sqllist = string.Format(sql, "ad.*,a.state agentstate,a.name agentname"); string sqlcount = string.Format(sql, "count(*)"); string sqlwhere = $" where a.state = 1 "; string sqllimit = $" ORDER BY ad.addtime desc LIMIT {(pageIndex - 1) * pageSize},{pageSize} "; //同步状态 if (opensyncdata > -1) { sqlwhere += $" and ad.opensyncdata ={opensyncdata} "; } //分销商名称 if (!string.IsNullOrEmpty(dname)) { sqlwhere += $" and a.name like @name"; parms.Add(new MySqlParameter("@name", $"%{dname}%")); } //所属上级 if (!string.IsNullOrEmpty(aname)) { List <Agentinfo> agentlist = AgentinfoBLL.SingleModel.GetListByName(aname, agentid); if (agentlist == null || agentlist.Count <= 0) { return(list); } string sqlagentids = string.Join(",", agentlist.Select(s => s.id).Distinct()); sqlwhere += $" and ad.parentagentid in ({sqlagentids}) "; } count = base.GetCountBySql(sqlcount + sqlwhere, parms.ToArray()); using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sqllist + sqlwhere + sqllimit, parms.ToArray())) { while (dr.Read()) { AgentDistributionRelation amodel = base.GetModel(dr); amodel.UserName = dr["agentname"].ToString(); list.Add(amodel); } } if (list == null || list.Count <= 0) { return(list); } //所属上级名称 string pagentids = string.Join(",", list.Select(s => s.ParentAgentId).Distinct()); string cagentids = string.Join(",", list.Select(s => s.AgentId).Distinct()); string agentids = pagentids + "," + cagentids; List <Agentinfo> pagentlist = AgentinfoBLL.SingleModel.GetListByIds(agentids); string accountids = "'" + string.Join("','", pagentlist?.Select(s => s.useraccountid).Distinct()) + "'"; List <XcxAppAccountRelation> xcxrelationlist = XcxAppAccountRelationBLL.SingleModel.GetListByTidAccountId(accountids, (int)TmpType.小未平台); string aids = string.Join(",", xcxrelationlist?.Select(s => s.Id).Distinct()); List <PlatStore> storelist = PlatStoreBLL.SingleModel.GetListByBindAids(aids); string storexcxaids = string.Join(",", storelist.Select(s => s.Aid).Distinct()); List <XcxAppAccountRelation> storexcxlist = XcxAppAccountRelationBLL.SingleModel.GetListByIds(storexcxaids); //List<PlatStatistics> statislist = new PlatStatisticsBLL().GetCountList(aids); foreach (AgentDistributionRelation item in list) { //所属上级名称 Agentinfo tempagentinfo = pagentlist?.Where(w => w.id == item.ParentAgentId).FirstOrDefault(); item.ParentName = tempagentinfo?.name; Agentinfo cagentinfo = pagentlist?.Where(w => w.id == item.AgentId).FirstOrDefault(); XcxAppAccountRelation xcxrelation = xcxrelationlist.Where(w => w.AccountId.ToString() == cagentinfo?.useraccountid).FirstOrDefault(); //平台访问量 //PlatStatistics statismodel = statislist?.Where(w => w.AId == xcxrelation?.Id).FirstOrDefault(); //item.PlatViewCount = statismodel!=null?statismodel.Count:0; item.PlatViewCount = PlatStatisticalFlowBLL.SingleModel.GetPVCount(xcxrelation?.Id); //店铺总数 int?sum = storelist?.Where(s => s.BindPlatAid == xcxrelation?.Id).ToList().Count(); item.StoreCount = sum.HasValue ? sum.Value : 0; //屏蔽店铺总数 int?closesum = storelist?.Where(s => s.BindPlatAid == xcxrelation?.Id && s.State > 0).ToList().Count(); item.CloseSyncStoreCount = closesum.HasValue ? closesum.Value : 0; //小程序总数 int?appsum = storexcxlist?.Where(s => !string.IsNullOrEmpty(s.AppId)).ToList().Count(); item.AppCount = appsum.HasValue ? appsum.Value : 0; } return(list); }
public ActionResult SaveUserInfo() { string password = Utility.IO.Context.GetRequest("password", string.Empty); string phone = Utility.IO.Context.GetRequest("phone", string.Empty); string code = Utility.IO.Context.GetRequest("code", string.Empty); string address = Utility.IO.Context.GetRequest("address", string.Empty); string sourcefrom = Utility.IO.Context.GetRequest("sourcefrom", ""); int agentqrcodeid = Utility.IO.Context.GetRequestInt("agentqrcodeid", 0); int opentype = Utility.IO.Context.GetRequestInt("opentype", 0); string username = Utility.IO.Context.GetRequest("username", ""); _msg.isok = false; //if (agentqrcodeid>0 && string.IsNullOrEmpty(username)) //{ // _msg.Msg = "请输入姓名"; // return Json(_msg, JsonRequestBehavior.AllowGet); //} if (string.IsNullOrEmpty(phone)) { _msg.Msg = "请输入手机号"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(code)) { _msg.Msg = "请输入验证码"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(password)) { _msg.Msg = "请输入密码"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } if (sourcefrom.Length > 20) { _msg.Msg = "无效来源"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } if (!string.IsNullOrEmpty(phone)) { Account tempaccout = AccountBLL.SingleModel.GetModelByPhone(phone); if (tempaccout != null) { _msg.Msg = "该手机号已被注册"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } } //是否校验手机号,0检验,1不校验 //校验验证码 _msg = CommondHelper.CheckVaildCode(phone, code); if (!_msg.isok) { return(Json(_msg, JsonRequestBehavior.AllowGet)); } Account account = null; //如果是代理分销扫描注册,测判断绑定的手机号是否已经注册过账号,如果没有则注册一个账号 if (agentqrcodeid > 0) { sourcefrom = "代理分销推广"; account = AccountBLL.SingleModel.GetModelByPhone(phone); } if (account == null) { account = AccountBLL.SingleModel.WeiXinRegister("", 0, "", true, address, phone, sourcefrom, password); } else { //修改已经注册过的用户信息 AccountBLL.SingleModel.UpdateUserInfo(account.Id.ToString(), phone, password, address); } if (account != null) { //用户已绑定手机号,判断是否有单页版 XcxAppAccountRelation usertemplate = XcxAppAccountRelationBLL.SingleModel.GetModelByaccound(account.Id.ToString()); if (usertemplate == null) { //免费开通单页版 XcxAppAccountRelationBLL.SingleModel.AddFreeTemplate(account); } //如果是扫分销代理码注册,则开通代理, if (agentqrcodeid > 0) { //判断是否是代理商 Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(account.Id.ToString(), -1); if (agentinfo != null) { _msg.isok = true; _msg.Msg = "注册失败,该号码已绑定了代理商账号"; return(Json(_msg, JsonRequestBehavior.AllowGet)); } _msg.Msg = _agentDistributionRelationBLL.CreateDistributionAgent(account.Id.ToString(), agentqrcodeid, opentype, username); if (_msg.Msg != "") { return(Json(_msg, JsonRequestBehavior.AllowGet)); } } _msg.isok = true; _msg.Msg = "注册成功"; } else { _msg.isok = false; _msg.Msg = "注册失败"; } string key = string.Format(_resetPasswordkey, phone); RedisUtil.Remove(key); return(Json(_msg, JsonRequestBehavior.AllowGet)); }
public ActionResult SystemMessageList() { int pageIndex = Context.GetRequestInt("pageIndex", 1); int pageSize = Context.GetRequestInt("pageSize", 10); int sysid = Context.GetRequestInt("sysid", 0); ViewBag.sysid = sysid; ViewBag.sysindex = -1; int count = 0; ViewModel <SystemUpdateMessage> viewmodel = new ViewModel <SystemUpdateMessage>(); viewmodel.DataList = new List <SystemUpdateMessage>(); if (dzaccount == null) { ViewBag.ishidden = true; List <SystemUpdateMessage> list = SystemUpdateMessageBLL.SingleModel.GetListByPage(pageSize, pageIndex, ref count); viewmodel.TotalCount = count; viewmodel.PageIndex = pageIndex; viewmodel.PageSize = pageSize; viewmodel.DataList = list; return(View(viewmodel)); //return Redirect("/dzhome/login"); } //Member member = _memberBll.GetMemberByAccountId(dzaccount.Id.ToString()); //if (member == null) //{ // return View("PageError", new Return_Msg() { Msg = "系统繁忙!", code = "500" }); //} //判断是否是代理商 Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(dzaccount.Id.ToString()); if (agentinfo == null) { agentinfo = new Agentinfo(); } List <XcxAppAccountRelation> relationlist = XcxAppAccountRelationBLL.SingleModel.GetListByaccountId(dzaccount.Id.ToString()); string tids = ""; if (relationlist != null && relationlist.Count > 0) { tids = string.Join(",", relationlist.Select(s => s.TId).Distinct()); } viewmodel.DataList = SystemUpdateMessageBLL.SingleModel.GetAllSystemUpdateMessageList(tids, dzaccount.Id.ToString(), agentinfo.id, pageIndex, pageSize, ref count); viewmodel.TotalCount = count; viewmodel.PageIndex = pageIndex; viewmodel.PageSize = pageSize; //设为已读 if (sysid > 0) { SystemUpdateUserLogBLL.SingleModel.Readed(sysid, dzaccount.Id.ToString()); } if (viewmodel.DataList != null && viewmodel.DataList.Count > 0 && sysid > 0) { SystemUpdateMessage item = viewmodel.DataList.Where(w => w.Id == sysid).FirstOrDefault(); if (item != null) { ViewBag.sysindex = viewmodel.DataList.IndexOf(item); } } return(View(viewmodel)); }