Ejemplo n.º 1
0
        public ActionResult mobileReg()
        {
            //代理分销,判断是否已开通过代理,开通过代理就不给他开通
            int agentqrcodeid = Context.GetRequestInt("agentqrcodeid", 0);

            if (agentqrcodeid > 0)
            {
                AgentQrCode agentqrmodel = AgentQrCodeBLL.SingleModel.GetModelById(agentqrcodeid);
                if (agentqrmodel == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "二维码已失效!", code = "403"
                    }));
                }
            }
            ViewBag.AgentQrCodeId = agentqrcodeid;

            return(View());
        }
Ejemplo n.º 2
0
        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("");
        }