Commit bb3d7da0 authored by liudong1993's avatar liudong1993

分销

parent 0367ae6c
...@@ -25,5 +25,10 @@ namespace Mall.Model.Extend.User ...@@ -25,5 +25,10 @@ namespace Mall.Model.Extend.User
/// 等级名称 /// 等级名称
/// </summary> /// </summary>
public string GradeName { get; set; } public string GradeName { get; set; }
/// <summary>
/// 是否直客 1是 2否
/// </summary>
public int? IsGuest { get; set; }
} }
} }
...@@ -2574,7 +2574,7 @@ namespace Mall.Module.Product ...@@ -2574,7 +2574,7 @@ namespace Mall.Module.Product
if (item.CostMoney > 0) { if (item.CostMoney > 0) {
//成本价格大于0的才进行返佣 //成本价格大于0的才进行返佣
string categoryids = string.Join(",", item.CategoryIdList); string categoryids = string.Join(",", item.CategoryIdList);
var hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { CategoryIdsT = categoryids }); var hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { CategoryIdsT = categoryids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (hpcList.Any()) if (hpcList.Any())
{ {
RB_Distributor_HPCommission_Extend hpcModel; RB_Distributor_HPCommission_Extend hpcModel;
......
...@@ -773,7 +773,7 @@ namespace Mall.Module.Product ...@@ -773,7 +773,7 @@ namespace Mall.Module.Product
//获取和平分销返佣 //获取和平分销返佣
if (disModel.HPGradeId > 0 && model.CostPrice > 0) { if (disModel.HPGradeId > 0 && model.CostPrice > 0) {
string categoryids = string.Join(",", model.CategoryList.Select(x => x.CategoryId)); string categoryids = string.Join(",", model.CategoryList.Select(x => x.CategoryId));
var hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { CategoryIdsT = categoryids }); var hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { CategoryIdsT = categoryids, TenantId = TenantId, MallBaseId = MallBaseId });
if (hpcList.Any()) if (hpcList.Any())
{ {
RB_Distributor_HPCommission_Extend hpcModel; RB_Distributor_HPCommission_Extend hpcModel;
...@@ -1137,7 +1137,7 @@ namespace Mall.Module.Product ...@@ -1137,7 +1137,7 @@ namespace Mall.Module.Product
if (disModel.HPGradeId > 0 && model.CostPrice > 0) if (disModel.HPGradeId > 0 && model.CostPrice > 0)
{ {
string categoryids = string.Join(",", model.CategoryList.Select(x => x.CategoryId)); string categoryids = string.Join(",", model.CategoryList.Select(x => x.CategoryId));
var hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { CategoryIdsT = categoryids }); var hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { CategoryIdsT = categoryids, TenantId = TenantId, MallBaseId = MallBaseId });
if (hpcList.Any()) if (hpcList.Any())
{ {
RB_Distributor_HPCommission_Extend hpcModel; RB_Distributor_HPCommission_Extend hpcModel;
......
...@@ -3359,6 +3359,79 @@ namespace Mall.Module.User ...@@ -3359,6 +3359,79 @@ namespace Mall.Module.User
}; };
} }
/// <summary>
/// 获取商品建议价格
/// </summary>
/// <param name="categoryIds"></param>
/// <param name="costPrice"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public object GetHpGoodsSuggestPrice(string categoryIds, decimal costPrice, int tenantId, int mallBaseId)
{
//判断是否开启和平返佣
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Distributor_HPCommission_Extend.Status),
FiledValue=0,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Distributor_HPCommission_Extend.Enabled),
FiledValue=1,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Distributor_HPCommission_Extend.TenantId),
FiledValue=tenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Distributor_HPCommission_Extend.MallBaseId),
FiledValue=mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
if (!distributor_HPCommissionRepository.Exists(wheres)) {
return new
{
Status = 2,
Msg = "未配置和平返佣"
};
}
List<RB_Distributor_HPCommission_Extend> hpcList = new List<RB_Distributor_HPCommission_Extend>();
if (string.IsNullOrEmpty(categoryIds))
{
hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { IsCommon = 1, TenantId = tenantId, MallBaseId = mallBaseId });
}
else {
hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { CategoryIds = categoryIds, TenantId = tenantId, MallBaseId = mallBaseId });
}
if (hpcList.Any()) {
var hpcModel = hpcList.FirstOrDefault();
//查询直客毛利率
var gList = distributor_HPGradeRatioRepository.GetList(new RB_Distributor_HPGradeRatio_Extend() { CommissionId = hpcModel.Id, IsGuest = 1, TenantId = tenantId, MallBaseId = mallBaseId });
var ratioModel = gList.FirstOrDefault();
if (ratioModel != null)
{
decimal MPrice = costPrice / (1 - ((ratioModel.CommissionRatio ?? 0) / 100));
MPrice = Math.Ceiling(MPrice);
return new
{
Status = 1,
MPrice,
Msg = ""
};
}
}
return new
{
Status = 3,
Msg = "未匹配到适用的返佣"
};
}
#endregion #endregion
} }
} }
...@@ -89,6 +89,9 @@ where {where} group by h.Id order by h.Id desc"; ...@@ -89,6 +89,9 @@ where {where} group by h.Id order by h.Id desc";
{ {
where += $@" and h.{nameof(RB_Distributor_HPCommission.Name)} like '%{dmodel.Name}%'"; where += $@" and h.{nameof(RB_Distributor_HPCommission.Name)} like '%{dmodel.Name}%'";
} }
if (dmodel.IsCommon == 1) {
where += $@" and h.{nameof(RB_Distributor_HPCommission.IsCommon)}=1";
}
string sql = $@"select h.* from RB_Distributor_HPCommission h string sql = $@"select h.* from RB_Distributor_HPCommission h
left join RB_Distributor_HPCategory c on h.Id = c.CommissionId left join RB_Distributor_HPCategory c on h.Id = c.CommissionId
......
...@@ -36,6 +36,9 @@ namespace Mall.Repository.User ...@@ -36,6 +36,9 @@ namespace Mall.Repository.User
if (!string.IsNullOrEmpty(dmodel.CommissionIds)) { if (!string.IsNullOrEmpty(dmodel.CommissionIds)) {
where += $@" and r.{nameof(RB_Distributor_HPGradeRatio.CommissionId)} in({dmodel.CommissionIds})"; where += $@" and r.{nameof(RB_Distributor_HPGradeRatio.CommissionId)} in({dmodel.CommissionIds})";
} }
if (dmodel.IsGuest == 1) {
where += $@" and g.{nameof(RB_Distributor_HPGradeInfo.IsGuest)}=1";
}
string sql = $@"select r.*,g.Grade,g.GradeName from RB_Distributor_HPGradeRatio r string sql = $@"select r.*,g.Grade,g.GradeName from RB_Distributor_HPGradeRatio r
inner join RB_Distributor_HPGradeInfo g on r.GradeId = g.Id inner join RB_Distributor_HPGradeInfo g on r.GradeId = g.Id
......
...@@ -2486,6 +2486,24 @@ namespace Mall.WebApi.Controllers.User ...@@ -2486,6 +2486,24 @@ namespace Mall.WebApi.Controllers.User
return ApiResult.Success("", obj); return ApiResult.Success("", obj);
} }
/// <summary>
/// 获取商品建议价格
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetHpGoodsSuggestPrice() {
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
string CategoryIds = parms.GetStringValue("CategoryIds");
decimal CostPrice = parms.GetDecimal("CostPrice");
if (CostPrice <= 0) {
return ApiResult.ParamIsNull("请传递成本价格");
}
var obj = userModule.GetHpGoodsSuggestPrice(CategoryIds, CostPrice, req.TenantId, req.MallBaseId);
return ApiResult.Success("", obj);
}
#endregion #endregion
} }
} }
\ No newline at end of file
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