Commit 0305fe6d authored by 吴春's avatar 吴春

提交代码

parent 21de4655
......@@ -120,6 +120,12 @@ namespace Mall.Model.Extend.Product
/// 是否制单
/// </summary>
public int IsFinance { get; set; }
/// <summary>
/// 订单商品ids
/// </summary>
public List<int> IdList { get; set; }
#endregion
}
......
......@@ -44,6 +44,19 @@ namespace Mall.Module.Finance
private readonly RB_CurrencyRepository currencyRepository = new RB_CurrencyRepository();
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Finance_Configurine_Extend> GetFinanceConfigurineList(RB_Finance_Configurine_Extend dmodel)
{
return finance_ConfigurineRepository.GetList(dmodel);
}
/// <summary>
/// 获取财务配置
/// </summary>
......@@ -62,9 +75,11 @@ namespace Mall.Module.Finance
Msg = "需新增"
};
}
else {
else
{
int TypeId = 0;
if (fmodel.Type == 1) {
if (fmodel.Type == 1)
{
var backModel = backAccountRepository.GetAccountList(new RB_BackAccount_Extend() { BankType = fmodel.AccountType, ID = fmodel.AccountId ?? 0, RB_Group_Id = 2 }).FirstOrDefault();
TypeId = backModel?.TypeId ?? 0;
}
......@@ -87,7 +102,7 @@ namespace Mall.Module.Finance
fmodel.RemitCostTypeId,
fmodel.WorkFlowId,
fmodel.Type,
StartTime = fmodel.StartTime.HasValue?fmodel.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"):"",
StartTime = fmodel.StartTime.HasValue ? fmodel.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
fmodel.IntervalDay
}
};
......@@ -153,7 +168,8 @@ namespace Mall.Module.Finance
/// 获取币种
/// </summary>
/// <returns></returns>
public object GetFinanceCurrencyList() {
public object GetFinanceCurrencyList()
{
var list = currencyRepository.GetList(new Model.Entity.Finance.RB_Currency() { RB_Group_Id = 2 });
return list.Select(x => new
{
......@@ -202,6 +218,6 @@ namespace Mall.Module.Finance
return list;
}
}
}
......@@ -6524,6 +6524,20 @@ namespace Mall.Module.Product
{
return goods_OrderDetailRepository.GetSupplierOrderPageList(pageIndex, pageSize, out count, dmodel);
}
/// <summary>
/// 获取订单商品列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_OrderDetail_Extend> GetSupplierOrderList(RB_Goods_OrderDetail_Extend dmodel)
{
return goods_OrderDetailRepository.GetSupplierOrderList(dmodel);
}
#endregion
}
}
......@@ -137,5 +137,81 @@ INNER JOIN rb_goods_order o on o.OrderId=od.OrderId
where {where} order by o.CreateDate desc";
return GetPage<RB_Goods_OrderDetail_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取订单商品列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_OrderDetail_Extend> GetSupplierOrderList(RB_Goods_OrderDetail_Extend dmodel)
{
string where = $" 1=1 and o.{nameof(RB_Goods_Order.Status)}=0 and o.OrderStatus in(2,3,4,5,6) ";
if (dmodel.TenantId > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and o.{nameof(RB_Goods_Order.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.OrderType > 0)
{
where += $@" and od.{nameof(RB_Goods_OrderDetail.OrderType)}={dmodel.OrderType}";
}
if (dmodel.SupplierId > 0)
{
where += $@" and od.{nameof(RB_Goods_OrderDetail.SupplierId)}={dmodel.SupplierId}";
}
if (dmodel.IsFinance > 0)
{
if (dmodel.IsFinance == 1)
{
where += $@" and od.{nameof(RB_Goods_OrderDetail.CostFinanceId)}>0";
}
else
{
where += $@" and od.{nameof(RB_Goods_OrderDetail.CostFinanceId)}<=0";
}
}
if (dmodel.IdList != null && dmodel.IdList.Any())
{
string ids = string.Join(",", dmodel.IdList.Select(x => x));
where += $@" and od.{nameof(RB_Goods_OrderDetail.Id)} in({ids}) ";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and o.{nameof(RB_Goods_Order.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and o.{nameof(RB_Goods_Order.CreateDate)} <='{dmodel.EndTime} 23:59:59'";
}
if (!string.IsNullOrEmpty(dmodel.OrderNo))
{
where += $@" and o.{nameof(RB_Goods_Order.OrderNo)} like '%{dmodel.OrderNo}%'";
}
if (!string.IsNullOrEmpty(dmodel.GoodsName))
{
where += $@" and od.{nameof(RB_Goods_OrderDetail.GoodsName)} like '%{dmodel.GoodsName}%'";
}
if (!string.IsNullOrEmpty(dmodel.ProductCode))
{
where += $@" and od.{nameof(RB_Goods_OrderDetail.ProductCode)} like '%{dmodel.ProductCode}%'";
}
string sql = $@"SELECT od.*,o.OrderNo FROM rb_goods_orderdetail od
INNER JOIN rb_goods_order o on o.OrderId=od.OrderId
where {where} order by o.CreateDate desc";
return Get<RB_Goods_OrderDetail_Extend>(sql).ToList();
}
}
}
......@@ -5,8 +5,11 @@ using System.Threading.Tasks;
using Mall.Common;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Model.Entity.Finance;
using Mall.Model.Extend.Finance;
using Mall.Model.Extend.Product;
using Mall.Model.Extend.User;
using Mall.Module.Finance;
using Mall.Module.Product;
using Mall.Module.User;
using Mall.WebApi.Filter;
......@@ -29,6 +32,13 @@ namespace Mall.WebApi.Controllers.User
/// </summary>
private readonly OrderModule orderModule = new OrderModule();
/// <summary>
/// 财务
/// </summary>
private readonly FinanceModule financeModule = new FinanceModule();
#region 供应商管理
[HttpPost]
public ApiResult GetSupplierList()
......@@ -173,7 +183,7 @@ namespace Mall.WebApi.Controllers.User
/// <summary>
/// 获取详情
/// 获取供应商下拉列表
/// </summary>
/// <returns></returns>
[HttpPost]
......@@ -221,6 +231,90 @@ namespace Mall.WebApi.Controllers.User
});
return ApiResult.Success("", pagelist);
}
//生成财务单据
/// <summary>
/// 供应商商品生成财务单据
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult PayCostFinance()
{
var parms = RequestParm;
RB_Goods_OrderDetail_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_OrderDetail_Extend>(RequestParm.msg.ToString());
demodel.TenantId = UserInfo.TenantId;
demodel.MallBaseId = parms.MallBaseId;
var list = orderModule.GetSupplierOrderList(demodel);
var result = new List<RB_Goods_OrderDetail_Extend>();
RB_Finance_Record_Extend record = new RB_Finance_Record_Extend();
record.MallBaseId = demodel.MallBaseId;
record.TenantId = demodel.TenantId;
record.Type = 2;
record.CreateDate = System.DateTime.Now;
record.RecordDetailList = new List<RB_Finance_RecordDetail>();
if (list != null && list.Any())
{
//先查询规则
var financeConfigurineModel = financeModule.GetFinanceConfigurineList(new Model.Extend.Finance.RB_Finance_Configurine_Extend { Type = 1, MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId }).FirstOrDefault();
foreach (var orderGoodsItem in list)
{
if (orderGoodsItem.Final_Price > 0)
{
var newOrderGoods = new RB_Goods_OrderDetail_Extend();
newOrderGoods = orderGoodsItem;
newOrderGoods.FinanceType = 1;
result.Add(newOrderGoods);
}
if (orderGoodsItem.FreightMoney.HasValue && orderGoodsItem.FreightMoney.Value > 0)
{
var newOrderGoods = new RB_Goods_OrderDetail_Extend();
newOrderGoods = orderGoodsItem;
newOrderGoods.FinanceType = 2;
result.Add(newOrderGoods);
}
RB_Finance_RecordDetail financeRecordDetail = new RB_Finance_RecordDetail
{
ID = 0,
RecordId = 0,
Type = record.Type,
TenantId = record.TenantId,
MallBaseId = record.MallBaseId,
FinanceId = 0,
CreateDate = record.CreateDate,
Name = orderGoodsItem.GoodsName,
OrderId = orderGoodsItem.OrderId ?? 0,
OrderDetailId = orderGoodsItem.Id,
GoodsPrice = ((orderGoodsItem.Final_Price ?? 0) - (orderGoodsItem.FreightMoney ?? 0)),
FreightMoney = orderGoodsItem.FreightMoney,
Unit_Price = orderGoodsItem.Unit_Price,
Number = orderGoodsItem.Number
};
record.RecordDetailList.Add(financeRecordDetail);
}
var detailList = result.Select(x => new
{
CostTypeId = x.FinanceType == 1 ? financeConfigurineModel.CBCostTypeId : financeConfigurineModel.FreightCostTypeId,
Number = x.FinanceType == 1 ? x.Number : 1,
OriginalMoney = x.FinanceType == 1 ? x.Unit_Price : x.FreightMoney,
UnitPrice = x.FinanceType == 1 ? (((x.Final_Price ?? 0) - (x.FreightMoney ?? 0)) / (x.Number ?? 0)) : x.FreightMoney,
Remark = x.GoodsName + x.OrderNo
});
}
return ApiResult.Success("");
}
#endregion
}
......
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