コード例 #1
0
        /// <summary>
        /// 核单
        /// </summary>
        /// <param name="entity">主键值</param>
        /// <param name="State">状态:1-启动;0-禁用</param>
        public string UpdateCheckState(TelphoneLiangJoinEntity entity, int State)
        {
            //获取0级机构id
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            if (OperatorProvider.Provider.Current().Account != "System")
            {
                var checkEntity = db.FindEntity <OrganizeEntity>(t => t.OuterPhone == entity.Telphone);
                if (checkEntity != null)
                {
                    return("该申请人的手机号已经通过审核,请刷新机构列表查看!");
                }

                var parentOrg0 = orgService.GetParentIdByOrgId(OperatorProvider.Provider.Current().CompanyId);//获得当前机构的所属0级机构
                if (!string.IsNullOrEmpty(parentOrg0.First().OrganizeId))
                {
                    string parentOrg = parentOrg0.First().OrganizeId;
                    //获取0级vip表
                    var vipEntity = db.FindEntity <TelphoneLiangVipEntity>(t => t.OrganizeId == parentOrg && t.VipEndDate > DateTime.Now);
                    if (vipEntity == null)
                    {
                        return("平台机构未开放【申请加盟】功能!");
                    }
                    else
                    {
                        int?      orgMax         = vipEntity.OrgMax;
                        DataTable dt             = orgService.GetOrgCount(parentOrg0.First().OrganizeId);//获取0级机构数量
                        int       parentOrgCount = Convert.ToInt32(dt.Rows[0][0].ToString());
                        //如果0级机构,超过了设置的机构上限
                        if (parentOrgCount > orgMax)
                        {
                            return("平台机构已超过上限,请联系上级增加机构容量!");
                        }
                    }
                }
            }

            if (State == 2)
            {
                entity.OrganizeId = "e21c39be-da56-4f1c-9120-a0926a520947";//修改审核机构为我
            }

            //判断2,3级数量是个超限

            //生成靓号商场平台
            OrganizeEntity orgEntity = new OrganizeEntity()
            {
                ParentId   = entity.OrganizeId,
                FullName   = entity.CompanyName,
                ShortName  = entity.NickName,
                OuterPhone = entity.Telphone,
                InnerPhone = entity.WxAccount, //微信账号
                Nature     = entity.WxQRcode,  //微信二维码
                ManagerId  = entity.OpenId,
                Manager    = entity.FullName,
                Layer      = 1,
                DeleteMark = 0
            };
            OrganizeEntity newEntity = orgService.SaveReturnEntity(orgEntity);

            //更新申请状态
            TelphoneLiangJoinEntity reserveEntity = new TelphoneLiangJoinEntity();

            reserveEntity.Modify(entity.Id);
            reserveEntity.CheckMark  = State;
            reserveEntity.OrganizeId = entity.OrganizeId;//审核机构为我
            this.BaseRepository().Update(reserveEntity);


            //发送通过短信
            if (!string.IsNullOrEmpty(newEntity.Description))
            {
                SmsSingleSenderResult singleResult;
                SmsSingleSender       singleSender = new SmsSingleSender(1400040861, "a92c87d0d291698777a9b5f323c0388a");
                List <string>         templParams  = new List <string>();
                templParams.Add(entity.FullName);
                templParams.Add(newEntity.Description);
                //成功
                singleResult = singleSender.SendWithParam("86", entity.Telphone, 205617, templParams, "", "", "");
            }

            return($"已通过短信的方式通知了你的下级,其靓号商城为:{newEntity.Description}");
        }