Commit 06e0b0cc authored by 吴春's avatar 吴春

提交代码

parent eb10bb4b
...@@ -5,6 +5,7 @@ using Mall.Model.Extend.Finance; ...@@ -5,6 +5,7 @@ using Mall.Model.Extend.Finance;
using Mall.Model.Extend.Product; using Mall.Model.Extend.Product;
using Mall.Repository.Finance; using Mall.Repository.Finance;
using Mall.Repository.Product; using Mall.Repository.Product;
using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -32,6 +33,7 @@ namespace Mall.WindowsService.Module ...@@ -32,6 +33,7 @@ namespace Mall.WindowsService.Module
/// 订单详情 /// 订单详情
/// </summary> /// </summary>
private static RB_Goods_OrderDetailRepository goodsOrderDetailRepository = new RB_Goods_OrderDetailRepository(); private static RB_Goods_OrderDetailRepository goodsOrderDetailRepository = new RB_Goods_OrderDetailRepository();
#region 收入
/// <summary> /// <summary>
/// 订单收入单据 /// 订单收入单据
...@@ -60,7 +62,7 @@ namespace Mall.WindowsService.Module ...@@ -60,7 +62,7 @@ namespace Mall.WindowsService.Module
var recordModel = financeRecordRepository.GetList(new Model.Extend.Finance.RB_Finance_Record_Extend { TenantId = item.TenantId, MallBaseId = item.MallBaseId }).OrderByDescending(x => x.CreateDate).FirstOrDefault(); var recordModel = financeRecordRepository.GetList(new Model.Extend.Finance.RB_Finance_Record_Extend { TenantId = item.TenantId, MallBaseId = item.MallBaseId }).OrderByDescending(x => x.CreateDate).FirstOrDefault();
if (recordModel == null)//今天没生成单据 if (recordModel == null)//今天没生成单据
{ {
if (item.StartTime.Value.AddDays(item.IntervalDay ?? 0).ToString("yyyy-MM-dd").Equals(System.DateTime.Now.ToString("yyyy-MM-dd")))//判断开始时间加上执行周期是否等于当前日期 if (Convert.ToDateTime(item.StartTime.Value.AddDays(item.IntervalDay ?? 0).ToString("yyyy-MM-dd 00:00:00")) <= Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd 00:00:00")))//判断开始时间加上执行周期是否等于当前日期
{ {
startDate = item.StartTime.Value; startDate = item.StartTime.Value;
addFinance = true; addFinance = true;
...@@ -68,7 +70,7 @@ namespace Mall.WindowsService.Module ...@@ -68,7 +70,7 @@ namespace Mall.WindowsService.Module
} }
else else
{ {
if (recordModel.CreateDate.Value.AddDays(item.IntervalDay ?? 0).ToString("yyyy-MM-dd").Equals(System.DateTime.Now.ToString("yyyy-MM-dd")))//判断最近一次执行的时间加上执行周期是否等于当前日期 if (Convert.ToDateTime(recordModel.CreateDate.Value.AddDays(item.IntervalDay ?? 0).ToString("yyyy-MM-dd 00:00:00")) <= Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd 00:00:00")))//判断最近一次执行的时间加上执行周期是否等于当前日期
{ {
startDate = recordModel.CreateDate.Value; startDate = recordModel.CreateDate.Value;
addFinance = true; addFinance = true;
...@@ -91,7 +93,7 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an ...@@ -91,7 +93,7 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an
record.Type = 1; record.Type = 1;
record.CreateDate = System.DateTime.Now; record.CreateDate = System.DateTime.Now;
record.RecordDetailList = new List<RB_Finance_RecordDetail>(); record.RecordDetailList = new List<RB_Finance_RecordDetail>();
foreach (var orderGoodsItem in goodsDetailList.Take(2)) foreach (var orderGoodsItem in goodsDetailList)
{ {
if (orderGoodsItem.Final_Price > 0) if (orderGoodsItem.Final_Price > 0)
...@@ -100,6 +102,7 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an ...@@ -100,6 +102,7 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an
newOrderGoods = orderGoodsItem; newOrderGoods = orderGoodsItem;
newOrderGoods.FinanceType = 1; newOrderGoods.FinanceType = 1;
result.Add(newOrderGoods); result.Add(newOrderGoods);
} }
if (orderGoodsItem.FreightMoney.HasValue && orderGoodsItem.FreightMoney.Value > 0) if (orderGoodsItem.FreightMoney.HasValue && orderGoodsItem.FreightMoney.Value > 0)
{ {
...@@ -108,6 +111,27 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an ...@@ -108,6 +111,27 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an
newOrderGoods.FinanceType = 2; newOrderGoods.FinanceType = 2;
result.Add(newOrderGoods); 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 var detailList = result.Select(x => new
...@@ -121,9 +145,10 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an ...@@ -121,9 +145,10 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an
var financeObj = new var financeObj = new
{ {
CreateBy = Config.NetworkDirector, CreateBy = Config.NetworkDirector,
IsPublic = item.IsPublic, item.IsPublic,
BType = item.AccountType, BType = item.AccountType,
AccountId = item.AccountId, AccountId = item.AccountId,
WBMoney = result.Sum(x => x.Final_Price ?? 0),
RB_Branch_Id = Config.RB_Branch_Id, RB_Branch_Id = Config.RB_Branch_Id,
RemitterName = item.RemitterName, RemitterName = item.RemitterName,
TradeDate = System.DateTime.Now.ToString("yyyy-MM-dd"), TradeDate = System.DateTime.Now.ToString("yyyy-MM-dd"),
...@@ -137,17 +162,23 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an ...@@ -137,17 +162,23 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey); string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new var resultInfo = new
{ {
msg = financeObj, msg = sign,
MallBaseId = item.MallBaseId,
TenantId = item.TenantId,
EmpId = Config.NetworkDirector,
sign
}; };
//byte[] data = System.Text.ASCIIEncoding.ASCII.GetBytes(JsonHelper.Serialize(financeObj));
//EncryptionHelper.AESEncrypt(data, Config.FinanceKey, "12345678", System.Security.Cryptography.CipherMode.CBC,System.Security.Cryptography.PaddingMode.PKCS7);
string apiResult = Mall.Common.Plugin.HttpHelper.HttpPost(Config.IncomeFinanceApi, JsonHelper.Serialize(resultInfo), ""); string apiResult = Mall.Common.Plugin.HttpHelper.HttpPost(Config.IncomeFinanceApi, 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;
int recordId = financeRecordRepository.Insert(record);
LogHelper.Write("财务单据ID:" + recordId + "订单数量:" + record.RecordDetailList.Count());
record.RecordDetailList.ForEach(x => x.RecordId = recordId);
record.RecordDetailList.ForEach(x => x.FinanceId = frid);
flag = financeRecordDetailRepository.InsertBatch(record.RecordDetailList);
}
LogHelper.Write(apiResult); LogHelper.Write(apiResult);
} }
} }
...@@ -162,5 +193,13 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an ...@@ -162,5 +193,13 @@ and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') an
return flag; return flag;
} }
#endregion
#region 成本
#endregion
} }
} }
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"RebornDMC": "reborn_dmc", "RebornDMC": "reborn_dmc",
"IncomeFinanceApi": "http://192.168.2.16:8083/api/Mall/InsertFinanceBatchForMallIn", "IncomeFinanceApi": "http://192.168.2.16:8083/api/Mall/InsertFinanceBatchForMallIn",
//"FinanceKey": "FinanceMallInsertToERPViitto2020", //"FinanceKey": "FinanceMallInsertToERPViitto2020",
"FinanceKey": "FinanceMallInsertToERPVi", "FinanceKey": "FinanceMallInsertToERPViitto2020",
"RedisSetting": { "RedisSetting": {
"RedisServer": "192.168.2.214", "RedisServer": "192.168.2.214",
"RedisPort": "6379", "RedisPort": "6379",
......
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