| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using CallCenter.Utility;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers
- {
- public class CallOutOptController : BaseController
- {
- // GET: CallOutOpt
- //外呼判断本地外地以及加前缀返回
- [Authority]
- public ActionResult GetCallOutprefix(string phone)
- {
- string phone1 = RequestString.ToDBC(RequestString.RemoveNotNumber(WebHelper.NoHtml(phone)));
- string tophone = phone1;
- string fix = ""; string bfix = ""; string wfix = "";
- string zipcode = Configs.GetValue("CallOutZipCode");
- bfix = Configs.GetValue("CallOutBPre");
- wfix = Configs.GetValue("CallOutWPre");
- int zip = GetZipCodeByPhone(phone1, zipcode);
- if (phone.Trim().Length != 4)
- {
- if (zip == 1)
- {
- fix = bfix;
- }
- else if (zip == 2)
- {
- fix = wfix;
- }
- else
- {
- tophone = phone1.TrimStart('0');
- if (zip == 3)
- {//本地固话去0加9 比如:988888517,937188888517
- fix = bfix;
- }
- else if (zip == 4)
- {//外地固话前加9 比如:9037188888517
- fix = wfix;
- }
- else
- {
- fix = bfix;
- }
- }
- }
- var obj = new
- {
- phone = fix + tophone,
- fix = fix
- };
- return Success("外呼号码加前缀", obj);
- }
- /// <summary>
- /// 根据号码和区号判断号码是否为归属地号码
- /// 返回0为分机号或特殊号码
- /// 返回1为本地号码
- /// 返回2为外地号码
- /// </summary>
- /// <param name="phone"></param>
- /// <param name="zipcode"></param>
- /// <returns></returns>
- [NonAction]
- public int GetZipCodeByPhone(string phone, string zipcode)
- {
- int res = 0;
- if (phone.Trim().Length >= 7)
- {
- //7位及7位以上是固定电话或手机
- //判断是否手机
- if (phone.Trim().Length == 11 && phone[0] == '1')
- {//号码为11位,首位是1,为手机号
- BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
- Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum = '" + phone.Substring(0, 7) + "' and F_IsDelete =0").FirstOrDefault();
- if (mobileModel != null)
- {
- if (mobileModel.F_ZipCode.Equals(zipcode))
- {
- res = 1;
- }
- else
- {
- res = 2;
- }
- }
- }
- else
- {
- if (phone.Trim().Length == 11 && phone.Substring(0, 3).Equals(zipcode))
- {//号码为11位
- //截取前三位区号判断是否本地
- bool resbd3 = phone.Substring(0, 3).Equals(zipcode);
- //截取前四位区号判断是否本地
- bool resbd4 = phone.Substring(0, 4).Equals(zipcode);
- if (resbd3 || resbd4)
- {
- res = 3;
- }
- else
- {
- res = 4;
- }
- }
- else if (phone.Trim().Length < 11)
- {//号码小于11位,为本地
- res = 3;
- }
- else if (phone.Trim().Length > 11 && phone.Substring(0, 4).Equals(zipcode))
- {//号码大于11位,截取前四位区号判断是否本地
- res = 3;
- }
- else
- {
- res = 4;
- }
- }
- }
- return res;
- }
- }
- }
|