2333 lines
106 KiB
C#
2333 lines
106 KiB
C#
using Aliyun.Acs.Core;
|
||
using Aliyun.Acs.Core.Exceptions;
|
||
using Aliyun.Acs.Core.Profile;
|
||
using Aliyun.Acs.Dysmsapi.Model.V20170525;
|
||
using Com.Alipay;
|
||
using dccdc.BLL;
|
||
using dccdc.Common;
|
||
using dccdc.Models;
|
||
using dccdc.Models.WeiXin;
|
||
using MessagingToolkit.QRCode.Codec;
|
||
using MessagingToolkit.QRCode.Codec.Data;
|
||
using MiniExcelLibs;
|
||
using NetSDKCS;
|
||
using NPOI.HSSF.UserModel;
|
||
using NPOI.SS.UserModel;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Collections.Specialized;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Reflection;
|
||
using System.Runtime.InteropServices;
|
||
using System.Security.Cryptography;
|
||
using System.Text;
|
||
using System.Web;
|
||
using System.Web.Mvc;
|
||
using System.Xml;
|
||
using ZWL.Common;
|
||
|
||
namespace dccdc.Controllers
|
||
{
|
||
public class WeiXinController : Controller
|
||
{
|
||
|
||
#region zzq
|
||
|
||
//const string appID = "wxb79cf945835c07e3";
|
||
//const string appsecret = "e7ff8220aaae27b4dc88862bdf0a0087";
|
||
|
||
#endregion
|
||
|
||
#region wwp
|
||
|
||
//wwp微信测试号信息
|
||
//private const string appID = "wxd87b28ea53d51416";
|
||
//private const string appsecret = "2a83e3bb4fed7f230e2cf0da90665834";
|
||
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// ytgjjc
|
||
/// </summary>
|
||
//const string Token = "3502b42365dff46b61c38f89524ebcf8";
|
||
|
||
//const string EncodingAESKey = "ha1Wb7md8RGwc6hziCONKVwtvIbT5sMS3O4CTKUlzcf";
|
||
//const string MyId = "gh_7a3845c111a0";
|
||
[AllowAnonymous]
|
||
public ActionResult about()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
// GET: WeiXin
|
||
[HttpGet]
|
||
public string Index()
|
||
{
|
||
string echostr = Request.QueryString["echostr"];
|
||
return CheckSignature() ? echostr : "error";
|
||
}
|
||
|
||
internal void sendtxmsgdx(jkztxsz sz, ProfessionalExamRegisterModel dtx)
|
||
{
|
||
var commonbll = new BLL.Common();
|
||
string yddx = commonbll.getParm_Value("qyyddx", "false", "是否启用移动短信");
|
||
if (yddx == "false")
|
||
{
|
||
string AccessKeyID = commonbll.getParm_Value("AccessKeyID", "LTAIWq3410bmP7hi", "阿里AccessKeyID");
|
||
string AccessKeySecret = commonbll.getParm_Value("AccessKeySecret", "F953Ru3uZN2ZbS5741zvO9OvHrthNV", "阿里AccessKeySecret");
|
||
string qm = commonbll.getParm_Value("aldxqm", "三才网络", "短信签名");
|
||
String product = "Dysmsapi";//短信API产品名称
|
||
String domain = "dysmsapi.aliyuncs.com";//短信API产品域名
|
||
String accessKeyId = AccessKeyID;//你的accessKeyId
|
||
String accessKeySecret = AccessKeySecret;//你的accessKeySecret
|
||
IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accessKeyId, accessKeySecret);
|
||
DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
|
||
IAcsClient acsClient = new DefaultAcsClient(profile);
|
||
SendSmsRequest request = new SendSmsRequest();
|
||
try
|
||
{
|
||
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为20个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
|
||
request.PhoneNumbers = dtx.mobile;
|
||
//必填:短信签名-可在短信控制台中找到
|
||
request.SignName = qm;
|
||
//必填:短信模板-可在短信控制台中找到
|
||
request.TemplateCode = commonbll.getParm_Value("aldxmb_cycb", "SMS_205400964", "短信模板从业人员催办"); //"SMS_205400964";
|
||
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
|
||
request.TemplateParam = Newtonsoft.Json.JsonConvert.SerializeObject(new { name = dtx.person_name, time = dtx.register_date });
|
||
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
|
||
//request.OutId = "21212121211";
|
||
//请求失败这里会抛ClientException异常
|
||
SendSmsResponse sendSmsResponse = acsClient.GetAcsResponse(request);
|
||
//System.Console.WriteLine(sendSmsResponse.Message);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(sendSmsResponse.Message);
|
||
}
|
||
catch (ServerException e)
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(e.Message + e.RequestId);
|
||
//System.Console.WriteLine("Hello World!");
|
||
//return Json(new { State = 0, Message = e.Message});
|
||
|
||
}
|
||
catch (ClientException e)
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(e.Message + e.RequestId);
|
||
//return Json(new { State = 0, Message = e.Message});
|
||
}
|
||
}
|
||
else
|
||
{
|
||
string ydhttp = commonbll.getParm_Value("ydhttp", "http://112.35.1.155:1992/sms/tmpsubmit", "移动短信地址");
|
||
var req = new Models.duanxin.msend();
|
||
req.ecName = commonbll.getParm_Value("yddxqymc", "德州市德城区疾病预防控制中心", "企业名称");
|
||
req.apId = commonbll.getParm_Value("yddxapId", "jkoa", "接口账号用户名");
|
||
req.mobiles = dtx.mobile;
|
||
req.sign = commonbll.getParm_Value("yddxsign", "d37CYmrbG", "签名编码");
|
||
req.templateId = "cb6620fa80254683a9bd41c22b55603f";
|
||
req.addSerial = "";
|
||
|
||
string[] parms = new string[2];
|
||
parms[0] = dtx.person_name;
|
||
parms[1] = dtx.register_date;
|
||
req.parms = Newtonsoft.Json.JsonConvert.SerializeObject(parms);
|
||
var md5 = MD5.Create();
|
||
//secretKey
|
||
var bs = md5.ComputeHash(Encoding.UTF8.GetBytes(req.ecName + req.apId + commonbll.getParm_Value("yddxsecretKey", "a7551898", "短信接口密码") + req.templateId + req.mobiles + req.parms + req.sign));
|
||
var sb = new StringBuilder();
|
||
foreach (byte b in bs)
|
||
{
|
||
sb.Append(b.ToString("x2"));
|
||
}
|
||
req.mac = sb.ToString().ToLower();
|
||
WebClient wc = new WebClient();
|
||
string upstr = Newtonsoft.Json.JsonConvert.SerializeObject(req);
|
||
upstr = upstr.Replace("parms", "params");
|
||
//new {params }
|
||
//upstr.Insert(upstr.Length-1,",")
|
||
byte[] resp = wc.UploadData(ydhttp, System.Text.Encoding.UTF8.GetBytes(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(upstr))));
|
||
var nres = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.duanxin.nrecive>(System.Text.Encoding.UTF8.GetString(resp));
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(System.Text.Encoding.UTF8.GetString(resp));
|
||
//return Json(new { State = 1, Message = yzm.id.ToString() });
|
||
//return Json(new { State = 1, Message = System.Text.Encoding.UTF8.GetString(resp) });
|
||
}
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
[HttpPost]
|
||
public string Index(FormCollection fc)
|
||
{
|
||
string postString;
|
||
using (Stream stream = Request.InputStream)
|
||
{
|
||
Byte[] postBytes = new Byte[stream.Length];
|
||
stream.Read(postBytes, 0, (Int32)stream.Length);
|
||
postString = Encoding.UTF8.GetString(postBytes);
|
||
}
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(postString);
|
||
string signature = Request.QueryString["signature"];
|
||
string timestamp = Request.QueryString["timestamp"];
|
||
string nonce = Request.QueryString["nonce"];
|
||
string msg_signature = Request.QueryString["msg_signature"];
|
||
string msg = postString;
|
||
string retmsg = string.Empty;
|
||
WXBizMsgCrypt wxbiz = new WXBizMsgCrypt(Common.Global.Token, Common.Global.EncodingAESKey, Common.Global.AppId);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(Common.Global.Token);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(Common.Global.EncodingAESKey);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(Common.Global.AppId);
|
||
|
||
//string msg = postString;
|
||
int code = wxbiz.DecryptMsg(msg_signature, timestamp, nonce, postString, ref msg);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(code);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(msg);
|
||
try
|
||
{
|
||
XmlDocument doc = new XmlDocument();
|
||
doc.LoadXml(msg);
|
||
XmlNode root = doc.FirstChild;
|
||
var xmlElement = root["MsgType"];
|
||
if (xmlElement != null)
|
||
{
|
||
string msgType = xmlElement.InnerText;
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(msgType);
|
||
|
||
switch (msgType.ToLower())
|
||
{
|
||
case "event":
|
||
retmsg = ExecEvent(doc);
|
||
break;
|
||
case "text":
|
||
//retmsg = ExceText(doc);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(ex.Message);
|
||
|
||
}
|
||
if (string.IsNullOrEmpty(retmsg))
|
||
return retmsg;
|
||
else
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(retmsg);
|
||
|
||
//int t_code = wxbiz.EncryptMsg(retmsg, timestamp, nonce, ref msg);
|
||
/*log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(msg);
|
||
if (t_code == 0)
|
||
return msg;
|
||
else
|
||
{
|
||
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(t_code.ToString());
|
||
return "";
|
||
}*/
|
||
|
||
return retmsg;
|
||
}
|
||
//return "";
|
||
}
|
||
|
||
#region 校验开发者
|
||
private bool CheckSignature()
|
||
{
|
||
string signature = Request.QueryString["signature"];
|
||
string timestamp = Request.QueryString["timestamp"];
|
||
string nonce = Request.QueryString["nonce"];
|
||
string[] arrTmp = { Common.Global.Token, timestamp, nonce };
|
||
//string[] arrTmp = { Token, timestamp, nonce };
|
||
Array.Sort(arrTmp);//字典排序
|
||
string tmpStr = string.Join("", arrTmp);
|
||
var sha1 = System.Security.Cryptography.SHA1.Create();
|
||
tmpStr = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(tmpStr))).Replace("-", ""); //对该字符串进行sha1加密
|
||
tmpStr = tmpStr.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理
|
||
//WriteLog(tmpStr);//计入日志
|
||
if (tmpStr == signature)//开发者获得加密后的字符串可与signature对比,标识该请求来源于微信。开发者通过检验signature对请求进行校验,若确认此次GET请求来自微信服务器,请原样返回echostr参数内容,则接入生效,否则接入失败
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 菜单维护
|
||
|
||
/// <summary>
|
||
/// 微信菜单管理
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public ActionResult Menu()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 微信菜单类型
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public JsonResult getCDLX()
|
||
{
|
||
return Json(
|
||
new[]
|
||
{
|
||
new { id="zu",name="菜单组" },
|
||
new { id="click",name="点击推事件" },
|
||
new { id="view",name="跳转URL" }
|
||
}
|
||
);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取菜单列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public string getMeun()
|
||
{
|
||
// string sql = "select * from menu";
|
||
var dt = new BLL.weixinBll().getMenu();
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(dt);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取上级菜单
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public string getSJCD()
|
||
{
|
||
var dt = new BLL.weixinBll().getSJCD();
|
||
var dr = new Models.WeiXin.menu
|
||
{
|
||
id = 0,
|
||
name = "顶级菜单"
|
||
};
|
||
dt.Insert(0, dr);
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(dt);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除菜单
|
||
/// </summary>
|
||
/// <param name="id">菜单ID</param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public JsonResult delCD(int id)
|
||
{
|
||
return Json(new BLL.weixinBll().delCd(id));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存菜单
|
||
/// </summary>
|
||
/// <param name="m">菜单实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public JsonResult saveCD(Models.WeiXin.menu m)
|
||
{
|
||
return Json(new BLL.weixinBll().saveCD(m));
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 发送菜单
|
||
|
||
/// <summary>
|
||
/// 提交微信菜单
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public string CreateWXMenu()
|
||
{
|
||
List<button> btns = new List<button>();
|
||
var dt = new BLL.weixinBll().getMenu();
|
||
var drs = dt.Where(t => t.pid == 0);
|
||
foreach (var dr in drs)
|
||
{
|
||
var btn = new button { name = dr.name };
|
||
var zcds = dt.Where(t => t.pid == dr.id);
|
||
var enumerable = zcds as menu[] ?? zcds.ToArray();
|
||
if (enumerable.Any())
|
||
{
|
||
btn.sub_button = new List<button>();
|
||
foreach (var zdr in enumerable)
|
||
{
|
||
var zcd = new button
|
||
{
|
||
name = zdr.name,
|
||
type = zdr.cdlx
|
||
};
|
||
if (zcd.type == "click")
|
||
{
|
||
zcd.key = zdr.key;
|
||
}
|
||
else if (zcd.type == "view")
|
||
{
|
||
zcd.url = zdr.url;
|
||
}
|
||
btn.sub_button.Add(zcd);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
btn.type = dr.cdlx;
|
||
if (btn.type == "click")
|
||
{
|
||
btn.key = dr.key;
|
||
}
|
||
else if (btn.type == "view")
|
||
{
|
||
btn.url = dr.url;
|
||
}
|
||
}
|
||
btns.Add(btn);
|
||
}
|
||
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(new { button = btns });
|
||
WebClient wc = new WebClient();
|
||
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||
log4net.LogManager.GetLogger(this.GetType()).Info(postData);
|
||
var result = wc.UploadData("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + Common.Global.getAccessToken.access_token, System.Text.Encoding.UTF8.GetBytes(postData));
|
||
string jg = System.Text.Encoding.UTF8.GetString(result);
|
||
return jg;
|
||
}
|
||
#endregion
|
||
|
||
#region 获取微信用户信息
|
||
|
||
public string GetOAuthOpenId(string code)
|
||
{
|
||
string url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + Common.Global.AppId + "&secret=" + Common.Global.Appsecret + "&code=" + code + "&grant_type=authorization_code";
|
||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||
Stream stream = response.GetResponseStream(); //获取响应的字符串流
|
||
if (stream != null)
|
||
{
|
||
StreamReader sr = new StreamReader(stream); //创建一个stream读取流
|
||
string html = sr.ReadToEnd(); //从头读到尾,放到字符串html李米
|
||
sr.Close();
|
||
stream.Close();
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(html);
|
||
|
||
return html;
|
||
}
|
||
return "";
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 获取微信用户信息员工疫苗
|
||
|
||
public string GetOAuthOpenIdYGYM(string code)
|
||
{
|
||
string url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + Common.Global.YMAppId + "&secret=" + Common.Global.YMSecret + "&code=" + code + "&grant_type=authorization_code";
|
||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||
Stream stream = response.GetResponseStream(); //获取响应的字符串流
|
||
if (stream != null)
|
||
{
|
||
StreamReader sr = new StreamReader(stream); //创建一个stream读取流
|
||
string html = sr.ReadToEnd(); //从头读到尾,放到字符串html李米
|
||
sr.Close();
|
||
stream.Close();
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(html);
|
||
|
||
return html;
|
||
}
|
||
return "";
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 预约登记
|
||
|
||
[HttpGet]
|
||
[AllowAnonymous]
|
||
public ActionResult ChargeResult()
|
||
{
|
||
if (Session["openuser"] == null || Session["openuser"].ToString() == "")
|
||
{
|
||
string code = Request.QueryString["code"];
|
||
if (string.IsNullOrEmpty(code))
|
||
{
|
||
return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.AppId +
|
||
//"&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) +
|
||
"&redirect_uri=" + Url.Encode("http://llty.xinelu.cn/dccdc/WeiXin/ChargeResult") +
|
||
"&response_type=code&scope=snsapi_base#wechat_redirect");
|
||
}
|
||
string openidstr = GetOAuthOpenId(code);
|
||
var openid = Newtonsoft.Json.JsonConvert.DeserializeObject<OAuthopenid>(openidstr);
|
||
Session["openuser"] = openid.openid;
|
||
HttpCookie hc = new HttpCookie("openuser");
|
||
hc.Value = openid.openid;
|
||
Response.Cookies.Add(hc);
|
||
}
|
||
ViewBag.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp();
|
||
ViewBag.nonceStr = Guid.NewGuid().ToString("N");
|
||
string[] ArrayList = { "jsapi_ticket=" + Common.Global.jsapi_ticket, "timestamp=" + ViewBag.timeStamp, "noncestr=" + ViewBag.nonceStr, "url=" + Request.Url.AbsoluteUri.Split('#')[0] };
|
||
Array.Sort(ArrayList);
|
||
string signature = string.Join("&", ArrayList);
|
||
var sha1 = System.Security.Cryptography.SHA1.Create();
|
||
signature = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signature))).Replace("-", ""); //对该字符串进行sha1加密
|
||
signature = signature.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理
|
||
ViewBag.signature = signature;
|
||
|
||
var tjfa = new MedicalSchemeMaintainBll().GetAllList();
|
||
tjfa.Insert(0, new MedicalSchemeMaintainModel { id = 0, medical_scheme = "请选择体检类型" });
|
||
ViewData["tjfn"] = new SelectList(tjfa, "id", "medical_scheme");
|
||
var tjjg = new DAL.weixinDal().getyyjg();
|
||
ViewData["tjjg"] = new SelectList(tjjg, "jgid", "jgmc");
|
||
return View();
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
public string getsjd(string yyrq, string jgid)
|
||
{
|
||
var list = new BLL.tj_yysjdBll().GetListByjg(jgid);
|
||
var list2 = new BLL.MedicalAppointmentBll().GetSjd(yyrq, jgid);
|
||
|
||
StringBuilder sb = new StringBuilder();
|
||
foreach (var model in list)
|
||
{
|
||
string key = model.id.ToString();
|
||
int yjyy2 = 0;
|
||
if (list2.Count(t => t.key == key) != 0)
|
||
{
|
||
yjyy2 = Convert.ToInt32(list2.First(t => t.key == key).value);
|
||
}
|
||
|
||
if (yjyy2 < model.yyrs)
|
||
{
|
||
sb.Append("<label class=\"weui-cell weui-check__label\">");
|
||
sb.Append(model.mc + " (剩余可预约" + (model.yyrs - yjyy2) + "人) <input type=\"radio\" class=\"weui-check\" name=\"sjdid\" value=\"" + model.id + "\">");
|
||
sb.Append("<span class=\"weui-icon-checked\"></span></label>");
|
||
}
|
||
else
|
||
{
|
||
sb.Append("<label class=\"weui-cell weui-check__label\" style=\"background-color:#ccc\">" + model.mc + " - 预约人数已满</label>");
|
||
}
|
||
}
|
||
return sb.ToString();
|
||
}
|
||
|
||
[HttpPost]
|
||
[AllowAnonymous]
|
||
public ActionResult ChargeResult(ChargeViewModel vm)
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("推送微信信息:0");
|
||
if (Session["openuser"] == null || Session["openuser"].ToString() == "")
|
||
{
|
||
return Json(new { State = 0, Message = "获取关注信息失败请重新打开页面预约!" });
|
||
}
|
||
if (DateTime.Now >= DateTime.Now.Date.AddHours(18) && vm.CYFA == 3)
|
||
{
|
||
return Json(new { State = 0, Message = "每天18点至第二天0点为系统维护期,不能进行药品从业的预约!" });
|
||
}
|
||
|
||
vm.openid = Session["openuser"].ToString();
|
||
/*
|
||
var yzmbll = new BLL.DuanXinYanZhengBll();
|
||
//int iyzmid;
|
||
//int.TryParse(yzmid, out iyzmid);
|
||
if (string.IsNullOrEmpty(vm.yzmid))
|
||
{
|
||
return Json(new { State = 0, Message = "手机验证码不正确!" });
|
||
}
|
||
var yzm = yzmbll.getYZMById(vm.yzmid);
|
||
if (yzm == null)
|
||
{
|
||
return Json(new { State = 0, Message = "手机验证码不正确!" });
|
||
}
|
||
if (yzm.ShouJiHao != vm.Mobile)
|
||
{
|
||
return Json(new { State = 0, Message = "手机号码和获取验证码的手机号码不一致!" });
|
||
}
|
||
if ((DateTime.Now - yzm.sendtime).TotalMinutes > yzm.YanZhengYouXiaoQi)
|
||
{
|
||
return Json(new { State = 0, Message = "验证码已经超过有效期!" });
|
||
}
|
||
if (yzm.state != 0)
|
||
{
|
||
return Json(new { State = 0, Message = "验证码已经使用不能重复验证!" });
|
||
}
|
||
|
||
if (yzm.smscode != vm.yzm)
|
||
{
|
||
return Json(new { State = 0, Message = "手机验证码不正确!" });
|
||
}*/
|
||
int i = 0;
|
||
string ksrq = new BLL.Common().getParm_Value("bzxyyksrq", "2018-05-02", "不限制预约开始日期");
|
||
string jsrq = new BLL.Common().getParm_Value("bzxyyjsrq", "2018-06-30", "不限制预约结束日期");
|
||
DateTime dksrq = DateTime.Parse(ksrq);
|
||
DateTime djsrq = DateTime.Parse(jsrq);
|
||
if (!(Convert.ToDateTime(vm.ADate) >= dksrq && Convert.ToDateTime(vm.ADate) <= djsrq))
|
||
{
|
||
//if (Convert.ToDateTime(vm.ADate).DayOfWeek.ToString() == "Saturday" || Convert.ToDateTime(vm.ADate).DayOfWeek.ToString() == "Sunday")
|
||
if (Convert.ToDateTime(vm.ADate).DayOfWeek.ToString() == "Sunday")
|
||
{
|
||
i++;
|
||
return Json(new { State = 0, Message = "周末不允许预约!" });
|
||
}
|
||
}
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("推送微信信息:1");
|
||
//if (i != 1) yzmbll.YanZhenged(yzm);
|
||
MedicalSchemeMaintainBll bll = new MedicalSchemeMaintainBll();
|
||
OperationResult or = new BLL.MedicalAppointmentBll().canYY(vm.ADate, vm.IDCard, vm.CYFA, vm.jgid);
|
||
if (or.State == 0)
|
||
{
|
||
return Json(or);
|
||
}
|
||
MedicalSchemeMaintainModel model = bll.GetAllList(vm.CYFA.ToString()).First();
|
||
//需要收费走收费页面
|
||
if (model.isCharge == "1")
|
||
{
|
||
MedicalSchemeChargeMaintainBll bll1 = new MedicalSchemeChargeMaintainBll();
|
||
List<MedicalSchemeChargeMaintainModel> al = bll1.GetListBymedicalschememaintainid(vm.CYFA.ToString());
|
||
foreach (var m in al)
|
||
{
|
||
vm.SFJE += Convert.ToDecimal(m.fee);
|
||
}
|
||
//return RedirectToAction("ConfirmCharge", vm);
|
||
}
|
||
vm.CYFAName = model.medical_scheme;
|
||
AutoMapper.Mapper.Initialize(x => x.CreateMap<ChargeViewModel, MedicalAppointment>());
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("推送微信信息:2");
|
||
var ma = AutoMapper.Mapper.Map<Models.MedicalAppointment>(vm);
|
||
ma = new BLL.MedicalAppointmentBll().WXYY(ma);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("推送微信信息:3");
|
||
if (vm.SFJE > 0)
|
||
{
|
||
return Json(new { State = 1, Message = Url.Action("ConfirmCharge") + "?id=" + ma.id });
|
||
}
|
||
else
|
||
{
|
||
return Json(new { State = 1, Message = Url.Action("OkResult") + "/" + ma.id });
|
||
}
|
||
//预约成功界面
|
||
//return RedirectToAction("OkResult");
|
||
}
|
||
|
||
[HttpGet]
|
||
[AllowAnonymous]
|
||
public ActionResult ConfirmCharge(string id)
|
||
{
|
||
var bll = new BLL.MedicalAppointmentBll();
|
||
var m = bll.GetModel(id);
|
||
AutoMapper.Mapper.Initialize(x => x.CreateMap<MedicalAppointment, ChargeViewModel>());
|
||
var vm = AutoMapper.Mapper.Map<ChargeViewModel>(m);
|
||
ViewBag.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp();
|
||
ViewBag.nonceStr = Guid.NewGuid().ToString("N");
|
||
string[] ArrayList = { "jsapi_ticket=" + Common.Global.jsapi_ticket, "timestamp=" + ViewBag.timeStamp, "noncestr=" + ViewBag.nonceStr, "url=" + Request.Url.AbsoluteUri.Split('#')[0] };
|
||
Array.Sort(ArrayList);
|
||
string signature = string.Join("&", ArrayList);
|
||
var sha1 = System.Security.Cryptography.SHA1.Create();
|
||
signature = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signature))).Replace("-", ""); //对该字符串进行sha1加密
|
||
signature = signature.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理
|
||
ViewBag.signature = signature;
|
||
//ViewBag.id = id;
|
||
return View(vm);
|
||
}
|
||
|
||
static object o_lock = new object();
|
||
|
||
[HttpPost]
|
||
[AllowAnonymous]
|
||
[dccdc.Filter.QianTaiAuthorize]
|
||
public ActionResult ConfirmCharge1(string id)
|
||
{
|
||
lock (o_lock)
|
||
{
|
||
MedicalAppointmentBll bll = new MedicalAppointmentBll();
|
||
var zf = new Global.WxZiFu();
|
||
string zfid = WxPayAPI.WxPayApi.GenerateOutTradeNo();
|
||
var m = bll.GetModel(id);
|
||
if (string.IsNullOrEmpty(m.ZFCode))
|
||
{
|
||
//填充微信订单号
|
||
bll.UpdateZfCode(id, zfid);
|
||
}
|
||
else
|
||
{
|
||
zfid = m.ZFCode;
|
||
}
|
||
//WxPayAPI.JsApiPay jspay = new WxPayAPI.JsApiPay();
|
||
WxPayAPI.WxPayData payData = new WxPayAPI.WxPayData();
|
||
payData.SetValue("device_info", "WXWEB");
|
||
payData.SetValue("body", new BLL.Common().getParm_Value("zfbt", "德城区疾控体检预约", "微信支付标题"));
|
||
payData.SetValue("attach", "体检");
|
||
payData.SetValue("out_trade_no", zfid);
|
||
payData.SetValue("total_fee", ((int)(m.SFJE * 100)).ToString());
|
||
payData.SetValue("spbill_create_ip", Request.UserHostAddress);
|
||
payData.SetValue("trade_type", "JSAPI");
|
||
payData.SetValue("openid", Session["openuser"].ToString());
|
||
payData.SetValue("notify_url", WxPayAPI.WxPayConfig.NOTIFY_URL);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(payData.ToXml());
|
||
var pdata = WxPayAPI.WxPayApi.UnifiedOrder(payData);
|
||
//记录支付日志
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("UnifiedOrder" + pdata.ToXml());
|
||
var jsdata = new WxPayAPI.WxPayData();
|
||
//即最后参与签名的参数有appId, timeStamp, nonceStr, package, signType
|
||
jsdata.SetValue("appId", zf.appId = Common.Global.AppId);
|
||
jsdata.SetValue("timeStamp", zf.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp());
|
||
jsdata.SetValue("nonceStr", zf.nonceStr = Guid.NewGuid().ToString("N"));
|
||
jsdata.SetValue("package", zf.package = "prepay_id=" + pdata.GetValue("prepay_id"));
|
||
jsdata.SetValue("signType", zf.signType = "MD5");
|
||
zf.paySign = jsdata.MakeSign();
|
||
return Json(zf);
|
||
}
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
[Filter.QianTaiAuthorize]
|
||
public ActionResult OkResult(string id)
|
||
{
|
||
|
||
MedicalAppointmentBll bll = new MedicalAppointmentBll();
|
||
|
||
MedicalAppointment model = bll.GetModel(id);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("推送微信信息:bll.GetModel(id)");
|
||
Models.tjjg jg = new DAL.weixinDal().getJiGouByID(model.jgid);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("推送微信信息:getJiGouByID(model.jgid)");
|
||
var list = new BLL.tj_yysjdBll().GetAllList(model.sjdid.ToString());
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("推送微信信息:.GetAllList(model.sjdid.ToString());");
|
||
|
||
string sjdmc = "";
|
||
if (list.Count > 0)
|
||
{
|
||
sjdmc = list[0].mc;
|
||
}
|
||
var data = new
|
||
{
|
||
touser = Session["openuser"].ToString(),
|
||
template_id = "qJWwF_DFvY6-Xr5fy-DPyC0kavKAg7J6yx9y9J47v6g",
|
||
url = new BLL.Common().getParm_Value("wxyyym", "http://dc.51csharp.com/", "微信预约域名") + Url.Action("Myxx", "WeiXin") + "/" + id,
|
||
data = new
|
||
{
|
||
first = new { value = "你已成功预约,请在" + model.ADate.ToString("yyyy-MM-dd") + "日" + sjdmc + "到体检中心体检。", color = "#173177" },
|
||
keyword1 = new { value = model.xingMing, color = "#173177" },
|
||
keyword2 = new { value = jg.jgmc, color = "#173177" },
|
||
keyword3 = new { value = model.ADate.ToString("yyyy-MM-dd") + " " + sjdmc, color = "#173177" },
|
||
remark = new { value = "请在预约日期上午空腹持本人身份证原件前往" + (model.jgid == 49 ? "德城区疾病预防控制中心二楼自助机领取体检指引单" : jg.jgmc) + "进行体检,过期需重新预约。", color = "#173177" },
|
||
}
|
||
};
|
||
|
||
WebClient wc = new WebClient();
|
||
byte[] bs= wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessToken.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data)));
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(System.Text.Encoding.UTF8.GetString(bs));
|
||
|
||
ViewBag.id = id;
|
||
return View();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取本openid提交的预约列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public ActionResult GetChargeListResult(string id)
|
||
{
|
||
return View();
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
public ActionResult Myxx(string id)
|
||
{
|
||
MedicalAppointmentBll bll = new MedicalAppointmentBll();
|
||
MedicalAppointment model = bll.GetModel(id);
|
||
AutoMapper.Mapper.Initialize(x => x.CreateMap<MedicalAppointment, ChargeViewModel>());
|
||
var ma = AutoMapper.Mapper.Map<ChargeViewModel>(model);
|
||
return View(ma);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 公众号门禁
|
||
|
||
/// <summary>
|
||
/// 生成二维码
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
[AllowAnonymous]
|
||
public string getErWM()
|
||
{
|
||
String guid = Guid.NewGuid().ToString();
|
||
StringBuilder sb = new StringBuilder();
|
||
sb.Append(guid);//个人身份证号
|
||
Bitmap bitmap = QRCodeEncoderUtil((sb.ToString().Trim()));//调用二维码编码方法生成位图
|
||
string fileName = Server.MapPath("~") + "Images\\QRImages\\" + guid + ".jpg";
|
||
bitmap.Save(fileName);//保存位图,文件名为guid
|
||
String ImageUrl = "~/Images/QRImages/" + guid + ".jpg";//显示图片
|
||
return ImageUrl;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取微信openId、门禁,员工、疫苗
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
[AllowAnonymous]
|
||
public ActionResult getWeiXinInfo()
|
||
{
|
||
string code = Request.QueryString["code"];
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("微信code"+ code);
|
||
|
||
if (string.IsNullOrEmpty(code))
|
||
{
|
||
return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.YMAppId +
|
||
"&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) +
|
||
"&response_type=code&scope=snsapi_base#wechat_redirect");
|
||
}
|
||
string openidstr = GetOAuthOpenIdYGYM(code);
|
||
var infoObject= Newtonsoft.Json.JsonConvert.DeserializeObject<OAuthopenid>(openidstr);
|
||
var openId = infoObject.openid;
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("微信openId" + openId);
|
||
//var openId = "oGWLKt5ROzF1r287sS_YTFplg8qQ";
|
||
var doorid = Request.QueryString["doorid"];
|
||
ViewBag.doorid = doorid;
|
||
ViewBag.openid = openId;
|
||
|
||
ViewBag.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp();
|
||
ViewBag.nonceStr = Guid.NewGuid().ToString("N");
|
||
string[] ArrayList = { "jsapi_ticket=" + Common.Global.jsapi_ticketYM, "timestamp=" + ViewBag.timeStamp, "noncestr=" + ViewBag.nonceStr, "url=" + Request.Url.AbsoluteUri.Split('#')[0] };
|
||
Array.Sort(ArrayList);
|
||
string signature = string.Join("&", ArrayList);
|
||
var sha1 = System.Security.Cryptography.SHA1.Create();
|
||
signature = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signature))).Replace("-", ""); //对该字符串进行sha1加密
|
||
signature = signature.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理
|
||
ViewBag.signature = signature;
|
||
return View();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取微信openId、门禁,体检
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
[AllowAnonymous]
|
||
public ActionResult getTjWeiXinInfo()
|
||
{
|
||
string code = Request.QueryString["code"];
|
||
if (string.IsNullOrEmpty(code))
|
||
{
|
||
return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.AppId +
|
||
"&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) +
|
||
"&response_type=code&scope=snsapi_base#wechat_redirect");
|
||
}
|
||
string openidstr = GetOAuthOpenId(code);//GetOAuthOpenIdYGYM(code);
|
||
var infoObject = Newtonsoft.Json.JsonConvert.DeserializeObject<OAuthopenid>(openidstr);
|
||
var openId = infoObject.openid;
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("微信openId" + openId);
|
||
//var openId = "oGWLKt5ROzF1r287sS_YTFplg8qQ";
|
||
var doorid = Request.QueryString["doorid"];
|
||
ViewBag.doorid = doorid;
|
||
ViewBag.openid = openId;
|
||
|
||
ViewBag.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp();
|
||
ViewBag.nonceStr = Guid.NewGuid().ToString("N");
|
||
string[] ArrayList = { "jsapi_ticket=" + Common.Global.jsapi_ticket, "timestamp=" + ViewBag.timeStamp, "noncestr=" + ViewBag.nonceStr, "url=" + Request.Url.AbsoluteUri.Split('#')[0] };
|
||
Array.Sort(ArrayList);
|
||
string signature = string.Join("&", ArrayList);
|
||
var sha1 = System.Security.Cryptography.SHA1.Create();
|
||
signature = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signature))).Replace("-", ""); //对该字符串进行sha1加密
|
||
signature = signature.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理
|
||
ViewBag.signature = signature;
|
||
return View();
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
[HttpPost]
|
||
public string opendoor(string doorid,string openId,double jd,double wd)
|
||
{
|
||
//Hashtable map = new Hashtable();
|
||
//JavaScriptSerializer ser = new JavaScriptSerializer();
|
||
//116.303595,37.459314
|
||
string JkJ=Common.Global.getParmValue("JKJD");
|
||
string JkW = Common.Global.getParmValue("JKWD");
|
||
//116.303595,37.459314
|
||
//37° 27' 33.5298,116° 18' 12.942
|
||
double Jkjd = Double.Parse(JkJ);
|
||
double JkWd = Double.Parse(JkW);
|
||
|
||
if (string.IsNullOrEmpty(openId))
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new {State=0,Message= "开门异常!没有获取到openid!" });
|
||
}
|
||
Boolean isFanW = DistanceHelper.FindNeighPosition(jd, wd, Jkjd, JkWd,0.3);
|
||
if (!isFanW)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "开门异常!不在有效范围内!" });
|
||
}
|
||
//员工验证
|
||
ERPUserBll userBll = new ERPUserBll();
|
||
|
||
int userId = userBll.GetERPUser(openId);//GetERPUser
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("查询工作人员userId" + userId);
|
||
if (string.IsNullOrEmpty(doorid))
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "开门异常!没有查到门编码!" });
|
||
}
|
||
List<AccessModel> acc = new AccessBll().GetId(doorid);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("门禁doorid" + doorid);
|
||
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("门禁list" + acc.Count);
|
||
if (acc == null||acc.Count<=0)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "开门异常!没有查到门编码!" });
|
||
}
|
||
//是否是工作人员
|
||
if (userId == 0)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "开门异常!非工作人员禁止开门,如果您是工作人员,请在办公系统进行绑定!" });
|
||
#region 疫苗验证取消
|
||
/*
|
||
//疫苗预约验证
|
||
ym_yymxBll yyBall = new ym_yymxBll();
|
||
string yyrq = DateTime.Now.ToString("yyyy-MM-dd");
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("疫苗查询-model");
|
||
ym_yymx YYModel = yyBall.GeYYListByYyRq(yyrq, openId);
|
||
|
||
//如果疫苗验证为null
|
||
if (YYModel == null)
|
||
{
|
||
//处理体检验证
|
||
//MedicalAppointment
|
||
MedicalAppointmentBll medicalAppointmentBll = new MedicalAppointmentBll();
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("体检查询-model");
|
||
MedicalAppointment medical = medicalAppointmentBll.getMedicalModel(openId, yyrq);
|
||
//MedicalAppointment medical = new MedicalAppointment();
|
||
//体检表没有数据
|
||
if (medical == null)
|
||
{
|
||
//体检表没有预约信息
|
||
//ViewBag.Msg = "您不是员工也没有相应的预约,没有此门操作权限!";
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("体检查询为null");
|
||
map.Add("zt", 0);
|
||
map.Add("message", "您不是员工也没有相应的预约,没有此门操作权限!");
|
||
String jsonStr = ser.Serialize(map);
|
||
return jsonStr;
|
||
}
|
||
else
|
||
{
|
||
//体检表有数据
|
||
if ((am[0].kmlx & 1) == 1)
|
||
{
|
||
//有开门权限
|
||
//记录开门日志
|
||
//ViewBag.Msg = "开门成功!";
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("体检开门成功");
|
||
map.Add("zt", 1);
|
||
map.Add("message", "体检开门成功!");
|
||
String jsonStr = ser.Serialize(map);
|
||
return jsonStr;
|
||
}
|
||
else
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("没有体检预约权限");
|
||
// ViewBag.Msg = "此门不能通过体检预约打开!";
|
||
map.Add("zt", 0);
|
||
map.Add("message", "此门不能通过体检预约打开!");
|
||
String jsonStr = ser.Serialize(map);
|
||
return jsonStr;
|
||
}
|
||
//}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//如果有今天的疫苗预约,判断有没有开门权限
|
||
if ((am[0].kmlx & 2) == 2)
|
||
{
|
||
//有开门权限
|
||
//记录开门日志
|
||
// ViewBag.Msg = "开门成功!";
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("疫苗开门成功!");
|
||
map.Add("zt", 1);
|
||
map.Add("message", "疫苗开门成功!");
|
||
String jsonStr = ser.Serialize(map);
|
||
return jsonStr;
|
||
}
|
||
else
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("没有疫苗预约权限");
|
||
//ViewBag.Msg = "此门不能通过疫苗预约打开!";
|
||
map.Add("zt", 0);
|
||
map.Add("message", "此门不能通过疫苗预约打开!");
|
||
String jsonStr = ser.Serialize(map);
|
||
return jsonStr;
|
||
}
|
||
//}
|
||
|
||
|
||
}*/
|
||
#endregion
|
||
}
|
||
else
|
||
{
|
||
//是工作人员,查看他的开门权限
|
||
if ((acc[0].kmlx & 4) == 4)
|
||
{
|
||
//有开门权限
|
||
//记录开门日志
|
||
//ViewBag.Msg = "开门成功!";
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("员工开门成功!");
|
||
NETClient.Init(null, IntPtr.Zero, null);
|
||
IntPtr loginID = IntPtr.Zero;
|
||
ushort port = 0;
|
||
try
|
||
{
|
||
port = Convert.ToUInt16(acc[0].dkh);
|
||
}
|
||
catch
|
||
{
|
||
//MessageBox.Show("Port error(端口错误)");
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "门禁设备端口号错误,请联系管理员设置!" });
|
||
//return "";
|
||
}
|
||
NET_DEVICEINFO_Ex deviceInfo = new NET_DEVICEINFO_Ex();
|
||
loginID = NETClient.Login(acc[0].sbip, port, acc[0].yhm, acc[0].mm, EM_LOGIN_SPAC_CAP_TYPE.TCP, IntPtr.Zero, ref deviceInfo);
|
||
if (loginID == IntPtr.Zero)
|
||
{
|
||
//MessageBox.Show(NETClient.GetLastError());
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = NETClient.GetLastError() });
|
||
}
|
||
NET_CTRL_ACCESS_OPEN openInfo = new NET_CTRL_ACCESS_OPEN();
|
||
openInfo.dwSize = (uint)Marshal.SizeOf(typeof(NET_CTRL_ACCESS_OPEN));
|
||
openInfo.nChannelID = 0;
|
||
openInfo.szTargetID = IntPtr.Zero;
|
||
openInfo.emOpenDoorType = EM_OPEN_DOOR_TYPE.REMOTE;
|
||
IntPtr inPtr = IntPtr.Zero;
|
||
try
|
||
{
|
||
inPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_CTRL_ACCESS_OPEN)));
|
||
Marshal.StructureToPtr(openInfo, inPtr, true);
|
||
bool ret = NETClient.ControlDevice(loginID, EM_CtrlType.ACCESS_OPEN, inPtr, 10000);
|
||
if (!ret)
|
||
{
|
||
//MessageBox.Show("Open door failed(开门失败)");
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "开门失败" });
|
||
}
|
||
}
|
||
finally
|
||
{
|
||
Marshal.FreeHGlobal(inPtr);
|
||
}
|
||
|
||
NETClient.Logout(loginID);
|
||
loginID = IntPtr.Zero;
|
||
OpeningrecordBll openingrecordBll = new BLL.OpeningrecordBll();
|
||
OpeningrecordModel openModel = new OpeningrecordModel();
|
||
openModel.sbid = Convert.ToInt32(doorid);
|
||
openModel.openid = openId;
|
||
openModel.kmlx = 0;
|
||
openModel.ygid = userId;
|
||
openingrecordBll.save(openModel);
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "开门成功!" });
|
||
}
|
||
else
|
||
{
|
||
ViewBag.Msg = "此门不能通过员工打开!";
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("没有员工权限");
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "此门不能通过员工打开" });
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 生成二维码工具类
|
||
/// </summary>
|
||
/// <param name="qrCodeContent">要编码的内容</param>
|
||
/// <returns>返回二维码位图</returns>
|
||
public static Bitmap QRCodeEncoderUtil(string qrCodeContent)
|
||
{
|
||
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
|
||
qrCodeEncoder.QRCodeVersion = 0;
|
||
Bitmap img = qrCodeEncoder.Encode(qrCodeContent, Encoding.UTF8);//指定utf-8编码, 支持中文
|
||
return img;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 解析二维码工具类
|
||
/// </summary>
|
||
/// <param name="bitmap">要解析的二维码位图</param>
|
||
/// <returns>解析后的字符串</returns>
|
||
public static string QRCodeDecoderUtil(Bitmap bitmap)
|
||
{
|
||
QRCodeDecoder decoder = new QRCodeDecoder();
|
||
string decodedString = decoder.Decode(new QRCodeBitmapImage(bitmap), Encoding.UTF8);//指定utf-8编码, 支持中文
|
||
return decodedString;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 我的预约
|
||
|
||
[AllowAnonymous]
|
||
[Filter.QianTaiAuthorize]
|
||
public ActionResult Myyy()
|
||
{
|
||
if (Session["openuser"] == null || Session["openuser"].ToString() == "")
|
||
{
|
||
string code = Request.QueryString["code"];
|
||
if (string.IsNullOrEmpty(code))
|
||
{
|
||
return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.AppId +
|
||
"&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) +
|
||
"&response_type=code&scope=snsapi_base#wechat_redirect");
|
||
}
|
||
string openidstr = GetOAuthOpenId(code);
|
||
var openid = Newtonsoft.Json.JsonConvert.DeserializeObject<OAuthopenid>(openidstr);
|
||
Session["openuser"] = openid.openid;
|
||
}
|
||
MedicalAppointmentBll bll = new MedicalAppointmentBll();
|
||
List<MedicalAppointment> model = bll.GetModelByOpenid(Session["openuser"].ToString());
|
||
ViewBag.model = model;
|
||
return View();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 体检状态查询
|
||
|
||
[AllowAnonymous]
|
||
[Filter.QianTaiAuthorize]
|
||
public ActionResult Tjztcx()
|
||
{
|
||
if (Session["openuser"] == null || Session["openuser"].ToString() == "")
|
||
{
|
||
string code = Request.QueryString["code"];
|
||
if (string.IsNullOrEmpty(code))
|
||
{
|
||
return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.AppId +
|
||
"&redirect_uri=" + Url.Encode(Request.Url.AbsoluteUri) +
|
||
"&response_type=code&scope=snsapi_base#wechat_redirect");
|
||
}
|
||
string openidstr = GetOAuthOpenId(code);
|
||
var openid = Newtonsoft.Json.JsonConvert.DeserializeObject<OAuthopenid>(openidstr);
|
||
Session["openuser"] = openid.openid;
|
||
HttpCookie hc = new HttpCookie("openuser");
|
||
hc.Value = openid.openid;
|
||
Response.Cookies.Add(hc);
|
||
}
|
||
ViewBag.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp();
|
||
ViewBag.nonceStr = Guid.NewGuid().ToString("N");
|
||
string[] ArrayList = { "jsapi_ticket=" + Common.Global.jsapi_ticket, "timestamp=" + ViewBag.timeStamp, "noncestr=" + ViewBag.nonceStr, "url=" + Request.Url.AbsoluteUri.Split('#')[0] };
|
||
Array.Sort(ArrayList);
|
||
string signature = string.Join("&", ArrayList);
|
||
var sha1 = System.Security.Cryptography.SHA1.Create();
|
||
signature = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signature))).Replace("-", ""); //对该字符串进行sha1加密
|
||
signature = signature.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理
|
||
ViewBag.signature = signature;
|
||
return View();
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
[Filter.QianTaiAuthorize]
|
||
public ActionResult TjztcxList(string tm)
|
||
{
|
||
var bll = new MedicalAppointmentBll();
|
||
var m = bll.getTjztXm(tm);
|
||
List<ExaminationProcessModel> model = bll.getTjztList(tm);
|
||
ViewBag.model = model;
|
||
ViewBag.xm = m.person_name;
|
||
ViewBag.tjzt = m.procedure_status;
|
||
return View();
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 处理微信发送过来的事件
|
||
/// </summary>
|
||
/// <param name="doc"></param>
|
||
/// <returns></returns>
|
||
private string ExecEvent(XmlDocument doc)
|
||
{
|
||
string msg = string.Empty;
|
||
XmlNode root = doc.FirstChild;
|
||
var xmlElement = root["Event"];
|
||
if (xmlElement != null)
|
||
{
|
||
var Event = xmlElement.InnerText;
|
||
var element = root["FromUserName"];
|
||
if (element != null)
|
||
{
|
||
string openid = element.InnerText;
|
||
switch (Event)
|
||
{
|
||
case "subscribe":
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("关注微信");
|
||
openuser ou = getopenuser(openid);
|
||
try
|
||
{
|
||
new BLL.weixinBll().updateOpenUser(ou);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(ex.Message);
|
||
}
|
||
var comm = new BLL.Common();
|
||
string xiaoxi = @"
|
||
<ArticleCount>1</ArticleCount><Articles><item>
|
||
<Title><![CDATA[HI " + ou.nickname + @"~" + comm.getParm_Value("wxgztitle", "欢迎关注德城疾控体检微信公众号", "微信关注消息标题") + @"]]></Title>
|
||
<Description><![CDATA[" + comm.getParm_Value("wxgzjj", "欢迎关注德城疾控体检微信公众号,体检疫苗缴费。", "微信关注消息简介") + @"]]></Description>
|
||
<PicUrl><![CDATA[" + comm.getParm_Value("wxgzpic", "http://www.dcqcdc.com/news/UploadFiles_9967/201707/2017071008093694.jpg", "微信关注消息图片连接") + @"]]></PicUrl>
|
||
<Url><![CDATA[" + comm.getParm_Value("wxgzurl", "http://www.dcqcdc.com", "微信关注消息连接") + @"]]></Url>
|
||
</item></Articles>";
|
||
msg = CreateNews(openid, "news", xiaoxi);
|
||
break;
|
||
case "unsubscribe":
|
||
// var opuunsubscribe = cont.OpenUser.Find(new[] { openid });
|
||
//ou = getopenuser(openid);
|
||
//updateOpenUser(ou);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("取消关注");
|
||
//unsubscribe(openid);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
return msg;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 生成返回消息
|
||
/// </summary>
|
||
/// <param name="touser"></param>
|
||
/// <param name="type"></param>
|
||
/// <param name="xiaoxi"></param>
|
||
/// <returns></returns>
|
||
string CreateNews(string touser, string type, string xiaoxi)
|
||
{
|
||
string msg = @"<xml><ToUserName><![CDATA[" + touser + @"]]></ToUserName><FromUserName><![CDATA[" + Common.Global.MyId + @"]]></FromUserName><CreateTime>" + GetNowTime() + @"</CreateTime><MsgType><![CDATA[" + type + @"]]></MsgType>" + xiaoxi + @"</xml> ";
|
||
return msg;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取时间差
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
int GetNowTime()
|
||
{
|
||
return (int)(DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1))).TotalSeconds;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 通过时间差获取时间
|
||
/// </summary>
|
||
/// <param name="tick"></param>
|
||
/// <returns></returns>
|
||
DateTime getTime(int tick)
|
||
{
|
||
return TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)).AddSeconds(tick);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 读取微信用户信息
|
||
/// </summary>
|
||
/// <param name="openid"></param>
|
||
/// <returns></returns>
|
||
private openuser getopenuser(string openid)
|
||
{
|
||
var accessToken = Common.Global.getAccessToken;
|
||
WebClient wc = new WebClient();
|
||
var stream = wc.OpenRead("https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + accessToken.access_token + "&openid=" + openid + "&lang=zh_CN");
|
||
var sr = new StreamReader(stream);
|
||
string token = sr.ReadToEnd();
|
||
sr.Close();
|
||
stream.Dispose();
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(token);
|
||
var ou = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.WeiXin.openuser>(token);
|
||
if (string.IsNullOrEmpty(ou.openid))
|
||
{
|
||
error err = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.WeiXin.error>(token);
|
||
WeiXinException wx = new WeiXinException { WeiXinError = err };
|
||
throw wx;
|
||
}
|
||
return ou;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关注用户页面
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public ActionResult OpenUserList()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取关注用户列表
|
||
/// </summary>
|
||
/// <param name="nc"></param>
|
||
/// <param name="bz"></param>
|
||
/// <param name="page"></param>
|
||
/// <param name="pagesize"></param>
|
||
/// <returns></returns>
|
||
public JsonResult getOpenUserList(string nc, string bz, int page, int pagesize)
|
||
{
|
||
var bll = new weixinBll();
|
||
var count = bll.getGZCount(nc, bz);
|
||
var list = bll.getGZList(nc, bz, page, pagesize);
|
||
return Json(new { Total = count, Rows = list });
|
||
}
|
||
|
||
/// <summary>
|
||
/// 备注关注用户
|
||
/// </summary>
|
||
/// <param name="openid"></param>
|
||
/// <param name="bz"></param>
|
||
/// <returns></returns>
|
||
public JsonResult remark(string openid, string bz)
|
||
{
|
||
try
|
||
{
|
||
var bll = new weixinBll();
|
||
var c = bll.remarkGZ(openid, bz);
|
||
if (c > 0)
|
||
{
|
||
/*
|
||
* {
|
||
"openid":"oDF3iY9ffA-hqb2vVvbr7qxf6A0Q",
|
||
"remark":"pangzi"
|
||
}
|
||
*/
|
||
var data = new { openid = openid, remark = bz };
|
||
WebClient wc = new WebClient();
|
||
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||
log4net.LogManager.GetLogger(this.GetType()).Info(Newtonsoft.Json.JsonConvert.SerializeObject(data));
|
||
var result = wc.UploadData("https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=" + Common.Global.getAccessToken.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data)));
|
||
string jg = System.Text.Encoding.UTF8.GetString(result);
|
||
var rjg = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.WeiXin.error>(jg);
|
||
if (rjg.errmsg == "ok")
|
||
{
|
||
return Json(new { State = 1, Message = "修改成功!" });
|
||
}
|
||
else
|
||
{
|
||
return Json(new { State = 0, Message = jg });
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(new { State = 0, Message = "没有数据备注成功!" });
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return Json(new { State = 0, Message = ex.Message });
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取手机验证码
|
||
/// </summary>
|
||
/// <param name="Mobile">手机号</param>
|
||
/// <returns>验证码ID</returns>
|
||
[AllowAnonymous]
|
||
public JsonResult getsjyzm(string Mobile)
|
||
{
|
||
if (System.Text.RegularExpressions.Regex.IsMatch(Mobile, "^1[3|4|5|7|8]\\d{9}$"))
|
||
{
|
||
var dxyz = new BLL.DuanXinYanZhengBll();
|
||
string cookieid = Guid.NewGuid().ToString();// Request.Cookies["clientid"].Value;
|
||
var yzm = dxyz.getYanZheng(Session.SessionID, cookieid, Request.UserHostAddress, Mobile);
|
||
if (yzm.id == 0)
|
||
{
|
||
return Json(new { State = 0, Message = yzm.bz });
|
||
}
|
||
else
|
||
{
|
||
var commonbll = new BLL.Common();
|
||
string yddx = commonbll.getParm_Value("qyyddx", "false", "是否启用移动短信");
|
||
if (yddx == "false")
|
||
{
|
||
string AccessKeyID = commonbll.getParm_Value("AccessKeyID", "LTAIWq3410bmP7hi", "阿里AccessKeyID");
|
||
string AccessKeySecret = commonbll.getParm_Value("AccessKeySecret", "F953Ru3uZN2ZbS5741zvO9OvHrthNV", "阿里AccessKeySecret");
|
||
string qm = commonbll.getParm_Value("aldxqm", "三才网络", "短信签名");
|
||
string dxmb = commonbll.getParm_Value("aldxmb", "SMS_80120090", "短信模版");
|
||
//string smsurl = System.Configuration.ConfigurationManager.AppSettings["smsurl"];
|
||
//string yznr = "你好,欢迎你注册天瑞体检中心会员,你的验证码是:" + yzm.smscode + "。有效期10分钟。回TD退订【天瑞体检】";
|
||
//var zysms = new zyer.smsservice.SmsServiceSoapClient("SmsServiceSoap");
|
||
//var smsjg = zysms.SendEx(username, userpassword, "808", sjh, "", yznr);
|
||
//var fz = Session["FenZhan"] as Model.FenZhan;
|
||
//Common.SendMsg.Send(sjh, yznr, fz.id);
|
||
String product = "Dysmsapi";//短信API产品名称
|
||
String domain = "dysmsapi.aliyuncs.com";//短信API产品域名
|
||
String accessKeyId = AccessKeyID;//你的accessKeyId
|
||
String accessKeySecret = AccessKeySecret;//你的accessKeySecret
|
||
|
||
IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accessKeyId, accessKeySecret);
|
||
//IAcsClient client = new DefaultAcsClient(profile);
|
||
// SingleSendSmsRequest request = new SingleSendSmsRequest();
|
||
|
||
DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
|
||
IAcsClient acsClient = new DefaultAcsClient(profile);
|
||
SendSmsRequest request = new SendSmsRequest();
|
||
try
|
||
{
|
||
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为20个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
|
||
request.PhoneNumbers = Mobile;
|
||
//必填:短信签名-可在短信控制台中找到
|
||
request.SignName = qm;
|
||
//必填:短信模板-可在短信控制台中找到
|
||
request.TemplateCode = dxmb;
|
||
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
|
||
request.TemplateParam = Newtonsoft.Json.JsonConvert.SerializeObject(new { code = yzm.smscode });
|
||
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
|
||
//request.OutId = "21212121211";
|
||
//请求失败这里会抛ClientException异常
|
||
SendSmsResponse sendSmsResponse = acsClient.GetAcsResponse(request);
|
||
|
||
//System.Console.WriteLine(sendSmsResponse.Message);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(sendSmsResponse.Message);
|
||
|
||
}
|
||
catch (ServerException e)
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(e.Message + e.RequestId);
|
||
//System.Console.WriteLine("Hello World!");
|
||
//return Json(new { State = 0, Message = e.Message});
|
||
|
||
}
|
||
catch (ClientException e)
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(e.Message + e.RequestId);
|
||
//return Json(new { State = 0, Message = e.Message});
|
||
}
|
||
return Json(new { State = 1, Message = yzm.id.ToString() });
|
||
}
|
||
else
|
||
{
|
||
//http://112.35.1.155:1992/sms/norsubmit
|
||
string ydhttp = commonbll.getParm_Value("ydhttp", "http://112.35.1.155:1992/sms/tmpsubmit", "移动短信地址");
|
||
var req = new Models.duanxin.msend();
|
||
req.ecName = commonbll.getParm_Value("yddxqymc", "德州市德城区疾病预防控制中心", "企业名称");
|
||
req.apId = commonbll.getParm_Value("yddxapId", "jkoa", "接口账号用户名");
|
||
req.mobiles = yzm.ShouJiHao;
|
||
req.sign = commonbll.getParm_Value("yddxsign", "d37CYmrbG", "签名编码");
|
||
req.templateId = "2c2e4092e23f432097dadf5672645ca6";
|
||
req.addSerial = "";
|
||
|
||
string[] parms = new string[1];
|
||
parms[0] = yzm.smscode;
|
||
req.parms = Newtonsoft.Json.JsonConvert.SerializeObject(parms);
|
||
var md5 = MD5.Create();
|
||
//secretKey
|
||
var bs = md5.ComputeHash(Encoding.UTF8.GetBytes(req.ecName + req.apId + commonbll.getParm_Value("yddxsecretKey", "a7551898", "短信接口密码") + req.templateId + req.mobiles + req.parms + req.sign));
|
||
var sb = new StringBuilder();
|
||
foreach (byte b in bs)
|
||
{
|
||
sb.Append(b.ToString("x2"));
|
||
}
|
||
req.mac = sb.ToString().ToLower();
|
||
WebClient wc = new WebClient();
|
||
string upstr = Newtonsoft.Json.JsonConvert.SerializeObject(req);
|
||
upstr = upstr.Replace("parms", "params");
|
||
//new {params }
|
||
//upstr.Insert(upstr.Length-1,",")
|
||
byte[] resp = wc.UploadData(ydhttp, System.Text.Encoding.UTF8.GetBytes(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(upstr))));
|
||
var nres = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.duanxin.nrecive>(System.Text.Encoding.UTF8.GetString(resp));
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(System.Text.Encoding.UTF8.GetString(resp));
|
||
return Json(new { State = 1, Message = yzm.id.ToString() });
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Json(new { State = 0, Message = "请输入正确的手机号码!" });
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 后台预约列表信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public ActionResult YYList()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取预约列表
|
||
/// </summary>
|
||
/// <param name="page"></param>
|
||
/// <param name="pagesize"></param>
|
||
/// <param name="xm"></param>
|
||
/// <param name="yyrq"></param>
|
||
/// <param name="yylx"></param>
|
||
/// <returns></returns>
|
||
public JsonResult getYYList(int page, int pagesize, string xm, string yyrq, string yylx, string jgid)
|
||
{
|
||
int ijgid = 0;
|
||
if (!int.TryParse(jgid, out ijgid))
|
||
{
|
||
ijgid = 0;
|
||
}
|
||
var user = Session["loginUser"] as ERPUser;
|
||
var bll = new MedicalAppointmentBll();
|
||
int count = bll.getyyCount(xm, yyrq, yylx, Common.Global.jgid, ijgid);
|
||
var list = bll.getYYList(xm, yyrq, yylx, page, pagesize, Common.Global.jgid, ijgid);
|
||
return Json(new { Total = count, Rows = list });
|
||
}
|
||
|
||
/// <summary>
|
||
/// 取消预约列表信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public ActionResult YYList2()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取取消预约列表
|
||
/// </summary>
|
||
/// <param name="page"></param>
|
||
/// <param name="pagesize"></param>
|
||
/// <param name="xm"></param>
|
||
/// <param name="yyrq"></param>
|
||
/// <param name="yylx"></param>
|
||
/// <returns></returns>
|
||
public JsonResult getYYList2(int page, int pagesize, string xm)
|
||
{
|
||
var bll = new MedicalAppointmentBll();
|
||
int count = bll.getqxyyCount(xm);
|
||
var list = bll.getYYList2(xm, page, pagesize);
|
||
|
||
List<MedicalAppointment> list2 = new List<MedicalAppointment>();
|
||
foreach (var model in list)
|
||
{
|
||
var m = Newtonsoft.Json.JsonConvert.DeserializeObject<MedicalAppointment>(model.yyxx);
|
||
m.ATime = model.qxsj;
|
||
list2.Add(m);
|
||
}
|
||
return Json(new { Total = count, Rows = list2 });
|
||
}
|
||
|
||
public JsonResult dcyy(string xm, string yyrq, string yylx, string jgid)
|
||
{
|
||
try
|
||
{
|
||
var bll = new MedicalAppointmentBll();
|
||
DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(Newtonsoft.Json.JsonConvert.SerializeObject(bll.getYYListDT(xm, yyrq, yylx, jgid)));
|
||
string filename = Guid.NewGuid().ToString("N") + ".xlsx";
|
||
string path = Server.MapPath("~/exp/");
|
||
if (!System.IO.Directory.Exists(path))
|
||
{
|
||
System.IO.Directory.CreateDirectory(path);
|
||
}
|
||
xiaoy.Excel.ExcelFile.SetData(dt, path + filename, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes);
|
||
string rpath = Url.Content("~/exp/" + filename);
|
||
return Json(new { State = 1, Message = rpath });
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return Json(new { State = 0, Message = ex.Message });
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 日期段是否可以预约
|
||
/// </summary>
|
||
/// <param name="rq"></param>
|
||
/// <param name="endtime"></param>
|
||
/// <returns></returns>
|
||
[AllowAnonymous]
|
||
public JsonResult canSelected(string rq, string endtime, string jgid, string CYFA)
|
||
{
|
||
return Json(new MedicalAppointmentBll().canSelected(rq, endtime, jgid, CYFA), JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 微信缴费页面
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[AllowAnonymous]
|
||
public ActionResult JiaoFei()
|
||
{
|
||
if (Session["openuser"] == null || Session["openuser"].ToString() == "")
|
||
{
|
||
string code = Request.QueryString["code"];
|
||
if (string.IsNullOrEmpty(code))
|
||
{
|
||
return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.AppId +
|
||
"&redirect_uri=" + Request.Url.AbsoluteUri +
|
||
"&response_type=code&scope=snsapi_base#wechat_redirect");
|
||
}
|
||
string openidstr = GetOAuthOpenId(code);
|
||
var openid = Newtonsoft.Json.JsonConvert.DeserializeObject<OAuthopenid>(openidstr);
|
||
Session["openuser"] = openid.openid;
|
||
HttpCookie hc = new HttpCookie("openuser");
|
||
hc.Value = openid.openid;
|
||
Response.Cookies.Add(hc);
|
||
}
|
||
ViewBag.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp();
|
||
ViewBag.nonceStr = Guid.NewGuid().ToString("N");
|
||
string[] ArrayList = { "jsapi_ticket=" + Common.Global.jsapi_ticket, "timestamp=" + ViewBag.timeStamp, "noncestr=" + ViewBag.nonceStr, "url=" + Request.Url.AbsoluteUri.Split('#')[0] };
|
||
Array.Sort(ArrayList);
|
||
string signature = string.Join("&", ArrayList);
|
||
var sha1 = System.Security.Cryptography.SHA1.Create();
|
||
signature = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signature))).Replace("-", ""); //对该字符串进行sha1加密
|
||
signature = signature.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理
|
||
ViewBag.signature = signature;
|
||
return View();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 支付消息接收
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[AllowAnonymous]
|
||
|
||
public string notify()
|
||
{
|
||
var loger = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||
StreamReader sr = new StreamReader(Request.InputStream);
|
||
string str = sr.ReadToEnd();
|
||
sr.Close();
|
||
loger.Info(str);
|
||
WxPayAPI.WxPayData pdata = new WxPayAPI.WxPayData();
|
||
pdata.FromXml(str);
|
||
if (pdata.GetValue("result_code").ToString() == "SUCCESS")
|
||
{
|
||
|
||
loger.Info("Success");
|
||
string id = pdata.GetValue("out_trade_no").ToString();
|
||
loger.Info(id);
|
||
WxPayAPI.WxPayData rdata = new WxPayAPI.WxPayData();
|
||
rdata.SetValue("return_msg", "");
|
||
rdata.SetValue("return_code", "SUCCESS");
|
||
//
|
||
MedicalAppointmentBll bll = new MedicalAppointmentBll();
|
||
bll.UpdateZfzt(id);
|
||
return rdata.ToXml();
|
||
}
|
||
else
|
||
{
|
||
WxPayAPI.WxPayData rdata = new WxPayAPI.WxPayData();
|
||
rdata.SetValue("return_msg", "");
|
||
rdata.SetValue("return_code", "SUCCESS");
|
||
return rdata.ToXml();
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检查体检缴费状态
|
||
/// </summary>
|
||
/// <param name="tm">体检条码</param>
|
||
/// <returns></returns>
|
||
[AllowAnonymous]
|
||
public JsonResult checktjjf(string tm, string lx)
|
||
{
|
||
var bll = new BLL.weixinBll();
|
||
|
||
return Json(bll.checktjjf(tm, lx));
|
||
}
|
||
|
||
[Filter.QianTaiAuthorize]
|
||
[AllowAnonymous]
|
||
public ActionResult tjjf(string id)
|
||
{
|
||
if (Session["openuser"] == null || Session["openuser"].ToString() == "")
|
||
{
|
||
string code = Request.QueryString["code"];
|
||
if (string.IsNullOrEmpty(code))
|
||
{
|
||
return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.AppId +
|
||
"&redirect_uri=" + Request.Url.AbsoluteUri +
|
||
"&response_type=code&scope=snsapi_base#wechat_redirect");
|
||
}
|
||
string openidstr = GetOAuthOpenId(code);
|
||
var openid = Newtonsoft.Json.JsonConvert.DeserializeObject<OAuthopenid>(openidstr);
|
||
Session["openuser"] = openid.openid;
|
||
HttpCookie hc = new HttpCookie("openuser");
|
||
hc.Value = openid.openid;
|
||
Response.Cookies.Add(hc);
|
||
}
|
||
ViewBag.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp();
|
||
ViewBag.nonceStr = Guid.NewGuid().ToString("N");
|
||
string[] ArrayList = { "jsapi_ticket=" + Common.Global.jsapi_ticket, "timestamp=" + ViewBag.timeStamp, "noncestr=" + ViewBag.nonceStr, "url=" + Request.Url.AbsoluteUri.Split('#')[0] };
|
||
Array.Sort(ArrayList);
|
||
string signature = string.Join("&", ArrayList);
|
||
var sha1 = System.Security.Cryptography.SHA1.Create();
|
||
signature = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signature))).Replace("-", ""); //对该字符串进行sha1加密
|
||
signature = signature.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理
|
||
ViewBag.signature = signature;
|
||
var m = new BLL.chargeBll().getModel(id);
|
||
return View(m);
|
||
}
|
||
[Filter.QianTaiAuthorize]
|
||
[AllowAnonymous]
|
||
public ActionResult ymjf(string id)
|
||
{
|
||
if (Session["openuser"] == null || Session["openuser"].ToString() == "")
|
||
{
|
||
string code = Request.QueryString["code"];
|
||
if (string.IsNullOrEmpty(code))
|
||
{
|
||
return Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + Common.Global.AppId +
|
||
"&redirect_uri=" + Request.Url.AbsoluteUri +
|
||
"&response_type=code&scope=snsapi_base#wechat_redirect");
|
||
}
|
||
string openidstr = GetOAuthOpenId(code);
|
||
var openid = Newtonsoft.Json.JsonConvert.DeserializeObject<OAuthopenid>(openidstr);
|
||
Session["openuser"] = openid.openid;
|
||
HttpCookie hc = new HttpCookie("openuser");
|
||
hc.Value = openid.openid;
|
||
Response.Cookies.Add(hc);
|
||
}
|
||
ViewBag.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp();
|
||
ViewBag.nonceStr = Guid.NewGuid().ToString("N");
|
||
string[] ArrayList = { "jsapi_ticket=" + Common.Global.jsapi_ticket, "timestamp=" + ViewBag.timeStamp, "noncestr=" + ViewBag.nonceStr, "url=" + Request.Url.AbsoluteUri.Split('#')[0] };
|
||
Array.Sort(ArrayList);
|
||
string signature = string.Join("&", ArrayList);
|
||
var sha1 = System.Security.Cryptography.SHA1.Create();
|
||
signature = BitConverter.ToString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(signature))).Replace("-", ""); //对该字符串进行sha1加密
|
||
signature = signature.ToLower();//对字符串中的字母部分进行小写转换,非字母字符不作处理
|
||
ViewBag.signature = signature;
|
||
var m = new BLL.chargeBll().getModel(id);
|
||
return View(m);
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
[Filter.QianTaiAuthorize]
|
||
public JsonResult chargeZF(string id)
|
||
{
|
||
chargeBll bll = new chargeBll();
|
||
var zf = new Global.WxZiFu();
|
||
string zfid = WxPayAPI.WxPayApi.GenerateOutTradeNo();
|
||
var m = bll.getModel(id);
|
||
if (m.status == "已缴费")
|
||
{
|
||
return Json(new { State = 0, Message = "已经缴费不能重复缴费" });
|
||
}
|
||
if (!string.IsNullOrEmpty(m.zfid))
|
||
{
|
||
zfid = m.zfid;
|
||
}
|
||
//填充微信订单号
|
||
bll.UpdateZfCode(id, zfid);
|
||
//WxPayAPI.JsApiPay jspay = new WxPayAPI.JsApiPay();
|
||
WxPayAPI.WxPayData payData = new WxPayAPI.WxPayData();
|
||
payData.SetValue("device_info", "WXWEB");
|
||
payData.SetValue("body", m.person + m.type);
|
||
payData.SetValue("attach", m.type);
|
||
payData.SetValue("out_trade_no", zfid);
|
||
payData.SetValue("total_fee", ((int)(m.money * 100)).ToString());
|
||
payData.SetValue("spbill_create_ip", Request.UserHostAddress);
|
||
payData.SetValue("trade_type", "JSAPI");
|
||
payData.SetValue("openid", Session["openuser"].ToString());
|
||
payData.SetValue("notify_url", WxPayAPI.WxPayConfig.NOTIFY_URL_Charge);
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(payData.ToXml());
|
||
var pdata = WxPayAPI.WxPayApi.UnifiedOrder(payData);
|
||
//记录支付日志
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("UnifiedOrder" + pdata.ToXml());
|
||
var jsdata = new WxPayAPI.WxPayData();
|
||
//即最后参与签名的参数有appId, timeStamp, nonceStr, package, signType
|
||
jsdata.SetValue("appId", zf.appId = Common.Global.AppId);
|
||
jsdata.SetValue("timeStamp", zf.timeStamp = WxPayAPI.WxPayApi.GenerateTimeStamp());
|
||
jsdata.SetValue("nonceStr", zf.nonceStr = Guid.NewGuid().ToString("N"));
|
||
jsdata.SetValue("package", zf.package = "prepay_id=" + pdata.GetValue("prepay_id"));
|
||
jsdata.SetValue("signType", zf.signType = "MD5");
|
||
zf.paySign = jsdata.MakeSign();
|
||
zf.State = 1;
|
||
return Json(zf);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 支付消息接收
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[AllowAnonymous]
|
||
|
||
public string notify_Charge()
|
||
{
|
||
var loger = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||
StreamReader sr = new StreamReader(Request.InputStream);
|
||
string str = sr.ReadToEnd();
|
||
sr.Close();
|
||
loger.Info(str);
|
||
WxPayAPI.WxPayData pdata = new WxPayAPI.WxPayData();
|
||
pdata.FromXml(str);
|
||
if (pdata.GetValue("result_code").ToString() == "SUCCESS")
|
||
{
|
||
|
||
loger.Info("Success");
|
||
string id = pdata.GetValue("out_trade_no").ToString();
|
||
loger.Info(id);
|
||
WxPayAPI.WxPayData rdata = new WxPayAPI.WxPayData();
|
||
rdata.SetValue("return_msg", "");
|
||
rdata.SetValue("return_code", "SUCCESS");
|
||
//
|
||
chargeBll bll = new chargeBll();
|
||
bll.UpdateZfzt(id);
|
||
return rdata.ToXml();
|
||
}
|
||
else
|
||
{
|
||
WxPayAPI.WxPayData rdata = new WxPayAPI.WxPayData();
|
||
rdata.SetValue("return_msg", "");
|
||
rdata.SetValue("return_code", "SUCCESS");
|
||
return rdata.ToXml();
|
||
}
|
||
|
||
}
|
||
[HttpPost]
|
||
[AllowAnonymous]
|
||
//取消预约
|
||
public string qxyy(string id)
|
||
{
|
||
if (Session["openuser"] == null)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "只能在微信平台取消!" });
|
||
}
|
||
if (string.IsNullOrEmpty(id))
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "没有查到预约信息!" });
|
||
}
|
||
var yyxx = new DAL.MedicalAppointmentDal().GetModel(id);
|
||
if (yyxx == null)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "没有查到预约信息!" });
|
||
}
|
||
if (yyxx.status == 1)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "已经登记的预约不能取消!" });
|
||
}
|
||
if (yyxx.CYFA == 3 && yyxx.ZFZT == 1)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "已经支付的药品从业不能取消!" });
|
||
}
|
||
try
|
||
{
|
||
new DAL.MedicalAppointmentDal().qxyy(id, Session["openuser"].ToString(), Request.UserHostAddress, Newtonsoft.Json.JsonConvert.SerializeObject(yyxx));
|
||
|
||
var openuser = Session["openuser"].ToString();
|
||
if (!string.IsNullOrEmpty(openuser))
|
||
{
|
||
try
|
||
{
|
||
Models.tjjg jg = new DAL.weixinDal().getJiGouByID(yyxx.jgid);
|
||
var data = new
|
||
{
|
||
touser = openuser,
|
||
template_id = "EzCx3uU7Vp7REX1anQ_vbI1r7OhZGGnj3ZIhWm2MRFU",
|
||
url = "http://dc.51csharp.com/",
|
||
data = new
|
||
{
|
||
first = new { value = "您好,您预约的体检已取消成功。", color = "#173177" },
|
||
keyword1 = new { value = yyxx.xingMing, color = "#173177" },
|
||
keyword2 = new { value = jg.jgmc, color = "#173177" },
|
||
keyword3 = new { value = yyxx.ADate.ToString("yyyy-MM-dd"), color = "#173177" },
|
||
remark = new { value = "期待您的下次预约。", color = "#173177" },
|
||
}
|
||
};
|
||
WebClient wc = new WebClient();
|
||
wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessToken.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data)));
|
||
}
|
||
catch { }
|
||
}
|
||
|
||
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "取消成功!" });
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = ex.Message });
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 判断企业是否可以在疾控体检
|
||
/// </summary>
|
||
/// <param name="qy"></param>
|
||
/// <returns></returns>
|
||
[AllowAnonymous]
|
||
public JsonResult sfkyyqy(string qy)
|
||
{
|
||
return Json(new BLL.weixinBll().sfkyyqy(qy));
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
public ActionResult telme()
|
||
{
|
||
//wtai://wp//mc;0534-2267110
|
||
return Redirect("tel:0534-2267110");
|
||
}
|
||
|
||
|
||
[AllowAnonymous]
|
||
public string notify_alipay()
|
||
{
|
||
|
||
SortedDictionary<string, string> sPara = GetRequestPost();
|
||
foreach (var s in sPara)
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(s.Key + "\t" + s.Value);
|
||
}
|
||
if (sPara.Count > 0)//判断是否有带返回参数
|
||
{
|
||
//Notify aliNotify = new Notify();
|
||
Notify aliNotify = new Notify(Com.Alipay.Config.charset, Com.Alipay.Config.sign_type, Com.Alipay.Config.pid, Com.Alipay.Config.mapiUrl, Com.Alipay.Config.alipay_public_key);
|
||
|
||
//对异步通知进行验签
|
||
bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]);
|
||
//对验签结果
|
||
//bool isSign = Aop.Api.Util.AlipaySignature.RSACheckV2(sPara, Config.alipay_public_key ,Config.charset,Config.sign_type,false );
|
||
|
||
if (verifyResult && CheckParams()) //验签成功 && 关键业务参数校验成功
|
||
{
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
//请在这里加上商户的业务逻辑程序代码
|
||
|
||
|
||
//——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
|
||
//获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
|
||
|
||
//商户订单号
|
||
string out_trade_no = Request.Form["out_trade_no"];
|
||
|
||
|
||
//支付宝交易号
|
||
string trade_no = Request.Form["trade_no"];
|
||
|
||
//交易状态
|
||
//在支付宝的业务通知中,只有交易通知状态为TRADE_SUCCESS或TRADE_FINISHED时,才是买家付款成功。
|
||
string trade_status = Request.Form["trade_status"];
|
||
if (trade_status == "TRADE_SUCCESS" || trade_status == "TRADE_FINISHED")
|
||
{
|
||
//MedicalAppointmentBll bll = new MedicalAppointmentBll();
|
||
//bll.UpdateZfzt(out_trade_no,"支付宝");
|
||
chargeBll bll = new chargeBll();
|
||
bll.UpdateZfzt(out_trade_no, "支付宝");
|
||
}
|
||
|
||
//判断是否在商户网站中已经做过了这次通知返回的处理
|
||
//如果没有做过处理,那么执行商户的业务程序
|
||
//如果有做过处理,那么不执行商户的业务程序
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("success");
|
||
return "success"; //请不要修改或删除
|
||
|
||
//——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
}
|
||
else//验证失败
|
||
{
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("fail");
|
||
|
||
return "fail";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
|
||
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info("无通知参数");
|
||
return "无通知参数";
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 对支付宝异步通知的关键参数进行校验
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool CheckParams()
|
||
{
|
||
bool ret = true;
|
||
|
||
//获得商户订单号out_trade_no
|
||
string out_trade_no = Request.Form["out_trade_no"];
|
||
//TODO 商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号,
|
||
|
||
//获得支付总金额total_amount
|
||
string total_amount = Request.Form["total_amount"];
|
||
//TODO 判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
|
||
|
||
//获得卖家账号seller_email
|
||
string seller_email = Request.Form["seller_email"];
|
||
//TODO 校验通知中的seller_email(或者seller_id) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id / seller_email)
|
||
|
||
//获得调用方的appid;
|
||
//如果是非授权模式,appid是商户的appid;如果是授权模式(token调用),appid是系统商的appid
|
||
string app_id = Request.Form["app_id"];
|
||
//TODO 验证app_id是否是调用方的appid;。
|
||
|
||
//验证上述四个参数,完全吻合则返回参数校验成功
|
||
return ret;
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取支付宝POST过来通知消息,并以“参数名=参数值”的形式组成数组
|
||
/// </summary>
|
||
/// <returns>request回来的信息组成的数组</returns>
|
||
public SortedDictionary<string, string> GetRequestPost()
|
||
{
|
||
int i = 0;
|
||
SortedDictionary<string, string> sArray = new SortedDictionary<string, string>();
|
||
NameValueCollection coll;
|
||
//Load Form variables into NameValueCollection variable.
|
||
coll = Request.Form;
|
||
|
||
// Get names of all forms into a string array.
|
||
String[] requestItem = coll.AllKeys;
|
||
|
||
for (i = 0; i < requestItem.Length; i++)
|
||
{
|
||
sArray.Add(requestItem[i], Request.Form[requestItem[i]]);
|
||
}
|
||
|
||
return sArray;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改预约日期
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <param name="yyrq"></param>
|
||
/// <returns></returns>
|
||
public JsonResult xgyyrq(string id, string yyrq)
|
||
{
|
||
var erpUser = Session["loginUser"] as Models.ERPUser;
|
||
return Json(new weixinBll().xgyyrq(id, yyrq,erpUser.ID));
|
||
}
|
||
|
||
[HttpGet]
|
||
public ActionResult impYYXX()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
public string impYYXX(string yyrq)
|
||
{
|
||
if (Request.Files.Count == 0)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = "没有要处理的文件" });
|
||
}
|
||
else
|
||
{
|
||
try
|
||
{
|
||
string path = Server.MapPath("~/exec/");
|
||
|
||
if (!Directory.Exists(path))
|
||
{
|
||
Directory.CreateDirectory(path);
|
||
}
|
||
string strName = Guid.NewGuid().ToString("N") + Request.Files[0].FileName.Substring(Request.Files[0].FileName.LastIndexOf("."));
|
||
Request.Files[0].SaveAs(path+strName);
|
||
|
||
//DataTable dtx = MiniExcel.QueryAsDataTable(path, useHeaderRow: true);
|
||
|
||
//DataTable[] dts = { dtx };// xiaoy.Excel.ExcelFile.GetData(path, xiaoy.Excel.ExcelVersion.Excel12, xiaoy.Excel.HDRType.Yes, false);
|
||
System.Data.DataTable dtx = ZWL.Common.DataToExcel.Reader_Excel(path, strName);
|
||
System.Data.DataTable[] dts = { dtx };
|
||
var bll = new BLL.OccupationDataImportObjectBll();
|
||
|
||
for (int i = 0; i < dts[0].Rows.Count; i++)
|
||
{
|
||
var yybll = new BLL.MedicalAppointmentBll();
|
||
|
||
var m = new Models.MedicalAppointment
|
||
{
|
||
IDCard = dts[0].Rows[i]["身份证"].ToString(),
|
||
xingMing = dts[0].Rows[i]["姓名"].ToString(),
|
||
Mobile = dts[0].Rows[i]["手机号"].ToString(),
|
||
MType = 1,
|
||
QYXX = "批量导入预约",
|
||
CYFAName = dts[0].Rows[i]["体检方案"].ToString(),
|
||
ADate = DateTime.Parse(yyrq),
|
||
ATime = DateTime.Now
|
||
};
|
||
|
||
if (m.CYFAName == "公共场所")
|
||
{
|
||
m.CYFA = 1;
|
||
}
|
||
else if (m.CYFAName == "食品从业")
|
||
{
|
||
m.CYFA = 2;
|
||
}
|
||
else if (m.CYFAName == "药品从业")
|
||
{
|
||
m.CYFA = 3;
|
||
}
|
||
else
|
||
{
|
||
m.CYFA = 0;
|
||
}
|
||
m.jgid = Common.Global.jgid;
|
||
if (string.IsNullOrEmpty(m.IDCard) || string.IsNullOrEmpty(m.xingMing) || string.IsNullOrEmpty(m.Mobile) || string.IsNullOrEmpty(m.CYFAName))
|
||
continue;
|
||
yybll.WXYY(m, 4);
|
||
}
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "导入预约信息成功!" });
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = ex.Message });
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 读取excel
|
||
/// </summary>
|
||
/// <param name="path1"></param>
|
||
/// <param name="Excel_Name"></param>
|
||
/// <returns></returns>
|
||
/* public System.Data.DataTable Reader_Excel(string path1, string Excel_Name)
|
||
{
|
||
try
|
||
{
|
||
//实例化DataTable来存放数据
|
||
System.Data.DataTable dt = new System.Data.DataTable();
|
||
string fileName = path1 + Excel_Name;
|
||
string sheetName = Excel_Name;//Excel的工作表名称
|
||
bool isColumnName = true;//判断第一行是否为标题列
|
||
IWorkbook workbook;//创建一个工作薄接口
|
||
string fileExt = Path.GetExtension(fileName).ToLower();//获取文件的拓展名
|
||
//创建一个文件流
|
||
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
|
||
{
|
||
if (fileExt == ".xls" || fileExt == ".xlsx")//xlsx
|
||
{
|
||
//.xls ,xlsx
|
||
//XSSFWorkbook workbook = new XSSFWorkbook(file);
|
||
//HSSFWorkbook workbook = new HSSFWorkbook(file);
|
||
workbook = new HSSFWorkbook(fs);
|
||
}
|
||
else
|
||
{
|
||
workbook = null;
|
||
}
|
||
|
||
//实例化sheet
|
||
ISheet sheet = null;
|
||
if (sheetName != null && sheetName != "")//判断是否存在sheet
|
||
{
|
||
sheet = workbook.GetSheet(sheetName);
|
||
if (sheet == null)
|
||
{
|
||
sheet = workbook.GetSheetAt(0);//从第一个开始读取,0位索引
|
||
}
|
||
else
|
||
{
|
||
sheet = workbook.GetSheetAt(0);
|
||
}
|
||
}
|
||
|
||
//获取表头
|
||
IRow header = sheet.GetRow(sheet.FirstRowNum);
|
||
int startRow = 0;//数据的第一行索引
|
||
if (isColumnName)//表示第一行是列名
|
||
{
|
||
startRow = sheet.FirstRowNum + 1;//数据从第二行开始读
|
||
|
||
//遍历表的第一行,即所有的列名
|
||
for (int i = header.FirstCellNum; i < header.LastCellNum; i++)
|
||
{
|
||
ICell cell = header.GetCell(i);
|
||
if (cell != null)
|
||
{
|
||
//获取列名的值
|
||
string cellValue = cell.ToString();
|
||
if (cellValue != null)
|
||
{
|
||
DataColumn col = new DataColumn(cellValue);
|
||
dt.Columns.Add(col);
|
||
}
|
||
else
|
||
{
|
||
DataColumn col = new DataColumn();
|
||
dt.Columns.Add(col);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//读取数据
|
||
for (int i = startRow; i <= sheet.LastRowNum; i++)
|
||
{
|
||
IRow row = sheet.GetRow(i);
|
||
if (row == null)
|
||
{
|
||
continue;
|
||
}
|
||
DataRow dr = dt.NewRow();
|
||
for (int j = row.FirstCellNum; j < row.LastCellNum; j++)
|
||
{
|
||
if (row.GetCell(j) != null)
|
||
{
|
||
dr[j] = row.GetCell(j).ToString();
|
||
}
|
||
}
|
||
dt.Rows.Add(dr);
|
||
}
|
||
return dt;
|
||
}
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
throw e;
|
||
}
|
||
}*/
|
||
public ActionResult BNYYWX()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据日期获取不可预约日期列表
|
||
/// </summary>
|
||
/// <param name="page"></param>
|
||
/// <param name="pagesize"></param>
|
||
/// <param name="key"></param>
|
||
/// <returns></returns>
|
||
public JsonResult getBKYYList(int page, int pagesize, string key)
|
||
{
|
||
var bll = new BLL.MedicalAppointmentBll();
|
||
int count = bll.getBKYYCount(key);
|
||
var Rows = bll.getBKYYList(page, pagesize, key);
|
||
return Json(new { Total = count, Rows = Rows });
|
||
}
|
||
|
||
public JsonResult saveBKYYRQ(Models.BKYYRQ bkyy)
|
||
{
|
||
return Json(new BLL.MedicalAppointmentBll().saveBKYYRQ(bkyy));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据id删除不可预约日期
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
public JsonResult delRqlist(string id)
|
||
{
|
||
if (string.IsNullOrEmpty(id))
|
||
return Json(null);
|
||
return Json(new BLL.MedicalAppointmentBll().delRqlist(id));
|
||
}
|
||
|
||
public ActionResult jgkyyrswh()
|
||
{
|
||
return View();
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
public string getjg()
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new DAL.weixinDal().getyyjg());
|
||
}
|
||
|
||
public string gettjlx()
|
||
{
|
||
var tjfa = new MedicalSchemeMaintainBll().GetAllList();
|
||
tjfa.Insert(0, new MedicalSchemeMaintainModel { id = 0, medical_scheme = "请选择" });
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(tjfa);
|
||
}
|
||
|
||
public string getjgyyrs(string jgid, string tjlx)
|
||
{
|
||
if (string.IsNullOrEmpty(jgid))
|
||
{
|
||
jgid = "0";
|
||
}
|
||
if (string.IsNullOrEmpty(tjlx))
|
||
{
|
||
tjlx = "0";
|
||
}
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { Rows = new DAL.weixinDal().getjgyyrs(jgid, tjlx) });
|
||
}
|
||
|
||
public string saveyyrs(dccdc.Models.set_jg_lx_kyyrs setyyrs)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new DAL.weixinDal().saveyrs(setyyrs));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据id删除可预约人数
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
public JsonResult delKyywh(string id)
|
||
{
|
||
if (string.IsNullOrEmpty(id))
|
||
return Json(null);
|
||
return Json(new DAL.weixinDal().delKyywh(id));
|
||
}
|
||
|
||
public ActionResult rgyy()
|
||
{
|
||
var tjfa = new MedicalSchemeMaintainBll().GetAllList();
|
||
tjfa.Insert(0, new MedicalSchemeMaintainModel { id = 0, medical_scheme = "请选择体检类型" });
|
||
ViewData["tjfn"] = new SelectList(tjfa, "id", "medical_scheme");
|
||
return View();
|
||
}
|
||
|
||
public string savergyy(MedicalAppointment ma)
|
||
{
|
||
try
|
||
{
|
||
var dal = new MedicalAppointmentBll();
|
||
ma.ATime = DateTime.Now;
|
||
ma.MType = 5;
|
||
ma.QYXX = "手工预约";
|
||
ma.jgid = Common.Global.jgid;
|
||
if (ma.CYFA == 1)
|
||
{
|
||
ma.CYFAName = "公共场所";
|
||
}
|
||
else if (ma.CYFA == 2)
|
||
{
|
||
ma.CYFAName = "食品从业";
|
||
}
|
||
else
|
||
{
|
||
ma.CYFAName = "药品从业";
|
||
}
|
||
dal.WXYY(ma, 5);
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 1, Message = "预约成功!" });
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { State = 0, Message = ex.Message });
|
||
}
|
||
|
||
}
|
||
|
||
internal void sendtxmsg(jkztxsz sz, ProfessionalExamRegisterModel dtx)
|
||
{
|
||
var openuser = new BLL.weixinBll().getopenuser(dtx.openid);
|
||
if (openuser != null && openuser.subscribe == 1)
|
||
{
|
||
var data = new
|
||
{
|
||
touser = openuser.openid,
|
||
template_id = "fw-h8dHjUQq9myTiqdSekNJu4-_QflQtWsz6DuOJx78",
|
||
url = new BLL.Common().getParm_Value("wxyyym", "http://dc.51csharp.com/", "微信预约域名") + "/dccdc/WeiXin/ChargeResult",// Url.Action("ChargeResult", "WeiXin") + "" ,
|
||
data = new
|
||
{
|
||
first = new { value = "你的健康证明(" + dtx.category + ")即将到期。", color = "#173177" },
|
||
name = new { value = "你的健康证明(" + dtx.category + ")", color = "#173177" },
|
||
expDate = new { value = DateTime.Parse(dtx.register_date).AddYears(1).AddDays(-1).ToString("yyyy-MM-dd"), color = "#173177" },
|
||
remark = new { value = "请进行新一年度的从业健康体检。。", color = "#173177" },
|
||
}
|
||
};
|
||
|
||
WebClient wc = new WebClient();
|
||
wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessToken.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data)));
|
||
}
|
||
}
|
||
|
||
[AllowAnonymous]
|
||
public ActionResult xtwh()
|
||
{
|
||
return View();
|
||
}
|
||
}
|
||
} |