/// <summary> /// 个人中心 /// </summary> /// <returns></returns> public ActionResult PersonalCenter(string code) { openid = WechatHelper.GetOpenidByCode(code); //提取我的资料 ViewBag.Title = "个人中心"; return(View()); }
/// <summary> /// 我的主页 /// </summary> /// <returns></returns> public ActionResult HomePage(string code) { openid = WechatHelper.GetOpenidByCode(code); //提取我的资料 ViewBag.Title = "我的主页"; return(View()); }
/// <summary> /// 在线留言父级 /// </summary> /// <param name="code"></param> /// <returns></returns> public ActionResult MessagePartent(string code) { url.urltype = "MessagePartent"; if (!string.IsNullOrEmpty(code)) { if (!string.IsNullOrEmpty(CodeJjudgeByOpenid(code))) { var uuu = wuser.GetUserInfo(this.openid); if (uuu.UserInfo != null) { ViewBag.user = wuser.GetUserInfo(this.openid); ViewBag.openid = this.openid; } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "MessagePartent", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "MessagePartent", "")); } return(View()); }
/// <summary> /// 报修入口 /// </summary> /// <param name="code"></param> /// <returns></returns> public ActionResult RepairEntrance(string code) { try { if (!string.IsNullOrEmpty(code)) { if (!string.IsNullOrEmpty(CodeJjudgeByOpenid(code))) { Response.Redirect(Url.Action("Repair")); } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } } catch (Exception e) { throw; } return(View()); }
/// <summary> /// 经销商中心 /// </summary> /// <param name="code"></param> /// <returns></returns> public ActionResult Partner(string code) { Models.WechatUser user = new Models.WechatUser(); if (!string.IsNullOrEmpty(code)) { if (!string.IsNullOrEmpty(CodeJjudgeByOpenid(code))) { user = partner.GetPartnerInfo(this.openid); if (user == null) { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "PersonalCenter", "")); } else { ViewBag.wuser = user; } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Partner", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Partner", "")); } ViewBag.Title = "经销商中心"; return(View()); }
/// <summary> /// 个人详细信息页面 /// </summary> /// <param name="code"></param> /// <returns></returns> public ActionResult MyMessage(string code) { Models.WechatUser user = new Models.WechatUser(); url.urltype = "MyMessage"; if (!string.IsNullOrEmpty(code)) { if (!string.IsNullOrEmpty(CodeJjudgeByOpenid(code))) { user = wuser.GetUserInfo(CodeJjudgeByOpenid(code)); if (user.UserInfo == null) { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } ViewBag.user = user; } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "MyMessage", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "MyMessage", "")); } ViewBag.Title = "个人信息"; return(View()); }
/// <summary> /// 生成随机串,随机串包含字母或数字 /// </summary> /// <returns>随机串</returns> public static string GenerateNonceStr() { //RandomGenerator randomGenerator = new RandomGenerator(); //return randomGenerator.GetRandomUInt().ToString(); //return Guid.NewGuid().ToString().Replace("-", ""); return(WechatHelper.GetNonceStrGuid()); }
/// <summary> /// 个人注册 /// </summary> /// <param name="RealName">姓名</param> /// <param name="PhoneNumber"></param> /// <param name="code"></param> /// <returns></returns> public JsonResult RegisterJson(string RealName, string PhoneNumber, string code) { try { if (!(string.IsNullOrEmpty(RealName) && string.IsNullOrEmpty(PhoneNumber))) { //逻辑代码 if (wuser.Regiet(RealName, PhoneNumber, WechatHelper.GetOpenidByCode(code)) != null) { return(Json(new { msg = "Y" })); } else { return(Json(new { msg = "N" })); } } else { return(Json(new { msg = "N" })); } } catch (Exception e) { return(Json(new { msg = "N" })); } }
/// <summary> /// 我的主页 /// </summary> /// <returns></returns> public ActionResult HomePage(string code) { try { if (!string.IsNullOrEmpty(code)) { if (!string.IsNullOrEmpty(CodeJjudgeByOpenid(code))) { ViewBag.User = wuser.GetUserInfo(this.openid); } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "HomePage", "")); } } catch (Exception) { throw; } //提取我的资料 ViewBag.Title = "我的主页"; return(View()); }
public void TestSendComMessage(int id) { var workernamArr = System.Configuration.ConfigurationManager.AppSettings["repairworkers"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //var msg = "abcdefg1234567890abcdefg1234567890abcdefg1234567890abcdefg1234567890abcdefg1234567890abcdefg1234567890abcdefg1234567890abcdefg1234567890"; var msg = string.Format(System.Configuration.ConfigurationManager.AppSettings["repairnoticemodelforworker"], id.ToString()); WechatHelper.SendComponyMessage(workernamArr, msg); }
public ActionResult SaveForm(string keyValue, TelphoneLiOrderEntity entity) { if (string.IsNullOrEmpty(keyValue)) { //订单提醒 WechatHelper.SendOrder(entity.Telphone, entity.SellerName, entity.Amount.ToString()); WechatHelper.SendToManager(entity.OrderCode, entity.Telphone, entity.SellerName, entity.Amount.ToString()); } telphoneliorderbll.SaveForm(keyValue, entity); return(Success("操作成功。")); }
/// <summary> /// 注册 /// </summary> /// <returns></returns> public ActionResult Register(string code, string userName, string userPhone, string userPwd) { openid = WechatHelper.GetOpenidByCode(code); if (!(string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(userPhone) && string.IsNullOrEmpty(userPwd))) { var WechatUser = wuser.Regiet(userName, userPhone, openid); ViewBag.Text = WechatUser != null ? "添加成功!" : "添加失败!"; } ViewBag.Title = "注册"; return(View()); }
/// <summary> /// 判断是否存在openid缓存,不存在则根据code重新获取一次openid /// </summary> /// <param name="code"></param> /// <returns></returns> private string CodeJjudgeByOpenid(string code) { //this.openid = "olQmIjmqPu9tExxvjfJpNAFV4gJ4"; if (!string.IsNullOrEmpty(this.openid)) { return(this.openid); } else { return(this.openid = WechatHelper.GetOpenidByCode(code)); } }
public JsonResult wxCreatePay(int oid, string remark = null) { OrderDTO model = _iOrderService.Get(oid); model.Shop_id = Session["fxid"].ToInt32(); if (remark != null) { model.Remark = remark;//输入验证? _iOrderService.SaveOrUpdate(model); } //先用商店id当分销id; _iOrderService.ChangeStatus(model, "付款成功"); //string teststr="{\"success\": null }"; //return Json(Message.Success(teststr));//测试用 WechatHelper wechatHelper = new WechatHelper(this.wid); string notifyUrl = "http://ms.571400yb.com/wfxShoping/api/wxNotify"; if (this.OpenId == "oEeLDwVCN9aA66-ghojAh8ptupNQ") { model.Price = 0.01M; } //第一个参数需要修改。 UnifiedOrderResponse uoRes = wechatHelper.CreateUnifiedOrder(title + " 购买商品", notifyUrl, this.OpenId, model.Order_sn, Convert.ToInt32((model.Price) * 100)); if (uoRes.return_code.ToLower() == "SUCCESS".ToLower()) { LogHelper.Info <UserController>("创建订单成功:" + wid); string timeSpan = DateTime.Now.ToFileTime().ToString().Substring(0, 9); string nonceStr = Guid.NewGuid().ToString().Replace("-", ""); model.Pay_sn = uoRes.prepay_id; string package = "prepay_id=" + uoRes.prepay_id; Dictionary <String, String> dict = new Dictionary <string, string>(); dict.Add("appId", wechatHelper.AppId); dict.Add("nonceStr", nonceStr); dict.Add("package", package); dict.Add("signType", "MD5"); dict.Add("timeStamp", timeSpan); string sign = wechatHelper.WechatPaySign(dict); String cfg = "{\"timestamp\": " + timeSpan + ", \"nonceStr\": \"" + nonceStr + "\", \"package\": \"" + package + "\", \"signType\":\"MD5\", \"paySign\": \"" + sign + "\", \"success\": null }"; return(Json(Message.Success(cfg))); } else { return(Json(Message.Error(uoRes.return_msg))); } }
/// <summary> /// 申请退款 /// </summary> /// <param name="inputObj">提交给申请退款API的参数</param> /// <param name="timeOut">超时时间</param> /// <returns>成功时返回接口调用结果,其他抛异常</returns> public static WxPayData Refund(WxPayData inputObj, int timeOut = 6) { string url = "https://api.mch.weixin.qq.com/secapi/pay/refund"; //检测必填参数 if (!inputObj.IsSet("out_trade_no") && !inputObj.IsSet("transaction_id")) { throw new Exception("退款申请接口中,out_trade_no、transaction_id至少填一个!"); } else if (!inputObj.IsSet("out_refund_no")) { throw new Exception("退款申请接口中,缺少必填参数out_refund_no!"); } else if (!inputObj.IsSet("total_fee")) { throw new Exception("退款申请接口中,缺少必填参数total_fee!"); } else if (!inputObj.IsSet("refund_fee")) { throw new Exception("退款申请接口中,缺少必填参数refund_fee!"); } else if (!inputObj.IsSet("op_user_id")) { throw new Exception("退款申请接口中,缺少必填参数op_user_id!"); } inputObj.SetValue("appid", PubConf.AppId); //公众账号ID inputObj.SetValue("mch_id", PubPayConf.MchId); //商户号 inputObj.SetValue("nonce_str", WechatHelper.GetNonceStrGuid()); //随机字符串 inputObj.SetValue("sign_type", WxPayData.SIGN_TYPE_HMAC_SHA256); //签名类型 inputObj.SetValue("sign", inputObj.MakeSign()); //签名 string xml = inputObj.ToXml(); var start = DateTime.Now; WechatHelper.Log.Debug("WxPayApi:Refund request : " + xml); string response = HttpService.Post(xml, url, true, timeOut);//调用HTTP通信接口提交数据到API WechatHelper.Log.Debug("WxPayApi:Refund response : " + response); var end = DateTime.Now; int timeCost = (int)((end - start).TotalMilliseconds);//获得接口耗时 //将xml格式的结果转换为对象以返回 WxPayData result = new WxPayData(); result.FromXml(response); ReportCostTime(url, timeCost, result);//测速上报 return(result); }
/// <summary> /// 发送红包 /// </summary> /// <param name="appId">重要,企业号请使用转openid返回的appid</param> /// <param name="agentId">企业应用ID</param> /// <param name="openId">接受红包用户OpenId</param> /// <param name="amount">红包金额(单位:分)</param> /// <param name="act_name">活动名称</param> /// <param name="wishing">红包祝福语</param> /// <param name="remark">备注信息</param> /// <param name="scene_id">发放红包使用场景,红包金额大于200时必传</param> /// PRODUCT_1: 商品促销 /// PRODUCT_2:抽奖 /// PRODUCT_3:虚拟物品兑奖 /// PRODUCT_4:企业内部福利 /// PRODUCT_5:渠道分润 /// PRODUCT_6:保险回馈 /// PRODUCT_7:彩票派奖 /// PRODUCT_8:税务刮奖 public static EntRedpackResult SendPack(string appId, int agentId, string openId, int amount, string act_name, string wishing, string remark, string scene_id = "") { // 请求参数 var data = new EntPayData(); data.SetValue("nonce_str", WechatHelper.GetNonceStrGuid()); data.SetValue("mch_billno", WechatHelper.GenerateOutTradeNo(EntPayConf.MchId)); data.SetValue("mch_id", EntPayConf.MchId); data.SetValue("wxappid", appId); // 以企业应用的名义发红包,企业应用id,整型,可在企业微信管理端应用的设置页面查看。与sender_name互斥,二者只能填一个。 data.SetValue("agentid", agentId); data.SetValue("re_openid", openId); data.SetValue("total_amount", amount); data.SetValue("act_name", act_name); data.SetValue("wishing", wishing); data.SetValue("remark", remark); //发放红包使用场景,红包金额大于200时必传 if (!string.IsNullOrEmpty(scene_id)) { data.SetValue("scene_id", scene_id); } data.SetValue("workwx_sign", data.MakeSignQy()); data.SetValue("sign", data.MakeSignWx()); // 证书 var cert = WechatHelper.GetRequestCert(EntPayConf.CertPath, EntPayConf.CertPass, EntPayConf.MchId.ToString()); using (var client = new HttpClient(cert)) { var result = client.PostAsync(SEND_REDPACK_URL, new StringContent(data.ToXml())).Result.Content.ReadAsStringAsync().Result; //EntPayData res = new EntPayData(); //res.FromXml(result); //WechatHelper.Log.Error("数据" + data.ToXml() + " 结果:" + Newtonsoft.Json.JsonConvert.SerializeObject(result)); //return new EntRedpackResult() //{ // err_code = res.GetAsStringValue("err_code"), // err_code_des = res.GetAsStringValue("err_code_des"), // result_code = res.GetAsStringValue("result_code"), // return_code = res.GetAsStringValue("return_code"), // return_msg = res.GetAsStringValue("return_msg"), // JsonResult = result //}; var res = SerializeHelper.XmlDeserialize <EntRedpackResult>(result); return(res); } }
/// <summary> /// 提交被扫支付API /// 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台, /// 由商户收银台或者商户后台调用该接口发起支付。 /// </summary> /// <param name="inputObj">提交给被扫支付API的参数</param> /// <param name="timeOut">超时时间</param> /// <returns>成功时返回调用结果,其他抛异常</returns> public static WxPayData Micropay(WxPayData inputObj, int timeOut = 10) { string url = "https://api.mch.weixin.qq.com/pay/micropay"; //检测必填参数 if (!inputObj.IsSet("body")) { throw new Exception("提交被扫支付API接口中,缺少必填参数body!"); } else if (!inputObj.IsSet("out_trade_no")) { throw new Exception("提交被扫支付API接口中,缺少必填参数out_trade_no!"); } else if (!inputObj.IsSet("total_fee")) { throw new Exception("提交被扫支付API接口中,缺少必填参数total_fee!"); } else if (!inputObj.IsSet("auth_code")) { throw new Exception("提交被扫支付API接口中,缺少必填参数auth_code!"); } inputObj.SetValue("spbill_create_ip", WechatHelper.GetServerIP()); //终端ip inputObj.SetValue("appid", PubConf.AppId); //公众账号ID inputObj.SetValue("mch_id", PubPayConf.MchId); //商户号 inputObj.SetValue("nonce_str", WechatHelper.GetNonceStrGuid()); //随机字符串 inputObj.SetValue("sign_type", WxPayData.SIGN_TYPE_HMAC_SHA256); //签名类型 inputObj.SetValue("sign", inputObj.MakeSign()); //签名 string xml = inputObj.ToXml(); var start = DateTime.Now;//请求开始时间 WechatHelper.Log.Debug("WxPayApi:MicroPay request : " + xml); string response = HttpService.Post(xml, url, false, timeOut);//调用HTTP通信接口以提交数据到API WechatHelper.Log.Debug("WxPayApi:MicroPay response : " + response); var end = DateTime.Now; int timeCost = (int)((end - start).TotalMilliseconds);//获得接口耗时 //将xml格式的结果转换为对象以返回 WxPayData result = new WxPayData(); result.FromXml(response); ReportCostTime(url, timeCost, result);//测速上报 return(result); }
/// <summary> /// 最近报修 /// </summary> /// <param name="code"></param> /// <returns></returns> public ActionResult LatestRepair(string code) { url.urltype = "LatestRepair"; try { if (!string.IsNullOrEmpty(code)) { if (!string.IsNullOrEmpty(CodeJjudgeByOpenid(code))) { var user = wuser.GetUserInfo(this.openid); if (user.UserInfo != null) { ViewBag.user = user; ViewBag.openid = this.openid; //历史报修记录 var repairlist = repairHelper.GetHistoryRepair(this.openid); ViewBag.RepairList = repairlist.Count() == 0 ? null : repairlist; ViewBag.Recordid = RecordHelper.GetRecord(this.openid); ViewBag.HasUnFinishedRepair = repairHelper.HasUnFinishedRepair(this.openid); ViewBag.Village = repairHelper.GetAllVillage().FirstOrDefault(item => item.Name == ViewBag.Recordid.Address); } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "LatestRepair", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "LatestRepair", "")); } } catch (Exception) { throw; } //ViewBag.user = wuser.GetUserInfo("olQmIjmqPu9tExxvjfJpNAFV4gJ4"); //ViewBag.openid = "olQmIjmqPu9tExxvjfJpNAFV4gJ4"; //ViewBag.RepairList = repairHelper.GetHistoryRepair("olQmIjmqPu9tExxvjfJpNAFV4gJ4"); return(View()); }
/// <summary> /// 经销商 /// </summary> /// <returns></returns> public ActionResult Distributor(string code) { url.urltype = "Distributor"; try { if (!string.IsNullOrEmpty(code)) { if (!string.IsNullOrEmpty(CodeJjudgeByOpenid(code))) { var user = wuser.GetUserInfo(this.openid); if (user.UserInfo == null) { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } else { if (partner.GetPartnerInfo(this.openid) == null) { ViewBag.user = user; ViewBag.parnter = partner.GetPartnerInfo(openid); ViewBag.Salesman = SalesmanHelper.GetAllSalesman(); //获取所有销售 ViewBag.AllDistrict = partner.GetAllDistrict(); //获取所有地区 } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Partner", "")); } } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Supplier", "")); } } catch (Exception) { throw; } ViewBag.openid = this.openid; return(View()); }
/// <summary> /// 获取JS-SDK权限验证的签名 /// </summary> /// <param name="timestamp"></param> /// <param name="nonceStr"></param> /// <param name="url"></param> /// <returns></returns> public static string JsSdkSign(long timestamp, string nonceStr, string url) { try { //对所有待签名参数按照字段名的ASCII 码从小到大排序 var string1Builder = new StringBuilder().Append("jsapi_ticket=").Append(PubInterface.JsSdkTicket).Append("&") .Append("noncestr=").Append(nonceStr).Append("&") .Append("timestamp=").Append(timestamp).Append("&") .Append("url=").Append(url.IndexOf("#") >= 0 ? url.Substring(0, url.IndexOf("#")) : url); var string1 = string1Builder.ToString(); return(WechatHelper.Sha1SignShare(string1).ToLower()); } catch { return(string.Empty); } }
/// <summary> /// 测速上报接口实现 /// </summary> /// <param name="inputObj">提交给测速上报接口的参数</param> /// <param name="timeOut">测速上报接口超时时间</param> /// <returns>成功时返回测速上报接口返回的结果,其他抛异常</returns> public static WxPayData Report(WxPayData inputObj, int timeOut = 1) { string url = "https://api.mch.weixin.qq.com/payitil/report"; //检测必填参数 if (!inputObj.IsSet("interface_url")) { throw new Exception("接口URL,缺少必填参数interface_url!"); } if (!inputObj.IsSet("return_code")) { throw new Exception("返回状态码,缺少必填参数return_code!"); } if (!inputObj.IsSet("result_code")) { throw new Exception("业务结果,缺少必填参数result_code!"); } if (!inputObj.IsSet("user_ip")) { throw new Exception("访问接口IP,缺少必填参数user_ip!"); } if (!inputObj.IsSet("execute_time_")) { throw new Exception("接口耗时,缺少必填参数execute_time_!"); } inputObj.SetValue("appid", PubConf.AppId); //公众账号ID inputObj.SetValue("mch_id", PubPayConf.MchId); //商户号 inputObj.SetValue("user_ip", WechatHelper.GetServerIP()); //终端ip inputObj.SetValue("time", DateTime.Now.ToString("yyyyMMddHHmmss")); //商户上报时间 inputObj.SetValue("nonce_str", GenerateNonceStr()); //随机字符串 inputObj.SetValue("sign_type", WxPayData.SIGN_TYPE_HMAC_SHA256); //签名类型 inputObj.SetValue("sign", inputObj.MakeSign()); //签名 string xml = inputObj.ToXml(); WechatHelper.Log.Info("WxPayApi:Report request : " + xml); string response = HttpService.Post(xml, url, false, timeOut); WechatHelper.Log.Info("WxPayApi:Report response : " + response); WxPayData result = new WxPayData(); result.FromXml(response); return(result); }
public ActionResult Audit(TelphoneCertificationEntity entity) { entity.createId = CurrentWxUser.OpenId; entity.createName = CurrentWxUser.NickName; //插入实名认证表 string responseText = telphonecertificationbll.SaveForm("", entity); if (responseText.IndexOf("OK") >= 0) { //微信提醒 WechatHelper.SendWX(entity.mobileNumber, entity.custName, entity.custCertCode, entity.custCertAddress); //订单提醒 WechatHelper.SendToTemplate(entity.createId); } return(Content(responseText)); }
public async Task <ExternalLoginInfo> CreateExternalLogin(string provider, string token) { switch (provider) { case ExternalProvider.Facebook: { var payload = await FacebookHelper.GetFacebookUser(token); var cp = FacebookHelper.GetClaims(payload); if (cp == null) { return(null); } return(new ExternalLoginInfo(cp, ExternalProvider.Facebook, FacebookHelper.GetId(payload), ExternalProvider.Facebook)); } case ExternalProvider.Google: { var payload = await GoogleHelper.GetGoogleUser(token); var cp = GoogleHelper.GetClaims(payload); if (cp == null) { return(null); } return(new ExternalLoginInfo(cp, ExternalProvider.Google, GoogleHelper.GetId(payload), ExternalProvider.Google)); } case ExternalProvider.Wechat: { string[] variables = token.Split(":"); var payload = await WechatHelper.GetWechatUser(variables[0], variables[1]); var cp = WechatHelper.GetClaims(payload); if (cp == null) { return(null); } return(new ExternalLoginInfo(cp, ExternalProvider.Wechat, WechatHelper.GetId(payload), ExternalProvider.Wechat)); } default: return(null); } }
public static string UploadFile(UploadFileObj uploadFileObj) { string objName = null; string mchId = RedisCache.CreateInstance().Get(ConstCacheKey.GetMchIdKey(uploadFileObj.WxId)); if (string.IsNullOrEmpty(mchId)) { mchId = "00000000000"; } WechatHelper wechatHelper = new WechatHelper(); //图片 if (uploadFileObj.MsgType == 3) { byte[] buffer = wechatHelper.GetMsgBigImg(uploadFileObj.LongDataLength, uploadFileObj.MsgId, uploadFileObj.WxId, uploadFileObj.ToWxId, 0, (int)uploadFileObj.LongDataLength); if (buffer != null) { objName = FileStorageHelper.GetObjectName(mchId); FileStorageHelper.Upload(buffer, $"{objName}{uploadFileObj.MsgId}.png"); } } //语音 else if (uploadFileObj.MsgType == 34) { if (uploadFileObj.Buffer != null) { objName = FileStorageHelper.GetObjectName(mchId); FileStorageHelper.Upload(uploadFileObj.Buffer, $"{objName}{uploadFileObj.MsgId}.silk"); } } //视频 else if (uploadFileObj.MsgType == 43) { byte[] buffer = wechatHelper.GetVideo(uploadFileObj.WxId, uploadFileObj.ToWxId, uploadFileObj.MsgId, uploadFileObj.LongDataLength, 0, (int)uploadFileObj.LongDataLength); if (buffer != null) { objName = FileStorageHelper.GetObjectName(mchId); FileStorageHelper.Upload(buffer, $"{objName}{uploadFileObj.MsgId}.mp4"); } } return(objName); }
/// <summary> /// 经销商信息修改 /// </summary> /// <returns></returns> public ActionResult PersonalCenter(string code, string type) { url.urltype = "PersonalCenter"; try { if (!string.IsNullOrEmpty(code)) { if (!string.IsNullOrEmpty(CodeJjudgeByOpenid(code))) { var user = wuser.GetUserInfo(this.openid); if (user.UserInfo == null) { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } else { ViewBag.user = user; ViewBag.parnter = partner.GetPartnerInfo(openid); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "PersonalCenter", "")); } } catch (Exception) { throw; } ViewBag.Title = "经销商注册"; if (ViewBag.parnter != null) { ViewBag.Title = "经销商修改"; } ViewBag.openid = this.openid; return(View()); }
/// <summary> /// 发送红包 /// </summary> /// <param name="appId">重要,企业号请使用转openid返回的appid</param> /// <param name="openId">接受红包用户OpenId</param> /// <param name="amount">红包金额(单位:分)</param> /// <param name="ip">发送红包服务器IP</param> /// <param name="act_name">活动名称</param> /// <param name="wishing">红包祝福语</param> /// <param name="remark">备注信息</param> /// <param name="send_name">发红包公司</param> public static PackResult SendPack(string appId, string openId, int amount, string ip, string act_name, string wishing, string remark, string send_name) { var data = new WxPayData(); data.SetValue("mch_billno", WechatHelper.GenerateOutTradeNo(PubPayConf.MchId)); data.SetValue("mch_id", PubPayConf.MchId); data.SetValue("wxappid", appId); data.SetValue("send_name", send_name); data.SetValue("re_openid", openId); data.SetValue("total_amount", 100); data.SetValue("total_num", 1); data.SetValue("wishing", wishing); data.SetValue("client_ip", ip); data.SetValue("act_name", act_name); data.SetValue("remark", remark); data.SetValue("nonce_str", WechatHelper.GetNonceStrGuid()); data.SetValue("sign", data.MakeSign(WxPayData.SIGN_TYPE_MD5)); // 证书 var cert = WechatHelper.GetRequestCert(PubPayConf.CertPath, PubPayConf.CertPass, PubPayConf.MchId.ToString()); using (var client = new HttpClient(cert)) { var result = client.PostAsync(SEND_REDPACK_URL, new StringContent(data.ToXml())).Result.Content.ReadAsStringAsync().Result; WechatHelper.Log.Debug("数据" + data.ToXml() + " 结果:" + SerializeHelper.JsonSerialize(result)); // 解析返回结果 //WxPayData res = new WxPayData(); //res.FromXml(result); //return new PackResult() //{ // err_code = res.GetAsStringValue("err_code"), // err_code_des = res.GetAsStringValue("err_code_des").ToString(), // result_code = res.GetAsStringValue("result_code").ToString(), // return_code = res.GetAsStringValue("return_code").ToString(), // return_msg = res.GetAsStringValue("return_msg").ToString() //}; // 红包不返回签名,验证签名必定报错 var res = SerializeHelper.XmlDeserialize <PackResult>(result); return(res); } }
/// <summary> /// 合作伙伴修改 /// </summary> /// <param name="code"></param> /// <param name="comName"></param> /// <param name="Type"> Sub_contractor分包商,Supplier供应商 </param> /// <param name="realName"></param> /// <param name="Address"></param> /// <param name="comPhone"></param> /// <returns></returns> public JsonResult EditPartnerInfoJson(string code, string comName, string type, string realName, string Address, string comPhone) { try { DoShineMP.Models.PartnerType p = (DoShineMP.Models.PartnerType)Enum.Parse(typeof(DoShineMP.Models.PartnerType), type); if (partner.ReginPartner(WechatHelper.GetOpenidByCode(code), comName, p, realName, Address, comPhone) != null) { return(Json(new { msg = "Y" })); } else { return(Json(new { msg = "N" })); } } catch (Exception e) { return(Json(new { msg = "N" })); } }
/// <summary> /// 报修详情 /// </summary> /// <param name="code"></param> /// <returns></returns> public ActionResult RepairDetails(string repairid) { int a; if (int.TryParse(repairid, out a)) { var repairdetail = repairHelper.GetDetail(a); if (repairdetail != null) { ViewBag.RepairDetail = repairdetail; } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Repair", "")); } } ViewBag.Title = "报修详情"; return(View()); }
/// <summary> /// 检查服务器是否支持DigiCert证书 /// </summary> /// <returns></returns> public static string CheckDigiCert() { var url = "https://apitest.mch.weixin.qq.com/sandboxnew/pay/getsignkey"; var data = new EntPayData(); data.SetValue("mch_id", EntPayConf.MchId); data.SetValue("nonce_str", WechatHelper.GetNonceStrGuid()); data.SetValue("sign", data.MakeSignWx()); // 发送请求 var cert = WechatHelper.GetRequestCert(EntPayConf.CertPath, EntPayConf.CertPass, EntPayConf.MchId.ToString()); using (var client = new HttpClient(cert)) { var result = client.PostAsync(url, new StringContent(data.ToXml())).Result.Content.ReadAsStringAsync().Result; EntPayData res = new EntPayData(); res.FromXml(result); return(res.ToJson()); } }
static void Main(string[] args) { //string message = "新年快乐! 过节费5000."; //Console.WriteLine("If using email to greeting, you can do like this:"); //MessageServiceV20.GreetMessageService service = new MessageServiceV20.GreetMessageService(SendTool.Email); //service.Greet(message); //Console.WriteLine("\r\nIf using telephone to greeting, you can do like this:"); //service = new MessageServiceV20.GreetMessageService(SendTool.Telephone); //service.Greet(message); //return; //// string message = "新年快乐! 过节费5000."; //Console.WriteLine("If using email to greeting, you can do like this:"); //ISendable greetTool = new EmailV20.EmailHelper(); //MessageServiceV20.GreetMessageService service = new MessageServiceV20.GreetMessageService(greetTool); //greetTool.Send(message); //Console.WriteLine("\r\nIf using telephone to greeting, you can do like this:"); //ISendable greetTool = new TelephoneHelper(); //GreetMessageService service = new GreetMessageService(greetTool); //service.Greet(message); //Console.WriteLine("\r\nIf using SMS to greeting, you can do like this:"); //ISendable greetTool = new SMSHelper(); //GreetMessageService service = new GreetMessageService(greetTool); //service.Greet(message); Console.WriteLine("\r\nIf using wechat to greeting, you can do like this:"); ISendable greetTool = new WechatHelper(); GreetMessageService service = new GreetMessageService(greetTool); service.Greet(message); Console.ReadLine(); }