Пример #1
0
        /// <summary>
        /// 获取专业版各个版本的价格
        /// </summary>
        /// <param name="agentid"></param>
        /// <param name="templateType"></param>
        /// <param name="tid"></param>
        /// <param name="versionId"></param>
        /// <returns></returns>
        public FunctionList GetModelBytid(int agentid, int templateType, int tid, int versionId)
        {
            FunctionList      model = base.GetModel($"TemplateType={templateType} and VersionId={versionId}");
            Xcxtemplate_Price Xcxtemplate_Pricemodel = Xcxtemplate_PriceBLL.SingleModel.GetModelByAgentIdAndTid(agentid, tid, versionId);

            if (Xcxtemplate_Pricemodel != null)
            {
                model.Price = Xcxtemplate_Pricemodel.price;
            }

            return(model);
        }
Пример #2
0
        /// <summary>
        /// 获取专业版里的版本代理商自定义价格
        /// </summary>
        /// <param name="TemplateType"></param>
        /// <param name="agentid"></param>
        /// <returns></returns>
        public List <VersionType> GetRealPriceVersionTemplateList(int TemplateType, int agentid, int agenttype = 0)
        {
            List <VersionType> listVersionType = FunctionListBLL.SingleModel.GetVersionTypeList(TemplateType, agenttype);
            List <VersionType> list            = new List <VersionType>();
            int         tid         = 0;
            XcxTemplate xcxTemplate = base.GetModel($"Type={TemplateType}");

            if (xcxTemplate != null)
            {
                tid = xcxTemplate.Id;
            }
            if (listVersionType != null && listVersionType.Count > 0)
            {
                foreach (var item in listVersionType)
                {
                    Xcxtemplate_Price template_Price = Xcxtemplate_PriceBLL.SingleModel.GetModel($"tid={tid} and agentid='{agentid}' and state=0 and VersionId={item.VersionId}");

                    if (template_Price != null)
                    {
                        if (template_Price.price > 0 || item.VersionId == 3)
                        {
                            list.Add(new
                                     VersionType
                            {
                                VersionId    = item.VersionId,
                                VersionName  = item.VersionName,
                                VersionPrice = template_Price.price.ToString(),
                                LimitCount   = template_Price.LimitCount
                            });
                        }
                        else
                        {
                            list.Add(item);
                        }
                    }
                    else
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Пример #3
0
        public List <XcxTemplate> GetRealPriceTemplateList(string sqlwhere, int agentid)
        {
            List <XcxTemplate> templateList = GetList(sqlwhere, 2000, 1, "", "sort asc");
            List <XcxTemplate> list         = null;

            if (templateList != null && templateList.Count > 0)
            {
                list = new List <XcxTemplate>();
                foreach (XcxTemplate xcxmodel in templateList)
                {
                    Xcxtemplate_Price template_Price = Xcxtemplate_PriceBLL.SingleModel.GetModel($"tid={xcxmodel.Id} and agentid='{agentid}' and state>=0");
                    if (template_Price != null)
                    {
                        if (xcxmodel.Type == (int)TmpType.小未平台子模版)
                        {
                            //自定义代理开通模板价格
                            xcxmodel.Price = template_Price.price >= 0 ? template_Price.price : xcxmodel.Price;
                        }
                        else
                        {
                            //自定义代理开通模板价格
                            xcxmodel.Price = template_Price.price > 0 ? template_Price.price : xcxmodel.Price;
                        }
                        //自定义代理开通多门店模板增加分店价格
                        xcxmodel.SPrice = template_Price.SPrice > 0 ? template_Price.SPrice : xcxmodel.SPrice;
                        //自定义代理开通模板价格
                        xcxmodel.SCount = template_Price.SCount > 0 ? template_Price.SCount : xcxmodel.SCount;
                        //免费版限制开通数量
                        if (xcxmodel.Price <= 0)
                        {
                            xcxmodel.LimitCount = template_Price.LimitCount <= 0 ? 1000 : template_Price.LimitCount;
                        }
                    }

                    list.Add(xcxmodel);
                }
            }
            return(list);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }