三元财务API

CallOutOptController.cs 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using CallCenter.Utility;
  2. using CallCenterApi.Interface.Controllers.Base;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. namespace CallCenterApi.Interface.Controllers
  9. {
  10. public class CallOutOptController : BaseController
  11. {
  12. //外呼判断本地外地以及加前缀返回
  13. public ActionResult GetCallOutprefix(string phone)
  14. {
  15. ActionResult res = NoToken("未知错误,请重新登录");
  16. if (Request.IsAuthenticated)
  17. {
  18. string phone1 = RequestString.ToDBC(RequestString.RemoveNotNumber(WebHelper.NoHtml(phone)));
  19. string tophone = phone1;
  20. string zipcode = ""; string bfix = ""; string wfix = ""; string fix = "";
  21. string userseatgroupid = CurrentUser.UserData.F_SeartGroupID.ToString();
  22. if (userseatgroupid != "" && userseatgroupid != "0")
  23. {
  24. Model.T_Sys_SeatGroup smodel = new BLL.T_Sys_SeatGroup().GetModel(int.Parse(userseatgroupid));
  25. if (smodel != null)
  26. {
  27. zipcode = smodel.F_ZXAtt.Trim();
  28. bfix = smodel.F_WHBDKey.Trim();
  29. wfix = smodel.F_WHWDKey.Trim();
  30. }
  31. }
  32. int zip = GetZipCodeByPhone(phone1, zipcode);
  33. #region
  34. if (zip == 1)
  35. {//手机本地号码
  36. fix = bfix;
  37. }
  38. else if (zip == 2)
  39. {//手机外地号码
  40. fix = wfix;
  41. }
  42. else
  43. {
  44. tophone = phone1.TrimStart('0');
  45. if (zip == 3)
  46. {//本地固话去0加9 比如:988888517,937188888517
  47. fix = bfix;
  48. }
  49. else if (zip == 4)
  50. {//外地固话前加9 比如:9037188888517
  51. fix = wfix;
  52. }
  53. }
  54. #endregion
  55. var obj = new
  56. {
  57. phone = fix + tophone,
  58. fix = fix
  59. };
  60. res = Success("外呼号码加前缀", obj);
  61. }
  62. return res;
  63. }
  64. /// <summary>
  65. /// 根据号码和区号判断号码是否为归属地号码
  66. /// 返回0为分机号或特殊号码
  67. /// 返回1为手机本地号码
  68. /// 返回2为手机外地号码
  69. /// 返回3为固定电话本地号码
  70. /// 返回4为固定电话外地号码
  71. /// </summary>
  72. /// <param name="phone"></param>
  73. /// <param name="zipcode"></param>
  74. /// <returns></returns>
  75. [NonAction]
  76. public int GetZipCodeByPhone(string phone, string zipcode)
  77. {
  78. int res = 0;
  79. if (phone.Trim().Length >= 7)
  80. {
  81. //7位及7位以上是固定电话或手机
  82. //判断是否手机
  83. if (phone.Trim().Length == 11 && phone[0] == '1')
  84. {//号码为11位,首位是1,为手机号
  85. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  86. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList("F_MobileNum='" + phone.Substring(0, 7) + "'").FirstOrDefault();
  87. if (mobileModel != null)
  88. {
  89. if (mobileModel.F_ZipCode.Equals(zipcode))
  90. {
  91. res = 1;
  92. }
  93. else
  94. {
  95. res = 2;
  96. }
  97. }
  98. }
  99. else
  100. {
  101. if (phone.Trim().Length == 11 && phone.Substring(0, 3).Equals(zipcode))
  102. {//号码为11位
  103. //截取前三位区号判断是否本地
  104. bool resbd3 = phone.Substring(0, 3).Equals(zipcode);
  105. //截取前四位区号判断是否本地
  106. bool resbd4 = phone.Substring(0, 4).Equals(zipcode);
  107. if (resbd3 || resbd4)
  108. {
  109. res = 3;
  110. }
  111. else
  112. {
  113. res = 4;
  114. }
  115. }
  116. else if (phone.Trim().Length < 11)
  117. {//号码小于11位,为本地
  118. res = 3;
  119. }
  120. else if (phone.Trim().Length > 11 && phone.Substring(0, 4).Equals(zipcode))
  121. {//号码大于11位,截取前四位区号判断是否本地
  122. res = 3;
  123. }
  124. else
  125. {
  126. res = 4;
  127. }
  128. }
  129. }
  130. return res;
  131. }
  132. }
  133. }