| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- using CallCenter.Utility;
- using CallCenterApi.Common;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.customer
- {
- public class CusVipController : BaseController
- {
- private BLL.T_Cus_VipInfo vipinfp=new BLL.T_Cus_VipInfo ();
- public ActionResult GetList(string name, string phone
- , string remarks, int state = -1)
- {
- string sql = "and F_IsDelete=0";
- DataTable dt = new DataTable();
-
- //string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
- //string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- if (!string .IsNullOrEmpty (name))
- {
- sql += " and F_Name like '%" + name + "%' ";
- }
- if (!string.IsNullOrEmpty(phone))
- {
- sql += " and F_Phone like '%" + phone + "%' ";
- }
- if (!string.IsNullOrEmpty(remarks))
- {
- sql += " and F_Remarks like '%" + remarks + "%' ";
- }
- if (state>-1)
- {
- sql += " and F_State ="+ state;
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Cus_VipInfo",
- "F_ID",
- "*",
- sql,
- "ORDER BY F_AddTime desc",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public ActionResult GetVIP()
- {
- int id = Utils.StrToInt(RequestString.GetQueryString("id"), 0);
- if (id != 0)
- {
- Model.T_Cus_VipInfo vipInfo = vipinfp.GetModel(id );
- if (vipInfo != null)
- {
- return Success("获取成功", vipInfo);
- }
- else
- {
- return Error("获取失败");
- }
- }
- else
- {
- return Error("参数传输失败");
- }
- }
- public ActionResult AddVip(Model.T_Cus_VipInfo vipinfos)
- {
- int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (string.IsNullOrEmpty(vipinfos.F_Phone))
- return Error("请输入vip电话");
- Model.T_Cus_VipInfo model = new Model.T_Cus_VipInfo();
- model.F_Name = vipinfos.F_Name;
- model.F_Phone = vipinfos.F_Phone;
- model.F_Remarks = vipinfos.F_Remarks;
- model.F_State = 0;
- model.F_AddUser = userModel.F_UserCode ;
- model.F_AddTime = DateTime .Now ;
- model.F_IsDelete = 0;
- int n = vipinfp.Add(model) ;
- if (n > 0)
- return Success("添加成功");
- else
- return Error("添加失败");
- }
- public ActionResult EditVip(Model.T_Cus_VipInfo vipinfos)
- {
- int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (vipinfos.F_ID <= 0)
- return Error("参数错误");
- if (string.IsNullOrEmpty(vipinfos.F_Phone))
- return Error("请输入vip电话");
- Model.T_Cus_VipInfo model = vipinfp.GetModel (vipinfos.F_ID );
- if (model == null)
- return Error("该VIP用户不存在");
- model.F_Name = vipinfos.F_Name;
- model.F_Phone = vipinfos.F_Phone;
- model.F_Remarks = vipinfos.F_Remarks;
- model.F_State = 0;
- model.F_UpdateUser = userModel.F_UserCode;
- model.F_UpdateTime = DateTime.Now;
- model.F_IsDelete = 0;
- bool n = new BLL.T_Cus_VipInfo().Update (model);
- if (n )
- return Success("修改成功");
- else
- return Error("修改失败");
- }
- public ActionResult DeleteVip(string id)
- {
- int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (string.IsNullOrEmpty(id))
- return Error("请选择vip用户");
- 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(',') + ")";
- if (DbHelperSQL.ExecuteSql(sql) > 0)
- {
- return Success("设置成功");
- }
- else
- {
- return Error("设置失败");
- }
- }
- public ActionResult EditState(string id,int state=0)
- {
- int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- if (string .IsNullOrEmpty (id))
- return Error("请选择vip用户");
- string sql = "update T_Cus_VipInfo set F_State="+ state + " where F_ID in(" + id.TrimEnd(',') + ")";
- if (DbHelperSQL.ExecuteSql(sql) > 0)
- {
- return Success("设置成功");
- }
- else
- {
- return Error("设置失败");
- }
- }
- }
- }
|