82 lines
3.0 KiB
C#
82 lines
3.0 KiB
C#
using Ninject;
|
|
using System;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Res;
|
|
using WX.CRM.IBLL.weapp;
|
|
using WX.CRM.WebHelper.Infrastructure;
|
|
|
|
namespace AppletMvcService.Controllers
|
|
{
|
|
public class WxUserInfoSvrController : Controller
|
|
{
|
|
|
|
ValidationErrors errors = new ValidationErrors();
|
|
|
|
//[Inject]
|
|
//private IWEAPP_USERINFO weapp_UserInfo_BL { get; set; }
|
|
|
|
//[Inject]
|
|
//private IRES_CUSTOMER_Q res_Customer_Q_BL { get; set; }
|
|
|
|
//[Inject]
|
|
//private IRES_CUSTOMER res_Customer_BL { get; set; }
|
|
|
|
private readonly IRES_CUSTOMER res_Customer_BL = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMER>();
|
|
private readonly IRES_CUSTOMER_Q res_Customer_Q_BL = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMER_Q>();
|
|
private readonly IWEAPP_USERINFO weapp_UserInfo_BL = NinjectControllerFactory.ninjectKernel.Get<IWEAPP_USERINFO>();
|
|
public JsonResult BindResId(string resId, string openId, decimal resIdVerify)
|
|
{
|
|
try
|
|
{
|
|
var flag = false;
|
|
if (string.IsNullOrWhiteSpace(resId) || string.IsNullOrWhiteSpace(openId))
|
|
{
|
|
errors.Add("参数不能为空!");
|
|
return Json(new { result = flag, msg = errors.Error });
|
|
}
|
|
if (resId.Length != 18 && resId.Length != 11)
|
|
{
|
|
errors.Add("手机号格式不正确!");
|
|
return Json(new { result = flag, msg = errors.Error });
|
|
}
|
|
if (resId.Length == 11 && !Utility.ChekMobile(resId))
|
|
{
|
|
errors.Add("手机号格式不正确!");
|
|
return Json(new { result = flag, msg = errors.Error });
|
|
}
|
|
else
|
|
{
|
|
string resid = WX.CRM.Common.ResUtil.CreateResId(resId);
|
|
if (res_Customer_Q_BL.getResCustomerByResId(resid) == null)
|
|
{
|
|
res_Customer_BL.ResgisterCustomer(resId, resid, "OpenIdBindResId");
|
|
}
|
|
|
|
resId = resid;
|
|
}
|
|
int result = weapp_UserInfo_BL.BindResIdByOpenId(openId, resId, resIdVerify, ref errors);
|
|
if (errors.Count == 0)
|
|
flag = true;
|
|
if (result == 0)
|
|
{
|
|
errors.Add("此客户已被验证绑定!不能再做修改。");
|
|
}
|
|
return Json(new { result = flag, resid = resId, msg = errors.Error });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
return Json(new { result = false, msg = "系统错误:" + ex.ToString() });
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public JsonResult GetUserInfoOrderExtByOpenId(string openId)
|
|
{
|
|
var json = weapp_UserInfo_BL.GetUserInfoOrderExtByOpenId(openId);
|
|
return Json(json);
|
|
}
|
|
}
|
|
} |