Nav apraksta

CusVipController.cs 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. namespace CallCenterApi.Interface.Controllers.customer
  12. {
  13. public class CusVipController : BaseController
  14. {
  15. private BLL.T_Cus_VipInfo vipinfp=new BLL.T_Cus_VipInfo ();
  16. public ActionResult GetList(string name, string phone
  17. , string remarks, int state = -1)
  18. {
  19. string sql = "and F_IsDelete=0";
  20. DataTable dt = new DataTable();
  21. //string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  22. //string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  23. string strpageindex = RequestString.GetQueryString("page");
  24. int pageindex = 1;
  25. string strpagesize = RequestString.GetQueryString("pagesize");
  26. int pagesize = 10;
  27. if (!string .IsNullOrEmpty (name))
  28. {
  29. sql += " and F_Name like '%" + name + "%' ";
  30. }
  31. if (!string.IsNullOrEmpty(phone))
  32. {
  33. sql += " and F_Phone like '%" + phone + "%' ";
  34. }
  35. if (!string.IsNullOrEmpty(remarks))
  36. {
  37. sql += " and F_Remarks like '%" + remarks + "%' ";
  38. }
  39. if (state>-1)
  40. {
  41. sql += " and F_State ="+ state;
  42. }
  43. if (strpageindex.Trim() != "")
  44. {
  45. pageindex = Convert.ToInt32(strpageindex);
  46. }
  47. if (strpagesize.Trim() != "")
  48. {
  49. pagesize = Convert.ToInt32(strpagesize);
  50. }
  51. int recordCount = 0;
  52. dt = BLL.PagerBLL.GetListPager(
  53. "T_Cus_VipInfo",
  54. "F_ID",
  55. "*",
  56. sql,
  57. "ORDER BY F_AddTime desc",
  58. pagesize,
  59. pageindex,
  60. true,
  61. out recordCount);
  62. var obj = new
  63. {
  64. state = "success",
  65. message = "成功",
  66. rows = dt,
  67. total = recordCount
  68. };
  69. return Content(obj.ToJson());
  70. }
  71. /// <summary>
  72. ///
  73. /// </summary>
  74. /// <returns></returns>
  75. public ActionResult GetVIP()
  76. {
  77. int id = Utils.StrToInt(RequestString.GetQueryString("id"), 0);
  78. if (id != 0)
  79. {
  80. Model.T_Cus_VipInfo vipInfo = vipinfp.GetModel(id );
  81. if (vipInfo != null)
  82. {
  83. return Success("获取成功", vipInfo);
  84. }
  85. else
  86. {
  87. return Error("获取失败");
  88. }
  89. }
  90. else
  91. {
  92. return Error("参数传输失败");
  93. }
  94. }
  95. public ActionResult AddVip(Model.T_Cus_VipInfo vipinfos)
  96. {
  97. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  98. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  99. if (string.IsNullOrEmpty(vipinfos.F_Phone))
  100. return Error("请输入vip电话");
  101. Model.T_Cus_VipInfo model = new Model.T_Cus_VipInfo();
  102. model.F_Name = vipinfos.F_Name;
  103. model.F_Phone = vipinfos.F_Phone;
  104. model.F_Remarks = vipinfos.F_Remarks;
  105. model.F_State = 0;
  106. model.F_AddUser = userModel.F_UserCode ;
  107. model.F_AddTime = DateTime .Now ;
  108. model.F_IsDelete = 0;
  109. int n = vipinfp.Add(model) ;
  110. if (n > 0)
  111. return Success("添加成功");
  112. else
  113. return Error("添加失败");
  114. }
  115. public ActionResult EditVip(Model.T_Cus_VipInfo vipinfos)
  116. {
  117. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  118. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  119. if (vipinfos.F_ID <= 0)
  120. return Error("参数错误");
  121. if (string.IsNullOrEmpty(vipinfos.F_Phone))
  122. return Error("请输入vip电话");
  123. Model.T_Cus_VipInfo model = vipinfp.GetModel (vipinfos.F_ID );
  124. if (model == null)
  125. return Error("该VIP用户不存在");
  126. model.F_Name = vipinfos.F_Name;
  127. model.F_Phone = vipinfos.F_Phone;
  128. model.F_Remarks = vipinfos.F_Remarks;
  129. model.F_State = 0;
  130. model.F_UpdateUser = userModel.F_UserCode;
  131. model.F_UpdateTime = DateTime.Now;
  132. model.F_IsDelete = 0;
  133. bool n = new BLL.T_Cus_VipInfo().Update (model);
  134. if (n )
  135. return Success("修改成功");
  136. else
  137. return Error("修改失败");
  138. }
  139. public ActionResult DeleteVip(string id)
  140. {
  141. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  142. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  143. if (string.IsNullOrEmpty(id))
  144. return Error("请选择vip用户");
  145. string sql = "update T_Cus_VipInfo set F_IsDelete=1,F_DeleteTime="+DateTime .Now + ",F_DeleteUser="+ userModel.F_UserCode + " where F_ID in(" + id.TrimEnd(',') + ")";
  146. if (DbHelperSQL.ExecuteSql(sql) > 0)
  147. {
  148. return Success("设置成功");
  149. }
  150. else
  151. {
  152. return Error("设置失败");
  153. }
  154. }
  155. public ActionResult EditState(string id,int state=0)
  156. {
  157. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  158. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  159. if (string .IsNullOrEmpty (id))
  160. return Error("请选择vip用户");
  161. string sql = "update T_Cus_VipInfo set F_State="+ state + " where F_ID in(" + id.TrimEnd(',') + ")";
  162. if (DbHelperSQL.ExecuteSql(sql) > 0)
  163. {
  164. return Success("设置成功");
  165. }
  166. else
  167. {
  168. return Error("设置失败");
  169. }
  170. }
  171. }
  172. }