Ejemplo n.º 1
0
        public ActionResult SaveAgentLevelConfig(PinAgentLevelConfig agentLevelConfig)
        {
            if (agentLevelConfig == null)
            {
                result.msg = "数据不能为空!";
                return(Json(result));
            }

            PinAgentLevelConfig model = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(agentLevelConfig.Id);

            if (model == null)
            {
                result.msg = "该等级不存在数据库里!";
                return(Json(result));
            }
            model.AgentFee           = agentLevelConfig.AgentFee;
            model.AgentExtract       = agentLevelConfig.AgentExtract;
            model.OrderExtract       = agentLevelConfig.OrderExtract;
            model.SecondAgentExtract = agentLevelConfig.SecondAgentExtract;
            model.SecondOrderExtract = agentLevelConfig.SecondOrderExtract;
            model.UpdateTime         = DateTime.Now;


            if (PinAgentLevelConfigBLL.SingleModel.Update(model, "AgentFee,AgentExtract,OrderExtract,SecondAgentExtract,SecondOrderExtract,UpdateTime"))
            {
                result.code = 1;
                result.msg  = "保存成功";
            }
            else
            {
                result.msg = "保存失败";
            }
            return(Json(result));
        }
Ejemplo n.º 2
0
        public List <object> GetListByAgentId_type(int aid, int fuserId, int pageIndex, int pageSize, out int count, int extractType = 0)
        {
            string sqlwhere = $" fuserId={fuserId} and state=1 and aid={aid}";

            if (extractType == 1)
            {
                //查找下下级
                sqlwhere = $" aid={aid} and fuserId in({GetGrandfatherAgentIds(fuserId)}) and state=1 ";
            }
            count = GetCount(sqlwhere);
            List <PinAgent> list           = GetList(sqlwhere, pageSize, pageIndex, "*", "id desc");
            List <object>   objList        = new List <object>();
            string          agentLevelName = string.Empty;

            if (list != null && list.Count > 0)
            {
                string            userIds      = string.Join(",", list.Select(s => s.userId));
                List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds);

                foreach (var agent in list)
                {
                    C_UserInfo userInfo = userInfoList?.FirstOrDefault(f => f.Id == agent.userId) ?? new C_UserInfo();
                    string     sql      = $"select sum(income) as income from pinagentincomelog where source=0 and userid={fuserId} and  sourceuid={agent.userId} and ExtractType={extractType}";
                    var        result   = SqlMySql.ExecuteScalar(connName, System.Data.CommandType.Text, sql);

                    string income = result == DBNull.Value ? "0.00" : (Convert.ToInt32(result) * 0.001 * 0.01).ToString("0.00");

                    PinAgentLevelConfig pinAgentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(agent.AgentLevel, aid);
                    if (pinAgentLevelConfig != null)
                    {
                        agentLevelName = pinAgentLevelConfig.LevelName;//等级名称
                    }

                    objList.Add(new { headImg = userInfo.HeadImgUrl, name = userInfo.NickName, income, addtime = agent.addTimeStr, phone = userInfo.TelePhone, storeId = userInfo.StoreId, agentLevelName = agentLevelName });
                }
            }
            return(objList);
        }
Ejemplo n.º 3
0
        public ActionResult UpdateAgentLevel()
        {
            int aid        = Utility.IO.Context.GetRequestInt("aid", 0);
            int agentLevel = Utility.IO.Context.GetRequestInt("agentLevel", 0);
            int agentId    = Utility.IO.Context.GetRequestInt("agentId", 0);
            int agentFee   = Utility.IO.Context.GetRequestInt("agentFee", 0);

            if (aid <= 0 || agentId <= 0)
            {
                result.code = 0;
                result.msg  = "参数错误";
                return(Json(result));
            }
            XcxAppAccountRelation xcxAppAccountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxAppAccountRelation == null)
            {
                result.code = 0;
                result.msg  = "小程序不存在";
                return(Json(result));
            }

            PinAgent pinAgent = PinAgentBLL.SingleModel.GetModel(agentId);

            if (pinAgent == null)
            {
                result.code = 0;
                result.msg  = "代理商不存在";
                return(Json(result));
            }
            if (pinAgent.state == 0)
            {
                result.code = 0;
                result.msg  = "代理商不可用";
                return(Json(result));
            }
            int      oldAgentLevel = pinAgent.AgentLevel;//保存之前的等级
            DateTime oldAddtime    = pinAgent.addTime;

            pinAgent.AgentLevel = agentLevel;
            pinAgent.addTime    = DateTime.Now;
            PinAgentLevelConfig pinAgentLevel = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(agentLevel, aid);

            if (pinAgentLevel == null)
            {
                result.code = 0;
                result.msg  = "升级的等级不存在";
                return(Json(result));
            }
            if (pinAgentLevel.State == -1)
            {
                result.code = 0;
                result.msg  = "升级的等级被删除了";
                return(Json(result));
            }
            agentFee = agentFee < 0 ? pinAgentLevel.AgentFee : agentFee;

            if (!PinAgentBLL.SingleModel.UpdateAgentLevel(pinAgent, agentFee, oldAgentLevel, oldAddtime))
            {
                result.code = 0;
                result.msg  = "升级失败";
                return(Json(result));
            }

            result.code = 1;
            result.msg  = "升级成功";
            return(Json(result));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取代理商列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAgentList()
        {
            int    aid       = Utility.IO.Context.GetRequestInt("aid", 0);
            int    pageIndex = Utility.IO.Context.GetRequestInt("pageIndex", 1);
            int    pageSize  = Utility.IO.Context.GetRequestInt("pageSize", 10);
            string nickName  = Utility.IO.Context.GetRequest("nickName", string.Empty);
            string phone     = Utility.IO.Context.GetRequest("phone", string.Empty);
            string fnickName = Utility.IO.Context.GetRequest("fnickName", string.Empty);
            string fphone    = Utility.IO.Context.GetRequest("fphone", string.Empty);

            if (aid <= 0)
            {
                result.code = 0;
                result.msg  = "参数错误";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation xcxAppAccountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxAppAccountRelation == null)
            {
                result.code = 0;
                result.msg  = "小程序不存在";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            int recordCount = 0;


            List <PinAgent> agentList = PinAgentBLL.SingleModel.GetListByAid_State(xcxAppAccountRelation.AppId, aid, pageSize, pageIndex, out recordCount, phone: phone, nickName: nickName, fnickName: fnickName, fphone: fphone);

            if (agentList != null && agentList.Count > 0)
            {
                string userIds  = string.Join(",", agentList.Select(s => s.userId).Distinct());
                string fuserIds = string.Join(",", agentList.Where(w => w.fuserId > 0)?.Select(s => s.fuserId).Distinct());
                if (!string.IsNullOrEmpty(fuserIds))
                {
                    if (!string.IsNullOrEmpty(userIds))
                    {
                        userIds = userIds + "," + fuserIds;
                    }
                    else
                    {
                        userIds = fuserIds;
                    }
                }
                List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds);
                agentList.ForEach(x =>
                {
                    C_UserInfo userInfo = userInfoList?.FirstOrDefault(f => f.Id == x.userId);
                    if (userInfo != null)
                    {
                        x.userInfo = userInfo;
                    }

                    PinAgentLevelConfig pinAgentLevel = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(x.AgentLevel, aid);
                    if (pinAgentLevel != null)
                    {
                        x.AgentLevelName = pinAgentLevel.LevelName;
                        x.AgentLevelTimeList.Add(new { Time = -1, Txt = "请选择", Money = 0 });
                        x.AgentLevelTimeList.Add(new { Time = 1, Txt = "1年", Money = pinAgentLevel.AgentFee * 0.01 });
                        x.AgentLevelTimeList.Add(new { Time = 2, Txt = "2年", Money = pinAgentLevel.AgentFee * 0.01 * 2 });
                        x.AgentLevelTimeList.Add(new { Time = 3, Txt = "3年", Money = pinAgentLevel.AgentFee * 0.01 * 3 });
                        x.AgentLevelTimeList.Add(new { Time = 4, Txt = "4年", Money = pinAgentLevel.AgentFee * 0.01 * 4 });
                        x.AgentLevelTimeList.Add(new { Time = 5, Txt = "5年", Money = pinAgentLevel.AgentFee * 0.01 * 5 });
                    }


                    if (x.fuserId > 0)
                    {
                        PinAgentDec pinAgentDec = new PinAgentDec();

                        C_UserInfo fuserInfo = userInfoList?.FirstOrDefault(f => f.Id == x.fuserId);
                        if (fuserInfo != null)
                        {
                            pinAgentDec.UserId   = fuserInfo.Id;
                            pinAgentDec.UserName = fuserInfo.NickName;
                            pinAgentDec.Phone    = fuserInfo.TelePhone;
                        }

                        PinAgent fpinAgent = PinAgentBLL.SingleModel.GetModelByUserId(x.fuserId);
                        if (fpinAgent != null)
                        {
                            PinAgentLevelConfig pinFAgentLevel = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(fpinAgent.AgentLevel, aid);
                            if (pinFAgentLevel != null)
                            {
                                pinAgentDec.AgentLevelName = pinFAgentLevel.LevelName;
                                pinAgentDec.AgentLevel     = pinFAgentLevel.LevelId;
                            }
                        }

                        x.pinAgentDec = pinAgentDec;
                    }

                    x.TotalAgentMoney = PinAgentBLL.SingleModel.GetAgentFee(x.id);
                });
            }


            result.code = 1;
            result.obj  = new { list = agentList, recordCount };
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public ActionResult AddAgentTime()
        {
            int aid        = Utility.IO.Context.GetRequestInt("aid", 0);
            int timeLength = Utility.IO.Context.GetRequestInt("timeLength", 0);
            int agentId    = Utility.IO.Context.GetRequestInt("agentId", 0);

            if (aid <= 0 || agentId <= 0 || timeLength <= 0)
            {
                result.code = 0;
                result.msg  = "参数错误";
                return(Json(result));
            }
            XcxAppAccountRelation xcxAppAccountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxAppAccountRelation == null)
            {
                result.code = 0;
                result.msg  = "小程序不存在";
                return(Json(result));
            }

            PinAgent pinAgent = PinAgentBLL.SingleModel.GetModel(agentId);

            if (pinAgent == null)
            {
                result.code = 0;
                result.msg  = "代理商不存在";
                return(Json(result));
            }
            if (pinAgent.state == 0)
            {
                result.code = 0;
                result.msg  = "代理商不可用";
                return(Json(result));
            }


            PinAgentLevelConfig pinAgentLevel = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(pinAgent.AgentLevel, aid);

            if (pinAgentLevel == null)
            {
                result.code = 0;
                result.msg  = "续期失败,代理商的等级不存在";
                return(Json(result));
            }
            if (pinAgentLevel.State == -1)
            {
                result.code = 0;
                result.msg  = "续期失败,代理商的等级被删除了";
                return(Json(result));
            }

            if (!PinAgentBLL.SingleModel.AddAgentTime(pinAgent, pinAgentLevel.AgentFee * timeLength, timeLength))
            {
                result.code = 0;
                result.msg  = "续期失败";
                return(Json(result));
            }



            result.code = 1;
            result.msg  = "续期成功";
            return(Json(result));
        }
Ejemplo n.º 6
0
        public ActionResult MyAgentInfo(int id = 0, string openId = "", string phone = "", string testpxhappid = "", string utoken = "")
        {
            if (string.IsNullOrEmpty(testpxhappid))
            {
                testpxhappid = _pxhAppId;
            }
            C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModelByTelephone_appid(phone, testpxhappid);//_pxhAppId

            if (userinfo == null)
            {
                return(Content("无效用户"));
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(userinfo.appId);

            if (xcxrelation == null)
            {
                return(Content("无效模板"));
            }

            if (id <= 0)
            {
                return(Content("无效用户id"));
            }

            //获取登陆秘钥
            utoken = CheckLoginClass.GetLoginSessionKey("1", userinfo.OpenId);


            if (string.IsNullOrEmpty(utoken))
            {
                return(Content("utoken无效,请重新登录"));
            }

            PinAgent agent = PinAgentBLL.SingleModel.GetModelByUserId(userinfo.Id);

            userinfo.zbSiteId = id;
            agent.userInfo    = userinfo;

            agent.First = new AgentDistributionDetail()
            {
                AgentCount    = PinAgentBLL.SingleModel.GetAgentCount(agent.aId, agent.userId, 0),
                AgentSumMoney = PinAgentIncomeLogBLL.SingleModel.GetIncomeSum(agent.id, 0, 0),
                OrderSum      = PinAgentIncomeLogBLL.SingleModel.GetIncomeSum(agent.id, 1, 0),
                StoreCount    = PinStoreBLL.SingleModel.GetStoreCount(agent.id, 0)
            };

            agent.Second = new AgentDistributionDetail()
            {
                AgentCount    = PinAgentBLL.SingleModel.GetAgentCount(agent.aId, agent.userId, 1),
                AgentSumMoney = PinAgentIncomeLogBLL.SingleModel.GetIncomeSum(agent.id, 0, 1),
                OrderSum      = PinAgentIncomeLogBLL.SingleModel.GetIncomeSum(agent.id, 1, 1),
                StoreCount    = PinStoreBLL.SingleModel.GetStoreCount(agent.id, 1)
            };
            PinAgentLevelConfig pinAgentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(agent.AgentLevel, agent.aId);

            if (pinAgentLevelConfig != null)
            {
                agent.AgentLevelName = pinAgentLevelConfig.LevelName;//等级名称
            }


            ViewBag.utoken = utoken;
            ViewBag.openId = openId;
            return(View(agent));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 代理提成
        /// </summary>
        /// <param name="agent"></param>
        /// <param name="pinOrder"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public bool UpdateIncome(PinAgent agent, PinGoodsOrder pinOrder, TransactionModel tran = null)
        {
            bool istran = tran != null;

            if (!istran)
            {
                tran = new TransactionModel();
            }

            PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(agent.aId);

            if (platform == null)
            {
                log4net.LogHelper.WriteError(GetType(), new Exception($"代理提成错误:找不到平台信息信息 userid:{agent.fuserId}"));
                return(istran);
            }


            PinAgentLevelConfig agentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(agent.AgentLevel, agent.aId);

            if (agentLevelConfig == null)
            {
                log4net.LogHelper.WriteInfo(GetType(), $"代理提成错误:当前入驻代理商{agent.id}等级找不到");
                return(istran);
            }

            PinAgent fagent = GetModelByUserId(agent.fuserId);

            if (fagent == null)
            {
                log4net.LogHelper.WriteInfo(GetType(), $"代理提成错误:找不到上级代理信息 userid:{agent.fuserId}");
                return(istran);
            }

            //查找该代理上级所属等级 根据所属等级进行不同比例分成

            PinAgentLevelConfig fagentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(fagent.AgentLevel, fagent.aId);

            if (fagentLevelConfig == null)
            {
                log4net.LogHelper.WriteInfo(GetType(), $"代理提成错误:上级代理商{fagent.id}等级找不到");
                return(istran);
            }
            int percent = fagentLevelConfig.AgentExtract;

            if (agentLevelConfig.LevelId > fagentLevelConfig.LevelId)
            {
                //表示当前代理商级别高于所属上级代理商级别则按越级比例分配给上级
                percent = platform.JumpExtract;
            }



            //上级代理获得提成
            fagent.cash  += pinOrder.money * percent;
            fagent.money += pinOrder.money * percent;
            tran.Add(BuildUpdateSql(fagent, "cash,money"));


            #region 查找上级代理商是否有上级,如果有上级则上级也要获得抽成
            PinAgent grandfatherAgent = GetModelByUserId(fagent.fuserId);
            if (grandfatherAgent != null)
            {
                //上上级
                PinAgentLevelConfig gfagentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(grandfatherAgent.AgentLevel, grandfatherAgent.aId);
                if (fagentLevelConfig == null || gfagentLevelConfig.SecondAgentExtract <= 0 || (gfagentLevelConfig.AgentExtract + gfagentLevelConfig.SecondAgentExtract) > 1000)
                {
                    log4net.LogHelper.WriteInfo(GetType(), $"上上级代理提成错误:上上级代理商{grandfatherAgent.id}等级找不到或者比例不能分成");
                    return(istran);
                }

                grandfatherAgent.cash  += pinOrder.money * gfagentLevelConfig.SecondAgentExtract;
                grandfatherAgent.money += pinOrder.money * gfagentLevelConfig.SecondAgentExtract;
                tran.Add(BuildUpdateSql(grandfatherAgent, "cash,money"));
            }
            #endregion



            if (istran)
            {
                return(true);
            }
            return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取商家订单提成
        /// </summary>
        /// <param name="apply"></param>
        /// <returns></returns>
        public bool AddStoreIncome(DrawCashApply apply)
        {
            bool             result = false;
            TransactionModel tran   = new TransactionModel();

            PinStore store = PinStoreBLL.SingleModel.GetModelByAid_UserId(apply.Aid, apply.userId);

            if (store == null)
            {
                log4net.LogHelper.WriteInfo(GetType(), $"获取商家订单提成失败:商户不存在 userId:{apply.userId}");
                return(result);
            }

            //更新提现状态
            tran.Add(DrawCashApplyBLL.SingleModel.BuildUpdateSql(apply, "drawstate,drawtime,updatetime,remark"));

            //各级分成
            if (store.agentId > 0)
            {
                PinAgent fagent = GetModelById(store.agentId);
                if (fagent == null)
                {
                    log4net.LogHelper.WriteInfo(GetType(), $"获取商家订单提成失败:代理不存在 agentId:{store.agentId}");
                    return(result);
                }

                PinAgentLevelConfig fagentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(fagent.AgentLevel, fagent.aId);
                if (fagentLevelConfig == null)
                {
                    log4net.LogHelper.WriteInfo(GetType(), $"获取商家订单提成错误:代理商{fagent.id}等级找不到");
                    return(result);
                }

                //表示商家上级找到了进行分成
                int money = fagentLevelConfig.OrderExtract * apply.applyMoney;
                fagent.cash  += money;
                fagent.money += money;
                tran.Add(BuildUpdateSql(fagent, "cash,money"));
                PinAgentIncomeLogBLL.SingleModel.AddAgentLog(store, money, fagent, tran, "");//插入上级提成日志



                #region 表示有上上级推广者

                PinStore fatherStore = PinStoreBLL.SingleModel.GetModelByAid_UserId(apply.Aid, fagent.userId);//查找出推广者的店铺,然后再找出上上级推广者
                if (fatherStore != null)
                {
                    if (fatherStore.agentId > 0)
                    {
                        //表示有上上级推广者
                        PinAgent gfAgent = GetModelById(fatherStore.agentId);
                        if (gfAgent != null)
                        {
                            PinAgentLevelConfig gfLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(gfAgent.AgentLevel, gfAgent.aId);
                            if (gfLevelConfig == null)
                            {
                                log4net.LogHelper.WriteInfo(GetType(), $"获取商家订单提成错误:上上级代理商{fagent.id}等级找不到");
                                return(result);
                            }

                            int gfatherAgentMoney = gfLevelConfig.SecondOrderExtract * apply.applyMoney;
                            gfAgent.cash  += gfatherAgentMoney;
                            gfAgent.money += gfatherAgentMoney;
                            tran.Add(BuildUpdateSql(gfAgent, "cash,money"));
                            PinAgentIncomeLogBLL.SingleModel.AddAgentLog(store, gfatherAgentMoney, gfAgent, tran, "");//插入上上级提成日志
                        }
                    }
                }
                #endregion
            }

            result = ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray);
            return(result);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 代理提成日志
        /// </summary>
        /// <param name="agent"></param>
        /// <param name="pinOrder"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public bool AddAgentLog(PinAgent agent, PinGoodsOrder pinOrder, TransactionModel tran = null)
        {
            bool istran = tran != null;

            if (!istran)
            {
                tran = new TransactionModel();
            }

            PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(agent.aId);

            if (platform == null)
            {
                log4net.LogHelper.WriteError(GetType(), new Exception("平台信息错误"));
                return(false);
            }

            #region 旧代码 没有代理商等级时候的逻辑
            //int Percent = platform.agentExtract;//上级比例
            //PinAgent grandfatherAgent = null;
            //int money = pinOrder.money * Percent;
            //if (agent.fuserId > 0)
            //{
            //    PinAgent fatherAgent = PinAgentBLL.SingleModel.GetModelByUserId(agent.fuserId);
            //    if (fatherAgent != null)
            //    {
            //        grandfatherAgent = PinAgentBLL.SingleModel.GetModelByUserId(fatherAgent.fuserId);
            //        if (grandfatherAgent != null && platform.FirstExtract > 0 && platform.SecondExtract > 0 && (platform.FirstExtract + platform.SecondExtract) <= 1000)
            //        {
            //            //表示有上上级 重新分配上级提成比例
            //            money = Convert.ToInt32(platform.FirstExtract * 0.001 * money);
            //        }
            //    }
            //}

            //PinAgentIncomeLog log = new PinAgentIncomeLog()
            //{
            //    aId = agent.aId,
            //    userId = agent.fuserId,
            //    sourceUid = agent.userId,
            //    income = money,
            //    source = 0
            //};
            //C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(agent.userId);
            //if (userInfo == null)
            //{
            //    log.remark = $"代理付费日志出错:找不到代理用户信息 userid:{agent.userId}";
            //    log4net.LogHelper.WriteError(GetType(), new Exception(log.remark));
            //    tran.Add(BuildAddSql(log));
            //    if (istran) return true;
            //    return ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray);
            //}
            //log.remark = $"{userInfo.NickName} 成为代理";

            //if (agent.fuserId > 0)
            //{
            //    PinAgent fagent = PinAgentBLL.SingleModel.GetModelByUserId(agent.fuserId);
            //    if (fagent == null)
            //    {
            //        log.remark = $"代理付费日志出错:找不到上级代理 userid:{agent.fuserId}";
            //        log4net.LogHelper.WriteError(GetType(), new Exception(log.remark));
            //        tran.Add(BuildAddSql(log));
            //        if (istran) return true;
            //        return ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray);
            //    }
            //    log.agentId = fagent.id;
            //    log.beforeMoney = fagent.cash;
            //    log.afterMoney = fagent.cash + money;
            //    C_UserInfo fuserInfo = C_UserInfoBLL.SingleModel.GetModel(agent.fuserId);
            //    if (fuserInfo == null)
            //    {
            //        log.remark = $"代理付费日志出错:找不到上级代理用户信息 userid:{agent.fuserId}";
            //        log4net.LogHelper.WriteError(GetType(), new Exception(log.remark));
            //        tran.Add(BuildAddSql(log));
            //        if (istran) return true;
            //        return ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray);
            //    }
            //    log.remark += $",{fuserInfo.NickName}获得提成{log.incomeStr}元";
            //}
            //tran.Add(BuildAddSql(log));

            #region   级分提成日志
            //if (grandfatherAgent != null && platform.FirstExtract > 0 && platform.SecondExtract > 0 && (platform.FirstExtract + platform.SecondExtract) <= 1000)
            //{
            //    //表示有上上级 记录分给上上级提成日志

            //    int grandfatherAgentMoney = Convert.ToInt32(pinOrder.money * Percent * platform.SecondExtract * 0.001);
            //    PinAgentIncomeLog grandfatherAgentLog = new PinAgentIncomeLog()
            //    {
            //        aId = grandfatherAgent.aId,
            //        userId = grandfatherAgent.userId,
            //        sourceUid = agent.userId,
            //        income = grandfatherAgentMoney,
            //        source = 0,
            //        ExtractType = 1
            //    };

            //    grandfatherAgentLog.agentId = grandfatherAgent.id;
            //    grandfatherAgentLog.beforeMoney = grandfatherAgent.cash;
            //    grandfatherAgentLog.afterMoney = grandfatherAgent.cash + grandfatherAgentMoney;

            //    C_UserInfo gfuserInfo = C_UserInfoBLL.SingleModel.GetModel(grandfatherAgent.userId);
            //    if (gfuserInfo == null)
            //    {
            //        grandfatherAgentLog.remark = $"代理付费日志出错:找不到上上级代理用户信息 userid:{grandfatherAgent.userId}";
            //        log4net.LogHelper.WriteError(GetType(), new Exception(grandfatherAgentLog.remark));
            //        tran.Add(BuildAddSql(grandfatherAgentLog));
            //        if (istran) return true;
            //        return ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray);
            //    }
            //    grandfatherAgentLog.remark += $",{gfuserInfo.NickName}获得提成{grandfatherAgentLog.incomeStr}元";
            //    grandfatherAgentLog.remark += $"{userInfo.NickName} 成为代理(下下级)";
            //    tran.Add(BuildAddSql(grandfatherAgentLog));

            //}

            #endregion
            #endregion


            PinAgentLevelConfig agentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(agent.AgentLevel, agent.aId);
            if (agentLevelConfig == null)
            {
                log4net.LogHelper.WriteInfo(GetType(), $"代理提成log错误:当前入驻代理商{agent.id}等级找不到");
                return(false);
            }

            PinAgent fagent = PinAgentBLL.SingleModel.GetModelByUserId(agent.fuserId);
            if (fagent == null)
            {
                log4net.LogHelper.WriteInfo(GetType(), $"代理提成log错误:找不到上级代理信息 userid:{agent.fuserId}");
                return(false);
            }

            //查找该代理上级所属等级 根据所属等级进行不同比例分成

            PinAgentLevelConfig fagentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(fagent.AgentLevel, fagent.aId);
            if (fagentLevelConfig == null)
            {
                log4net.LogHelper.WriteInfo(GetType(), $"代理提log成错误:上级代理商{fagent.id}等级找不到");
                return(false);
            }

            int percent = fagentLevelConfig.AgentExtract;
            if (agentLevelConfig.LevelId > fagentLevelConfig.LevelId)
            {
                //表示当前代理商级别高于所属上级代理商级别则按越级比例分配给上级
                percent = platform.JumpExtract;
            }

            int money = pinOrder.money * percent;

            PinAgentIncomeLog fAgengLog = new PinAgentIncomeLog()
            {
                aId         = agent.aId,
                userId      = agent.fuserId,
                sourceUid   = agent.userId,
                income      = money,
                source      = 0,
                agentId     = fagent.id,
                beforeMoney = fagent.cash,
                afterMoney  = fagent.cash + money
            };
            C_UserInfo agentUserInfo = C_UserInfoBLL.SingleModel.GetModel(agent.userId);
            if (agentUserInfo == null)
            {
                fAgengLog.remark = $"代理付费日志出错:找不到代理用户信息 userid:{agent.userId}";
                log4net.LogHelper.WriteInfo(GetType(), fAgengLog.remark);
                tran.Add(BuildAddSql(fAgengLog));
                if (istran)
                {
                    return(true);
                }
                return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray));
            }
            fAgengLog.remark = $"{agentUserInfo.NickName}成为{agentLevelConfig.LevelName}代理";

            C_UserInfo fuserInfo = C_UserInfoBLL.SingleModel.GetModel(agent.fuserId);
            if (fuserInfo == null)
            {
                fAgengLog.remark = $"代理付费日志出错:找不到上级代理用户信息 userid:{agent.fuserId}";
                log4net.LogHelper.WriteInfo(GetType(), fAgengLog.remark);
                tran.Add(BuildAddSql(fAgengLog));
                if (istran)
                {
                    return(true);
                }
                return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray));
            }
            fAgengLog.remark += $",{fuserInfo.NickName}获得提成{fAgengLog.incomeStr}元";
            tran.Add(BuildAddSql(fAgengLog));

            #region   级分提成日志
            PinAgent grandfatherAgent = PinAgentBLL.SingleModel.GetModelByUserId(fagent.fuserId);

            if (grandfatherAgent != null)
            {
                //表示有上上级 记录分给上上级提成日志

                PinAgentLevelConfig gfagentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(grandfatherAgent.AgentLevel, grandfatherAgent.aId);
                if (fagentLevelConfig == null || gfagentLevelConfig.SecondAgentExtract <= 0 || (gfagentLevelConfig.AgentExtract + gfagentLevelConfig.SecondAgentExtract) > 1000)
                {
                    log4net.LogHelper.WriteInfo(GetType(), $"上上级代理提成错误:上上级代理商{grandfatherAgent.id}等级找不到或者比例不能分成");
                    return(istran);
                }

                int grandfatherAgentMoney             = pinOrder.money * gfagentLevelConfig.SecondAgentExtract;
                PinAgentIncomeLog grandfatherAgentLog = new PinAgentIncomeLog()
                {
                    aId         = grandfatherAgent.aId,
                    userId      = grandfatherAgent.userId,
                    sourceUid   = agent.userId,
                    income      = grandfatherAgentMoney,
                    source      = 0,
                    ExtractType = 1,
                    agentId     = grandfatherAgent.id,
                    beforeMoney = grandfatherAgent.cash,
                    afterMoney  = grandfatherAgent.cash + grandfatherAgentMoney
                };


                C_UserInfo gfuserInfo = C_UserInfoBLL.SingleModel.GetModel(grandfatherAgent.userId);
                if (gfuserInfo == null)
                {
                    grandfatherAgentLog.remark = $"代理付费日志出错:找不到上上级代理用户信息 userid:{grandfatherAgent.userId}";
                    log4net.LogHelper.WriteError(GetType(), new Exception(grandfatherAgentLog.remark));
                    tran.Add(BuildAddSql(grandfatherAgentLog));
                    if (istran)
                    {
                        return(true);
                    }
                    return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray));
                }
                grandfatherAgentLog.remark += $",{gfuserInfo.NickName}获得提成{grandfatherAgentLog.incomeStr}元";
                grandfatherAgentLog.remark += $"{fuserInfo.NickName} 成为代理(下下级)";
                tran.Add(BuildAddSql(grandfatherAgentLog));
            }

            #endregion


            if (istran)
            {
                return(true);
            }
            return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray));
        }