Commit e99585d7 authored by 吴春's avatar 吴春

提交供应商返佣/分类包邮规则

parent 76746f37
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.BaseSetUp
{
/// <summary>
/// 分类包邮规则
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_FreeShipping
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
/// <summary>
/// 单品满件包邮
/// </summary>
public int? FullNumPinkage
{
get;
set;
}
/// <summary>
/// 单品满额包邮
/// </summary>
public decimal? FullMoneyPinkage
{
get;
set;
}
/// <summary>
/// 是否启用全局包邮
/// </summary>
public int IsEnable { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.BaseSetUp
{
/// <summary>
/// 分类包邮分类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_FreeShippingCategory
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
/// <summary>
/// 分类id
/// </summary>
public int CategoryId { get; set; }
/// <summary>
/// 包邮规则id
/// </summary>
public int FreeShippingId { get; set; }
}
}
...@@ -355,5 +355,9 @@ namespace Mall.Model.Entity.BaseSetUp ...@@ -355,5 +355,9 @@ namespace Mall.Model.Entity.BaseSetUp
/// </summary> /// </summary>
public int TenantId { get; set; } public int TenantId { get; set; }
/// <summary>
/// 是否开启全局分类包邮规则
/// </summary>
public int IsFreeShipping { get; set; }
} }
} }
...@@ -130,5 +130,11 @@ namespace Mall.Model.Entity.Finance ...@@ -130,5 +130,11 @@ namespace Mall.Model.Entity.Finance
{ {
get; set; get; set;
} }
///// <summary>
///// 供应商id
///// </summary>
//public int SupplierId { get; set; }
} }
} }
...@@ -87,9 +87,6 @@ namespace Mall.Model.Entity.User ...@@ -87,9 +87,6 @@ namespace Mall.Model.Entity.User
public int Introducer { get; set; } public int Introducer { get; set; }
/// <summary>
/// 供应商关联人返佣比例
/// </summary>
public decimal CommissionRate { get; set; }
} }
} }
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 供应商
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_SupplierCommission
{
public int ID { get; set; }
/// <summary>
/// 供应商id
/// </summary>
public int SupplierId { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
/// <summary>
/// 返佣类型1-10
/// </summary>
public int CommissionType { get; set; }
/// <summary>
/// 返佣比例
/// </summary>
public decimal CommissionRate { get; set; }
}
}
using Mall.Common.AOP;
using Mall.Model.Entity.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Extend.BaseSetUp
{
/// <summary>
/// 分类包邮扩展表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_FreeShippingCategory_Extend : RB_FreeShippingCategory
{
/// <summary>
/// 分类名称
/// </summary>
public string CategoryName { get; set; }
public string FreeShippingIds { get; set; }
/// <summary>
/// 分类id
/// </summary>
public string CategoryIds { get; set; }
}
}
using Mall.Common.AOP;
using Mall.Model.Entity.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Extend.BaseSetUp
{
/// <summary>
/// 分类包邮规则
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_FreeShipping_Extend : RB_FreeShipping
{
/// <summary>
/// 分类列表
/// </summary>
public List<RB_FreeShippingCategory_Extend> CategoryList { get; set; }
}
}
...@@ -21,5 +21,7 @@ namespace Mall.Model.Extend.User ...@@ -21,5 +21,7 @@ namespace Mall.Model.Extend.User
/// 介绍人名称 /// 介绍人名称
/// </summary> /// </summary>
public string IntroducerName { get; set; } public string IntroducerName { get; set; }
}
public List<RB_SupplierCommission> SupplierCommissionList { get; set; }
}
} }
...@@ -25,6 +25,9 @@ namespace Mall.Module.BaseSetUp ...@@ -25,6 +25,9 @@ namespace Mall.Module.BaseSetUp
private RB_ElectronicSheetRepository electronicSheetRepository = new RB_ElectronicSheetRepository(); private RB_ElectronicSheetRepository electronicSheetRepository = new RB_ElectronicSheetRepository();
private RB_File_StoreRepository storeRepository = new RB_File_StoreRepository(); private RB_File_StoreRepository storeRepository = new RB_File_StoreRepository();
private RB_FreeShippingCategoryRepository freeShippingCategoryRepository = new RB_FreeShippingCategoryRepository();
private RB_FreeShippingRepository freeShippingRepository = new RB_FreeShippingRepository();
#region 基础设置 #region 基础设置
/// <summary> /// <summary>
/// 获取小程序列表 /// 获取小程序列表
...@@ -545,7 +548,7 @@ namespace Mall.Module.BaseSetUp ...@@ -545,7 +548,7 @@ namespace Mall.Module.BaseSetUp
{ {
new WhereHelper (){ FiledName=nameof(RB_Logistics_RulesRegion.ID),FiledValue=itemRegion.ID,OperatorEnum=OperatorEnum.Equal} new WhereHelper (){ FiledName=nameof(RB_Logistics_RulesRegion.ID),FiledValue=itemRegion.ID,OperatorEnum=OperatorEnum.Equal}
}; };
logisticsRulesRegionRepository.Update(filedsRegion, whereHelpersRegion, trans); logisticsRulesRegionRepository.Update(filedsRegion, whereHelpersRegion, trans);
} }
} }
if (model.List != null && model.List.Any()) if (model.List != null && model.List.Any())
...@@ -556,7 +559,7 @@ namespace Mall.Module.BaseSetUp ...@@ -556,7 +559,7 @@ namespace Mall.Module.BaseSetUp
model.List.ForEach(x => x.RulesPriceId = rulesId); model.List.ForEach(x => x.RulesPriceId = rulesId);
model.List.ForEach(x => x.RulesType = model.RulesType); model.List.ForEach(x => x.RulesType = model.RulesType);
model.List.ForEach(x => x.MallBaseId = model.MallBaseId); model.List.ForEach(x => x.MallBaseId = model.MallBaseId);
logisticsRulesRegionRepository.InsertBatch(model.List, trans); logisticsRulesRegionRepository.InsertBatch(model.List, trans);
} }
logisticsRulesRepository.DBSession.Commit(); logisticsRulesRepository.DBSession.Commit();
...@@ -927,5 +930,239 @@ namespace Mall.Module.BaseSetUp ...@@ -927,5 +930,239 @@ namespace Mall.Module.BaseSetUp
} }
#endregion #endregion
#region 分类包邮规则
/// <summary>
/// 新增/修改基础信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateIsFreeShipping(int mallId, int IsFreeShipping)
{
try
{
IDictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_MallBase.IsFreeShipping),IsFreeShipping},
};
IList<WhereHelper> whereHelpers = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_MallBase.ID),FiledValue=mallId,OperatorEnum=OperatorEnum.Equal}
};
return mallBaseRepository.Update(fileds, whereHelpers);
}
catch (Exception ex)
{
LogHelper.Write(ex, "AddOrUpdateIsFreeShipping");
mallBaseRepository.DBSession.Rollback("AddOrUpdateIsFreeShipping");
return false;
}
}
/// <summary>
/// 分类包邮规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_FreeShipping_Extend> GetFreeShippingList(int pageIndex, int pageSize, out long rowCount, RB_FreeShipping_Extend query)
{
List<RB_FreeShipping_Extend> list = freeShippingRepository.GetPageListRepository(pageIndex, pageSize, out rowCount, query);
if (list != null && list.Any())
{
List<RB_FreeShippingCategory_Extend> listLogisticsRulesRegion = freeShippingCategoryRepository.GetFreeShippingCategoryList(new RB_FreeShippingCategory_Extend { TenantId = query.TenantId, MallBaseId = query.MallBaseId, FreeShippingIds = string.Join(",", list.Select(x => x.ID)) });
foreach (var item in list)
{
item.CategoryList = new List<RB_FreeShippingCategory_Extend>();
item.CategoryList = listLogisticsRulesRegion.Where(x => x.FreeShippingId == item.ID).ToList();
}
}
return list;
}
/// <summary>
/// 分类包邮规则
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_FreeShipping_Extend GetFreeShippingModel(RB_FreeShipping_Extend query)
{
RB_FreeShipping_Extend model = freeShippingRepository.GetFreeShippingList(query).FirstOrDefault();
if (model != null)
{
List<RB_FreeShippingCategory_Extend> listLogisticsRulesRegion = freeShippingCategoryRepository.GetFreeShippingCategoryList(new RB_FreeShippingCategory_Extend { TenantId = query.TenantId, MallBaseId = query.MallBaseId, FreeShippingId = model.ID });
model.CategoryList = new List<RB_FreeShippingCategory_Extend>();
model.CategoryList = listLogisticsRulesRegion;
}
return model;
}
/// <summary>
/// 新增/修改分类包邮基础信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateFreeShipping(RB_FreeShipping_Extend model)
{
bool flag = false;
var trans = freeShippingRepository.DbTransaction;
try
{
int rulesId = 0;
if (model.ID == 0)
{
rulesId = freeShippingRepository.Insert(model, trans);
flag = rulesId > 0;
if (model.CategoryList != null && model.CategoryList.Any())
{
model.CategoryList.ForEach(x => x.TenantId = model.TenantId);
model.CategoryList.ForEach(x => x.CreateDate = model.CreateDate);
model.CategoryList.ForEach(x => x.UpdateDate = model.UpdateDate);
model.CategoryList.ForEach(x => x.ID = 0);
model.CategoryList.ForEach(x => x.FreeShippingId = rulesId);
model.CategoryList.ForEach(x => x.MallBaseId = model.MallBaseId);
freeShippingCategoryRepository.InsertBatch(model.CategoryList, trans);
}
}
else
{
rulesId = model.ID;
flag = freeShippingRepository.Update(model, trans);
List<RB_FreeShippingCategory_Extend> rlist = freeShippingCategoryRepository.GetFreeShippingCategoryList(new RB_FreeShippingCategory_Extend { TenantId = model.TenantId, MallBaseId = model.MallBaseId, FreeShippingId = model.ID });
#region 验证比例是否修改
var rUpdateList = rlist.Where(x => model.CategoryList.Select(z => z.FreeShippingId).Contains(x.FreeShippingId)).ToList();
var rDelList = rlist.Where(x => !model.CategoryList.Select(z => z.FreeShippingId).Contains(x.FreeShippingId)).ToList();
var rInsertList = model.CategoryList.Where(x => !rlist.Select(z => z.FreeShippingId).Contains(x.FreeShippingId)).ToList();
foreach (var item in rUpdateList)
{
var rmodel = model.CategoryList.Where(x => x.FreeShippingId == item.FreeShippingId).FirstOrDefault();
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_FreeShippingCategory.CategoryId),rmodel.CategoryId}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_FreeShippingCategory.ID),
FiledValue=item.ID,
OperatorEnum=OperatorEnum.Equal
}
};
freeShippingCategoryRepository.Update(keyValues1, wheres1, trans);
}
foreach (var item in rDelList)
{
freeShippingCategoryRepository.Delete(item, trans);
}
foreach (var item in rInsertList)
{
item.TenantId = model.TenantId;
item.CreateDate = System.DateTime.Now;
item.UpdateDate = System.DateTime.Now;
item.ID = 0;
item.FreeShippingId = rulesId;
item.MallBaseId = model.MallBaseId;
freeShippingCategoryRepository.Insert(item, trans);
}
#endregion
}
freeShippingRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "AddOrUpdateFreeShipping");
freeShippingRepository.DBSession.Rollback("AddOrUpdateFreeShipping");
return false;
}
return flag;
}
/// <summary>
/// 删除分类包邮规则
/// </summary>
/// <param name="gradeId"></param>
/// <param name="uid"></param>
/// <returns></returns>
public bool DelFreeShipping(int id, int uid, int mallBaseId)
{
bool flag = false;
var trans = freeShippingRepository.DbTransaction;
try
{
Dictionary<string, object> cols = new Dictionary<string, object>()
{
{ nameof(RB_FreeShipping.Status),1},
{ nameof(RB_FreeShipping.UpdateDate),DateTime.Now},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_FreeShipping.ID),
FiledValue=id,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_FreeShipping.TenantId),
FiledValue=Convert.ToInt32(uid),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_FreeShipping.MallBaseId),
FiledValue=Convert.ToInt32(mallBaseId),
OperatorEnum=OperatorEnum.Equal
}
};
flag = freeShippingRepository.Update(cols, wheres1, trans);
IDictionary<string, object> filedsRegion = new Dictionary<string, object>()//删除价格下面对应的分类
{
{ nameof(RB_FreeShippingCategory.Status),1},
{ nameof(RB_FreeShippingCategory.UpdateDate),System.DateTime.Now},
};
IList<WhereHelper> whereHelpersRegion = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_FreeShippingCategory.FreeShippingId),FiledValue=id,OperatorEnum=OperatorEnum.Equal},
new WhereHelper(){
FiledName=nameof(RB_FreeShippingCategory.TenantId),
FiledValue=Convert.ToInt32(uid),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_FreeShippingCategory.MallBaseId),
FiledValue=Convert.ToInt32(mallBaseId),
OperatorEnum=OperatorEnum.Equal
} };
flag = freeShippingCategoryRepository.Update(filedsRegion, whereHelpersRegion, trans);
freeShippingRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "DelFreeShipping");
freeShippingRepository.DBSession.Rollback("DelFreeShipping");
return false;
}
return flag;
}
/// <summary>
/// 分类包邮规则分类信息列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_FreeShippingCategory_Extend> GetFreeShippingCategoryList(RB_FreeShippingCategory_Extend query)
{
return freeShippingCategoryRepository.GetFreeShippingCategoryList(query);
}
#endregion
} }
} }
...@@ -16,7 +16,7 @@ namespace Mall.Module.User ...@@ -16,7 +16,7 @@ namespace Mall.Module.User
public class SupplierModule public class SupplierModule
{ {
private RB_SupplierRepository supplierRepository = new RB_SupplierRepository(); private RB_SupplierRepository supplierRepository = new RB_SupplierRepository();
private RB_SupplierCommissionRepository supplierCommissionRepository = new RB_SupplierCommissionRepository();
private RB_ClientBankAccountRepository clientBankAccountRepository = new RB_ClientBankAccountRepository(); private RB_ClientBankAccountRepository clientBankAccountRepository = new RB_ClientBankAccountRepository();
/// <summary> /// <summary>
...@@ -34,10 +34,14 @@ namespace Mall.Module.User ...@@ -34,10 +34,14 @@ namespace Mall.Module.User
{ {
string ids = string.Join(",", list.Select(x => x.BankAccountId)); string ids = string.Join(",", list.Select(x => x.BankAccountId));
var backList = clientBankAccountRepository.GetList(new RB_ClientBankAccount(), "", ids); var backList = clientBankAccountRepository.GetList(new RB_ClientBankAccount(), "", ids);
var supplierCommissionList = supplierCommissionRepository.GetListBySupplierIds(ids);
foreach (var item in list) foreach (var item in list)
{ {
item.ClientBankAccount = new RB_ClientBankAccount(); item.ClientBankAccount = new RB_ClientBankAccount();
item.ClientBankAccount = backList.Where(x => x.ID == item.BankAccountId).FirstOrDefault(); item.ClientBankAccount = backList.Where(x => x.ID == item.BankAccountId).FirstOrDefault();
item.SupplierCommissionList = new List<RB_SupplierCommission>();
item.SupplierCommissionList = supplierCommissionList.Where(x => x.SupplierId == item.ID).ToList();
} }
} }
return list; return list;
...@@ -56,10 +60,13 @@ namespace Mall.Module.User ...@@ -56,10 +60,13 @@ namespace Mall.Module.User
{ {
string ids = string.Join(",", list.Select(x => x.BankAccountId)); string ids = string.Join(",", list.Select(x => x.BankAccountId));
var backList = clientBankAccountRepository.GetList(new RB_ClientBankAccount(), "", ids); var backList = clientBankAccountRepository.GetList(new RB_ClientBankAccount(), "", ids);
var supplierCommissionList = supplierCommissionRepository.GetListBySupplierIds(ids);
foreach (var item in list) foreach (var item in list)
{ {
item.ClientBankAccount = new RB_ClientBankAccount(); item.ClientBankAccount = new RB_ClientBankAccount();
item.ClientBankAccount = backList.Where(x => x.ID == item.BankAccountId).FirstOrDefault(); item.ClientBankAccount = backList.Where(x => x.ID == item.BankAccountId).FirstOrDefault();
item.SupplierCommissionList = new List<RB_SupplierCommission>();
item.SupplierCommissionList = supplierCommissionList.Where(x => x.SupplierId == item.ID).ToList();
} }
} }
return list; return list;
...@@ -128,6 +135,28 @@ namespace Mall.Module.User ...@@ -128,6 +135,28 @@ namespace Mall.Module.User
}; };
flag = supplierRepository.Update(filedsSupplier, whereHelpersSupplier); flag = supplierRepository.Update(filedsSupplier, whereHelpersSupplier);
} }
var supplierCommissionList = supplierCommissionRepository.GetSupplierCommissionList(new RB_SupplierCommission { SupplierId = model.ID });
foreach (var item in model.SupplierCommissionList)
{
var commissionModel = supplierCommissionList.Where(x => x.CommissionType == item.CommissionType).FirstOrDefault();
if (commissionModel != null)
{
commissionModel.CommissionRate = item.CommissionRate;
supplierCommissionRepository.Update(commissionModel);
}
else
{
item.CreateDate = System.DateTime.Now;
item.UpdateDate = System.DateTime.Now;
item.MallBaseId = model.MallBaseId;
item.TenantId = model.TenantId;
item.SupplierId = model.ID;
item.Status = model.Status;
supplierCommissionRepository.Insert(item);
}
}
} }
else else
{ {
...@@ -138,6 +167,12 @@ namespace Mall.Module.User ...@@ -138,6 +167,12 @@ namespace Mall.Module.User
{ {
model.BankAccountId = id; model.BankAccountId = id;
int supplierId = supplierRepository.Insert(model); int supplierId = supplierRepository.Insert(model);
model.SupplierCommissionList.ForEach(x => x.CreateDate = model.CreateDate);
model.SupplierCommissionList.ForEach(x => x.UpdateDate = model.UpdateDate);
model.SupplierCommissionList.ForEach(x => x.MallBaseId = model.MallBaseId);
model.SupplierCommissionList.ForEach(x => x.TenantId = model.TenantId);
model.SupplierCommissionList.ForEach(x => x.SupplierId = supplierId);
supplierCommissionRepository.InsertBatch(model.SupplierCommissionList);
flag = supplierId > 0; flag = supplierId > 0;
//IDictionary<string, object> fileds = new Dictionary<string, object>() //IDictionary<string, object> fileds = new Dictionary<string, object>()
//{ //{
...@@ -195,6 +230,16 @@ namespace Mall.Module.User ...@@ -195,6 +230,16 @@ namespace Mall.Module.User
new WhereHelper (){ FiledName=nameof(RB_Supplier.ID),FiledValue=ID,OperatorEnum=OperatorEnum.Equal} new WhereHelper (){ FiledName=nameof(RB_Supplier.ID),FiledValue=ID,OperatorEnum=OperatorEnum.Equal}
}; };
flag = supplierRepository.Update(filedsSupplier, whereHelpersSupplier); flag = supplierRepository.Update(filedsSupplier, whereHelpersSupplier);
IDictionary<string, object> filedsSupplierCommission = new Dictionary<string, object>()
{
{ nameof(RB_SupplierCommission.Status),(int) Common.Enum.DateStateEnum.Delete}
};
IList<WhereHelper> whereHelpersSupplierCommission = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_SupplierCommission.SupplierId),FiledValue=ID,OperatorEnum=OperatorEnum.Equal}
};
supplierCommissionRepository.Update(filedsSupplierCommission, whereHelpersSupplierCommission);
} }
} }
catch (Exception ex) catch (Exception ex)
......
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Extend.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.BaseSetUp
{
/// <summary>
/// 分类包邮规则分类仓储层
/// </summary>
public class RB_FreeShippingCategoryRepository : RepositoryBase<RB_FreeShippingCategory>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_FreeShippingCategory); } }
/// <summary>
/// 分类包邮规则分类信息列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_FreeShippingCategory_Extend> GetFreeShippingCategoryPage(int pageIndex, int pageSize, out long rowCount, RB_FreeShippingCategory_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT a.*,b.`Name` as CategoryName FROM {TableName} as a LEFT JOIN rb_product_category as b on a.CategoryId=b.Id WHERE a.`Status`=0 and b.`Status`=0");
if (query != null)
{
if (query.ID > 0)
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.ID)}={query.ID}");
}
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.TenantId)}={query.TenantId}");
}
if (query.MallBaseId > 0)
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.FreeShippingId > 0)
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.FreeShippingId)}={query.FreeShippingId}");
}
if (!string.IsNullOrWhiteSpace(query.FreeShippingIds))
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.FreeShippingId)} in ({query.FreeShippingIds})");
}
if (!string.IsNullOrWhiteSpace(query.CategoryIds))
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.CategoryId)} in ({query.CategoryIds})");
}
}
return GetPage<RB_FreeShippingCategory_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 分类包邮规则分类信息列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_FreeShippingCategory_Extend> GetFreeShippingCategoryList(RB_FreeShippingCategory_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT a.*,b.`Name` as CategoryName FROM {TableName} as a LEFT JOIN rb_product_category as b on a.CategoryId=b.Id WHERE a.`Status`=0 and b.`Status`=0");
if (query != null)
{
if (query.ID > 0)
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.ID)}={query.ID}");
}
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.TenantId)}={query.TenantId}");
}
if (query.MallBaseId > 0)
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.FreeShippingId > 0)
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.FreeShippingId)}={query.FreeShippingId}");
}
if (!string.IsNullOrWhiteSpace(query.FreeShippingIds))
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.FreeShippingId)} in ({query.FreeShippingIds})");
}
if (!string.IsNullOrWhiteSpace(query.CategoryIds))
{
builder.Append($" AND a.{nameof(RB_FreeShippingCategory_Extend.CategoryId)} in ({query.CategoryIds})");
}
}
return Get<RB_FreeShippingCategory_Extend>(builder.ToString()).ToList();
}
}
}
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Extend.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.BaseSetUp
{
/// <summary>
/// 分类包邮规则仓储层
/// </summary>
public class RB_FreeShippingRepository : RepositoryBase<RB_FreeShipping>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_FreeShipping); } }
/// <summary>
/// 物料规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_FreeShipping_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_FreeShipping_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_FreeShipping_Extend.Status)}=0");
if (query != null)
{
// where += $@" and {nameof(RB_Customer_InfoCreate.CustomerId)}={dmodel.CustomerId}";
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_FreeShipping_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_FreeShipping_Extend.MallBaseId)}={query.MallBaseId}");
}
}
return GetPage<RB_FreeShipping_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 物流规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_FreeShipping_Extend> GetFreeShippingList(RB_FreeShipping_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_FreeShipping_Extend.Status)}=0 ");
if (query != null)
{
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_FreeShipping_Extend.ID)}={query.ID}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_FreeShipping_Extend.TenantId)}={query.TenantId}");
}
if (query.MallBaseId > 0)
{
builder.Append($" AND {nameof(RB_FreeShipping_Extend.MallBaseId)}={query.MallBaseId}");
}
}
return Get<RB_FreeShipping_Extend>(builder.ToString()).ToList();
}
}
}
using Mall.Model.Entity.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.User
{
public class RB_SupplierCommissionRepository:RepositoryBase<RB_SupplierCommission>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_SupplierCommission); } }
/// <summary>
/// 供应商返佣规则
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_SupplierCommission> GetSupplierCommissionPage(int pageIndex, int pageSize, out long rowCount, RB_SupplierCommission query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_SupplierCommission.Status)}=0");
if (query != null)
{
// where += $@" and {nameof(RB_Customer_InfoCreate.CustomerId)}={dmodel.CustomerId}";
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_SupplierCommission.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_SupplierCommission.MallBaseId)}={query.MallBaseId}");
}
if (query.CommissionType > 0)
{
builder.Append($" AND {nameof(RB_SupplierCommission.CommissionType)}={query.CommissionType}");
}
if (query.SupplierId > 0)
{
builder.Append($" AND {nameof(RB_SupplierCommission.SupplierId)}={query.SupplierId}");
}
}
return GetPage<RB_SupplierCommission>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 供应商返佣规则
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_SupplierCommission> GetSupplierCommissionList(RB_SupplierCommission query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_SupplierCommission.Status)}=0 ");
if (query != null)
{
// where += $@" and {nameof(RB_Customer_InfoCreate.CustomerId)}={dmodel.CustomerId}";
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_SupplierCommission.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_SupplierCommission.MallBaseId)}={query.MallBaseId}");
}
if (query.CommissionType > 0)
{
builder.Append($" AND {nameof(RB_SupplierCommission.CommissionType)}={query.CommissionType}");
}
if (query.SupplierId > 0)
{
builder.Append($" AND {nameof(RB_SupplierCommission.SupplierId)}={query.SupplierId}");
}
}
return Get<RB_SupplierCommission>(builder.ToString()).ToList();
}
/// <summary>
/// 供应商返佣规则
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_SupplierCommission> GetListBySupplierIds(string ids)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_SupplierCommission.Status)}=0 ");
if (!string.IsNullOrWhiteSpace(ids))
{
builder.Append($" AND {nameof(RB_SupplierCommission.SupplierId)} in ({ids})");
}
return Get<RB_SupplierCommission>(builder.ToString()).ToList();
}
}
}
...@@ -971,5 +971,159 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -971,5 +971,159 @@ namespace Mall.WebApi.Controllers.MallBase
} }
#endregion #endregion
#region 包邮规则
/// <summary>
/// 列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetFreeShippingList()
{
var parms = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
RB_FreeShipping_Extend demodel = JsonConvert.DeserializeObject<RB_FreeShipping_Extend>(RequestParm.msg.ToString());
demodel.TenantId = UserInfo.TenantId;
demodel.MallBaseId = parms.MallBaseId;
var list = mallBaseModule.GetFreeShippingList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.ID,
x.FullMoneyPinkage,
x.FullNumPinkage,
x.CategoryList
});
return ApiResult.Success("", pagelist);
}
public ApiResult DelFreeShipping()
{
var parms = RequestParm;
JObject parmsJob = JObject.Parse(RequestParm.msg.ToString());
int Id = parmsJob.GetInt("Id", 0);
if (Id <= 0)
{
return ApiResult.Failed("请传递参数");
}
bool flag = mallBaseModule.DelFreeShipping(Id, UserInfo.TenantId, parms.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 获取详情
/// </summary>
/// <returns></returns>
public ApiResult GetFreeShippingModel()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_FreeShipping_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
var oldLogisticsModel = mallBaseModule.GetFreeShippingModel(query);
if (oldLogisticsModel == null)
{
oldLogisticsModel = new RB_FreeShipping_Extend();
}
return ApiResult.Success("", oldLogisticsModel);
}
/// <summary>
/// 保存分类包邮规则
/// </summary>
/// <returns></returns>
public ApiResult AddOrUpdateFreeShipping()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_FreeShipping_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
if (query == null)
{
return ApiResult.Failed("请传入包邮规则信息");
}
else
{
if ((query.FullMoneyPinkage ?? 0) <= 0 || (query.FullNumPinkage ?? 0) <= 0)
{
return ApiResult.Failed("满减/满额不能同时为零");
}
if (query.CategoryList == null || !query.CategoryList.Any())
{
return ApiResult.Failed("请选择需要包邮的分类");
}
//判断当前的分类是否有被其他包邮规则添加,
var categoryList = mallBaseModule.GetFreeShippingCategoryList(new RB_FreeShippingCategory_Extend { TenantId = UserInfo.TenantId, MallBaseId = parms.MallBaseId, CategoryIds = string.Join(",", query.CategoryList.Select(x => x.CategoryId)) });
if (categoryList.Any(x => x.CategoryId == 0))
{
return ApiResult.Failed("已添加全局包邮规则");
}
foreach (var item in query.CategoryList)
{
if (categoryList.Any(x => x.CategoryId == item.CategoryId&&x.FreeShippingId!=query.ID))
{
return ApiResult.Failed(item.CategoryName + "已添加包邮规则");
}
}
if (query.ID == 0)
{
query.CreateDate = System.DateTime.Now;
}
query.UpdateDate = System.DateTime.Now;
bool result = mallBaseModule.AddOrUpdateFreeShipping(query);
if (result)
{
return ApiResult.Success("分类包邮规则信息保存成功");
}
else
{
return ApiResult.Failed("分类包邮规则信息保存失败");
}
}
}
/// <summary>
/// 保存全局分类包邮规则
/// </summary>
/// <returns></returns>
public ApiResult AddOrUpdateIsFreeShipping()
{
var parms = RequestParm;
JObject parmsJob = JObject.Parse(RequestParm.msg.ToString());
int Id = parmsJob.GetInt("Id", 0);
int IsFreeShipping = parmsJob.GetInt("IsFreeShipping", 0);
if (Id <= 0)
{
return ApiResult.Failed("请传递参数");
}
bool flag = mallBaseModule.AddOrUpdateIsFreeShipping(Id, IsFreeShipping);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
#endregion
} }
} }
\ No newline at end of file
...@@ -59,13 +59,14 @@ namespace Mall.WebApi.Controllers.User ...@@ -59,13 +59,14 @@ namespace Mall.WebApi.Controllers.User
x.Mobile, x.Mobile,
x.Address, x.Address,
x.IntroducerName, x.IntroducerName,
x.CommissionRate,
CardNum = x.ClientBankAccount != null ? x.ClientBankAccount.CardNum : "", CardNum = x.ClientBankAccount != null ? x.ClientBankAccount.CardNum : "",
OpenBankName = x.ClientBankAccount != null ? x.ClientBankAccount.OpenBankName : "", OpenBankName = x.ClientBankAccount != null ? x.ClientBankAccount.OpenBankName : "",
AccountAlias = x.ClientBankAccount != null ? x.ClientBankAccount.AccountAlias : "", AccountAlias = x.ClientBankAccount != null ? x.ClientBankAccount.AccountAlias : "",
AccountHolder = x.ClientBankAccount != null ? x.ClientBankAccount.AccountHolder : "", AccountHolder = x.ClientBankAccount != null ? x.ClientBankAccount.AccountHolder : "",
BackId = x.ClientBankAccount != null ? x.ClientBankAccount.ID : 0, BackId = x.ClientBankAccount != null ? x.ClientBankAccount.ID : 0,
x.SupplierCommissionList,
AccountClassifyStr = x.ClientBankAccount != null ? (x.ClientBankAccount?.AccountClassify == 2 ? "银行" : (x.ClientBankAccount?.AccountClassify == 3 ? "虚拟账户" : (x.ClientBankAccount?.AccountClassify == 4 ? "微信支付宝" : (x.ClientBankAccount?.AccountClassify == 1 ? "平台" : "")))) : "", AccountClassifyStr = x.ClientBankAccount != null ? (x.ClientBankAccount?.AccountClassify == 2 ? "银行" : (x.ClientBankAccount?.AccountClassify == 3 ? "虚拟账户" : (x.ClientBankAccount?.AccountClassify == 4 ? "微信支付宝" : (x.ClientBankAccount?.AccountClassify == 1 ? "平台" : "")))) : "",
}); });
return ApiResult.Success("", pagelist); return ApiResult.Success("", pagelist);
} }
...@@ -148,6 +149,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -148,6 +149,7 @@ namespace Mall.WebApi.Controllers.User
if (oldLogisticsModel == null) if (oldLogisticsModel == null)
{ {
oldLogisticsModel = new RB_Supplier_Extend(); oldLogisticsModel = new RB_Supplier_Extend();
} }
return ApiResult.Success("", oldLogisticsModel); return ApiResult.Success("", oldLogisticsModel);
} }
......
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