コード例 #1
0
ファイル: AgentQrCodeBLL.cs プロジェクト: soon14/vzan
        public List <AgentQrCode> GetAgentQrCodeList(int agentid, int pageIndex, int pageSize, ref int count, bool reflesh = false)
        {
            RedisModel <AgentQrCode> model = new RedisModel <AgentQrCode>();

            model = RedisUtil.Get <RedisModel <AgentQrCode> >(string.Format(_redis_AgentQrCodeKey, agentid, pageSize, pageIndex));
            int dataversion = RedisUtil.GetVersion(string.Format(_redis_AgentQrCodeVersion, agentid));

            if (reflesh || model == null || model.DataList == null || model.DataList.Count <= 0 || model.DataVersion != dataversion)
            {
                model = new RedisModel <AgentQrCode>();
                List <AgentQrCode> list = GetDataList(agentid, pageSize, pageIndex);

                if (list == null || list.Count <= 0)
                {
                    return(new List <AgentQrCode>());
                }

                string qrcodeids = string.Join(",", list.Select(s => s.Id).Distinct());
                List <AgentCustomerRelation> rlist = AgentCustomerRelationBLL.SingleModel.GetListByQrCodeId(qrcodeids);
                if (rlist != null && rlist.Count > 0)
                {
                    string         userids     = "'" + string.Join("','", rlist.Select(s => s.useraccountid)) + "'";
                    List <Account> accountlist = AccountBLL.SingleModel.GetListByAccountids(userids);
                    if (accountlist != null && accountlist.Count > 0)
                    {
                        foreach (AgentQrCode item in list)
                        {
                            AgentCustomerRelation rmodel = rlist.FirstOrDefault(f => f.QrcodeId == item.Id);
                            if (rmodel == null)
                            {
                                continue;
                            }
                            Account account = accountlist.Where(w => w.Id.ToString() == rmodel.useraccountid).FirstOrDefault();
                            if (account == null)
                            {
                                continue;
                            }
                            item.LoginId            = account.LoginId;
                            item.OpenExtension      = rmodel.OpenExtension;
                            item.CustomerRelationId = rmodel.id;
                        }
                    }
                }

                count             = GetCountByAgentId(agentid);
                model.DataList    = list;
                model.DataVersion = dataversion;
                model.Count       = count;
                RedisUtil.Set <RedisModel <AgentQrCode> >(string.Format(_redis_AgentQrCodeKey, agentid, pageSize, pageIndex), model);
            }
            else
            {
                count = model.Count;
            }

            return(model.DataList);
        }
コード例 #2
0
ファイル: AgentCaseBackBLL.cs プロジェクト: soon14/vzan
        private readonly string _redis_AgentCaseBackVersion = "redis_AgentCaseBackVersion_{0}";//版本控制

        public List <AgentCaseBack> GetAgentCaseBackList(string agentname, string soucefrom, string starttime, string endtime, string agentid, int pageIndex, int pageSize, ref int count, bool reflesh = false, int datatype = 0)
        {
            RedisModel <AgentCaseBack> model = new RedisModel <AgentCaseBack>();

            model = RedisUtil.Get <RedisModel <AgentCaseBack> >(string.Format(_redis_AgentCaseBackKey, agentid, pageSize, pageIndex, datatype));
            int dataversion = RedisUtil.GetVersion(string.Format(_redis_AgentCaseBackVersion, agentid));

            if (!string.IsNullOrEmpty(starttime) || !string.IsNullOrEmpty(endtime))
            {
                reflesh = true;
            }

            string othersqlwhere = "";

            if (!string.IsNullOrEmpty(agentname))
            {
                othersqlwhere += $" and a.name='{agentname}'";
                Account account = AccountBLL.SingleModel.GetModelByLoginid(agentname);
                if (account != null)
                {
                    othersqlwhere = $" and (a.name='{agentname}' or a.useraccountid='{account.Id}') ";
                }
                reflesh = true;
            }
            if (!string.IsNullOrEmpty(soucefrom))
            {
                string  accountid = "";
                Account account   = AccountBLL.SingleModel.GetModelByLoginid(soucefrom);
                if (account == null || account?.Id == Guid.Empty)
                {
                    accountid = "";
                }
                else
                {
                    accountid = account.Id.ToString();
                }
                List <AgentCustomerRelation> crmodel = AgentCustomerRelationBLL.SingleModel.GetListByAccountId(agentid, accountid, soucefrom);
                if (crmodel == null || crmodel.Count <= 0)
                {
                    return(new List <AgentCaseBack>());
                }

                string qrcodeids = string.Join(",", crmodel.Select(s => s.QrcodeId).Distinct());
                othersqlwhere += $" and ad.qrcodeid in ({qrcodeids})";
                reflesh        = true;
            }

            if (reflesh || model == null || model.DataList == null || model.DataList.Count <= 0 || model.DataVersion != dataversion)
            {
                model = new RedisModel <AgentCaseBack>();
                List <AgentCaseBack> list = new List <AgentCaseBack>();
                string sqlcount           = $" select count(*) from AgentCaseBack ac right join (select * from agentdistributionrelation where parentagentid in ({agentid}) UNION select* from agentdistributionrelation where parentagentid in (select agentid from agentdistributionrelation where parentagentid in ({agentid}))) ad on ac.AgentDistributionRelatioinId = ad.id left join agentinfo a on a.id = ad.agentid";
                string sql      = $" select ac.*,ad.`level`,ad.agentid,ad.qrcodeid,a.name agentname,a.useraccountid,a.LastDeposit from AgentCaseBack ac right join (select *,'一级分销' level from agentdistributionrelation where parentagentid in ({agentid}) UNION select *,'二级分销' level from agentdistributionrelation where parentagentid in (select agentid from agentdistributionrelation where parentagentid in ({agentid}))) ad on ac.AgentDistributionRelatioinId = ad.id left join agentinfo a on a.id = ad.agentid";
                string sqlwhere = $" where  1=1 and ac.id>0 and ac.datatype={datatype} {othersqlwhere}";
                string sqllimit = $" ORDER BY ac.addtime desc LIMIT {(pageIndex - 1) * pageSize},{pageSize} ";
                if (!string.IsNullOrEmpty(starttime))
                {
                    sqlwhere += $" and ac.addtime>='{starttime}' ";
                }
                if (!string.IsNullOrEmpty(endtime))
                {
                    sqlwhere += $" and ac.addtime<='{endtime} 23:59' ";
                }

                using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sql + sqlwhere + sqllimit, null))
                {
                    while (dr.Read())
                    {
                        AgentCaseBack amodel = base.GetModel(dr);
                        amodel.Level         = dr["level"].ToString();
                        amodel.AgentName     = dr["agentname"].ToString();
                        amodel.UseraccountId = dr["useraccountid"].ToString();
                        if (dr["agentid"] != DBNull.Value)
                        {
                            amodel.AgentId = Convert.ToInt32(dr["agentid"]);
                        }
                        if (dr["qrcodeid"] != DBNull.Value)
                        {
                            amodel.QrCodeId = Convert.ToInt32(dr["qrcodeid"]);
                        }
                        if (dr["LastDeposit"] != DBNull.Value)
                        {
                            amodel.LastDeposit = Convert.ToInt32(dr["LastDeposit"]);
                        }
                        list.Add(amodel);
                    }
                }

                if (list == null || list.Count <= 0)
                {
                    return(new List <AgentCaseBack>());
                }
                string qrcodeids = string.Join("", list.Select(s => s.QrCodeId).Distinct());
                List <AgentCustomerRelation> customerRelationlist = AgentCustomerRelationBLL.SingleModel.GetListByQrCodeId(qrcodeids);
                string cruserids = "'" + string.Join("','", customerRelationlist.Select(s => s.useraccountid)) + "'";
                string userids   = "'" + string.Join("','", list.Select(s => s.UseraccountId)) + "'";
                if (cruserids.Length > 0)
                {
                    userids = userids + "," + cruserids;
                }
                List <Account> accountlist = AccountBLL.SingleModel.GetListByAccountids(userids);
                foreach (AgentCaseBack item in list)
                {
                    Account aitem = accountlist?.Where(w => w.Id.ToString() == item.UseraccountId).FirstOrDefault();
                    item.LoginId = aitem?.LoginId;
                    AgentCustomerRelation crmodel = customerRelationlist?.Where(w => w.QrcodeId == item.QrCodeId).FirstOrDefault();
                    Account critem = accountlist?.Where(w => w.Id.ToString() == crmodel?.useraccountid).FirstOrDefault();
                    item.SourceFrom = crmodel?.username + "/" + critem?.LoginId;
                }

                count             = base.GetCountBySql(sqlcount + sqlwhere);
                model.DataList    = list;
                model.DataVersion = dataversion;
                model.Count       = count;
                if (!reflesh)
                {
                    RedisUtil.Set <RedisModel <AgentCaseBack> >(string.Format(_redis_AgentCaseBackKey, agentid, pageSize, pageIndex, datatype), model);
                }
            }
            else
            {
                count = model.Count;
            }

            return(model.DataList);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        public List <AgentDistributionRelation> GetAgentDistributionRelationList(string starttime, string endtime, string loginid, int agentqrcodeid, int agentid, int pageIndex, int pageSize, ref int count, bool reflesh = false)
        {
            string accountids = "";

            if (!string.IsNullOrEmpty(loginid))
            {
                Account accountlist = AccountBLL.SingleModel.GetModelByLoginid(loginid);
                if (accountlist == null)
                {
                    return(new List <AgentDistributionRelation>());
                }
                accountids = "'" + accountlist.Id + "'";
                reflesh    = true;
            }
            if (!string.IsNullOrEmpty(starttime) || !string.IsNullOrEmpty(endtime))
            {
                reflesh = true;
            }

            RedisModel <AgentDistributionRelation> model = new RedisModel <AgentDistributionRelation>();

            model = RedisUtil.Get <RedisModel <AgentDistributionRelation> >(string.Format(_redis_AgentDistributionRelationKey, agentid, agentqrcodeid, pageSize, pageIndex));
            int dataversion = RedisUtil.GetVersion(string.Format(_redis_AgentDistributionRelationVersion, agentid));

            if (reflesh || model == null || model.DataList == null || model.DataList.Count <= 0 || model.DataVersion != dataversion)
            {
                model = new RedisModel <AgentDistributionRelation>();

                List <AgentDistributionRelation> list = new List <AgentDistributionRelation>();

                string sqlcount = $" select Count(*) from AgentDistributionRelation ad left join agentinfo a on ad.agentid = a.id ";
                string sql      = $" select ad.*,a.useraccountid,a.LastDeposit,a.name agentname from AgentDistributionRelation ad left join agentinfo a on ad.agentid = a.id ";
                string sqlwhere = $" where ad.state>=0 and ad.ParentAgentId = {agentid} and qrcodeid={agentqrcodeid}";
                if (accountids.Length > 0)
                {
                    sqlwhere += $" and useraccountid in ({accountids}) ";
                }
                if (!string.IsNullOrEmpty(starttime))
                {
                    sqlwhere += $" and ad.addtime>='{starttime}' ";
                }
                if (!string.IsNullOrEmpty(endtime))
                {
                    sqlwhere += $" and ad.addtime<='{endtime} 23:59' ";
                }

                string sqllimit = $" ORDER BY ad.addtime desc LIMIT {(pageIndex - 1) * pageSize},{pageSize} ";

                using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sql + sqlwhere + sqllimit, null))
                {
                    while (dr.Read())
                    {
                        AgentDistributionRelation amodel = base.GetModel(dr);
                        amodel.UserAccountId = dr["useraccountid"].ToString();
                        amodel.UserName      = dr["agentname"].ToString();
                        if (dr["LastDeposit"] != DBNull.Value)
                        {
                            amodel.LastDeposit = Convert.ToInt32(dr["LastDeposit"]);
                        }
                        AgentFollowLog agentlogmodel = AgentFollowLogBLL.SingleModel.GetLastModel(amodel.Id);
                        if (agentlogmodel != null)
                        {
                            amodel.Desc = agentlogmodel.Desc;
                        }
                        list.Add(amodel);
                    }
                }

                if (list == null || list.Count <= 0)
                {
                    return(new List <AgentDistributionRelation>());
                }

                //查找来源
                string qrcodeid = string.Join(",", list.Select(s => s.QrCodeId).Distinct());
                List <AgentCustomerRelation> customerRelationlist = AgentCustomerRelationBLL.SingleModel.GetListByQrCodeId(qrcodeid);
                string cruserids = "'" + string.Join("','", customerRelationlist.Select(s => s.useraccountid)) + "'";
                string userids   = "'" + string.Join("','", list.Select(s => s.UserAccountId)) + "'";
                if (cruserids.Length > 0)
                {
                    userids = userids + "," + cruserids;
                }
                List <Account> accountlist = AccountBLL.SingleModel.GetListByAccountids(userids);
                foreach (AgentDistributionRelation item in list)
                {
                    Account aitem = accountlist?.Where(w => w.Id.ToString() == item.UserAccountId).FirstOrDefault();
                    item.LoginId = aitem?.LoginId;
                    item.Phone   = aitem?.ConsigneePhone;
                    AgentCustomerRelation crmodel = customerRelationlist?.Where(w => w.QrcodeId == item.QrCodeId).FirstOrDefault();
                    Account critem = accountlist?.Where(w => w.Id.ToString() == crmodel?.useraccountid).FirstOrDefault();
                    item.SourceFrom = crmodel?.username + "/" + (string.IsNullOrEmpty(critem?.ConsigneePhone) ? "未绑定手机号" : critem?.ConsigneePhone);
                }

                count             = base.GetCountBySql(sqlcount + sqlwhere);
                model.DataList    = list;
                model.DataVersion = dataversion;
                model.Count       = count;
                if (!reflesh)
                {
                    RedisUtil.Set <RedisModel <AgentDistributionRelation> >(string.Format(_redis_AgentDistributionRelationKey, agentid, agentqrcodeid, pageSize, pageIndex), model);
                }
            }
            else
            {
                count = model.Count;
            }

            return(model.DataList);
        }
コード例 #5
0
        /// <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);
        }