diff --git a/Common/Const/RedisConstMgr.cs b/Common/Const/RedisConstMgr.cs index 884c607..cc0aed4 100644 --- a/Common/Const/RedisConstMgr.cs +++ b/Common/Const/RedisConstMgr.cs @@ -49,6 +49,11 @@ /// 密码错误次数缓存 /// public const string KeyErrorPasswordCount = "sys_errorPasswordCount:"; + + /// + /// App密码错误次数缓存 + /// + public const string AppKeyErrorPasswordCount = "app_sys_errorPasswordCount:"; /// /// 租户缓存 diff --git a/Entity/Api/Req/QueryAmtOrderInfoPageReq.cs b/Entity/Api/Req/QueryAmtOrderInfoPageReq.cs new file mode 100644 index 0000000..77d5742 --- /dev/null +++ b/Entity/Api/Req/QueryAmtOrderInfoPageReq.cs @@ -0,0 +1,36 @@ +using Entity.DbModel.Station; +using Entity.Dto.Req; +using HybirdFrameworkCore.Entity; + +namespace Entity.Api.Req; +/// +/// 预约订单分页查询 +/// +public class QueryAmtOrderInfoPageReq: QueryPageModel +{ + /// + /// Desc:客户id + /// Default: + /// Nullable:True + /// + public long? CustomerId { get; set; } + + /// + /// Desc:查询时间 + /// Default: + /// Nullable:True + /// + public DateTime? Time { get; set; } +} +/// +/// 添加预约订单 +/// +public class AddAmtOrderInfoReq : AmtOrderInfo +{ +} +/// +/// 取消预约单 +/// +public class DeleteAmtOrderInfoReq : BaseIdReq +{ +} \ No newline at end of file diff --git a/Entity/Api/Req/QuerySwapOrderPageReq.cs b/Entity/Api/Req/QuerySwapOrderPageReq.cs index 60b1a73..0cb3598 100644 --- a/Entity/Api/Req/QuerySwapOrderPageReq.cs +++ b/Entity/Api/Req/QuerySwapOrderPageReq.cs @@ -10,6 +10,15 @@ public class QuerySwapOrderPageReq : QueryPageModel /// Nullable:True /// public string? Sn { get; set; } + + + /// + /// Desc:客户id + /// Default: + /// Nullable:True + /// + public long? CustomerId { get; set; } + /// /// Desc:车牌号 @@ -74,4 +83,11 @@ public class QuerySwapOrderPageReq : QueryPageModel /// Nullable:True /// public string? UpBatteryNo { get; set; } + + /// + /// Desc:查询时间 + /// Default: + /// Nullable:True + /// + public DateTime? Time { get; set; } } \ No newline at end of file diff --git a/Entity/DbModel/Station/AmtOrderInfo.cs b/Entity/DbModel/Station/AmtOrderInfo.cs new file mode 100644 index 0000000..206f8ce --- /dev/null +++ b/Entity/DbModel/Station/AmtOrderInfo.cs @@ -0,0 +1,174 @@ +using SqlSugar; + +namespace Entity.DbModel.Station; + +/// +/// 预约订单表 +/// +[SugarTable("amt_order_info")] +public partial class AmtOrderInfo +{ + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "id", ColumnDescription = "主键Id", IsPrimaryKey = true, IsIdentity = true)] + public virtual long Id { get; set; } + + /// + /// Desc:换电站编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "sn")] + public string? sn { get; set; } + + /// + /// Desc:车辆编码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "car_no")] + public string CarNo { get; set; } + + /// + /// Desc:预约单号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "order_no")] + public string? OrderNo { get; set; } + + /// + /// Desc:车辆vim码 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "vin")] + public string Vin { get; set; } + + /// + /// Desc:电池类型 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "battery_type")] + public string? BatteryType { get; set; } + + /// + /// Desc:预约电池编号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "battery_nos")] + public string? BatteryNos { get; set; } + + /// + /// Desc:预约数量 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "batnum")] + public int? Batnum { get; set; } + + /// + /// Desc:预约电池锁仓仓号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "bin_nos")] + public string BinNos { get; set; } + + /// + /// Desc:预约时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "start_time")] + public DateTime? StartTime { get; set; } + + /// + /// Desc:预约到期时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "end_time")] + public DateTime? EndTime { get; set; } + + /// + /// Desc:预约单状态 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "status")] + public int? Status { get; set; } + + /// + /// Desc:取消时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "cancel_time")] + public DateTime? CancelTime { get; set; } + + /// + /// Desc:换电完成时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "swap_finish_time")] + public DateTime? SwapFinishTime { get; set; } + + /// + /// Desc:换电订单编号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "swap_order_no")] + public string? SwapOrderNo { get; set; } + + /// + /// Desc:创建人 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "created_by")] + public string? CreatedBy { get; set; } + + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "created_time")] + public DateTime? CreatedTime { get; set; } + + /// + /// Desc:更新人 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "updated_by")] + public string? UpdatedBy { get; set; } + + /// + /// Desc:更新时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "updated_time")] + public DateTime? UpdatedTime { get; set; } + + /// + /// Desc:客户ID + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "customer_id")] + public long? CustomerId { get; set; } + + public AmtOrderInfo() + { + } +} \ No newline at end of file diff --git a/Entity/DbModel/System/App/AppCustomer.cs b/Entity/DbModel/System/App/AppCustomer.cs new file mode 100644 index 0000000..5258c54 --- /dev/null +++ b/Entity/DbModel/System/App/AppCustomer.cs @@ -0,0 +1,172 @@ +using Common.Enum; +using SqlSugar; + +namespace Entity.DbModel.System.App; + +/// +/// App用户表 +/// +[SugarTable("app_customer")] +public class AppCustomer +{ + /// + /// 自增 + /// + [SugarColumn(ColumnName = "id", ColumnDescription = "主键Id", IsPrimaryKey = true, IsIdentity = true)] + public virtual long Id { get; set; } + + /// + /// 登录号码 + /// + [SugarColumn(ColumnName = "login_no", ColumnDescription = "登录号码", Length = 20)] + public virtual string LoginNo { get; set; } + + /// + /// 车队ID + /// + [SugarColumn(ColumnName = "team_id", ColumnDescription = "车队ID")] + public virtual long? TeamId { get; set; } + + /// + /// 登录方式 + /// + [SugarColumn(ColumnName = "login_type", ColumnDescription = "登录方式")] + public virtual byte? LoginType { get; set; } + + /// + /// 登录密码 + /// + [SugarColumn(ColumnName = "login_psd", ColumnDescription = "登录密码", Length = 60)] + public virtual string? LoginPsd { get; set; } + + /// + /// 是否是会员 + /// + [SugarColumn(ColumnName = "is_member", ColumnDescription = "是否是会员")] + public virtual byte? IsMember { get; set; } + + /// + /// 用户昵称 + /// + [SugarColumn(ColumnName = "nick_name", ColumnDescription = "用户昵称", Length = 20)] + public virtual string NickName { get; set; } + + /// + /// 姓名 + /// + [SugarColumn(ColumnName = "user_name", ColumnDescription = "姓名", Length = 30)] + public virtual string? UserName { get; set; } + + /// + /// 用户头像URL + /// + [SugarColumn(ColumnName = "user_avatar", ColumnDescription = "用户头像URL", Length = 255)] + public virtual string? UserAvatar { get; set; } + + /// + /// 性别 + /// + [SugarColumn(ColumnName = "gender", ColumnDescription = "性别")] + public virtual byte? Gender { get; set; } + + /// + /// 身份证号码 + /// + [SugarColumn(ColumnName = "identify_code", ColumnDescription = "身份证号码", Length = 30)] + public virtual string? IdentifyCode { get; set; } + + /// + /// 手机号码 + /// + [SugarColumn(ColumnName = "iphone_no", ColumnDescription = "手机号码", Length = 15)] + public virtual string? IphoneNo { get; set; } + + /// + /// 邮箱 + /// + [SugarColumn(ColumnName = "email", ColumnDescription = "邮箱", Length = 100)] + public virtual string? Email { get; set; } + + /// + /// 家庭住址 + /// + [SugarColumn(ColumnName = "home_addr", ColumnDescription = "家庭住址", Length = 100)] + public virtual string? HomeAddr { get; set; } + + /// + /// 车牌号 + /// + [SugarColumn(ColumnName = "car_no", ColumnDescription = "车牌号", Length = 20)] + public virtual string? CarNo { get; set; } + + /// + /// 使用状态 + /// + [SugarColumn(ColumnName = "state", ColumnDescription = "使用状态")] + public StatusEnum State { get; set; } = StatusEnum.Enable; + /// + /// 注册平台 + /// + [SugarColumn(ColumnName = "register_plat", ColumnDescription = "注册平台")] + public virtual byte? RegisterPlat { get; set; } + + /// + /// 支付宝userid + /// + [SugarColumn(ColumnName = "user_id", ColumnDescription = "支付宝userid", Length = 100)] + public virtual string? UserId { get; set; } + + /// + /// 微信openid + /// + [SugarColumn(ColumnName = "open_id", ColumnDescription = "微信openid", Length = 100)] + public virtual string? OpenId { get; set; } + + /// + /// unionid + /// + [SugarColumn(ColumnName = "union_id", ColumnDescription = "unionid", Length = 100)] + public virtual string? UnionId { get; set; } + + /// + /// 公众号openid + /// + [SugarColumn(ColumnName = "wx_open_id", ColumnDescription = "公众号openid", Length = 100)] + public virtual string? WxOpenId { get; set; } + + /// + /// 出生日期 + /// + [SugarColumn(ColumnName = "birthday", ColumnDescription = "出生日期", Length = 50)] + public virtual string? Birthday { get; set; } + + /// + /// 审核进度 + /// + [SugarColumn(ColumnName = "audit_state", ColumnDescription = "审核进度")] + public virtual byte? AuditState { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "created_by", ColumnDescription = "创建人", Length = 32)] + public virtual string? CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "created_time", ColumnDescription = "创建时间")] + public virtual DateTime? CreatedTime { get; set; } + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "updated_by", ColumnDescription = "更新人", Length = 32)] + public virtual string? UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "updated_time", ColumnDescription = "更新时间")] + public virtual DateTime? UpdatedTime { get; set; } +} \ No newline at end of file diff --git a/Entity/DbModel/System/App/AppCustomerVehicle.cs b/Entity/DbModel/System/App/AppCustomerVehicle.cs new file mode 100644 index 0000000..61171bc --- /dev/null +++ b/Entity/DbModel/System/App/AppCustomerVehicle.cs @@ -0,0 +1,161 @@ +using SqlSugar; + +namespace Entity.DbModel.System.App; + +/// +/// 客户车辆表 +/// +[SugarTable("app_customer_vehicle")] +public class AppCustomerVehicle +{ + /// + /// 自增 + /// + [SugarColumn(ColumnName = "id", ColumnDescription = "主键Id", IsPrimaryKey = true, IsIdentity = true)] + public virtual long Id { get; set; } + + /// + /// 客户id + /// + [SugarColumn(ColumnName = "customer_id", ColumnDescription = "客户id")] + public virtual long? CustomerId { get; set; } + + /// + /// 用户名 + /// + [SugarColumn(ColumnName = "user_name", ColumnDescription = "用户名")] + public virtual string UserName { get; set; } + + /// + /// 手机号 + /// + [SugarColumn(ColumnName = "phone", ColumnDescription = "手机号")] + public virtual string? Phone { get; set; } + + /// + /// 车队id + /// + [SugarColumn(ColumnName = "team_id", ColumnDescription = "车队id")] + public virtual long? TeamId { get; set; } + + /// + /// 车辆id + /// + [SugarColumn(ColumnName = "car_id", ColumnDescription = "车辆id")] + public virtual long? CarId { get; set; } + + /// + /// 车牌号 + /// + [SugarColumn(ColumnName = "car_no", ColumnDescription = "车牌号")] + public virtual string CarNo { get; set; } + + /// + /// VIN码 + /// + [SugarColumn(ColumnName = "vin", ColumnDescription = "VIN码")] + public virtual string Vin { get; set; } + + /// + /// MAC地址 + /// + [SugarColumn(ColumnName = "mac", ColumnDescription = "MAC地址")] + public virtual string? Mac { get; set; } + + /// + /// 发动机编号 + /// + [SugarColumn(ColumnName = "engine_no", ColumnDescription = "发动机编号")] + public virtual string? EngineNo { get; set; } + + /// + /// 行驶证图片 + /// + [SugarColumn(ColumnName = "vehicle_license", ColumnDescription = "行驶证图片")] + public virtual string VehicleLicense { get; set; } + + /// + /// 驾驶证图片 + /// + [SugarColumn(ColumnName = "driver_license", ColumnDescription = "驾驶证图片")] + public virtual string DriverLicense { get; set; } + + /// + /// 身份证人像面 + /// + [SugarColumn(ColumnName = "id_front", ColumnDescription = "身份证人像面")] + public virtual string IdFront { get; set; } + + /// + /// 身份证国徽面 + /// + [SugarColumn(ColumnName = "id_back", ColumnDescription = "身份证国徽面")] + public virtual string IdBack { get; set; } + + /// + /// 申请认证时间 + /// + [SugarColumn(ColumnName = "apply_time", ColumnDescription = "申请认证时间")] + public virtual DateTime? ApplyTime { get; set; } + + /// + /// 审核状态 + /// 0:未审核;1:通过审核;2:审核拒绝 + /// + [SugarColumn(ColumnName = "audit_status", ColumnDescription = "审核状态")] + public virtual int? AuditStatus { get; set; } + + /// + /// 申请原因 + /// + [SugarColumn(ColumnName = "audit_reason", ColumnDescription = "申请原因")] + public virtual string? AuditReason { get; set; } + + /// + /// 是否默认扣费账户 + /// + [SugarColumn(ColumnName = "is_default", ColumnDescription = "是否默认扣费账户")] + public virtual int? IsDefault { get; set; } = 0; + + /// + /// 审核id + /// + [SugarColumn(ColumnName = "audit_id", ColumnDescription = "审核id")] + public virtual long? AuditId { get; set; } + + /// + /// 审核人 + /// + [SugarColumn(ColumnName = "audit_name", ColumnDescription = "审核人")] + public virtual string? AuditName { get; set; } + + /// + /// 审核时间 + /// + [SugarColumn(ColumnName = "audit_time", ColumnDescription = "审核时间")] + public virtual DateTime? AuditTime { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "created_by", ColumnDescription = "创建人")] + public virtual string? CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "created_time", ColumnDescription = "创建时间")] + public virtual DateTime? CreatedTime { get; set; } = DateTime.Now; + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "updated_by", ColumnDescription = "更新人")] + public virtual string? UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "updated_time", ColumnDescription = "更新时间")] + public virtual DateTime? UpdatedTime { get; set; } = DateTime.Now; +} \ No newline at end of file diff --git a/Entity/DbModel/System/App/CarTeam.cs b/Entity/DbModel/System/App/CarTeam.cs new file mode 100644 index 0000000..4cd32aa --- /dev/null +++ b/Entity/DbModel/System/App/CarTeam.cs @@ -0,0 +1,100 @@ +using SqlSugar; + +namespace Entity.DbModel.System.App; + +/// +/// 车队 +/// +[SugarTable("car_team")] +public class CarTeam +{ + /// + /// 自增 + /// + [SugarColumn(ColumnName = "id", ColumnDescription = "主键Id", IsPrimaryKey = true, IsIdentity = true)] + public virtual long Id { get; set; } + + /// + /// 客户id + /// + [SugarColumn(ColumnName = "customer_id", ColumnDescription = "客户id")] + public virtual long? CustomerId { get; set; } + + /// + /// 车队编码 + /// + [SugarColumn(ColumnName = "team_code", ColumnDescription = "车队编码", Length = 50)] + public virtual string TeamCode { get; set; } + + /// + /// 车队名称 + /// + [SugarColumn(ColumnName = "team_name", ColumnDescription = "车队名称", Length = 30, IsNullable = false)] + public virtual string TeamName { get; set; } + + /// + /// 负责人 + /// + [SugarColumn(ColumnName = "principal", ColumnDescription = "负责人", Length = 50)] + public virtual string Principal { get; set; } + + /// + /// 联系方式 + /// + [SugarColumn(ColumnName = "contact_way", ColumnDescription = "联系方式", Length = 300)] + public virtual string ContactWay { get; set; } + + /// + /// 是否打折:0:否;1是 + /// + [SugarColumn(ColumnName = "is_discount", ColumnDescription = "是否打折:0:否;1是")] + public virtual int? IsDiscount { get; set; } + + /// + /// 折扣比例:1-100 + /// + [SugarColumn(ColumnName = "discount_percent", ColumnDescription = "折扣比例:1-100")] + public virtual int? DiscountPercent { get; set; } + + /// + /// 折扣范围:0全部折扣;1:计费模型折扣;3电价折扣 + /// + [SugarColumn(ColumnName = "discount_scope", ColumnDescription = "折扣范围:0全部折扣;1:计费模型折扣;3电价折扣")] + public virtual int? DiscountScope { get; set; } + + /// + /// 舍入模式:0.向下取整;1.四舍五入;2.向上取整 + /// + [SugarColumn(ColumnName = "rounding_mode", ColumnDescription = "舍入模式:0.向下取整;1.四舍五入;2.向上取整", IsNullable = false)] + public virtual int RoundingMode { get; set; } = 0; + + /// + /// 额度限制,小于此额度则认证失败,提示余额不足 + /// + [SugarColumn(ColumnName = "limit", ColumnDescription = "额度限制,小于此额度则认证失败,提示余额不足", DecimalDigits = 2)] + public virtual decimal? Limit { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "created_by", ColumnDescription = "创建人", Length = 32)] + public virtual string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "created_time", ColumnDescription = "创建时间", IsNullable = true, IsOnlyIgnoreUpdate = true)] + public virtual DateTime? CreatedTime { get; set; } = DateTime.Now; + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "updated_by", ColumnDescription = "更新人", Length = 32)] + public virtual string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "updated_time", ColumnDescription = "更新时间", IsNullable = true)] + public virtual DateTime? UpdatedTime { get; set; } = DateTime.Now; +} \ No newline at end of file diff --git a/Entity/Dto/Req/App/CustomerTeamReq.cs b/Entity/Dto/Req/App/CustomerTeamReq.cs new file mode 100644 index 0000000..10702ba --- /dev/null +++ b/Entity/Dto/Req/App/CustomerTeamReq.cs @@ -0,0 +1,21 @@ +namespace Entity.Dto.Req.App; + +/// +/// 用户绑定车队 +/// +public class CustomerTeamReq +{ + /// + /// 登录号码 + /// + public virtual string LoginNo { get; set; } + + /// + /// 车队ID + /// + public virtual long TeamId { get; set; } + /// + /// 绑定or解绑 + /// + public virtual bool Bind { get; set; } +} \ No newline at end of file diff --git a/Entity/Dto/Req/App/PageCustomerReq.cs b/Entity/Dto/Req/App/PageCustomerReq.cs new file mode 100644 index 0000000..465c022 --- /dev/null +++ b/Entity/Dto/Req/App/PageCustomerReq.cs @@ -0,0 +1,60 @@ +using System.ComponentModel.DataAnnotations; +using Entity.DbModel.System.App; +using HybirdFrameworkCore.Entity; + +namespace Entity.Dto.Req.App; + +/// +/// 获取App用户分页列表输入参数 +/// +public class PageCustomerReq : QueryPageModel +{ + /// + /// 账号 + /// + public string Account { get; set; } = ""; + + /// + /// 姓名 + /// + public string RealName { get; set; } = ""; +} + +/// +/// 增加App用户输入参数 +/// +public class AddAppCustomerReq : AppCustomer +{ +} + +/// +/// 更新App用户输入参数 +/// +public class UpdateAppCustomerReq : AddAppCustomerReq +{ +} + +/// +/// 修改用户密码输入参数 +/// +public class CustomerPwdReq +{ + + /// + /// 账号 + /// + [Required(ErrorMessage = "账号不能为空")] + public string LoginNo { get; set; } + + /// + /// 当前密码 + /// + [Required(ErrorMessage = "当前密码不能为空")] + public string PasswordOld { get; set; } + + /// + /// 新密码 + /// + [Required(ErrorMessage = "新密码不能为空"), MinLength(5, ErrorMessage = "密码需要大于5个字符")] + public string PasswordNew { get; set; } +} \ No newline at end of file diff --git a/Entity/Dto/Req/PageCarTeamReq.cs b/Entity/Dto/Req/PageCarTeamReq.cs new file mode 100644 index 0000000..9104342 --- /dev/null +++ b/Entity/Dto/Req/PageCarTeamReq.cs @@ -0,0 +1,47 @@ +using Entity.DbModel.System.App; +using HybirdFrameworkCore.Entity; + +namespace Entity.Dto.Req; + +/// +/// 车队分页查询参数 +/// +public class PageCarTeamReq : QueryPageModel +{ + /// + /// 车队编码 + /// + public virtual string? TeamCode { get; set; } + + /// + /// 车队名称 + /// + public virtual string? TeamName { get; set; } + + /// + /// 负责人 + /// + public virtual string? Principal { get; set; } + +} + +/// +/// 增加车队 +/// +public class AddCarTeamReq : CarTeam +{ +} + +/// +/// 修改车队 +/// +public class UpdateCarTeamReq : AddCarTeamReq +{ +} + +/// +/// 删除车队 +/// +public class DeleteCarTeamReq : BaseIdReq +{ +} \ No newline at end of file diff --git a/Entity/Dto/Req/PageCustomerVehicleReq.cs b/Entity/Dto/Req/PageCustomerVehicleReq.cs new file mode 100644 index 0000000..95f7b54 --- /dev/null +++ b/Entity/Dto/Req/PageCustomerVehicleReq.cs @@ -0,0 +1,70 @@ +using Entity.DbModel.System.App; +using HybirdFrameworkCore.Entity; + +namespace Entity.Dto.Req; + +/// +/// 客户车辆查询 +/// +public class PageCustomerVehicleReq: QueryPageModel +{ + + /// + /// 客户id + /// + public virtual long? CustomerId { get; set; } + + /// + /// 车牌 + /// + public virtual string? CarNo { get; set; } + + /// + /// 审核状态 + /// + public virtual int? AuditStatus { get; set; } +} +/// +/// 增加车辆 +/// +public class AddCustomerVehicleReq : AppCustomerVehicle +{ +} +/// +/// 修改车辆 +/// +public class UpdateCustomerVehicleReq : AddCustomerVehicleReq +{ +} +/// +/// 删除车辆 +/// +public class DeleteCustomerVehicleReq : BaseIdReq +{ +} +/// +/// 车辆审核 +/// +public class VehicleAuditReq +{ + /// + /// 车牌 + /// + public virtual string CarNo { get; set; } + + /// + /// 审核id + /// + public virtual long AuditId { get; set; } + + /// + /// 审核人 + /// + public virtual string AuditName { get; set; } + + /// + /// 状态 + /// + public virtual int? AuditStatus { get; set; } + +} \ No newline at end of file diff --git a/Entity/Dto/Resp/App/AppCustomerResp.cs b/Entity/Dto/Resp/App/AppCustomerResp.cs new file mode 100644 index 0000000..3e4c5c6 --- /dev/null +++ b/Entity/Dto/Resp/App/AppCustomerResp.cs @@ -0,0 +1,133 @@ +using Common.Enum; +using SqlSugar; + +namespace Entity.Dto.Resp; +/// +/// App用户基础信息 +/// +public class AppCustomerResp +{ + /// + /// 自增 + /// + public virtual long Id { get; set; } + + /// + /// 登录号码 + /// + public virtual string LoginNo { get; set; } + + /// + /// 车队ID + /// + public virtual long? TeamId { get; set; } + + /// + /// 登录方式 + /// + public virtual byte? LoginType { get; set; } + + /// + /// 是否是会员 + /// + public virtual byte? IsMember { get; set; } + + /// + /// 用户昵称 + /// + public virtual string NickName { get; set; } + + /// + /// 姓名 + /// + public virtual string? UserName { get; set; } + + /// + /// 用户头像URL + /// + public virtual string? UserAvatar { get; set; } + + /// + /// 性别 + /// + public virtual byte? Gender { get; set; } + + /// + /// 手机号码 + /// + public virtual string IphoneNo { get; set; } + + /// + /// 邮箱 + /// + public virtual string? Email { get; set; } + + /// + /// 家庭住址 + /// + public virtual string? HomeAddr { get; set; } + + /// + /// 车牌号 + /// + public virtual string? CarNo { get; set; } + + /// + /// 使用状态 + /// + public StatusEnum State { get; set; } = StatusEnum.Enable; + /// + /// 注册平台 + /// + public virtual byte? RegisterPlat { get; set; } + + /// + /// 支付宝userid + /// + public virtual string? UserId { get; set; } + + /// + /// 微信openid + /// + public virtual string? OpenId { get; set; } + + /// + /// unionid + /// + public virtual string? UnionId { get; set; } + + /// + /// 公众号openid + /// + public virtual string? WxOpenId { get; set; } + + /// + /// 出生日期 + /// + public virtual string? Birthday { get; set; } + + /// + /// 审核进度 + /// + public virtual byte? AuditState { get; set; } + + /// + /// 创建人 + /// + public virtual string? CreatedBy { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime? CreatedTime { get; set; } + + /// + /// 更新人 + /// + public virtual string? UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + public virtual DateTime? UpdatedTime { get; set; } +} \ No newline at end of file diff --git a/Entity/Dto/Resp/App/AppLoginResp.cs b/Entity/Dto/Resp/App/AppLoginResp.cs new file mode 100644 index 0000000..383c4d0 --- /dev/null +++ b/Entity/Dto/Resp/App/AppLoginResp.cs @@ -0,0 +1,92 @@ +using Common.Enum; + +namespace Entity.Dto.Resp; + +public class AppLoginResp +{ + public string token { get; set; } + + public long expireAt { get; set; } + + /// + /// 自增 + /// + public virtual long Id { get; set; } + + /// + /// 运营商id + /// + public virtual long OperatorId { get; set; } + + /// + /// 登录号码 + /// + public virtual string LoginNo { get; set; } + + /// + /// 车队ID + /// + public virtual long? TeamId { get; set; } + + /// + /// 是否是会员 + /// + public virtual byte? IsMember { get; set; } + + /// + /// 用户昵称 + /// + public virtual string NickName { get; set; } + + /// + /// 姓名 + /// + public virtual string UserName { get; set; } + + /// + /// 用户头像URL + /// + public virtual string UserAvatar { get; set; } + + /// + /// 性别 + /// + public virtual byte? Gender { get; set; } + + /// + /// 手机号码 + /// + public virtual string IphoneNo { get; set; } + + /// + /// 邮箱 + /// + public virtual string Email { get; set; } + + public StatusEnum State { get; set; } = StatusEnum.Enable; + + + public virtual string Birthday { get; set; } + + public virtual byte? AuditState { get; set; } + + /// + /// 创建人 + /// + public virtual string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime? CreatedTime { get; set; } + + /// + /// 更新人 + /// + public virtual string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + public virtual DateTime? UpdatedTime { get; set; } +} \ No newline at end of file diff --git a/Repository/Repository.csproj b/Repository/Repository.csproj index e47b41c..b49260f 100644 --- a/Repository/Repository.csproj +++ b/Repository/Repository.csproj @@ -16,10 +16,6 @@ - - - - ..\Common\lib\HybirdFrameworkCore.dll diff --git a/Repository/Station/AmtOrderInfoRepository.cs b/Repository/Station/AmtOrderInfoRepository.cs new file mode 100644 index 0000000..96826bf --- /dev/null +++ b/Repository/Station/AmtOrderInfoRepository.cs @@ -0,0 +1,51 @@ +using System.Linq.Expressions; +using Entity.DbModel.Station; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Entity; +using log4net; +using SqlSugar; + +namespace Repository.Station; +[Scope("SingleInstance")] +public class AmtOrderInfoRepository: BaseRepository +{ + private static readonly ILog _log = LogManager.GetLogger(typeof(AmtOrderInfoRepository)); + + public AmtOrderInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + } + + public IPage QueryIPage(QueryPageModel page, Expression> predicate) + { + if (null == predicate) + { + return QueryPage(page); + } + + int totalCount = 0; + + + List pageList = DbBaseClient + .Queryable() + .Where(predicate) + .OrderByDescending(x => x.CreatedTime) + .WithNoLockOrNot(false) + .ToPageList(page.PageNum, page.PageSize, ref totalCount); + + return new IPage(totalCount, page, pageList); + } + + public IPage QueryPage(QueryPageModel page) + { + int totalCount = 0; + + + List pageList = DbBaseClient + .Queryable() + .OrderByDescending(x => x.CreatedTime) + .WithNoLockOrNot(false) + .ToPageList(page.PageNum, page.PageSize, ref totalCount); + + return new IPage(totalCount, page, pageList); + } +} \ No newline at end of file diff --git a/Repository/Station/CarTeamRepository.cs b/Repository/Station/CarTeamRepository.cs new file mode 100644 index 0000000..c11fd83 --- /dev/null +++ b/Repository/Station/CarTeamRepository.cs @@ -0,0 +1,16 @@ +using Entity.DbModel.System.App; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.Station; + +[Scope] +public class CarTeamRepository : BaseRepository +{ + private ISqlSugarClient DbBaseClient; + + public CarTeamRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + DbBaseClient = sqlSugar; + } +} \ No newline at end of file diff --git a/Repository/System/App/AppCustomerRepository.cs b/Repository/System/App/AppCustomerRepository.cs new file mode 100644 index 0000000..a05b37d --- /dev/null +++ b/Repository/System/App/AppCustomerRepository.cs @@ -0,0 +1,16 @@ +using Entity.DbModel.System.App; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.System.App; + +[Scope("SingleInstance")] +public class AppCustomerRepository : BaseRepository +{ + private ISqlSugarClient DbBaseClient; + + public AppCustomerRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + DbBaseClient = sqlSugar; + } +} \ No newline at end of file diff --git a/Repository/System/App/AppCustomerVehicleRepository.cs b/Repository/System/App/AppCustomerVehicleRepository.cs new file mode 100644 index 0000000..ae1a48b --- /dev/null +++ b/Repository/System/App/AppCustomerVehicleRepository.cs @@ -0,0 +1,24 @@ +using Entity.DbModel.System.App; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.System.App; +[Scope()] +public class AppCustomerVehicleRepository : BaseRepository +{ + private ISqlSugarClient DbBaseClient; + + public AppCustomerVehicleRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + DbBaseClient = sqlSugar; + } + + public List GetVinList(long? customerId) + { + List vehicles = QueryByClauseToList(u => u.CustomerId == customerId); + + List vinList = vehicles.Select(v => v.Vin ?? string.Empty).ToList(); + + return vinList; + } +} \ No newline at end of file diff --git a/Service/MyJob/CancelAmtOrderJob.cs b/Service/MyJob/CancelAmtOrderJob.cs new file mode 100644 index 0000000..a31b476 --- /dev/null +++ b/Service/MyJob/CancelAmtOrderJob.cs @@ -0,0 +1,55 @@ +using Autofac; +using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Job; +using log4net; +using Repository.Station; + +namespace Service.Job; + +[Scope] +public class CancelAmtOrderJob : AbstractCronJob +{ + private static readonly ILog Log = LogManager.GetLogger(typeof(CancelAmtOrderJob)); + + public readonly AmtOrderInfoRepository + _amtOrderInfoRepository = AppInfo.Container.Resolve(); + + public readonly BinInfoRepository _binInfoRepository = AppInfo.Container.Resolve(); + + protected override Task Handle() + { + var time = DateTime.Now; + DateTime halfHourAgo = time.AddMinutes(-30); + + // 查询最近半小时内的预约订单 + var recentOrders = _amtOrderInfoRepository.QueryListByClause(u => + u.CreatedTime > halfHourAgo && u.Status == 1 && u.EndTime < time && u.SwapOrderNo == null); + + if (recentOrders != null) + { + foreach (var amtOrderInfo in recentOrders) + { + amtOrderInfo.Status = 2; + // _binInfoRepository.UpdateAsync(i => i.ChargerNo == amtOrderInfo.BinNos, i => i.AmtLock == 0); + _binInfoRepository.UpdateAsync(i => i.AmtLock == 0,i => i.No == amtOrderInfo.BinNos); + + } + + _amtOrderInfoRepository.Update(recentOrders); + } + + + return Task.CompletedTask; + } + + protected override string Key() + { + return "CancelAmtOrderJob"; + } + + protected override string Cron() + { + return "0 * * * * ?"; + } +} \ No newline at end of file diff --git a/Service/Station/AmtOrderInfoService.cs b/Service/Station/AmtOrderInfoService.cs new file mode 100644 index 0000000..752e4de --- /dev/null +++ b/Service/Station/AmtOrderInfoService.cs @@ -0,0 +1,148 @@ +using System.Linq.Expressions; +using Entity.Api.Req; +using Entity.DbModel.Station; +using Entity.DbModel.System.App; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Entity; +using log4net; +using Repository.Station; +using Service.Init; +using Swapping.Business.Common; + +namespace Service.Station; + +[Scope("SingleInstance")] +public class AmtOrderInfoService : BaseServices +{ + private static readonly ILog Log = LogManager.GetLogger(typeof(AmtOrderInfoService)); + private AmtOrderInfoRepository _amtOrderInfoRepository; + public BinInfoRepository _binInfoRepository { get; set; } + public AmtOrderInfoService(AmtOrderInfoRepository dal) + { + _amtOrderInfoRepository = dal; + BaseDal = dal; + } + + public PageResult AppQuerySwapOrder(QueryAmtOrderInfoPageReq req) + { + //创建一个空的表达式树 + Expression> where = null; + //// 定义参数表达式 + ParameterExpression parameter = Expression.Parameter(typeof(AmtOrderInfo), "u"); + + + where = queryTreeApp(req, where, parameter); + if (where == null) + { + return new PageResult(); + } + + return PageResult.ConvertPage(_amtOrderInfoRepository.QueryIPage(req, where)); + } + + /// + /// 添加预约订单 + /// + /// + /// + public virtual async Task> InsertAmtOrder(AddAmtOrderInfoReq input) + { + if (input == null || !input.CustomerId.HasValue) + { + return Result.Fail("CustomerId为null"); + } + + BinInfo binInfo = await _binInfoRepository.QueryByClauseAsync(u => u.No == input.BinNos); + + if (binInfo==null||binInfo.AmtLock==1||binInfo.Status==0||binInfo.CanSwapFlag==0) + { + return Result.Fail("仓位不满足换电,请更换仓位预约"); + } + var time = DateTime.Now; + DateTime halfHourAgo = time.AddMinutes(-30); + DateTime halfHourLater = time.AddMinutes(30); + + // 查询最近半小时内的预约订单 + var recentOrders = await _amtOrderInfoRepository.QueryByClauseAsync(u => + u.CustomerId == input.CustomerId && u.CreatedTime > halfHourAgo && u.Status == 1); + + if (recentOrders != null) + { + return Result.Fail("您已有预约订单"); + } + // 换电站编码 + var stationNo = StaticStationInfo.StationNo; + // 生成订单号 + var orderNo = SwapOrderNoGenerator.GenerateOrderNo(stationNo); + input.OrderNo = orderNo; + input.sn = stationNo; + input.Status = 1; + input.CreatedTime = time; + input.StartTime = time; + input.EndTime = halfHourLater; + input.BatteryNos = binInfo.BatteryNo; + input.Batnum = 1; + // 插入新订单 + await _amtOrderInfoRepository.InsertAsync(input); + + // 查询新插入的订单 + var amtOrder = await _amtOrderInfoRepository.QueryByClauseAsync(u => u.OrderNo == orderNo); + if (amtOrder!=null) + { + await _binInfoRepository.UpdateAsync(i => i.AmtLock == 1,i => i.No == input.BinNos); + return Result.Success("新增预约订单id: "+amtOrder.Id); + + } + return Result.Fail("新增预约订单失败"); + + } + + public virtual async Task> CancelAmtOrder(DeleteAmtOrderInfoReq req) + { + var amtOrder = await _amtOrderInfoRepository.QueryByClauseAsync(u => u.Id == req.Id); + amtOrder.Status = 2; + + if (await _amtOrderInfoRepository.UpdateAsync(amtOrder)) + { + await _binInfoRepository.UpdateAsync(i => i.AmtLock == 1, i => i.ChargerNo == amtOrder.BinNos); + } + else + { + return Result.Fail("失败"); + } + return Result.Success("成功取消"); + } + + + private Expression>? queryTreeApp(QueryAmtOrderInfoPageReq req, + Expression>? where, ParameterExpression parameter) + { + if (req.Time != null) + { + DateTime startTime = new DateTime(req.Time.Value.Year, req.Time.Value.Month, 1, 0, 0, 0); + DateTime endTime = startTime.AddMonths(1).AddSeconds(-1); + + Expression> condition2Expr = + u => u.CreatedTime >= startTime && u.CreatedTime <= endTime; + where = where == null + ? condition2Expr + : Expression.Lambda>(Expression.AndAlso(where.Body, condition2Expr.Body), + parameter); + } + + if (req.CustomerId.HasValue) + { + Expression> condition2Expr = u => u.CustomerId == req.CustomerId; + where = where == null + ? condition2Expr + : Expression.Lambda>(Expression.AndAlso(where.Body, condition2Expr.Body), + parameter); + } + else + { + return null; + } + + return where; + } +} \ No newline at end of file diff --git a/Service/Station/CarTeamService.cs b/Service/Station/CarTeamService.cs new file mode 100644 index 0000000..c6080cd --- /dev/null +++ b/Service/Station/CarTeamService.cs @@ -0,0 +1,128 @@ +using Entity.DbModel.System.App; +using Entity.Dto.Req; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Entity; +using Repository.Station; +using SqlSugar; + +namespace Service.Station; + +[Scope] +public class CarTeamService : BaseServices +{ + private readonly CarTeamRepository _carTeamRepository; + + public CarTeamService( + CarTeamRepository carTeamRepository + ) + { + _carTeamRepository = carTeamRepository; + } + + /// + /// 获取车队分页 + /// + /// + /// + public async Task> Page(PageCarTeamReq input) + { + RefAsync total = 0; + + var items = await _carTeamRepository.QueryPageAsync( + entity => true, + !string.IsNullOrWhiteSpace(input.TeamCode), u => u.TeamCode.Equals(input.TeamCode.Trim()), + !string.IsNullOrWhiteSpace(input.TeamName), u => u.TeamName.Equals(input.TeamName.Trim()), + !string.IsNullOrWhiteSpace(input.Principal), u => u.Principal.Equals(input.Principal.Trim()), + u => u.CreatedTime, OrderByType.Desc, input.PageNum, input.PageSize, total); + return new PageResult() + { + PageNum = input.PageNum, + PageSize = input.PageSize, + ToTal = total, + Rows = items, + }; + } + + /// + /// 获取所有车队 + /// + /// + public async Task> GetTeamList() + { + return await _carTeamRepository.QueryAsync(); + } + + /// + /// 新增车队 + /// + /// + /// + public virtual async Task AddCarTeamReq(AddCarTeamReq input) + { + var existingUser = + await _carTeamRepository.QueryByClauseAsync(u => + u.TeamCode == input.TeamCode || u.TeamName == input.TeamName); + + if (existingUser?.TeamCode == input.TeamCode) + { + return "车队编码已存在"; + } + + if (existingUser?.TeamName == input.TeamName) + { + return "车队名称已存在"; + } + + // 插入新用户 + await _carTeamRepository.InsertAsync(input); + + // 查询新ID + CarTeam carTeam = await _carTeamRepository.QueryByClauseAsync(u => u.TeamCode == input.TeamCode); + + return "新增车队:" + carTeam.TeamName; + } + + /// + /// 车队修改 + /// + /// + /// + public virtual async Task> UpdateTeam(UpdateCarTeamReq team) + { + var existingTeam = + await _carTeamRepository.QueryByClauseAsync(u => + u.TeamCode == team.TeamCode || u.TeamName == team.TeamName && u.Id != team.Id); + + if (existingTeam?.TeamCode == team.TeamCode) + { + return Result.Fail("修改失败,车队编码已存在"); + } + + if (existingTeam?.TeamName == team.TeamName) + { + return Result.Fail("修改失败,车队名称已存在"); + } + + var updateAsync = await _carTeamRepository.UpdateAsync(team); + if (updateAsync) + { + return Result.Success("修改成功"); + } + + return Result.Fail("修改失败"); + } + + /// + /// 车队删除 + /// + /// + /// + /// + public virtual async Task DeleteTeam(DeleteCarTeamReq input) + { + var user = await _carTeamRepository.QueryByClauseAsync(u => u.Id == input.Id); + if (user == null) + throw new ArgumentException($"车队不存在"); + return await _carTeamRepository.DeleteAsync(user); + } +} \ No newline at end of file diff --git a/Service/Station/SwapOrderService.cs b/Service/Station/SwapOrderService.cs index 7746383..3181fd3 100644 --- a/Service/Station/SwapOrderService.cs +++ b/Service/Station/SwapOrderService.cs @@ -10,6 +10,7 @@ using AutoMapper; using Entity.Dto; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.Mvc; +using Repository.System.App; using Service.Mgr; namespace Service.Station; @@ -24,7 +25,7 @@ public class SwapOrderService : BaseServices public SwapOrderReportCloudRepository SwapOrderReportCloudRepository { get; set; } public SwapOrderMgr SwapOrderMgr { get; set; } - + public AppCustomerVehicleRepository _appCustomerVehicleRepository{ get; set; } public SwapOrderService(SwapOrderRepository dal) { BaseDal = dal; @@ -72,7 +73,7 @@ public class SwapOrderService : BaseServices where = queryTree(swapOrder, where, parameter); #endregion - + //查询 //var swapOrderResp = PageResult.ConvertPage(swapOrderRepository.QueryIPageByCause(swapOrder, where)); @@ -85,8 +86,62 @@ public class SwapOrderService : BaseServices //List StepList = new List(); return PageResult.ConvertPage(swapOrderRepository.QueryIPage(swapOrder, where)); } + + + public PageResult AppQuerySwapOrder(QuerySwapOrderPageReq swapOrder) + { + //创建一个空的表达式树 + Expression> where = null; + //// 定义参数表达式 + ParameterExpression parameter = Expression.Parameter(typeof(SwapOrder), "u"); + + + where = queryTreeApp(swapOrder, where, parameter); + if (where==null) + { + return new PageResult(); + } + + return PageResult.ConvertPage(swapOrderRepository.QueryIPage(swapOrder, where)); + } + + + private Expression>? queryTreeApp(QuerySwapOrderPageReq swapOrder, + Expression>? where, ParameterExpression parameter) + { + + if (swapOrder.Time != null) + { + DateTime startTime = new DateTime(swapOrder.Time.Value.Year, swapOrder.Time.Value.Month, 1, 0, 0, 0); + DateTime endTime = startTime.AddMonths(1).AddSeconds(-1); + + Expression> condition2Expr = u => u.CreatedTime >= startTime && u.CreatedTime <= endTime; + where = where == null + ? condition2Expr + : Expression.Lambda>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter); + } + + if (swapOrder.CustomerId.HasValue) + { + List vinList = _appCustomerVehicleRepository.GetVinList(swapOrder.CustomerId); + + if (vinList != null && vinList.Count > 0) + { + Expression> condition2Expr = u => vinList.Contains(u.VehicleVin); + where = where == null + ? condition2Expr + : Expression.Lambda>(Expression.AndAlso(where.Body, condition2Expr.Body), + parameter); + } + } + else + { + return null; + } + return where; + } - private static Expression>? queryTree(QuerySwapOrderPageReq swapOrder, + private Expression>? queryTree(QuerySwapOrderPageReq swapOrder, Expression>? where, ParameterExpression parameter) { if (!string.IsNullOrEmpty(swapOrder.Sn)) @@ -106,6 +161,21 @@ public class SwapOrderService : BaseServices : Expression.Lambda>(Expression.AndAlso(where.Body, condition2Expr.Body), parameter); } + + if (swapOrder.CustomerId.HasValue) + { + List vinList = _appCustomerVehicleRepository.GetVinList(swapOrder.CustomerId); + + if (vinList != null && vinList.Count > 0) + { + Expression> condition2Expr = u => vinList.Contains(u.VehicleVin); + where = where == null + ? condition2Expr + : Expression.Lambda>(Expression.AndAlso(where.Body, condition2Expr.Body), + parameter); + } + } + if (!string.IsNullOrEmpty(swapOrder.VehicleMac)) { diff --git a/Service/System/App/AppCustomerService.cs b/Service/System/App/AppCustomerService.cs new file mode 100644 index 0000000..ed52186 --- /dev/null +++ b/Service/System/App/AppCustomerService.cs @@ -0,0 +1,159 @@ +using AutoMapper; +using Common.Util; +using Entity.DbModel.System.App; +using Entity.Dto.Req.App; +using Entity.Dto.Resp; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Entity; +using Repository.System.App; + +namespace Service.System.App; + +[Scope] +public class AppCustomerService : BaseServices +{ + private readonly AppCustomerRepository _appCustomerRepository; + + public AppCustomerService( + AppCustomerRepository appCustomerRepository + ) + { + _appCustomerRepository = appCustomerRepository; + } + + /// + /// App端新增用户 + /// + /// + /// + public virtual async Task AddAppCustomer(AddAppCustomerReq input) + { + var existingUser = + await _appCustomerRepository.QueryByClauseAsync(u => + u.LoginNo == input.LoginNo || u.IphoneNo == input.IphoneNo); + + if (existingUser?.LoginNo == input.LoginNo) + { + return "账号已存在"; + } + + // 对密码进行加密 + input.LoginPsd = CryptogramUtil.Encrypt(input.LoginPsd); + + // 插入新用户 + await _appCustomerRepository.InsertAsync(input); + + // 查询新用户的ID + AppCustomer newAddUser = await _appCustomerRepository.QueryByClauseAsync(u => u.LoginNo == input.LoginNo); + + return "新增账号:" + newAddUser.LoginNo; + } + + /// + /// App用户基础信息 + /// + /// + /// + public virtual async Task GetBaseInfo(String loginNo) + { + AppCustomer appCustomer = await _appCustomerRepository.QueryByClauseAsync(u => u.LoginNo == loginNo); + + var config = new MapperConfiguration(cfg => { cfg.CreateMap().ReverseMap(); }); + IMapper mapper = config.CreateMapper(); + + AppCustomerResp vo = mapper.Map(appCustomer); + return vo; + } + + /// + /// 修改App用户基础信息 + /// + /// + /// + public virtual async Task> UpdateBaseInfo(UpdateAppCustomerReq user) + { + var existingUser = + await _appCustomerRepository.QueryByClauseAsync(u => + u.LoginNo == user.LoginNo && u.Id != user.Id); + + if (existingUser?.LoginNo == user.LoginNo) + { + return Result.Fail("修改失败,账号已存在"); + } + + int updateAsync = await _appCustomerRepository.UpdateAsync(user, true, u => new { u.LoginPsd }); + if (updateAsync > 0) + { + return Result.Success("修改成功"); + } + + return Result.Fail("修改失败"); + } + + /// + /// 绑定车队 + /// + /// + /// + public virtual async Task> BindTeam(CustomerTeamReq user) + { + var existingUser = await _appCustomerRepository.QueryByClauseAsync(u => u.LoginNo == user.LoginNo); + + if (existingUser == null) + { + return Result.Fail("账户不存在"); + } + + // 绑定or解绑 + return user.Bind ? await TeamBind(user, existingUser) : await UnbindTeam(existingUser); + } + + /// + /// 绑定车队 + /// + /// + /// + /// + private async Task> TeamBind(CustomerTeamReq user, AppCustomer existingUser) + { + existingUser.TeamId = user.TeamId; + var updateAsync = await _appCustomerRepository.UpdateAsync(existingUser, true); + + return updateAsync > 0 ? Result.Success("绑定成功") : Result.Fail("绑定失败"); + } + + /// + /// 解绑车队 + /// + /// + /// + private async Task> UnbindTeam(AppCustomer existingUser) + { + existingUser.TeamId = null; + var updateAsync = await _appCustomerRepository.UpdateAsync(existingUser, false); + + return updateAsync > 0 ? Result.Success("解绑成功") : Result.Fail("解绑失败"); + } + + + /// + /// 修改密码 + /// + /// + /// + public virtual async Task UpdateCustomerPsd(CustomerPwdReq input) + { + var user = await _appCustomerRepository.QueryByClauseAsync(u => u.LoginNo == input.LoginNo); + + if (CryptogramUtil.Decrypt(user.LoginPsd) != input.PasswordOld) + return "旧密码不匹配"; + + if (input.PasswordOld == input.PasswordNew) + return "新密码不能与旧密码相同"; + + user.LoginPsd = CryptogramUtil.Encrypt(input.PasswordNew); + + await _appCustomerRepository.UpdateAsync(user); + return "修改密码成功"; + } +} \ No newline at end of file diff --git a/Service/System/App/AppCustomerVehicleService.cs b/Service/System/App/AppCustomerVehicleService.cs new file mode 100644 index 0000000..6a34aa6 --- /dev/null +++ b/Service/System/App/AppCustomerVehicleService.cs @@ -0,0 +1,119 @@ +using Entity.DbModel.System.App; +using Entity.Dto.Req; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Entity; +using Repository.System.App; +using SqlSugar; + +namespace Service.System.App; + +[Scope()] +public class AppCustomerVehicleService : BaseServices +{ + private readonly AppCustomerVehicleRepository _appCustomerVehicleRepository; + + public AppCustomerVehicleService( + AppCustomerVehicleRepository appCustomerVehicleRepository + ) + { + _appCustomerVehicleRepository = appCustomerVehicleRepository; + } + + /// + /// 车辆分页查询 + /// + /// + /// + public async Task> Page(PageCustomerVehicleReq input) + { + RefAsync total = 0; + if (!input.CustomerId.HasValue) + { + return new PageResult(); + } + + var items = await _appCustomerVehicleRepository.QueryPageAsync( + entity => true, + (input.CustomerId.HasValue), u => u.CustomerId.Equals(input.CustomerId), + !string.IsNullOrWhiteSpace(input.CarNo), u => u.CarNo.Equals(input.CarNo.Trim()), + (input.AuditStatus.HasValue), u => u.AuditStatus.Equals(input.AuditStatus), + u => u.CreatedTime, OrderByType.Desc, input.PageNum, input.PageSize, total); + return new PageResult() + { + PageNum = input.PageNum, + PageSize = input.PageSize, + ToTal = total, + Rows = items, + }; + } + + /// + /// 车辆新增 + /// + /// + /// + public virtual async Task AddCustomerVehicle(AddCustomerVehicleReq input) + { + if (!input.CustomerId.HasValue) + { + return "客户id为空"; + } + + AppCustomerVehicle vehicle = + await _appCustomerVehicleRepository.QueryByClauseAsync(u => u.CarNo == input.CarNo); + if (vehicle != null) + { + return "该车牌已被绑定请先解绑"; + } + + input.ApplyTime = DateTime.Now; + input.AuditStatus = 0; + + await _appCustomerVehicleRepository.InsertAsync(input); + + // 查询新ID + AppCustomerVehicle newVehicle = + await _appCustomerVehicleRepository.QueryByClauseAsync(u => u.CarNo == input.CarNo); + + return "新增车辆:" + newVehicle.CarNo; + } + + /// + /// 车辆审核 + /// + /// + /// + public virtual async Task> AuditVehicle(VehicleAuditReq req) + { + var vehicle = await _appCustomerVehicleRepository.QueryByClauseAsync(u => u.CarNo == req.CarNo); + + if (vehicle == null) + { + return Result.Fail("车辆不存在"); + } + + vehicle.AuditId = req.AuditId; + vehicle.AuditTime = DateTime.Now; + vehicle.AuditStatus = req.AuditStatus; + vehicle.AuditName = req.AuditName; + + var updateAsync = await _appCustomerVehicleRepository.UpdateAsync(vehicle, true); + + return updateAsync > 0 ? Result.Success("修改成功") : Result.Fail("修改失败"); + } + + + /// + /// 删除解绑车辆 + /// + /// + /// + /// + public virtual async Task DeleteCustomerVehicle(DeleteCustomerVehicleReq input) + { + var vehicle = await _appCustomerVehicleRepository.QueryByClauseAsync(u => u.Id == input.Id); + if (vehicle == null) + throw new ArgumentException($"车辆不存在"); + return await _appCustomerVehicleRepository.DeleteAsync(vehicle); + } +} \ No newline at end of file diff --git a/Service/System/App/AppLoginService.cs b/Service/System/App/AppLoginService.cs new file mode 100644 index 0000000..7c1bff4 --- /dev/null +++ b/Service/System/App/AppLoginService.cs @@ -0,0 +1,103 @@ +using Autofac; +using AutoMapper; +using Common.Const; +using Common.Enum; +using Common.Util; +using Entity.DbModel.System.App; +using Entity.Dto.Resp; +using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Entity; +using HybirdFrameworkCore.Redis; +using Repository.System.App; + +namespace Service.System.App; + +[Scope] +public class AppLoginService +{ + private readonly AppCustomerRepository _appCustomerRepository; + + public AppLoginService( + AppCustomerRepository appCustomerRepository + ) + { + _appCustomerRepository = appCustomerRepository; + } + + RedisHelper _redisHelper = AppInfo.Container.Resolve(); + + public async Task> Login(string username, string password) + { + // 判断密码错误次数(默认10次) + var keyErrorPasswordCount = $"{RedisConstMgr.AppKeyErrorPasswordCount}{username}"; + int errorPasswordCount = Convert.ToInt32(_redisHelper.GetStrValue(keyErrorPasswordCount)); + if (errorPasswordCount >= 10) + { + throw new ArgumentException($"密码错误次数过多,账号已锁定,请半小时后重试!"); + } + AppCustomer user = await _appCustomerRepository.QueryByClauseAsync(u => u.LoginNo == username); + + if (user == null) + { + throw new ArgumentException($"用户名不存在"); + } + + if (user.State == StatusEnum.Disable) + { + throw new ArgumentException($"当前账户处于禁用状态"); + } + + // // 国密SM2解密(前端密码传输SM2加密后的) + // password = CryptogramUtil.SM2Decrypt(password); + + string verifyPassword = VerifyPassword(password, keyErrorPasswordCount, errorPasswordCount, user); + + if (verifyPassword.Equals("密码不正确")) + { + throw new ArgumentException($"密码不正确"); + } + + // _userManager.SetManagerContent(user); + + return Result.Success(CreateResult(user, JwtUtil.BuildToken(username))) ; + } + + private string VerifyPassword(string inputReq, string keyErrorPasswordCount, int errorPasswordCount, + AppCustomer user) + { + string result = ""; + if (CryptogramUtil.CryptoType == CryptogramEnum.MD5.ToString()) + { + if (!user.LoginPsd.Equals(MD5Util.MD5Encrypt32(inputReq))) + { + errorPasswordCount++; + _redisHelper.SetKeyValueStr(keyErrorPasswordCount, errorPasswordCount.ToString()); + result = "密码不正确"; + } + } + else + { + if (!CryptogramUtil.Decrypt(user.LoginPsd).Equals(inputReq)) + { + errorPasswordCount++; + _redisHelper.SetKeyValueStr(keyErrorPasswordCount, errorPasswordCount.ToString()); + result = "密码不正确"; + } + } + + return result; + } + + private AppLoginResp CreateResult(AppCustomer user, string token) + { + var config = new MapperConfiguration(cfg => { cfg.CreateMap().ReverseMap(); }); + IMapper mapper = config.CreateMapper(); + + AppLoginResp vo = mapper.Map(user); + + vo.token = token; + vo.expireAt = LoginService.getTimeStamp(); + return vo; + } +} \ No newline at end of file diff --git a/Service/System/SysFileServices.cs b/Service/System/SysFileServices.cs index 957fd48..742e137 100644 --- a/Service/System/SysFileServices.cs +++ b/Service/System/SysFileServices.cs @@ -1,23 +1,14 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -using System.Text; -using System.Text.RegularExpressions; -using System.Web; -using Aliyun.OSS.Util; -using Common.Enum; -using Common.Util; -using Entity.Base; using Entity.DbModel.System; +using Entity.DbModel.System.App; using Entity.Dto.Req; -using Furion.VirtualFileServer; using HybirdFrameworkCore.Autofac.Attribute; -using HybirdFrameworkCore.Configuration; using HybirdFrameworkCore.Entity; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using OnceMi.AspNetCore.OSS; using Repository.System; +using Repository.System.App; using Service.Mgr; using SqlSugar; using Yitter.IdGenerator; @@ -32,16 +23,20 @@ namespace Service.System private readonly SysFileMgr _sysFileMgr; private readonly string _imageType = ".jpg.png.bmp.gif.tif"; - + + private readonly AppCustomerRepository _appCustomerRepository; public SysFileServices( SysUserRepository sysUserRepository, SysFileRepository sysFileRep, - SysFileMgr sysFileMgr) + SysFileMgr sysFileMgr, + AppCustomerRepository appCustomerRepository + ) { _sysUserRep = sysUserRepository; _sysFileRep = sysFileRep; _sysFileMgr = sysFileMgr; + _appCustomerRepository = appCustomerRepository; } @@ -59,6 +54,21 @@ namespace Service.System await _sysUserRep.UpdateAsync(u => new SysUser() { Avatar = sysFile.Url }, u => u.Id == user.Id); return sysFile; } + + /// + /// App端上传头像 + /// + /// + /// + /// + /// + public async Task UploadAppAvatar([Required] IFormFile file, string path,string loginNo) + { + var sysFile = await _sysFileMgr.HandleUploadFile(file, path, _imageType); + + await _appCustomerRepository.UpdateAsync(u => new AppCustomer() { UserAvatar = sysFile.Url }, u => u.LoginNo == loginNo); + return sysFile; + } /// /// 获取文件分页列表 🔖 @@ -95,6 +105,7 @@ namespace Service.System { return await _sysFileMgr.HandleUploadFile(file, path); } + /// /// 上传文件Base64 diff --git a/WebStarter/Controllers/AmtOrderInfoController.cs b/WebStarter/Controllers/AmtOrderInfoController.cs new file mode 100644 index 0000000..47b647a --- /dev/null +++ b/WebStarter/Controllers/AmtOrderInfoController.cs @@ -0,0 +1,59 @@ +using System.ComponentModel.DataAnnotations; +using Entity.Api.Req; +using Entity.DbModel.Station; +using HybirdFrameworkCore.Entity; +using log4net; +using Microsoft.AspNetCore.Mvc; +using Service.Station; + +namespace WebStarter.Controllers; + +/// +/// 预约订单 +/// +[ApiController] +[Route("api/[controller]")] +public class AmtOrderInfoController : ControllerBase +{ + private static readonly ILog Log = LogManager.GetLogger(typeof(AmtOrderInfoController)); + private readonly AmtOrderInfoService _amtOrderInfoService; + + + public AmtOrderInfoController(AmtOrderInfoService amtOrderInfoService) + { + this._amtOrderInfoService = amtOrderInfoService; + } + + /// + /// 预约订单查询 + /// + /// + /// + [HttpPost("Page")] + public async Task>> QueryPage([FromBody] QueryAmtOrderInfoPageReq req) + { + return Result>.Success(_amtOrderInfoService.AppQuerySwapOrder(req)); + } + /// + /// 添加预约单 + /// + /// + /// + [HttpPost] + [Route("add")] + public async Task> AddTeam([FromBody] [Required] AddAmtOrderInfoReq input) + { + return await _amtOrderInfoService.InsertAmtOrder(input); + } + /// + /// 取消预约订单 + /// + /// + /// + [HttpPost] + [Route("CancelAmtOrder")] + public async Task> CancelAmtOrder([FromBody] [Required] DeleteAmtOrderInfoReq input) + { + return await _amtOrderInfoService.CancelAmtOrder(input); + } +} \ No newline at end of file diff --git a/WebStarter/Controllers/CarTeamController.cs b/WebStarter/Controllers/CarTeamController.cs new file mode 100644 index 0000000..12332b2 --- /dev/null +++ b/WebStarter/Controllers/CarTeamController.cs @@ -0,0 +1,94 @@ +using System.ComponentModel.DataAnnotations; +using Entity.DbModel.System.App; +using Entity.Dto.Req; +using HybirdFrameworkCore.Entity; +using Microsoft.AspNetCore.Mvc; +using Service.Station; + +namespace WebStarter.Controllers; + +/// +/// 车队 +/// +[ApiController] +[Route("api/[controller]")] +public class CarTeamController +{ + private readonly CarTeamService _carTeamService; + + /// + /// + /// + /// + public CarTeamController(CarTeamService carTeamService) + { + _carTeamService = carTeamService; + } + + + /// + /// 查询车队分页 + /// + /// 查询参数 + /// + [HttpPost] + [Route("GetTeamPage")] + public async Task> GetTeamPage( + [FromBody] PageCarTeamReq req) + { + return await _carTeamService.Page(req); + } + /// + /// 获取所有车队 + /// + /// + [HttpPost] + [Route("GetTeamList")] + public async Task>> GetTeamList() + { + return Result>.Success(await _carTeamService.GetTeamList()); + } + + + /// + /// 新增车队 + /// + /// + /// + [HttpPost] + [Route("add")] + public async Task> AddTeam([FromBody] [Required] AddCarTeamReq input) + { + var data = await _carTeamService.AddCarTeamReq(input); + return Result.Success(data); + } + + + /// + /// 修改车队 + /// + /// + /// + [HttpPost] + [Route("UpdateTeam")] + public async Task> UpdateTeam([FromBody] UpdateCarTeamReq user) + { + return await _carTeamService.UpdateTeam(user); + } + + /// + /// 删除车队 + /// + /// + /// + [HttpPost] + [Route("delete")] + public async Task> DeleteTeam([FromBody] [Required] DeleteCarTeamReq input) + { + var data = await _carTeamService.DeleteTeam(input); + if (data) + return Result.Success(data); + else + return Result.Fail(data); + } +} \ No newline at end of file diff --git a/WebStarter/Controllers/SwapOrderController.cs b/WebStarter/Controllers/SwapOrderController.cs index bd5e979..bcf8119 100644 --- a/WebStarter/Controllers/SwapOrderController.cs +++ b/WebStarter/Controllers/SwapOrderController.cs @@ -56,6 +56,30 @@ public class SwapOrderController : ControllerBase var swapOrderResp = swapOrderService.QuerySwapOrder(req); Log.Info($"查询换电订单 SwapOrderController end QueryPage swapOrderService.QuerySwapOrder req={req}"); + PackageSwapOrder(swapOrderResp); + return Result>.Success(swapOrderResp); + } + + /// + /// app查询换电订单 + /// + /// + /// + [HttpPost("AppSwapOrder")] + public async Task>> AppSwapOrder([FromBody] QuerySwapOrderPageReq req) + { + Log.Info($"SwapOrderController QueryPage req={req}"); + + Log.Info($"查询换电订单 SwapOrderController start QueryPage swapOrderService.QuerySwapOrder req={req}"); + var swapOrderResp = swapOrderService.AppQuerySwapOrder(req); + Log.Info($"查询换电订单 SwapOrderController end QueryPage swapOrderService.QuerySwapOrder req={req}"); + + PackageSwapOrder(swapOrderResp); + return Result>.Success(swapOrderResp); + } + + private void PackageSwapOrder(PageResult swapOrderResp) + { //获取所有订单号 var orderSns = swapOrderResp.Rows.Select(row => row.Sn).ToList(); Log.Info($"查询上报云平台次数 SwapOrderController start QueryPage swapOrderService.QueryReportCloudNumBySn req={orderSns}"); @@ -112,7 +136,6 @@ public class SwapOrderController : ControllerBase swapOrderResp.Rows[i].StepList .AddRange(swapOrderStep.Where(step => step.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList()); } - return Result>.Success(swapOrderResp); } private PageResult BatteryCodeList(QuerySwapOrderPageReq req) diff --git a/WebStarter/Controllers/System/App/AppCustomerController.cs b/WebStarter/Controllers/System/App/AppCustomerController.cs new file mode 100644 index 0000000..dc028c4 --- /dev/null +++ b/WebStarter/Controllers/System/App/AppCustomerController.cs @@ -0,0 +1,92 @@ +using System.ComponentModel.DataAnnotations; +using Entity.Dto.Req.App; +using Entity.Dto.Resp; +using HybirdFrameworkCore.Entity; +using Microsoft.AspNetCore.Mvc; +using Service.System.App; + +namespace WebStarter.Controllers.System.App; + +/// +/// App用户 +/// +[ApiController] +[Route("api/[controller]")] +public class AppCustomerController +{ + private readonly AppCustomerService _appCustomerService; + + /// + /// + /// + /// + public AppCustomerController(AppCustomerService appCustomerService) + { + _appCustomerService = appCustomerService; + } + + /// + /// App用户注册 + /// + /// + /// + [HttpPost] + [Route("add")] + public async Task> AddAppCustomer([FromBody] [Required] AddAppCustomerReq input) + { + var data = await _appCustomerService.AddAppCustomer(input); + return Result.Success(data); + } + + /// + /// 获取用户基础信息 + /// + /// + /// + [HttpGet] + [Route("GetInfo")] + public async Task> GetBaseInfo(String loginNo) + { + return Result.Success(await _appCustomerService.GetBaseInfo(loginNo)); + } + + /// + /// 修改用户基础信息 + /// + /// + /// + [HttpPost] + [Route("UpdateInfo")] + public async Task> UpdateInfo([FromBody] UpdateAppCustomerReq user) + { + return await _appCustomerService.UpdateBaseInfo(user); + } + + /// + /// 车队绑定 + /// + /// + /// + [HttpPost] + [Route("BindTeam")] + public async Task> BindTeam([FromBody] CustomerTeamReq user) + { + return await _appCustomerService.BindTeam(user); + } + + /// + /// 修改密码 + /// + /// + /// + [HttpPost] + [Route("UpdateInfoPwd")] + public async Task> UpdateInfoPwd([FromBody] CustomerPwdReq input) + { + var data = await _appCustomerService.UpdateCustomerPsd(input); + return Result.Success(data); + } + + + +} \ No newline at end of file diff --git a/WebStarter/Controllers/System/App/AppCustomerVehicleController.cs b/WebStarter/Controllers/System/App/AppCustomerVehicleController.cs new file mode 100644 index 0000000..856772c --- /dev/null +++ b/WebStarter/Controllers/System/App/AppCustomerVehicleController.cs @@ -0,0 +1,78 @@ +using System.ComponentModel.DataAnnotations; +using Entity.DbModel.System.App; +using Entity.Dto.Req; +using HybirdFrameworkCore.Entity; +using Microsoft.AspNetCore.Mvc; +using Service.System.App; + +namespace WebStarter.Controllers.System.App; + +/// +/// 客户车辆 +/// +[ApiController] +[Route("api/[controller]")] +public class AppCustomerVehicleController +{ + private readonly AppCustomerVehicleService _appCustomerVehicleService; + + /// + /// + /// + /// + public AppCustomerVehicleController(AppCustomerVehicleService appCustomerVehicleService) + { + _appCustomerVehicleService = appCustomerVehicleService; + } + /// + /// 客户车辆分页 + /// + /// + /// + [HttpPost] + [Route("CustomerVehiclePage")] + public async Task> CustomerVehiclePage( + [FromBody] PageCustomerVehicleReq req) + { + return await _appCustomerVehicleService.Page(req); + } + /// + /// 车辆新增 + /// + /// + /// + [HttpPost] + [Route("add")] + public async Task> AddTeam([FromBody] [Required] AddCustomerVehicleReq input) + { + var data = await _appCustomerVehicleService.AddCustomerVehicle(input); + return Result.Success(data); + } + /// + /// 车辆审核 + /// + /// + /// + [HttpPost] + [Route("AuditVehicle")] + public async Task> AuditVehicle([FromBody] VehicleAuditReq req) + { + return await _appCustomerVehicleService.AuditVehicle(req); + } + + /// + /// 删除解绑车辆 + /// + /// + /// + [HttpPost] + [Route("delete")] + public async Task> Delete([FromBody] [Required] DeleteCustomerVehicleReq input) + { + var data = await _appCustomerVehicleService.DeleteCustomerVehicle(input); + if (data) + return Result.Success(data); + else + return Result.Fail(data); + } +} \ No newline at end of file diff --git a/WebStarter/Controllers/System/App/AppLoginController.cs b/WebStarter/Controllers/System/App/AppLoginController.cs new file mode 100644 index 0000000..cd5ec78 --- /dev/null +++ b/WebStarter/Controllers/System/App/AppLoginController.cs @@ -0,0 +1,39 @@ +using System.ComponentModel.DataAnnotations; +using Entity.Dto.Req; +using Entity.Dto.Resp; +using HybirdFrameworkCore.Entity; +using Microsoft.AspNetCore.Mvc; +using Service.System.App; + +namespace WebStarter.Controllers.System.App; + +/// +/// App登录 +/// +[Produces("application/json")] +[ApiController] +public class AppLoginController : ControllerBase +{ + private readonly AppLoginService _appLoginService; + + /// + /// + /// + /// + public AppLoginController(AppLoginService appLoginService) + { + _appLoginService = appLoginService; + } + + /// + /// 登录 + /// + /// 账户 密码 + /// + [HttpPost] + [Route("/api/app/login")] + public async Task> Login([FromBody] [Required] LoginReq loginInputReq) + { + return await _appLoginService.Login(loginInputReq.Account, loginInputReq.Password); + } +} \ No newline at end of file diff --git a/WebStarter/Controllers/System/SysFileController.cs b/WebStarter/Controllers/System/SysFileController.cs index e72eb3f..ba899ae 100644 --- a/WebStarter/Controllers/System/SysFileController.cs +++ b/WebStarter/Controllers/System/SysFileController.cs @@ -32,7 +32,14 @@ namespace WebStarter.Controllers.System [Route("/api/sysFile/uploadFile")] public async Task UploadFile([Required] IFormFile file, [FromQuery] string? path) { - return await _sysFileServices.UploadFile(file, path); + return await _sysFileServices.UploadFile(file, _webHostEnvironment.WebRootPath); + } + + [HttpPost] + [Route("/api/app/uploadFile")] + public async Task> AppUploadFile([Required] IFormFile file) + { + return Result.Success(await _sysFileServices.UploadFile(file, _webHostEnvironment.WebRootPath)); } [HttpPost] @@ -57,6 +64,19 @@ namespace WebStarter.Controllers.System { return await _sysFileServices.UploadAvatar(file, _webHostEnvironment.WebRootPath); } + + /// + /// App上传头像 + /// + /// + /// + /// + [HttpPost] + [Route("/api/app/sysFile/uploadAvatar")] + public async Task UploadAppAvatar([Required] IFormFile file, [FromForm] string loginNo) + { + return await _sysFileServices.UploadAppAvatar(file, _webHostEnvironment.WebRootPath,loginNo); + } } diff --git a/WebStarter/appsettings.dev.json b/WebStarter/appsettings.dev.json index cc8ae47..9d46d74 100644 --- a/WebStarter/appsettings.dev.json +++ b/WebStarter/appsettings.dev.json @@ -152,7 +152,7 @@ "enable": true }, "task": { - "enable": false + "enable": true }, "Task": { "Disabled": "ChargeOrderUploadTask" @@ -160,6 +160,9 @@ "fire": { "enable": false }, + "Job": { + "Enabled": true + }, "Log": { "Src": "D:\\RiderProjects\\hn_back_charger\\WebStarter\\bin\\Debug\\net6.0\\logs", "Dest": "D:\\zip", diff --git a/WebStarter/db/app新增表/app_customer.sql b/WebStarter/db/app新增表/app_customer.sql new file mode 100644 index 0000000..e0620f3 --- /dev/null +++ b/WebStarter/db/app新增表/app_customer.sql @@ -0,0 +1,55 @@ +/* + Navicat Premium Data Transfer + + Source Server : 192.168.2.2 + Source Server Type : MySQL + Source Server Version : 80034 + Source Host : 192.168.2.2:3306 + Source Schema : eaxing_dev + + Target Server Type : MySQL + Target Server Version : 80034 + File Encoding : 65001 + + Date: 30/07/2024 08:51:09 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for app_customer +-- ---------------------------- +DROP TABLE IF EXISTS `app_customer`; +CREATE TABLE `app_customer` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `login_no` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '登录号码', + `team_id` bigint NULL DEFAULT NULL COMMENT '车队ID', + `login_type` tinyint NULL DEFAULT NULL COMMENT '登录方式', + `login_psd` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '登录密码', + `is_member` tinyint NULL DEFAULT 0 COMMENT '是否是会员:0否1是', + `nick_name` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '用户昵称', + `user_name` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '姓名', + `user_avatar` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '用户头像URL', + `gender` tinyint NULL DEFAULT 1 COMMENT '性别:1男2女3保密', + `identify_code` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '身份证号码', + `iphone_no` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '手机号码', + `email` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '邮箱', + `home_addr` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '家庭住址', + `car_no` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '车牌号', + `state` tinyint NOT NULL DEFAULT 0 COMMENT '使用状态:0正常;1停用', + `register_plat` tinyint NULL DEFAULT 0 COMMENT '注册平台', + `user_id` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '支付宝userid', + `open_id` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '微信openid', + `union_id` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL, + `wx_open_id` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '公众号openid', + `birthday` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '出生日期', + `audit_state` tinyint NULL DEFAULT 0 COMMENT '审核进度:0:未审核;1:通过审核;2:审核拒绝', + `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人', + `created_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间', + `updated_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人', + `updated_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 199 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '用户注册信息' ROW_FORMAT = DYNAMIC; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/WebStarter/db/app新增表/app_customer_vehicle.sql b/WebStarter/db/app新增表/app_customer_vehicle.sql new file mode 100644 index 0000000..9ba8fa4 --- /dev/null +++ b/WebStarter/db/app新增表/app_customer_vehicle.sql @@ -0,0 +1,53 @@ +/* + Navicat Premium Data Transfer + + Source Server : 192.168.2.2 + Source Server Type : MySQL + Source Server Version : 80034 + Source Host : 192.168.2.2:3306 + Source Schema : eaxing_dev + + Target Server Type : MySQL + Target Server Version : 80034 + File Encoding : 65001 + + Date: 30/07/2024 09:00:41 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for app_customer_vehicle +-- ---------------------------- +DROP TABLE IF EXISTS `app_customer_vehicle`; +CREATE TABLE `app_customer_vehicle` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', + `customer_id` bigint NULL DEFAULT NULL COMMENT '客户id', + `user_name` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '用户名', + `phone` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '手机号', + `team_id` bigint NULL DEFAULT NULL COMMENT '车队id', + `car_id` bigint NULL DEFAULT NULL COMMENT '车辆id', + `car_no` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '车牌号', + `vin` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT 'vin', + `mac` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT 'mac地址', + `engine_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '发动机编号', + `vehicle_license` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '行驶证图片', + `driver_license` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '驾驶证图片', + `id_front` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '身份证人像面', + `id_back` varchar(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '身份证国徽面', + `apply_time` datetime NULL DEFAULT NULL COMMENT '申请认证时间', + `audit_status` int NULL DEFAULT NULL COMMENT '0:未审核;1:通过审核;2:审核拒绝', + `audit_reason` varchar(500) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '申请原因', + `is_default` int NULL DEFAULT 0 COMMENT '是否默认扣费账户:0否;1是', + `audit_id` bigint NULL DEFAULT NULL COMMENT '审核id', + `audit_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '审核人', + `audit_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '审核时间', + `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人', + `created_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间', + `updated_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人', + `updated_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 173 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '客户车辆表' ROW_FORMAT = DYNAMIC; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/WebStarter/db/app新增表/car_team.sql b/WebStarter/db/app新增表/car_team.sql new file mode 100644 index 0000000..e3415bb --- /dev/null +++ b/WebStarter/db/app新增表/car_team.sql @@ -0,0 +1,43 @@ +/* + Navicat Premium Data Transfer + + Source Server : 192.168.2.2 + Source Server Type : MySQL + Source Server Version : 80034 + Source Host : 192.168.2.2:3306 + Source Schema : eaxing_dev + + Target Server Type : MySQL + Target Server Version : 80034 + File Encoding : 65001 + + Date: 30/07/2024 08:51:17 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for car_team +-- ---------------------------- +DROP TABLE IF EXISTS `car_team`; +CREATE TABLE `car_team` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键Id', + `customer_id` bigint NULL DEFAULT NULL COMMENT '客户id', + `team_code` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '车队编码', + `team_name` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '车队名称', + `principal` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '负责人', + `contact_way` varchar(300) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '联系方式', + `is_discount` int NULL DEFAULT NULL COMMENT '是否打折:0:否;1是', + `discount_percent` int NULL DEFAULT NULL COMMENT '折扣比例:1-100', + `discount_scope` int NULL DEFAULT NULL COMMENT '折扣范围:0全部折扣;1:计费模型折扣;3电价折扣', + `rounding_mode` int NULL DEFAULT 0 COMMENT '舍入模式:0.向下取整;1.四舍五入;2.向上取整', + `limit` decimal(12, 2) NULL DEFAULT NULL COMMENT '额度限制,小于此额度则认证失败,提示余额不足', + `created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人', + `created_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间', + `updated_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人', + `updated_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 67 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '车队' ROW_FORMAT = DYNAMIC; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/WebStarter/db/app新增表/新增字段.txt b/WebStarter/db/app新增表/新增字段.txt new file mode 100644 index 0000000..015cc52 --- /dev/null +++ b/WebStarter/db/app新增表/新增字段.txt @@ -0,0 +1,2 @@ +ALTER TABLE amt_order_info +ADD customer_id BIGINT NOT NULL DEFAULT -1 COMMENT '客户id';