Commit 5b970c95 authored by liudong1993's avatar liudong1993

初始化 粉象返佣

parent dd9e5d36
......@@ -5725,7 +5725,98 @@ namespace Mall.Module.Product
#endregion
#region 同步粉象商品规格佣金
/// <summary>
/// 同步粉象佣金
/// </summary>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool SyncGoodsSpecificationCommission(int tenantId, int mallBaseId)
{
var goodsList = goodsRepository.GetSingleList(new RB_Goods_Extend() { TenantId = tenantId, MallBaseId = mallBaseId });
if (goodsList.Any())
{
//查询所有的分销价格
string goodsIds = string.Join(",", goodsList.Select(x => x.Id));
var dclist = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsIds = goodsIds, TenantId = tenantId, MallBaseId = mallBaseId });
//查询所有的规格价格
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsIds = goodsIds, TenantId = tenantId, MallBaseId = mallBaseId });
foreach (var item in goodsList) {
if (item.SeparateDistribution == 1 && item.SeparateDistributionMoneyType == 2)
{
var dc1list = dclist.Where(x => x.GoodsId == item.Id).ToList();
if (item.IsCustomSpecification == 1)
{
var sp1list = splist.Where(x => x.GoodsId == item.Id).ToList();
if (item.SeparateDistributionType == 1)
{
//普通设置 直接查 分销商等级的 返佣和
var dcmodel = dc1list.Where(x => x.DistributorGrade == 74).FirstOrDefault();
decimal TotalMoney = (dcmodel.OneCommission ?? 0) + (dcmodel.TwoCommission ?? 0) + (dcmodel.ThreeCommission ?? 0);
foreach (var qitem in sp1list)
{
//每个规格都设置为这么多fanyong
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods_SpecificationPrice.Commission),TotalMoney}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_SpecificationPrice.Id),
FiledValue=qitem.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_SpecificationPriceRepository.Update(keyValues, wheres);
}
}
else
{
//详细设置咯 对比规格更新
foreach (var qitem in dc1list.Where(x => x.DistributorGrade == 74)) {
decimal TotalMoney = (qitem.OneCommission ?? 0) + (qitem.TwoCommission ?? 0) + (qitem.ThreeCommission ?? 0);
var spmodel = sp1list.Where(x => x.SpecificationSort == qitem.SpecificationSort).FirstOrDefault();
if (spmodel != null) {
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods_SpecificationPrice.Commission),TotalMoney}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_SpecificationPrice.Id),
FiledValue=spmodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goods_SpecificationPriceRepository.Update(keyValues, wheres);
}
}
}
}
else {
//没有自定义规格 直接弄主表返佣金额
var dcmodel = dc1list.Where(x => x.DistributorGrade == 74).FirstOrDefault();
decimal TotalMoney = (dcmodel.OneCommission ?? 0) + (dcmodel.TwoCommission ?? 0) + (dcmodel.ThreeCommission ?? 0);
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.Commission),TotalMoney}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
goodsRepository.Update(keyValues, wheres);
}
}
}
}
return true;
}
#endregion
#region 分销商
/// <summary>
......
......@@ -2268,5 +2268,34 @@ namespace Mall.WebApi.Controllers.MallBase
}
#endregion
#region 同步商品规格返佣
/// <summary>
/// 同步商品规格佣金
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SyncGoodsSpecificationCommission() {
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int TenantId = parms.GetInt("TenantId", 0);
int MallBaseId = parms.GetInt("MallBaseId", 0);
if (TenantId <= 0 || MallBaseId <= 0) {
return ApiResult.Failed();
}
bool flag = productModule.SyncGoodsSpecificationCommission(TenantId, MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
#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