private void SendMessage(string Number, string U_Number, string CurrMoney, string result, string Money, string time) { var usermodel = database.FindEntity <Ho_PartnerUser>(U_Number); var first = new First() { color = "#000000", value = usermodel.Name + ",您电费缴费" + result }; var keynote1 = new Keynote1() { color = "#0000ff", value = Money + "元" }; var keynote2 = new Keynote2() { color = "#0000ff", value = time }; var keynote3 = new Keynote3() { color = "#0000ff", value = CurrMoney + "元" }; //var keynote4 = new Keynote4() //{ // color = "#0000ff", // value = rent.CreateTime.Value.ToString("yyyy年MM月dd日") //}; //var keynote5 = new Keynote5() //{ // color = "#0000ff", // value = "已派师傅:" + wxuser.Name + " " + wxuser.Mobile //}; Weixin.Mp.Sdk.Domain.Remark remark = new Remark(); remark.color = "#464646"; remark.value = result == "成功" ? "感谢您的使用。" : "费用已经退回您的余额,稍后重新尝试!"; Weixin.Mp.Sdk.Domain.Data data = new Data(); data.first = first; data.keynote1 = keynote1; data.keynote2 = keynote2; data.keynote3 = keynote3; //data.keynote4 = keynote4; //data.keynote5 = keynote5; data.remark = remark; Weixin.Mp.Sdk.Domain.Miniprogram miniprogram = new Miniprogram(); miniprogram.appid = ""; miniprogram.pagepath = ""; Weixin.Mp.Sdk.Domain.TemplateMessage templateMessage = new TemplateMessage(); templateMessage.AppId = ConfigHelper.AppSettings("WEPAY_WEB_APPID"); templateMessage.AppSecret = ConfigHelper.AppSettings("WEPAY_WEb_AppSecret"); templateMessage.data = data; templateMessage.miniprogram = miniprogram; templateMessage.template_id = "LvmnXS1GVISLKU0sg3bmRq78G7xHq6BiQvOTr5i2a4Y"; templateMessage.touser = usermodel.OpenId; templateMessage.url = "http://am.zst0771.com/Personal/AmmeterPayCost?number=" + Number; templateMessage.SendTemplateMessage(); }
/// <summary> /// 账单推送 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BillSendTimerdEvent(object sender, System.Timers.ElapsedEventArgs e) { BillSendTimer.Stop(); var config = database.FindEntityByWhere <Fx_WebConfig>(""); if (config != null && config.SendBillDate.Value > 0) { var time = DateTime.Now.AddDays(config.SendBillDate.Value); List <DbParameter> par = new List <DbParameter>(); par.Add(DbFactory.CreateDbParameter("@time", time)); par.Add(DbFactory.CreateDbParameter("@Status", "0")); var billList = database.FindList <Am_Bill>(" and BeginTime<=@time and Status=@Status ", par.ToArray()); foreach (var item in billList) { item.Status = 1; item.StatusStr = "未支付"; item.SendTime = DateTime.Now; if (database.Update <Am_Bill>(item) > 0) { //账单推送 IMpClient mpClient = new MpClient(); AccessTokenGetRequest request = new AccessTokenGetRequest() { AppIdInfo = new AppIdInfo() { AppID = ConfigHelper.AppSettings("WEPAY_WEB_APPID"), AppSecret = ConfigHelper.AppSettings("WEPAY_WEb_AppSecret") } }; AccessTokenGetResponse response = mpClient.Execute(request); if (response.IsError) { continue; } Weixin.Mp.Sdk.Domain.First first = new First(); first.color = "#000000"; first.value = item.T_U_Name + ",您本月的账单已生成"; Weixin.Mp.Sdk.Domain.Keynote1 keynote1 = new Keynote1(); keynote1.color = "#0000ff"; keynote1.value = item.Address + " " + item.Cell + "单元" + item.Floor + "楼" + item.Room + "号"; Weixin.Mp.Sdk.Domain.Keynote2 keynote2 = new Keynote2(); keynote2.color = "#0000ff"; keynote2.value = item.BeginTime.Value.ToString("yyyy-MM-dd") + "至" + item.EndTime.Value.ToString("yyyy-MM-dd"); Weixin.Mp.Sdk.Domain.Keynote3 keynote3 = new Keynote3(); keynote3.color = "#0000ff"; keynote3.value = item.Money.Value.ToString("0.00"); //Weixin.Mp.Sdk.Domain.Keynote4 keynote4 = new Keynote4(); //keynote4.color = "#0000ff"; //keynote4.value = model.s_Reception + " " + model.s_ReMobile; Weixin.Mp.Sdk.Domain.Remark remark = new Remark(); remark.color = "#464646"; remark.value = "请在" + config.SendBillDate.Value.ToString() + "天之内在线支付账单!"; Weixin.Mp.Sdk.Domain.Data data = new Data(); data.first = first; data.keynote1 = keynote1; data.keynote2 = keynote2; data.keynote3 = keynote3; //data.keynote4 = keynote4; data.remark = remark; Weixin.Mp.Sdk.Domain.Miniprogram miniprogram = new Miniprogram(); miniprogram.appid = ""; miniprogram.pagepath = ""; Weixin.Mp.Sdk.Domain.TemplateMessage templateMessage = new TemplateMessage(); templateMessage.data = data; templateMessage.miniprogram = miniprogram; templateMessage.template_id = "d0NDpmuQ7BjtlxPurNTr9N1GlATOAQ98S8vrmgAijH8"; var usermodel = database.FindEntity <Ho_PartnerUser>(item.T_U_Number); templateMessage.touser = usermodel.OpenId; templateMessage.url = "http://am.zst0771.com/Personal/NewBillDetails?Number=" + item.Number; string postData = templateMessage.ToJsonString1(); /*JsonHelper.ToJson(templateMessage);*/ AppIdInfo app = new AppIdInfo() { AppID = ConfigHelper.AppSettings("WEPAY_WEB_APPID"), AppSecret = ConfigHelper.AppSettings("WEPAY_WEb_AppSecret"), CallBack = "" }; SendTemplateMessageRequest req = new SendTemplateMessageRequest() { AccessToken = response.AccessToken.AccessToken, SendData = postData, AppIdInfo = app }; SendTemplateMessageResponse res = mpClient.Execute(req); if (res.IsError) { continue; } } } } BillSendTimer.Start(); }
public ActionResult SubmitUserForm(string KeyValue, string Number, Ho_SetSubscribe model, string BuildFormJson) { IDatabase database = DataFactory.Database(); DbTransaction isOpenTrans = database.BeginTrans(); try { //获取订单信息-订单和接单安排分离 var oldModel = database.FindEntity <Ho_MySubscribe>(Number); if (oldModel == null) { return(Content(new JsonMessage { Success = false, Code = "-1", Message = "预约不存在" }.ToString())); } string Message = KeyValue == "" ? "新增成功。" : "编辑成功。"; model.s_StatuStr = model.s_Status == 0 ? "正常" : "做废"; model.ReUserNumber = ManageProvider.Provider.Current().UserId; model.ReUser = ManageProvider.Provider.Current().Account; if (!string.IsNullOrEmpty(KeyValue)) { model.Modify(KeyValue); var IsOk = database.Update(model, isOpenTrans); //更新订单状态为已安排 if (IsOk > 0 && model.s_Status == 0) { oldModel.Status = 1; oldModel.StatusStr = "接待中"; oldModel.Modify(oldModel.Number); database.Update(oldModel, isOpenTrans); } Base_SysLogBll.Instance.WriteLog(KeyValue, OperationType.Update, IsOk > 0 ? "成功" : "失败", "预约接待安排更改"); } else //新建 { model.MS_Number = oldModel.Number; model.Create(); var IsOk = database.Insert(model, isOpenTrans); //更新订单状态为已安排 if (IsOk > 0 && model.s_Status == 0) { oldModel.Status = 1; oldModel.StatusStr = "接待中"; oldModel.Modify(oldModel.Number); database.Update(oldModel, isOpenTrans); } Base_SysLogBll.Instance.WriteLog(KeyValue, OperationType.Update, IsOk > 0 ? "成功" : "失败", "预约接待安排增加"); } database.Commit(); //发送微信通知 IMpClient mpClient = new MpClient(); AccessTokenGetRequest request = new AccessTokenGetRequest() { AppIdInfo = new AppIdInfo() { AppID = ConfigHelper.AppSettings("AppID"), AppSecret = ConfigHelper.AppSettings("AppSecret") } }; AccessTokenGetResponse response = mpClient.Execute(request); if (response.IsError) { Message += ":微信消息发送不成功-" + response.ErrInfo; return(Content(new JsonMessage { Success = true, Code = "1", Message = Message }.ToString())); } Weixin.Mp.Sdk.Domain.First first = new First(); first.color = "#000000"; first.value = "您预约的看房已安排"; Weixin.Mp.Sdk.Domain.Keynote1 keynote1 = new Keynote1(); keynote1.color = "#0000ff"; keynote1.value = model.s_MYTime; Weixin.Mp.Sdk.Domain.Keynote2 keynote2 = new Keynote2(); keynote2.color = "#0000ff"; keynote2.value = model.s_Address; Weixin.Mp.Sdk.Domain.Keynote3 keynote3 = new Keynote3(); keynote3.color = "#0000ff"; keynote3.value = oldModel.HName; Weixin.Mp.Sdk.Domain.Keynote4 keynote4 = new Keynote4(); keynote4.color = "#0000ff"; keynote4.value = model.s_Reception + " " + model.s_ReMobile; Weixin.Mp.Sdk.Domain.Remark remark = new Remark(); remark.color = "#464646"; remark.value = "您有任何疑问随时联系ta"; Weixin.Mp.Sdk.Domain.Data data = new Data(); data.first = first; data.keynote1 = keynote1; data.keynote2 = keynote2; data.keynote3 = keynote3; data.keynote4 = keynote4; data.remark = remark; Weixin.Mp.Sdk.Domain.Miniprogram miniprogram = new Miniprogram(); miniprogram.appid = ""; miniprogram.pagepath = ""; Weixin.Mp.Sdk.Domain.TemplateMessage templateMessage = new TemplateMessage(); templateMessage.data = data; templateMessage.miniprogram = miniprogram; templateMessage.template_id = "nak4v_a9vwzdL9QMWv-Fl3ommOdN7kEORQ1X2BRJrCo"; var usermodel = database.FindEntity <Ho_PartnerUser>(oldModel.UNumber); templateMessage.touser = usermodel.OpenId; templateMessage.url = "http://house.pthl600.com/Ui/Industry?Number=" + oldModel.MHNumber; string postData = templateMessage.ToJsonString(); /*JsonHelper.ToJson(templateMessage);*/ AppIdInfo app = new AppIdInfo() { AppID = ConfigHelper.AppSettings("AppID"), AppSecret = ConfigHelper.AppSettings("AppSecret"), CallBack = "" }; SendTemplateMessageRequest req = new SendTemplateMessageRequest() { AccessToken = response.AccessToken.AccessToken, SendData = postData, AppIdInfo = app }; SendTemplateMessageResponse res = mpClient.Execute(req); if (res.IsError) { Message += ":微信消息发送失败-" + response.ErrInfo; return(Content(new JsonMessage { Success = true, Code = "1", Message = Message }.ToString())); } return(Content(new JsonMessage { Success = true, Code = "1", Message = Message }.ToString())); } catch (Exception ex) { database.Rollback(); return(Content(new JsonMessage { Success = false, Code = "-1", Message = "操作失败:" + ex.Message }.ToString())); } }
public ActionResult SubContract(Am_Contract contract, List <Am_ContractImage> itemList) { List <DbParameter> parameter = new List <DbParameter>(); parameter.Add(DbFactory.CreateDbParameter("@Number", contract.AmmeterNumber)); var ammeter = database.FindEntityByWhere <Am_Ammeter>(" and Number=@Number ", parameter.ToArray()); if (ammeter != null && ammeter.Number != null) { List <DbParameter> par1 = new List <DbParameter>(); par1.Add(DbFactory.CreateDbParameter("@AmmeterNumber", contract.AmmeterNumber)); var contractTemplate = database.FindEntityByWhere <Am_ContractTemplate>(" and AmmeterNumber=@AmmeterNumber ", par1.ToArray()); var newTemplate = new Am_ContractTemplate(); if (contractTemplate != null && contractTemplate.Number != null) { newTemplate = new Am_ContractTemplate { Number = contractTemplate.Number, Address = contract.Address, AmmeterCode = contractTemplate.AmmeterCode, AmmeterNumber = contractTemplate.AmmeterNumber, Am_Money = contract.Am_Money, BackMoney = contract.BackMoney, BackTime = contract.BackTime, BankCode = contract.BankCode, BankInfo = contract.BankInfo, BankUserName = contract.BankUserName, Cell = contract.Cell, City = contract.City, ContractPaht = contractTemplate.ContractPaht, County = contract.County, CreateTime = contract.CreateTime, CycleTime = contract.CycleTime, DepositMoney = contract.DepositMoney, DepositMoneyStr = contract.DepositMoneyStr, Floor = contract.Floor, GarbageMoney = contract.GarbageMoney, GoMoney = contract.GoMoney, GoOnTime = contract.GoOnTime, GoTime = contract.GoTime, HallNum = contract.HallNum, HoName = contract.HoName, HoUserMobile = contract.HoUserMobile, HoUserName = contract.HoUserName, HouseSize = contract.HouseSize, KitchenNum = contract.KitchenNum, Money = contract.Money, MoneyStr = contract.MoneyStr, NetMoney = contract.NetMoney, PenaltyMoney = contract.PenaltyMoney, PenaltyTime = contract.PenaltyTime, PropertyMoeny = contract.PropertyMoeny, Province = contract.Province, Remark = contract.Remark, RentMoneyTime = contract.RentMoneyTime, Room = contract.Room, RoomNum = contract.RoomNum, ToiletNum = contract.ToiletNum, TotalMoney = contract.TotalMoney, TotalMoneyStr = contract.TotalMoneyStr, Useing = contract.Useing, UseingSize = contract.UseingSize, UserName = ammeter.UserName, U_Name = ammeter.U_Name, U_Number = ammeter.U_Number, WaterMoney = contract.WaterMoney }; database.Update <Am_ContractTemplate>(newTemplate); } else { newTemplate = new Am_ContractTemplate { Number = CommonHelper.GetGuid, Address = contract.Address, AmmeterCode = ammeter.AM_Code, AmmeterNumber = ammeter.Number, Am_Money = contract.Am_Money, BackMoney = contract.BackMoney, BackTime = contract.BackTime, BankCode = contract.BankCode, BankInfo = contract.BankInfo, BankUserName = contract.BankUserName, Cell = contract.Cell, City = contract.City, ContractPaht = "", County = contract.County, CreateTime = contract.CreateTime, CycleTime = contract.CycleTime, DepositMoney = contract.DepositMoney, DepositMoneyStr = contract.DepositMoneyStr, Floor = contract.Floor, GarbageMoney = contract.GarbageMoney, GoMoney = contract.GoMoney, GoOnTime = contract.GoOnTime, GoTime = contract.GoTime, HallNum = contract.HallNum, HoName = contract.HoName, HoUserMobile = contract.HoUserMobile, HoUserName = contract.HoUserName, HouseSize = contract.HouseSize, KitchenNum = contract.KitchenNum, Money = contract.Money, MoneyStr = contract.MoneyStr, NetMoney = contract.NetMoney, PenaltyMoney = contract.PenaltyMoney, PenaltyTime = contract.PenaltyTime, PropertyMoeny = contract.PropertyMoeny, Province = contract.Province, Remark = contract.Remark, RentMoneyTime = contract.RentMoneyTime, Room = contract.Room, RoomNum = contract.RoomNum, ToiletNum = contract.ToiletNum, TotalMoney = contract.TotalMoney, TotalMoneyStr = contract.TotalMoneyStr, Useing = contract.Useing, UseingSize = contract.UseingSize, UserName = ammeter.UserName, U_Name = ammeter.U_Name, U_Number = ammeter.U_Number, WaterMoney = contract.WaterMoney }; database.Insert <Am_ContractTemplate>(newTemplate); } //重新生成模板附件 NewContractTemplate(itemList, newTemplate); var contractCount = database.FindCount <Am_Contract>(); var addContract = new Am_Contract { Address = contract.Address, Remark = contract.Remark, AgoDay = contract.AgoDay, AmmeterCode = ammeter.AM_Code, AmmeterNumber = ammeter.Number, Number = CommonHelper.GetGuid, Am_Money = contract.Am_Money, BackMoney = contract.BackMoney, BackTime = contract.BackTime, BankCode = contract.BankCode, BankInfo = contract.BankInfo, BankUserName = contract.BankUserName, Cell = contract.Cell, City = contract.City, ContractCode = DateTime.Now.ToString("yyyyMMdd") + "_" + contract.Cell + "_" + contract.Floor + "_" + contract.Room + "_" + contractCount, Room = contract.Room, Floor = contract.Floor, County = contract.County, CreateAddress = contract.CreateAddress, CreateTime = contract.CreateTime, CycleTime = contract.CycleTime, DepositMoney = contract.DepositMoney, DepositMoneyStr = contract.DepositMoneyStr, F_UserName = ammeter.UY_UserName, F_U_Name = ammeter.UY_Name, F_U_Number = ammeter.UY_Number, GarbageMoney = contract.GarbageMoney, GoMoney = contract.GoMoney, GoOnTime = contract.GoOnTime, GoTime = contract.GoTime, HallNum = contract.HallNum, HoName = contract.HoName, HoUserMobile = contract.HoUserMobile, HoUserName = contract.HoUserName, HouseSize = contract.HouseSize, KitchenNum = contract.KitchenNum, Money = contract.Money, MoneyStr = contract.MoneyStr, NetMoney = contract.NetMoney, PenaltyMoney = contract.PenaltyMoney, PenaltyTime = contract.PenaltyTime, PropertyMoeny = contract.PropertyMoeny, Province = contract.Province, RentBeginTime = contract.RentBeginTime, RentDate = contract.RentDate, RentEndTime = contract.RentEndTime, RentMoneyTime = contract.RentMoneyTime, RoomNum = contract.RoomNum, Status = 0, StatusStr = "待签订", TemplateNumber = newTemplate.Number, ToiletNum = contract.ToiletNum, TotalMoney = contract.TotalMoney, TotalMoneyStr = contract.TotalMoneyStr, UpdateTime = DateTime.Now, Useing = contract.Useing, UseingSize = contract.UseingSize, UserName = ammeter.UserName, U_Code = contract.U_Code, U_Mobile = contract.U_Mobile, U_Name = contract.U_Name, U_Number = ammeter.U_Number, WaterMoney = contract.WaterMoney }; database.Insert <Am_Contract>(addContract); //生成合同附件 NewContract(itemList, addContract.Number); //推送通知用户 var first = new First() { color = "#000000", value = addContract.U_Name + ",您有新的合同待签!" }; var keynote1 = new Keynote1() { color = "#0000ff", value = addContract.ContractCode }; var keynote2 = new Keynote2() { color = "#0000ff", value = addContract.TotalMoney.Value.ToString("0.00") }; var keynote3 = new Keynote3() { color = "#0000ff", value = addContract.Address + addContract.Cell + "单元" + addContract.Floor + "楼" + addContract.Room + "房" }; var keynote4 = new Keynote4() { color = "#0000ff", value = addContract.RentBeginTime.Value.ToString("yyyy-MM-dd") + "至" + addContract.RentEndTime.Value.ToString("yyyy-MM-dd") }; var keynote5 = new Keynote5() { color = "#0000ff", value = addContract.F_U_Name }; Weixin.Mp.Sdk.Domain.Remark remark = new Remark(); remark.color = "#464646"; remark.value = "请尽快完成线上签约。"; Weixin.Mp.Sdk.Domain.Data data = new Data(); data.first = first; data.keynote1 = keynote1; data.keynote2 = keynote2; data.keynote3 = keynote3; data.keynote4 = keynote4; data.keynote5 = keynote5; data.remark = remark; Weixin.Mp.Sdk.Domain.Miniprogram miniprogram = new Miniprogram(); miniprogram.appid = ""; miniprogram.pagepath = ""; Weixin.Mp.Sdk.Domain.TemplateMessage templateMessage = new TemplateMessage(); templateMessage.AppId = ConfigHelper.AppSettings("WEPAY_WEB_APPID"); templateMessage.AppSecret = ConfigHelper.AppSettings("WEPAY_WEb_AppSecret"); templateMessage.data = data; templateMessage.miniprogram = miniprogram; templateMessage.template_id = "hs52Q2SBFc1iEdJrPD9CH3NR6t_IMfYDN-Yg2z6U0ak"; var usermodel = database.FindEntity <Ho_PartnerUser>(addContract.U_Number); templateMessage.touser = usermodel.OpenId; templateMessage.url = "http://am.zst0771.com/Common/Contract?KeyValue=" + addContract.Number; templateMessage.SendTemplateMessage(); return(Json(new { res = "Ok", msg = "提交成功" })); } return(Json(new { res = "No", msg = "提交失败" })); }