104 lines
3.5 KiB
C#
104 lines
3.5 KiB
C#
using YLErp.Modules.ClientModule;
|
|
|
|
|
|
namespace YLErp.Web.Controllers
|
|
{
|
|
public class clientblackController : BaseController
|
|
{
|
|
[MyAuthorize("客户管理-黑名单客户")]
|
|
public ActionResult clientblacklist()
|
|
{
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
public JsonResult clientblacklistQuery(ClientBlackReq req)
|
|
{
|
|
var sList = new ClientBlackService(CurUser).SearchList(req);
|
|
return Json(sList);
|
|
}
|
|
|
|
public ActionResult clientblackAdd(int id = 0)
|
|
{
|
|
var clientBlack = DataCacheProvider.GetClientBlackDataSource().GetData(id) ?? new client_black();
|
|
return View(clientBlack);
|
|
}
|
|
public JsonResult ClientBlackAddJson(client_black client, bool checkStatus)
|
|
{
|
|
if (string.IsNullOrEmpty(client.Name))
|
|
{
|
|
return JsonError("客户名称不能为空");
|
|
}
|
|
new ClientBlackService(CurUser).AddClientBlack(new[] { client }, checkStatus);
|
|
return JsonSuccess("", client);
|
|
}
|
|
/// <summary>
|
|
/// 导入黑名单
|
|
/// </summary>
|
|
public ActionResult UploadSettlementBill(IFormFile file, bool checkStatus)
|
|
{
|
|
try
|
|
{
|
|
if (file == null || string.IsNullOrWhiteSpace(file.FileName))
|
|
{
|
|
return JsonError("未获取上传文件");
|
|
}
|
|
var fileExtension = Path.GetExtension(file.FileName);
|
|
using var inputStream = file.OpenReadStream();
|
|
new ClientBlackService(CurUser).ImportxlsxClientBlack(inputStream, checkStatus);
|
|
return JsonSuccess("导入成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFactory.GetLogger("导入黑名单").Error("导入黑名单出错", ex);
|
|
return JsonError(ex.Messages());
|
|
}
|
|
}
|
|
public ActionResult DeleteClientBlack(string ids)
|
|
{
|
|
var datalist = ids.Split(',');
|
|
var list = new List<int>();
|
|
foreach (var item in datalist)
|
|
{
|
|
var data = clientDB.client_black.Find(int.Parse(item));
|
|
if (data == null)
|
|
{
|
|
return JsonError("未找到要删除的数据");
|
|
}
|
|
else
|
|
{
|
|
var clitid = clientDB.client.Where(c => c.Name == data.Name).FirstOrDefault();
|
|
if (clitid != null)
|
|
{
|
|
clientDB.ClientAuditLog.Add(new ClientAuditLog
|
|
{
|
|
ClientId = clitid.id,
|
|
OptType = "移除黑名单",
|
|
Changes = string.Empty,
|
|
DataType = "00",
|
|
OptId = UserId,
|
|
OptName = UserName,
|
|
OptDate = DateTime.Now
|
|
});
|
|
}
|
|
|
|
clientDB.client_black.Remove(data);
|
|
}
|
|
|
|
}
|
|
clientDB.SaveChanges();
|
|
return JsonSuccess("删除成功");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 黑名单导出
|
|
/// </summary>
|
|
[HttpPost]
|
|
public object ExportClientBlack(ClientBlackReq req)
|
|
{
|
|
var bytes = new ClientBlackService(CurUser).ExportClientBlack(req);
|
|
|
|
return File(bytes, xlsxMimeType, $"黑名单导出-{DateTime.Now:yyyy-MM-dd}.xlsx");
|
|
}
|
|
}
|
|
} |