diff --git a/DSWeb/Areas/Dispatch/Controllers/WxAppController.cs b/DSWeb/Areas/Dispatch/Controllers/WxAppController.cs index 1bbc74cc..3ceb4ae4 100644 --- a/DSWeb/Areas/Dispatch/Controllers/WxAppController.cs +++ b/DSWeb/Areas/Dispatch/Controllers/WxAppController.cs @@ -14,7 +14,7 @@ using DSWeb.Areas.Dispatch.DB; using DSWeb.Areas.Dispatch.DB_Wx; using DSWeb.Areas.CommMng.DAL; using HcUtility.Comm; - +using System.Data.Entity.Migrations; namespace DSWeb.Areas.Dispatch.Controllers { @@ -31,6 +31,8 @@ namespace DSWeb.Areas.Dispatch.Controllers public string AuthCode { get; set; } } + + //微信小程序专用接口控制器 public class WxAppController : Controller { @@ -1404,5 +1406,80 @@ namespace DSWeb.Areas.Dispatch.Controllers } */ + + #region 方合派车小程序 + + //三个功能 + //1依据司机表验证登陆 + //2 司机查看业务 小程序需要的字段名对应东胜派车管理里的字段 + //提单号、船名航次、提箱场站、装货日期(到时分秒)、派车申请人、装货工厂、装货地址、箱型箱量、件数、重量、体积、货物标识、品名、危品登记、危品编号 + //、集装箱明细(包含箱型、箱号、封号)司机注意事项、放在附件管理里的司机携带的提箱单和罐证等文件(需要司机可以下载) + //3 录入费用列表 提交后向待办事务表中添加 + // 如重复添加则更新 + + public class DriverLoginInfo : LoginInfo + { + public string TEL { get; set; } + } + + [HttpPost] + public ActionResult DriverFirstLogin(DriverLoginInfo logininfo) + { + var cdc = new DSWeb.Common.DB.CommonDataContext(); + + try + { + //1首先根据手机号和密码 判断是否存在 如不存在 返回否 结束 + var DriverList = cdc.tMsWlDriver.Where(x => x.Mobile== logininfo.TEL && x.PassWord== logininfo.password).ToList(); + + if (DriverList == null || DriverList.Count > 0) { + return Json(new { ErrorCode = 500, Message = "电话或密码错误" }, JsonRequestBehavior.AllowGet); + } + + var Driver = DriverList[0]; + + var obj = getOpenId(logininfo.AuthCode); + + if (obj.errcode == 0) + { + + var userWxList = cdc.tMsWlDriver.Where(x => x.OPENID == obj.openid && x.DrvCode!= Driver.DrvCode).ToList(); + if (userWxList.Count > 0) + { + //将所有使用这个openid的user数据的openid置为‘’ 然后继续正常操作 + foreach (var item in userWxList) + { + item.OPENID = ""; + cdc.tMsWlDriver.AddOrUpdate(item); + } + + } + + Driver.OPENID = obj.openid; + cdc.tMsWlDriver.AddOrUpdate(Driver); + cdc.SaveChanges(); + + BasicDataRefDAL.SaveLog("", obj.openid, "wxapp", "登录3"); + return Json(new + { + ErrorCode = 0, + Message = "获取成功", + BaseInfo = new { Driver.DrvName, Driver.Mobile, userinfo.companyname, userWx.OPENID } + }, + JsonRequestBehavior.AllowGet); + + } + } + catch (Exception e) + { + BasicDataRefDAL.SaveLog("", e.Message, "wxapp", "登陆错误"); + //log.Debug("wxapp登陆错误:" + e.Message); + } + BasicDataRefDAL.SaveLog("", obj.openid, "wxapp", "登录f"); + return Json(new { ErrorCode = 500, Message = "发生错误" }, JsonRequestBehavior.AllowGet); + } + + + #endregion } } \ No newline at end of file