401 lines
20 KiB
C#
401 lines
20 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Web.Http;
|
||
using System.Web.Http.Description;
|
||
using SuperMap.RealEstate.Utility;
|
||
using ESCM = CommercialApi.Model;
|
||
using ESCG = CommercialApi.GeneralMethod;
|
||
using HZQR.Common;
|
||
|
||
namespace CommercialApi.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 客群分析相关接口
|
||
/// </summary>
|
||
public class CustomerController : BaseController
|
||
{
|
||
#region 方法 -> 获取客群分析占比
|
||
/// <summary>
|
||
/// 获取客群分析占比
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// 应用场景:分别显示男性、女性、年龄层次的占比,可以按交易笔数或消费金额统计占比结果<br/>
|
||
/// 返参内容:<br/>
|
||
/// name:名称(男性/女性/年龄)<br/>
|
||
/// data:<br/>
|
||
/// name=男性/女性:[交易占比]<br/>
|
||
/// name=年龄:[00后,90后,80后,70后]
|
||
/// </remarks>
|
||
/// <param name="statisticsType">
|
||
/// 统计类型:<br/>
|
||
/// 1【按交易笔数】<br/>
|
||
/// 2【按消费金额】
|
||
/// </param>
|
||
/// <param name="provinceCode">业主单位标识</param>
|
||
/// <param name="serverpartId">服务区内码</param>
|
||
/// <param name="serverpartCode">服务区编码</param>
|
||
/// <param name="statisticsMonth">统计月份,格式如202110</param>
|
||
/// <returns></returns>
|
||
[AcceptVerbs("GET")]
|
||
[Route("Customer/GetCustomerRatio")]
|
||
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.CustomerAnalysisModel>>))]
|
||
public IHttpActionResult GetCustomerRatio(int statisticsType, string provinceCode,
|
||
int? serverpartId = null, string serverpartCode = "", int? statisticsMonth = null)
|
||
{
|
||
string Parameter = "入参信息:统计类型【" + statisticsType + "】,业主单位标识【" + provinceCode + "】," +
|
||
"服务区内码【" + serverpartId + "】,服务区编码【" + serverpartCode + "】,统计月份【" + statisticsMonth + "】";
|
||
|
||
try
|
||
{
|
||
//获取客群分析占比图
|
||
List<ESCM.CustomerAnalysisModel> CustomerRatioChart = ESCG.CustomerHelper.GetCustomerRatio(
|
||
transaction, statisticsType, provinceCode, serverpartId, serverpartCode, statisticsMonth);
|
||
|
||
//返回数据,将返回结果转换成API接口的JsonList格式
|
||
Models.JsonList<ESCM.CustomerAnalysisModel> jsonList = Models.JsonList<ESCM.CustomerAnalysisModel>.Success(CustomerRatioChart);
|
||
|
||
//返回数据
|
||
return Ok(Models.JsonMsg<Models.JsonList<ESCM.CustomerAnalysisModel>>.Success(jsonList, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetCustomerRatio");
|
||
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取客群消费能力占比
|
||
/// <summary>
|
||
/// 获取客群消费能力占比
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// 应用场景:按性别统计客群消费的能力,统计4种金额区间(0<X≤30,30<X≤60,60<X≤90,X>90)交易客单数量的占比<br/>
|
||
/// 返参内容:<br/>
|
||
/// name:性别<br/>
|
||
/// data:[0<X≤30,30<X≤60,60<X≤90,X>90]客单交易占比的数组
|
||
/// </remarks>
|
||
/// <param name="provinceCode">业主单位标识</param>
|
||
/// <param name="serverpartId">服务区内码</param>
|
||
/// <param name="serverpartCode">服务区编码</param>
|
||
/// <param name="statisticsMonth">统计月份,格式如202110</param>
|
||
/// <returns></returns>
|
||
[AcceptVerbs("GET")]
|
||
[Route("Customer/GetCustomerConsumeRatio")]
|
||
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.CustomerAnalysisModel>>))]
|
||
public IHttpActionResult GetCustomerConsumeRatio(string provinceCode,
|
||
int? serverpartId = null, string serverpartCode = "", int? statisticsMonth = null)
|
||
{
|
||
string Parameter = "入参信息:业主单位标识【" + provinceCode + "】," +
|
||
"服务区内码【" + serverpartId + "】,服务区编码【" + serverpartCode + "】,统计月份【" + statisticsMonth + "】";
|
||
|
||
try
|
||
{
|
||
//获取客群消费能力占比图
|
||
List<ESCM.CustomerAnalysisModel> CustomerConsumeRatioChart = ESCG.CustomerHelper.GetCustomerConsumeRatio(
|
||
transaction, provinceCode, serverpartId, serverpartCode, statisticsMonth);
|
||
|
||
//返回数据,将返回结果转换成API接口的JsonList格式
|
||
Models.JsonList<ESCM.CustomerAnalysisModel> jsonList = Models.JsonList<ESCM.CustomerAnalysisModel>.Success(CustomerConsumeRatioChart);
|
||
|
||
//返回数据
|
||
return Ok(Models.JsonMsg<Models.JsonList<ESCM.CustomerAnalysisModel>>.Success(jsonList, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetCustomerConsumeRatio");
|
||
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取客群年龄层次占比
|
||
/// <summary>
|
||
/// 获取客群年龄层次占比
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// 应用场景:按性别统计客群消费的能力,统计00后、90后、80后、70后交易客单数量的占比<br/>
|
||
/// 返参内容:<br/>
|
||
/// name:性别<br/>
|
||
/// data:[00后,90后,80后,70后]客单交易占比的数组
|
||
/// </remarks>
|
||
/// <param name="provinceCode">业主单位标识</param>
|
||
/// <param name="serverpartId">服务区内码</param>
|
||
/// <param name="serverpartCode">服务区编码</param>
|
||
/// <param name="statisticsMonth">统计月份,格式如202110</param>
|
||
/// <returns></returns>
|
||
[AcceptVerbs("GET")]
|
||
[Route("Customer/GetCustomerAgeRatio")]
|
||
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.CustomerAnalysisModel>>))]
|
||
public IHttpActionResult GetCustomerAgeRatio(string provinceCode,
|
||
int? serverpartId = null, string serverpartCode = "", int? statisticsMonth = null)
|
||
{
|
||
string Parameter = "入参信息:业主单位标识【" + provinceCode + "】," +
|
||
"服务区内码【" + serverpartId + "】,服务区编码【" + serverpartCode + "】,统计月份【" + statisticsMonth + "】";
|
||
|
||
try
|
||
{
|
||
//获取客群年龄层次占比图
|
||
List<ESCM.CustomerAnalysisModel> CustomerAgeRatioChart = ESCG.CustomerHelper.GetCustomerAgeRatio(
|
||
transaction, provinceCode, serverpartId, serverpartCode, statisticsMonth);
|
||
|
||
//返回数据,将返回结果转换成API接口的JsonList格式
|
||
Models.JsonList<ESCM.CustomerAnalysisModel> jsonList = Models.JsonList<ESCM.CustomerAnalysisModel>.Success(CustomerAgeRatioChart);
|
||
|
||
//返回数据
|
||
return Ok(Models.JsonMsg<Models.JsonList<ESCM.CustomerAnalysisModel>>.Success(jsonList, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetCustomerAgeRatio");
|
||
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取客群特征分析
|
||
/// <summary>
|
||
/// 获取客群特征分析
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// 应用场景:按性别、年龄层次统计客群消费的能力,展示什么年龄段消费多少金额占总交易笔数的比例<br/>
|
||
/// 返参内容:<br/>
|
||
/// name:性别<br/>
|
||
/// data:[年龄,交易金额,交易占比]的二维数组
|
||
/// </remarks>
|
||
/// <param name="provinceCode">业主单位标识</param>
|
||
/// <param name="serverpartId">服务区内码</param>
|
||
/// <param name="serverpartCode">服务区编码</param>
|
||
/// <param name="statisticsMonth">统计月份,格式如202110</param>
|
||
/// <returns></returns>
|
||
[AcceptVerbs("GET")]
|
||
[Route("Customer/GetCustomerGroupRatio")]
|
||
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.CustomerGroupModel>>))]
|
||
public IHttpActionResult GetCustomerGroupRatio(string provinceCode,
|
||
int? serverpartId = null, string serverpartCode = "", int? statisticsMonth = null)
|
||
{
|
||
string Parameter = "入参信息:业主单位标识【" + provinceCode + "】," +
|
||
"服务区内码【" + serverpartId + "】,服务区编码【" + serverpartCode + "】,统计月份【" + statisticsMonth + "】";
|
||
|
||
try
|
||
{
|
||
//获取客群特征分析图
|
||
List<ESCM.CustomerGroupModel> CustomerGroupRatioChart = ESCG.CustomerHelper.GetCustomerGroupRatio(
|
||
transaction, provinceCode, serverpartId, serverpartCode, statisticsMonth);
|
||
|
||
//返回数据,将返回结果转换成API接口的JsonList格式
|
||
Models.JsonList<ESCM.CustomerGroupModel> jsonList = Models.JsonList<ESCM.CustomerGroupModel>.Success(CustomerGroupRatioChart);
|
||
|
||
//返回数据
|
||
return Ok(Models.JsonMsg<Models.JsonList<ESCM.CustomerGroupModel>>.Success(jsonList, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetCustomerGroupRatio");
|
||
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取客群分析说明表列表
|
||
/// <summary>
|
||
/// 获取客群分析说明表列表
|
||
/// </summary>
|
||
/// <param name="statisticsMonth">统计月份</param>
|
||
/// <param name="serverpartId">服务区内码</param>
|
||
/// <param name="serverpartCode">服务区编码</param>
|
||
/// <param name="provinceCode">省份编码</param>
|
||
/// <param name="statisticsType">统计类型
|
||
/// 1:消费人群占比
|
||
/// 2:消费能力占比
|
||
/// 3:客群特征分析
|
||
/// 4:消费能力分析
|
||
/// 5:年龄层次分析</param>
|
||
/// <returns></returns>
|
||
[Route("Customer/GetAnalysisDescList")]
|
||
[AcceptVerbs("GET")]
|
||
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.AnalysisDescModel>>))]
|
||
public IHttpActionResult GetAnalysisDescList(int? statisticsMonth = null, int? serverpartId = null,
|
||
string serverpartCode = "", string provinceCode = "", int? statisticsType = null)
|
||
{
|
||
string Parameter = "入参信息:统计类型【" + statisticsType + "】,业主单位标识【" + provinceCode + "】," +
|
||
"服务区内码【" + serverpartId + "】,服务区编码【" + serverpartCode + "】,统计月份【" + statisticsMonth + "】";
|
||
|
||
try
|
||
{
|
||
//获取客群分析说明表列表
|
||
List<ESCM.AnalysisDescModel> AnalysisDescList = ESCG.CustomerHelper.GetAnalysisDescList(
|
||
transaction, statisticsMonth, serverpartId, serverpartCode, provinceCode, statisticsType);
|
||
|
||
//转化json形式
|
||
Models.JsonList<ESCM.AnalysisDescModel> jsonList = Models.JsonList<ESCM.AnalysisDescModel>.Success(AnalysisDescList);
|
||
|
||
return Ok(Models.JsonMsg<Models.JsonList<ESCM.AnalysisDescModel>>.Success(jsonList, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetAnalysisDescList");
|
||
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取客群分析说明表明细
|
||
/// <summary>
|
||
/// 获取客群分析说明表明细
|
||
/// </summary>
|
||
/// <param name="statisticsType">统计类型
|
||
/// 1:消费人群占比
|
||
/// 2:消费能力占比
|
||
/// 3:客群特征分析
|
||
/// 4:消费能力分析
|
||
/// 5:年龄层次分析</param>
|
||
/// <param name="statisticsMonth">统计月份</param>
|
||
/// <param name="serverpartId">服务区内码</param>
|
||
/// <param name="serverpartCode">服务区编码</param>
|
||
/// <param name="provinceCode">省份编码</param>
|
||
/// <returns></returns>
|
||
[Route("Customer/GetAnalysisDescDetail")]
|
||
[AcceptVerbs("GET")]
|
||
[ResponseType(typeof(Models.JsonMsg<ESCM.AnalysisDescModel>))]
|
||
public IHttpActionResult GetAnalysisDescDetail(int statisticsType, int? statisticsMonth = null,
|
||
int? serverpartId = null, string serverpartCode = "", string provinceCode = "")
|
||
{
|
||
string Parameter = "入参信息:统计类型【" + statisticsType + "】,业主单位标识【" + provinceCode + "】," +
|
||
"服务区内码【" + serverpartId + "】,服务区编码【" + serverpartCode + "】,统计月份【" + statisticsMonth + "】";
|
||
|
||
try
|
||
{
|
||
//获取客群分析说明表明细
|
||
ESCM.AnalysisDescModel customer_analysisModel = ESCG.CustomerHelper.GetAnalysisDescDetail(
|
||
transaction, statisticsType, statisticsMonth, serverpartId, serverpartCode, provinceCode);
|
||
|
||
return Ok(Models.JsonMsg<ESCM.AnalysisDescModel>.Success(customer_analysisModel, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetAnalysisDescDetail");
|
||
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取客群消费偏好数据
|
||
/// <summary>
|
||
/// 获取客群消费偏好数据
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// 应用场景:展示客群消费偏好的数据接口,可以从经营业态、服务区、片区、月份的角度进行显示,
|
||
/// 返回的结果中包含男性、女性、70后、80后、90后、00后组合维度的数据集。<br/>
|
||
/// 返回结果:<br/>
|
||
/// StatisticsMonth: 统计月份<br/>
|
||
/// SPRegionTypeId: 片区内码<br/>
|
||
/// SPRegionTypeName: 片区名称<br/>
|
||
/// ServerpartId: 服务区内码<br/>
|
||
/// ServerpartName: 服务区名称<br/>
|
||
/// BusinessTradeValue: 经营业态内码<br/>
|
||
/// BusinessTradeName: 经营业态名称<br/>
|
||
/// TotalRatio: 总占比<br/>
|
||
/// MaleRatio: 男性占比<br/>
|
||
/// FemaleRatio: 女性占比<br/>
|
||
/// Ratio_00: 00后占比<br/>
|
||
/// Ratio_90: 90后占比<br/>
|
||
/// Ratio_80: 80后占比<br/>
|
||
/// Ratio_70: 70后占比<br/>
|
||
/// MaleRatio_00: 00后男性占比<br/>
|
||
/// MaleRatio_90: 90后男性占比<br/>
|
||
/// MaleRatio_80: 80后男性占<br/>
|
||
/// MaleRatio_70: 70后男性占比<br/>
|
||
/// FemaleRatio_00: 00后女性占比<br/>
|
||
/// FemaleRatio_90: 90后女性占比<br/>
|
||
/// FemaleRatio_80: 80后女性占比<br/>
|
||
/// FemaleRatio_70: 70后女性占比
|
||
/// </remarks>
|
||
/// <param name="statisticsType">
|
||
/// 统计类型,多个用,隔开:<br/>
|
||
/// 1、按经营业态分组显示<br/>
|
||
/// 2、按服务区分组显示<br/>
|
||
/// 3、按片区分组显示<br/>
|
||
/// 4、按月份分组显示
|
||
/// </param>
|
||
/// <param name="startMonth">统计开始月份,格式如202301</param>
|
||
/// <param name="endMonth">统计结束月份,格式如202301</param>
|
||
/// <param name="provinceCode">业主单位标识</param>
|
||
/// <param name="spRegionTypeId">片区内码,多个用,隔开</param>
|
||
/// <param name="serverpartId">服务区内码,多个用,隔开</param>
|
||
/// <param name="businessTrade">经营业态,多个用,隔开</param>
|
||
/// <param name="showTradeLevel">
|
||
/// 经营业态显示级别:<br/>
|
||
/// 0:最低级别业态<br/>
|
||
/// 1:一级业态,父级id=-1<br/>
|
||
/// 2:二级业态,父级是一级业态<br/>
|
||
/// </param>
|
||
/// <param name="showDetailCount">
|
||
/// 单品明细显示数量:<br/>
|
||
/// 传0不显示,否则显示明细
|
||
/// </param>
|
||
/// <param name="sortStr">排序字段</param>
|
||
/// <returns></returns>
|
||
[AcceptVerbs("GET")]
|
||
[Route("Customer/GetCustomerSaleRatio")]
|
||
[ResponseType(typeof(Models.JsonMsg<ESCM.CustomerSaleRatioModel>))]
|
||
public IHttpActionResult GetCustomerSaleRatio(string statisticsType, string startMonth, string endMonth,
|
||
string provinceCode, string spRegionTypeId = "", string serverpartId = "", string businessTrade = "",
|
||
int showTradeLevel = 0, int showDetailCount = 10, string sortStr = "")
|
||
{
|
||
provinceCode = GetStringHeader("ProvinceCode", provinceCode);
|
||
//根据业主单位标识转译成省份内码
|
||
provinceCode = ESCG.BaseInfoHelper.GetProvinceID(transaction, provinceCode);
|
||
|
||
string Parameter = "入参信息:统计类型【" + statisticsType + "】,统计开始月份【" + startMonth + "】," +
|
||
"统计结束月份【" + startMonth + "】,业主单位标识【" + provinceCode + "】,片区内码【" + spRegionTypeId + "】," +
|
||
"服务区内码【" + serverpartId + "】,经营业态【" + businessTrade + "】," +
|
||
"经营业态显示级别【" + showTradeLevel + "】,单品明细显示数量【" + showDetailCount + "】";
|
||
try
|
||
{
|
||
if (string.IsNullOrWhiteSpace(statisticsType) || string.IsNullOrWhiteSpace(provinceCode))
|
||
{
|
||
return Ok(ESCG.Common.ReturnJson(101, "查询失败:请传入正确的参数"));
|
||
}
|
||
|
||
//获取客群消费偏好数据
|
||
ESCM.CustomerSaleRatioModel customerSaleRatioModel = ESCG.CustomerHelper.GetCustomerSaleRatio(transaction,
|
||
statisticsType, startMonth, endMonth, provinceCode, spRegionTypeId, serverpartId,
|
||
businessTrade, showTradeLevel, showDetailCount, sortStr);
|
||
|
||
if (customerSaleRatioModel == null)
|
||
{
|
||
return Ok(ESCG.Common.ReturnJson(101, "查询失败:无数据返回"));
|
||
}
|
||
|
||
return Ok(Models.JsonMsg<ESCM.CustomerSaleRatioModel>.Success(customerSaleRatioModel, 100, "查询成功"));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
transaction.Rollback();
|
||
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
|
||
DateTime.Now.ToString("yyyyMMdd") + "_GetCustomerSaleRatio");
|
||
return Ok(ESCG.Common.ReturnJson(999, "查询失败" + ex.Message));
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
} |