Commit a072f2bb authored by liudong1993's avatar liudong1993

1 教育资产 增加 资产商品化出库操作

parent 52f62296
......@@ -49,6 +49,17 @@ namespace REBORN.Common.Enum
/// 其他耗材出库
/// </summary>
[EnumField("其他耗材出库")]
OtherSuppliesStockOut = 13
OtherSuppliesStockOut = 13,
/// <summary>
/// 教育商品- 咖啡
/// </summary>
[EnumField("教育咖啡劵")]
EduCoffee = 15,
/// <summary>
/// 教育商品- 资产
/// </summary>
[EnumField("教育资产商品")]
EduProperty = 16,
}
}
......@@ -97,5 +97,15 @@ namespace Property.Model.Entity
/// </summary>
public int Type { get; set; }
/// <summary>
/// 电商关联订单ID
/// </summary>
public int MallOrderId { get; set; }
/// <summary>
/// 电商关联凭证
/// </summary>
public string MallRelevance { get; set; }
}
}
\ No newline at end of file
......@@ -168,6 +168,11 @@ namespace Property.Module.FixedAssets
/// 流程
/// </summary>
private readonly RB_Property_AuditRelevanceRepository auditRelevanceRepository = new RB_Property_AuditRelevanceRepository();
/// <summary>
/// 电商商品
/// </summary>
private readonly RB_Goods_OrderDetailRepository goods_OrderDetailRepository = new RB_Goods_OrderDetailRepository();
//流程模板
......@@ -6005,7 +6010,8 @@ namespace Property.Module.FixedAssets
RB_CreateByName = userInfo.emName,
RB_DepartName = userInfo.DepartName,
RB_BranchName = schoolRepository.GetEntity(SchoolId)?.SName ?? "",
RB_GroupName = userInfo.GroupName
RB_GroupName = userInfo.GroupName,
ECOrderList = oldModel.MallOrderId > 0 ? JsonHelper.DeserializeObject<List<object>>(oldModel.MallRelevance) : new List<object>()
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
......@@ -6029,7 +6035,7 @@ namespace Property.Module.FixedAssets
#endregion
#region 更新申请单
bool UpdateGoodsCost = false;
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Supplies_StockOutApplyFor_Extend.FinanceIds),JsonConvert.SerializeObject(FinanceIdList)},
{ nameof(RB_Supplies_StockOutApplyFor_Extend.Remark),FinanceRematk},
......@@ -6041,6 +6047,7 @@ namespace Property.Module.FixedAssets
else
{
keyValues1.Add(nameof(RB_Supplies_StockOutApplyFor_Extend.StockOutStatus), 3);
UpdateGoodsCost = true;
}
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
......@@ -6053,6 +6060,33 @@ namespace Property.Module.FixedAssets
#endregion
supplies_StockOutApplyForRepository.DBSession.Commit();
if (UpdateGoodsCost && oldModel.MallOrderId > 0) {
//更新 电商订单成本
try
{
var stockOutList = supplies_StockOutRepository.GetList(new RB_Supplies_StockOut_Extend() { RB_Group_Id = oldModel.RB_Group_Id, ApplyForId = oldModel.Id });
if (stockOutList.Any()) {
string soIds = string.Join(",", stockOutList.Select(x => x.Id));
var sdetailList = supplies_StockOutDetailRepository.GetList(new RB_Supplies_StockOutDetail_Extend() { RB_Group_Id = oldModel.RB_Group_Id, StockOutIdStr = soIds });
decimal TCostMoney = sdetailList.Sum(x => x.Money ?? 0);//平均算法下的 总金额
//设置 电商商品的成本金额 (有了成本金额之后 无法再取消)
goods_OrderDetailRepository.UpdateEduGoodsCostMoney(TCostMoney, oldModel.MallOrderId);
//设置 教育关联订单 成本金额 (后续统计使用)
finance_ConfigRepository.UpdateEduGoodsCostMoney(TCostMoney, oldModel.MallOrderId);
foreach (var qtem in list) {
//单商品的总成本价格
decimal costMoney = sdetailList.Where(x => x.SuppliesId == qtem.SuppliesId).Sum(x => x.Money ?? 0);
goods_OrderDetailRepository.UpdateEduGoodsDetailCostMoney(costMoney, oldModel.MallOrderId, qtem.SuppliesId);
finance_ConfigRepository.UpdateEduGoodsDetailCostMoney(costMoney, oldModel.MallOrderId, qtem.SuppliesId);
}
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "UpdateGoodsCost");
}
}
return "";
}
catch (Exception ex)
......
......@@ -57,5 +57,28 @@ namespace Property.Repository.Mall
string sql = $@"SELECT a.*,b.`Name` as SupplierName FROM rb_goods_orderdetail as a LEFT JOIN rb_supplier as b on a.SupplierId=b.ID where {where} order by a.Id asc";
return Get<RB_Goods_OrderDetail>(sql).ToList();
}
/// <summary>
/// 更新电商订单成本 (根据出库商品金额)
/// </summary>
/// <param name="costMoney"></param>
/// <param name="mallOrderId"></param>
public void UpdateEduGoodsCostMoney(decimal costMoney, int mallOrderId)
{
string sql = $@"update rb_goods_order set CostMoney ={costMoney} where OrderId ={mallOrderId}";
Execute(sql);
}
/// <summary>
/// 更新电商订单商品成本 (根据出库商品金额)
/// </summary>
/// <param name="costMoney"></param>
/// <param name="mallOrderId"></param>
/// <param name="suppliesId"></param>
public void UpdateEduGoodsDetailCostMoney(decimal costMoney, int mallOrderId, int suppliesId)
{
string sql = $@"update rb_goods_orderdetail set CostMoney ={costMoney} where OrderId ={mallOrderId} and MaterialId ={suppliesId}";
Execute(sql);
}
}
}
......@@ -90,8 +90,12 @@ left join rb_supplies_material sm on ssd.SuppliesId=sm.Id
{
where += " and ss." + nameof(RB_Supplies_StockOut_Extend.EmployeeId) + "=" + dmodel.EmployeeId;
}
if (dmodel.ApplyForId > 0)
{
where += " and ss." + nameof(RB_Supplies_StockOut_Extend.ApplyForId) + "=" + dmodel.ApplyForId;
}
string sql = $@" select distinct ss.*,sw.Name as WareHouseName from RB_Supplies_StockOut ss
string sql = $@" select ss.* from RB_Supplies_StockOut ss
{where} order by ss.Id desc";
return Get<RB_Supplies_StockOut_Extend>(sql).ToList();
}
......
......@@ -2,6 +2,7 @@
using Property.Model.Entity;
using Property.Model.Extend;
using REBORN.Common.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -34,5 +35,28 @@ namespace Property.Repository
string sql = $@" select * from RB_Finance_Config where {where} order by Id desc";
return Get<RB_Finance_Config_ViewModel>(sql).ToList();
}
/// <summary>
/// 更新教育商品统计表 成本价格
/// </summary>
/// <param name="costMoney"></param>
/// <param name="mallOrderId"></param>
public void UpdateEduGoodsCostMoney(decimal costMoney, int mallOrderId)
{
string sql = $@"update rb_goods_order set CostMoney ={costMoney} where MallOrderId ={mallOrderId}";
Execute(sql);
}
/// <summary>
/// 更新教育商品统计表 订单明细成本价格
/// </summary>
/// <param name="costMoney"></param>
/// <param name="mallOrderId"></param>
/// <param name="suppliesId"></param>
public void UpdateEduGoodsDetailCostMoney(decimal costMoney, int mallOrderId, int suppliesId)
{
string sql = $@"update rb_goods_orderdetail set CostMoney ={costMoney} where MallOrderId ={mallOrderId} and MaterialId ={suppliesId}";
Execute(sql);
}
}
}
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