Commit 81340c2a authored by liudong1993's avatar liudong1993
parents 434b27bd 04506b1e
using VT.FW.DB;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 用户统计表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_User_Statistics
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 日期
/// </summary>
public DateTime Date { get; set; }
/// <summary>
/// 付款人数
/// </summary>
public int PeopleNum { get; set; }
/// <summary>
/// 订单数量
/// </summary>
public int OrderNum { get; set; }
/// <summary>
/// 付款金额
/// </summary>
public decimal PayMoney { get; set; }
/// <summary>
/// 购买数量
/// </summary>
public int BuyNum { get; set; }
/// <summary>
/// 平均每人购买单数
/// </summary>
public decimal AvgOrderNum { get; set; }
/// <summary>
/// 平均每人购买件数
/// </summary>
public decimal AvgBuyNum { get; set; }
/// <summary>
/// 平均每单单价
/// </summary>
public decimal AvgUnitPrice { get; set; }
/// <summary>
/// 平均每人购买单价
/// </summary>
public decimal AvgBuyPrice { get; set; }
/// <summary>
/// 会员累计数量
/// </summary>
public int MemberNum { get; set; }
/// <summary>
/// 累计付款人数
/// </summary>
public int PaymentNum { get; set; }
/// <summary>
/// 会员订单转换率
/// </summary>
public decimal MOrderRate { get; set; }
/// <summary>
/// 复购人数
/// </summary>
public int ReBuyNum { get; set; }
/// <summary>
/// 复购率
/// </summary>
public decimal ReBuyRate { get; set; }
/// <summary>
/// 新人下单
/// </summary>
public int NewPeopleNum { get; set; }
/// <summary>
/// 今日普象新增
/// </summary>
public int PXNum { get; set; }
/// <summary>
/// 今日VIP新增
/// </summary>
public int VipNum { get; set; }
/// <summary>
/// 今日银象新增
/// </summary>
public int YXNum { get; set; }
/// <summary>
/// 今日金象新增
/// </summary>
public int JXNum { get; set; }
/// <summary>
/// 利润
/// </summary>
public decimal Profit { get; set; }
/// <summary>
/// 利润率
/// </summary>
public decimal ProfitRate { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 商户号id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateDate { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime UpdateDate { get; set; }
/// <summary>
/// 普象累计
/// </summary>
public int PXLJNum { get; set; }
/// <summary>
/// VIP累计
/// </summary>
public int VipLJNum { get; set; }
/// <summary>
/// 银象累计
/// </summary>
public int YXLJNum { get; set; }
/// <summary>
/// 金象累计
/// </summary>
public int JXLJNum { get; set; }
/// <summary>
/// 取消单数
/// </summary>
public int CancelOrderNum { get; set; }
}
}
This diff is collapsed.
......@@ -36,6 +36,15 @@ namespace Mall.Model.Query
/// </summary>
public string GoodsName { get; set; }
/// <summary>
/// 付款时间
/// </summary>
public DateTime PaymentTime { get; set; }
/// <summary>
/// 下单用户id
/// </summary>
public int UserId { get; set; }
/// <summary>
/// 商品id
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -309,5 +309,87 @@ where {where} order by di.CreateDate desc";
string sql = $@"select di.* from RB_Distributor_Info di where {where} order by di.CreateDate desc";
return Get<RB_Distributor_Info_Extend>(sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Distributor_Info_Extend> GetNewUserForNowDay(RB_Distributor_Info_Extend dmodel, string NowDate)
{
string where = $@" 1=1 and di.{nameof(RB_Distributor_Info.Status)}=0";
if (dmodel.TenantId > 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.UserId > 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.UserId)}={dmodel.UserId}";
}
if (dmodel.AuditStatus > 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.AuditStatus)}={(int)dmodel.AuditStatus}";
}
if (!string.IsNullOrEmpty(dmodel.UserIds))
{
where += $@" and di.{nameof(RB_Distributor_Info.UserId)} in({dmodel.UserIds})";
}
if (dmodel.GradeId >= 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.GradeId)}={dmodel.GradeId}";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += $@" and (mu.{nameof(RB_Member_User.Name)} like '%{dmodel.Name}%' or di.{nameof(RB_Distributor_Info.Name)} like '%{dmodel.Name}%' )";
}
string sql = $@"select di.*,mu.OpenId,mu.Name as MemberUserName from RB_Distributor_Info di inner join rb_member_user as mu on di.UserId=mu.Id where {where} and mu.CreateDate >='{NowDate}' and mu.CreateDate <='{NowDate} 23:59:59' order by di.CreateDate desc";
return Get<RB_Distributor_Info_Extend>(sql).ToList();
}
/// <summary>
/// 获取当前日期 累计会员数量
/// </summary>
/// <param name="dmodel"></param>
/// <param name="NowDate"></param>
public List<RB_Distributor_Info_Extend> GetMemberDistributorNumberForCutOff(RB_Distributor_Info_Extend dmodel, string NowDate)
{
string where = $@" 1=1 and di.{nameof(RB_Distributor_Info.Status)}=0";
if (dmodel.TenantId > 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.UserId > 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.UserId)}={dmodel.UserId}";
}
if (dmodel.AuditStatus > 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.AuditStatus)}={(int)dmodel.AuditStatus}";
}
if (!string.IsNullOrEmpty(dmodel.UserIds))
{
where += $@" and di.{nameof(RB_Distributor_Info.UserId)} in({dmodel.UserIds})";
}
if (dmodel.GradeId >= 0)
{
where += $@" and di.{nameof(RB_Distributor_Info.GradeId)}={dmodel.GradeId}";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += $@" and (mu.{nameof(RB_Member_User.Name)} like '%{dmodel.Name}%' or di.{nameof(RB_Distributor_Info.Name)} like '%{dmodel.Name}%' )";
}
string sql = $@"select di.FXGradeId,COUNT(0) AS SortNum from RB_Distributor_Info di inner join rb_member_user as mu on di.UserId=mu.Id where {where} and mu.CreateDate <='{NowDate} 23:59:59' GROUP BY di.FXGradeId";
return Get<RB_Distributor_Info_Extend>(sql).ToList();
}
}
}
......@@ -163,9 +163,6 @@ select * from RB_Member_User where {where} order by CreateDate desc
return Get<RB_Member_User_Extend>(sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
......@@ -229,8 +226,6 @@ select * from RB_Member_User where {where} order by CreateDate desc
return Get<RB_Member_User_Extend>(sql).ToList();
}
/// <summary>
/// 获取列表(粉象)
/// </summary>
......@@ -1699,5 +1694,60 @@ FROM RB_Member_User AS a LEFT JOIN rb_miai_baseinfo AS b ON a.Id = b.UserId) as
}
#region 订单统计
/// <summary>
/// 获取日期以前用户数量
/// </summary>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <param name="startTime"></param>
/// <returns></returns>
public int GetMemberUserTotalNumForDay(int tenantId, int mallBaseId, string startTime)
{
string sql = $" select count(0) as count from RB_Member_User where TenantId={tenantId} and MallBaseId={mallBaseId} and CreateDate <='{startTime} 23:59:59'";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
}
/// <summary>
/// 获取日期截止付款用户数量
/// </summary>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <param name="startTime"></param>
/// <returns></returns>
public int GetMemberUserPayNumForDay(int tenantId, int mallBaseId, string startTime)
{
string sql = $@" SELECT count(0) FROM
(select u.Id from RB_Member_User u
LEFT JOIN rb_goods_order o on u.Id = o.UserId
where u.TenantId={tenantId} and u.MallBaseId={mallBaseId} and u.CreateDate <='{startTime} 23:59:59' and o.PaymentTime is not null
GROUP BY u.Id)t ";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
}
/// <summary>
/// 获取日期当天复购人数
/// </summary>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <param name="startTime"></param>
/// <param name="userIds"></param>
/// <returns></returns>
public int GetMemberReBuyNumForNowDay(int tenantId, int mallBaseId, string startTime, string userIds)
{
string sql = $@"SELECT count(0) FROM
(select u.Id from RB_Member_User u
LEFT JOIN rb_goods_order o on u.Id = o.UserId
where u.TenantId={tenantId} and u.MallBaseId={mallBaseId} and o.OrderStatus <>7 and o.CreateDate <'{startTime}' and o.PaymentTime is not null and u.Id in({userIds})
GROUP BY u.Id)t";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.User;
using Mall.Model.Extend.User;
using System.Linq;
using Mall.Common.Enum.User;
using VT.FW.DB.Dapper;
namespace Mall.Repository.User
{
/// <summary>
/// 用户统计仓储层
/// </summary>
public partial class RB_User_StatisticsRepository : BaseRepository<RB_User_Statistics>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_User_Statistics_Extend> GetList(RB_User_Statistics_Extend dmodel)
{
string where = " 1=1 ";
if (dmodel.TenantId > 0)
{
where += $@" and {nameof(RB_User_Statistics.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and {nameof(RB_User_Statistics.MallBaseId)}={dmodel.MallBaseId}";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and {nameof(RB_User_Statistics.Date)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and {nameof(RB_User_Statistics.Date)} <='{dmodel.EndTime} 23:59:59'";
}
string sql = $@"select * from RB_User_Statistics where {where} ";
return Get<RB_User_Statistics_Extend>(sql).ToList();
}
}
}
......@@ -46,6 +46,22 @@ namespace Mall.WindowsService.Helper
LogHelper.Write("DistributorVipModule=====End");
#endregion
#region 电商统计
if (DateTime.Now.Hour == 1)
{
LogHelper.Write("UpdateToDayUserStatistics=====Start");
try
{
new Module.UserStatisticsModule().UpdateToDayUserStatistics("", "");
}
catch (Exception ex)
{
LogHelper.Write("UpdateToDayUserStatistics:" + ex.Message);
}
LogHelper.Write("UpdateToDayUserStatistics=====End");
}
#endregion
Interlocked.Exchange(ref inTimer, 0);
}
......
......@@ -32,6 +32,7 @@
<ProjectReference Include="..\Mall.CacheManager\Mall.CacheManager.csproj" />
<ProjectReference Include="..\Mall.Common\Mall.Common.csproj" />
<ProjectReference Include="..\Mall.Model\Mall.Model.csproj" />
<ProjectReference Include="..\Mall.Module.MarketingCenter\Mall.Module.MarketingCenter.csproj" />
<ProjectReference Include="..\Mall.Module.User\Mall.Module.User.csproj" />
<ProjectReference Include="..\Mall.Repository\Mall.Repository.csproj" />
</ItemGroup>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment