优化细节

development
温天培 2 years ago
parent 41d0ca2d1b
commit e27bd95b72

@ -11,10 +11,6 @@ namespace GDZZ.Application.Entity
[Description("余额表")] [Description("余额表")]
public class Balance : DEntityBase public class Balance : DEntityBase
{ {
/// <summary>
/// 租户Id
/// </summary>
public long TenantId { get; set; }
/// <summary> /// <summary>
/// 用户ID /// 用户ID
/// </summary> /// </summary>

@ -2,8 +2,6 @@
using SqlSugar; using SqlSugar;
using System.ComponentModel; using System.ComponentModel;
using GDZZ.Core.Entity; using GDZZ.Core.Entity;
using GDZZ.Core;
namespace GDZZ.Application.Entity namespace GDZZ.Application.Entity
{ {
/// <summary> /// <summary>
@ -20,7 +18,7 @@ namespace GDZZ.Application.Entity
/// <summary> /// <summary>
/// 用户类型 /// 用户类型
/// </summary> /// </summary>
public UserEnum Type { get; set; } public int Type { get; set; }
/// <summary> /// <summary>
/// 用户名 /// 用户名
/// </summary> /// </summary>
@ -32,7 +30,7 @@ namespace GDZZ.Application.Entity
/// <summary> /// <summary>
/// 公共状态 /// 公共状态
/// </summary> /// </summary>
public CommonStatus Status { get; set; } public int Status { get; set; }
/// <summary> /// <summary>
/// 微信用户ID /// 微信用户ID
/// </summary> /// </summary>
@ -45,5 +43,13 @@ namespace GDZZ.Application.Entity
/// 开发平台ID /// 开发平台ID
/// </summary> /// </summary>
public string UnionId { get; set; } public string UnionId { get; set; }
/// <summary>
/// 公司ID
/// </summary>
public long CompanyID { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Describe { get; set; }
} }
} }

@ -0,0 +1,35 @@
using System;
using SqlSugar;
using System.ComponentModel;
using GDZZ.Core.Entity;
namespace GDZZ.Application.Entity
{
/// <summary>
/// 消费记录
/// </summary>
[SugarTable("mini_consume")]
[Description("消费记录")]
public class Consume : DEntityBase
{
/// <summary>
/// 消费金额
/// </summary>
public decimal CAmount { get; set; }
/// <summary>
/// 余额
/// </summary>
public decimal Surplus { get; set; }
/// <summary>
/// 用户ID
/// </summary>
public long UserID { get; set; }
/// <summary>
/// 消费类型
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 沟通ID
/// </summary>
public long? ResumeID { get; set; }
}
}

@ -11,10 +11,6 @@ namespace GDZZ.Application.Entity
[Description("聊天用户好友表")] [Description("聊天用户好友表")]
public class LiveUserFriend : DEntityBase public class LiveUserFriend : DEntityBase
{ {
/// <summary>
/// 租户Id
/// </summary>
public long TenantId { get; set; }
/// <summary> /// <summary>
/// 好友ID /// 好友ID
/// </summary> /// </summary>

@ -9,11 +9,6 @@
余额表 余额表
</summary> </summary>
</member> </member>
<member name="P:GDZZ.Application.Entity.Balance.TenantId">
<summary>
租户Id
</summary>
</member>
<member name="P:GDZZ.Application.Entity.Balance.UserID"> <member name="P:GDZZ.Application.Entity.Balance.UserID">
<summary> <summary>
用户ID 用户ID
@ -69,6 +64,16 @@
开发平台ID 开发平台ID
</summary> </summary>
</member> </member>
<member name="P:GDZZ.Application.Entity.BaseUser.CompanyID">
<summary>
公司ID
</summary>
</member>
<member name="P:GDZZ.Application.Entity.BaseUser.Describe">
<summary>
描述
</summary>
</member>
<member name="T:GDZZ.Application.Entity.Company"> <member name="T:GDZZ.Application.Entity.Company">
<summary> <summary>
公司属性 公司属性
@ -94,6 +99,36 @@
公司详情图片 公司详情图片
</summary> </summary>
</member> </member>
<member name="T:GDZZ.Application.Entity.Consume">
<summary>
消费记录
</summary>
</member>
<member name="P:GDZZ.Application.Entity.Consume.CAmount">
<summary>
消费金额
</summary>
</member>
<member name="P:GDZZ.Application.Entity.Consume.Surplus">
<summary>
余额
</summary>
</member>
<member name="P:GDZZ.Application.Entity.Consume.UserID">
<summary>
用户ID
</summary>
</member>
<member name="P:GDZZ.Application.Entity.Consume.Sort">
<summary>
消费类型
</summary>
</member>
<member name="P:GDZZ.Application.Entity.Consume.ResumeID">
<summary>
沟通ID
</summary>
</member>
<member name="T:GDZZ.Application.Entity.FeedBack"> <member name="T:GDZZ.Application.Entity.FeedBack">
<summary> <summary>
意见反馈 意见反馈
@ -209,11 +244,6 @@
聊天用户好友表 聊天用户好友表
</summary> </summary>
</member> </member>
<member name="P:GDZZ.Application.Entity.LiveUserFriend.TenantId">
<summary>
租户Id
</summary>
</member>
<member name="P:GDZZ.Application.Entity.LiveUserFriend.FriendID"> <member name="P:GDZZ.Application.Entity.LiveUserFriend.FriendID">
<summary> <summary>
好友ID 好友ID
@ -533,13 +563,6 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:GDZZ.Application.Service.Auth.AuthService.WxPay(GDZZ.Application.AuthUserInput)">
<summary>
微信支付
</summary>
<param name="productId"></param>
<returns></returns>
</member>
<member name="T:GDZZ.Application.Service.Auth.IAuthService"> <member name="T:GDZZ.Application.Service.Auth.IAuthService">
<summary> <summary>
业务权限控制 业务权限控制
@ -552,41 +575,34 @@
<param name="phoneModel"></param> <param name="phoneModel"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:GDZZ.Application.Service.LiveChat.ILiveChatService"> <member name="T:GDZZ.Application.Service.WXPay.Dto.BalanceOut">
<summary> <summary>
即时聊天接口
</summary> </summary>
</member> </member>
<member name="T:GDZZ.Application.Service.LiveChat.LiveChatService"> <member name="P:GDZZ.Application.Service.WXPay.Dto.BalanceOut.UserID">
<summary> <summary>
即时聊天 用户ID
</summary> </summary>
</member> </member>
<member name="F:GDZZ.Application.Service.LiveChat.LiveChatService._chatHubContext"> <member name="P:GDZZ.Application.Service.WXPay.Dto.BalanceOut.Amount">
<summary> <summary>
聊天总线 余额
</summary> </summary>
</member> </member>
<member name="M:GDZZ.Application.Service.LiveChat.LiveChatService.#ctor(Microsoft.AspNetCore.SignalR.IHubContext{GDZZ.Core.ChatHub,GDZZ.Core.IChatClient},GDZZ.Core.SqlSugarRepository{GDZZ.Core.Entity.OnlineUser})"> <member name="P:GDZZ.Application.Service.WXPay.Dto.RechargeOut.TotalPrice">
<summary> <summary>
聊天服务 总价格
</summary> </summary>
<param name="chatHubContext"></param>
<param name="_sysOnlineUerRep"></param>
</member> </member>
<member name="T:GDZZ.Application.Service.WXPay.Dto.BalanceOut"> <member name="P:GDZZ.Application.Service.WXPay.Dto.RechargeOut.PaymentMoney">
<summary> <summary>
支付金额
</summary> </summary>
</member> </member>
<member name="P:GDZZ.Application.Service.WXPay.Dto.BalanceOut.UserID"> <member name="P:GDZZ.Application.Service.WXPay.Dto.RechargeOut.Status">
<summary> <summary>
用户ID 充值状态
</summary>
</member>
<member name="P:GDZZ.Application.Service.WXPay.Dto.BalanceOut.Amount">
<summary>
余额
</summary> </summary>
</member> </member>
<member name="T:GDZZ.Application.Service.WXPay.IWXPayService"> <member name="T:GDZZ.Application.Service.WXPay.IWXPayService">
@ -605,6 +621,24 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:GDZZ.Application.Service.WXPay.WXPayService.GetRechargeList">
<summary>
充值记录查询
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Service.WXPay.WXPayService.UpBalance(System.Decimal,System.Nullable{System.Int64})">
<summary>
修改余额
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Service.WXPay.WXPayService.GetBalance">
<summary>
查询消费记录
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Service.WXPay.WXPayService.WxPay(GDZZ.Application.AuthUserInput)"> <member name="M:GDZZ.Application.Service.WXPay.WXPayService.WxPay(GDZZ.Application.AuthUserInput)">
<summary> <summary>
微信小程序支付 微信小程序支付
@ -668,14 +702,24 @@
</summary> </summary>
</member> </member>
<member name="T:GDZZ.Application.BaseUserService"> <member name="P:GDZZ.Application.AuthUserOut.Describe">
<summary> <summary>
基础用户服务
</summary> </summary>
</member> </member>
<member name="F:GDZZ.Application.BaseUserService._oauthConfig"> <member name="P:GDZZ.Application.AuthUserOut.Tenant">
<summary> <summary>
获取配置文件 租户信息
</summary>
</member>
<member name="P:GDZZ.Application.AuthUserOut.companyDto">
<summary>
公司信息
</summary>
</member>
<member name="T:GDZZ.Application.BaseUserService">
<summary>
基础用户服务
</summary> </summary>
</member> </member>
<member name="M:GDZZ.Application.BaseUserService.Update(GDZZ.Application.UpdateBaseUserInput)"> <member name="M:GDZZ.Application.BaseUserService.Update(GDZZ.Application.UpdateBaseUserInput)">
@ -685,6 +729,12 @@
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:GDZZ.Application.BaseUserService.TeacherList">
<summary>
获取教师列表
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.BaseUserService.Page(GDZZ.Application.BaseUserInput)"> <member name="M:GDZZ.Application.BaseUserService.Page(GDZZ.Application.BaseUserInput)">
<summary> <summary>
分页查询基础用户 分页查询基础用户
@ -860,6 +910,21 @@
主键Id 主键Id
</summary> </summary>
</member> </member>
<member name="P:GDZZ.Application.UpdateBaseUserInput.Self">
<summary>
职业
</summary>
</member>
<member name="P:GDZZ.Application.UpdateBaseUserInput.Sex">
<summary>
性别
</summary>
</member>
<member name="P:GDZZ.Application.UpdateBaseUserInput.Describe">
<summary>
描述
</summary>
</member>
<member name="T:GDZZ.Application.BaseUserOutput"> <member name="T:GDZZ.Application.BaseUserOutput">
<summary> <summary>
基础用户输出参数 基础用户输出参数
@ -1326,6 +1391,11 @@
文件名称 文件名称
</summary> </summary>
</member> </member>
<member name="P:GDZZ.Application.AddLiveFriendInput.CompanyID">
<summary>
公司ID
</summary>
</member>
<member name="T:GDZZ.Application.LiveHistoryContactsOutput"> <member name="T:GDZZ.Application.LiveHistoryContactsOutput">
<summary> <summary>
聊天历史任务列表输出参数 聊天历史任务列表输出参数
@ -1396,29 +1466,16 @@
聊天服务 聊天服务
</summary> </summary>
</member> </member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.AddLive(GDZZ.Application.AddLiveHistoryContactsInput)"> <member name="M:GDZZ.Application.LiveHistoryContactsService.AddLive(GDZZ.Application.AddLiveFriendInput)">
<summary> <summary>
新增联系人 新增联系人
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.UPLive(GDZZ.Application.UpdateLiveHistoryContactsInput)">
<summary>
修改未读消息
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.DelLive(System.Int64)">
<summary>
删除联系人
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.List"> <member name="M:GDZZ.Application.LiveHistoryContactsService.List">
<summary> <summary>
获取联系人 获取联系人列表
</summary> </summary>
<param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:GDZZ.Application.LiveHistoryContactsService.GetMessageLists(System.Int64)"> <member name="M:GDZZ.Application.LiveHistoryContactsService.GetMessageLists(System.Int64)">

@ -16,6 +16,8 @@ using Furion.DynamicApiController;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using GDZZ.Application.Help; using GDZZ.Application.Help;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Mapster;
using GDZZ.Core.Service;
namespace GDZZ.Application.Service.Auth namespace GDZZ.Application.Service.Auth
{ {
@ -27,7 +29,7 @@ namespace GDZZ.Application.Service.Auth
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储 private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储 private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储
private readonly SqlSugarRepository<SeIF> Self; //职业仓储 private readonly SqlSugarRepository<SeIF> Self; //职业仓储
private readonly SqlSugarRepository<Company> CompanyRep;
private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储 private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储
private readonly SqlSugarRepository<MiniPayTake> payTakeRep; //支付仓储 private readonly SqlSugarRepository<MiniPayTake> payTakeRep; //支付仓储
#endregion #endregion
@ -51,11 +53,14 @@ namespace GDZZ.Application.Service.Auth
SqlSugarRepository<SysTenant> sysTenantRep, SqlSugarRepository<SysTenant> sysTenantRep,
SqlSugarRepository<SysUser> sysUserRep, SqlSugarRepository<SysUser> sysUserRep,
SqlSugarRepository<SeIF> Self, SqlSugarRepository<SeIF> Self,
SqlSugarRepository<Company> CompanyRep,
SqlSugarRepository<MiniPayTake> payTakeRep,
ICacheService cacheService, ICacheService cacheService,
WechatOAuth wechatOAuth, WechatOAuth wechatOAuth,
IEventPublisher eventPublisher, IEventPublisher eventPublisher,
IHttpContextAccessor httpContextAccessor) IHttpContextAccessor httpContextAccessor)
{ {
this.CompanyRep= CompanyRep;
this._eventPublisher= eventPublisher; this._eventPublisher= eventPublisher;
this._sysUserRep = sysUserRep; this._sysUserRep = sysUserRep;
this._sysTenantRep = sysTenantRep; this._sysTenantRep = sysTenantRep;
@ -63,6 +68,7 @@ namespace GDZZ.Application.Service.Auth
this._httpContextAccessor = httpContextAccessor; this._httpContextAccessor = httpContextAccessor;
this.cacheService= cacheService; this.cacheService= cacheService;
this.Self = Self; this.Self = Self;
this.payTakeRep = payTakeRep;
_wechatOAuth = wechatOAuth; _wechatOAuth = wechatOAuth;
_oauthConfig = options.Value.Wechat; _oauthConfig = options.Value.Wechat;
} }
@ -76,9 +82,11 @@ namespace GDZZ.Application.Service.Auth
public async Task<AuthUserOut> SignInAsync(PhoneModel phoneModel) public async Task<AuthUserOut> SignInAsync(PhoneModel phoneModel)
{ {
AuthUserOut authUserOut = new AuthUserOut(); AuthUserOut authUserOut = new AuthUserOut();
Company company = new Company();
//读取凭证 //读取凭证
var tokenModel = await this._wechatOAuth.GetAccessTokenAsync(phoneModel.code); var tokenModel = await this._wechatOAuth.GetAccessTokenAsync(phoneModel.code);
//解析电话 //解析电话
var phoneInfo = MiniProgramUtil.AESDecrypt(phoneModel.encryptedDataStr, tokenModel.SessionKey, phoneModel.iv); var phoneInfo = MiniProgramUtil.AESDecrypt(phoneModel.encryptedDataStr, tokenModel.SessionKey, phoneModel.iv);
@ -87,6 +95,14 @@ namespace GDZZ.Application.Service.Auth
.Filter("TenantId", true) .Filter("TenantId", true)
.First(x => x.Phone == phoneInfo.PhoneNumber); .First(x => x.Phone == phoneInfo.PhoneNumber);
var wxUser = await this.Baseuser.AsQueryable()
.Filter("TenantId", true)
.Where(x => x.OpenID == tokenModel.OpenId).SingleAsync();
//账号不存在 生成系统账号
if (sysUser.IsEmpty()) if (sysUser.IsEmpty())
{ {
sysUser = await this._sysUserRep.InsertReturnEntityAsync(new SysUser() sysUser = await this._sysUserRep.InsertReturnEntityAsync(new SysUser()
@ -111,10 +127,9 @@ namespace GDZZ.Application.Service.Auth
}); });
} }
var wxUser = await this.Baseuser.AsQueryable() //区分不同类型账号
.Filter("TenantId", true) if (phoneModel.logInType ==(int)UserEnum.JOB)
.Where(x => x.OpenID == tokenModel.OpenId).SingleAsync(); {
if (wxUser.IsEmpty()) if (wxUser.IsEmpty())
{ {
wxUser = await this.Baseuser.InsertReturnEntityAsync(new BaseUser() wxUser = await this.Baseuser.InsertReturnEntityAsync(new BaseUser()
@ -124,17 +139,31 @@ namespace GDZZ.Application.Service.Auth
CreatedTime = DateTime.Now, CreatedTime = DateTime.Now,
CreatedUserName = sysUser.Name, CreatedUserName = sysUser.Name,
AvatarUrl = "https://gdzongzhi.com/assets/img/logo.png", AvatarUrl = "https://gdzongzhi.com/assets/img/logo.png",
Status = CommonStatus.ENABLE, Status =(int)CommonStatus.ENABLE,
OpenID = tokenModel.OpenId, OpenID = tokenModel.OpenId,
TenantId = 392820661919813, TenantId = 392820661919813,
Type = UserEnum.JOB, Type = (int)UserEnum.JOB,
UserName = phoneInfo.PhoneNumber, UserName = phoneInfo.PhoneNumber,
}); });
} }
}
else
{
//如果是企业账号,应该是绑定了企业租户信息
if (wxUser.IsEmpty()|| wxUser.CompanyID.IsNullOrZero())
throw Oops.Oh(ErrorCode.xg1002);
//获取公司信息
company = await this.CompanyRep.SingleAsync(x=>x.Id == wxUser.CompanyID);
authUserOut.companyDto = company.Adapt<CompanyDto>();
}
if (wxUser.IsEmpty() || sysUser.IsEmpty()) if (wxUser.IsEmpty() || sysUser.IsEmpty())
throw Oops.Oh(ErrorCode.xg1002); throw Oops.Oh(ErrorCode.xg1002);
var Self = await this.Self.FirstOrDefaultAsync(x => x.CreatedUserId == sysUser.Id); var Self = await this.Self.FirstOrDefaultAsync(x => x.CreatedUserId == sysUser.Id);
// 获取加密后的密码 // 获取加密后的密码
@ -143,13 +172,13 @@ namespace GDZZ.Application.Service.Auth
// 验证账号是否被冻结 // 验证账号是否被冻结
if (sysUser.Status == CommonStatus.DISABLE) if (sysUser.Status == CommonStatus.DISABLE)
throw Oops.Oh(ErrorCode.D1017); throw Oops.Oh(ErrorCode.D1017);
//获取对应租户 //获取对应租户
var tenant = this._sysTenantRep.Single(sysUser.TenantId); var tenant = this._sysTenantRep.Single(sysUser.TenantId);
if (tenant.IsNullOrZero()) if (tenant.IsNullOrZero())
throw Oops.Oh(ErrorCode.F1001); throw Oops.Oh(ErrorCode.F1001);
// 生成Token令牌 // 生成Token令牌
authUserOut.Token = JWTEncryption.Encrypt(new Dictionary<string, object> authUserOut.Token = JWTEncryption.Encrypt(new Dictionary<string, object>
{ {
@ -180,9 +209,11 @@ namespace GDZZ.Application.Service.Auth
authUserOut.Sex = sysUser.Sex; authUserOut.Sex = sysUser.Sex;
authUserOut.UserId = sysUser.Id; authUserOut.UserId = sysUser.Id;
authUserOut.UserName = sysUser.Name; authUserOut.UserName = sysUser.Name;
authUserOut.Self = Self.IsEmpty() ? "未填写" : Self.Name; authUserOut.Self = Self.IsEmpty() ? null : Self.Name;
authUserOut.Type = UserEnum.JOB; authUserOut.Type = (UserEnum)wxUser.Type;
authUserOut.OpenID = tokenModel.OpenId; authUserOut.OpenID = tokenModel.OpenId;
authUserOut.Tenant = tenant.Adapt<TenantOutput>();
authUserOut.Describe = wxUser.Describe;
await this.cacheService.SetUserInfoAsync(authUserOut, authUserOut.UserId); await this.cacheService.SetUserInfoAsync(authUserOut, authUserOut.UserId);
return authUserOut; return authUserOut;
@ -200,17 +231,11 @@ namespace GDZZ.Application.Service.Auth
return await this.cacheService.GetUserInfoAsync(UserManager.UserId); return await this.cacheService.GetUserInfoAsync(UserManager.UserId);
} }
/// <summary>
/// 微信支付
/// </summary>
/// <param name="productId"></param>
/// <returns></returns>
[HttpGet("Mini/WxPay")]
public async Task<dynamic> WxPay(AuthUserInput authUserInput)
{
return null;
}

@ -1,4 +1,5 @@
using GDZZ.Core; using GDZZ.Core;
using GDZZ.Core.Service;
using Org.BouncyCastle.Bcpg.OpenPgp; using Org.BouncyCastle.Bcpg.OpenPgp;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -57,5 +58,19 @@ namespace GDZZ.Application
/// </summary> /// </summary>
public string OpenID { get; set; } public string OpenID { get; set; }
/// <summary>
///
/// </summary>
public string Describe { get; set; }
/// <summary>
/// 租户信息
/// </summary>
public TenantOutput Tenant { get; set; }
/// <summary>
/// 公司信息
/// </summary>
public CompanyDto companyDto { get; set; }
} }
} }

@ -21,20 +21,26 @@ namespace GDZZ.Application
public class BaseUserService : IBaseUserService, IDynamicApiController, ITransient public class BaseUserService : IBaseUserService, IDynamicApiController, ITransient
{ {
private readonly SqlSugarRepository<BaseUser> _rep; private readonly SqlSugarRepository<BaseUser> _rep;
private readonly SqlSugarRepository<SeIF> Self; //职业仓储
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储 private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly SqlSugarRepository<OnlineUser> _sysOnlineUerRep; // 在线用户表仓储
/// <summary>
/// 获取配置文件
/// </summary>
private readonly ThirdParty _oauthConfig;
public BaseUserService(SqlSugarRepository<BaseUser> rep, SqlSugarRepository<SysUser> _sysUserRep)
public BaseUserService(SqlSugarRepository<BaseUser> rep,
SqlSugarRepository<SeIF> Self,
SqlSugarRepository<OnlineUser> _sysOnlineUerRep,
SqlSugarRepository<SysUser> _sysUserRep)
{ {
_rep = rep; _rep = rep;
this._sysUserRep= _sysUserRep;
this.Self= Self;
this._sysUserRep = _sysUserRep;
this._sysOnlineUerRep= _sysOnlineUerRep;
} }
@ -56,15 +62,47 @@ namespace GDZZ.Application
var user = this._rep.AsQueryable() var user = this._rep.AsQueryable()
.Filter("TenantId", true) .Filter("TenantId", true)
.First(x => x.CreatedUserId == UserManager.UserId); .First(x => x.CreatedUserId == UserManager.UserId);
var Self = await this.Self.FirstOrDefaultAsync(x => x.CreatedUserId == sysuser.Id);
if(Self.IsEmpty())
{
await this.Self.InsertAsync(new SeIF
{
Name = input.Self,
});
}
else
{
Self.Name = input.Self;
await this.Self.AsUpdateable(Self).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
user.AvatarUrl = input.AvatarUrl; user.AvatarUrl = input.AvatarUrl;
user.Describe = input.Describe;
sysuser.Avatar = input.AvatarUrl; sysuser.Avatar = input.AvatarUrl;
sysuser.Sex = input.Sex;
await this._sysUserRep.AsUpdateable(sysuser).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); await this._sysUserRep.AsUpdateable(sysuser).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
await this._rep.AsUpdateable(user).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); await this._rep.AsUpdateable(user).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
} }
/// <summary>
/// 获取教师列表
/// </summary>
/// <returns></returns>
[HttpGet("/Mini/BaseUser/list")]
public async Task<dynamic> TeacherList()
{
var thls = await this._sysUserRep.AsQueryable()
.InnerJoin<OnlineUser>((u, r) => u.Id == r.UserId)
.Where(u => u.AdminType == AdminType.None)
.ToListAsync();
//var user = await _sysOnlineUerRep.AsQueryable()
// .Filter("TenantId", true)
// .Where(m => m.UserId == entity.OtherUserID).OrderByDescending(x => x.LastTime).FirstAsync();
return null;
}
/// <summary> /// <summary>
@ -130,5 +168,7 @@ namespace GDZZ.Application
} }
} }

@ -102,6 +102,26 @@ namespace GDZZ.Application
[Required(ErrorMessage = "主键Id不能为空")] [Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; } public long Id { get; set; }
/// <summary>
/// 职业
/// </summary>
public string Self { get; set; }
/// <summary>
/// 性别
/// </summary>
public Gender Sex { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Describe { get; set; }
} }
public class QueryeBaseUserInput : DeleteBaseUserInput public class QueryeBaseUserInput : DeleteBaseUserInput

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDZZ.Application.Service.LiveChat
{
/// <summary>
/// 即时聊天接口
/// </summary>
public interface ILiveChatService
{
}
}

@ -1,45 +0,0 @@
using GDZZ.Core;
using GDZZ.Core.Entity;
using GDZZ.Core.Service;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
namespace GDZZ.Application.Service.LiveChat
{
/// <summary>
/// 即时聊天
/// </summary>
[ApiDescriptionSettings("Application", Name = "LiveChat", Order = 1)]
public class LiveChatService:Hub<ILiveChatService> ,ILiveChatService, IDynamicApiController, ITransient
{
/// <summary>
/// 聊天总线
/// </summary>
private readonly IHubContext<ChatHub, IChatClient> _chatHubContext;
private readonly SqlSugarRepository<OnlineUser> sysOnlineUerRep; // 在线用户表仓储
/// <summary>
/// 聊天服务
/// </summary>
/// <param name="chatHubContext"></param>
/// <param name="_sysOnlineUerRep"></param>
public LiveChatService(IHubContext<ChatHub, IChatClient> chatHubContext,
SqlSugarRepository<OnlineUser> _sysOnlineUerRep)
{
this.sysOnlineUerRep = _sysOnlineUerRep;
_chatHubContext = chatHubContext;
}
}
}

@ -116,4 +116,15 @@ namespace GDZZ.Application
/// </summary> /// </summary>
public string FileName { get; set; } public string FileName { get; set; }
} }
public class AddLiveFriendInput
{
/// <summary>
/// 公司ID
/// </summary>
public long CompanyID { get; set; }
}
} }

@ -24,6 +24,8 @@ using Yitter.IdGenerator;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using ICacheService = GDZZ.Application.Help.ICacheService; using ICacheService = GDZZ.Application.Help.ICacheService;
using System.Threading; using System.Threading;
using System.ComponentModel.Design;
using Furion.FriendlyException;
namespace GDZZ.Application namespace GDZZ.Application
{ {
@ -34,6 +36,7 @@ namespace GDZZ.Application
public class LiveHistoryContactsService : ILiveHistoryContactsService, IDynamicApiController, ITransient public class LiveHistoryContactsService : ILiveHistoryContactsService, IDynamicApiController, ITransient
{ {
private readonly SqlSugarRepository<LiveHistoryContacts> _rep; //聊天历史任务列表仓储 private readonly SqlSugarRepository<LiveHistoryContacts> _rep; //聊天历史任务列表仓储
private readonly SqlSugarRepository<BaseUser> Baseuser; // wx用户仓储
private readonly SqlSugarRepository<LiveMessage> liveMessageRep; //消息仓储 private readonly SqlSugarRepository<LiveMessage> liveMessageRep; //消息仓储
private readonly SqlSugarRepository<LiveUserFriend> liveUserFriend; //好友表仓储 private readonly SqlSugarRepository<LiveUserFriend> liveUserFriend; //好友表仓储
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储 private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
@ -45,6 +48,7 @@ namespace GDZZ.Application
public LiveHistoryContactsService(SqlSugarRepository<LiveHistoryContacts> rep, public LiveHistoryContactsService(SqlSugarRepository<LiveHistoryContacts> rep,
ICacheService cacheService, ICacheService cacheService,
IOptions<UploadFileOptions> options, IOptions<UploadFileOptions> options,
SqlSugarRepository<BaseUser> Baseuser,
SqlSugarRepository<SysUser> _sysUserRep, SqlSugarRepository<SysUser> _sysUserRep,
SqlSugarRepository<OnlineUser> sysOnlineUerRep, SqlSugarRepository<OnlineUser> sysOnlineUerRep,
SqlSugarRepository<LiveUserFriend> liveUserFriend, SqlSugarRepository<LiveUserFriend> liveUserFriend,
@ -54,6 +58,7 @@ namespace GDZZ.Application
_rep = rep; _rep = rep;
_options = options.Value; _options = options.Value;
this.Baseuser= Baseuser;
this.cacheService = cacheService; this.cacheService = cacheService;
this._chatHubContext= chatHubContext; this._chatHubContext= chatHubContext;
this._sysOnlineUerRep = sysOnlineUerRep; this._sysOnlineUerRep = sysOnlineUerRep;
@ -64,53 +69,62 @@ namespace GDZZ.Application
#region 聊天列表 #region 聊天列表
/// <summary> /// <summary>
/// 新增联系人 /// 新增联系人
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost("/Mini/LiveHistoryContacts/AddLive")] [HttpPost("/Mini/LiveHistoryContacts/AddLive")]
public async Task AddLive(AddLiveHistoryContactsInput input) public async Task<dynamic> AddLive(AddLiveFriendInput input)
{ {
var entity = input.Adapt<LiveHistoryContacts>(); var baseUser = await this.Baseuser.AsQueryable().Filter("TenantId", true).Where(x => x.CompanyID == input.CompanyID).SingleAsync();
await _rep.InsertAsync(entity); if (baseUser.IsNullOrZero())
await this.cacheService.DelLiveHistoryService(UserManager.UserId); throw Oops.Oh(ErrorCode.B1002);
} var user = await this._sysUserRep.Where(x => x.Id == baseUser.CreatedUserId).SingleAsync();
if (user.IsNullOrZero())
throw Oops.Oh(ErrorCode.xg1002);
//判断是是好友
/// <summary> var fends =await this.liveUserFriend.Where(x => x.FriendID == UserManager.UserId && x.CreatedUserId == user.Id).FirstAsync();
/// 修改未读消息 if (fends.IsNullOrZero())
/// </summary>
/// <returns></returns>
[HttpPut("/Mini/LiveHistoryContacts/UPLive")]
public async Task UPLive(UpdateLiveHistoryContactsInput input)
{ {
//this.cacheService.UpUnreadAsync(input.Id);
}
List<LiveUserFriend> friends = new List<LiveUserFriend>();
/// <summary> if(user.Id != UserManager.UserId)
/// 删除联系人
/// </summary>
/// <returns></returns>
[HttpDelete("/Mini/LiveHistoryContacts/DelLive")]
public async Task DelLive(long ID)
{ {
friends.Add(new LiveUserFriend()
var entity = await this.liveUserFriend.SingleAsync(x => x.Id == ID); {
await _rep.DeleteAsync(entity); FriendID = user.Id,
await this.cacheService.DelLiveHistoryService(UserManager.UserId); });
} }
friends.Add(new LiveUserFriend()
{
FriendID = UserManager.UserId,
CreatedUserId = user.Id
});
foreach (var item in friends)
{
await this.liveUserFriend.InsertAsync(item);
}
}
else
{
}
await this.cacheService.DelLiveHistoryService(UserManager.UserId);
return user;
}
/// <summary> /// <summary>
/// 获取联系人 /// 获取联系人列表
/// </summary> /// </summary>
/// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("/Mini/LiveHistoryContacts/list")] [HttpGet("/Mini/LiveHistoryContacts/list")]
public async Task<List<LiveHistoryLists>> List() public async Task<List<LiveHistoryLists>> List()
@ -167,6 +181,12 @@ namespace GDZZ.Application
await this.cacheService.SetLiveHistoryService(UserManager.UserId, historyLists); await this.cacheService.SetLiveHistoryService(UserManager.UserId, historyLists);
return historyLists; return historyLists;
} }
#endregion #endregion
#region 聊天详情 #region 聊天详情

@ -22,6 +22,7 @@ using Senparc.Weixin.Exceptions;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using System.Collections.Generic; using System.Collections.Generic;
using Mapster; using Mapster;
using Furion.FriendlyException;
namespace GDZZ.Application.Service.WXPay namespace GDZZ.Application.Service.WXPay
{ {
@ -35,6 +36,7 @@ namespace GDZZ.Application.Service.WXPay
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储 private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储 private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储
private readonly SqlSugarRepository<SeIF> self; //职业仓储 private readonly SqlSugarRepository<SeIF> self; //职业仓储
private readonly SqlSugarRepository<Consume> ComsumeRep; //消费记录仓储
private readonly SqlSugarRepository<Balance> balance; //余额仓储 private readonly SqlSugarRepository<Balance> balance; //余额仓储
private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储 private readonly SqlSugarRepository<MiniRecharge> rechargeRep; //充值仓储
@ -60,6 +62,7 @@ namespace GDZZ.Application.Service.WXPay
SqlSugarRepository<SysTenant> sysTenantRep, SqlSugarRepository<SysTenant> sysTenantRep,
SqlSugarRepository<SysUser> sysUserRep, SqlSugarRepository<SysUser> sysUserRep,
SqlSugarRepository<Balance> balance, SqlSugarRepository<Balance> balance,
SqlSugarRepository<Consume> ComsumeRep,
SqlSugarRepository<SeIF> Self, SqlSugarRepository<SeIF> Self,
SqlSugarRepository<MiniRecharge> rechargeRep, SqlSugarRepository<MiniRecharge> rechargeRep,
SqlSugarRepository<MiniPayTake> payTakeRep, SqlSugarRepository<MiniPayTake> payTakeRep,
@ -67,11 +70,12 @@ namespace GDZZ.Application.Service.WXPay
IHttpContextAccessor _httpContextAccessor, IHttpContextAccessor _httpContextAccessor,
IEventPublisher eventPublisher) IEventPublisher eventPublisher)
{ {
this.self = Self;
this.balance = balance; this.balance = balance;
this.Baseuser = Baseuser; this.Baseuser = Baseuser;
this.ComsumeRep = ComsumeRep;
this._sysUserRep = sysUserRep; this._sysUserRep = sysUserRep;
this._sysTenantRep = sysTenantRep; this._sysTenantRep = sysTenantRep;
this.self = Self;
this.rechargeRep = rechargeRep; this.rechargeRep = rechargeRep;
this.payTakeRep = payTakeRep; this.payTakeRep = payTakeRep;
this._wechatOAuth = wechatOAuth; this._wechatOAuth = wechatOAuth;
@ -106,11 +110,53 @@ namespace GDZZ.Application.Service.WXPay
[Route("Mini/v1/GetRechargeList")] [Route("Mini/v1/GetRechargeList")]
public async Task<List<RechargeOut>> GetRechargeList() public async Task<List<RechargeOut>> GetRechargeList()
{ {
var rechargeLiist = this.rechargeRep.Where(x => x.CreatedUserId == UserManager.UserId).ToListAsync(); var rechargeLiist =await this.rechargeRep.Where(x => x.CreatedUserId == UserManager.UserId).ToListAsync();
return rechargeLiist.Adapt<List<RechargeOut>>(); return rechargeLiist.Adapt<List<RechargeOut>>();
} }
/// <summary>
/// 修改余额
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("Mini/v1/UpBalance")]
public async Task<dynamic> UpBalance(decimal Consume,long? ResumeID)
{
var comrep = await this.ComsumeRep.Where(x=>x.ResumeID== ResumeID).FirstAsync();
if(!comrep.IsNullOrZero()) //已经消费过了
return true;
var ban = await this.balance.Where(x => x.UserID == UserManager.UserId).FirstAsync();
if (ban == null)
throw Oops.Oh(ErrorCode.xg1002);
ban.Amount -= Consume;
if (ban.Amount < 0)
throw Oops.Oh(ErrorCode.B1001);
await this.ComsumeRep.InsertAsync(new Consume()
{
CAmount= Consume,
Surplus = ban.Amount,
ResumeID = ResumeID
});
return await this.balance.AsUpdateable(ban).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync()>0;
}
/// <summary>
/// 查询消费记录
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("Mini/v1/GetBalance")]
public async Task<dynamic> GetBalance()
{
return await this.ComsumeRep.Where(x=>x.UserID == UserManager.UserId).ToListAsync();
}
/// <summary> /// <summary>
@ -191,8 +237,7 @@ namespace GDZZ.Application.Service.WXPay
string return_code = resHandler.GetParameter("return_code"); string return_code = resHandler.GetParameter("return_code");
string return_msg = resHandler.GetParameter("return_msg"); string return_msg = resHandler.GetParameter("return_msg");
string res = null; var res = "";
resHandler.SetKey(Config.SenparcWeixinSetting.TenPayV3_Key); resHandler.SetKey(Config.SenparcWeixinSetting.TenPayV3_Key);
//验证请求是否从微信发过来(安全) //验证请求是否从微信发过来(安全)
if (resHandler.IsTenpaySign() && return_code.ToUpper() == "SUCCESS") if (resHandler.IsTenpaySign() && return_code.ToUpper() == "SUCCESS")

@ -392,9 +392,15 @@ public enum ErrorCode
[ErrorCodeItemMetadata("检测数据不存在")] [ErrorCodeItemMetadata("检测数据不存在")]
xg1002, xg1002,
/// <summary>
/// 请添加数据列
/// </summary>
[ErrorCodeItemMetadata("请添加数据列")] [ErrorCodeItemMetadata("请添加数据列")]
db1000, db1000,
/// <summary>
/// 数据表不存在
/// </summary>
[ErrorCodeItemMetadata("数据表不存在")] [ErrorCodeItemMetadata("数据表不存在")]
db1001, db1001,
@ -408,5 +414,16 @@ public enum ErrorCode
/// 租户不存在 /// 租户不存在
/// </summary> /// </summary>
[ErrorCodeItemMetadata("租户不存在")] [ErrorCodeItemMetadata("租户不存在")]
F1001 F1001,
/// <summary>
/// 余额不足
/// </summary>
[ErrorCodeItemMetadata("余额不足")]
B1001,
/// <summary>
/// 未绑定公司
/// </summary>
[ErrorCodeItemMetadata("未绑定公司")]
B1002
} }

@ -2560,6 +2560,16 @@
检测数据不存在 检测数据不存在
</summary> </summary>
</member> </member>
<member name="F:GDZZ.Core.ErrorCode.db1000">
<summary>
请添加数据列
</summary>
</member>
<member name="F:GDZZ.Core.ErrorCode.db1001">
<summary>
数据表不存在
</summary>
</member>
<member name="F:GDZZ.Core.ErrorCode.F1000"> <member name="F:GDZZ.Core.ErrorCode.F1000">
<summary> <summary>
表单不存在 表单不存在
@ -2570,6 +2580,16 @@
租户不存在 租户不存在
</summary> </summary>
</member> </member>
<member name="F:GDZZ.Core.ErrorCode.B1001">
<summary>
余额不足
</summary>
</member>
<member name="F:GDZZ.Core.ErrorCode.B1002">
<summary>
未绑定公司
</summary>
</member>
<member name="T:GDZZ.Core.FileExtensionEnum"> <member name="T:GDZZ.Core.FileExtensionEnum">
<summary> <summary>
文件扩展枚举 文件扩展枚举
@ -3535,6 +3555,11 @@
是否租户管理员 是否租户管理员
</summary> </summary>
</member> </member>
<member name="P:GDZZ.Core.OAuth.PhoneModel.logInType">
<summary>
登录类型
</summary>
</member>
<member name="T:GDZZ.Core.TokenModel"> <member name="T:GDZZ.Core.TokenModel">
<summary> <summary>
AccessToken参数 AccessToken参数

@ -9,14 +9,17 @@ namespace GDZZ.Core.OAuth
public class PhoneModel public class PhoneModel
{ {
/// <summary>
/// 登录类型
/// </summary>
public int logInType { get; set; }
public string encryptedDataStr { get; set; } public string encryptedDataStr { get; set; }
public string iv { get; set; } public string iv { get; set; }
public string code { get; set; } public string code { get; set; }
} }
} }

@ -69,10 +69,27 @@ public class SysRoleService : ISysRoleService, IDynamicApiController, ITransient
public async Task<dynamic> QueryRolePageList([FromQuery] RoleInput input) public async Task<dynamic> QueryRolePageList([FromQuery] RoleInput input)
{ {
var roles = await _sysRoleRep.AsQueryable() var roles = await _sysRoleRep.AsQueryable()
.InnerJoin<SysTenant>((u, r) => r.Id == u.TenantId)
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code.Contains(input.Code.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code.Contains(input.Code.Trim()))
.Where(u => u.Status == (int)CommonStatus.ENABLE) .Where(u => u.Status == (int)CommonStatus.ENABLE)
.OrderBy(u => u.Sort) .OrderBy(u => u.Sort)
.Select((u, r) => new
{
Tendand = r.Name,
Code = u.Code,
Name = u.Name,
CreatedTime= u.CreatedTime,
CreatedUserId = u.CreatedUserId,
CreatedUserName = u.CreatedUserName,
DataScopeType = u.DataScopeType,
ID = u.Id,
IsDeleted= u.IsDeleted,
RoleType= u.RoleType,
Sort = u.Sort,
Status = u.Status,
TenantId= u.TenantId
})
.ToPagedListAsync(input.PageNo, input.PageSize); .ToPagedListAsync(input.PageNo, input.PageSize);
return roles.XnPagedResult(); return roles.XnPagedResult();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Loading…
Cancel
Save