Commit 2793a9df authored by 吴春's avatar 吴春

提交代码

parent c38f9893
......@@ -126,6 +126,9 @@ namespace Mall.Model.Extend.Product
/// 订单商品ids
/// </summary>
public List<int> IdList { get; set; }
public int IsPublic { get; set; }
#endregion
}
......
......@@ -6,9 +6,11 @@ using System.Text.RegularExpressions;
using Mall.Common;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Finance;
using Mall.Repository;
using Mall.Repository.Finance;
using Mall.Repository.Product;
using Newtonsoft.Json;
namespace Mall.Module.Finance
......@@ -43,8 +45,18 @@ namespace Mall.Module.Finance
/// </summary>
private readonly RB_CurrencyRepository currencyRepository = new RB_CurrencyRepository();
/// <summary>
/// 财务生成记录
/// </summary>
private static RB_Finance_RecordRepository financeRecordRepository = new RB_Finance_RecordRepository();
/// <summary>
/// 财务生成记录详情
/// </summary>
private static RB_Finance_RecordDetailRepository financeRecordDetailRepository = new RB_Finance_RecordDetailRepository();
/// <summary>
/// 订单明细
/// </summary>
private readonly RB_Goods_OrderDetailRepository goods_OrderDetailRepository = new RB_Goods_OrderDetailRepository();
/// <summary>
/// 获取列表
/// </summary>
......@@ -221,5 +233,56 @@ namespace Mall.Module.Finance
}
#region 财务记录
public bool SetFinanceRecord(RB_Finance_Record_Extend model)
{
bool flag = false;
var trans = financeRecordRepository.DbTransaction;
try
{
int recordId = 0;
if (model.ID == 0)
{
recordId = financeRecordRepository.Insert(model, trans);
flag = recordId > 0;
if (model.RecordDetailList != null && model.RecordDetailList.Any())
{
model.RecordDetailList.ForEach(x => x.RecordId = recordId);
model.RecordDetailList.ForEach(x => x.FinanceId = model.FinanceId);
financeRecordDetailRepository.InsertBatch(model.RecordDetailList, trans);
}
if (flag)//更新订单商品的财务单据
{
foreach (var item in model.RecordDetailList)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Goods_OrderDetail.CostFinanceId),model.FinanceId}
};
List<WhereHelper> whereHelpers = new List<WhereHelper>() { new WhereHelper()
{
FiledName=nameof(RB_Finance_Configurine_Extend.Id),
FiledValue=item.OrderDetailId,
OperatorEnum=OperatorEnum.Equal
}
};
goods_OrderDetailRepository.Update(keyValues, whereHelpers, trans);
}
}
}
financeRecordRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetFinanceRecord");
financeRecordRepository.DBSession.Rollback("SetFinanceRecord");
return false;
}
return flag;
}
#endregion
}
}
......@@ -48,7 +48,10 @@ namespace Mall.Repository.User
{
where += $@" and {nameof(RB_Member_Balance.UserId)}={dmodel.UserId}";
}
if (dmodel.CreateDate.HasValue)
{
where += $@" and date_format( {nameof(RB_Member_Balance.CreateDate)}, '%Y-%m' ) =date_format( '{dmodel.CreateDate.Value}', '%Y-%m' ) ";
}
string sql = $@"select * from RB_Member_Balance where {where} order by Id desc";
return GetPage<RB_Member_Balance_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
......
......@@ -30,7 +30,6 @@ namespace Mall.WebApi.Controllers.User
private readonly UserModule userModule = new UserModule();
private readonly Module.MarketingCenter.CouponModule couponModule = new Module.MarketingCenter.CouponModule();
#region 收货地址
/// <summary>
......@@ -902,5 +901,34 @@ namespace Mall.WebApi.Controllers.User
return ApiResult.Success("", pagelist);
}
#endregion
#region 余额明细
/// <summary>
/// 个人中心- 积分明细
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetMemberBalancePageList()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_Member_Balance_Extend demodel = JsonConvert.DeserializeObject<RB_Member_Balance_Extend>(req.msg.ToString());
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
var list = userModule.GetMemberBalancePageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Remarks,
x.Description,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
x.Balance,
x.Type
});
return ApiResult.Success("", pagelist);
}
#endregion
}
}
\ No newline at end of file
......@@ -247,13 +247,9 @@ namespace Mall.WebApi.Controllers.User
RB_Goods_OrderDetail_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_OrderDetail_Extend>(RequestParm.msg.ToString());
demodel.TenantId = UserInfo.TenantId;
demodel.MallBaseId = parms.MallBaseId;
demodel.IsFinance = 2;
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;
......@@ -264,10 +260,21 @@ namespace Mall.WebApi.Controllers.User
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();
var financeConfigurineModel = financeModule.GetFinanceConfigurineList(new Model.Extend.Finance.RB_Finance_Configurine_Extend { Type = 2, MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId }).FirstOrDefault();
//查询供应商的财务信息
var supplierModel = supplierModule.GetList(new RB_Supplier_Extend { MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId, ID = demodel.SupplierId }).FirstOrDefault();
if (supplierModel == null)
{
return ApiResult.Failed("供应商信息不存在");
}
if (supplierModel.ClientBankAccount == null)
{
return ApiResult.Failed("供应商账户信息不存在");
}
foreach (var orderGoodsItem in list)
{
if (orderGoodsItem.Final_Price > 0)
if (orderGoodsItem.CostMoney > 0)
{
var newOrderGoods = new RB_Goods_OrderDetail_Extend();
newOrderGoods = orderGoodsItem;
......@@ -275,7 +282,7 @@ namespace Mall.WebApi.Controllers.User
result.Add(newOrderGoods);
}
if (orderGoodsItem.FreightMoney.HasValue && orderGoodsItem.FreightMoney.Value > 0)
if (orderGoodsItem.FreightCostMoney.HasValue && orderGoodsItem.FreightCostMoney.Value > 0)
{
var newOrderGoods = new RB_Goods_OrderDetail_Extend();
newOrderGoods = orderGoodsItem;
......@@ -295,22 +302,61 @@ namespace Mall.WebApi.Controllers.User
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,
GoodsPrice = ((orderGoodsItem.CostMoney ?? 0) * (orderGoodsItem.Number ?? 0)),
FreightMoney = orderGoodsItem.FreightCostMoney,
Unit_Price = orderGoodsItem.CostMoney,
Number = orderGoodsItem.Number
};
record.RecordDetailList.Add(financeRecordDetail);
}
var detailList = result.Select(x => new
{
CostTypeId = x.FinanceType == 1 ? financeConfigurineModel.CBCostTypeId : financeConfigurineModel.FreightCostTypeId,
CostTypeId = x.FinanceType == 1 ? financeConfigurineModel.CBCostTypeId : financeConfigurineModel.ExpensesCostTypeId,
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,
OriginalMoney = x.FinanceType == 1 ? x.CostMoney : x.FreightCostMoney,
UnitPrice = x.FinanceType == 1 ? ((x.CostMoney ?? 0)) : x.FreightCostMoney,
Remark = x.GoodsName + x.OrderNo
});
var financeObj = new
{
CreateBy = Config.NetworkDirector,
IsPublic = demodel.IsPublic,// supplierModel.ClientBankAccount.AccountType, //financeConfigurineModel.AccountType,
ClientType = supplierModel.ClientBankAccount.Type,
ClientID = supplierModel.BankAccountId,
CurrencyId = financeConfigurineModel.CurrencyId,
WBMoney = result.Sum(x => ((x.CostMoney ?? 0) * (x.Number ?? 0)) + (x.FreightCostMoney ?? 0)),
RB_Branch_Id = Config.RB_Branch_Id,
PayDate = System.DateTime.Now.ToString("yyyy-MM-dd"),
TemplateId = financeConfigurineModel.WorkFlowId,
OrderSource = 16,
OtherType = 13,
Remark = System.DateTime.Now.ToString("yyyy年MM月dd日") + "生成财务单据",
detailList,
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
{
msg = sign,
};
string apiResult = Mall.Common.Plugin.HttpHelper.HttpPost(Config.PaymentFinanceApi, JsonHelper.Serialize(resultInfo), "");
JObject parmsJob = JObject.Parse(apiResult);
string resultCode = parmsJob.GetStringValue("resultCode");
int frid = parmsJob.GetInt("data", 0);
if (resultCode == "1" && frid > 0)//新增记录
{
record.FinanceId = frid;
bool addResult = financeModule.SetFinanceRecord(record);
if (addResult)
{
return ApiResult.Success("财务单据生成成功");
}
else
{
return ApiResult.Failed("财务单据生成失败");
}
}
}
return ApiResult.Success("");
......
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