Commit 6baf161f authored by liudong1993's avatar liudong1993

生成财务单据绑订单

parent e552afaf
......@@ -14,6 +14,14 @@ namespace Mall.Model.Extend.Product
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Order_Extend : RB_Goods_Order
{
/// <summary>
/// 公司id
/// </summary>
public int CompanyId { get; set; }
/// <summary>
/// 公司返佣比例
/// </summary>
public decimal CompanyProfitRate { get; set; }
/// <summary>
/// 订单ids
/// </summary>
......
......@@ -28,7 +28,9 @@ namespace Mall.Model.Extend.User
/// </summary>
public List<RB_VipBuy_Commission_Extend> CommissionList { get; set; }
/// <summary>
/// ids
/// </summary>
public string VipBuyIds { get; set; }
}
}
......@@ -3528,6 +3528,16 @@ namespace Mall.Module.Product
int OrderId = goods_OrderRepository.Insert(demodel, trans);
if (OrderId > 0)
{
#region 公司比例
demodel.CompanyProfitRate = 0;
demodel.CompanyId = 0;
var pUserId = member_UserRepository.GetMemberFristParentren(demodel.UserId ?? 0);
if (pUserId > 0) {
var pumodel = member_UserRepository.GetEntity(pUserId);
demodel.CompanyProfitRate = pumodel.CompanyProfitRate;
demodel.CompanyId = pUserId;
}
#endregion
//插入订单明细+ 商品库存更新
InsertOrderDetail(demodel, trans, OrderId, SatisfiedGoodsList);
......@@ -5075,7 +5085,9 @@ namespace Mall.Module.Product
PayMoney = 0,
YFMoney = 0,
RealMoney = 0,
YSMoney = 0
YSMoney = 0,
CompanyId = demodel.CompanyId,
CompanyProfitRate = demodel.CompanyProfitRate
}, trans);
item.Id = detailId;
if (detailId > 0 && SatisfiedGoodsList.Any())
......@@ -5985,6 +5997,7 @@ namespace Mall.Module.Product
item.IsPublic = isPublic;
List<int> FinanceIds = new List<int>();//返回的财务单号
var detailList = new List<object>();
List<object> ECList = new List<object>();
foreach (var qitem in list)
{
var orderModel = OrderList.Where(x => x.OrderId == qitem.OrderId).FirstOrDefault();
......@@ -5997,6 +6010,11 @@ namespace Mall.Module.Product
UnitPrice = dMoney,
Remark = qitem.GoodsName + " " + qitem.Specification + " " + (orderModel?.OrderNo??"")
});
ECList.Add(new
{
ECOrderId = qitem.OrderId,
ECOrderDetailId = qitem.Id
});
}
foreach (var aitem in accountIdList) {
var financeObj = new
......@@ -6015,7 +6033,8 @@ namespace Mall.Module.Product
ReFinanceId = 0,
Remark = DateTime.Now.ToString("yyyy年MM月dd日") + "自动生成财务单据(主播订单佣金) 直播日期:"+ LiveTime,
detailList,
RB_Depart_Id = Config.ExpendDepartment
RB_Depart_Id = Config.ExpendDepartment,
ECOrderList = ECList
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
......
......@@ -152,6 +152,10 @@ namespace Mall.Module.User
/// vip购买返佣
/// </summary>
private RB_VipBuy_CommissionRepository vipBuy_CommissionRepository = new RB_VipBuy_CommissionRepository();
/// <summary>
/// vip购买
/// </summary>
private RB_Vip_BuyRepository vip_BuyRepository = new RB_Vip_BuyRepository();
/// <summary>
/// 粉象返佣金额
......@@ -2396,6 +2400,33 @@ namespace Mall.Module.User
}
};
item.IsPublic = 5;//默认平台虚拟账户
#region 查询所有的订单
List<Model.Entity.Finance.RB_ECFinanceId_Relation> ECList = new List<Model.Entity.Finance.RB_ECFinanceId_Relation>();
if (!string.IsNullOrEmpty(remitModel.ReOrderIds) || !string.IsNullOrEmpty(remitModel.ReVipIds))
{
List<int> reorderIdList = JsonConvert.DeserializeObject<List<int>>(remitModel.ReOrderIds);
List<int> revipIdList = JsonConvert.DeserializeObject<List<int>>(remitModel.ReVipIds);
if (revipIdList.Any()) {
var vipbuycList = vipBuy_CommissionRepository.GetList(new RB_VipBuy_Commission_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, VipIds = string.Join(",", revipIdList) });
//获取订单列表
if (vipbuycList.Where(x => x.ReOrderId > 0).Any())
{
reorderIdList.AddRange(vipbuycList.Where(x => x.ReOrderId > 0).Select(x => x.ReOrderId ?? 0).ToList());
}
}
if (reorderIdList.Any()) {
reorderIdList = reorderIdList.Distinct().ToList();
var orderDetailList = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, OrderIds = string.Join(",", reorderIdList) });
foreach (var qitem in orderDetailList) {
ECList.Add(new Model.Entity.Finance.RB_ECFinanceId_Relation()
{
ECOrderId = qitem.OrderId,
ECOrderDetailId = qitem.Id
});
}
}
}
#endregion
var financeObj = new
{
CreateBy = erpEmpId > 0 ? erpEmpId.ToString() : Config.ExpendDirector,
......@@ -2412,7 +2443,8 @@ namespace Mall.Module.User
ReFinanceId = remitId,
Remark = "名称:" + umodel.Name + "(" + umodel.Id + ")" + " 姓名:" + DisModel.Name + " 手机:" + DisModel.Mobile + " " + System.DateTime.Now.ToString("yyyy年MM月dd日") + "自动生成财务单据",
detailList,
RB_Depart_Id = Config.ExpendDepartment
RB_Depart_Id = Config.ExpendDepartment,
ECOrderList = ECList
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
......@@ -2503,6 +2535,16 @@ namespace Mall.Module.User
});
}
item.IsPublic = 5;//默认平台虚拟账户
#region 查询所有的订单
List<Model.Entity.Finance.RB_ECFinanceId_Relation> ECList = new List<Model.Entity.Finance.RB_ECFinanceId_Relation>();
foreach (var qitem in list) {
ECList.Add(new Model.Entity.Finance.RB_ECFinanceId_Relation()
{
ECOrderId = qitem.OrderId,
ECOrderDetailId = qitem.OrderDetailId
});
}
#endregion
var financeObj = new
{
CreateBy = Config.ExpendDirector,
......@@ -2519,7 +2561,8 @@ namespace Mall.Module.User
ReFinanceId = BillId,
Remark = "名称:" + umodel.Name + "(" + umodel.Id + ")" + " 姓名:" + DisModel.Name + " 手机:" + DisModel.Mobile + " " + System.DateTime.Now.ToString("yyyy年MM月dd日") + "自动生成财务单据(推荐供应商返佣)",
detailList,
RB_Depart_Id = Config.ExpendDepartment
RB_Depart_Id = Config.ExpendDepartment,
ECOrderList = ECList
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
......
......@@ -833,5 +833,26 @@ LEFT JOIN (SELECT SuperiorId,COUNT(SuperiorId) as ChildrenNum from rb_member_use
}
#endregion
#region 获取最上级用户
/// <summary>
/// 获取最上级用户
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public int GetMemberFristParentren(int id)
{
string sql = $@" select GetMemberFristParentren({id})";
var obj = ExecuteScalar(sql);
if (obj != null)
{
return Convert.ToInt32(obj.ToString());
}
else {
return 0;
}
}
#endregion
}
}
......@@ -306,6 +306,8 @@ namespace Mall.WebApi.Controllers.User
{
return ApiResult.Failed("供应商账户信息不存在");
}
List<object> ECList = new List<object>();//电商关联订单
foreach (var orderGoodsItem in list)
{
decimal OrderDetailPaid = (orderGoodsItem.PaidCostMoney ?? 0);
......@@ -375,7 +377,14 @@ namespace Mall.WebApi.Controllers.User
OrderDetailPaid = OrderDetailPaid,
};
record.RecordDetailList.Add(financeRecordDetail);
ECList.Add(new
{
ECOrderId = orderGoodsItem.OrderId,
ECOrderDetailId = orderGoodsItem.Id
});
}
ECList = ECList.Distinct().ToList();
var detailList = result.Select(x => new
{
CostTypeId = x.FinanceType == 1 ? financeConfigurineModel.CBCostTypeId : financeConfigurineModel.ExpensesCostTypeId,
......@@ -413,7 +422,8 @@ namespace Mall.WebApi.Controllers.User
OtherType = 13,
Remark = System.DateTime.Now.ToString("yyyy年MM月dd日") + "生成财务单据",
detailList,
RB_Depart_Id = Config.ExpendDepartment
RB_Depart_Id = Config.ExpendDepartment,
ECOrderList = ECList
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
......
......@@ -135,8 +135,6 @@ namespace Mall.WindowsService.Module
try
{
string str = financeConfigurineRepository.ConnectionStr;
Helper.LogHelper.Write("数据库连接:" + str);
//先查询规则
var financeConfigurineList = financeConfigurineRepository.GetList(new RB_Finance_Configurine_Extend { Type = 1 });
......@@ -181,7 +179,7 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
// b.OrderStatus IN (2, 3, 4, 5, 6) OR ( b.OrderStatus = 7 AND DATE_FORMAT(b.PaymentTime, '%y-%m-%d') >= DATE_FORMAT('{startDate}', '%y-%m-%d')
// AND DATE_FORMAT(b.PaymentTime, '%y-%m-%d') < DATE_FORMAT('{endDate}', '%y-%m-%d')))");
Helper.LogHelper.Write("sql语句:" + builder.ToString());
//Helper.LogHelper.Write("sql语句:" + builder.ToString());
var goodsDetailList = goodsOrderDetailRepository.Get<RB_Goods_OrderDetail_Extend>(builder.ToString()).ToList();
var result = new List<RB_Goods_OrderDetail_Extend>();
......@@ -206,7 +204,9 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
return false;
}
#region 查询所有的订单
List<RB_ECFinanceId_Relation> ECList = new List<RB_ECFinanceId_Relation>();
#endregion
foreach (var orderGoodsItem in goodsDetailList)
{
bool isAdd = true;
......@@ -272,6 +272,11 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
Number = orderGoodsItem.Number
};
record.RecordDetailList.Add(financeRecordDetail);
ECList.Add(new RB_ECFinanceId_Relation()
{
ECOrderId = orderGoodsItem.OrderId,
ECOrderDetailId = orderGoodsItem.Id
});
}
}
......@@ -314,7 +319,8 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
Remark = System.DateTime.Now.ToString("yyyy年MM月dd日") + "自动生成财务单据",
detailList,
OriginalFee,
RB_Depart_Id = Config.IncomeDepartment
RB_Depart_Id = Config.IncomeDepartment,
ECOrderList = ECList
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
......@@ -1551,6 +1557,20 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
decimal TotalMoney = 0;
var detailList = new List<object>();
#region 查询所有的订单
List<RB_ECFinanceId_Relation> ECList = new List<RB_ECFinanceId_Relation>();
if (oList.Any()) {
string orderids = string.Join(",", oList.Select(x => x.OrderId));
var dlist = goodsOrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderIds = orderids });
foreach (var qitem in dlist) {
ECList.Add(new RB_ECFinanceId_Relation()
{
ECOrderId = qitem.OrderId,
ECOrderDetailId = qitem.Id
});
}
}
#endregion
//订单退款
foreach (var omodel in oList)
{
......@@ -1594,7 +1614,7 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
//售后退款
foreach (var dmodel in afterList)
{
decimal Money = dmodel.Refund ?? 0;
decimal Money = dmodel.RefundActual ?? 0;
TotalMoney += Money;
//查询用户
var umodel = member_UserRepository.GetEntity(dmodel.UserId);
......@@ -1602,7 +1622,7 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
var omodel = goods_OrderRepository.GetEntity(dmodel.OrderId);
if (omodel == null) { return false; }
string dstr = "客人付款:" + (dmodel.Income ?? 0) + ",退款:" + (dmodel.Refund ?? 0);
string dstr = "客人付款:" + (dmodel.Income ?? 0) + ",退款:" + (dmodel.RefundActual ?? 0);
detailList.Add(
new
......@@ -1634,6 +1654,12 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
Number = 1
};
record.RecordDetailList.Add(financeRecordDetail);
ECList.Add(new RB_ECFinanceId_Relation()
{
ECOrderId = dmodel.OrderId,
ECOrderDetailId = dmodel.OrderDetialId
});
}
item.IsPublic = 8;//默认原路退款
......@@ -1655,7 +1681,8 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
ReFinanceId = 0,
Remark,
detailList,
RB_Depart_Id = Config.ExpendDepartment
RB_Depart_Id = Config.ExpendDepartment,
ECOrderList = ECList
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
......
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