Commit a17caffb authored by 吴春's avatar 吴春

提交自动生成收入财务单据

parent dd0cb945
......@@ -375,5 +375,28 @@ namespace Mall.Common
}
}
/// <summary>
/// 生成收入财务单据
/// </summary>
public static string IncomeFinanceApi
{
get
{
return new ConfigurationBuilder().Add(new JsonConfigurationSource { Path = "appsettings.json" }).Build().GetSection("IncomeFinanceApi").Value;
}
}
/// <summary>
/// 财务单据请求参数Key
/// </summary>
public static string FinanceKey
{
get
{
return new ConfigurationBuilder().Add(new JsonConfigurationSource { Path = "appsettings.json" }).Build().GetSection("FinanceKey").Value;
}
}
}
}
\ No newline at end of file
......@@ -229,6 +229,37 @@ namespace Mall.Common
#endregion
#region AES加密算法
/// <summary>
/// AES 加密
/// </summary>
/// <param name="str">明文(待加密)</param>
/// <param name="key">密文</param>
/// <returns></returns>
public static string AesEncrypt(string str, string key)
{
if (string.IsNullOrEmpty(str)) return null;
Byte[] toEncryptArray = Encoding.UTF8.GetBytes(str);
RijndaelManaged rm = new RijndaelManaged
{
Key = Encoding.UTF8.GetBytes(key),
Mode = CipherMode.ECB,
Padding = PaddingMode.PKCS7
};
ICryptoTransform cTransform = rm.CreateEncryptor();
Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}
/// <summary>
/// AES加密
/// </summary>
......@@ -283,7 +314,8 @@ namespace Mall.Common
encrypt = mStream.ToArray();
}
}
catch { }
catch (Exception ex)
{ }
aes.Clear();
return encrypt;
......
......@@ -28,7 +28,7 @@ namespace Mall.Common.Plugin
public static byte[] EncryptData(byte[] data)
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024);
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
//将公钥导入到RSA对象中,准备加密;
rsa.FromXmlString(TargetPublicKey);
......
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Finance
{
/// <summary>
/// 财务生成记录表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Finance_Record
{
/// <summary>
/// 编号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 类型 1收款 2成本 3退款 4打款
/// </summary>
public int? Type
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// 财务id
/// </summary>
public int FinanceId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Finance
{
/// <summary>
/// 财务生成记录详情表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Finance_RecordDetail
{
/// <summary>
/// 编号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 记录表ID
/// </summary>
public int RecordId { get; set; }
/// <summary>
/// 类型 1收款 2成本 3退款 4打款
/// </summary>
public int? Type
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// 财务id
/// </summary>
public int FinanceId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// 商品名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 订单id
/// </summary>
public int OrderId { get; set; }
/// <summary>
/// 订单详情id
/// </summary>
public int OrderDetailId { get; set; }
/// <summary>
/// 商品价格
/// </summary>
public decimal GoodsPrice { get; set; }
/// <summary>
/// 运费
/// </summary>
public decimal? FreightMoney { get; set; }
/// <summary>
/// 单价
/// </summary>
public decimal? Unit_Price
{
get;
set;
}
/// <summary>
/// 数量
/// </summary>
public int? Number
{
get;
set;
}
}
}
using Mall.Common.AOP;
using Mall.Model.Entity.Finance;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Extend.Finance
{
/// <summary>
/// 财务生成记录表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Finance_Record_Extend : RB_Finance_Record
{
/// <summary>
/// 详情
/// </summary>
public List<RB_Finance_RecordDetail> RecordDetailList { get; set; }
}
}
......@@ -97,5 +97,18 @@ namespace Mall.Model.Extend.Product
set;
}
#region 自动生成收入单据新增字段
/// <summary>
/// 订单号
/// </summary>
public string OrderNo { get; set; }
/// <summary>
/// 1-商品,2-运费
/// </summary>
public int FinanceType { get; set; }
#endregion
}
}
......@@ -70,7 +70,7 @@ namespace Mall.Module.User
{
bool flag = false;
var trans = supplierRepository.DbTransaction;
// var trans = supplierRepository.DbTransaction;
try
{
......@@ -79,8 +79,9 @@ namespace Mall.Module.User
if (model.ClientBankAccount.ID == 0)
{
model.Status = (int)Common.Enum.DateStateEnum.Normal;
var id = clientBankAccountRepository.Insert(model.ClientBankAccount, trans);
var id = clientBankAccountRepository.Insert(model.ClientBankAccount);
model.BankAccountId = id;
flag = id > 0;
}
else
{
......@@ -99,38 +100,44 @@ namespace Mall.Module.User
{
new WhereHelper (){ FiledName=nameof(RB_ClientBankAccount.ID),FiledValue=model.BankAccountId,OperatorEnum=OperatorEnum.Equal}
};
flag = clientBankAccountRepository.Update(fileds, whereHelpers, trans);
flag = clientBankAccountRepository.Update(fileds, whereHelpers);
}
IDictionary<string, object> filedsSupplier = new Dictionary<string, object>()
{
{ nameof(RB_Supplier.BankAccountId),model.BankAccountId},
{ nameof(RB_Supplier.Name),model.Name},
{ nameof(RB_Supplier.Mobile),model.Mobile},
{ nameof(RB_Supplier.Address),model.Address},
{ nameof(RB_Supplier.UpdateDate),model.UpdateDate}
};
IList<WhereHelper> whereHelpersSupplier = new List<WhereHelper>()
if (flag)
{
new WhereHelper (){ FiledName=nameof(RB_Supplier.ID),FiledValue=model.ID,OperatorEnum=OperatorEnum.Equal}
};
flag = supplierRepository.Update(filedsSupplier, whereHelpersSupplier, trans);
IDictionary<string, object> filedsSupplier = new Dictionary<string, object>()
{
{ nameof(RB_Supplier.BankAccountId),model.BankAccountId},
{ nameof(RB_Supplier.Name),model.Name},
{ nameof(RB_Supplier.Mobile),model.Mobile},
{ nameof(RB_Supplier.Address),model.Address},
{ nameof(RB_Supplier.UpdateDate),model.UpdateDate}
};
IList<WhereHelper> whereHelpersSupplier = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_Supplier.ID),FiledValue=model.ID,OperatorEnum=OperatorEnum.Equal}
};
flag = supplierRepository.Update(filedsSupplier, whereHelpersSupplier);
}
}
else
{
model.Status = (int)Common.Enum.DateStateEnum.Normal;
var id = clientBankAccountRepository.Insert(model.ClientBankAccount, trans);
var id = clientBankAccountRepository.Insert(model.ClientBankAccount);
model.BankAccountId = id;
if (id > 0)
{
model.BankAccountId = id;
flag = supplierRepository.Insert(model, trans) > 0;
flag = supplierRepository.Insert(model) > 0;
}
}
supplierRepository.DBSession.Commit();
// supplierRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "AddOrUpdateSupplier");
supplierRepository.DBSession.Rollback("AddOrUpdateSupplier");
// supplierRepository.DBSession.Rollback("AddOrUpdateSupplier");
return false;
}
return flag;
......@@ -143,10 +150,9 @@ namespace Mall.Module.User
/// <param name="ID"></param>
/// <param name="EmployeeId"></param>
/// <returns></returns>
public bool RemoveSupplier(int ID, int BankAccountId)
public bool RemoveSupplier(int ID, int BankAccountId)
{
bool flag = false;
var trans = supplierRepository.DbTransaction;
try
{
IDictionary<string, object> fileds = new Dictionary<string, object>()
......@@ -157,23 +163,24 @@ namespace Mall.Module.User
{
new WhereHelper (){ FiledName=nameof(RB_ClientBankAccount.ID),FiledValue=BankAccountId,OperatorEnum=OperatorEnum.Equal}
};
flag = clientBankAccountRepository.Update(fileds, whereHelpers, trans);
flag = clientBankAccountRepository.Update(fileds, whereHelpers);
IDictionary<string, object> filedsSupplier = new Dictionary<string, object>()
if (flag)
{
{ nameof(RB_ClientBankAccount.Status),(int) Common.Enum.DateStateEnum.Delete}
IDictionary<string, object> filedsSupplier = new Dictionary<string, object>()
{
{ nameof(RB_Supplier.Status),(int) Common.Enum.DateStateEnum.Delete}
};
IList<WhereHelper> whereHelpersSupplier = new List<WhereHelper>()
IList<WhereHelper> whereHelpersSupplier = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_ClientBankAccount.ID),FiledValue=BankAccountId,OperatorEnum=OperatorEnum.Equal}
new WhereHelper (){ FiledName=nameof(RB_Supplier.ID),FiledValue=ID,OperatorEnum=OperatorEnum.Equal}
};
flag = supplierRepository.Update(filedsSupplier, whereHelpersSupplier, trans);
supplierRepository.DBSession.Commit();
flag = supplierRepository.Update(filedsSupplier, whereHelpersSupplier);
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "RemoveSupplier");
supplierRepository.DBSession.Rollback("RemoveSupplier");
return false;
}
return flag;
......
......@@ -58,7 +58,7 @@ namespace Mall.Repository.Finance
{
where += string.Format(" AND a." + nameof(RB_ClientBankAccount_Extend.AccountHolder) + " like '%{0}%' ", model.AccountHolder);
}
string sql = $@"select a.*,b.name as BankName from {TableName} as a {TableName}";
string sql = $@"select a.* from {TableName} as a {TableName}";
return GetPage<RB_ClientBankAccount_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
......@@ -108,7 +108,7 @@ namespace Mall.Repository.Finance
{
where += string.Format(" AND a." + nameof(RB_ClientBankAccount.CardNum) + " like '%{0}%' ", model.CardNum);
}
string sql = $@"select a.*,b.name as BankName from {TableName} as a {TableName}";
string sql = $@"select a.* from {TableName} as a {where}";
return Get<RB_ClientBankAccount>(sql).ToList();
}
......@@ -157,7 +157,7 @@ namespace Mall.Repository.Finance
{
where += string.Format(" AND a." + nameof(RB_ClientBankAccount.CardNum) + " like '%{0}%' ", model.CardNum);
}
string sql = $@"select a.*,b.name as BankName from {TableName} as a {TableName}";
string sql = $@"select a.* from {TableName} as a {TableName}";
return Get<RB_ClientBankAccount>(sql).ToList();
}
......
using Mall.Model.Entity.Finance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Finance
{
public class RB_Finance_RecordDetailRepository:RepositoryBase<RB_Finance_RecordDetail>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Finance_RecordDetail); } }
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Finance_RecordDetail> GetList(RB_Finance_RecordDetail dmodel)
{
string where = $" where 1=1 ";
if (dmodel.TenantId > 0)
{
where += $@" and {nameof(RB_Finance_Record.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and {nameof(RB_Finance_Record.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Type > 0)
{
where += $@" and {nameof(RB_Finance_Record.Type)}={dmodel.Type}";
}
string sql = $@"SELECT * FROM {TableName} {where} order by Id asc";
return Get<RB_Finance_RecordDetail>(sql).ToList();
}
}
}
using Mall.Model.Entity.Finance;
using Mall.Model.Extend.Finance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Finance
{
public class RB_Finance_RecordRepository : RepositoryBase<RB_Finance_Record>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Finance_Record); } }
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Finance_Record_Extend> GetList(RB_Finance_Record_Extend dmodel)
{
string where = $" where 1=1 ";
if (dmodel.TenantId > 0)
{
where += $@" and {nameof(RB_Finance_Record.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and {nameof(RB_Finance_Record.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Type > 0)
{
where += $@" and {nameof(RB_Finance_Record.Type)}={dmodel.Type}";
}
string sql = $@"SELECT * FROM {TableName} {where} order by Id asc";
return Get<RB_Finance_Record_Extend>(sql).ToList();
}
}
}
......@@ -24,7 +24,7 @@ namespace Mall.Repository.User
/// <returns></returns>
public List<RB_Supplier_Extend> GetPageList(int pageIndex, int pageSize, out long rowCount, RB_Supplier_Extend dmodel)
{
string where = " 1=1 ";
string where = " 1=1 AND Status=0 ";
if (dmodel.TenantId > 0)
{
where += $@" and {nameof(RB_Supplier.TenantId)}={dmodel.TenantId}";
......@@ -33,6 +33,10 @@ namespace Mall.Repository.User
{
where += $@" and {nameof(RB_Supplier.MallBaseId)}={dmodel.MallBaseId}";
}
if (!string.IsNullOrWhiteSpace(dmodel.Name))
{
where += $@" and {nameof(RB_Supplier.Name)} like '%{dmodel.Name}%'";
}
string sql = $@"select * from {TableName} where {where} order by Id desc";
return GetPage<RB_Supplier_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
......@@ -44,7 +48,7 @@ namespace Mall.Repository.User
/// <returns></returns>
public List<RB_Supplier_Extend> GetList(RB_Supplier_Extend dmodel)
{
string where = " 1=1 ";
string where = " 1=1 AND Status=0 ";
if (dmodel.TenantId > 0)
{
where += $@" and a.{nameof(RB_Supplier.TenantId)}={dmodel.TenantId}";
......@@ -57,7 +61,7 @@ namespace Mall.Repository.User
{
where += $@" and a.{nameof(RB_Supplier.ID)}={dmodel.ID}";
}
string sql = $@"select * from {TableName} where {where} order by Id desc";
string sql = $@"select * from {TableName} as A where {where} order by Id desc";
return Get<RB_Supplier_Extend>(sql).ToList();
}
}
......
......@@ -36,15 +36,17 @@ namespace Mall.WebApi.Controllers.User
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.ID,
x.CreateDate,
x.Name,
x.Mobile,
x.Address,
x.ClientBankAccount?.CardNum,
x.ClientBankAccount?.OpenBankName,
x.ClientBankAccount?.AccountAlias,
x.ClientBankAccount?.AccountHolder,
AccountClassifyStr = x.ClientBankAccount?.AccountClassify == 2 ? "银行" : (x.ClientBankAccount?.AccountClassify == 3 ? "虚拟账户" : (x.ClientBankAccount?.AccountClassify == 4 ? "微信支付宝" : "")),
CardNum = x.ClientBankAccount != null ? x.ClientBankAccount.CardNum : "",
OpenBankName = x.ClientBankAccount != null ? x.ClientBankAccount.OpenBankName : "",
AccountAlias = x.ClientBankAccount != null ? x.ClientBankAccount.AccountAlias : "",
AccountHolder = x.ClientBankAccount != null ? x.ClientBankAccount.AccountHolder : "",
BackId = x.ClientBankAccount != null ? x.ClientBankAccount.ID : 0,
AccountClassifyStr = x.ClientBankAccount != null ? (x.ClientBankAccount?.AccountClassify == 2 ? "银行" : (x.ClientBankAccount?.AccountClassify == 3 ? "虚拟账户" : (x.ClientBankAccount?.AccountClassify == 4 ? "微信支付宝" : (x.ClientBankAccount?.AccountClassify == 1 ? "平台" : "")))) : "",
});
return ApiResult.Success("", pagelist);
}
......@@ -94,7 +96,14 @@ namespace Mall.WebApi.Controllers.User
demodel.ClientBankAccount.CreateDate = DateTime.Now;
demodel.ClientBankAccount.RB_Branch_Id = Convert.ToInt32(Config.RB_Branch_Id);
demodel.ClientBankAccount.RB_Group_Id = 2;
demodel.ClientBankAccount.Type = Common.Enum.Finance.ClientTypeEnum.Other;
demodel.ClientBankAccount.CreateBy = Convert.ToInt32(Config.NetworkDirector);
if (demodel.ID > 0)
{
demodel.BankAccountId = demodel.ClientBankAccount.ID;
}
bool flag = supplierModule.AddOrUpdateSupplier(demodel);
if (flag)
return ApiResult.Success();
......@@ -140,6 +149,10 @@ namespace Mall.WebApi.Controllers.User
{
return ApiResult.Failed("请传递参数");
}
if (BackId <= 0)
{
return ApiResult.Failed("请传递参数");
}
bool flag = supplierModule.RemoveSupplier(Id, BackId);
if (flag)
{
......
......@@ -31,6 +31,8 @@
"NetworkDirector": 1756, //网络主管的id,用于新建供应商账户的时候的创建人
"RB_Branch_Id": 49, //所属公司id
"RebornDMC": "reborn_dmc",
"IncomeFinanceApi": "http://192.168.2.16:8083/api/Mall/InsertFinanceBatchForMallIn",
"FinanceKey": "FinanceMallInsertToERPViitto2020",
"RedisSetting": {
"RedisServer": "192.168.2.214",
"RedisPort": "6379",
......
......@@ -22,7 +22,7 @@ namespace Mall.WindowsService.Helper
LogHelper.Write("ClearOrder=====Start");
//Module.OrderModule.ClearOrderModule();
Module.FinanceModule.OrderIncomeFinanceModule();
LogHelper.Write("ClearOrder=====End");
Interlocked.Exchange(ref inTimer, 0);
......
......@@ -2,15 +2,36 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.Development.json" />
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mall.Common\Mall.Common.csproj" />
<ProjectReference Include="..\Mall.DataAccess\Mall.DataAccess.csproj" />
<ProjectReference Include="..\Mall.Model\Mall.Model.csproj" />
<ProjectReference Include="..\Mall.Repository\Mall.Repository.csproj" />
</ItemGroup>
</Project>
using Mall.Common;
using Mall.Common.Plugin;
using Mall.Model.Entity.Finance;
using Mall.Model.Extend.Finance;
using Mall.Model.Extend.Product;
using Mall.Repository.Finance;
using Mall.Repository.Product;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.WindowsService.Module
{
public class FinanceModule
{
/// <summary>
/// 财务单据规则
/// </summary>
private static RB_Finance_ConfigurineRepository financeConfigurineRepository = new RB_Finance_ConfigurineRepository();
/// <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 static RB_Goods_OrderDetailRepository goodsOrderDetailRepository = new RB_Goods_OrderDetailRepository();
/// <summary>
/// 订单收入单据
/// </summary>
/// <returns></returns>
public static bool OrderIncomeFinanceModule()
{
var flag = false;
try
{
//先查询规则
var financeConfigurineList = financeConfigurineRepository.GetList(new Model.Extend.Finance.RB_Finance_Configurine_Extend { Type = 1 });
//根据规则中的小程序,查询订单详情信息
if (financeConfigurineList != null && financeConfigurineList.Any())
{
foreach (var item in financeConfigurineList)
{
if (item.StartTime.HasValue && item.StartTime < System.DateTime.Now)//判断开始时间是否大于当前时间
{
//查询今天是否已经生成了财务单据
var addFinance = false;
DateTime startDate = System.DateTime.Now.AddDays(-1);
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 (item.StartTime.Value.AddDays(item.IntervalDay ?? 0).ToString("yyyy-MM-dd").Equals(System.DateTime.Now.ToString("yyyy-MM-dd")))//判断开始时间加上执行周期是否等于当前日期
{
startDate = item.StartTime.Value;
addFinance = true;
}
}
else
{
if (recordModel.CreateDate.Value.AddDays(item.IntervalDay ?? 0).ToString("yyyy-MM-dd").Equals(System.DateTime.Now.ToString("yyyy-MM-dd")))//判断最近一次执行的时间加上执行周期是否等于当前日期
{
startDate = recordModel.CreateDate.Value;
addFinance = true;
}
}
DateTime endDate = startDate.AddDays(item.IntervalDay ?? 0);//结束时间
if (addFinance)//满足今天执行的条件查询间隔周期的订单
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat($@" SELECT a.*,b.OrderNo from rb_goods_orderdetail as a LEFT JOIN rb_goods_order as b on a.OrderId=b.OrderId
where b.TenantId=1 and b.MallBaseId=1 and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{startDate}','%y-%m-%d')
and DATE_FORMAT(b.CreateDate,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') and b.OrderStatus in(2,3,4,5,6) ");
var goodsDetailList = goodsOrderDetailRepository.Get<RB_Goods_OrderDetail_Extend>(builder.ToString()).ToList();
var result = new List<RB_Goods_OrderDetail_Extend>();
RB_Finance_Record_Extend record = new RB_Finance_Record_Extend();
record.MallBaseId = item.MallBaseId;
record.TenantId = item.TenantId;
record.Type = 1;
record.CreateDate = System.DateTime.Now;
record.RecordDetailList = new List<RB_Finance_RecordDetail>();
foreach (var orderGoodsItem in goodsDetailList.Take(2))
{
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);
}
}
var detailList = result.Select(x => new
{
CostTypeId = x.FinanceType == 1 ? item.IncomeCostTypeId : item.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
});
var financeObj = new
{
CreateBy = Config.NetworkDirector,
IsPublic = item.IsPublic,
BType = item.AccountType,
AccountId = item.AccountId,
RB_Branch_Id = Config.RB_Branch_Id,
RemitterName = item.RemitterName,
TradeDate = System.DateTime.Now.ToString("yyyy-MM-dd"),
AccountNumber = System.DateTime.Now.ToString("yyyyMMdd"),
TemplateId = item.WorkFlowId,
OrderSource = 16,
Remark = System.DateTime.Now.ToString("yyyy年MM月dd日") + "自动生成财务单据",
detailList,
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
{
msg = financeObj,
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), "");
LogHelper.Write(apiResult);
}
}
}
}
}
catch (Exception ex)
{
LogHelper.Write(ex);
}
return flag;
}
}
}
......@@ -24,7 +24,7 @@ namespace Mall.WindowsService
LogHelper.Write("主服务开始运行......");
TimersHelper helper = new TimersHelper();
timer1 = new System.Timers.Timer();
timer1.Interval = 1000 * (60 * 0.3); //60分钟
timer1.Interval = 1000 * (60 * 0.5); //60分钟
timer1.Elapsed += new System.Timers.ElapsedEventHandler(helper.RevenueFinance);
timer1.Enabled = true;
}
......
{
"ConnectionStrings": {
"DefaultConnection": "server=192.168.2.214;user id=reborn;password=Reborn@2018;database=reborn_mall;CharSet=utf8; Convert Zero Datetime=true; ",
"DefaultConnectionPName": "MySql.Data.MySqlClient",
"FinanceConnection": "server=192.168.2.214;user id=reborn;password=Reborn@2018;database=reborn_finance;CharSet=utf8; Convert Zero Datetime=true; ",
"FinanceConnectionPName": "MySql.Data.MySqlClient"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"JwtSecretKey": "@VIITTOREBORN*2018",
"JwtExpirTime": 2592000,
"ApiExpirTime": 2592000,
"AllowedHosts": "*",
"OpenValidation": "False",
"UploadSiteUrl": "http://192.168.2.214:8120",
"ViewFileSiteUrl": "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com",
"ImKey": "b612b31e837c79c68f141aeb719d2b20",
"ImSecret": "66000451fb72",
"Mongo": "mongodb://192.168.2.214:27017",
"MongoDBName": "Mall",
"ProjectUrl": "D:/project/GitProject/tripfriend",
"DeveloperKitsPort": "63994",
"FirstPage": "pages/index/index.html",
"ByteDanceSendTemplate": "https://developer.toutiao.com/api/apps/game/template/send",
"sTenpayNotify": "http://mallapi.oytour.com/api/WeChatNotify/Notify", //微信回调地址
"NetworkDirector": 1756, //网络主管的id,用于新建供应商账户的时候的创建人
"RB_Branch_Id": 49, //所属公司id
"RebornDMC": "reborn_dmc",
"IncomeFinanceApi": "http://192.168.2.16:8083/api/Mall/InsertFinanceBatchForMallIn",
//"FinanceKey": "FinanceMallInsertToERPViitto2020",
"FinanceKey": "FinanceMallInsertToERPVi",
"RedisSetting": {
"RedisServer": "192.168.2.214",
"RedisPort": "6379",
"RedisPwd": "123456"
},
"VirtualDirectory": "WebFile",
"FileService": "2",
"InitializeImages": {
"GradeEntranceImage": "1234566778"
}
}
\ No newline at end of file
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