/// <summary> /// 合作伙伴注册 /// </summary> /// <param name="openid">openid</param> /// <param name="comName">公司名称</param> /// <param name="type">类型(经销商,供应商)</param> /// <param name="realname">真实姓名</param> /// <param name="address">公司地址</param> /// <param name="comPhone">公司电话</param> /// <param name="email">电子邮件</param> /// <param name="salesmanId">对应的销售id</param> /// <param name="files">相关资质图片字符串,格式为文件 名称1 :mediaid; eg:经营许可证:000001;组织机构代码:000005;</param> /// <param name="discrictid">区域id</param> /// <param name="money">加盟资金</param> /// <param name="sex">性别</param> /// <returns></returns> public Partner ReginPartner(string openid, string comName, PartnerType type, string realname, string address, string comPhone, int?salesmanId, string email, string files, int?discrictid, Sex sex, string money) { var db = new ModelContext(); var usr = WechatHelper.CheckOpenid(openid); usr = WechatHelper.CheckUser(usr); if (usr.UserInfoId == null || usr.UserInfoId == 0 || usr.UserInfo == null) { return(null); } // 将用户信息中的姓名更新 usr.UserInfo.Name = realname; var pat = new Partner { RealName = realname, Address = address, CompanyName = comName, CreateDate = DateTime.Now, UserId = usr.UserInfoId, CompanyPhone = comPhone, Point = 0, Type = type, Email = email, SalesmanId = salesmanId, DistrictId = discrictid, Status = PartnerStatus.Apply, Sex = sex, Money = money, }; db.PartnerSet.Add(pat); db.SaveChanges(); db.WechatUserSet.Find(usr.WechatUserId).PartnerId = pat.PartnerId; db.SaveChanges(); //下载文件 var filestrList = files.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); var fileDic = new Dictionary <string, string>(); foreach (var filestr in filestrList) { var fileinfo = filestr.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (fileinfo.Length == 2) { fileDic.Add(fileinfo[0], fileinfo[1]); } } if (fileDic != null && fileDic.Count > 0) { WechatImageHelper.AddNewImageForPartner(fileDic, pat.PartnerId, openid); } LogHelper.AddLog("Regist as a patner.", pat.PartnerId.ToString(), openid); return(pat); }
/// <summary> /// 添加相关资质 /// </summary> /// <param name="mediaDic">key为文件名,value为mediaId</param> /// <returns></returns> public Partner AddFile(int partnerId, Dictionary <string, string> mediaDic, string openid) { var db = new ModelContext(); var par = db.PartnerSet.FirstOrDefault(item => item.PartnerId == partnerId); if (par == null) { return(null); } WechatImageHelper.AddNewImageForPartner(mediaDic, partnerId, openid); return(par); }
/// <summary> /// 完成处理 /// </summary> /// <param name="repairId">报修记录id</param> /// <param name="mediaIdList">meidia Id列表</param> /// <param name="describe">文字描述</param> /// <param name="type">完成类型</param> /// <returns></returns> public Repair FinishHandlen(int repairId, IEnumerable <string> mediaIdList, string describe, RepairFinishType type) { var db = new ModelContext(); var rep = db.RepairSet.Include("Village").FirstOrDefault(item => item.RepairId == repairId); if (rep == null) { return(null); } rep.Status = RepairStatus.FinishHandle; rep.FinishHandlendDate = DateTime.Now; rep.FinishType = type; rep.Describe = describe; db.SaveChanges(); var cl = WechatImageHelper.AddNewImageForHandleRepair(rep.RepairId, mediaIdList).ToList(); cl.Clear(); //发送模板消息 string content = rep.Contenet.Replace("<br />", "").Length > 7 ? rep.Contenet.Replace("<br />", "").Substring(0, 6) + "..." : rep.Contenet.Replace("<br />", ""); var wuser = WechatHelper.CheckWechatUser(rep.UserId ?? 0); if (wuser != null && !string.IsNullOrEmpty(wuser.OpenId)) { string url = string.Format("http://mp.doshine.com/doshinemp/PhoneWeb/RepairDetails?repairid={0}", rep.RepairId); WechatHelper.SendModelMessage( wuser.OpenId, url, "bI7o_XjdW10WRf1gPvmEpddVmBahfh97Irgv4u-__Gc", string.Format("\"first\":{{\"value\":\"您好,您的报修申请已完成处理\",\"color\":\"#000000\"}},\"keyword1\":{{\"value\":\"{0}\",\"color\":\"#173177\"}},\"keyword2\":{{\"value\":\"{1}\",\"color\":\"#173177\"}},\"remark\":{{\"value\":\"保修内容:{3}\\n处理结果:{2}\",\"color\":\"#000000\"}}", rep.InnerNumber, rep.FinishHandlendDate.Value.ToLongDateString() + " " + rep.FinishHandlendDate.Value.ToShortTimeString(), EnumFormat.GetDescription(rep.FinishType), content)); } return(rep); }
/// <summary> /// 提交一个新的报修申请 /// </summary> /// <param name="openid">用户openid</param> /// <param name="content"></param> /// <param name="mediaidList">图片列表,用逗号分割</param> /// <returns></returns> public Repair Add(string openid, string content, string mediaidList, string phone, int villageid, string name, int recordid) { var db = new ModelContext(); var usr = WechatHelper.CheckOpenid(openid); usr = WechatHelper.CheckUser(usr); if (usr.UserInfoId == null || usr.UserInfoId == 0 || usr.UserInfo == null) { return(null); } var mediaIdArr = mediaidList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var number = GetNewInnerNumber(); var rep = new Repair { Contenet = content, CreateDate = DateTime.Now, Status = RepairStatus.Apply, UserId = usr.UserInfoId, InnerNumber = number, PhoneNumber = phone, VillageId = villageid, Name = name, }; db.RepairSet.Add(rep); db.SaveChanges(); //下载文件 //单个 //if (!string.IsNullOrEmpty(mediaid)) //{ // WechatImageHelper.AddNewImageForRepair(mediaid, rep.RepairId, openid); //} //多个 if (mediaIdArr != null && mediaIdArr.Length > 0) { List <ImageDownloadLog> md = WechatImageHelper.AddNewImageForRepair(mediaIdArr, rep.RepairId, openid).ToList(); md.Clear(); } LogHelper.AddLog("Apply a new repair", rep.RepairId.ToString(), openid); db.SaveChanges(); var vill = db.VillageSet.Find(villageid); RecordHelper.UpdateRecord(recordid, openid, RecordType.MpRepair, phone, name, vill.Name); //发送企业号通知 var workernamArr = System.Configuration.ConfigurationManager.AppSettings["repairworkers"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string scontent = rep.Contenet.Replace("<br />", ",").Length > 7 ? rep.Contenet.Replace("<br />", ",").Substring(0, 6) + "..." : rep.Contenet.Replace("<br />", ","); var msg = $"收到新的报修申请,请尽快处理!\n报修单位:{rep.Village?.Name}\n报修人:{rep.Name}\n联系方式:{rep.PhoneNumber}\n报修内容:{scontent}\n报修时间:{rep.CreateDate.ToString("yyyy-MM-dd hh:mm")}\n\n<a href=\\\"http://mp.doshine.com/DoShineMP/PhoneWeb/RepairDetailsInterior?repairid={rep.RepairId}\\\">点击查看</a>"; WechatHelper.SendComponyMessage(workernamArr, msg); return(rep); }