From 7b4f0f9e8668fa99ced73675cb13705f251b2dce Mon Sep 17 00:00:00 2001
From: 17520697812 <1664311035@qq.com>
Date: Wed, 1 Nov 2023 16:38:20 +0800
Subject: [PATCH] =?UTF-8?q?=E6=AF=94=E6=9E=84=E5=AE=B6=E6=96=B0=E7=9A=84?=
=?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=A1=86=E6=9E=B6=E6=95=B4=E7=90=86=E5=AE=8C?=
=?UTF-8?q?=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Customer/CustomerController.cs | 92 ++++++++++++
.../Controllers/System/SysUserController.cs | 4 +-
ZR.Admin.WebApi/appsettings.json | 4 +-
ZR.ServiceCore/Model/CusCustomer.cs | 119 ++++++++++++++++
ZR.ServiceCore/Model/Dto/CustomerDto.cs | 133 ++++++++++++++++++
ZR.ServiceCore/Model/Dto/SysUserDto.cs | 18 +++
ZR.ServiceCore/Services/CustomerService.cs | 82 +++++++++++
.../Services/IService/ICustomerService.cs | 27 ++++
.../Services/IService/ISysUserService.cs | 4 +
ZR.ServiceCore/Services/SysUserService.cs | 27 +++-
10 files changed, 505 insertions(+), 5 deletions(-)
create mode 100644 ZR.Admin.WebApi/Controllers/Customer/CustomerController.cs
create mode 100644 ZR.ServiceCore/Model/CusCustomer.cs
create mode 100644 ZR.ServiceCore/Model/Dto/CustomerDto.cs
create mode 100644 ZR.ServiceCore/Services/CustomerService.cs
create mode 100644 ZR.ServiceCore/Services/IService/ICustomerService.cs
diff --git a/ZR.Admin.WebApi/Controllers/Customer/CustomerController.cs b/ZR.Admin.WebApi/Controllers/Customer/CustomerController.cs
new file mode 100644
index 00000000..89e60c17
--- /dev/null
+++ b/ZR.Admin.WebApi/Controllers/Customer/CustomerController.cs
@@ -0,0 +1,92 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using ZR.Model.System.Dto;
+using ZR.Model;
+using ZR.ServiceCore.Model.Dto;
+using ZR.Service.System.IService;
+using ZR.ServiceCore.Services.IService;
+using System.Collections.Generic;
+using ZR.Admin.WebApi.Filters;
+using ZR.Model.System;
+
+namespace ZR.Admin.WebApi.Controllers
+{
+ ///
+ /// 客户模块
+ ///
+ [Verify]
+ [Route("api/[controller]")]
+ public class CustomerController : BaseController
+ {
+ private readonly ICustomerService _customerService;
+
+ private readonly ISysUserService _sysUserService;
+
+
+ public CustomerController(ICustomerService customerService, ISysUserService sysUserService)
+ {
+ _customerService = customerService;
+ _sysUserService = sysUserService;
+ }
+
+
+ ///
+ /// 客户
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("list")]
+ public IActionResult List([FromQuery] CustomerQueryDto customerDto, PagerInfo pager)
+ {
+ var customerList = _customerService.SelectCustomerList(customerDto, pager);
+ return SUCCESS(customerList);
+ }
+
+
+
+ ///
+ /// 客户管理-编辑- 查询客户详细信息
+ ///
+ /// 客户ID
+ ///
+ [HttpGet("{id}")]
+ public IActionResult GetInfo(int id)
+ {
+ Dictionary dic = new();
+ var customer = _customerService.SelectCustomerById(id);
+ dic.Add("customer", customer);
+ dic.Add("users", _sysUserService.SelectUserAll());
+ return SUCCESS(dic);
+ }
+
+
+ ///
+ /// 编辑客户信息
+ ///
+ ///
+ ///
+ [HttpPut]
+ public IActionResult Put([FromBody] CustomerDto customer)
+ {
+ if (customer == null || customer.Id <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
+ int upResult = _customerService.UpdateCustomer(customer);
+ return ToResponse(upResult);
+
+ }
+
+
+ ///
+ /// 查询业务员
+ ///
+ ///
+ ///
+ [HttpGet("salesmans")]
+ public IActionResult Get(int userid)
+ {
+ return SUCCESS(_sysUserService.SelectUserAll());
+ }
+
+
+ }
+}
diff --git a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
index 9242360f..8077d859 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
@@ -94,7 +94,7 @@ namespace ZR.Admin.WebApi.Controllers.System
user.Create_by = HttpContext.GetName();
user.Create_time = DateTime.Now;
- user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password);
+ user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password).ToLower();
return SUCCESS(UserService.InsertUser(user));
}
@@ -160,7 +160,7 @@ namespace ZR.Admin.WebApi.Controllers.System
public IActionResult ResetPwd([FromBody] SysUserDto sysUser)
{
//密码md5
- sysUser.Password = NETCore.Encrypt.EncryptProvider.Md5(sysUser.Password);
+ sysUser.Password = NETCore.Encrypt.EncryptProvider.Md5(sysUser.Password).ToLower();
int result = UserService.ResetPwd(sysUser.UserId, sysUser.Password);
return ToResponse(result);
diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json
index 39c049c6..14019ddb 100644
--- a/ZR.Admin.WebApi/appsettings.json
+++ b/ZR.Admin.WebApi/appsettings.json
@@ -8,8 +8,8 @@
},
"dbConfigs": [
{
- "Conn": "Data Source=LAPTOP-STKF2M8H\\SQLEXPRESS;User ID=admin;Password=admin123;Initial Catalog=ZrAdmin;",
- "DbType": 1, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4
+ "Conn": "Server=42.193.239.183;port=3306;ConnectionTimeout=10;DefaultCommandTimeout=300;Database=beego_fenxiao;UserId=root;Password=ydh123456;CharacterSet=utf8;ConvertZeroDateTime=True;AllowUserVariables=True;SslMode=None;Pooling=True;MinimumPoolSize=4;MaximumPoolSize=100;",
+ "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4
"ConfigId": "0", //多租户唯一标识
"IsAutoCloseConnection": true
}
diff --git a/ZR.ServiceCore/Model/CusCustomer.cs b/ZR.ServiceCore/Model/CusCustomer.cs
new file mode 100644
index 00000000..4aa42594
--- /dev/null
+++ b/ZR.ServiceCore/Model/CusCustomer.cs
@@ -0,0 +1,119 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZR.ServiceCore.Model
+{
+ ///
+ ///
+ ///
+ [SugarTable("cus_customer")]
+ public class CusCustomer
+ {
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
+ public int Id { get; set; }
+ ///
+ /// 电子邮箱
+ ///
+ [SugarColumn(ColumnName = "email")]
+ public string Email { get; set; }
+ ///
+ /// 密码
+ ///
+ [SugarColumn(ColumnName = "Password")]
+ public string Password { get; set; }
+ ///
+ /// 注册时间
+ ///
+ [SugarColumn(ColumnName = "Regist_time")]
+ public DateTime RegistTime { get; set; }
+ ///
+ /// 邀请码
+ ///
+ [SugarColumn(ColumnName = "invitation_code")]
+ public string InvitationCode { get; set; }
+ ///
+ /// 分享链接点击次数
+ /// 默认值: 0
+ ///
+ [SugarColumn(ColumnName = "Invitelink_click")]
+ public int InvitelinkClick { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "Update_time")]
+ public DateTime UpdateTime { get; set; }
+ ///
+ /// 电话
+ ///
+ [SugarColumn(ColumnName = "Phone")]
+ public string Phone { get; set; }
+ ///
+ /// 用户昵称
+ ///
+ [SugarColumn(ColumnName = "UserName")]
+ public string UserName { get; set; }
+ ///
+ /// 价格倍数,用于设置在添加产品时,产品价格是成本价的几倍
+ /// 默认值: 2.00
+ ///
+ [SugarColumn(ColumnName = "Price_multiples")]
+ public decimal PriceMultiples { get; set; }
+ ///
+ /// 价格开关,打开后价格倍数才有效,不打开则按照系统默认倍数(0打开,1,关闭)
+ /// 默认值: 0
+ ///
+ [SugarColumn(ColumnName = "Price_switch")]
+ public string PriceSwitch { get; set; }
+ ///
+ /// 赊账余额是否申请,0未申请,1申请
+ /// 默认值: 0
+ ///
+ [SugarColumn(ColumnName = "credit_apply")]
+ public string CreditApply { get; set; }
+ ///
+ /// 赊账申请时间
+ ///
+ [SugarColumn(ColumnName = "apply_time")]
+ public DateTime? ApplyTime { get; set; }
+ ///
+ /// 业务Id
+ ///
+ [SugarColumn(ColumnName = "BusinessId")]
+ public string BusinessId { get; set; }
+ ///
+ /// 注册来源(Marketing:营销活动注册)
+ ///
+ [SugarColumn(ColumnName = "create_cource")]
+ public string CreateCource { get; set; }
+ ///
+ /// 最后登录时间
+ ///
+ [SugarColumn(ColumnName = "last_login_time")]
+ public DateTime? LastLoginTime { get; set; }
+ ///
+ /// 最后一次发送联系问候邮件的时间(超10天未登录则发送问候服务)
+ ///
+ [SugarColumn(ColumnName = "last_email_time")]
+ public DateTime? LastEmailTime { get; set; }
+
+
+ ///
+ /// 业务员 id
+ ///
+ [SugarColumn(ColumnName = "salesman_id")]
+ public long SalesmanId { get; set; }
+
+ ///
+ /// A 不启用自动支付 B 草稿 C 启用自动支付
+ /// 默认值: A
+ ///
+ [SugarColumn(ColumnName = "payment_state")]
+ public string PaymentState { get; set; }
+ }
+}
diff --git a/ZR.ServiceCore/Model/Dto/CustomerDto.cs b/ZR.ServiceCore/Model/Dto/CustomerDto.cs
new file mode 100644
index 00000000..0276db26
--- /dev/null
+++ b/ZR.ServiceCore/Model/Dto/CustomerDto.cs
@@ -0,0 +1,133 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZR.ServiceCore.Model.Dto
+{
+ public class CustomerQueryDto
+ {
+ public string Email { get; set; }
+
+ public string SalesmanId { get; set; }
+ }
+
+ public class CustomerDto
+ {
+
+ [SugarColumn(ColumnName = "id")]
+ public int Id { get; set; }
+ ///
+ /// 电子邮箱
+ ///
+ [SugarColumn(ColumnName = "email")]
+ public string Email { get; set; }
+
+
+
+ /////
+ ///// 密码
+ /////
+ //[SugarColumn(ColumnName = "Password")]
+ //public string Password { get; set; }
+
+
+ ///
+ /// 注册时间
+ ///
+ [SugarColumn(ColumnName = "Regist_time")]
+ public DateTime RegistTime { get; set; }
+
+
+ ///
+ /// 邀请码
+ ///
+ [SugarColumn(ColumnName = "invitation_code")]
+ public string InvitationCode { get; set; }
+ ///
+ /// 分享链接点击次数
+ /// 默认值: 0
+ ///
+ [SugarColumn(ColumnName = "Invitelink_click")]
+ public int InvitelinkClick { get; set; }
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "Update_time")]
+ public DateTime UpdateTime { get; set; }
+ ///
+ /// 电话
+ ///
+ [SugarColumn(ColumnName = "Phone")]
+ public string Phone { get; set; }
+ ///
+ /// 用户昵称
+ ///
+ [SugarColumn(ColumnName = "UserName")]
+ public string UserName { get; set; }
+ ///
+ /// 价格倍数,用于设置在添加产品时,产品价格是成本价的几倍
+ /// 默认值: 2.00
+ ///
+ [SugarColumn(ColumnName = "Price_multiples")]
+ public decimal PriceMultiples { get; set; }
+ ///
+ /// 价格开关,打开后价格倍数才有效,不打开则按照系统默认倍数(0打开,1,关闭)
+ /// 默认值: 0
+ ///
+ [SugarColumn(ColumnName = "Price_switch")]
+ public string PriceSwitch { get; set; }
+ ///
+ /// 赊账余额是否申请,0未申请,1申请
+ /// 默认值: 0
+ ///
+ [SugarColumn(ColumnName = "credit_apply")]
+ public string CreditApply { get; set; }
+ ///
+ /// 赊账申请时间
+ ///
+ [SugarColumn(ColumnName = "apply_time")]
+ public DateTime? ApplyTime { get; set; }
+ ///
+ /// 业务Id
+ ///
+ [SugarColumn(ColumnName = "BusinessId")]
+ public string BusinessId { get; set; }
+ ///
+ /// 注册来源(Marketing:营销活动注册)
+ ///
+ [SugarColumn(ColumnName = "create_cource")]
+ public string CreateCource { get; set; }
+ ///
+ /// 最后登录时间
+ ///
+ [SugarColumn(ColumnName = "last_login_time")]
+ public DateTime? LastLoginTime { get; set; }
+ ///
+ /// 最后一次发送联系问候邮件的时间(超10天未登录则发送问候服务)
+ ///
+ [SugarColumn(ColumnName = "last_email_time")]
+ public DateTime? LastEmailTime { get; set; }
+
+ ///
+ /// 业务员
+ ///
+ [SugarColumn(ColumnName = "salesman_id")]
+ public long SalesmanId { get; set; }
+
+ ///
+ /// A 不启用自动支付 B 草稿 C 启用自动支付
+ /// 默认值: A
+ ///
+ [SugarColumn(ColumnName = "payment_state")]
+ public string PaymentState { get; set; }
+
+
+
+ public string SalesmanName { get; set; }
+
+
+ }
+
+}
diff --git a/ZR.ServiceCore/Model/Dto/SysUserDto.cs b/ZR.ServiceCore/Model/Dto/SysUserDto.cs
index 9d07520f..f1b13c8d 100644
--- a/ZR.ServiceCore/Model/Dto/SysUserDto.cs
+++ b/ZR.ServiceCore/Model/Dto/SysUserDto.cs
@@ -34,4 +34,22 @@ namespace ZR.Model.System.Dto
public int Status { get; set; }
public long DeptId { get; set; }
}
+
+ public class SysSalesman
+ {
+ [SugarColumn(ColumnName = "userId")]
+ public long? UserId { get; set; }
+
+ [SugarColumn(ColumnName = "userName")]
+ public string UserName { get; set; }
+
+
+ [SugarColumn(ColumnName = "status")]
+ public string Status { get; set; }
+
+ public string NickName { get; set; }
+
+
+ }
+
}
diff --git a/ZR.ServiceCore/Services/CustomerService.cs b/ZR.ServiceCore/Services/CustomerService.cs
new file mode 100644
index 00000000..ba556841
--- /dev/null
+++ b/ZR.ServiceCore/Services/CustomerService.cs
@@ -0,0 +1,82 @@
+using Infrastructure.Attribute;
+using Mapster;
+using Microsoft.Extensions.DependencyInjection;
+using SqlSugar;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZR.Model;
+using ZR.Model.System;
+using ZR.Model.System.Dto;
+using ZR.Repository;
+using ZR.Service;
+using ZR.Service.System.IService;
+using ZR.ServiceCore.Model;
+using ZR.ServiceCore.Model.Dto;
+using ZR.ServiceCore.Services.IService;
+
+namespace ZR.ServiceCore.Services
+{
+
+ [AppService(ServiceType = typeof(ICustomerService), ServiceLifetime = LifeTime.Transient)]
+ public class CustomerService : BaseService, ICustomerService
+ {
+ public PagedInfo SelectCustomerList(CustomerQueryDto customer, PagerInfo pager)
+ {
+
+
+
+
+ var exp = Expressionable.Create();
+
+
+
+ exp.AndIF(!string.IsNullOrEmpty(customer.Email), u => u.Email.Contains(customer.Email));
+ exp.AndIF(!string.IsNullOrEmpty(customer.SalesmanId), u => u.SalesmanId == customer.SalesmanId.ParseToInt());
+
+
+ var query = Queryable().LeftJoin((u, user) => u.SalesmanId == user.UserId)
+ .Where(exp.ToExpression()).Select((u, user) => new CustomerDto { Id = u.Id.SelectAll(), SalesmanName = user.NickName });
+
+
+
+
+
+
+ return query.ToPage(pager);
+
+ //query.ToPage(pager);
+
+
+
+ // var query = Queryable()
+ //.LeftJoin((u, dept) => u.DeptId == dept.DeptId)
+ //.Where(exp.ToExpression())
+ //.Select((u, dept) => new SysUser
+ //{
+ // UserId = u.UserId.SelectAll(),
+ // DeptName = dept.DeptName,
+ //});
+
+
+
+ }
+
+
+ public CustomerDto SelectCustomerById(int customerId)
+ {
+ var customer = Queryable().LeftJoin((o, j) => o.SalesmanId == j.UserId).Where(o => o.Id == customerId).Select((o, j) => new CustomerDto { Id = o.Id, Phone = o.Phone, SalesmanName = j.UserName, SalesmanId = o.SalesmanId }).First();
+ return customer;
+ }
+
+ public int UpdateCustomer(CustomerDto customerDto)
+ {
+ var result = Update(new CusCustomer() { Id = customerDto.Id, Phone = customerDto.Phone, SalesmanId = customerDto.SalesmanId }, it => new { it.Phone, it.SalesmanId });
+ return result;
+ }
+
+ }
+}
diff --git a/ZR.ServiceCore/Services/IService/ICustomerService.cs b/ZR.ServiceCore/Services/IService/ICustomerService.cs
new file mode 100644
index 00000000..7c1069b7
--- /dev/null
+++ b/ZR.ServiceCore/Services/IService/ICustomerService.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZR.Model;
+using ZR.Model.System;
+using ZR.Model.System.Dto;
+using ZR.Service;
+using ZR.ServiceCore.Model;
+using ZR.ServiceCore.Model.Dto;
+
+namespace ZR.ServiceCore.Services.IService
+{
+ public interface ICustomerService : IBaseService
+ {
+
+ public PagedInfo SelectCustomerList(CustomerQueryDto customer, PagerInfo pager);
+
+
+ public CustomerDto SelectCustomerById(int customerId);
+
+ public int UpdateCustomer(CustomerDto customer);
+
+ }
+
+}
diff --git a/ZR.ServiceCore/Services/IService/ISysUserService.cs b/ZR.ServiceCore/Services/IService/ISysUserService.cs
index a074e852..d5103036 100644
--- a/ZR.ServiceCore/Services/IService/ISysUserService.cs
+++ b/ZR.ServiceCore/Services/IService/ISysUserService.cs
@@ -16,6 +16,10 @@ namespace ZR.Service.System.IService
///
public SysUser SelectUserById(long userId);
+
+
+ public List SelectUserAll();
+
///
/// 校验用户名称是否唯一
///
diff --git a/ZR.ServiceCore/Services/SysUserService.cs b/ZR.ServiceCore/Services/SysUserService.cs
index 7d7a4c39..6f4283fb 100644
--- a/ZR.ServiceCore/Services/SysUserService.cs
+++ b/ZR.ServiceCore/Services/SysUserService.cs
@@ -1,6 +1,7 @@
using Infrastructure;
using Infrastructure.Attribute;
using IPTools.Core;
+using Mapster;
using System.Collections;
using ZR.Common;
using ZR.Model;
@@ -81,6 +82,24 @@ namespace ZR.Service
return user;
}
+
+
+ ///
+ /// 查询所有用户 客户管理-编辑/新增-选择业务员
+ ///
+ ///
+ public List SelectUserAll()
+ {
+ var users = Queryable()
+ .Where(user => user.DelFlag == 0).Select(i => new { i.UserId, i.UserName,i.Status ,i.NickName})
+ .ToList();
+ return users.Adapt>();
+
+ }
+
+
+
+
///
/// 校验用户名称是否唯一
///
@@ -220,7 +239,7 @@ namespace ZR.Service
throw new CustomException("用户名不符合要求");
}
//密码md5
- string password = NETCore.Encrypt.EncryptProvider.Md5(dto.Password);
+ string password = NETCore.Encrypt.EncryptProvider.Md5(dto.Password).ToLower();
var ip_info = IpTool.Search(dto.UserIP);
SysUser user = new()
{
@@ -336,5 +355,11 @@ namespace ZR.Service
{
Update(new SysUser() { LoginIP = user.LoginIP, LoginDate = DateTime.Now, UserId = userId }, it => new { it.LoginIP, it.LoginDate });
}
+
+
+
+
+
+
}
}
--
Gitee